diff --git a/_sources/FontGen/FileDialogEx.cs b/_sources/FontGen/FileDialogEx.cs deleted file mode 100644 index 7778726..0000000 --- a/_sources/FontGen/FileDialogEx.cs +++ /dev/null @@ -1,519 +0,0 @@ -// ========================================================================== -// -// File: FileDialogEx.vb -// Location: Firefly.GUI -// Description: The extended file dialog class has compatibility issues under Win7 and is obsolete. Please use File Picker. -// Version: 2009.11.30. -// Copyright(C) F.R.C. -// -// ========================================================================== - -using System; -using System.Collections.Generic; -using System.Reflection; -using System.Windows.Forms; -using Microsoft.VisualBasic.CompilerServices; - -namespace FontGen -{ - - public partial class FileDialogEx - { - - #region modified properties - - protected bool IsSaveDialogValue; - public bool IsSaveDialog - { - get - { - return IsSaveDialogValue; - } - } - - public enum ModeSelectionEnum - { - File = 1, - Folder = 2, - FileWithFolder = 3 - } - - protected string InnerFilter; - protected ModeSelectionEnum ModeSelectionValue = ModeSelectionEnum.FileWithFolder; - public ModeSelectionEnum ModeSelection - { - get - { - return ModeSelectionValue; - } - set - { - switch (value) - { - case ModeSelectionEnum.File: - case ModeSelectionEnum.FileWithFolder: - { - if (ModeSelectionValue == ModeSelectionEnum.Folder) - { - Dialog.Filter = InnerFilter; - } - ModeSelectionValue = value; - break; - } - case ModeSelectionEnum.Folder: - { - InnerFilter = Dialog.Filter; - Dialog.Filter = "-| "; - ModeSelectionValue = value; - break; - } - - default: - { - throw new System.IO.InvalidDataException(); - } - } - } - } - - public bool CanSelectFiles - { - get - { - return Conversions.ToBoolean(ModeSelectionValue & ModeSelectionEnum.File); - } - } - - public bool CanSelectFolders - { - get - { - return Conversions.ToBoolean(ModeSelectionValue & ModeSelectionEnum.Folder); - } - } - - private bool MultiselectValue; - public bool Multiselect - { - get - { - return MultiselectValue; - } - set - { - MultiselectValue = value; - if (IsSaveDialog) - { - var mi = typeof(FileDialog).GetMethod("SetOption", BindingFlags.Instance | BindingFlags.InvokeMethod | BindingFlags.NonPublic | BindingFlags.Public); - // Friend Sub FileDialog.SetOption(ByVal [option] As Integer, ByVal value As Boolean) - mi.Invoke(SaveDialogValue, [0x200, value]); - } - // If Value Then - // Throw New NotSupportedException("Win7 has disabled this ability.") - // End If - else - { - OpenDialogValue.Multiselect = value; - } - } - } - - public string FileName - { - get - { - return Dialog.FileName; - } - set - { - Dialog.FileName = value; - } - } - - private List FileNamesValue = new List(); - public string[] FileNames - { - get - { - return FileNamesValue.ToArray(); - } - } - - /// It is only valid when used as an Open File Dialog, otherwise a Not Supported Exception will be thrown. - public string SafeFileName - { - get - { - if (IsSaveDialog) - throw new NotSupportedException(); - return OpenDialogValue.SafeFileName; - } - } - - private List SafeFileNamesValue = new List(); - /// It is only valid when used as an Open File Dialog, otherwise a Not Supported Exception will be thrown. - public string[] SafeFileNames - { - get - { - if (IsSaveDialog) - throw new NotSupportedException(); - return SafeFileNamesValue.ToArray(); - } - } - - #endregion - - #region FileDialogpublic method - - public bool AddExtension - { - get - { - return Dialog.AddExtension; - } - set - { - Dialog.AddExtension = value; - } - } - - public bool AutoUpgradeEnabled - { - get - { - return Dialog.AutoUpgradeEnabled; - } - set - { - Dialog.AutoUpgradeEnabled = value; - } - } - - public bool CheckFileExists - { - get - { - return Dialog.CheckFileExists; - } - set - { - Dialog.CheckFileExists = value; - } - } - - public bool CheckPathExists - { - get - { - return Dialog.CheckPathExists; - } - set - { - Dialog.CheckPathExists = value; - } - } - - public FileDialogCustomPlacesCollection CustomPlaces - { - get - { - return Dialog.CustomPlaces; - } - } - - public string DefaultExt - { - get - { - return Dialog.DefaultExt; - } - set - { - Dialog.DefaultExt = value; - } - } - - public bool DereferenceLinks - { - get - { - return Dialog.DereferenceLinks; - } - set - { - Dialog.DereferenceLinks = value; - } - } - - public string Filter - { - get - { - if (CanSelectFolders && !CanSelectFiles) - { - throw new InvalidOperationException(); - } - return Dialog.Filter; - } - set - { - if (CanSelectFolders && !CanSelectFiles) - { - throw new InvalidOperationException(); - } - Dialog.Filter = value; - } - } - - public int FilterIndex - { - get - { - return Dialog.FilterIndex; - } - set - { - Dialog.FilterIndex = value; - } - } - - public string InitialDirectory - { - get - { - return Dialog.InitialDirectory; - } - set - { - Dialog.InitialDirectory = value; - } - } - - public System.IO.Stream OpenFile() - { - if (IsSaveDialog) - { - return SaveDialogValue.OpenFile(); - } - else - { - return OpenDialogValue.OpenFile(); - } - } - - public void Reset() - { - Dialog.Reset(); - Multiselect = false; - } - - public bool RestoreDirectory - { - get - { - return Dialog.RestoreDirectory; - } - set - { - Dialog.RestoreDirectory = value; - } - } - - public bool ShowHelp - { - get - { - return Dialog.ShowHelp; - } - set - { - Dialog.ShowHelp = value; - } - } - - public bool SupportMultiDottedExtensions - { - get - { - return Dialog.SupportMultiDottedExtensions; - } - set - { - Dialog.SupportMultiDottedExtensions = value; - } - } - - public string Title - { - get - { - return Dialog.Title; - } - set - { - Dialog.Title = value; - } - } - - public bool ValidateNames - { - get - { - return Dialog.ValidateNames; - } - set - { - Dialog.ValidateNames = value; - } - } - - #endregion - - #region event parameters - - public class SelectionChangedEventArgs : EventArgs - { - - public SelectionChangedEventArgs(string FolderPath, string FilePath, string[] FileNames) - { - FolderPathValue = FolderPath; - FilePathValue = FilePath; - FileNamesValue = FileNames; - } - - protected string FolderPathValue; - public string FolderPath - { - get - { - return FolderPathValue; - } - } - - protected string FilePathValue; - public string FilePath - { - get - { - return FilePathValue; - } - } - - protected string[] FileNamesValue; - public string[] FileNames - { - get - { - return FileNamesValue; - } - } - } - - public class ButtonOpenClickEventArgs : SelectionChangedEventArgs - { - - public ButtonOpenClickEventArgs(string FolderPath, string FilePath, string[] FileNames, bool Cancel) : base(FolderPath, FilePath, FileNames) - { - CancelValue = Cancel; - } - - protected bool CancelValue; - public bool Cancel - { - get - { - return CancelValue; - } - set - { - CancelValue = value; - } - } - } - #endregion - - #region event - - private bool FileOKValue = false; - protected void mNativeDialog_ButtonOpenClick(object sender, ButtonOpenClickEventArgs e) - { - // If Not (EnableSelectFolders Or (IsSaveDialog AndAlso MultiselectValue)) Then Return - - Dialog.FileName = e.FilePath; - FileNamesValue.Clear(); - foreach (var f in e.FileNames) - FileNamesValue.Add(System.IO.Path.Combine(e.FolderPath, f)); - SafeFileNamesValue.Clear(); - SafeFileNamesValue.AddRange(e.FileNames); - - FileOKValue = true; - - var b = new System.ComponentModel.CancelEventArgs(); - FileOk?.Invoke(this, b); - e.Cancel = b.Cancel; - - if (b.Cancel) - { - FileOKValue = false; - } - } - - public event SelectionChangedClickEventHandler SelectionChangedClick; - - public delegate void SelectionChangedClickEventHandler(object sender, SelectionChangedEventArgs e); - protected void mNativeDialog_SelectionChangedClick(object sender, SelectionChangedEventArgs e) - { - Dialog.FileName = e.FilePath; - FileNamesValue.Clear(); - foreach (var f in e.FileNames) - FileNamesValue.Add(System.IO.Path.Combine(e.FolderPath, f)); - SafeFileNamesValue.Clear(); - SafeFileNamesValue.AddRange(e.FileNames); - - SelectionChangedClick?.Invoke(sender, e); - } - - public event FileOkEventHandler FileOk; - - public delegate void FileOkEventHandler(object sender, System.ComponentModel.CancelEventArgs e); - protected bool CancelValue; - protected void OpenDialogValue_FileOk(object sender, System.ComponentModel.CancelEventArgs e) - { - if (CanSelectFolders) - { - e.Cancel = CancelValue; - } - else - { - FileOk?.Invoke(this, e); - } - } - protected void SaveDialogValue_FileOk(object sender, System.ComponentModel.CancelEventArgs e) - { - if (CanSelectFolders || IsSaveDialog && MultiselectValue) - { - e.Cancel = CancelValue; - } - else - { - FileOk?.Invoke(this, e); - } - } - - public event HelpRequestEventHandler HelpRequest; - - public delegate void HelpRequestEventHandler(object sender, EventArgs e); - protected void OpenDialogValue_HelpRequest(object sender, EventArgs e) - { - HelpRequest?.Invoke(this, e); - } - protected void SaveDialogValue_HelpRequest(object sender, EventArgs e) - { - HelpRequest?.Invoke(this, e); - } - - #endregion - - } -} \ No newline at end of file diff --git a/_sources/FontGen/FileDialogInterop.cs b/_sources/FontGen/FileDialogInterop.cs deleted file mode 100644 index 55d1585..0000000 --- a/_sources/FontGen/FileDialogInterop.cs +++ /dev/null @@ -1,309 +0,0 @@ -// ========================================================================== -// -// File: FileDialogInterop.vb -// Location: Firefly.GUI -// Description: The extended file dialog class has compatibility issues under Win7 and is obsolete. Please use File Picker. -// Version: 2009.11.30. -// Copyright(C) F.R.C. -// -// ========================================================================== - - -using System; -using System.Collections.Generic; -using System.Runtime.InteropServices; -using System.Text; - -namespace FontGen -{ - - public static class FileDialogInterop - { - public delegate bool WndEnumProc(IntPtr hWnd, int lParam); - - [DllImport("user32.dll", EntryPoint = "SendMessageW", CharSet = CharSet.Unicode)] - public static extern IntPtr SendMessage(HandleRef hWnd, uint msg, IntPtr wParam, IntPtr lParam); - [DllImport("user32.dll", EntryPoint = "SendMessageW", CharSet = CharSet.Unicode)] - public static extern IntPtr SendMessage(HandleRef hWnd, uint msg, IntPtr wParam, StringBuilder lParam); - - [DllImport("user32.dll")] - public static extern IntPtr GetParent(HandleRef hWnd); - [DllImport("user32.dll", EntryPoint = "GetClassNameW", CharSet = CharSet.Unicode)] - public static extern int GetClassName(HandleRef hWnd, StringBuilder param, int length); - [DllImport("user32.dll", EntryPoint = "GetClassNameW")] - public static extern int GetDlgCtrlID(HandleRef hWnd); - [DllImport("user32.dll")] - public static extern bool EnumChildWindows(HandleRef hWndParent, WndEnumProc lpEnumFunc, IntPtr lParam); - - public static byte[][] IntPtrToItemIdList(IntPtr pNativeData) - { - var IdList = new List(); - while (true) - { - short Length = Marshal.ReadInt16(pNativeData); - pNativeData = new IntPtr(pNativeData.ToInt64() + 2L); - if (Length == 0) - { - break; - } - Length = (short)(Length - 2); - byte[] ID = new byte[Length]; - for (int i = 0, loopTo = Length - 1; i <= loopTo; i++) - { - ID[i] = Marshal.ReadByte(pNativeData); - pNativeData = new IntPtr(pNativeData.ToInt64() + 1L); - } - IdList.Add(ID); - } - return IdList.ToArray(); - } - } - - [StructLayout(LayoutKind.Sequential)] - public struct LVITEM - { - public uint mask; - public int iItem; - public int iSubItem; - public uint state; - public uint stateMask; - public IntPtr pszText; - public int cchTextMax; - public int iImage; - public IntPtr lParam; - public int iIndent; - public int iGroupId; - } - - public enum CommonDialogMessages - { - CDM_FIRST = 1024 + 100, - CDM_GETSPEC = CDM_FIRST + 0, - CDM_GETFILEPATH = CDM_FIRST + 1, - CDM_GETFOLDERPATH = CDM_FIRST + 2, - CDM_GETFOLDERIDLIST = CDM_FIRST + 3, - CDM_SETCONTROLTEXT = CDM_FIRST + 4, - CDM_HIDECONTROL = CDM_FIRST + 5, - CDM_SETDEFEXT = CDM_FIRST + 6 - } - - public enum ListViewMessages : uint - { - LVM_FIRST = 4096U, - // ListView messages - LVM_GETITEMCOUNT = LVM_FIRST + 4, - LVM_GETITEM = LVM_FIRST + 75 - } - - // Windows Messages - public enum Msg - { - WM_NULL = 0, - WM_CREATE = 1, - WM_DESTROY = 2, - WM_MOVE = 3, - WM_SIZE = 5, - WM_ACTIVATE = 6, - WM_SETFOCUS = 7, - WM_KILLFOCUS = 8, - WM_ENABLE = 10, - WM_SETREDRAW = 11, - WM_SETTEXT = 12, - WM_GETTEXT = 13, - WM_GETTEXTLENGTH = 14, - WM_PAINT = 15, - WM_CLOSE = 16, - WM_QUERYENDSESSION = 17, - WM_QUIT = 18, - WM_QUERYOPEN = 19, - WM_ERASEBKGND = 20, - WM_SYSCOLORCHANGE = 21, - WM_ENDSESSION = 22, - WM_SHOWWINDOW = 24, - WM_CTLCOLOR = 25, - WM_WININICHANGE = 26, - WM_SETTINGCHANGE = 26, - WM_DEVMODECHANGE = 27, - WM_ACTIVATEAPP = 28, - WM_FONTCHANGE = 29, - WM_TIMECHANGE = 30, - WM_CANCELMODE = 31, - WM_SETCURSOR = 32, - WM_MOUSEACTIVATE = 33, - WM_CHILDACTIVATE = 34, - WM_QUEUESYNC = 35, - WM_GETMINMAXINFO = 36, - WM_PAINTICON = 38, - WM_ICONERASEBKGND = 39, - WM_NEXTDLGCTL = 40, - WM_SPOOLERSTATUS = 42, - WM_DRAWITEM = 43, - WM_MEASUREITEM = 44, - WM_DELETEITEM = 45, - WM_VKEYTOITEM = 46, - WM_CHARTOITEM = 47, - WM_SETFONT = 48, - WM_GETFONT = 49, - WM_SETHOTKEY = 50, - WM_GETHOTKEY = 51, - WM_QUERYDRAGICON = 55, - WM_COMPAREITEM = 57, - WM_GETOBJECT = 61, - WM_COMPACTING = 65, - WM_COMMNOTIFY = 68, - WM_WINDOWPOSCHANGING = 70, - WM_WINDOWPOSCHANGED = 71, - WM_POWER = 72, - WM_COPYDATA = 74, - WM_CANCELJOURNAL = 75, - WM_NOTIFY = 78, - WM_INPUTLANGCHANGEREQUEST = 80, - WM_INPUTLANGCHANGE = 81, - WM_TCARD = 82, - WM_HELP = 83, - WM_USERCHANGED = 84, - WM_NOTIFYFORMAT = 85, - WM_CONTEXTMENU = 123, - WM_STYLECHANGING = 124, - WM_STYLECHANGED = 125, - WM_DISPLAYCHANGE = 126, - WM_GETICON = 127, - WM_SETICON = 128, - WM_NCCREATE = 129, - WM_NCDESTROY = 130, - WM_NCCALCSIZE = 131, - WM_NCHITTEST = 132, - WM_NCPAINT = 133, - WM_NCACTIVATE = 134, - WM_GETDLGCODE = 135, - WM_SYNCPAINT = 136, - WM_NCMOUSEMOVE = 160, - WM_NCLBUTTONDOWN = 161, - WM_NCLBUTTONUP = 162, - WM_NCLBUTTONDBLCLK = 163, - WM_NCRBUTTONDOWN = 164, - WM_NCRBUTTONUP = 165, - WM_NCRBUTTONDBLCLK = 166, - WM_NCMBUTTONDOWN = 167, - WM_NCMBUTTONUP = 168, - WM_NCMBUTTONDBLCLK = 169, - WM_NCXBUTTONDOWN = 171, - WM_NCXBUTTONUP = 172, - WM_NCXBUTTONDBLCLK = 173, - WM_KEYDOWN = 256, - WM_KEYUP = 257, - WM_CHAR = 258, - WM_DEADCHAR = 259, - WM_SYSKEYDOWN = 260, - WM_SYSKEYUP = 261, - WM_SYSCHAR = 262, - WM_SYSDEADCHAR = 263, - WM_KEYLAST = 264, - WM_IME_STARTCOMPOSITION = 269, - WM_IME_ENDCOMPOSITION = 270, - WM_IME_COMPOSITION = 271, - WM_IME_KEYLAST = 271, - WM_INITDIALOG = 272, - WM_COMMAND = 273, - WM_SYSCOMMAND = 274, - WM_TIMER = 275, - WM_HSCROLL = 276, - WM_VSCROLL = 277, - WM_INITMENU = 278, - WM_INITMENUPOPUP = 279, - WM_MENUSELECT = 287, - WM_MENUCHAR = 288, - WM_ENTERIDLE = 289, - WM_MENURBUTTONUP = 290, - WM_MENUDRAG = 291, - WM_MENUGETOBJECT = 292, - WM_UNINITMENUPOPUP = 293, - WM_MENUCOMMAND = 294, - WM_CTLCOLORMSGBOX = 306, - WM_CTLCOLOREDIT = 307, - WM_CTLCOLORLISTBOX = 308, - WM_CTLCOLORBTN = 309, - WM_CTLCOLORDLG = 310, - WM_CTLCOLORSCROLLBAR = 311, - WM_CTLCOLORSTATIC = 312, - WM_MOUSEMOVE = 512, - WM_LBUTTONDOWN = 513, - WM_LBUTTONUP = 514, - WM_LBUTTONDBLCLK = 515, - WM_RBUTTONDOWN = 516, - WM_RBUTTONUP = 517, - WM_RBUTTONDBLCLK = 518, - WM_MBUTTONDOWN = 519, - WM_MBUTTONUP = 520, - WM_MBUTTONDBLCLK = 521, - WM_MOUSEWHEEL = 522, - WM_XBUTTONDOWN = 523, - WM_XBUTTONUP = 524, - WM_XBUTTONDBLCLK = 525, - WM_PARENTNOTIFY = 528, - WM_ENTERMENULOOP = 529, - WM_EXITMENULOOP = 530, - WM_NEXTMENU = 531, - WM_SIZING = 532, - WM_CAPTURECHANGED = 533, - WM_MOVING = 534, - WM_DEVICECHANGE = 537, - WM_MDICREATE = 544, - WM_MDIDESTROY = 545, - WM_MDIACTIVATE = 546, - WM_MDIRESTORE = 547, - WM_MDINEXT = 548, - WM_MDIMAXIMIZE = 549, - WM_MDITILE = 550, - WM_MDICASCADE = 551, - WM_MDIICONARRANGE = 552, - WM_MDIGETACTIVE = 553, - WM_MDISETMENU = 560, - WM_ENTERSIZEMOVE = 561, - WM_EXITSIZEMOVE = 562, - WM_DROPFILES = 563, - WM_MDIREFRESHMENU = 564, - WM_IME_SETCONTEXT = 641, - WM_IME_NOTIFY = 642, - WM_IME_CONTROL = 643, - WM_IME_COMPOSITIONFULL = 644, - WM_IME_SELECT = 645, - WM_IME_CHAR = 646, - WM_IME_REQUEST = 648, - WM_IME_KEYDOWN = 656, - WM_IME_KEYUP = 657, - WM_MOUSEHOVER = 673, - WM_MOUSELEAVE = 675, - WM_CUT = 768, - WM_COPY = 769, - WM_PASTE = 770, - WM_CLEAR = 771, - WM_UNDO = 772, - WM_RENDERFORMAT = 773, - WM_RENDERALLFORMATS = 774, - WM_DESTROYCLIPBOARD = 775, - WM_DRAWCLIPBOARD = 776, - WM_PAINTCLIPBOARD = 777, - WM_VSCROLLCLIPBOARD = 778, - WM_SIZECLIPBOARD = 779, - WM_ASKCBFORMATNAME = 780, - WM_CHANGECBCHAIN = 781, - WM_HSCROLLCLIPBOARD = 782, - WM_QUERYNEWPALETTE = 783, - WM_PALETTEISCHANGING = 784, - WM_PALETTECHANGED = 785, - WM_HOTKEY = 786, - WM_PRINT = 791, - WM_PRINTCLIENT = 792, - WM_THEME_CHANGED = 794, - WM_HANDHELDFIRST = 856, - WM_HANDHELDLAST = 863, - WM_AFXFIRST = 864, - WM_AFXLAST = 895, - WM_PENWINFIRST = 896, - WM_PENWINLAST = 911, - WM_APP = 32768, - WM_USER = 1024, - WM_REFLECT = WM_USER + 7168 - } -} \ No newline at end of file diff --git a/_sources/FontGen/FileDialogNative.cs b/_sources/FontGen/FileDialogNative.cs deleted file mode 100644 index 7036d45..0000000 --- a/_sources/FontGen/FileDialogNative.cs +++ /dev/null @@ -1,634 +0,0 @@ -// ========================================================================== -// -// File: FileDialogNative.vb -// Location: Firefly.GUI -// Description: Extended file dialog class, there are compatibility issues under Win7, it is obsolete, please use File Picker -// This file uses the method mentioned in http://www.codeproject.com/KB/dialog/Open File Dialog Ex.aspx -// Known issue 1: Hidden extension files such as shortcuts cannot be processed correctly -// Known issue 2: Unable to automatically enter the folder when pressing Enter -// Version: 2009.11.30. -// Copyright(C) F.R.C. -// -// ========================================================================== - - -using System; -using System.Collections.Generic; -using System.IO; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using System.Text; -using System.Windows.Forms; -using Firefly; -using Microsoft.VisualBasic.CompilerServices; - -namespace FontGen -{ - - public partial class FileDialogEx : Form - { - private OpenFileDialog _OpenDialogValue; - - protected virtual OpenFileDialog OpenDialogValue - { - [MethodImpl(MethodImplOptions.Synchronized)] - get - { - return _OpenDialogValue; - } - - [MethodImpl(MethodImplOptions.Synchronized)] - set - { - if (_OpenDialogValue != null) - { - _OpenDialogValue.FileOk -= OpenDialogValue_FileOk; - _OpenDialogValue.HelpRequest -= OpenDialogValue_HelpRequest; - } - - _OpenDialogValue = value; - if (_OpenDialogValue != null) - { - _OpenDialogValue.FileOk += OpenDialogValue_FileOk; - _OpenDialogValue.HelpRequest += OpenDialogValue_HelpRequest; - } - } - } - private SaveFileDialog _SaveDialogValue; - - protected virtual SaveFileDialog SaveDialogValue - { - [MethodImpl(MethodImplOptions.Synchronized)] - get - { - return _SaveDialogValue; - } - - [MethodImpl(MethodImplOptions.Synchronized)] - set - { - if (_SaveDialogValue != null) - { - _SaveDialogValue.FileOk -= SaveDialogValue_FileOk; - _SaveDialogValue.HelpRequest -= SaveDialogValue_HelpRequest; - } - - _SaveDialogValue = value; - if (_SaveDialogValue != null) - { - _SaveDialogValue.FileOk += SaveDialogValue_FileOk; - _SaveDialogValue.HelpRequest += SaveDialogValue_HelpRequest; - } - } - } - - protected internal bool SetIntializeFileNameToNull = false; - - private FileDialogBase _mNativeDialog; - - protected virtual FileDialogBase mNativeDialog - { - [MethodImpl(MethodImplOptions.Synchronized)] - get - { - return _mNativeDialog; - } - - [MethodImpl(MethodImplOptions.Synchronized)] - set - { - if (_mNativeDialog != null) - { - _mNativeDialog.ButtonOpenClick -= mNativeDialog_ButtonOpenClick; - _mNativeDialog.SelectionChangedClick -= mNativeDialog_SelectionChangedClick; - } - - _mNativeDialog = value; - - if (_mNativeDialog != null) - { - _mNativeDialog.ButtonOpenClick += mNativeDialog_ButtonOpenClick; - _mNativeDialog.SelectionChangedClick += mNativeDialog_SelectionChangedClick; - } - } - } - protected IntPtr mDialogHandle = IntPtr.Zero; - protected override void WndProc(ref Message m) - { - if (m.Msg == (int)Msg.WM_ACTIVATE) - { - if (mDialogHandle != m.LParam) - { - var ClassNameSB = new StringBuilder(256); - FileDialogInterop.GetClassName(new HandleRef(this, m.LParam), ClassNameSB, ClassNameSB.Capacity); - string ClassName = ClassNameSB.ToString(); - - if (ClassName == "#32770") - { - mDialogHandle = m.LParam; - if (mNativeDialog is not null) - { - SetIntializeFileNameToNull = mNativeDialog.SetIntializeFileNameToNull; - mNativeDialog.Dispose(); - } - mNativeDialog = new FileDialogBase(mDialogHandle, this); - mNativeDialog.SetIntializeFileNameToNull = SetIntializeFileNameToNull; - } - } - } - base.WndProc(ref m); - } - - protected FileDialog Dialog - { - get - { - if (IsSaveDialog) - return SaveDialogValue; - return OpenDialogValue; - } - } - - public new DialogResult ShowDialog() - { - var returnDialogResult = DialogResult.Cancel; - FileOKValue = false; - Show(); - int HideFileExt = Conversions.ToInteger(Microsoft.Win32.Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced").GetValue("HideFileExt", 1)); - if (HideFileExt != 0) - { - Microsoft.Win32.Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced", true).SetValue("HideFileExt", 0); - } - - if (FileName.EndsWith(Conversions.ToString(Path.DirectorySeparatorChar))) - { - FileName = Path.Combine(FileName, Path.GetFileName(FileName.TrimEnd(Path.DirectorySeparatorChar))); - mNativeDialog.SetIntializeFileNameToNull = true; - } - - returnDialogResult = Dialog.ShowDialog(this); - - if (HideFileExt != 0) - { - Microsoft.Win32.Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced", true).SetValue("HideFileExt", 1); - } - - Hide(); - - if (FileOKValue) - return DialogResult.OK; - return returnDialogResult; - } - - protected class FileDialogBase : NativeWindow, IDisposable - { - - protected FileDialogEx mSourceControl; - protected IntPtr mFileDialogHandle; - protected IntPtr mListViewHandle; - protected IntPtr mEditFileNameHandle; - - protected internal bool SetIntializeFileNameToNull = false; - - public FileDialogBase(IntPtr Handle, FileDialogEx SourceControl) - { - mFileDialogHandle = Handle; - mSourceControl = SourceControl; - AssignHandle(mFileDialogHandle); - } - - public event ButtonOpenClickEventHandler ButtonOpenClick; - - public delegate void ButtonOpenClickEventHandler(object sender, ButtonOpenClickEventArgs e); - public event SelectionChangedClickEventHandler SelectionChangedClick; - - public delegate void SelectionChangedClickEventHandler(object sender, SelectionChangedEventArgs e); - - protected bool FileDialogEnumWindowCallBack(IntPtr hWnd, int lParam) - { - var ClassNameSB = new StringBuilder(256); - FileDialogInterop.GetClassName(new HandleRef(this, hWnd), ClassNameSB, ClassNameSB.Capacity); - string ClassName = ClassNameSB.ToString(); - int ControlId = FileDialogInterop.GetDlgCtrlID(new HandleRef(this, hWnd)); - - if (ClassName == "SysListView32") - { - mListViewHandle = hWnd; - } - else if (ClassName == "Edit") - { - mEditFileNameHandle = hWnd; - } - - return true; - } - - protected void FileDialogEnumWindow() - { - FileDialogInterop.EnumChildWindows(new HandleRef(this, mFileDialogHandle), FileDialogEnumWindowCallBack, new IntPtr(0)); - } - - protected string GetFilePath() - { - var Length = FileDialogInterop.SendMessage(new HandleRef(this, mFileDialogHandle), (uint)CommonDialogMessages.CDM_GETFILEPATH, IntPtr.Zero, IntPtr.Zero); - if (Length.ToInt32() < 0) - return ""; - - var FilePath = new StringBuilder(Length.ToInt32()); - FileDialogInterop.SendMessage(new HandleRef(this, mFileDialogHandle), (uint)CommonDialogMessages.CDM_GETFILEPATH, new IntPtr(FilePath.Capacity), FilePath); - string t = FilePath.ToString(); - if (t.Contains("\"")) - { - int a = t.IndexOf("\""); - int b = t.IndexOf("\"", a + 1); - t = t.Substring(0, a) + t.Substring(a + 1, b - a - 1); - } - return t; - } - - protected string GetFolderPath() - { - var Length = FileDialogInterop.SendMessage(new HandleRef(this, mFileDialogHandle), (uint)CommonDialogMessages.CDM_GETFOLDERPATH, IntPtr.Zero, IntPtr.Zero); - if (Length.ToInt32() < 0) - return ""; - - var FolderPath = new StringBuilder(Length.ToInt32()); - FileDialogInterop.SendMessage(new HandleRef(this, mFileDialogHandle), (uint)CommonDialogMessages.CDM_GETFOLDERPATH, new IntPtr(FolderPath.Capacity), FolderPath); - return FolderPath.ToString(); - } - - protected string[] GetFileNames() - { - var Length = FileDialogInterop.SendMessage(new HandleRef(this, mListViewHandle), (uint)ListViewMessages.LVM_GETITEMCOUNT, IntPtr.Zero, IntPtr.Zero); - - string FolderPath = ""; - if (!mSourceControl.CanSelectFolders) - { - FolderPath = GetFolderPath(); - } - - var FileNames = new List(); - string FileName = ""; - for (int n = 0, loopTo = (int)(Length.ToInt64() - 1L); n <= loopTo; n++) - { - var NamePtr = Marshal.AllocHGlobal(2048 * 4); - var Item = new LVITEM() { mask =uint.MaxValue, iItem = n, iSubItem = 0, state = 0U, stateMask = uint.MaxValue, pszText = NamePtr, cchTextMax = 2048 }; - var p = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(LVITEM)) * 4); - Marshal.StructureToPtr(Item, p, true); - var Successful = FileDialogInterop.SendMessage(new HandleRef(this, mListViewHandle), (int)ListViewMessages.LVM_GETITEM, new IntPtr(Marshal.SizeOf(typeof(LVITEM))), p); - Item = (LVITEM)Marshal.PtrToStructure(p, typeof(LVITEM)); - Marshal.FreeHGlobal(p); - string Name = ""; - if (Item.pszText != new IntPtr(-1)) - { - Name = Marshal.PtrToStringUni(NamePtr); - } - Marshal.FreeHGlobal(NamePtr); - - if (Successful != IntPtr.Zero) - continue; - - // state - // LVIS_FOCUSED 0x0001 - // LVIS_SELECTED 0x0002 - bool Focused = Conversions.ToBoolean(Item.state & 1L); - bool Selected = Conversions.ToBoolean(Item.state & 2L); - - if (!string.IsNullOrEmpty(Name)) - { - // System.Console.WriteLine("Cap " & Name & " " & Focused & " " & Selected) - if (!mSourceControl.CanSelectFiles) - { - if (File.Exists(Path.Combine(FolderPath, Name))) - continue; - } - if (!mSourceControl.CanSelectFolders) - { - if (Directory.Exists(Path.Combine(FolderPath, Name))) - continue; - } - - if (Selected) - FileNames.Add(Name); - if (Focused) - FileName = Name; - } - else - { - // System.Console.WriteLine("Cap " & Focused & " " & Selected) - } - } - - if (!string.IsNullOrEmpty(FileName) && FileNames.Contains(FileName)) - { - FileNames.Remove(FileName); - FileNames.Insert(0, FileName); - } - - // If FileNames.Count = 0 Then - // Console.WriteLine("Cap " & FileNames.Count & " " & Length.ToInt64) - // End If - - return FileNames.ToArray(); - } - - protected string GetPathFromFolderPath(string FilePath, string FolderPath) - { - if ((FilePath ?? "") == (FolderPath ?? "") && !FilePath.EndsWith(Conversions.ToString(Path.DirectorySeparatorChar))) - { - if (string.IsNullOrEmpty(FilePath)) - return FilePath; - return FilePath + Path.DirectorySeparatorChar; - } - return FilePath; - } - - protected string GetEditFileNameText() - { - var TextLength = FileDialogInterop.SendMessage(new HandleRef(this, mEditFileNameHandle), (uint)Msg.WM_GETTEXTLENGTH, IntPtr.Zero, IntPtr.Zero); - var Text = new StringBuilder(TextLength.ToInt32() + 2); - FileDialogInterop.SendMessage(new HandleRef(this, mEditFileNameHandle), (uint)Msg.WM_GETTEXT, new IntPtr(Text.Capacity), Text); - - return Text.ToString(); - } - - protected string[] GetEditFileNames() - { - string Text = GetEditFileNameText(); - if (Text is null || string.IsNullOrEmpty(Text.Trim())) - return []; - if (!Text.Contains("\"")) - { - return [Text]; - } - - var FileNames = new List(); - var FileName = new StringBuilder(); - bool Odd = false; - foreach (var c in Text) - { - if (Conversions.ToString(c) == "\"") - { - Odd = !Odd; - if (!Odd) - { - FileNames.Add(FileName.ToString()); - FileName = new StringBuilder(); - } - } - else if (Odd) - { - FileName.Append(c); - } - } - if (Odd) - throw new InvalidCastException(); - - return FileNames.ToArray(); - } - - protected void SetEditFileNames(string[] FileNames) - { - StringBuilder sb; - if (FileNames is not null) - { - if (FileNames.Length == 1) - { - sb = new StringBuilder(FileNames[0]); - } - else - { - string[] Names = (string[])FileNames.Clone(); - for (int n = 0, loopTo = Names.Length - 1; n <= loopTo; n++) - Names[n] = "\"" + Names[n] + "\""; - - sb = new StringBuilder(string.Join(" ", Names)); - } - } - else - { - sb = new StringBuilder(); - } - FileDialogInterop.SendMessage(new HandleRef(this, mEditFileNameHandle), (uint)Msg.WM_SETTEXT, IntPtr.Zero, sb); - } - - protected enum AfterButtonOpenClicked - { - None = 0, - RefreshSelection = 1, - InternalMessageHandling = 2 - } - - protected AfterButtonOpenClicked OnButtonOpenClicked(ref Message m) - { - // If mSourceControl.EnableSelectFolders OrElse (mSourceControl.IsSaveDialog AndAlso mSourceControl.MultiselectValue) Then - FileDialogEnumWindow(); - - string FilePath = GetFilePath(); - string FolderPath = GetFolderPath(); - string[] FileNames = null; - - try - { - FileNames = GetEditFileNames(); - } - catch (Exception ex) - { - return AfterButtonOpenClicked.RefreshSelection | AfterButtonOpenClicked.InternalMessageHandling; - } - - if (FileNames.Length == 0) - { - if (!mSourceControl.CanSelectFolders) - return AfterButtonOpenClicked.RefreshSelection | AfterButtonOpenClicked.InternalMessageHandling; - - FilePath = GetPathFromFolderPath(FilePath, FolderPath); - FileNames = [FolderPath]; - var b = new ButtonOpenClickEventArgs(FolderPath, FilePath, FileNames, false); - ButtonOpenClick?.Invoke(this, b); - mSourceControl.CancelValue = b.Cancel; - if (!b.Cancel) - { - var argm = new Message() { Msg = (int)Msg.WM_COMMAND, WParam = new IntPtr(2), LParam = m.LParam, HWnd = m.HWnd, Result = IntPtr.Zero }; - base.WndProc(ref argm); - return AfterButtonOpenClicked.None; - } - } - - FilePath = GetPathFromFolderPath(FilePath, FolderPath); - - char[] Invailds = Path.GetInvalidPathChars(); - foreach (var f in FileNames) - { - foreach (var c in Invailds) - { - if (string.IsNullOrEmpty(f) || f.Contains(Conversions.ToString(c))) - return AfterButtonOpenClicked.None; - } - } - - if (mSourceControl.CheckPathExists) - { - foreach (var f in FileNames) - { - if (string.IsNullOrEmpty(f)) - return AfterButtonOpenClicked.None; - if (!Directory.Exists(Path.Combine(FolderPath, Path.GetDirectoryName(f)))) - return AfterButtonOpenClicked.None; - } - } - - if (mSourceControl.CheckFileExists) - { - switch (mSourceControl.ModeSelection) - { - case ModeSelectionEnum.File: - { - foreach (var f in FileNames) - { - if (!File.Exists(Path.Combine(FolderPath, f))) - return AfterButtonOpenClicked.None; - } - - break; - } - case ModeSelectionEnum.Folder: - { - foreach (var f in FileNames) - { - if (!Directory.Exists(Path.Combine(FolderPath, f))) - return AfterButtonOpenClicked.None; - } - - break; - } - case ModeSelectionEnum.FileWithFolder: - { - foreach (var f in FileNames) - { - if (!(File.Exists(Path.Combine(FolderPath, f)) || Directory.Exists(Path.Combine(FolderPath, f)))) - return AfterButtonOpenClicked.None; - } - - break; - } - } - } - - var e = new ButtonOpenClickEventArgs(FolderPath, FilePath, FileNames, false); - ButtonOpenClick?.Invoke(this, e); - mSourceControl.CancelValue = e.Cancel; - if (!e.Cancel) - { - var argm1 = new Message() { Msg = (int)Msg.WM_COMMAND, WParam = new IntPtr(2), LParam = m.LParam, HWnd = m.HWnd, Result = IntPtr.Zero }; - base.WndProc(ref argm1); - return AfterButtonOpenClicked.None; - } - // End If - - return AfterButtonOpenClicked.RefreshSelection | AfterButtonOpenClicked.InternalMessageHandling; - } - - protected override void WndProc(ref Message m) - { - if (m.Msg == (int)Msg.WM_COMMAND) - { - int ControlId = (int)(m.WParam.ToInt64() & 0xFFFFL); - int Notification = (int)(m.WParam.ToInt64() >> 16 & 0xFFFFL); - if (ControlId == 1 && Notification == 0) // ButtonOpen, BN_CLICKED - { - // System.Console.WriteLine("{0} : {1}, {2}, {3}", "FileDialogBase", DirectCast(m.Msg, Msg), m.LParam, m.WParam) - // System.Console.WriteLine(" {0}, {1}", ControlId, Notification) - - var r = OnButtonOpenClicked(ref m); - switch (r) - { - case AfterButtonOpenClicked.None: - { - return; - } - case AfterButtonOpenClicked.RefreshSelection | AfterButtonOpenClicked.InternalMessageHandling: - { - break; - } - case AfterButtonOpenClicked.InternalMessageHandling: - { - base.WndProc(ref m); - return; - } - - default: - { - throw new InvalidDataException(); - } - } - } - } - - switch (m.Msg) - { - case 1324: - { - FileDialogEnumWindow(); - - string FilePath; - string FolderPath; - string[] FileNames; - try - { - FilePath = GetFilePath(); - FolderPath = GetFolderPath(); - FileNames = GetFileNames(); - if (FileNames.Length == 0 && (FilePath ?? "") != (FolderPath ?? "")) - { - FileNames = [FileNameHandling.GetFileName(FilePath)]; - } - FilePath = GetPathFromFolderPath(FilePath, FolderPath); - } - catch (Exception ex) - { - break; - } - - FileDialogEnumWindow(); - - if (SetIntializeFileNameToNull) - { - SetEditFileNames([]); - SetIntializeFileNameToNull = false; - } - else if (mSourceControl.MultiselectValue) - { - SetEditFileNames(FileNames); - } - else if (FileNames.Length > 1) - { - SetEditFileNames([Path.GetFileName(FilePath)]); - } - else if (FileNames.Length > 0) - { - SetEditFileNames(FileNames); - } - - var b = new SelectionChangedEventArgs(FolderPath, FilePath, FileNames); - SelectionChangedClick?.Invoke(this, b); - break; - } - } - base.WndProc(ref m); - } - - private bool _Dispose_Disposed = false; - - public void Dispose() - { - if (!_Dispose_Disposed) - { - ReleaseHandle(); - _Dispose_Disposed = true; - } - GC.SuppressFinalize(this); - } - } - } -} \ No newline at end of file diff --git a/_sources/FontGen/FilePicker.Designer.cs b/_sources/FontGen/FilePicker.Designer.cs deleted file mode 100644 index 964e7dc..0000000 --- a/_sources/FontGen/FilePicker.Designer.cs +++ /dev/null @@ -1,244 +0,0 @@ - -namespace FontGen -{ - [Microsoft.VisualBasic.CompilerServices.DesignerGenerated()] - public partial class FilePicker : System.Windows.Forms.Form - { - - // Form 重写 Dispose,以清理组件列表。 - [System.Diagnostics.DebuggerNonUserCode()] - protected override void Dispose(bool disposing) - { - try - { - if (disposing && components is not null) - { - components.Dispose(); - } - } - finally - { - base.Dispose(disposing); - } - } - - // Windows 窗体设计器所必需的 - private System.ComponentModel.IContainer components; - - // 注意: 以下过程是 Windows 窗体设计器所必需的 - // 可以使用 Windows 窗体设计器修改它。 - // 不要使用代码编辑器修改它。 - [System.Diagnostics.DebuggerStepThrough()] - private void InitializeComponent() - { - Button_Select = new System.Windows.Forms.Button(); - Button_Select.Click += new System.EventHandler(Button_Select_Click); - Button_Cancel = new System.Windows.Forms.Button(); - Button_Cancel.Click += new System.EventHandler(Button_Cancel_Click); - Button_Enter = new System.Windows.Forms.Button(); - Button_Enter.Click += new System.EventHandler(Button_Enter_Click); - FileListView = new System.Windows.Forms.ListView(); - FileListView.RetrieveVirtualItem += new System.Windows.Forms.RetrieveVirtualItemEventHandler(FileListView_RetrieveVirtualItem); - FileListView.ColumnClick += new System.Windows.Forms.ColumnClickEventHandler(FileListView_ColumnClick); - FileListView.Enter += new System.EventHandler(FileListView_Enter); - FileListView.ItemActivate += new System.EventHandler(FileListView_ItemActivate); - FileListView.KeyDown += new System.Windows.Forms.KeyEventHandler(FileListView_KeyDown); - FileListView.SelectedIndexChanged += new System.EventHandler(FileListView_SelectedIndexChanged); - ColumnHeader_Name = new System.Windows.Forms.ColumnHeader(); - ColumnHeader_Length = new System.Windows.Forms.ColumnHeader(); - ColumnHeader_Type = new System.Windows.Forms.ColumnHeader(); - ColumnHeader_ModifyTime = new System.Windows.Forms.ColumnHeader(); - ColumnHeader_CreateTime = new System.Windows.Forms.ColumnHeader(); - ComboBox_FileName = new System.Windows.Forms.ComboBox(); - ComboBox_FileName.Enter += new System.EventHandler(ComboBox_FileName_Enter); - ComboBox_FileName.TextChanged += new System.EventHandler(ComboBox_FileName_TextChanged); - Label_FileName = new System.Windows.Forms.Label(); - ComboBox_Filter = new System.Windows.Forms.ComboBox(); - ComboBox_Filter.SelectedIndexChanged += new System.EventHandler(ComboBox_Filter_SelectedIndexChanged); - Label_Filter = new System.Windows.Forms.Label(); - ComboBox_Directory = new System.Windows.Forms.ComboBox(); - ComboBox_Directory.SelectedIndexChanged += new System.EventHandler(ComboBox_Directory_SelectedIndexChanged); - ComboBox_Directory.Enter += new System.EventHandler(ComboBox_Directory_Enter); - Label_Directory = new System.Windows.Forms.Label(); - SuspendLayout(); - // - // Button_Select - // - Button_Select.Anchor = System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right; - Button_Select.Location = new System.Drawing.Point(415, 216); - Button_Select.Name = "Button_Select"; - Button_Select.Size = new System.Drawing.Size(67, 21); - Button_Select.TabIndex = 6; - Button_Select.Text = "选定(&S)"; - // - // Button_Cancel - // - Button_Cancel.Anchor = System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right; - Button_Cancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; - Button_Cancel.Location = new System.Drawing.Point(415, 242); - Button_Cancel.Name = "Button_Cancel"; - Button_Cancel.Size = new System.Drawing.Size(67, 21); - Button_Cancel.TabIndex = 9; - Button_Cancel.Text = "取消"; - // - // Button_Enter - // - Button_Enter.Anchor = System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right; - Button_Enter.Location = new System.Drawing.Point(415, 11); - Button_Enter.Name = "Button_Enter"; - Button_Enter.Size = new System.Drawing.Size(67, 21); - Button_Enter.TabIndex = 2; - Button_Enter.Text = "进入(&E)"; - // - // FileListView - // - FileListView.AllowColumnReorder = true; - FileListView.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right; - - FileListView.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { ColumnHeader_Name, ColumnHeader_Length, ColumnHeader_Type, ColumnHeader_ModifyTime, ColumnHeader_CreateTime }); - FileListView.FullRowSelect = true; - FileListView.Location = new System.Drawing.Point(14, 38); - FileListView.Name = "FileListView"; - FileListView.ShowGroups = false; - FileListView.Size = new System.Drawing.Size(468, 171); - FileListView.TabIndex = 3; - FileListView.UseCompatibleStateImageBehavior = false; - FileListView.View = System.Windows.Forms.View.Details; - FileListView.VirtualMode = true; - // - // ColumnHeader_Name - // - ColumnHeader_Name.Text = "名称"; - ColumnHeader_Name.Width = 300; - // - // ColumnHeader_Length - // - ColumnHeader_Length.Text = "大小"; - ColumnHeader_Length.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; - // - // ColumnHeader_Type - // - ColumnHeader_Type.Text = "类型"; - ColumnHeader_Type.Width = 110; - // - // ColumnHeader_ModifyTime - // - ColumnHeader_ModifyTime.Text = "修改时间"; - ColumnHeader_ModifyTime.Width = 110; - // - // ColumnHeader_CreateTime - // - ColumnHeader_CreateTime.Text = "创建时间"; - ColumnHeader_CreateTime.Width = 110; - // - // ComboBox_FileName - // - ComboBox_FileName.Anchor = System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right; - ComboBox_FileName.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.Suggest; - ComboBox_FileName.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.FileSystem; - ComboBox_FileName.FormattingEnabled = true; - ComboBox_FileName.Location = new System.Drawing.Point(112, 216); - ComboBox_FileName.Name = "ComboBox_FileName"; - ComboBox_FileName.Size = new System.Drawing.Size(297, 20); - ComboBox_FileName.TabIndex = 5; - // - // Label_FileName - // - Label_FileName.Anchor = System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left; - Label_FileName.AutoSize = true; - Label_FileName.Location = new System.Drawing.Point(12, 219); - Label_FileName.Name = "Label_FileName"; - Label_FileName.Size = new System.Drawing.Size(65, 12); - Label_FileName.TabIndex = 4; - Label_FileName.Text = "文件名(&N):"; - // - // ComboBox_Filter - // - ComboBox_Filter.Anchor = System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right; - ComboBox_Filter.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - ComboBox_Filter.FormattingEnabled = true; - ComboBox_Filter.Location = new System.Drawing.Point(112, 243); - ComboBox_Filter.Name = "ComboBox_Filter"; - ComboBox_Filter.Size = new System.Drawing.Size(297, 20); - ComboBox_Filter.TabIndex = 8; - // - // Label_Filter - // - Label_Filter.Anchor = System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left; - Label_Filter.AutoSize = true; - Label_Filter.Location = new System.Drawing.Point(12, 246); - Label_Filter.Name = "Label_Filter"; - Label_Filter.Size = new System.Drawing.Size(77, 12); - Label_Filter.TabIndex = 7; - Label_Filter.Text = "文件类型(&T):"; - // - // ComboBox_Directory - // - ComboBox_Directory.Anchor = System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right; - ComboBox_Directory.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.Suggest; - ComboBox_Directory.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.FileSystemDirectories; - ComboBox_Directory.FormattingEnabled = true; - ComboBox_Directory.Location = new System.Drawing.Point(112, 12); - ComboBox_Directory.Name = "ComboBox_Directory"; - ComboBox_Directory.Size = new System.Drawing.Size(297, 20); - ComboBox_Directory.TabIndex = 1; - // - // Label_Directory - // - Label_Directory.Anchor = System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left; - Label_Directory.AutoSize = true; - Label_Directory.Location = new System.Drawing.Point(12, 15); - Label_Directory.Name = "Label_Directory"; - Label_Directory.Size = new System.Drawing.Size(77, 12); - Label_Directory.TabIndex = 0; - Label_Directory.Text = "查找范围(&I):"; - // - // FilePicker - // - AutoScaleDimensions = new System.Drawing.SizeF(6.0f, 12.0f); - AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - CancelButton = Button_Cancel; - ClientSize = new System.Drawing.Size(494, 275); - Controls.Add(Button_Enter); - Controls.Add(Label_Filter); - Controls.Add(Label_Directory); - Controls.Add(Label_FileName); - Controls.Add(ComboBox_Filter); - Controls.Add(ComboBox_Directory); - Controls.Add(ComboBox_FileName); - Controls.Add(FileListView); - Controls.Add(Button_Cancel); - Controls.Add(Button_Select); - FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; - KeyPreview = true; - MaximizeBox = false; - MinimizeBox = false; - Name = "FilePicker"; - ShowInTaskbar = false; - StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - Text = "FilePicker"; - Load += new System.EventHandler(FilePicker_Load); - Shown += new System.EventHandler(FilePicker_Shown); - KeyDown += new System.Windows.Forms.KeyEventHandler(FilePicker_KeyDown); - ResumeLayout(false); - PerformLayout(); - - } - internal System.Windows.Forms.Button Button_Select; - internal System.Windows.Forms.Button Button_Cancel; - internal System.Windows.Forms.Button Button_Enter; - internal System.Windows.Forms.ListView FileListView; - internal System.Windows.Forms.ComboBox ComboBox_FileName; - internal System.Windows.Forms.Label Label_FileName; - internal System.Windows.Forms.ComboBox ComboBox_Filter; - internal System.Windows.Forms.Label Label_Filter; - internal System.Windows.Forms.ComboBox ComboBox_Directory; - internal System.Windows.Forms.Label Label_Directory; - internal System.Windows.Forms.ColumnHeader ColumnHeader_Name; - internal System.Windows.Forms.ColumnHeader ColumnHeader_Length; - internal System.Windows.Forms.ColumnHeader ColumnHeader_Type; - internal System.Windows.Forms.ColumnHeader ColumnHeader_ModifyTime; - internal System.Windows.Forms.ColumnHeader ColumnHeader_CreateTime; - - } -} \ No newline at end of file diff --git a/_sources/FontGen/FilePicker.cs b/_sources/FontGen/FilePicker.cs deleted file mode 100644 index 4df6d5c..0000000 --- a/_sources/FontGen/FilePicker.cs +++ /dev/null @@ -1,284 +0,0 @@ -// ========================================================================== -// -// File: FilePicker.vb -// Location: Firefly.GUI -// Description: File selection dialog box -// Version: 2009.12.04. -// Copyright(C) F.R.C. -// -// ========================================================================== - -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Windows.Forms; -using Firefly; -using Microsoft.VisualBasic.CompilerServices; - -namespace FontGen -{ - /// The file selection dialog box is used to open and save single and multiple files and folders in a unified manner. It can replace the three dialog boxes of Open File Dialog, Save File Dialog and Folder Browser Dialog. - public partial class FilePicker - { - private string InitialDirectoryValue; - public string InitialDirectory - { - get - { - return InitialDirectoryValue; - } - set - { - if (Directory.Exists(value)) - { - InitialDirectoryValue = value; - CurrentDirectory = value; - } - } - } - - private string CurrentDirectoryValue; - public string CurrentDirectory - { - get - { - return CurrentDirectoryValue; - } - set - { - value = FileNameHandling.GetDirectoryPathWithTailingSeparator(FileNameHandling.GetAbsolutePath(value, CurrentDirectoryValue)); - if (Directory.Exists(value)) - { - string Previous = CurrentDirectoryValue; - try - { - CurrentDirectoryValue = value; - ComboBox_Directory.Text = value; - RefreshList(); - } - catch (UnauthorizedAccessException ex) - { - MessageBox.Show(@"Inaccessible{0}。\r\naccess denied。".Descape().Formats(CurrentDirectoryValue), "Unavailable position", MessageBoxButtons.OK, MessageBoxIcon.Error); - CurrentDirectoryValue = Previous; - ComboBox_Directory.Text = Previous; - RefreshList(); - } - } - } - } - - private List> FilterValues = new List>(); - private int FilterIndexValue = -1; - public string Filter - { - get - { - return string.Join("|", (from p in FilterValues - select (p.Key + "|" + string.Join(";", p.Value))).ToArray()); - } - set - { - if (string.IsNullOrEmpty(value) || !value.Contains("|")) - { - FilterValues.Clear(); - FilterIndexValue = -1; - return; - } - string[] r = value.Split('|'); - if (r.Length % 2 != 0) - throw new ArgumentException(); - FilterValues = Enumerable.Range(0, r.Length / 2).Select(i => new KeyValuePair(r[i * 2], r[i * 2 + 1].Split(';'))).ToList(); - FilterIndexValue = 0; - } - } - - public int CurrentFilterIndex - { - get - { - return FilterIndexValue; - } - set - { - FilterIndexValue = value; - if (FilterIndexValue >= 0 && FilterIndexValue < FilterValues.Count) - { - ComboBox_Filter.SelectedIndex = FilterIndexValue; - } - } - } - - protected bool IsSaveDialogValue = false; - public bool IsSaveDialog - { - get - { - return IsSaveDialogValue; - } - set - { - IsSaveDialogValue = value; - if ((Title ?? "") != (Name ?? "")) - return; - if (value) - { - Title = "Save as.."; - } - else - { - Title = "Open"; - } - } - } - - public enum ModeSelectionEnum - { - File = 1, - Folder = 2, - FileWithFolder = 3 - } - - protected ModeSelectionEnum ModeSelectionValue = ModeSelectionEnum.File; - public ModeSelectionEnum ModeSelection - { - get - { - return ModeSelectionValue; - } - set - { - switch (value) - { - case ModeSelectionEnum.File: - case ModeSelectionEnum.FileWithFolder: - case ModeSelectionEnum.Folder: - { - ModeSelectionValue = value; - break; - } - - default: - { - throw new ArgumentException(); - } - } - } - } - - public bool CanSelectFiles - { - get - { - return Conversions.ToBoolean(ModeSelectionValue & ModeSelectionEnum.File); - } - } - - public bool CanSelectFolders - { - get - { - return Conversions.ToBoolean(ModeSelectionValue & ModeSelectionEnum.Folder); - } - } - - private bool MultiselectValue = false; - public bool Multiselect - { - get - { - return MultiselectValue; - } - set - { - MultiselectValue = value; - FileListView.MultiSelect = value; - } - } - - private string FilePathValue = ""; - public string FilePath - { - get - { - return FilePathValue; - } - set - { - FilePathValue = value; - CurrentDirectory = FileNameHandling.GetFileDirectory(value); - ComboBox_FileName.Text = FileNameHandling.GetFileName(value); - } - } - - private string[] FileNamesValue = []; - public string[] FileNames - { - get - { - return FileNamesValue.ToArray(); - } - } - - public string[] FilePaths - { - get - { - string d = CurrentDirectory; - return (from f in FileNamesValue - select FileNameHandling.GetAbsolutePath(f, d)).ToArray(); - } - } - - private bool CheckFileExistsValue = true; - public bool CheckFileExists - { - get - { - return CheckFileExistsValue; - } - set - { - CheckFileExistsValue = value; - } - } - - private bool CheckPathExistsValue = true; - public bool CheckPathExists - { - get - { - return CheckPathExistsValue; - } - set - { - CheckPathExistsValue = value; - } - } - - public string Title - { - get - { - return Text; - } - set - { - Text = value; - } - } - - private bool ValidateNamesValue = true; - public bool ValidateNames - { - get - { - return ValidateNamesValue; - } - set - { - ValidateNamesValue = value; - } - } - } -} \ No newline at end of file diff --git a/_sources/FontGen/FilePicker.resx b/_sources/FontGen/FilePicker.resx deleted file mode 100644 index 19dc0dd..0000000 --- a/_sources/FontGen/FilePicker.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/_sources/FontGen/FilePickerInterop.cs b/_sources/FontGen/FilePickerInterop.cs deleted file mode 100644 index cd80893..0000000 --- a/_sources/FontGen/FilePickerInterop.cs +++ /dev/null @@ -1,142 +0,0 @@ -// ========================================================================== -// -// File: FilePickerInterop.vb -// Location: Firefly.GUI -// Description: File selection dialog - Win32 call wrapper -// Version: 2009.11.30. -// Copyright(C) F.R.C. -// -// ========================================================================== - -using System; -using System.Drawing; -using System.Runtime.InteropServices; - -namespace FontGen -{ - - public sealed class FilePickerInterop - { - public static Icon GetAssociatedIcon(string Path, bool large) - { - var info = new SHFILEINFO(true); - int cbFileInfo = Marshal.SizeOf(info); - SHGFI flags; - - if (large) - { - flags = SHGFI.Icon | SHGFI.LargeIcon; - } - else - { - flags = SHGFI.Icon | SHGFI.SmallIcon; - } - - SHGetFileInfo(Path, 0U, out info, (uint)cbFileInfo, flags); - - if (info.hIcon == IntPtr.Zero) - return null; - var i = Icon.FromHandle(info.hIcon).Clone(); - DestroyIcon(info.hIcon); - - return (Icon)i; - } - public static string GetTypeName(string Path) - { - var info = new SHFILEINFO(true); - int cbFileInfo = Marshal.SizeOf(info); - SHGFI flags; - flags = SHGFI.TypeName; - - SHGetFileInfo(Path, 0U, out info, (uint)cbFileInfo, flags); - - return info.szTypeName; - } - - [DllImport("shell32.dll", CharSet = CharSet.Ansi)] - private static extern IntPtr SHGetFileInfo(string pszPath, uint dwFileAttributes, out SHFILEINFO psfi, uint cbfileInfo, SHGFI uFlags); - [DllImport("user32.dll", SetLastError = true)] - private static extern bool DestroyIcon(IntPtr hIcon); - - private const int MAX_PATH = 260; - private const int MAX_TYPE = 80; - - private struct SHFILEINFO - { - public SHFILEINFO(bool b) - { - hIcon = IntPtr.Zero; - iIcon = 0; - dwAttributes = 0U; - szDisplayName = ""; - szTypeName = ""; - } - - public IntPtr hIcon; - public int iIcon; - public uint dwAttributes; - [MarshalAs(UnmanagedType.ByValTStr, SizeConst = MAX_PATH)] - public string szDisplayName; - [MarshalAs(UnmanagedType.ByValTStr, SizeConst = MAX_TYPE)] - public string szTypeName; - } - - [Flags()] - public enum SHGFI : uint - { - /// get icon - Icon = 0x100U, - - /// get display name - DisplayName = 0x200U, - - /// get type name - TypeName = 0x400U, - - /// get attributes - Attributes = 0x800U, - - /// get icon location - IconLocation = 0x1000U, - - /// return exe type - ExeType = 0x2000U, - - /// get system icon index - SysIconIndex = 0x4000U, - - /// put a link overlay on icon - LinkOverlay = 0x8000U, - - /// show icon in selected state - Selected = 0x10000U, - - /// get only specified attributes - Attr_Specified = 0x20000U, - - /// get large icon - LargeIcon = 0x0U, - - /// get small icon - SmallIcon = 0x1U, - - /// get open icon - OpenIcon = 0x2U, - - /// get shell size icon - ShellIconize = 0x4U, - - /// pszPath is a pidl - PIDL = 0x8U, - - /// use passed dwFileAttribute - UseFileAttributes = 0x10U, - - /// apply the appropriate overlays - AddOverlays = 0x20U, - - /// Get the index of the overlay in the upper 8 bits of the iIcon - OverlayIndex = 0x40U - } - } -} \ No newline at end of file diff --git a/_sources/FontGen/FilePickerView.cs b/_sources/FontGen/FilePickerView.cs deleted file mode 100644 index 4d84d60..0000000 --- a/_sources/FontGen/FilePickerView.cs +++ /dev/null @@ -1,621 +0,0 @@ -// ========================================================================== -// -// File: FilePickerView.vb -// Location: Firefly.GUI -// Description: 文件选取对话框 - 界面 -// Version: 2010.02.04. -// Copyright(C) F.R.C. -// -// ========================================================================== - -using System; -using System.Collections.Generic; -using System.Drawing; -using System.IO; -using System.Linq; -using System.Windows.Forms; -using Firefly; -using Microsoft.VisualBasic.CompilerServices; - -namespace FontGen -{ - - public partial class FilePicker - { - private class Item - { - public string Name; - public int Type; - } - - private List DirectoryList = new List(); - private void RefreshDirectoryList() - { - string DirectoryText = ComboBox_Directory.Text; - DirectoryList.Clear(); - ComboBox_Directory.Items.Clear(); - DirectoryList.Add(Environment.GetFolderPath(Environment.SpecialFolder.Desktop)); - ComboBox_Directory.Items.Add("desktop"); - foreach (var d in DriveInfo.GetDrives()) - { - DirectoryList.Add(d.Name); - if (d.IsReady) - { - ComboBox_Directory.Items.Add("{0} ({1})".Formats(FileNameHandling.GetDirectoryPathWithoutTailingSeparator(d.Name), d.VolumeLabel)); - } - else - { - ComboBox_Directory.Items.Add(FileNameHandling.GetDirectoryPathWithoutTailingSeparator(d.Name)); - } - } - ComboBox_Directory.Text = DirectoryText; - } - - private void ComboBox_Directory_SelectedIndexChanged(object sender, EventArgs e) - { - ComboBox_Directory.Text = DirectoryList[ComboBox_Directory.SelectedIndex]; - CurrentDirectory = ComboBox_Directory.Text; - } - - private ImageList ImageList = new ImageList(); - private Dictionary IconDict = new Dictionary(); - private List Sorter = new List(); - private void FillItem(int i) - { - var Item = Sorter[i]; - if (IconDict.ContainsKey(i)) - return; - - string f = FileNameHandling.GetAbsolutePath(Item.SubItems[0].Text, CurrentDirectory); - Icon Icon = null; - Icon = FilePickerInterop.GetAssociatedIcon(f, false); - if (Icon is not null) - { - int Index; - ImageList.Images.Add(Icon); - Index = IconDict.Count; - IconDict.Add(i, Icon); - Item.ImageIndex = Index; - } - string TypeName = FilePickerInterop.GetTypeName(f); - Item.SubItems[2].Text = TypeName; - } - - private void RefreshList() - { - if (!Directory.Exists(CurrentDirectory)) - return; - foreach (var p in IconDict) - p.Value.Dispose(); - ImageList = new ImageList(); - IconDict = new Dictionary(); - ImageList.ColorDepth = ColorDepth.Depth32Bit; - FileListView.SmallImageList = ImageList; - - FileListView.VirtualListSize = 0; - - Item[] RootItems = [new Item() { Name = "..", Type = -1 }]; - var DirectoryItems = Directory.GetDirectories(CurrentDirectory).OrderBy(f => f, StringComparer.OrdinalIgnoreCase).Select(f => new Item() { Name = f, Type = 0 }); - string[] FileMasks = []; - if (FilterIndexValue >= 0 && FilterIndexValue < FilterValues.Count) - { - FileMasks = FilterValues[FilterIndexValue].Value; - } - bool FileNamePredicate(string FileName) => FileMasks.Any(m => FileNameHandling.IsMatchFileMask(FileName, m)); - var FileItems = Directory.GetFiles(CurrentDirectory).Where(FilePath => FileNamePredicate(FileNameHandling.GetFileName(FilePath))).OrderBy(f => f, StringComparer.OrdinalIgnoreCase).Select(f => new Item() { Name = f, Type = 1 }); - Item[] Items = RootItems.Concat(DirectoryItems).Concat(FileItems).ToArray(); - - int n = 0; - Sorter = new List(); - foreach (var p in Items) - { - string f = FileNameHandling.GetAbsolutePath(p.Name, CurrentDirectory); - if (string.IsNullOrEmpty(f)) - continue; - var fi = new FileInfo(f); - string TypeName = ""; - if (Directory.Exists(f)) - { - var Item = new ListViewItem(new string[] { FileNameHandling.GetFileName(p.Name), "", TypeName, Conversions.ToString(fi.LastWriteTime), Conversions.ToString(fi.CreationTime), n.ToString(), p.Type.ToString() }); - Sorter.Add(Item); - } - else - { - var Item = new ListViewItem(new string[] { FileNameHandling.GetFileName(p.Name), fi.Length.ToString(), TypeName, Conversions.ToString(fi.LastWriteTime), Conversions.ToString(fi.CreationTime), n.ToString(), p.Type.ToString() }); - Sorter.Add(Item); - } - n += 1; - } - if (FileListViewMajorCompareeIndex != -1) - Sorter.Sort(Comparison); - - FileListView.VirtualListSize = Sorter.Count; - } - - private void FileListView_RetrieveVirtualItem(object sender, RetrieveVirtualItemEventArgs e) - { - FillItem(e.ItemIndex); - e.Item = Sorter[e.ItemIndex]; - } - - private int FileListViewMajorCompareeIndex = -1; - - private int Comparison(ListViewItem x, ListViewItem y) - { - var OrderSeq = new List(); - OrderSeq.Add(FileListView.Columns.Count + 1); - var r = Enumerable.Range(0, FileListView.Columns.Count); - if (r.Contains(FileListViewMajorCompareeIndex)) - { - OrderSeq.Add(FileListViewMajorCompareeIndex); - OrderSeq.AddRange(r.Except(new int[] { FileListViewMajorCompareeIndex })); - } - else - { - OrderSeq.AddRange(r); - } - OrderSeq.Add(FileListView.Columns.Count); - - foreach (var c in OrderSeq) - { - switch (c) - { - case 1: - { - if (x.SubItems[c].Text.Length < y.SubItems[c].Text.Length) - return -1; - if (x.SubItems[c].Text.Length > y.SubItems[c].Text.Length) - return 1; - break; - } - } - if (Operators.CompareString(x.SubItems[c].Text, y.SubItems[c].Text, false) < 0) - return -1; - if (Operators.CompareString(x.SubItems[c].Text, y.SubItems[c].Text, false) > 0) - return 1; - } - return 0; - } - - private void FileListView_ColumnClick(object sender, ColumnClickEventArgs e) - { - FileListViewMajorCompareeIndex = e.Column; - RefreshList(); - } - - private void RefreshFilterList() - { - ComboBox_Filter.Items.Clear(); - if (FilterValues.Count > 0) - { - ComboBox_Filter.Items.AddRange((from f in FilterValues - select f.Key).ToArray()); - if (FilterIndexValue >= 0 && FilterIndexValue < FilterValues.Count) - { - ComboBox_Filter.SelectedIndex = FilterIndexValue; - } - } - } - - private void ComboBox_Filter_SelectedIndexChanged(object sender, EventArgs e) - { - if (ComboBox_Filter.SelectedIndex != FilterIndexValue) - { - FilterIndexValue = ComboBox_Filter.SelectedIndex; - RefreshList(); - } - } - - public FilePicker(bool IsSaveDialog = false) - { - - Timer = new Timer(); - // This call is required by Windows Forms Designer. - InitializeComponent(); - - // Add any initialization after the Initialize Component() call. - - // FileListView.ContextMenu = ContextMenu - - InitialDirectory = Environment.CurrentDirectory; - CurrentDirectory = InitialDirectory; - Filter = "所有文件(*.*)|*.*"; - this.IsSaveDialog = IsSaveDialog; - ModeSelection = ModeSelectionEnum.File; - Multiselect = false; - CheckFileExists = true; - CheckPathExists = true; - ValidateNames = true; - } - - private void FilePicker_Load(object sender, EventArgs e) - { - RefreshDirectoryList(); - RefreshFilterList(); - RefreshList(); - } - - private void FilePicker_Shown(object sender, EventArgs e) - { - LastSourceControl = ComboBox_FileName; - ComboBox_FileName.Focus(); - } - - public new void Hide() - { - Owner = null; - base.Hide(); - } - - private void HideSelf() - { - Hide(); - if (Parent is not null) - Parent.Focus(); - } - - private Control LastSourceControl; - - private void Button_Enter_Click(object sender, EventArgs e) - { - if (ReferenceEquals(LastSourceControl, ComboBox_Directory)) - { - CurrentDirectory = ComboBox_Directory.Text; - } - else if (ReferenceEquals(LastSourceControl, ComboBox_FileName)) - { - CurrentDirectory = ComboBox_FileName.Text; - } - else if (ReferenceEquals(LastSourceControl, FileListView)) - { - var FocusedItem = FileListView.FocusedItem; - if (FocusedItem is null) - return; - if (FocusedItem.SubItems.Count != FileListView.Columns.Count + 2) - return; - switch (Conversions.ToInteger(FocusedItem.SubItems[FileListView.Columns.Count + 1].Text)) - { - case -1: - { - CurrentDirectory = FileNameHandling.GetFileDirectory(FileNameHandling.GetDirectoryPathWithoutTailingSeparator(CurrentDirectory)); - break; - } - case 0: - { - CurrentDirectory = FileNameHandling.GetAbsolutePath(FocusedItem.SubItems[0].Text, CurrentDirectory); - break; - } - } - } - } - - private bool ExistNode(string Path) - { - if (Conversions.ToBoolean(ModeSelection & ModeSelectionEnum.File)) - { - if (File.Exists(Path)) - return true; - } - if (Conversions.ToBoolean(ModeSelection & ModeSelectionEnum.Folder)) - { - if (Directory.Exists(Path)) - return true; - } - return false; - } - - private bool CheckComboBox_FileName(bool PopCheckFileExistBox) - { - string Path = FileNameHandling.GetAbsolutePath(ComboBox_FileName.Text, CurrentDirectory); - if (CheckPathExists) - { - if (!Directory.Exists(FileNameHandling.GetFileDirectory(Path))) - return false; - } - if (CheckFileExists) - { - if (IsSaveDialog) - { - if (ExistNode(Path)) - { - if (PopCheckFileExistBox) - { - var dr = MessageBox.Show(@"{0} existed. Do RN want to replace??".Descape().Formats(Path), "Confirm that it is stored again", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); - if (dr != DialogResult.Yes) - return false; - } - } - else if (ValidateNames) - { - foreach (var c in System.IO.Path.GetInvalidPathChars()) - { - if (Path.Contains(Conversions.ToString(c))) - return false; - } - } - } - else if (!ExistNode(Path)) - return false; - } - return true; - } - - private HashSet FileNameHistorySet = new HashSet(); - private void Button_Select_Click(object sender, EventArgs e) - { - if (ReferenceEquals(LastSourceControl, ComboBox_FileName)) - { - if (CheckComboBox_FileName(true)) - { - if (!FileNameHistorySet.Contains(ComboBox_FileName.Text)) - { - FileNameHistorySet.Add(ComboBox_FileName.Text); - ComboBox_Directory.Items.Add(ComboBox_FileName.Text); - } - string Path = FileNameHandling.GetAbsolutePath(ComboBox_FileName.Text, CurrentDirectory); - FilePathValue = Path; - FileNamesValue = [FileNameHandling.GetRelativePath(Path, CurrentDirectory)]; - DialogResult = DialogResult.OK; - HideSelf(); - } - } - else if (ReferenceEquals(LastSourceControl, FileListView)) - { - var l = new List(); - string f = ""; - - foreach (ListViewItem r in Sorter) - { - if (!r.Selected) - continue; - if (r.SubItems.Count == FileListView.Columns.Count + 2) - { - switch (Conversions.ToInteger(r.SubItems[FileListView.Columns.Count + 1].Text)) - { - case -1: - { - break; - } - case 0: - { - if (Conversions.ToBoolean(ModeSelection & ModeSelectionEnum.File)) - { - l.Add(r.SubItems[0].Text); - } - - break; - } - - default: - { - if (Conversions.ToBoolean(ModeSelection & ModeSelectionEnum.Folder)) - { - l.Add(r.SubItems[0].Text); - } - - break; - } - } - } - if (r.Focused) - { - f = r.SubItems[0].Text; - } - } - if (string.IsNullOrEmpty(f) && l.Count > 0) - f = l[0]; - FilePathValue = FileNameHandling.GetAbsolutePath(f, CurrentDirectory); - FileNamesValue = l.ToArray(); - DialogResult = DialogResult.OK; - HideSelf(); - } - } - - private void ProcessReturn(object sender, EventArgs e) - { - if (ComboBox_Directory.Focused && Button_Enter.Enabled) - { - Button_Enter_Click(sender, e); - } - else if (ComboBox_FileName.Focused && Button_Select.Enabled) - { - Button_Select_Click(sender, e); - } - else if (ComboBox_FileName.Focused && Button_Enter.Enabled) - { - Button_Enter_Click(sender, e); - } - else if (FileListView.Focused && Button_Enter.Enabled) - { - Button_Enter_Click(sender, e); - } - else if (FileListView.Focused && Button_Select.Enabled) - { - Button_Select_Click(sender, e); - } - } - - private void FileListView_Enter(object sender, EventArgs e) - { - LastSourceControl = FileListView; - } - - private void FileListView_ItemActivate(object sender, EventArgs e) - { - LastSourceControl = FileListView; - ProcessReturn(sender, e); - } - - private void ComboBox_Directory_Enter(object sender, EventArgs e) - { - LastSourceControl = ComboBox_Directory; - Button_Enter.Enabled = true; - } - - private void ComboBox_FileName_Enter(object sender, EventArgs e) - { - LastSourceControl = ComboBox_FileName; - ComboBox_FileName_TextChanged(sender, e); - } - - private void FileListView_KeyDown(object sender, KeyEventArgs e) - { - switch (e.KeyData) - { - case Keys.Control | Keys.A: - { - if (Multiselect) - { - foreach (ListViewItem r in Sorter) - { - if (r.SubItems.Count == FileListView.Columns.Count + 2) - { - if (Conversions.ToInteger(r.SubItems[FileListView.Columns.Count + 1].Text) == -1) - { - r.Selected = false; - } - else - { - r.Selected = true; - } - } - } - } - - break; - } - case Keys.Back: - { - CurrentDirectory = FileNameHandling.GetFileDirectory(FileNameHandling.GetDirectoryPathWithoutTailingSeparator(CurrentDirectory)); - break; - } - - default: - { - return; - } - } - e.Handled = true; - } - - private void FileListView_SelectedIndexChanged(object sender, EventArgs e) - { - Timer.Stop(); - var FocusedItem = FileListView.FocusedItem; - if (FocusedItem is null) - return; - if (FocusedItem.SubItems.Count != FileListView.Columns.Count + 2) - return; - switch (Conversions.ToInteger(FocusedItem.SubItems[FileListView.Columns.Count + 1].Text)) - { - case -1: - case 0: - { - Button_Enter.Enabled = true; - break; - } - - default: - { - Button_Enter.Enabled = false; - break; - } - } - bool Exist = false; - foreach (ListViewItem r in Sorter) - { - if (!r.Selected) - continue; - if (r.SubItems.Count == FileListView.Columns.Count + 2) - { - Exist = true; - switch (Conversions.ToInteger(r.SubItems[FileListView.Columns.Count + 1].Text)) - { - case -1: - { - Button_Select.Enabled = false; - return; - } - case 0: - { - if (ModeSelection == ModeSelectionEnum.File) - { - Button_Select.Enabled = false; - return; - } - - break; - } - - default: - { - if (ModeSelection == ModeSelectionEnum.Folder) - { - Button_Select.Enabled = false; - return; - } - - break; - } - } - } - } - Button_Select.Enabled = Exist; - } - - private void ComboBox_FileName_TextChanged(object sender, EventArgs e) - { - Box_TextChanged(sender, e); - } - - private Timer Timer; - internal int IMECompositing = 0; - private int Block = 0; - private void Box_Tick(object sender, EventArgs e) - { - if (Conversions.ToBoolean(System.Threading.Interlocked.CompareExchange(ref IMECompositing, -1, -1))) - return; - System.Threading.Interlocked.Exchange(ref Block, -1); - Timer.Stop(); - if (ComboBox_FileName.Focused) - { - Timer.Interval = 500; - Timer.Start(); - } - Button_Select.Enabled = CheckComboBox_FileName(false); - System.Threading.Interlocked.Exchange(ref Block, 0); - } - private void Box_TextChanged(object sender, EventArgs e) - { - if (Conversions.ToBoolean(System.Threading.Interlocked.CompareExchange(ref Block, -1, -1))) - return; - Timer.Stop(); - Timer.Interval = 500; - Timer.Start(); - } - - private void FilePicker_KeyDown(object sender, KeyEventArgs e) - { - switch (e.KeyData) - { - case Keys.Return: - { - ProcessReturn(sender, e); - break; - } - - default: - { - return; - } - } - e.Handled = true; - } - - private void Button_Cancel_Click(object sender, EventArgs e) - { - DialogResult = DialogResult.Cancel; - HideSelf(); - } - } -} \ No newline at end of file diff --git a/_sources/FontGen/FileSelectBox.cs b/_sources/FontGen/FileSelectBox.cs deleted file mode 100644 index 4224b19..0000000 --- a/_sources/FontGen/FileSelectBox.cs +++ /dev/null @@ -1,341 +0,0 @@ -// ========================================================================== -// -// File: FileSelectBox.vb -// Location: Firefly.GUI -// Description: File selection box -// Version: 2009.11.30. -// Copyright(C) F.R.C. -// -// ========================================================================== - -using System; -using System.ComponentModel; -using System.Runtime.CompilerServices; -using System.Windows.Forms; -using Firefly; -using static FontGen.FilePicker; - -namespace FontGen -{ - - [Microsoft.VisualBasic.CompilerServices.DesignerGenerated()] - public class FileSelectBox : UserControl - { - public FileSelectBox() - { - InitializeComponent(); - SplitContainer = _SplitContainer; - _SplitContainer.Name = "SplitContainer"; - //SplitterDistance = _SplitterDistance; - } - - // User Control overrides Dispose to clean up the component list. - [System.Diagnostics.DebuggerNonUserCode()] - protected override void Dispose(bool disposing) - { - try - { - if (disposing && components is not null) - { - components.Dispose(); - } - } - finally - { - base.Dispose(disposing); - } - } - internal Button Button; - internal TextBox TextBox; - internal Label Label; - private SplitContainer _SplitContainer; - - public virtual SplitContainer SplitContainer - { - [MethodImpl(MethodImplOptions.Synchronized)] - get - { - return _SplitContainer; - } - - [MethodImpl(MethodImplOptions.Synchronized)] - set - { - _SplitContainer = value; - } - } - // Required for Windows Forms Designer - private IContainer components; - - // NOTE: The following procedure is required for Windows Forms Designer - // This can be modified using Windows Forms Designer. - // Don't use the code editor to modify it. - [System.Diagnostics.DebuggerStepThrough()] - private void InitializeComponent() - { - this.Button = new System.Windows.Forms.Button(); - this.TextBox = new System.Windows.Forms.TextBox(); - this.Label = new System.Windows.Forms.Label(); - this._SplitContainer = new System.Windows.Forms.SplitContainer(); - ((System.ComponentModel.ISupportInitialize)(this._SplitContainer)).BeginInit(); - this._SplitContainer.Panel1.SuspendLayout(); - this._SplitContainer.Panel2.SuspendLayout(); - this._SplitContainer.SuspendLayout(); - this.SuspendLayout(); - // - // Button - // - this.Button.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Right))); - this.Button.Location = new System.Drawing.Point(141, 2); - this.Button.Name = "Button"; - this.Button.Size = new System.Drawing.Size(34, 25); - this.Button.TabIndex = 0; - this.Button.Text = "..."; - this.Button.UseVisualStyleBackColor = true; - this.Button.Click += new System.EventHandler(this.Button_Click); - // - // TextBox - // - this.TextBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.TextBox.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.Suggest; - this.TextBox.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.FileSystemDirectories; - this.TextBox.Location = new System.Drawing.Point(3, 5); - this.TextBox.Margin = new System.Windows.Forms.Padding(0); - this.TextBox.Name = "TextBox"; - this.TextBox.Size = new System.Drawing.Size(135, 20); - this.TextBox.TabIndex = 1; - this.TextBox.KeyUp += new System.Windows.Forms.KeyEventHandler(this.TextBox_KeyUp); - // - // Label - // - this.Label.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left))); - this.Label.AutoSize = true; - this.Label.Location = new System.Drawing.Point(3, 8); - this.Label.Name = "Label"; - this.Label.Size = new System.Drawing.Size(33, 13); - this.Label.TabIndex = 2; - this.Label.Text = "Label"; - // - // _SplitContainer - // - this._SplitContainer.Dock = System.Windows.Forms.DockStyle.Fill; - this._SplitContainer.FixedPanel = System.Windows.Forms.FixedPanel.Panel1; - this._SplitContainer.IsSplitterFixed = true; - this._SplitContainer.Location = new System.Drawing.Point(0, 0); - this._SplitContainer.Name = "_SplitContainer"; - // - // _SplitContainer.Panel1 - // - this._SplitContainer.Panel1.Controls.Add(this.Label); - this._SplitContainer.Panel1MinSize = 200; - // - // _SplitContainer.Panel2 - // - this._SplitContainer.Panel2.Controls.Add(this.TextBox); - this._SplitContainer.Panel2.Controls.Add(this.Button); - this._SplitContainer.Size = new System.Drawing.Size(379, 29); - this._SplitContainer.SplitterDistance = 200; - this._SplitContainer.SplitterWidth = 1; - this._SplitContainer.TabIndex = 3; - // - // FileSelectBox - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.AutoSize = true; - this.Controls.Add(this._SplitContainer); - this.Name = "FileSelectBox"; - this.Size = new System.Drawing.Size(379, 29); - this._SplitContainer.Panel1.ResumeLayout(false); - this._SplitContainer.Panel1.PerformLayout(); - this._SplitContainer.Panel2.ResumeLayout(false); - this._SplitContainer.Panel2.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)(this._SplitContainer)).EndInit(); - this._SplitContainer.ResumeLayout(false); - this.ResumeLayout(false); - - } - - private void TextBox_KeyUp(object sender, KeyEventArgs e) - { - if (e.KeyData == Keys.Enter) - { - EnterPressed?.Invoke(this, new EventArgs()); - } - } - - private FilePicker _PopupDialog_d = default; - - public void PopupDialog() - { - string CurrentDirectory = System.IO.Directory.GetCurrentDirectory(); - { - var withBlock = TextBox; - if (_PopupDialog_d is null) - _PopupDialog_d = new FilePicker(IsSaveDialogValue); - if (_PopupDialog_d.IsSaveDialog != IsSaveDialogValue) - _PopupDialog_d = new FilePicker(IsSaveDialogValue); - _PopupDialog_d.Multiselect = Multiselect; - _PopupDialog_d.ModeSelection = ModeSelectionValue; - - string dir = FileNameHandling.GetFileDirectory(withBlock.Text); - if (System.IO.Directory.Exists(dir)) - { - _PopupDialog_d.FilePath = withBlock.Text.TrimEnd('\\').TrimEnd('/'); - } - _PopupDialog_d.Filter = FilterValue; - if (_PopupDialog_d.ShowDialog() == DialogResult.OK) - { - string T = FileNameHandling.GetRelativePath(_PopupDialog_d.FilePath, CurrentDirectory); - if (!string.IsNullOrEmpty(T) && !string.IsNullOrEmpty(_PopupDialog_d.FilePath) && T.Length < _PopupDialog_d.FilePath.Length) - { - withBlock.Text = T; - } - else - { - withBlock.Text = _PopupDialog_d.FilePath; - } - } - } - System.IO.Directory.SetCurrentDirectory( CurrentDirectory); - } - - private void Button_Click(object sender, EventArgs e) - { - PopupDialog(); - } - - private string FilterValue = "(*.*)|*.*"; - [Category("Appearance")] - public string Filter - { - get - { - return FilterValue; - } - set - { - if (value is null) - throw new ArgumentException(); - var n = default(int); - var i = default(int); - while (true) - { - i = value.IndexOf("|", i + 1); - if (i < 0) - break; - n += 1; - } - if ((n & 1) == 0) - throw new ArgumentException(); - FilterValue = value; - } - } - - [Category("Appearance")] - public string LabelText - { - get - { - return Label.Text; - } - set - { - Label.Text = value; - } - } - - [Category("Appearance")] - public string Path - { - get - { - return TextBox.Text; - } - set - { - TextBox.Text = value; - } - } - - [Category("Appearance")] - public int SplitterDistance - { - get - { - return SplitContainer.SplitterDistance; - } - set - { - SplitContainer.SplitterDistance = value; - } - } - - private bool IsSaveDialogValue = false; - [Category("Behavior")] - [DefaultValue(false)] - public bool IsSaveDialog - { - get - { - return IsSaveDialogValue; - } - set - { - IsSaveDialogValue = value; - } - } - - private bool MultiselectValue = false; - [Category("Behavior")] - [DefaultValue(false)] - public bool Multiselect - { - get - { - return MultiselectValue; - } - set - { - MultiselectValue = value; - } - } - - protected ModeSelectionEnum ModeSelectionValue = ModeSelectionEnum.FileWithFolder; - [Category("Behavior")] - [DefaultValue(typeof(ModeSelectionEnum), "FileWithFolder")] - public ModeSelectionEnum ModeSelection - { - get - { - return ModeSelectionValue; - } - set - { - switch (value) - { - case ModeSelectionEnum.File: - case ModeSelectionEnum.Folder: - case ModeSelectionEnum.FileWithFolder: - { - ModeSelectionValue = value; - break; - } - - default: - { - throw new System.IO.InvalidDataException(); - } - } - } - } - - public event EnterPressedEventHandler EnterPressed; - - public delegate void EnterPressedEventHandler(object sender, EventArgs e); - } -} \ No newline at end of file diff --git a/_sources/FontGen/FileSelectBox.resx b/_sources/FontGen/FileSelectBox.resx deleted file mode 100644 index d58980a..0000000 --- a/_sources/FontGen/FileSelectBox.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/_sources/FontGen/FontGen_VS2010.csproj b/_sources/FontGen/FontGen_VS2010.csproj index ea3e15b..7547599 100644 --- a/_sources/FontGen/FontGen_VS2010.csproj +++ b/_sources/FontGen/FontGen_VS2010.csproj @@ -77,26 +77,6 @@ - - Form - - - - Form - - - FilePicker.cs - - - Form - - - - Form - - - UserControl - Form @@ -114,13 +94,6 @@ - - FilePicker.cs - - - FileSelectBox.cs - Designer - FontGenContent.cs