public static FontDescriptor FromFont(Font f) { if (f == null) { return(null); } var descriptor = new FontDescriptor(); descriptor.FontFamily = f.FontFamily.Name; descriptor.Size = f.Size; descriptor.Style = (int)f.Style; return(descriptor); }
// ================================================================================================================================================================== // ================================================================================================================================================================== // // Initialize static setting descriptors // static Form1() { List <IApplicableSetting2 <Settings> > d = null; Setting_BackColor = applicableSettings.AddReturn( d.Setting("ImageBackColor", s => s.Color, (s, v) => s.Color = v).Encoding(x => x != 0 ? Color.FromArgb(x) : Color.Empty, x => x.IsEmpty ? 0 : x.ToArgb()) .Lift().Wrap <Form1>(x => Settings.Instance).Applicable((x, v) => { if (!v.IsEmpty) { x.mainImageControl.BackColor = v; } }) ).DifferentGetter(x => x.mainImageControl.BackColor); applicableSettings.Add( d.Setting("WindowWidth", s => s.WindowWidth, (s, v) => s.WindowWidth = v) .Lift().Wrap <Form1>(x => Settings.Instance).Applicable((x, v) => { if (v != 0) { x.Width = v; } }) ); applicableSettings.Add( d.Setting("WindowHeight", s => s.WindowHeight, (s, v) => s.WindowHeight = v) .Lift().Wrap <Form1>(x => Settings.Instance).Applicable((x, v) => { if (v != 0) { x.Height = v; } }) ); Setting_SortCaseSensitive = applicableSettings.AddReturn( d.Setting("SortCaseSensitive", s => s.SortCaseSensitive, (s, v) => s.SortCaseSensitive = v) .Lift().Wrap <Form1>(x => Settings.Instance).Applicable((x, v) => x.SetSortCaseSensitive(v)) ); Setting_ApplicationFont = applicableSettings.AddReturn( d.Setting("ApplicationFont", s => s.ApplicationFont, (s, v) => s.ApplicationFont = v).Encoding(x => x?.ToFont(), x => FontDescriptor.FromFont(x)) .Lift().Wrap <Form1>(x => Settings.Instance).Applicable((x, v) => { if (v != null) { x.SetApplicationFont(v); } }) ).DifferentGetter(x => x.Font); applicableSettings.Add( d.Setting("OverviewControlWidth", s => s.OverviewControlWidth, (s, v) => s.OverviewControlWidth = v) .Lift().Wrap <Form1>(x => Settings.Instance).Applicable((x, v) => { if (v >= 0) { x.overviewControl.Width = v; } }) ); Setting_SplitterWidth = applicableSettings.AddReturn( d.Setting("SplitterWidth", s => s.SplitterWidth, (s, v) => s.SplitterWidth = v) .Lift().Wrap <Form1>(x => Settings.Instance).Applicable((x, v) => { if (v >= 0) { x.splitter.ChangeWidth(v); } }) ).DifferentGetter(x => x.splitter.Width); Setting_MouseWheelMode = applicableSettings.AddReturn( d.Setting("MouseWheelMode", s => s.MouseWheelMode, (s, v) => s.MouseWheelMode = v).Enum <Settings, MouseWheelMode>() .Lift().Wrap <Form1>(x => Settings.Instance).Applicable((x, v) => x.MouseWheelMode = v) ).DifferentGetter(x => x.MouseWheelMode); Setting_UseCurrentImageAsWindowIcon = applicableSettings.AddReturn( d.Setting("UseCurrentImageAsWindowIcon", s => s.UseCurrentImageAsWindowIcon, (s, v) => s.UseCurrentImageAsWindowIcon = v) .Lift().Wrap <Form1>(x => Settings.Instance).Applicable((x, v) => x.SetUseCurrentImageAsWindowIcon(v)) ); Setting_FileListBackColor = applicableSettings.AddReturn( d.Setting("FileListBackColor", s => s.FileListBackColor, (s, v) => s.FileListBackColor = v).Encoding(x => x != 0 ? Color.FromArgb(x) : Color.Empty, x => x.IsEmpty ? 0 : x.ToArgb()) .Lift().Wrap <Form1>(x => Settings.Instance).Applicable((x, v) => { if (!v.IsEmpty) { x.overviewControl.BackColor = v; } }) ).DifferentGetter(x => x.overviewControl.BackColor); Setting_FileListForeColor = applicableSettings.AddReturn( d.Setting("FileListForeColor", s => s.FileListForeColor, (s, v) => s.FileListForeColor = v).Encoding(x => x != 0 ? Color.FromArgb(x) : Color.Empty, x => x.IsEmpty ? 0 : x.ToArgb()) .Lift().Wrap <Form1>(x => Settings.Instance).Applicable((x, v) => { if (!v.IsEmpty) { x.overviewControl.ForeColor = v; } }) ).DifferentGetter(x => x.overviewControl.ForeColor); Setting_FileListForeColorError = applicableSettings.AddReturn( d.Setting("FileListForeColorError", s => s.FileListForeColorError, (s, v) => s.FileListForeColorError = v).Encoding(x => x != 0 ? Color.FromArgb(x) : Color.Empty, x => x.IsEmpty ? 0 : x.ToArgb()) .Lift().Wrap <Form1>(x => Settings.Instance).Applicable((x, v) => { if (!v.IsEmpty) { x.overviewControl.ForeColorError = v; } }) ).DifferentGetter(x => x.overviewControl.ForeColorError); }