├── .gitignore
├── DevExpressWinFormsExtension.Samples
├── App.config
├── CalcProgressControl.Designer.cs
├── CalcProgressControl.cs
├── CalcProgressControl.resx
├── Data
│ ├── MusicStyleDataItem.cs
│ ├── PersonGridRowInfo.cs
│ └── PropertyGridControlItems.cs
├── DevExpressWinFormsExtension.Samples.csproj
├── DevExpressWinFormsExtension.Samples.csproj.bak
├── Enums
│ └── DateViewEnum.cs
├── Forms
│ ├── EmptyMDIForm.Designer.cs
│ ├── EmptyMDIForm.cs
│ ├── EmptyMDIForm.resx
│ ├── ParentMDIForm.Designer.cs
│ ├── ParentMDIForm.cs
│ └── ParentMDIForm.resx
├── MainForm.Designer.cs
├── MainForm.cs
├── MainForm.resx
├── Program.cs
├── Properties
│ ├── AssemblyInfo.cs
│ ├── Resources.Designer.cs
│ ├── Resources.resx
│ ├── Settings.Designer.cs
│ └── Settings.settings
└── packages.config
├── DevExpressWinFormsExtension.sln
├── DevExpressWinFormsExtension
├── DataControls
│ ├── CheckedListBoxControlDev.cs
│ ├── CheckedListBoxControlDev.resx
│ ├── ColorPickEdit
│ │ ├── ColorPickEditDev.Designer.cs
│ │ ├── ColorPickEditDev.cs
│ │ ├── ColorPickEditDev.resx
│ │ ├── ColorPickEditUtils.cs
│ │ ├── RepositoryItemColorPickEditDev.Designer.cs
│ │ ├── RepositoryItemColorPickEditDev.cs
│ │ └── RepositoryItemColorPickEditDev.resx
│ ├── DateDoubleTrackBarControlDev.Designer.cs
│ ├── DateDoubleTrackBarControlDev.cs
│ ├── DateDoubleTrackBarControlDev.resx
│ ├── Extensions
│ │ ├── BaseEditExtension.cs
│ │ ├── ChartControlExtension.cs
│ │ ├── DateEditExtension.cs
│ │ ├── GridViewExtension.cs
│ │ ├── PropertyGridControlExtension.cs
│ │ └── TreeListNodeExtension.cs
│ ├── Forms
│ │ ├── Utils
│ │ │ ├── ShowControlParentForm.Designer.cs
│ │ │ └── ShowControlParentForm.cs
│ │ ├── XtraFormDev.cs
│ │ └── XtraUserControlDev.cs
│ ├── GridView
│ │ ├── BandedGridViewDev.cs
│ │ ├── BandedGridViewDev.designer.cs
│ │ ├── BandedGridViewDev.resx
│ │ ├── GridControlDev.cs
│ │ ├── GridControlDev.designer.cs
│ │ ├── GridViewDev.cs
│ │ ├── GridViewDev.designer.cs
│ │ ├── GridViewDev.resx
│ │ ├── HistogramData.cs
│ │ └── Utils
│ │ │ ├── BandedGridDevInfoRegistrator.cs
│ │ │ ├── BandedGridViewInfoDev.cs
│ │ │ ├── GridHelper.cs
│ │ │ ├── GridPainterDev.cs
│ │ │ ├── GridViewDevInfoRegistrator.cs
│ │ │ └── GridViewInfoDev.cs
│ ├── GroupControlCheckedDev.Designer.cs
│ ├── GroupControlCheckedDev.cs
│ ├── GroupControlCheckedDev.resx
│ ├── InputBoxValidableDev.Designer.cs
│ ├── InputBoxValidableDev.cs
│ ├── InputBoxValidableDev.resx
│ ├── LookUp
│ │ ├── ILookUpSplitableItem.cs
│ │ ├── LookUpDev.cs
│ │ ├── PopupLookUpEditFormDev.cs
│ │ └── RepositoryItemLookUpDev.cs
│ ├── PasswordTextEditDev.cs
│ └── TreeList
│ │ ├── TreeListDev.cs
│ │ ├── TreeListSearchable.Designer.cs
│ │ ├── TreeListSearchable.cs
│ │ ├── TreeListSearchable.resx
│ │ └── Utils
│ │ ├── TreeListSearchableDesigner.cs
│ │ └── TreeListViewInfoDev.cs
├── DevExpressWinFormsExtension.csproj
├── DevExpressWinFormsExtension.csproj.bak
├── DevExpressWinFormsExtension.sln
├── Interfaces
│ ├── IClosableControl.cs
│ └── IValidableControl.cs
├── Progress
│ ├── ControlProgressHandler.cs
│ ├── IProgressControlHandler.cs
│ ├── ProgressControl.Designer.cs
│ ├── ProgressControl.cs
│ ├── ProgressControl.resx
│ └── ProgressManager.cs
├── Properties
│ ├── AssemblyInfo.cs
│ ├── Resources.Designer.cs
│ └── Resources.resx
├── Resources
│ ├── Clear_16.png
│ ├── CollapseAll_16.png
│ ├── Color_16.png
│ ├── Decimal_16.png
│ ├── ExpandAll_16.png
│ ├── ImageBrush_16.png
│ ├── IsHidden_16.png
│ ├── IsVisible_16.png
│ ├── Lock_16.png
│ ├── Samples
│ │ ├── ChartLassoSample.jpg
│ │ ├── DateDoubleTrackBarSample.jpg
│ │ ├── GridControlSample.jpg
│ │ ├── GridFooterSample.jpg
│ │ ├── GridHistogramSample.jpg
│ │ ├── GroupControlCheckedSample.jpg
│ │ ├── InputBoxValidableSample.jpg
│ │ ├── LookUpSample.jpg
│ │ ├── LookUpSplitterSample.jpg
│ │ ├── MDISample.jpg
│ │ ├── PasswordTextEditSample.jpg
│ │ ├── ProgressManagerSample.jpg
│ │ ├── PropertyGridControlSortingSample.jpg
│ │ ├── SampleProject.jpg
│ │ ├── ScreenshotCaptureSample.jpg
│ │ ├── SkinPreviewSample.jpg
│ │ └── TreeListSearchableSample.jpg
│ └── Unlock_16.png
└── Utils
│ ├── ChartControlLassoProcessor.cs
│ ├── ColorExtension.cs
│ ├── ControlScreenshotCapture.cs
│ ├── EnumEditorItem.cs
│ ├── EnumExtension.cs
│ ├── FormHelper.cs
│ ├── MDITabsDragHelper.cs
│ ├── MdiManager
│ ├── MatrixGridControl.Designer.cs
│ ├── MatrixGridControl.cs
│ ├── MatrixGridControl.resx
│ └── MdiManagerHelper.cs
│ ├── NaturalStringComparer.cs
│ ├── RegexMaskHelper.cs
│ ├── SkinHelper.cs
│ ├── SolidBrushesCache.cs
│ └── XtraUserControlHelper.cs
└── README.md
/DevExpressWinFormsExtension.Samples/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/DevExpressWinFormsExtension.Samples/CalcProgressControl.Designer.cs:
--------------------------------------------------------------------------------
1 | namespace DevExpressWinFormsExtension.Samples
2 | {
3 | partial class CalcProgressControl
4 | {
5 | ///
6 | /// Required designer variable.
7 | ///
8 | private System.ComponentModel.IContainer components = null;
9 |
10 | ///
11 | /// Clean up any resources being used.
12 | ///
13 | /// true if managed resources should be disposed; otherwise, false.
14 | protected override void Dispose(bool disposing)
15 | {
16 | if (disposing && (components != null))
17 | {
18 | components.Dispose();
19 | }
20 | base.Dispose(disposing);
21 | }
22 |
23 | #region Component Designer generated code
24 |
25 | ///
26 | /// Required method for Designer support - do not modify
27 | /// the contents of this method with the code editor.
28 | ///
29 | private void InitializeComponent()
30 | {
31 | this.btnStartCalc = new DevExpress.XtraEditors.SimpleButton();
32 | this.SuspendLayout();
33 | //
34 | // btnStartCalc
35 | //
36 | this.btnStartCalc.Anchor = System.Windows.Forms.AnchorStyles.Top;
37 | this.btnStartCalc.Location = new System.Drawing.Point(138, 41);
38 | this.btnStartCalc.Name = "btnStartCalc";
39 | this.btnStartCalc.Size = new System.Drawing.Size(156, 22);
40 | this.btnStartCalc.TabIndex = 9;
41 | this.btnStartCalc.Text = "Start long calculations...";
42 | this.btnStartCalc.Click += new System.EventHandler(this.btnStartCalc_Click);
43 | //
44 | // CalcProgressControl
45 | //
46 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
47 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
48 | this.Controls.Add(this.btnStartCalc);
49 | this.Name = "CalcProgressControl";
50 | this.Size = new System.Drawing.Size(434, 104);
51 | this.ResumeLayout(false);
52 |
53 | }
54 |
55 | #endregion
56 |
57 | private DevExpress.XtraEditors.SimpleButton btnStartCalc;
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/DevExpressWinFormsExtension.Samples/CalcProgressControl.cs:
--------------------------------------------------------------------------------
1 | using DevExpressWinFormsExtension.DataControls.Forms;
2 | using DevExpressWinFormsExtension.Progress;
3 | using System.Threading.Tasks;
4 |
5 | namespace DevExpressWinFormsExtension.Samples
6 | {
7 | ///
8 | /// Sample control to demonstrate progress
9 | ///
10 | public partial class CalcProgressControl : XtraUserControlDev
11 | {
12 | public CalcProgressControl()
13 | {
14 | InitializeComponent();
15 | }
16 |
17 | ///
18 | /// Event on start calculations
19 | ///
20 | /// Source
21 | /// Parameters
22 | private void btnStartCalc_Click(object sender, System.EventArgs e)
23 | {
24 | var handler = ProgressManager.InitMarquee(this);
25 |
26 | //// Perform long business logic
27 | new Task(() =>
28 | {
29 | while (true)
30 | {
31 | if (handler.Token.IsCancellationRequested)
32 | {
33 | handler.Drop();
34 | break;
35 | }
36 | }
37 | }).Start();
38 | }
39 | }
40 | }
--------------------------------------------------------------------------------
/DevExpressWinFormsExtension.Samples/CalcProgressControl.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
--------------------------------------------------------------------------------
/DevExpressWinFormsExtension.Samples/Data/MusicStyleDataItem.cs:
--------------------------------------------------------------------------------
1 | using DevExpressWinFormsExtension.DataControls.LookUp;
2 |
3 | namespace DevExpressWinFormsExtension.Samples.Data
4 | {
5 | ///
6 | /// Music style item
7 | ///
8 | internal struct MusicStyleDataItem : ILookUpSplitableItem
9 | {
10 | ///
11 | /// Constructor with parameters
12 | ///
13 | /// Style name
14 | /// Hint description
15 | /// If item is a last item before splitting
16 | public MusicStyleDataItem(string name, string description, bool isSplitter = false)
17 | {
18 | Name = name;
19 | Description = description;
20 | IsSplitter = isSplitter;
21 | }
22 |
23 | ///
24 | /// Style name
25 | ///
26 | public string Name { get; set; }
27 |
28 | ///
29 | /// Hint description
30 | ///
31 | public string Description { get; set; }
32 |
33 | ///
34 | /// Flag if a current item is a last item before splitting
35 | ///
36 | public bool IsSplitter { get; set; }
37 | }
38 | }
--------------------------------------------------------------------------------
/DevExpressWinFormsExtension.Samples/Data/PersonGridRowInfo.cs:
--------------------------------------------------------------------------------
1 | namespace DevExpressWinFormsExtension.Samples.Data
2 | {
3 | ///
4 | /// Row info about test person
5 | ///
6 | internal sealed class PersonGridRowInfo
7 | {
8 | ///
9 | /// Full name
10 | ///
11 | public string Name { get; set; }
12 |
13 | ///
14 | /// Department
15 | ///
16 | public string Department { get; set; }
17 |
18 | ///
19 | /// Average salary
20 | ///
21 | public double AverageSalary { get; set; }
22 |
23 | ///
24 | /// Is person valid
25 | ///
26 | public bool IsValid { get; set; }
27 |
28 | ///
29 | /// List of values for building histogram
30 | ///
31 | public object Histogram { get; set; }
32 | }
33 | }
--------------------------------------------------------------------------------
/DevExpressWinFormsExtension.Samples/Data/PropertyGridControlItems.cs:
--------------------------------------------------------------------------------
1 | using System.ComponentModel;
2 | using System.ComponentModel.DataAnnotations;
3 |
4 | namespace DevExpressWinFormsExtension.Samples.Data
5 | {
6 | ///
7 | /// Base row info for a PropertyGridControl demo
8 | ///
9 | public class BaseRowInfo
10 | {
11 | ///
12 | /// Price
13 | ///
14 | [Category("Level"), Display(Name = "Price", Order = 0)]
15 | public decimal Price { get; set; }
16 |
17 | ///
18 | /// Percent price
19 | ///
20 | [Category("Level"), Display(Name = "Price in percent", Order = 2)]
21 | public double PercentPrice { get; set; }
22 | }
23 |
24 | ///
25 | /// Extended row info for a PropertyGridControl demo
26 | ///
27 | public sealed class ExtendedRowInfo :BaseRowInfo
28 | {
29 | ///
30 | /// View in percent
31 | ///
32 | [Category("Level"), Display(Name = "Show in percent", Order = 1)]
33 | public bool InPercent { get; set; }
34 |
35 | ///
36 | /// Is level usable
37 | ///
38 | [Category("Level"), Display(Name = "Use level", Order = 3)]
39 | public bool Use { get; set; }
40 | }
41 | }
--------------------------------------------------------------------------------
/DevExpressWinFormsExtension.Samples/Enums/DateViewEnum.cs:
--------------------------------------------------------------------------------
1 | using System.ComponentModel;
2 |
3 | namespace DevExpressWinFormsExtension.Samples.Enums
4 | {
5 | ///
6 | /// Date view types
7 | ///
8 | public enum DateViewEnum
9 | {
10 | [Description("Months view")]
11 | Month,
12 |
13 | [Description("Year view")]
14 | Year
15 | }
16 | }
--------------------------------------------------------------------------------
/DevExpressWinFormsExtension.Samples/Forms/EmptyMDIForm.Designer.cs:
--------------------------------------------------------------------------------
1 | namespace DevExpressWinFormsExtension.Samples
2 | {
3 | partial class EmptyMDIForm
4 | {
5 | ///
6 | /// Required designer variable.
7 | ///
8 | private System.ComponentModel.IContainer components = null;
9 |
10 | ///
11 | /// Clean up any resources being used.
12 | ///
13 | /// true if managed resources should be disposed; otherwise, false.
14 | protected override void Dispose(bool disposing)
15 | {
16 | if (disposing && (components != null))
17 | {
18 | components.Dispose();
19 | }
20 | base.Dispose(disposing);
21 | }
22 |
23 | #region Windows Form Designer generated code
24 |
25 | ///
26 | /// Required method for Designer support - do not modify
27 | /// the contents of this method with the code editor.
28 | ///
29 | private void InitializeComponent()
30 | {
31 | this.labelControl1 = new DevExpress.XtraEditors.LabelControl();
32 | this.SuspendLayout();
33 | //
34 | // labelControl1
35 | //
36 | this.labelControl1.Appearance.Font = new System.Drawing.Font("Tahoma", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(204)));
37 | this.labelControl1.Appearance.Options.UseFont = true;
38 | this.labelControl1.Appearance.Options.UseTextOptions = true;
39 | this.labelControl1.Appearance.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;
40 | this.labelControl1.Appearance.TextOptions.WordWrap = DevExpress.Utils.WordWrap.Wrap;
41 | this.labelControl1.AutoSizeMode = DevExpress.XtraEditors.LabelAutoSizeMode.None;
42 | this.labelControl1.Dock = System.Windows.Forms.DockStyle.Fill;
43 | this.labelControl1.Location = new System.Drawing.Point(0, 0);
44 | this.labelControl1.Name = "labelControl1";
45 | this.labelControl1.Size = new System.Drawing.Size(800, 450);
46 | this.labelControl1.TabIndex = 0;
47 | this.labelControl1.Text = "Empty form. You can pass your form type here.";
48 | //
49 | // EmptyForm
50 | //
51 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
52 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
53 | this.ClientSize = new System.Drawing.Size(800, 450);
54 | this.Controls.Add(this.labelControl1);
55 | this.Name = "EmptyForm";
56 | this.Text = "EmptyForm";
57 | this.ResumeLayout(false);
58 |
59 | }
60 |
61 | #endregion
62 |
63 | private DevExpress.XtraEditors.LabelControl labelControl1;
64 | }
65 | }
--------------------------------------------------------------------------------
/DevExpressWinFormsExtension.Samples/Forms/EmptyMDIForm.cs:
--------------------------------------------------------------------------------
1 | using DevExpress.XtraEditors;
2 |
3 | namespace DevExpressWinFormsExtension.Samples
4 | {
5 | ///
6 | /// Empty MDI form
7 | ///
8 | public partial class EmptyMDIForm : XtraForm
9 | {
10 | ///
11 | /// Parameterless constructor
12 | ///
13 | public EmptyMDIForm()
14 | {
15 | InitializeComponent();
16 | }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/DevExpressWinFormsExtension.Samples/Forms/EmptyMDIForm.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
--------------------------------------------------------------------------------
/DevExpressWinFormsExtension.Samples/Forms/ParentMDIForm.cs:
--------------------------------------------------------------------------------
1 | using DevExpress.XtraEditors;
2 | using DevExpressWinFormsExtension.Utils.MdiManager;
3 | using System;
4 | using System.Windows.Forms;
5 |
6 | namespace DevExpressWinFormsExtension.Samples.Forms
7 | {
8 | ///
9 | /// Parent MDI form
10 | ///
11 | public partial class ParentMDIForm : XtraForm
12 | {
13 | ///
14 | /// Parameterless constructor
15 | ///
16 | public ParentMDIForm()
17 | {
18 | InitializeComponent();
19 |
20 | IsMdiContainer = true;
21 | }
22 |
23 | ///
24 | /// Event on user MDI children size selected
25 | ///
26 | /// Source
27 | /// Parameters
28 | private void matrixGridControl_OnSizeSelected(object sender, EventArgs e)
29 | {
30 | popupContainerControlMatrix.OwnerEdit.ClosePopup();
31 |
32 |
33 |
34 | MdiManagerHelper.InitMDIChildren(this, matrixGridControl.TotalSize, typeof(EmptyMDIForm));
35 | UpdateMDILayout();
36 | }
37 |
38 | ///
39 | /// Event on form's resize
40 | ///
41 | /// Source
42 | /// Parameters
43 | private void ParentMDIForm_ClientSizeChanged(object sender, EventArgs e)
44 | {
45 | UpdateMDILayout();
46 | }
47 |
48 | ///
49 | /// Event on custom display text for popupMatrix
50 | ///
51 | /// Source
52 | /// Parameters
53 | private void repositoryItemPopupMatrix_CustomDisplayText(object sender, DevExpress.XtraEditors.Controls.CustomDisplayTextEventArgs e)
54 | {
55 | e.DisplayText = matrixGridControl.TotalSize.ToString();
56 | }
57 |
58 | ///
59 | /// Update MDI children layout
60 | ///
61 | private void UpdateMDILayout()
62 | {
63 | LayoutMdi(matrixGridControl.SelectedSize.Width > matrixGridControl.SelectedSize.Height ? MdiLayout.TileVertical : MdiLayout.TileHorizontal);
64 | }
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/DevExpressWinFormsExtension.Samples/Forms/ParentMDIForm.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
--------------------------------------------------------------------------------
/DevExpressWinFormsExtension.Samples/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Windows.Forms;
3 |
4 | namespace DevExpressWinFormsExtension.Samples
5 | {
6 | static class Program
7 | {
8 | ///
9 | /// The main entry point for the application.
10 | ///
11 | [STAThread]
12 | static void Main()
13 | {
14 | Application.EnableVisualStyles();
15 | Application.SetCompatibleTextRenderingDefault(false);
16 | Application.Run(new MainForm());
17 | }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/DevExpressWinFormsExtension.Samples/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.InteropServices;
3 |
4 | // General Information about an assembly is controlled through the following
5 | // set of attributes. Change these attribute values to modify the information
6 | // associated with an assembly.
7 | [assembly: AssemblyTitle("DevExpressWinFormsExtension.Samples")]
8 | [assembly: AssemblyDescription("")]
9 | [assembly: AssemblyConfiguration("")]
10 | [assembly: AssemblyCompany("")]
11 | [assembly: AssemblyProduct("DevExpressWinFormsExtension.Samples")]
12 | [assembly: AssemblyCopyright("Copyright © 2022")]
13 | [assembly: AssemblyTrademark("")]
14 | [assembly: AssemblyCulture("")]
15 |
16 | // Setting ComVisible to false makes the types in this assembly not visible
17 | // to COM components. If you need to access a type in this assembly from
18 | // COM, set the ComVisible attribute to true on that type.
19 | [assembly: ComVisible(false)]
20 |
21 | // The following GUID is for the ID of the typelib if this project is exposed to COM
22 | [assembly: Guid("66f9de51-3014-443b-8825-387b48905332")]
23 |
24 | // Version information for an assembly consists of the following four values:
25 | //
26 | // Major Version
27 | // Minor Version
28 | // Build Number
29 | // Revision
30 | //
31 | // You can specify all the values or you can default the Build and Revision Numbers
32 | // by using the '*' as shown below:
33 | // [assembly: AssemblyVersion("1.0.*")]
34 | [assembly: AssemblyVersion("1.0.0.0")]
35 | [assembly: AssemblyFileVersion("1.0.0.0")]
36 |
--------------------------------------------------------------------------------
/DevExpressWinFormsExtension.Samples/Properties/Resources.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.42000
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 |
12 | namespace DevExpressWinFormsExtension.Samples.Properties
13 | {
14 | ///
15 | /// A strongly-typed resource class, for looking up localized strings, etc.
16 | ///
17 | // This class was auto-generated by the StronglyTypedResourceBuilder
18 | // class via a tool like ResGen or Visual Studio.
19 | // To add or remove a member, edit your .ResX file then rerun ResGen
20 | // with the /str option, or rebuild your VS project.
21 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
22 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
23 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
24 | internal class Resources
25 | {
26 |
27 | private static global::System.Resources.ResourceManager resourceMan;
28 |
29 | private static global::System.Globalization.CultureInfo resourceCulture;
30 |
31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
32 | internal Resources()
33 | {
34 | }
35 |
36 | ///
37 | /// Returns the cached ResourceManager instance used by this class.
38 | ///
39 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
40 | internal static global::System.Resources.ResourceManager ResourceManager
41 | {
42 | get
43 | {
44 | if ((resourceMan == null))
45 | {
46 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("DevExpressWinFormsExtension.Samples.Properties.Resources", typeof(Resources).Assembly);
47 | resourceMan = temp;
48 | }
49 | return resourceMan;
50 | }
51 | }
52 |
53 | ///
54 | /// Overrides the current thread's CurrentUICulture property for all
55 | /// resource lookups using this strongly typed resource class.
56 | ///
57 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
58 | internal static global::System.Globalization.CultureInfo Culture
59 | {
60 | get
61 | {
62 | return resourceCulture;
63 | }
64 | set
65 | {
66 | resourceCulture = value;
67 | }
68 | }
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/DevExpressWinFormsExtension.Samples/Properties/Resources.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 | text/microsoft-resx
107 |
108 |
109 | 2.0
110 |
111 |
112 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
113 |
114 |
115 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
--------------------------------------------------------------------------------
/DevExpressWinFormsExtension.Samples/Properties/Settings.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.42000
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 |
12 | namespace DevExpressWinFormsExtension.Samples.Properties
13 | {
14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
17 | {
18 |
19 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
20 |
21 | public static Settings Default
22 | {
23 | get
24 | {
25 | return defaultInstance;
26 | }
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/DevExpressWinFormsExtension.Samples/Properties/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/DevExpressWinFormsExtension.Samples/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/DevExpressWinFormsExtension.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.32510.428
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DevExpressWinFormsExtension", "DevExpressWinFormsExtension\DevExpressWinFormsExtension.csproj", "{3638FA4B-5F64-4F9B-8D0A-F7EC7B753202}"
7 | EndProject
8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DevExpressWinFormsExtension.Samples", "DevExpressWinFormsExtension.Samples\DevExpressWinFormsExtension.Samples.csproj", "{66F9DE51-3014-443B-8825-387B48905332}"
9 | EndProject
10 | Global
11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
12 | Debug|Any CPU = Debug|Any CPU
13 | Release|Any CPU = Release|Any CPU
14 | EndGlobalSection
15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
16 | {3638FA4B-5F64-4F9B-8D0A-F7EC7B753202}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
17 | {3638FA4B-5F64-4F9B-8D0A-F7EC7B753202}.Debug|Any CPU.Build.0 = Debug|Any CPU
18 | {3638FA4B-5F64-4F9B-8D0A-F7EC7B753202}.Release|Any CPU.ActiveCfg = Release|Any CPU
19 | {3638FA4B-5F64-4F9B-8D0A-F7EC7B753202}.Release|Any CPU.Build.0 = Release|Any CPU
20 | {66F9DE51-3014-443B-8825-387B48905332}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
21 | {66F9DE51-3014-443B-8825-387B48905332}.Debug|Any CPU.Build.0 = Debug|Any CPU
22 | {66F9DE51-3014-443B-8825-387B48905332}.Release|Any CPU.ActiveCfg = Release|Any CPU
23 | {66F9DE51-3014-443B-8825-387B48905332}.Release|Any CPU.Build.0 = Release|Any CPU
24 | EndGlobalSection
25 | GlobalSection(SolutionProperties) = preSolution
26 | HideSolutionNode = FALSE
27 | EndGlobalSection
28 | GlobalSection(ExtensibilityGlobals) = postSolution
29 | SolutionGuid = {2D9B9AA8-E82D-42D3-8765-94E3CCBDA143}
30 | EndGlobalSection
31 | EndGlobal
32 |
--------------------------------------------------------------------------------
/DevExpressWinFormsExtension/DataControls/CheckedListBoxControlDev.cs:
--------------------------------------------------------------------------------
1 | using DevExpress.XtraEditors;
2 | using DevExpress.XtraEditors.Controls;
3 | using System.ComponentModel;
4 | using System.Drawing;
5 | using System.Windows.Forms;
6 |
7 | namespace DevExpressWinFormsExtension.DataControls
8 | {
9 | ///
10 | /// CheckedListBoxControl component
11 | ///
12 | /// The extension for the standard component supports hotkeys for fast check/uncheck of items. Ctrl+A: check all, Ctrl+D: uncheck all, Ctrl+I: invert checking.
13 | [ToolboxItem(true)]
14 | [ToolboxBitmap(typeof(CheckedListBoxControl))]
15 | [Description("CheckedListBoxControl with hotkeys")]
16 | public class CheckedListBoxControlDev : CheckedListBoxControl
17 | {
18 | ///
19 | /// Event on KeyDown
20 | ///
21 | /// Parameters
22 | protected override void OnKeyDown(KeyEventArgs e)
23 | {
24 | switch (e.KeyData)
25 | {
26 | case Keys.Control | Keys.D:
27 | UnCheckAll();
28 | break;
29 | case Keys.Control | Keys.A:
30 | CheckAll();
31 | break;
32 | case Keys.Control | Keys.I:
33 | {
34 | InvertSelection();
35 | break;
36 | }
37 | }
38 | }
39 |
40 | ///
41 | /// Inverse checkings
42 | ///
43 | private void InvertSelection()
44 | {
45 | BeginItemsCheck();
46 | try
47 | {
48 | foreach (CheckedListBoxItem item in Items)
49 | {
50 | item.CheckState = item.CheckState == CheckState.Checked ? CheckState.Unchecked : CheckState.Checked;
51 | }
52 | }
53 | finally
54 | {
55 | EndItemsCheck();
56 | }
57 | }
58 | }
59 | }
--------------------------------------------------------------------------------
/DevExpressWinFormsExtension/DataControls/ColorPickEdit/ColorPickEditDev.Designer.cs:
--------------------------------------------------------------------------------
1 | using System.ComponentModel;
2 |
3 | namespace DevExpressWinFormsExtension.DataControls.ColorPickEdit
4 | {
5 | partial class ColorPickEditDev
6 | {
7 | ///
8 | /// Required designer variable.
9 | ///
10 | private IContainer components = null;
11 |
12 | ///
13 | /// Clean up any resources being used.
14 | ///
15 | /// true if managed resources should be disposed; otherwise, false.
16 | protected override void Dispose(bool disposing)
17 | {
18 | if (disposing && (components != null))
19 | {
20 | components.Dispose();
21 | }
22 | base.Dispose(disposing);
23 | }
24 |
25 | #region Component Designer generated code
26 |
27 | ///
28 | /// Required method for Designer support - do not modify
29 | /// the contents of this method with the code editor.
30 | ///
31 | private void InitializeComponent()
32 | {
33 | this.fProperties = new DevExpress.XtraEditors.Repository.RepositoryItemColorEdit();
34 | ((System.ComponentModel.ISupportInitialize)(this.fProperties)).BeginInit();
35 | this.SuspendLayout();
36 | //
37 | // fProperties
38 | //
39 | this.fProperties.Buttons.AddRange(new DevExpress.XtraEditors.Controls.EditorButton[] {
40 | new DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Combo)});
41 | this.fProperties.Name = "fProperties";
42 | //
43 | // ColorEdit
44 | //
45 | ((System.ComponentModel.ISupportInitialize)(this.fProperties)).EndInit();
46 | this.ResumeLayout(false);
47 |
48 | }
49 |
50 | #endregion
51 |
52 | private new DevExpress.XtraEditors.Repository.RepositoryItemColorEdit fProperties;
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/DevExpressWinFormsExtension/DataControls/ColorPickEdit/ColorPickEditDev.cs:
--------------------------------------------------------------------------------
1 | using DevExpress.XtraEditors;
2 | using DevExpress.XtraEditors.Popup;
3 | using System.ComponentModel;
4 | using System.Drawing;
5 | using System.Reflection;
6 |
7 | namespace DevExpressWinFormsExtension.DataControls.ColorPickEdit
8 | {
9 | ///
10 | /// ColorPickEdit component
11 | ///
12 | /// The extension for the standard components allows to save custom user colors during the program, so each ColorPickEdit and RepositoryItemColorPickEdit will have the same, actual user colors.
13 | [ToolboxItem(true)]
14 | [ToolboxBitmap(typeof(DevExpress.XtraEditors.ColorPickEdit))]
15 | [Description("ColorPickEdit component")]
16 | public partial class ColorPickEditDev : DevExpress.XtraEditors.ColorPickEdit
17 | {
18 | ///
19 | /// Parameterless constructor
20 | ///
21 | public ColorPickEditDev()
22 | {
23 | InitializeComponent();
24 | Properties.ColorPickDialogClosed += Properties_ColorPickDialogClosed;
25 | }
26 |
27 | ///
28 | /// Event on dialog closed
29 | ///
30 | /// Source
31 | /// Parameters
32 | private void Properties_ColorPickDialogClosed(object sender, ColorPickDialogClosedEventArgs e)
33 | {
34 | ColorPickEditUtils.SaveCustomUserColors(Properties.RecentColors);
35 | }
36 |
37 | ///
38 | /// Event on showing popup dialog
39 | ///
40 | public override void ShowPopup()
41 | {
42 | ColorPickEditUtils.InitializeCustomColors(Properties.RecentColors);
43 | var popupFormProperty = typeof(DevExpress.XtraEditors.ColorPickEdit).GetProperty("PopupForm", BindingFlags.Instance | BindingFlags.NonPublic);
44 | if (popupFormProperty?.GetValue(this, null) is PopupColorEditForm popupForm)
45 | {
46 | popupForm.TabControl.SelectedTabPageIndex = 0;
47 | }
48 |
49 | base.ShowPopup();
50 | }
51 | }
52 | }
--------------------------------------------------------------------------------
/DevExpressWinFormsExtension/DataControls/ColorPickEdit/ColorPickEditUtils.cs:
--------------------------------------------------------------------------------
1 | using DevExpress.XtraEditors.ColorPickEditControl;
2 | using System.Collections.Generic;
3 | using System.Drawing;
4 |
5 | namespace DevExpressWinFormsExtension.DataControls.ColorPickEdit
6 | {
7 | ///
8 | /// Utils for ColorPickUpEdit components
9 | ///
10 | internal static class ColorPickEditUtils
11 | {
12 | ///
13 | /// All user-defiended colors, to apply for all pickup components in a program
14 | ///
15 | /// If necessary - can save them to xml.
16 | internal static List CustomUserColors = new List();
17 |
18 | ///
19 | /// Initialize user custom colors in editors
20 | ///
21 | /// An editor color matrix
22 | internal static void InitializeCustomColors(Matrix editorColorsMatrix)
23 | {
24 | if (CustomUserColors.Count == 0)
25 | {
26 | return;
27 | }
28 |
29 | editorColorsMatrix.Clear();
30 | for (var i = 0; i < CustomUserColors.Count; ++i)
31 | {
32 | var color = CustomUserColors[i];
33 | editorColorsMatrix[0, i] = color;
34 | }
35 | }
36 |
37 | ///
38 | /// Save user defined colors
39 | ///
40 | /// Editor colors matrix
41 | internal static void SaveCustomUserColors(Matrix editorColorsMatrix)
42 | {
43 | CustomUserColors.Clear();
44 | for (var i = 0; i < editorColorsMatrix.ColumnCount; i++)
45 | {
46 | var color = editorColorsMatrix[0, i];
47 | if (color.IsEmpty || color.A == 0)
48 | {
49 | continue;
50 | }
51 |
52 | CustomUserColors.Add(color);
53 | }
54 | }
55 | }
56 | }
--------------------------------------------------------------------------------
/DevExpressWinFormsExtension/DataControls/ColorPickEdit/RepositoryItemColorPickEditDev.Designer.cs:
--------------------------------------------------------------------------------
1 | using System.ComponentModel;
2 |
3 | namespace DevExpressWinFormsExtension.DataControls.ColorPickEdit
4 | {
5 | partial class RepositoryItemColorPickEditDev
6 | {
7 | ///
8 | /// Required designer variable.
9 | ///
10 | private IContainer components = null;
11 |
12 | ///
13 | /// Clean up any resources being used.
14 | ///
15 | /// true if managed resources should be disposed; otherwise, false.
16 | protected override void Dispose(bool disposing)
17 | {
18 | if (disposing && (components != null))
19 | {
20 | components.Dispose();
21 | }
22 | base.Dispose(disposing);
23 | }
24 |
25 | #region Component Designer generated code
26 |
27 | ///
28 | /// Required method for Designer support - do not modify
29 | /// the contents of this method with the code editor.
30 | ///
31 | private void InitializeComponent()
32 | {
33 | ((System.ComponentModel.ISupportInitialize)(this)).BeginInit();
34 | //
35 | // RepositoryItemColorEdit
36 | //
37 | ((System.ComponentModel.ISupportInitialize)(this)).EndInit();
38 |
39 | }
40 |
41 | #endregion
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/DevExpressWinFormsExtension/DataControls/ColorPickEdit/RepositoryItemColorPickEditDev.cs:
--------------------------------------------------------------------------------
1 | using DevExpress.XtraEditors;
2 | using DevExpress.XtraEditors.Popup;
3 | using System;
4 | using System.Reflection;
5 |
6 | namespace DevExpressWinFormsExtension.DataControls.ColorPickEdit
7 | {
8 | ///
9 | /// RepositoryItemColorPickEdit component
10 | ///
11 | /// The extension for the standard components allows to save custom user colors during the program, so each ColorPickEdit and RepositoryItemColorPickEdit will have the same, actual user colors.
12 | public partial class RepositoryItemColorPickEditDev : DevExpress.XtraEditors.Repository.RepositoryItemColorPickEdit
13 | {
14 | ///
15 | /// Parameterless constructor
16 | ///
17 | public RepositoryItemColorPickEditDev()
18 | {
19 | InitializeComponent();
20 | ColorPickDialogClosed += Properties_ColorPickDialogClosed;
21 | BeforePopup += RepositoryItemColorEdit_BeforePopup;
22 | Popup += RepositoryItemColorEdit_Popup;
23 | }
24 |
25 | ///
26 | /// Event before a dialog popup
27 | ///
28 | /// Source
29 | /// Parameters
30 | private void RepositoryItemColorEdit_Popup(object sender, EventArgs e)
31 | {
32 | var popupFormProperty = typeof(DevExpress.XtraEditors.ColorPickEdit).GetProperty("PopupForm", BindingFlags.Instance | BindingFlags.NonPublic);
33 | if (popupFormProperty?.GetValue(this, null) is PopupColorEditForm popupForm)
34 | {
35 | popupForm.TabControl.SelectedTabPageIndex = 0;
36 | }
37 | }
38 |
39 | ///
40 | /// Event before a dialog popup
41 | ///
42 | /// Source
43 | /// Parameters
44 | private void RepositoryItemColorEdit_BeforePopup(object sender, EventArgs e)
45 | {
46 | ColorPickEditUtils.InitializeCustomColors(RecentColors);
47 | }
48 |
49 | ///
50 | /// Event on dialog closed
51 | ///
52 | /// Source
53 | /// Parameters
54 | private void Properties_ColorPickDialogClosed(object sender, ColorPickDialogClosedEventArgs e)
55 | {
56 | ColorPickEditUtils.SaveCustomUserColors(RecentColors);
57 | }
58 | }
59 | }
--------------------------------------------------------------------------------
/DevExpressWinFormsExtension/DataControls/DateDoubleTrackBarControlDev.Designer.cs:
--------------------------------------------------------------------------------
1 | namespace DevExpressWinFormsExtension.DataControls
2 | {
3 | partial class DateDoubleTrackBarControlDev
4 | {
5 | ///
6 | /// Required designer variable.
7 | ///
8 | private System.ComponentModel.IContainer components = null;
9 |
10 | ///
11 | /// Clean up any resources being used.
12 | ///
13 | /// true if managed resources should be disposed; otherwise, false.
14 | protected override void Dispose(bool disposing)
15 | {
16 | if (disposing && (components != null))
17 | {
18 | components.Dispose();
19 | }
20 | base.Dispose(disposing);
21 | }
22 |
23 | #region Component Designer generated code
24 |
25 | ///
26 | /// Required method for Designer support - do not modify
27 | /// the contents of this method with the code editor.
28 | ///
29 | private void InitializeComponent()
30 | {
31 | this.components = new System.ComponentModel.Container();
32 | this.btnLeftDate = new DevExpress.XtraEditors.SimpleButton();
33 | this.btnMiddle = new DevExpress.XtraEditors.SimpleButton();
34 | this.btnRightDate = new DevExpress.XtraEditors.SimpleButton();
35 | this.toolTipController = new DevExpress.Utils.ToolTipController(this.components);
36 | this.SuspendLayout();
37 | //
38 | // btnLeftDate
39 | //
40 | this.btnLeftDate.AllowFocus = false;
41 | this.btnLeftDate.Cursor = System.Windows.Forms.Cursors.SizeWE;
42 | this.btnLeftDate.Location = new System.Drawing.Point(3, 3);
43 | this.btnLeftDate.Name = "btnLeftDate";
44 | this.btnLeftDate.Size = new System.Drawing.Size(25, 31);
45 | this.btnLeftDate.TabIndex = 1;
46 | this.btnLeftDate.Text = "<";
47 | this.btnLeftDate.ToolTipController = this.toolTipController;
48 | this.btnLeftDate.MouseDown += new System.Windows.Forms.MouseEventHandler(this.dragButton_MouseDown);
49 | this.btnLeftDate.MouseMove += new System.Windows.Forms.MouseEventHandler(this.dragButton_MouseMove);
50 | this.btnLeftDate.MouseUp += new System.Windows.Forms.MouseEventHandler(this.dragButton_MouseUp);
51 | //
52 | // btnMiddle
53 | //
54 | this.btnMiddle.AllowFocus = false;
55 | this.btnMiddle.Cursor = System.Windows.Forms.Cursors.SizeWE;
56 | this.btnMiddle.Location = new System.Drawing.Point(34, 3);
57 | this.btnMiddle.Name = "btnMiddle";
58 | this.btnMiddle.Size = new System.Drawing.Size(25, 31);
59 | this.btnMiddle.TabIndex = 1;
60 | this.btnMiddle.Text = "|";
61 | this.btnMiddle.ToolTipController = this.toolTipController;
62 | this.btnMiddle.MouseDown += new System.Windows.Forms.MouseEventHandler(this.dragButton_MouseDown);
63 | this.btnMiddle.MouseMove += new System.Windows.Forms.MouseEventHandler(this.dragButton_MouseMove);
64 | this.btnMiddle.MouseUp += new System.Windows.Forms.MouseEventHandler(this.dragButton_MouseUp);
65 | //
66 | // btnRightDate
67 | //
68 | this.btnRightDate.AllowFocus = false;
69 | this.btnRightDate.Cursor = System.Windows.Forms.Cursors.SizeWE;
70 | this.btnRightDate.Location = new System.Drawing.Point(65, 3);
71 | this.btnRightDate.Name = "btnRightDate";
72 | this.btnRightDate.Size = new System.Drawing.Size(25, 31);
73 | this.btnRightDate.TabIndex = 1;
74 | this.btnRightDate.Text = ">";
75 | this.btnRightDate.ToolTipController = this.toolTipController;
76 | this.btnRightDate.MouseDown += new System.Windows.Forms.MouseEventHandler(this.dragButton_MouseDown);
77 | this.btnRightDate.MouseMove += new System.Windows.Forms.MouseEventHandler(this.dragButton_MouseMove);
78 | this.btnRightDate.MouseUp += new System.Windows.Forms.MouseEventHandler(this.dragButton_MouseUp);
79 | //
80 | // DateDoubleTrackBarControlDev
81 | //
82 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
83 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
84 | this.Controls.Add(this.btnLeftDate);
85 | this.Controls.Add(this.btnMiddle);
86 | this.Controls.Add(this.btnRightDate);
87 | this.DoubleBuffered = true;
88 | this.Name = "DateDoubleTrackBarControlDev";
89 | this.Size = new System.Drawing.Size(253, 61);
90 | this.ResumeLayout(false);
91 |
92 | }
93 |
94 | #endregion
95 |
96 | private DevExpress.XtraEditors.SimpleButton btnLeftDate;
97 | private DevExpress.XtraEditors.SimpleButton btnMiddle;
98 | private DevExpress.XtraEditors.SimpleButton btnRightDate;
99 | private DevExpress.Utils.ToolTipController toolTipController;
100 | }
101 | }
102 |
--------------------------------------------------------------------------------
/DevExpressWinFormsExtension/DataControls/Extensions/BaseEditExtension.cs:
--------------------------------------------------------------------------------
1 | using DevExpress.XtraEditors;
2 | using System;
3 | using DevExpressWinFormsExtension.Utils;
4 |
5 | namespace DevExpressWinFormsExtension.DataControls.Extensions
6 | {
7 | ///
8 | /// Extension for BaseEdit
9 | ///
10 | public static class BaseEditExtension
11 | {
12 | ///
13 | /// Check if no set value in the editor.
14 | ///
15 | /// Editor
16 | /// Flag, if need to set warning back color on empty value
17 | /// True, if value empty
18 | public static bool IsValueEmpty(this BaseEdit editor, bool setWarningColor = false)
19 | {
20 | bool isValid;
21 | if (editor is TextEdit && !(editor is PopupContainerEdit))
22 | {
23 | isValid = !string.IsNullOrWhiteSpace(editor.Text);
24 | }
25 | else if (editor is DateEdit)
26 | {
27 | var dateEdit = editor as DateEdit;
28 | isValid = dateEdit.DateTime != DateTime.MinValue && dateEdit.DateTime != DateTime.MaxValue;
29 | }
30 | else
31 | {
32 | isValid = editor.EditValue != null && !string.IsNullOrWhiteSpace(editor.EditValue.ToString());
33 | }
34 |
35 | if (setWarningColor)
36 | {
37 | editor.BackColor = isValid ? SkinHelper.GetEditorBackColor() : SkinHelper.GetEditorWarningBackColor();
38 | }
39 |
40 | return !isValid;
41 | }
42 | }
43 | }
--------------------------------------------------------------------------------
/DevExpressWinFormsExtension/DataControls/Extensions/ChartControlExtension.cs:
--------------------------------------------------------------------------------
1 | using DevExpress.XtraCharts;
2 | using DevExpressWinFormsExtension.Utils;
3 | using System;
4 | using System.Collections.Generic;
5 | using System.Drawing;
6 | using System.Linq;
7 |
8 | namespace DevExpressWinFormsExtension.DataControls.Extensions
9 | {
10 | ///
11 | /// Extension for the ChartControl component
12 | ///
13 | public static class ChartControlExtension
14 | {
15 | ///
16 | /// Information about lasso processors
17 | ///
18 | private static readonly Dictionary _chartControlLassoProcessors = new Dictionary();
19 |
20 | ///
21 | /// Change the hue for series with the same color
22 | ///
23 | /// Chart control
24 | public static void ColorizeSameColoredSeries(this ChartControl chartControl)
25 | {
26 | var colorSeries = new Dictionary>();
27 | var series = chartControl.Series.Where(serie => serie.Visible).ToList();
28 | foreach (Series serie in series)
29 | {
30 | var color = serie.View.Color;
31 | if (!colorSeries.ContainsKey(color))
32 | {
33 | colorSeries.Add(color, new List() { serie });
34 | }
35 | else
36 | {
37 | colorSeries[color].Add(serie);
38 | }
39 | }
40 |
41 | const float colorizeKoef = 200f;
42 | foreach (Series serie in series)
43 | {
44 | var seriesList = colorSeries[serie.View.Color];
45 | if (seriesList.Count < 2)
46 | {
47 | continue;
48 | }
49 |
50 | var serieIndex = seriesList.IndexOf(serie);
51 | var percent = (((serieIndex + 1) * (colorizeKoef / (seriesList.Count + 1))) - 100) / 100f;
52 | if (percent < 0)
53 | {
54 | serie.View.Color = ColorExtension.Darken(serie.View.Color, Math.Abs(percent));
55 | }
56 | else
57 | {
58 | serie.View.Color = ColorExtension.Lighten(serie.View.Color, Math.Abs(percent));
59 | }
60 | }
61 | }
62 |
63 | ///
64 | /// Enable lasso selection in a Chart
65 | ///
66 | /// Chart control
67 | /// Selection lasso color
68 | /// Deselection lasso color
69 | /// Lasso pen width
70 | public static void EnableLassoSelection(this ChartControl chartControl, Color selectionColor = default, Color deselectionColor = default, float penWidth = 2)
71 | {
72 | new ChartControlLassoProcessor(chartControl, selectionColor, deselectionColor, penWidth);
73 | }
74 |
75 | ///
76 | /// Disable lasso selection in a Chart
77 | ///
78 | /// Chart control
79 | public static void DisableLassoSelection(this ChartControl chartControl)
80 | {
81 | if (!_chartControlLassoProcessors.ContainsKey(chartControl))
82 | {
83 | return;
84 | }
85 |
86 | _chartControlLassoProcessors[chartControl].Dispose();
87 | _chartControlLassoProcessors.Remove(chartControl);
88 | }
89 | }
90 | }
--------------------------------------------------------------------------------
/DevExpressWinFormsExtension/DataControls/Extensions/DateEditExtension.cs:
--------------------------------------------------------------------------------
1 | using DevExpress.XtraEditors;
2 | using DevExpress.XtraEditors.Repository;
3 |
4 | namespace DevExpressWinFormsExtension.DataControls.Extensions
5 | {
6 | ///
7 | /// Extension for the DateEdit component
8 | ///
9 | public static class DateEditExtension
10 | {
11 | ///
12 | /// Update view style of DateEdit editor according to the date interval type
13 | ///
14 | /// Link to the editor
15 | /// Date interval type
16 | public static void UpdateView(this DateEdit editor, VistaCalendarInitialViewStyle intervalType)
17 | {
18 | UpdateView(editor.Properties, intervalType);
19 | }
20 |
21 | ///
22 | /// Update view style of RepositoryItemDateEdit editor according to the date interval type
23 | ///
24 | /// Link to the editor
25 | /// Date interval type
26 | public static void UpdateView(this RepositoryItemDateEdit editor, VistaCalendarInitialViewStyle intervalType)
27 | {
28 | editor.CalendarView = CalendarView.Vista;
29 | editor.DisplayFormat.FormatType = DevExpress.Utils.FormatType.Custom;
30 | editor.VistaDisplayMode = DevExpress.Utils.DefaultBoolean.True;
31 | switch (intervalType)
32 | {
33 | case VistaCalendarInitialViewStyle.YearView:
34 | editor.VistaCalendarInitialViewStyle = VistaCalendarInitialViewStyle.YearsGroupView;
35 | editor.VistaCalendarViewStyle = VistaCalendarViewStyle.YearsGroupView;
36 |
37 | editor.DisplayFormat.FormatString = editor.Mask.EditMask = "yyyy";
38 | break;
39 | case VistaCalendarInitialViewStyle.QuarterView:
40 | editor.VistaCalendarInitialViewStyle = VistaCalendarInitialViewStyle.QuarterView;
41 | editor.VistaCalendarViewStyle = VistaCalendarViewStyle.QuarterView;
42 |
43 | editor.DisplayFormat.FormatString = editor.Mask.EditMask = "MMM yyyy";
44 | break;
45 | case VistaCalendarInitialViewStyle.MonthView:
46 | editor.VistaCalendarInitialViewStyle = VistaCalendarInitialViewStyle.YearView;
47 | editor.VistaCalendarViewStyle = VistaCalendarViewStyle.YearView;
48 |
49 | editor.DisplayFormat.FormatString = editor.Mask.EditMask = "MM yyyy";
50 | break;
51 | default:
52 | editor.VistaCalendarInitialViewStyle = VistaCalendarInitialViewStyle.MonthView;
53 | editor.VistaCalendarViewStyle = VistaCalendarViewStyle.All;
54 |
55 | editor.DisplayFormat.FormatString = editor.Mask.EditMask = "dd MM yyyy";
56 | break;
57 | }
58 | }
59 | }
60 | }
--------------------------------------------------------------------------------
/DevExpressWinFormsExtension/DataControls/Extensions/PropertyGridControlExtension.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.ComponentModel.DataAnnotations;
3 | using System.Linq;
4 | using System.Reflection;
5 | using DevExpress.XtraVerticalGrid;
6 | using DevExpress.XtraVerticalGrid.Rows;
7 |
8 | namespace DevExpressWinFormsExtension.DataControls.Extensions
9 | {
10 | ///
11 | /// Extensions for PropertyGridControl
12 | ///
13 | public static class PropertyGridControlExtension
14 | {
15 | ///
16 | /// Reorder field rows by a "Display/Order" attribute
17 | ///
18 | /// PropertyGridControl
19 | /// Was in v21 DevExpress. Fixed in v22.
20 | public static void UpdateFieldsOrderByDisplayOrder(this PropertyGridControl control)
21 | {
22 | control.BeginUpdate();
23 | try
24 | {
25 | foreach (var row in control.Rows)
26 | {
27 | UpdateRowOrder(row, null);
28 | }
29 | }
30 | finally
31 | {
32 | control.EndUpdate();
33 | }
34 | }
35 |
36 | ///
37 | /// Supported recursive void for ordering
38 | ///
39 | /// Current row
40 | /// Base category type
41 | private static void UpdateRowOrder(BaseRow row, Type categoryType)
42 | {
43 | foreach (var child in row.ChildRows)
44 | {
45 | UpdateRowOrder(child, row.Properties.RowType);
46 | }
47 |
48 | var type = categoryType ?? row.Properties.RowType;
49 | var property = type.GetProperty(row.Properties.FieldName);
50 | if (property?.GetCustomAttributes().FirstOrDefault(a => a is DisplayAttribute) is DisplayAttribute displayAttribute)
51 | {
52 | row.SetOrder(int.MaxValue - displayAttribute.Order); // As DevExpress used reversed order for rows
53 | }
54 | }
55 | }
56 | }
--------------------------------------------------------------------------------
/DevExpressWinFormsExtension/DataControls/Forms/Utils/ShowControlParentForm.Designer.cs:
--------------------------------------------------------------------------------
1 |
2 | namespace DevExpressWinFormsExtension.DataControls.Forms.Utils
3 | {
4 | partial class ShowControlParentForm
5 | {
6 | ///
7 | /// Required designer variable.
8 | ///
9 | private System.ComponentModel.IContainer components = null;
10 |
11 | ///
12 | /// Clean up any resources being used.
13 | ///
14 | /// true if managed resources should be disposed; otherwise, false.
15 | protected override void Dispose(bool disposing)
16 | {
17 | if (disposing && (components != null))
18 | {
19 | components.Dispose();
20 | }
21 | base.Dispose(disposing);
22 | }
23 |
24 | #region Windows Form Designer generated code
25 |
26 | ///
27 | /// Required method for Designer support - do not modify
28 | /// the contents of this method with the code editor.
29 | ///
30 | private void InitializeComponent()
31 | {
32 | this.components = new System.ComponentModel.Container();
33 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
34 | this.ClientSize = new System.Drawing.Size(800, 450);
35 | this.Text = "frmControlBox";
36 | }
37 |
38 | #endregion
39 | }
40 | }
--------------------------------------------------------------------------------
/DevExpressWinFormsExtension/DataControls/Forms/Utils/ShowControlParentForm.cs:
--------------------------------------------------------------------------------
1 | using DevExpress.XtraEditors;
2 | using DevExpressWinFormsExtension.Interfaces;
3 | using System;
4 | using System.ComponentModel;
5 | using System.Data;
6 | using System.Linq;
7 | using System.Windows.Forms;
8 | using static DevExpressWinFormsExtension.Utils.XtraUserControlHelper;
9 |
10 | namespace DevExpressWinFormsExtension.DataControls.Forms.Utils
11 | {
12 | ///
13 | /// A form to show XtraUserControl's in dialog/float modes
14 | ///
15 | internal partial class ShowControlParentForm : XtraForm
16 | {
17 | ///
18 | /// Showing mode
19 | ///
20 | private readonly ShowingControlModeEnum showingMode;
21 |
22 | ///
23 | /// Focused child on the control
24 | ///
25 | private readonly Control focusedChild;
26 |
27 | ///
28 | /// Contructor with parameters
29 | ///
30 | /// Focused child
31 | /// Showing mode
32 | public ShowControlParentForm(Control focusedChild, ShowingControlModeEnum showingMode)
33 | {
34 | this.focusedChild = focusedChild;
35 | this.showingMode = showingMode;
36 | }
37 |
38 | ///
39 | /// Event on form closed
40 | ///
41 | /// Parameters
42 | protected override void OnClosed(EventArgs e)
43 | {
44 | base.OnClosed(e);
45 | if (showingMode == ShowingControlModeEnum.Float)
46 | {
47 | Dispose();
48 | }
49 | }
50 |
51 | ///
52 | /// Event on closing
53 | ///
54 | /// Parameters
55 | protected override void OnClosing(CancelEventArgs e)
56 | {
57 | if (DialogResult != DialogResult.OK && DialogResult != DialogResult.Yes)
58 | {
59 | var allowClose = true;
60 | foreach (var control in Controls)
61 | {
62 | if (control is IClosableControl closableControl)
63 | {
64 | allowClose &= closableControl.AllowClose();
65 | }
66 | }
67 |
68 | e.Cancel = !allowClose;
69 | if (e.Cancel)
70 | {
71 | return;
72 | }
73 | }
74 |
75 | foreach (Control control in Controls)
76 | {
77 | control.Dispose();
78 | }
79 | }
80 |
81 | ///
82 | /// Event on preprocess keys
83 | ///
84 | /// Message
85 | /// Key
86 | /// True if success
87 | protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
88 | {
89 | if (keyData == Keys.Escape)
90 | {
91 | DialogResult = DialogResult.Cancel;
92 | return true;
93 | }
94 |
95 | return base.ProcessCmdKey(ref msg, keyData);
96 | }
97 |
98 | ///
99 | /// Event on key down
100 | ///
101 | /// Parameters
102 | protected override void OnKeyDown(KeyEventArgs e)
103 | {
104 | base.OnKeyDown(e);
105 | if (e.KeyCode == Keys.Escape)
106 | {
107 | Close();
108 | }
109 | }
110 |
111 | ///
112 | /// Event on form shown
113 | ///
114 | /// Source
115 | /// Parameters
116 | private void frmControlBox_Shown(object sender, EventArgs e)
117 | {
118 | if (focusedChild == null)
119 | {
120 | var control = Controls.Cast().FirstOrDefault(c => !(c is SimpleButton));
121 | control?.Focus();
122 | return;
123 | }
124 |
125 | focusedChild.Focus();
126 | }
127 | }
128 | }
--------------------------------------------------------------------------------
/DevExpressWinFormsExtension/DataControls/Forms/XtraFormDev.cs:
--------------------------------------------------------------------------------
1 | using DevExpress.XtraEditors;
2 | using System.ComponentModel;
3 | using System.Drawing;
4 | using System.Windows.Forms.Design;
5 |
6 | namespace DevExpressWinFormsExtension.DataControls.Forms
7 | {
8 | ///
9 | /// XtraForm with the update mechanism
10 | ///
11 | [ToolboxItem(true)]
12 | [ToolboxBitmap(typeof(XtraForm))]
13 | [Designer(typeof(ParentControlDesigner))]
14 | [Description("XtraForm with the update mechanism")]
15 | public class XtraFormDev : XtraForm
16 | {
17 | ///
18 | /// Update depth
19 | ///
20 | private byte updateDepth;
21 |
22 | ///
23 | /// If form is updating
24 | ///
25 | protected bool IsLockUpdating
26 | {
27 | get
28 | {
29 | return updateDepth > 0;
30 | }
31 | }
32 |
33 | ///
34 | /// Begin update
35 | ///
36 | protected void BeginUpdate()
37 | {
38 | OnBeginUpdate();
39 | }
40 |
41 | ///
42 | /// End update
43 | ///
44 | protected void EndUpdate()
45 | {
46 | OnEndUpdate();
47 | }
48 |
49 | ///
50 | /// Event on begin update
51 | ///
52 | protected virtual void OnBeginUpdate()
53 | {
54 | updateDepth++;
55 | }
56 |
57 | ///
58 | /// Event on end update
59 | ///
60 | protected virtual void OnEndUpdate()
61 | {
62 | if (updateDepth > 0)
63 | {
64 | updateDepth--;
65 | }
66 | }
67 | }
68 | }
--------------------------------------------------------------------------------
/DevExpressWinFormsExtension/DataControls/Forms/XtraUserControlDev.cs:
--------------------------------------------------------------------------------
1 | using DevExpress.XtraEditors;
2 | using System.ComponentModel;
3 | using System.Drawing;
4 | using System.Windows.Forms.Design;
5 |
6 | namespace DevExpressWinFormsExtension.DataControls.Forms
7 | {
8 | ///
9 | /// XtraUserControl with the update mechanism
10 | ///
11 | [ToolboxItem(true)]
12 | [ToolboxBitmap(typeof(XtraUserControl))]
13 | [Designer(typeof(ParentControlDesigner))]
14 | [Description("XtraUserControl with the update mechanism")]
15 | public class XtraUserControlDev : XtraUserControl
16 | {
17 | ///
18 | /// Update depth
19 | ///
20 | private byte updateDepth;
21 |
22 | ///
23 | /// If form is updating
24 | ///
25 | protected bool IsLockUpdating
26 | {
27 | get
28 | {
29 | return updateDepth > 0;
30 | }
31 | }
32 |
33 | ///
34 | /// Begin update
35 | ///
36 | protected void BeginUpdate()
37 | {
38 | OnBeginUpdate();
39 | }
40 |
41 | ///
42 | /// End update
43 | ///
44 | protected void EndUpdate()
45 | {
46 | OnEndUpdate();
47 | }
48 |
49 | ///
50 | /// Event on begin update
51 | ///
52 | protected virtual void OnBeginUpdate()
53 | {
54 | updateDepth++;
55 | }
56 |
57 | ///
58 | /// Event on end update
59 | ///
60 | protected virtual void OnEndUpdate()
61 | {
62 | if (updateDepth > 0)
63 | {
64 | updateDepth--;
65 | }
66 | }
67 | }
68 | }
--------------------------------------------------------------------------------
/DevExpressWinFormsExtension/DataControls/GridView/GridControlDev.cs:
--------------------------------------------------------------------------------
1 | using DevExpress.XtraGrid;
2 | using DevExpress.XtraGrid.Registrator;
3 | using DevExpress.XtraGrid.Views.Base;
4 | using DevExpressWinFormsExtension.DataControls.GridView.Utils;
5 | using System.ComponentModel;
6 | using System.Drawing;
7 |
8 | namespace DevExpressWinFormsExtension.DataControls.GridView
9 | {
10 | ///
11 | /// GridControl with registration of GridView/BandedGridView views.
12 | ///
13 | [ToolboxItem(true)]
14 | [ToolboxBitmap(typeof(GridControl))]
15 | [Description("GridControl")]
16 | public partial class GridControlDev : GridControl
17 | {
18 | ///
19 | /// Create default view
20 | ///
21 | /// View
22 | protected override BaseView CreateDefaultView()
23 | {
24 | return CreateView(typeof(GridViewDev).Name);
25 | }
26 |
27 | ///
28 | /// Register custom views
29 | ///
30 | /// Views list
31 | protected override void RegisterAvailableViewsCore(InfoCollection collection)
32 | {
33 | base.RegisterAvailableViewsCore(collection);
34 | collection.Add(new GridViewDevInfoRegistrator());
35 | collection.Add(new BandedGridDevInfoRegistrator());
36 | }
37 |
38 | ///
39 | /// Create view
40 | ///
41 | /// View name
42 | /// View
43 | /// View
44 | public override BaseView CreateView(string name)
45 | {
46 | if (name == typeof(DevExpress.XtraGrid.Views.Grid.GridView).Name)
47 | {
48 | name = typeof(GridViewDev).Name;
49 | }
50 | else if (name == typeof(DevExpress.XtraGrid.Views.BandedGrid.BandedGridView).Name)
51 | {
52 | name = typeof(BandedGridViewDev).Name;
53 | }
54 |
55 | return base.CreateView(name);
56 | }
57 | }
58 | }
--------------------------------------------------------------------------------
/DevExpressWinFormsExtension/DataControls/GridView/GridControlDev.designer.cs:
--------------------------------------------------------------------------------
1 | namespace DevExpressWinFormsExtension.DataControls.GridView
2 | {
3 | partial class GridControlDev
4 | {
5 | ///
6 | /// Required designer variable.
7 | ///
8 | private System.ComponentModel.IContainer components = null;
9 |
10 | ///
11 | /// Clean up any resources being used.
12 | ///
13 | /// true if managed resources should be disposed; otherwise, false.
14 | protected override void Dispose(bool disposing)
15 | {
16 | if (disposing && (components != null))
17 | {
18 | components.Dispose();
19 | }
20 | base.Dispose(disposing);
21 | }
22 |
23 | #region Component Designer generated code
24 |
25 | ///
26 | /// Required method for Designer support - do not modify
27 | /// the contents of this method with the code editor.
28 | ///
29 | private void InitializeComponent()
30 | {
31 | components = new System.ComponentModel.Container();
32 | }
33 |
34 | #endregion
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/DevExpressWinFormsExtension/DataControls/GridView/HistogramData.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Drawing;
3 |
4 | namespace DevExpressWinFormsExtension.DataControls.GridView
5 | {
6 | ///
7 | /// Data for the histogram
8 | ///
9 | public class HistogramData
10 | {
11 | ///
12 | /// Contructor with parameters
13 | ///
14 | /// Pre-calced points
15 | /// Min value
16 | /// Max value
17 | public HistogramData(IEnumerable points, double min, double max)
18 | {
19 | Points = points;
20 | Min = min;
21 | Max = max;
22 | }
23 |
24 | ///
25 | /// Histogram pre-calced points
26 | ///
27 | public IEnumerable Points { get; private set; }
28 |
29 | ///
30 | /// Min value
31 | ///
32 | public double Min { get; private set; }
33 |
34 | ///
35 | /// Max value
36 | ///
37 | public double Max { get; private set; }
38 | }
39 | }
--------------------------------------------------------------------------------
/DevExpressWinFormsExtension/DataControls/GridView/Utils/BandedGridDevInfoRegistrator.cs:
--------------------------------------------------------------------------------
1 | using DevExpress.XtraGrid;
2 | using DevExpress.XtraGrid.Registrator;
3 | using DevExpress.XtraGrid.Views.Base;
4 | using DevExpress.XtraGrid.Views.Base.ViewInfo;
5 |
6 | namespace DevExpressWinFormsExtension.DataControls.GridView.Utils
7 | {
8 | ///
9 | /// Custom BandedGridViewDev registrator
10 | ///
11 | public class BandedGridDevInfoRegistrator : BandedGridInfoRegistrator
12 | {
13 | ///
14 | /// Custom view name
15 | ///
16 | public override string ViewName
17 | {
18 | get
19 | {
20 | return "BandedGridViewDev";
21 | }
22 | }
23 |
24 | ///
25 | /// Create custom view
26 | ///
27 | /// GridControl
28 | /// View
29 | public override BaseView CreateView(GridControl grid)
30 | {
31 | return new BandedGridViewDev(grid);
32 | }
33 |
34 | ///
35 | /// Create custom view info
36 | ///
37 | /// View
38 | /// ViewInfo
39 | public override BaseViewInfo CreateViewInfo(BaseView view)
40 | {
41 | return new BandedGridViewInfoDev(view as BandedGridViewDev);
42 | }
43 | }
44 | }
--------------------------------------------------------------------------------
/DevExpressWinFormsExtension/DataControls/GridView/Utils/BandedGridViewInfoDev.cs:
--------------------------------------------------------------------------------
1 | namespace DevExpressWinFormsExtension.DataControls.GridView.Utils
2 | {
3 | ///
4 | /// Custom BandedGridViewInfo
5 | ///
6 | internal class BandedGridViewInfoDev : DevExpress.XtraGrid.Views.BandedGrid.ViewInfo.BandedGridViewInfo
7 | {
8 | ///
9 | /// Constructor with parameters
10 | ///
11 | /// Link to GridView
12 | public BandedGridViewInfoDev(DevExpress.XtraGrid.Views.BandedGrid.BandedGridView gridView)
13 | : base(gridView)
14 | {
15 | }
16 |
17 | ///
18 | /// Custom group footer height
19 | ///
20 | public override int GroupFooterCellHeight
21 | {
22 | get
23 | {
24 | var devGridView = DefaultView as BandedGridViewDev;
25 | var multiplier = devGridView?.GroupFooterCellHeight ?? 1;
26 |
27 | return base.GroupFooterCellHeight * multiplier;
28 | }
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/DevExpressWinFormsExtension/DataControls/GridView/Utils/GridViewDevInfoRegistrator.cs:
--------------------------------------------------------------------------------
1 | using DevExpress.XtraGrid;
2 | using DevExpress.XtraGrid.Registrator;
3 | using DevExpress.XtraGrid.Views.Base;
4 | using DevExpress.XtraGrid.Views.Base.ViewInfo;
5 |
6 | namespace DevExpressWinFormsExtension.DataControls.GridView.Utils
7 | {
8 | ///
9 | /// Custom GridViewDev registrator
10 | ///
11 | public class GridViewDevInfoRegistrator : GridInfoRegistrator
12 | {
13 | ///
14 | /// Custom view name
15 | ///
16 | public override string ViewName
17 | {
18 | get
19 | {
20 | return "GridViewDev";
21 | }
22 | }
23 |
24 | ///
25 | /// Create custom view
26 | ///
27 | /// GridControl
28 | /// View
29 | public override BaseView CreateView(GridControl grid)
30 | {
31 | return new GridViewDev(grid);
32 | }
33 |
34 | ///
35 | /// Create custom view info
36 | ///
37 | /// View
38 | /// ViewInfo
39 | public override BaseViewInfo CreateViewInfo(BaseView view)
40 | {
41 | return new GridViewInfoDev(view as GridViewDev);
42 | }
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/DevExpressWinFormsExtension/DataControls/GridView/Utils/GridViewInfoDev.cs:
--------------------------------------------------------------------------------
1 | namespace DevExpressWinFormsExtension.DataControls.GridView.Utils
2 | {
3 | ///
4 | /// Custom GridViewInfo
5 | ///
6 | internal class GridViewInfoDev : DevExpress.XtraGrid.Views.Grid.ViewInfo.GridViewInfo
7 | {
8 | ///
9 | /// Constructor with parameters
10 | ///
11 | /// Link to GridView
12 | public GridViewInfoDev(DevExpress.XtraGrid.Views.Grid.GridView gridView) : base(gridView)
13 | {
14 | }
15 |
16 | ///
17 | /// Custom group footer height
18 | ///
19 | public override int GroupFooterCellHeight
20 | {
21 | get
22 | {
23 | var devGridView = DefaultView as GridViewDev;
24 | var multiplier = devGridView?.GroupFooterCellHeight ?? 1;
25 |
26 | return base.GroupFooterCellHeight * multiplier;
27 | }
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/DevExpressWinFormsExtension/DataControls/GroupControlCheckedDev.Designer.cs:
--------------------------------------------------------------------------------
1 |
2 | namespace DevExpressWinFormsExtension.DataControls
3 | {
4 | partial class GroupControlCheckedDev
5 | {
6 | ///
7 | /// Required designer variable.
8 | ///
9 | private System.ComponentModel.IContainer components = null;
10 |
11 | ///
12 | /// Clean up any resources being used.
13 | ///
14 | /// true if managed resources should be disposed; otherwise, false.
15 | protected override void Dispose(bool disposing)
16 | {
17 | if (disposing && (components != null))
18 | {
19 | components.Dispose();
20 | }
21 | base.Dispose(disposing);
22 | }
23 |
24 | #region Component Designer generated code
25 |
26 | ///
27 | /// Required method for Designer support - do not modify
28 | /// the contents of this method with the code editor.
29 | ///
30 | private void InitializeComponent()
31 | {
32 | this.header = new DevExpress.XtraEditors.PanelControl();
33 | this.checkEdit = new DevExpress.XtraEditors.CheckEdit();
34 | ((System.ComponentModel.ISupportInitialize)(this.header)).BeginInit();
35 | this.header.SuspendLayout();
36 | ((System.ComponentModel.ISupportInitialize)(this.checkEdit.Properties)).BeginInit();
37 | this.SuspendLayout();
38 | //
39 | // header
40 | //
41 | this.header.Controls.Add(this.checkEdit);
42 | this.header.Dock = System.Windows.Forms.DockStyle.Top;
43 | this.header.Location = new System.Drawing.Point(0, 0);
44 | this.header.Margin = new System.Windows.Forms.Padding(0, 3, 0, 3);
45 | this.header.Name = "header";
46 | this.header.Size = new System.Drawing.Size(253, 19);
47 | this.header.TabIndex = 0;
48 | //
49 | // checkEdit
50 | //
51 | this.checkEdit.AutoSizeInLayoutControl = true;
52 | this.checkEdit.EditValue = true;
53 | this.checkEdit.Location = new System.Drawing.Point(5, 0);
54 | this.checkEdit.Margin = new System.Windows.Forms.Padding(3, 0, 0, 0);
55 | this.checkEdit.Name = "checkEdit";
56 | this.checkEdit.Properties.AllowFocused = false;
57 | this.checkEdit.Properties.AutoWidth = true;
58 | this.checkEdit.Properties.Caption = "GroupBox Title";
59 | this.checkEdit.Properties.CheckBoxOptions.Style = DevExpress.XtraEditors.Controls.CheckBoxStyle.CheckBox;
60 | this.checkEdit.Size = new System.Drawing.Size(92, 19);
61 | this.checkEdit.TabIndex = 1;
62 | this.checkEdit.CheckedChanged += new System.EventHandler(this.CheckEditCheckedChanged);
63 | //
64 | // GroupControlWithCheckBox
65 | //
66 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
67 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
68 | this.Controls.Add(this.header);
69 | this.Name = "GroupControlWithCheckBox";
70 | this.Size = new System.Drawing.Size(253, 86);
71 | this.ControlAdded += new System.Windows.Forms.ControlEventHandler(this.GroupControlWithCheckBoxControlAdded);
72 | ((System.ComponentModel.ISupportInitialize)(this.header)).EndInit();
73 | this.header.ResumeLayout(false);
74 | this.header.PerformLayout();
75 | ((System.ComponentModel.ISupportInitialize)(this.checkEdit.Properties)).EndInit();
76 | this.ResumeLayout(false);
77 |
78 | }
79 |
80 | #endregion
81 |
82 | private DevExpress.XtraEditors.PanelControl header;
83 | private DevExpress.XtraEditors.CheckEdit checkEdit;
84 | }
85 | }
86 |
--------------------------------------------------------------------------------
/DevExpressWinFormsExtension/DataControls/GroupControlCheckedDev.cs:
--------------------------------------------------------------------------------
1 | using DevExpress.XtraEditors;
2 | using DevExpress.XtraEditors.Controls;
3 | using DevExpressWinFormsExtension.DataControls.Forms;
4 | using System;
5 | using System.ComponentModel;
6 | using System.Drawing;
7 | using System.Windows.Forms;
8 | using System.Windows.Forms.Design;
9 |
10 | namespace DevExpressWinFormsExtension.DataControls
11 | {
12 | ///
13 | /// GroupControl with checkbox in header.
14 | ///
15 | /// Allows user to disable/enable all controls in the GroupControl
16 | [ToolboxItem(true)]
17 | [Description("GroupControl with checkbox in header.")]
18 | [ToolboxBitmap(typeof(GroupControl))]
19 | [Designer(typeof(ParentControlDesigner))]
20 | public partial class GroupControlCheckedDev : XtraUserControlDev
21 | {
22 | ///
23 | /// Parameterless constructor
24 | ///
25 | public GroupControlCheckedDev()
26 | {
27 | InitializeComponent();
28 | foreach (Control control in Controls)
29 | {
30 | control.Enabled = Checked;
31 | }
32 |
33 | header.Enabled = true;
34 | }
35 |
36 | ///
37 | /// Event on checked changed
38 | ///
39 | [Browsable(true)]
40 | [Category("Action")]
41 | [Description("Event on checked changed")]
42 | public event EventHandler CheckedChanged;
43 |
44 | ///
45 | /// GroupBox title
46 | ///
47 | [Browsable(true)]
48 | [Category("Appearance")]
49 | [Description("GroupBox title")]
50 | public string Title
51 | {
52 | get
53 | {
54 | return checkEdit.Text;
55 | }
56 |
57 | set
58 | {
59 | checkEdit.Text = value;
60 | }
61 | }
62 |
63 | ///
64 | /// CheckBox state
65 | ///
66 | [Browsable(true)]
67 | [Category("Appearance")]
68 | [Description("CheckBox state")]
69 | public bool Checked
70 | {
71 | get
72 | {
73 | return checkEdit.Checked;
74 | }
75 |
76 | set
77 | {
78 | checkEdit.Checked = value;
79 | }
80 | }
81 |
82 | ///
83 | /// CheckBox style
84 | ///
85 | [Browsable(true)]
86 | [Category("Appearance")]
87 | [Description("CheckBox style")]
88 | public CheckBoxStyle CheckStyle
89 | {
90 | get
91 | {
92 | return checkEdit.Properties.CheckBoxOptions.Style;
93 | }
94 |
95 | set
96 | {
97 | checkEdit.Properties.CheckBoxOptions.Style = value;
98 | }
99 | }
100 |
101 | ///
102 | /// Event on checked changed
103 | ///
104 | /// Source
105 | /// Parameters
106 | private void CheckEditCheckedChanged(object sender, EventArgs e)
107 | {
108 | CheckedChanged?.Invoke(this, e);
109 | foreach (Control control in Controls)
110 | {
111 | if (control != header)
112 | {
113 | control.Enabled = Checked;
114 | }
115 | }
116 | }
117 |
118 | ///
119 | /// Event on new control added
120 | ///
121 | /// Source
122 | /// Parameters
123 | private void GroupControlWithCheckBoxControlAdded(object sender, ControlEventArgs e)
124 | {
125 | //e.Control.Enabled = Checked;
126 | // header.SendToBack();
127 | }
128 | }
129 | }
--------------------------------------------------------------------------------
/DevExpressWinFormsExtension/DataControls/GroupControlCheckedDev.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
--------------------------------------------------------------------------------
/DevExpressWinFormsExtension/DataControls/LookUp/ILookUpSplitableItem.cs:
--------------------------------------------------------------------------------
1 | namespace DevExpressWinFormsExtension.DataControls.LookUp
2 | {
3 | ///
4 | /// Interface for LookUp items, which support splitters
5 | ///
6 | /// In case, if need to create last selected items for example
7 | public interface ILookUpSplitableItem
8 | {
9 | ///
10 | /// Flag if a current item is a last item before splitting
11 | ///
12 | bool IsSplitter { get; set; }
13 | }
14 | }
--------------------------------------------------------------------------------
/DevExpressWinFormsExtension/DataControls/LookUp/LookUpDev.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.ComponentModel;
3 | using System.Drawing;
4 | using DevExpress.XtraEditors;
5 | using DevExpressWinFormsExtension.Utils;
6 |
7 | namespace DevExpressWinFormsExtension.DataControls.LookUp
8 | {
9 | ///
10 | /// LookUpEdit component
11 | ///
12 | /// Allows to show hint for each element in the editor
13 | [ToolboxItem(true)]
14 | [ToolboxBitmap(typeof(LookUpEdit))]
15 | [Description("LookUpEdit component with hints")]
16 | public class LookUpDev : LookUpEdit
17 | {
18 | ///
19 | /// Parameterless constructor
20 | ///
21 | static LookUpDev()
22 | {
23 | RepositoryItemLookUpDev.RegisterLookUpEditHints();
24 | }
25 |
26 | ///
27 | /// Parameterless constructor
28 | ///
29 | public LookUpDev()
30 | : base()
31 | {
32 | CustomDrawCell += LookUpDev_CustomDrawCell;
33 | }
34 |
35 | ///
36 | /// Event on showing ToolTip
37 | ///
38 | public event EventHandler BeforeShowingTooltip
39 | {
40 | add
41 | {
42 | Properties.BeforeShowingTooltip += value;
43 | }
44 | remove
45 | {
46 | Properties.BeforeShowingTooltip -= value;
47 | }
48 | }
49 |
50 | ///
51 | /// Description field
52 | ///
53 | public string DescriptionField
54 | {
55 | set
56 | {
57 | Properties.DescriptionField = value;
58 | OnPropertiesChanged();
59 | }
60 | get
61 | {
62 | return Properties.DescriptionField;
63 | }
64 | }
65 |
66 | ///
67 | /// Gets the class name of the current editor.
68 | ///
69 | public override string EditorTypeName
70 | {
71 | get
72 | {
73 | return RepositoryItemLookUpDev.LookUpEditHintsName;
74 | }
75 | }
76 |
77 | ///
78 | /// Specifies settings specific to the current editor.
79 | ///
80 | [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
81 | public new RepositoryItemLookUpDev Properties
82 | {
83 | get
84 | {
85 | return base.Properties as RepositoryItemLookUpDev;
86 | }
87 | }
88 |
89 | ///
90 | /// Event on creating a lookup popup form
91 | ///
92 | /// Popup form
93 | protected override DevExpress.XtraEditors.Popup.PopupBaseForm CreatePopupForm()
94 | {
95 | return new PopupLookUpEditFormDev(this);
96 | }
97 |
98 | ///
99 | /// Event on custom draw cell
100 | ///
101 | /// Source
102 | /// Parameters
103 | private void LookUpDev_CustomDrawCell(object sender, DevExpress.XtraEditors.Popup.LookUpCustomDrawCellArgs e)
104 | {
105 | if (e.Row is ILookUpSplitableItem item && item.IsSplitter)
106 | {
107 | e.DefaultDraw();
108 | using (var pen = new Pen(SkinHelper.TranslateColor(Color.LightGray)))
109 | {
110 | e.Graphics.DrawLine(pen, new Point(e.Bounds.X, e.Bounds.Bottom), new Point(e.Bounds.Right, e.Bounds.Bottom));
111 | }
112 |
113 | e.Handled = true;
114 | }
115 | }
116 | }
117 | }
--------------------------------------------------------------------------------
/DevExpressWinFormsExtension/DataControls/LookUp/PopupLookUpEditFormDev.cs:
--------------------------------------------------------------------------------
1 | using System.ComponentModel;
2 | using System.Drawing;
3 | using DevExpress.Utils;
4 | using DevExpress.XtraEditors.Popup;
5 |
6 | namespace DevExpressWinFormsExtension.DataControls.LookUp
7 | {
8 | ///
9 | /// Popup lookupform
10 | ///
11 | [ToolboxItem(false)]
12 | internal class PopupLookUpEditFormDev : PopupLookUpEditForm
13 | {
14 | ///
15 | /// Previous point
16 | ///
17 | private Point prevPoint = Point.Empty;
18 |
19 | ///
20 | /// ToolTipController
21 | ///
22 | private ToolTipController toolTipController;
23 |
24 | ///
25 | /// Previous selected row index
26 | ///
27 | private int prevRowIndex = -1;
28 |
29 | ///
30 | /// Contructor with parameters
31 | ///
32 | /// LookUpEdit owner
33 | public PopupLookUpEditFormDev(LookUpDev ownerEdit)
34 | : base(ownerEdit)
35 | {
36 | if (OwnerEdit.ToolTipController == null)
37 | {
38 | toolTipController = ToolTipController.DefaultController;
39 | }
40 |
41 | toolTipController.BeforeShow += ToolTipControllerBeforeShow;
42 | }
43 |
44 | ///
45 | /// Event befor tooltip showing
46 | ///
47 | /// Source
48 | /// Parameters
49 | private void ToolTipControllerBeforeShow(object sender, ToolTipControllerShowEventArgs e)
50 | {
51 | if (OwnerEdit is LookUpDev lookUpEdit)
52 | {
53 | lookUpEdit.Properties.OnBeforeShowingTooltip(e);
54 | }
55 | }
56 |
57 | ///
58 | /// Event on show popup form
59 | ///
60 | public override void ShowPopupForm()
61 | {
62 | SetToolTipController();
63 | base.ShowPopupForm();
64 | }
65 |
66 | ///
67 | /// Check mouse cursor for showing tooltip
68 | ///
69 | /// HitTest info
70 | protected override void CheckMouseCursor(LookUpPopupHitTest hitTest)
71 | {
72 | if (prevPoint.X != hitTest.Point.X || prevPoint.Y != hitTest.Point.Y)
73 | {
74 | prevPoint = hitTest.Point;
75 |
76 | if (!(OwnerEdit is LookUpDev lookUp) || string.IsNullOrEmpty(lookUp.DescriptionField))
77 | {
78 | return;
79 | }
80 |
81 | if (hitTest.HitType == LookUpPopupHitType.Row)
82 | {
83 | if (hitTest.Index != prevRowIndex)
84 | {
85 | toolTipController.HideHint();
86 | prevRowIndex = hitTest.Index;
87 | }
88 |
89 | var value = lookUp.Properties.GetDataSourceValue(lookUp.Properties.DescriptionField, hitTest.Index);
90 | if (value != null && !string.IsNullOrEmpty(value.ToString()))
91 | {
92 | toolTipController.ShowHint(value.ToString());
93 | }
94 | }
95 | }
96 |
97 | base.CheckMouseCursor(hitTest);
98 | }
99 |
100 | ///
101 | /// Attach tooltipcontroller to the LookUpEdit
102 | ///
103 | private void SetToolTipController()
104 | {
105 | if (OwnerEdit.ToolTipController != null && OwnerEdit.ToolTipController != toolTipController)
106 | {
107 | toolTipController = OwnerEdit.ToolTipController;
108 | toolTipController.BeforeShow += ToolTipControllerBeforeShow;
109 | }
110 | }
111 | }
112 | }
--------------------------------------------------------------------------------
/DevExpressWinFormsExtension/DataControls/LookUp/RepositoryItemLookUpDev.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.ComponentModel;
3 | using System.Drawing;
4 | using DevExpress.XtraEditors.Drawing;
5 | using DevExpress.XtraEditors.Popup;
6 | using DevExpress.XtraEditors.Registrator;
7 | using DevExpress.XtraEditors.Repository;
8 | using DevExpress.XtraEditors.ViewInfo;
9 | using DevExpressWinFormsExtension.Utils;
10 |
11 | namespace DevExpressWinFormsExtension.DataControls.LookUp
12 | {
13 | ///
14 | /// RepositoryItemLookUpEdit component
15 | ///
16 | /// Allows to show hint for each element in the editor
17 | [ToolboxItem(false)]
18 | [UserRepositoryItem("RepositoryItemLookUpDev")]
19 | public class RepositoryItemLookUpDev : RepositoryItemLookUpEdit
20 | {
21 | ///
22 | /// Custom lookup control name
23 | ///
24 | internal const string LookUpEditHintsName = "LookUpEditHints";
25 |
26 | ///
27 | /// Description field
28 | ///
29 | private string descriptionField = string.Empty;
30 |
31 | ///
32 | /// Handler before showing ToolTip
33 | ///
34 | private static readonly object beforeShowingTooltipHandler = new object();
35 |
36 | ///
37 | /// Parameterless constructor
38 | ///
39 | static RepositoryItemLookUpDev()
40 | {
41 | RegisterLookUpEditHints();
42 | }
43 |
44 | ///
45 | /// Parameterless constructor
46 | ///
47 | public RepositoryItemLookUpDev()
48 | : base()
49 | {
50 | }
51 |
52 | ///
53 | /// Event before showing tooltip
54 | ///
55 | public event EventHandler BeforeShowingTooltip
56 | {
57 | add
58 | {
59 | Events.AddHandler(beforeShowingTooltipHandler, value);
60 | }
61 | remove
62 | {
63 | Events.RemoveHandler(beforeShowingTooltipHandler, value);
64 | }
65 | }
66 |
67 | ///
68 | /// Description field
69 | ///
70 | public string DescriptionField
71 | {
72 | set
73 | {
74 | descriptionField = value;
75 | OnPropertiesChanged();
76 | }
77 | get
78 | {
79 | return descriptionField;
80 | }
81 | }
82 |
83 | ///
84 | /// Custom editor registration
85 | ///
86 | public static void RegisterLookUpEditHints()
87 | {
88 | EditorRegistrationInfo.Default.Editors.Add(new EditorClassInfo(
89 | LookUpEditHintsName, typeof(LookUpDev), typeof(RepositoryItemLookUpDev),
90 | typeof(LookUpEditViewInfo), new ButtonEditPainter(), true));
91 | }
92 |
93 | ///
94 | /// Custom lookup control name
95 | ///
96 | public override string EditorTypeName
97 | {
98 | get
99 | {
100 | return LookUpEditHintsName;
101 | }
102 | }
103 |
104 | ///
105 | /// Copies properties of the source repository item to the current object.
106 | ///
107 | /// The source repository item object.
108 | public override void Assign(RepositoryItem item)
109 | {
110 | BeginUpdate();
111 | try
112 | {
113 | base.Assign(item);
114 | if (!(item is RepositoryItemLookUpDev source))
115 | {
116 | return;
117 | }
118 |
119 | DescriptionField = source.DescriptionField;
120 | Events.AddHandler(beforeShowingTooltipHandler, source.Events[beforeShowingTooltipHandler]);
121 | }
122 | finally
123 | {
124 | EndUpdate();
125 | }
126 | }
127 |
128 | ///
129 | /// Event before showing tooltip
130 | ///
131 | /// Parameters
132 | protected internal virtual void OnBeforeShowingTooltip(EventArgs e)
133 | {
134 | var handler = (EventHandler)Events[beforeShowingTooltipHandler];
135 | handler?.Invoke(GetEventSender(), e);
136 | }
137 |
138 | ///
139 | /// Event on custom draw cell
140 | ///
141 | /// Source
142 | /// Parameters
143 | protected override void RaiseCustomDrawCell(LookUpCustomDrawCellArgs e)
144 | {
145 | base.RaiseCustomDrawCell(e);
146 | if (e.Row is ILookUpSplitableItem item && item.IsSplitter)
147 | {
148 | e.DefaultDraw();
149 | using (var pen = new Pen(SkinHelper.TranslateColor(Color.LightGray)))
150 | {
151 | e.Graphics.DrawLine(pen, new Point(e.Bounds.X, e.Bounds.Bottom), new Point(e.Bounds.Right, e.Bounds.Bottom));
152 | }
153 |
154 | e.Handled = true;
155 | }
156 | }
157 | }
158 | }
--------------------------------------------------------------------------------
/DevExpressWinFormsExtension/DataControls/PasswordTextEditDev.cs:
--------------------------------------------------------------------------------
1 | using DevExpress.XtraEditors;
2 | using DevExpress.XtraEditors.Controls;
3 | using DevExpress.XtraEditors.Drawing;
4 | using System.ComponentModel;
5 | using System.Drawing;
6 |
7 | namespace DevExpressWinFormsExtension.DataControls
8 | {
9 | ///
10 | /// The extension for working with passwords, allows user to show/hide input characters.
11 | ///
12 | [ToolboxItem(true)]
13 | [ToolboxBitmap(typeof(ButtonEdit))]
14 | [Description("The extension for working with passwords, allows user to show/hide input characters.")]
15 | public class PasswordTextEditDev : ButtonEdit
16 | {
17 | ///
18 | /// Hide password char
19 | ///
20 | private const char passwordChar = '*';
21 |
22 | ///
23 | /// Tag for button for changing visibility of the password
24 | ///
25 | private const string buttonVisibilityTag = "Visible";
26 |
27 | ///
28 | /// Hint title to show password
29 | ///
30 | private const string showPasswordHint = "Show password";
31 |
32 | ///
33 | /// Hint title to hide password
34 | ///
35 | private const string hidePasswordHint = "Hide password";
36 |
37 | ///
38 | /// Current state
39 | ///
40 | private PasswordStateEnum passwordState = PasswordStateEnum.Hidden;
41 |
42 | ///
43 | /// Parameterless constructor
44 | ///
45 | public PasswordTextEditDev()
46 | {
47 | var button = new EditorButton
48 | {
49 | Visible = true,
50 | ToolTip = showPasswordHint,
51 | Tag = buttonVisibilityTag,
52 | Kind = ButtonPredefines.Glyph
53 | };
54 | button.ImageOptions.Image = DevExpressWinFormsExtension.Properties.Resources.IsVisible_16;
55 | Properties.Buttons.Add(button);
56 |
57 | Anchor = System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right;
58 | Properties.PasswordChar = passwordChar;
59 | }
60 |
61 | ///
62 | /// Enum of password visibility
63 | ///
64 | private enum PasswordStateEnum
65 | {
66 | ///
67 | /// Hiidden
68 | ///
69 | Hidden,
70 |
71 | ///
72 | /// Visible
73 | ///
74 | Visible
75 | }
76 |
77 | ///
78 | /// Event on buttons click
79 | ///
80 | /// Button info
81 | protected override void OnClickButton(EditorButtonObjectInfoArgs buttonInfo)
82 | {
83 | base.OnClickButton(buttonInfo);
84 |
85 | passwordState = passwordState == PasswordStateEnum.Hidden ? PasswordStateEnum.Visible : PasswordStateEnum.Hidden;
86 | if (buttonInfo.Button.Tag?.ToString() != buttonVisibilityTag)
87 | {
88 | return;
89 | }
90 |
91 | switch (passwordState)
92 | {
93 | case PasswordStateEnum.Hidden:
94 | buttonInfo.Button.ImageOptions.Image = DevExpressWinFormsExtension.Properties.Resources.IsVisible_16;
95 | Properties.PasswordChar = passwordChar;
96 | buttonInfo.Button.ToolTip = showPasswordHint;
97 | break;
98 | case PasswordStateEnum.Visible:
99 | buttonInfo.Button.ImageOptions.Image = DevExpressWinFormsExtension.Properties.Resources.IsHidden_16;
100 | Properties.PasswordChar = '\0';
101 | buttonInfo.Button.ToolTip = hidePasswordHint;
102 | break;
103 | }
104 | }
105 | }
106 | }
--------------------------------------------------------------------------------
/DevExpressWinFormsExtension/DataControls/TreeList/TreeListSearchable.Designer.cs:
--------------------------------------------------------------------------------
1 | namespace DevExpressWinFormsExtension.DataControls.TreeList
2 | {
3 | partial class TreeListSearchable
4 | {
5 | ///
6 | /// Required designer variable.
7 | ///
8 | private System.ComponentModel.IContainer components = null;
9 |
10 | ///
11 | /// Clean up any resources being used.
12 | ///
13 | /// true if managed resources should be disposed; otherwise, false.
14 | protected override void Dispose(bool disposing)
15 | {
16 | if (disposing && (components != null))
17 | {
18 | components.Dispose();
19 | }
20 | base.Dispose(disposing);
21 | }
22 |
23 | #region Component Designer generated code
24 |
25 | ///
26 | /// Required method for Designer support - do not modify
27 | /// the contents of this method with the code editor.
28 | ///
29 | private void InitializeComponent()
30 | {
31 | this.components = new System.ComponentModel.Container();
32 | this.beSearch = new DevExpress.XtraEditors.ButtonEdit();
33 | this.dataTreeList = new DevExpressWinFormsExtension.DataControls.TreeList.TreeListDev();
34 | this.panelFilter = new DevExpress.XtraEditors.PanelControl();
35 | ((System.ComponentModel.ISupportInitialize)(this.beSearch.Properties)).BeginInit();
36 | ((System.ComponentModel.ISupportInitialize)(this.dataTreeList)).BeginInit();
37 | ((System.ComponentModel.ISupportInitialize)(this.panelFilter)).BeginInit();
38 | this.panelFilter.SuspendLayout();
39 | this.SuspendLayout();
40 | //
41 | // beSearch
42 | //
43 | this.beSearch.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
44 | | System.Windows.Forms.AnchorStyles.Right)));
45 | this.beSearch.EditValue = "";
46 | this.beSearch.Location = new System.Drawing.Point(5, 5);
47 | this.beSearch.Name = "beSearch";
48 | this.beSearch.Properties.Buttons.AddRange(new DevExpress.XtraEditors.Controls.EditorButton[] {
49 | new DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Delete)});
50 | this.beSearch.Properties.NullText = "Filter condition...";
51 | this.beSearch.Size = new System.Drawing.Size(220, 20);
52 | this.beSearch.TabIndex = 1;
53 | this.beSearch.ButtonClick += new DevExpress.XtraEditors.Controls.ButtonPressedEventHandler(this.beSearch_ButtonClick);
54 | this.beSearch.EditValueChanging += new DevExpress.XtraEditors.Controls.ChangingEventHandler(this.beSearch_EditValueChanging);
55 | //
56 | // dataTreeList
57 | //
58 | this.dataTreeList.Dock = System.Windows.Forms.DockStyle.Fill;
59 | this.dataTreeList.Location = new System.Drawing.Point(0, 30);
60 | this.dataTreeList.Name = "dataTreeList";
61 | this.dataTreeList.Size = new System.Drawing.Size(228, 217);
62 | this.dataTreeList.TabIndex = 2;
63 | //
64 | // panelFilter
65 | //
66 | this.panelFilter.Controls.Add(this.beSearch);
67 | this.panelFilter.Dock = System.Windows.Forms.DockStyle.Top;
68 | this.panelFilter.Location = new System.Drawing.Point(0, 0);
69 | this.panelFilter.Name = "panelFilter";
70 | this.panelFilter.Size = new System.Drawing.Size(228, 30);
71 | this.panelFilter.TabIndex = 13;
72 | //
73 | // TreeListSearchable
74 | //
75 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
76 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
77 | this.Controls.Add(this.dataTreeList);
78 | this.Controls.Add(this.panelFilter);
79 | this.Name = "TreeListSearchable";
80 | this.Size = new System.Drawing.Size(228, 247);
81 | ((System.ComponentModel.ISupportInitialize)(this.beSearch.Properties)).EndInit();
82 | ((System.ComponentModel.ISupportInitialize)(this.dataTreeList)).EndInit();
83 | ((System.ComponentModel.ISupportInitialize)(this.panelFilter)).EndInit();
84 | this.panelFilter.ResumeLayout(false);
85 | this.ResumeLayout(false);
86 |
87 | }
88 |
89 | #endregion
90 | private DevExpress.XtraEditors.ButtonEdit beSearch;
91 | private TreeListDev dataTreeList;
92 | private DevExpress.XtraEditors.PanelControl panelFilter;
93 | }
94 | }
95 |
--------------------------------------------------------------------------------
/DevExpressWinFormsExtension/DataControls/TreeList/TreeListSearchable.cs:
--------------------------------------------------------------------------------
1 | using DevExpress.XtraEditors.Controls;
2 | using DevExpressWinFormsExtension.DataControls.Forms;
3 | using DevExpressWinFormsExtension.DataControls.TreeList.Utils;
4 | using System;
5 | using System.ComponentModel;
6 | using System.Drawing;
7 |
8 | namespace DevExpressWinFormsExtension.DataControls.TreeList
9 | {
10 | ///
11 | /// TreeList component with filtration panel on top
12 | ///
13 | [ToolboxItem(true)]
14 | [ToolboxBitmap(typeof(DevExpress.XtraTreeList.TreeList))]
15 | [Designer(typeof(TreeListSearchableDesigner))]
16 | [Description("TreeList with filtration panel on top")]
17 | public partial class TreeListSearchable : XtraUserControlDev
18 | {
19 | ///
20 | /// Custom function for filtration
21 | ///
22 | public Action CustomFilterFunction;
23 |
24 | ///
25 | /// Flag if filter panel is enabled
26 | ///
27 | private bool isSearchable = true;
28 |
29 | ///
30 | /// Parameterless constructor
31 | ///
32 | public TreeListSearchable()
33 | {
34 | InitializeComponent();
35 | beSearch.EditValue = null;
36 | }
37 |
38 | ///
39 | /// TreeList
40 | ///
41 | public TreeListDev TreeList
42 | {
43 | get
44 | {
45 | return dataTreeList;
46 | }
47 | }
48 |
49 | ///
50 | /// Flag if filter panel is enabled
51 | ///
52 | [Category("Appearance")]
53 | [Description("Enable filter panel")]
54 | public bool IsSearchable
55 | {
56 | get
57 | {
58 | return isSearchable;
59 | }
60 |
61 | set
62 | {
63 | isSearchable = value;
64 | beSearch.EditValue = null;
65 | panelFilter.Visible = isSearchable;
66 | }
67 | }
68 |
69 | ///
70 | /// Filter condition
71 | ///
72 | public string FilterCondition
73 | {
74 | get
75 | {
76 | return beSearch.Text == beSearch.Properties.NullText ? string.Empty : beSearch.Text;
77 | }
78 | }
79 |
80 | ///
81 | ///Event on filter condition changing
82 | ///
83 | /// Source
84 | /// Parameters
85 | private void beSearch_EditValueChanging(object sender, ChangingEventArgs e)
86 | {
87 | try
88 | {
89 | BeginUpdate();
90 |
91 | if (CustomFilterFunction != null)
92 | {
93 | CustomFilterFunction(e.NewValue == null ? string.Empty : (string)e.NewValue);
94 | }
95 | else
96 | {
97 | if (e.NewValue == null || string.IsNullOrWhiteSpace(e.NewValue.ToString()))
98 | {
99 | TreeList.ClearNodesFilter();
100 | }
101 | else
102 | {
103 | TreeList.Filter(((string)e.NewValue).Trim());
104 | }
105 | }
106 | }
107 | finally
108 | {
109 | EndUpdate();
110 | }
111 | }
112 |
113 | ///
114 | /// Event on clear filter
115 | ///
116 | /// Source
117 | /// Parameters
118 | private void beSearch_ButtonClick(object sender, ButtonPressedEventArgs e)
119 | {
120 | beSearch.EditValue = null;
121 | }
122 | }
123 | }
--------------------------------------------------------------------------------
/DevExpressWinFormsExtension/DataControls/TreeList/TreeListSearchable.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
--------------------------------------------------------------------------------
/DevExpressWinFormsExtension/DataControls/TreeList/Utils/TreeListSearchableDesigner.cs:
--------------------------------------------------------------------------------
1 | using System.ComponentModel;
2 | using System.Windows.Forms.Design;
3 |
4 | namespace DevExpressWinFormsExtension.DataControls.TreeList.Utils
5 | {
6 | ///
7 | /// Designer for the TreeListSearchable
8 | ///
9 | public class TreeListSearchableDesigner : ControlDesigner
10 | {
11 | ///
12 | /// Initialization
13 | ///
14 | /// Component
15 | public override void Initialize(IComponent component)
16 | {
17 | base.Initialize(component);
18 | EnableDesignMode(((TreeListSearchable)Control).TreeList, typeof(TreeListDev).Name);
19 | }
20 | }
21 | }
--------------------------------------------------------------------------------
/DevExpressWinFormsExtension/DataControls/TreeList/Utils/TreeListViewInfoDev.cs:
--------------------------------------------------------------------------------
1 | using DevExpress.XtraTreeList.ViewInfo;
2 | using System.Drawing;
3 |
4 | namespace DevExpressWinFormsExtension.DataControls.TreeList.Utils
5 | {
6 | ///
7 | /// Custom TreeListViewInfo
8 | ///
9 | /// Remove empty spaces for nodes without StateImage
10 | internal class TreeListViewInfoDev : TreeListViewInfo
11 | {
12 | ///
13 | /// Constructor with parameters
14 | ///
15 | /// TreeList
16 | /// Flag if TreeListNode has custom images in tags and draws them itself
17 | public TreeListViewInfoDev(DevExpress.XtraTreeList.TreeList treeList, bool hasNodeImageInTag)
18 | : base(treeList)
19 | {
20 | HasNodeImageInTag = hasNodeImageInTag;
21 | }
22 |
23 | ///
24 | /// Flag if TreeListNode has custom images in tags and draws them itself
25 | ///
26 | private bool HasNodeImageInTag { get; set; }
27 |
28 | /// s
29 | /// Calc select image bounds
30 | ///
31 | /// Row info
32 | /// Indents
33 | protected override void CalcSelectImageBounds(RowInfo rInfo, Rectangle indentBounds)
34 | {
35 | base.CalcSelectImageBounds(rInfo, indentBounds);
36 | if (rInfo.StateImageIndex == -1 && (!HasNodeImageInTag || rInfo.Node.Tag != null))
37 | {
38 | rInfo.SelectImageBounds = Rectangle.Empty;
39 | }
40 | }
41 |
42 | ///
43 | /// Calc state image bounds
44 | ///
45 | /// Row info
46 | /// Indents
47 | protected override void CalcStateImageBounds(RowInfo rInfo, Rectangle indentBounds)
48 | {
49 | base.CalcStateImageBounds(rInfo, indentBounds);
50 | if (rInfo.StateImageIndex == - 1 && (!HasNodeImageInTag || rInfo.Node.Tag != null))
51 | {
52 | rInfo.StateImageBounds = Rectangle.Empty;
53 | }
54 | }
55 | }
56 | }
--------------------------------------------------------------------------------
/DevExpressWinFormsExtension/DevExpressWinFormsExtension.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.32510.428
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DevExpressWinFormsExtension", "DevExpressWinFormsExtension.csproj", "{52971080-F195-4546-83EC-F1AF004DFC39}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {52971080-F195-4546-83EC-F1AF004DFC39}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {52971080-F195-4546-83EC-F1AF004DFC39}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {52971080-F195-4546-83EC-F1AF004DFC39}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {52971080-F195-4546-83EC-F1AF004DFC39}.Release|Any CPU.Build.0 = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | GlobalSection(ExtensibilityGlobals) = postSolution
23 | SolutionGuid = {B695012C-2E6F-462B-98F2-C700A0E10599}
24 | EndGlobalSection
25 | EndGlobal
26 |
--------------------------------------------------------------------------------
/DevExpressWinFormsExtension/Interfaces/IClosableControl.cs:
--------------------------------------------------------------------------------
1 | namespace DevExpressWinFormsExtension.Interfaces
2 | {
3 | ///
4 | /// Interface for control's which suppport AllowClosing query
5 | ///
6 | public interface IClosableControl
7 | {
8 | ///
9 | /// Confirmation of form closing event
10 | ///
11 | /// True, if form can be closed
12 | bool AllowClose();
13 | }
14 | }
--------------------------------------------------------------------------------
/DevExpressWinFormsExtension/Interfaces/IValidableControl.cs:
--------------------------------------------------------------------------------
1 | namespace DevExpressWinFormsExtension.Interfaces
2 | {
3 | ///
4 | /// Interface for controls, which support validation
5 | ///
6 | public interface IValidable
7 | {
8 | ///
9 | /// Control validation
10 | ///
11 | /// True, if valid
12 | bool ValidateData();
13 |
14 | ///
15 | /// Setup control's state, depends on validation result
16 | ///
17 | /// Validation result
18 | void SetControlState(bool isValid);
19 | }
20 | }
--------------------------------------------------------------------------------
/DevExpressWinFormsExtension/Progress/ControlProgressHandler.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Threading;
3 | using System.Windows.Forms;
4 |
5 | namespace DevExpressWinFormsExtension.Progress
6 | {
7 | ///
8 | /// Progress manager
9 | ///
10 | internal class ControlProgressHandler : IProgressControlHandler
11 | {
12 | ///
13 | /// Temp progress increment value
14 | ///
15 | /// For use with fractional numbers, visual increment for whole numbers only
16 | private float cumulativeIncrementValue = 0f;
17 |
18 | ///
19 | /// Progress control
20 | ///
21 | private readonly ProgressControl control;
22 |
23 | ///
24 | /// Cancellation token source
25 | ///
26 | private readonly CancellationTokenSource tokenSource;
27 |
28 | ///
29 | /// Contstructor with parameters
30 | ///
31 | /// A progress control
32 | internal ControlProgressHandler(ProgressControl progressControl)
33 | {
34 | control = progressControl;
35 | Token = progressControl.Token;
36 | tokenSource = progressControl.TokenSource;
37 | MessageSuffix = string.Empty;
38 | }
39 |
40 | ///
41 | /// Cancellation token
42 | ///
43 | public CancellationToken Token
44 | {
45 | get;
46 |
47 | private set;
48 | }
49 |
50 | ///
51 | /// Message suffix for an iteration progress
52 | ///
53 | public string MessageSuffix { get; set; }
54 |
55 | ///
56 | /// Increment a progress
57 | ///
58 | /// Incrementation value
59 | public void Increment(float value)
60 | {
61 | cumulativeIncrementValue += value;
62 | var fullPartNumber = Convert.ToInt32(Math.Truncate(cumulativeIncrementValue));
63 | cumulativeIncrementValue -= fullPartNumber;
64 | if (fullPartNumber < 1)
65 | {
66 | return;
67 | }
68 |
69 | if (control.InvokeRequired)
70 | {
71 | control.BeginInvoke(new Action(() => { control.Increment(fullPartNumber); }));
72 | }
73 | else
74 | {
75 | control.Increment(fullPartNumber);
76 | Application.DoEvents();
77 | }
78 | }
79 |
80 | ///
81 | /// Set user message
82 | ///
83 | /// User message
84 | public void SetMessage(string message)
85 | {
86 | if (control.InvokeRequired)
87 | {
88 | control.BeginInvoke(new Action(() => { control.SetMessage(message + " " + MessageSuffix); }));
89 | }
90 | else
91 | {
92 | control.SetMessage(message + " " + MessageSuffix);
93 | }
94 | }
95 |
96 | ///
97 | /// Remove a progress control from a parent control
98 | ///
99 | public void Drop()
100 | {
101 | if (control.InvokeRequired)
102 | {
103 | control.BeginInvoke(new Action(() => { control.Parent = null; }));
104 | }
105 | else
106 | {
107 | control.Parent = null;
108 | }
109 | }
110 |
111 | ///
112 | /// Cancel an operation
113 | ///
114 | public void Cancel()
115 | {
116 | tokenSource?.Cancel();
117 | }
118 |
119 | ///
120 | /// Set progress value
121 | ///
122 | /// Value
123 | public void SetValue(int value)
124 | {
125 | if (control.InvokeRequired)
126 | {
127 | control.BeginInvoke(new Action(() => { control.SetValue(value); }));
128 | }
129 | else
130 | {
131 | control.SetValue(value);
132 | }
133 | }
134 | }
135 | }
--------------------------------------------------------------------------------
/DevExpressWinFormsExtension/Progress/IProgressControlHandler.cs:
--------------------------------------------------------------------------------
1 | using System.Threading;
2 |
3 | namespace DevExpressWinFormsExtension.Progress
4 | {
5 | ///
6 | /// Interface for progress manager
7 | ///
8 | public interface IProgressControlHandler
9 | {
10 | ///
11 | /// Cancellation token
12 | ///
13 | CancellationToken Token { get; }
14 |
15 | ///
16 | /// Message suffix for an iteration progress
17 | ///
18 | string MessageSuffix { get; set; }
19 |
20 | ///
21 | /// Increment a progress
22 | ///
23 | /// Incrementation value
24 | void Increment(float value);
25 |
26 | ///
27 | /// Set progress value
28 | ///
29 | /// Value
30 | void SetValue(int value);
31 |
32 | ///
33 | /// Set user message
34 | ///
35 | /// User message
36 | void SetMessage(string message);
37 |
38 | ///
39 | /// Remove a progress control from a parent control
40 | ///
41 | void Drop();
42 |
43 | ///
44 | /// Cancel an operation
45 | ///
46 | void Cancel();
47 | }
48 | }
--------------------------------------------------------------------------------
/DevExpressWinFormsExtension/Progress/ProgressControl.Designer.cs:
--------------------------------------------------------------------------------
1 | namespace DevExpressWinFormsExtension.Progress
2 | {
3 | partial class ProgressControl
4 | {
5 | ///
6 | /// Required designer variable.
7 | ///
8 | private System.ComponentModel.IContainer components = null;
9 |
10 | ///
11 | /// Clean up any resources being used.
12 | ///
13 | /// true if managed resources should be disposed; otherwise, false.
14 | protected override void Dispose(bool disposing)
15 | {
16 | if (disposing && (components != null))
17 | {
18 | components.Dispose();
19 | }
20 | base.Dispose(disposing);
21 | }
22 |
23 | #region Component Designer generated code
24 |
25 | ///
26 | /// Required method for Designer support - do not modify
27 | /// the contents of this method with the code editor.
28 | ///
29 | private void InitializeComponent()
30 | {
31 | this.lblProgressText = new DevExpress.XtraEditors.LabelControl();
32 | this.progressBar = new DevExpress.XtraEditors.ProgressBarControl();
33 | this.btnCancel = new DevExpress.XtraEditors.SimpleButton();
34 | this.marqueeProgress = new DevExpress.XtraEditors.MarqueeProgressBarControl();
35 | ((System.ComponentModel.ISupportInitialize)(this.progressBar.Properties)).BeginInit();
36 | ((System.ComponentModel.ISupportInitialize)(this.marqueeProgress.Properties)).BeginInit();
37 | this.SuspendLayout();
38 | //
39 | // lblProgressText
40 | //
41 | this.lblProgressText.Anchor = System.Windows.Forms.AnchorStyles.None;
42 | this.lblProgressText.Location = new System.Drawing.Point(189, 132);
43 | this.lblProgressText.Name = "lblProgressText";
44 | this.lblProgressText.Size = new System.Drawing.Size(63, 13);
45 | this.lblProgressText.TabIndex = 0;
46 | this.lblProgressText.Text = "labelControl1";
47 | //
48 | // progressBar
49 | //
50 | this.progressBar.Anchor = System.Windows.Forms.AnchorStyles.None;
51 | this.progressBar.Location = new System.Drawing.Point(42, 158);
52 | this.progressBar.Name = "progressBar";
53 | this.progressBar.Size = new System.Drawing.Size(386, 20);
54 | this.progressBar.TabIndex = 1;
55 | //
56 | // btnCancel
57 | //
58 | this.btnCancel.Location = new System.Drawing.Point(189, 191);
59 | this.btnCancel.Name = "btnCancel";
60 | this.btnCancel.Size = new System.Drawing.Size(75, 23);
61 | this.btnCancel.TabIndex = 2;
62 | this.btnCancel.Text = "Cancel";
63 | this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
64 | //
65 | // marqueeProgress
66 | //
67 | this.marqueeProgress.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
68 | | System.Windows.Forms.AnchorStyles.Right)));
69 | this.marqueeProgress.EditValue = 0;
70 | this.marqueeProgress.Location = new System.Drawing.Point(42, 158);
71 | this.marqueeProgress.Name = "marqueeProgress";
72 | this.marqueeProgress.Size = new System.Drawing.Size(386, 20);
73 | this.marqueeProgress.TabIndex = 3;
74 | //
75 | // ProgressControl
76 | //
77 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
78 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
79 | this.Controls.Add(this.marqueeProgress);
80 | this.Controls.Add(this.btnCancel);
81 | this.Controls.Add(this.progressBar);
82 | this.Controls.Add(this.lblProgressText);
83 | this.Name = "ProgressControl";
84 | this.Size = new System.Drawing.Size(468, 310);
85 | this.SizeChanged += new System.EventHandler(this.ProgressControl_SizeChanged);
86 | ((System.ComponentModel.ISupportInitialize)(this.progressBar.Properties)).EndInit();
87 | ((System.ComponentModel.ISupportInitialize)(this.marqueeProgress.Properties)).EndInit();
88 | this.ResumeLayout(false);
89 | this.PerformLayout();
90 |
91 | }
92 |
93 | #endregion
94 |
95 | private DevExpress.XtraEditors.LabelControl lblProgressText;
96 | private DevExpress.XtraEditors.ProgressBarControl progressBar;
97 | private DevExpress.XtraEditors.SimpleButton btnCancel;
98 | private DevExpress.XtraEditors.MarqueeProgressBarControl marqueeProgress;
99 | }
100 | }
101 |
--------------------------------------------------------------------------------
/DevExpressWinFormsExtension/Progress/ProgressControl.cs:
--------------------------------------------------------------------------------
1 | using DevExpress.XtraEditors;
2 | using DevExpressWinFormsExtension.DataControls.Forms;
3 | using DevExpressWinFormsExtension.Utils;
4 | using System;
5 | using System.ComponentModel;
6 | using System.Drawing;
7 | using System.Threading;
8 | using System.Windows.Forms;
9 |
10 | namespace DevExpressWinFormsExtension.Progress
11 | {
12 | ///
13 | /// Progress control to show on a XtraUserControl
14 | ///
15 | [ToolboxItem(false)]
16 | internal partial class ProgressControl : XtraUserControlDev
17 | {
18 | ///
19 | /// Label offset
20 | ///
21 | private const int labelYOffset = 5;
22 |
23 | ///
24 | /// Cancellation token
25 | ///
26 | private readonly CancellationTokenSource cancellationToken;
27 |
28 | ///
29 | /// ProgressBar control
30 | ///
31 | private readonly ProgressBarBaseControl activeProgress;
32 |
33 | ///
34 | /// Constructor with parameters
35 | ///
36 | /// Flag if marquee progress
37 | public ProgressControl(bool isMarquee)
38 | {
39 | InitializeComponent();
40 | cancellationToken = new CancellationTokenSource();
41 | Handler = new ControlProgressHandler(this);
42 | marqueeProgress.Visible = progressBar.Visible = false;
43 | activeProgress = isMarquee ? (ProgressBarBaseControl)marqueeProgress : progressBar;
44 | activeProgress.Visible = true;
45 | Appearance.BackColor = SkinHelper.TranslateColor(SystemColors.Control);
46 | }
47 |
48 | ///
49 | /// Progress manager
50 | ///
51 | public IProgressControlHandler Handler
52 | {
53 | get; private set;
54 | }
55 |
56 | ///
57 | /// Cancellation token
58 | ///
59 | public CancellationToken Token
60 | {
61 | get
62 | {
63 | return cancellationToken == null ? CancellationToken.None : cancellationToken.Token;
64 | }
65 | }
66 |
67 | ///
68 | /// Cancellation token source
69 | ///
70 | public CancellationTokenSource TokenSource
71 | {
72 | get
73 | {
74 | return cancellationToken;
75 | }
76 | }
77 |
78 | ///
79 | /// Increment a progress
80 | ///
81 | /// Incrementation value
82 | public void Increment(int value)
83 | {
84 | if (activeProgress == progressBar)
85 | {
86 | progressBar.Increment(value);
87 | }
88 | }
89 |
90 | ///
91 | /// Set progress value
92 | ///
93 | /// Value
94 | public void SetValue(int value)
95 | {
96 | if (activeProgress == progressBar)
97 | {
98 | var safeValue = Math.Min(Math.Max(value, 0), 100);
99 | progressBar.EditValue = safeValue;
100 | }
101 | }
102 |
103 | ///
104 | /// Set user message
105 | ///
106 | /// User message
107 | public void SetMessage(string message)
108 | {
109 | lblProgressText.Text = message;
110 | SetControlAtCenter(lblProgressText, (activeProgress.Height / 2) + (lblProgressText.Height / 2) + labelYOffset);
111 | }
112 |
113 | ///
114 | /// Event on the cancel button
115 | ///
116 | /// Source
117 | /// Parameters
118 | private void btnCancel_Click(object sender, EventArgs e)
119 | {
120 | if (XtraMessageBox.Show("Please confirm the cancellation", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No)
121 | {
122 | return;
123 | }
124 |
125 | cancellationToken?.Cancel();
126 | }
127 |
128 | ///
129 | /// Event on resize
130 | ///
131 | /// Source
132 | /// Parameters
133 | private void ProgressControl_SizeChanged(object sender, EventArgs e)
134 | {
135 | if (activeProgress == null)
136 | {
137 | return;
138 | }
139 |
140 | const int cancelButtonOffset = 10;
141 | SetControlAtCenter(activeProgress, 0);
142 | SetControlAtCenter(lblProgressText, (activeProgress.Height / 2) + (lblProgressText.Height / 2) + labelYOffset);
143 | SetControlAtCenter(btnCancel, -((activeProgress.Height / 2) + (btnCancel.Height / 2)) - cancelButtonOffset);
144 | }
145 |
146 | ///
147 | /// Update control position
148 | ///
149 | /// Control
150 | /// Offset
151 | private void SetControlAtCenter(Control control, int offsetY)
152 | {
153 | control.Left = (Width / 2) - (control.Width / 2);
154 | control.Top = (Height / 2) - (control.Height / 2) - offsetY;
155 | }
156 | }
157 | }
--------------------------------------------------------------------------------
/DevExpressWinFormsExtension/Progress/ProgressControl.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
--------------------------------------------------------------------------------
/DevExpressWinFormsExtension/Progress/ProgressManager.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Windows.Forms;
3 |
4 | namespace DevExpressWinFormsExtension.Progress
5 | {
6 | ///
7 | /// Progress manager
8 | ///
9 | /// Used to create/drop new progress for a control
10 | public static class ProgressManager
11 | {
12 | ///
13 | /// Add marquee progress to the control
14 | ///
15 | /// Conrol
16 | /// Manager for control the created progress
17 | public static IProgressControlHandler InitMarquee(Control control)
18 | {
19 | if (control.InvokeRequired)
20 | {
21 | return (IProgressControlHandler)control.Invoke(
22 | new Func(() =>
23 | {
24 | return SafeInit(control, isMarquee: true);
25 | }));
26 | }
27 | else
28 | {
29 | return SafeInit(control, isMarquee: true);
30 | }
31 | }
32 |
33 | ///
34 | /// Add progress to the control
35 | ///
36 | /// Conrol
37 | /// Manager to control the created progress
38 | public static IProgressControlHandler Init(Control control)
39 | {
40 | if (control == null)
41 | {
42 | return null;
43 | }
44 |
45 | if (control.InvokeRequired)
46 | {
47 | return (IProgressControlHandler)control.Invoke(
48 | new Func(() =>
49 | {
50 | return SafeInit(control, isMarquee: false);
51 | }));
52 | }
53 | else
54 | {
55 | return SafeInit(control, isMarquee: false);
56 | }
57 | }
58 |
59 | ///
60 | /// Remove progress
61 | ///
62 | /// Manager for a progress
63 | public static void Drop(IProgressControlHandler manager)
64 | {
65 | manager?.Drop();
66 | }
67 |
68 | ///
69 | /// Add progress to the control
70 | ///
71 | /// Control
72 | /// Flag if marquee
73 | /// Manager to control the created progress
74 | private static IProgressControlHandler SafeInit(Control control, bool isMarquee)
75 | {
76 | var progressControl = new ProgressControl(isMarquee: isMarquee)
77 | {
78 | Parent = control
79 | };
80 | progressControl.BringToFront();
81 | progressControl.Handler.SetMessage("Please wait...");
82 | progressControl.Dock = DockStyle.Fill;
83 | return progressControl.Handler;
84 | }
85 | }
86 | }
--------------------------------------------------------------------------------
/DevExpressWinFormsExtension/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.InteropServices;
3 |
4 | // General Information about an assembly is controlled through the following
5 | // set of attributes. Change these attribute values to modify the information
6 | // associated with an assembly.
7 | [assembly: AssemblyTitle("DevExpressWinFormsExtension.DataControls")]
8 | [assembly: AssemblyDescription("A small library to solve some troubles, which I met during my work with DevExpress.")]
9 | [assembly: AssemblyConfiguration("")]
10 | [assembly: AssemblyCompany("kulikov.dev")]
11 | [assembly: AssemblyProduct("DevExpressWinFormsExtension.DataControls")]
12 | [assembly: AssemblyCopyright("Copyright © 2020")]
13 | [assembly: AssemblyTrademark("")]
14 | [assembly: AssemblyCulture("")]
15 |
16 | // Setting ComVisible to false makes the types in this assembly not visible
17 | // to COM components. If you need to access a type in this assembly from
18 | // COM, set the ComVisible attribute to true on that type.
19 | [assembly: ComVisible(false)]
20 |
21 | // The following GUID is for the ID of the typelib if this project is exposed to COM
22 | [assembly: Guid("52971080-f195-4546-83ec-f1af004dfc39")]
23 |
24 | // Version information for an assembly consists of the following four values:
25 | //
26 | // Major Version
27 | // Minor Version
28 | // Build Number
29 | // Revision
30 | //
31 | // You can specify all the values or you can default the Build and Revision Numbers
32 | // by using the '*' as shown below:
33 | // [assembly: AssemblyVersion("1.0.*")]
34 | [assembly: AssemblyVersion("1.0.0.0")]
35 | [assembly: AssemblyFileVersion("1.0.0.0")]
36 |
--------------------------------------------------------------------------------
/DevExpressWinFormsExtension/Resources/Clear_16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kulikov-dev/DevExpress-WinForms-Extension/b8145edfa8ba211cd82803550d1cdc1b9cec7024/DevExpressWinFormsExtension/Resources/Clear_16.png
--------------------------------------------------------------------------------
/DevExpressWinFormsExtension/Resources/CollapseAll_16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kulikov-dev/DevExpress-WinForms-Extension/b8145edfa8ba211cd82803550d1cdc1b9cec7024/DevExpressWinFormsExtension/Resources/CollapseAll_16.png
--------------------------------------------------------------------------------
/DevExpressWinFormsExtension/Resources/Color_16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kulikov-dev/DevExpress-WinForms-Extension/b8145edfa8ba211cd82803550d1cdc1b9cec7024/DevExpressWinFormsExtension/Resources/Color_16.png
--------------------------------------------------------------------------------
/DevExpressWinFormsExtension/Resources/Decimal_16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kulikov-dev/DevExpress-WinForms-Extension/b8145edfa8ba211cd82803550d1cdc1b9cec7024/DevExpressWinFormsExtension/Resources/Decimal_16.png
--------------------------------------------------------------------------------
/DevExpressWinFormsExtension/Resources/ExpandAll_16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kulikov-dev/DevExpress-WinForms-Extension/b8145edfa8ba211cd82803550d1cdc1b9cec7024/DevExpressWinFormsExtension/Resources/ExpandAll_16.png
--------------------------------------------------------------------------------
/DevExpressWinFormsExtension/Resources/ImageBrush_16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kulikov-dev/DevExpress-WinForms-Extension/b8145edfa8ba211cd82803550d1cdc1b9cec7024/DevExpressWinFormsExtension/Resources/ImageBrush_16.png
--------------------------------------------------------------------------------
/DevExpressWinFormsExtension/Resources/IsHidden_16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kulikov-dev/DevExpress-WinForms-Extension/b8145edfa8ba211cd82803550d1cdc1b9cec7024/DevExpressWinFormsExtension/Resources/IsHidden_16.png
--------------------------------------------------------------------------------
/DevExpressWinFormsExtension/Resources/IsVisible_16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kulikov-dev/DevExpress-WinForms-Extension/b8145edfa8ba211cd82803550d1cdc1b9cec7024/DevExpressWinFormsExtension/Resources/IsVisible_16.png
--------------------------------------------------------------------------------
/DevExpressWinFormsExtension/Resources/Lock_16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kulikov-dev/DevExpress-WinForms-Extension/b8145edfa8ba211cd82803550d1cdc1b9cec7024/DevExpressWinFormsExtension/Resources/Lock_16.png
--------------------------------------------------------------------------------
/DevExpressWinFormsExtension/Resources/Samples/ChartLassoSample.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kulikov-dev/DevExpress-WinForms-Extension/b8145edfa8ba211cd82803550d1cdc1b9cec7024/DevExpressWinFormsExtension/Resources/Samples/ChartLassoSample.jpg
--------------------------------------------------------------------------------
/DevExpressWinFormsExtension/Resources/Samples/DateDoubleTrackBarSample.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kulikov-dev/DevExpress-WinForms-Extension/b8145edfa8ba211cd82803550d1cdc1b9cec7024/DevExpressWinFormsExtension/Resources/Samples/DateDoubleTrackBarSample.jpg
--------------------------------------------------------------------------------
/DevExpressWinFormsExtension/Resources/Samples/GridControlSample.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kulikov-dev/DevExpress-WinForms-Extension/b8145edfa8ba211cd82803550d1cdc1b9cec7024/DevExpressWinFormsExtension/Resources/Samples/GridControlSample.jpg
--------------------------------------------------------------------------------
/DevExpressWinFormsExtension/Resources/Samples/GridFooterSample.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kulikov-dev/DevExpress-WinForms-Extension/b8145edfa8ba211cd82803550d1cdc1b9cec7024/DevExpressWinFormsExtension/Resources/Samples/GridFooterSample.jpg
--------------------------------------------------------------------------------
/DevExpressWinFormsExtension/Resources/Samples/GridHistogramSample.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kulikov-dev/DevExpress-WinForms-Extension/b8145edfa8ba211cd82803550d1cdc1b9cec7024/DevExpressWinFormsExtension/Resources/Samples/GridHistogramSample.jpg
--------------------------------------------------------------------------------
/DevExpressWinFormsExtension/Resources/Samples/GroupControlCheckedSample.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kulikov-dev/DevExpress-WinForms-Extension/b8145edfa8ba211cd82803550d1cdc1b9cec7024/DevExpressWinFormsExtension/Resources/Samples/GroupControlCheckedSample.jpg
--------------------------------------------------------------------------------
/DevExpressWinFormsExtension/Resources/Samples/InputBoxValidableSample.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kulikov-dev/DevExpress-WinForms-Extension/b8145edfa8ba211cd82803550d1cdc1b9cec7024/DevExpressWinFormsExtension/Resources/Samples/InputBoxValidableSample.jpg
--------------------------------------------------------------------------------
/DevExpressWinFormsExtension/Resources/Samples/LookUpSample.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kulikov-dev/DevExpress-WinForms-Extension/b8145edfa8ba211cd82803550d1cdc1b9cec7024/DevExpressWinFormsExtension/Resources/Samples/LookUpSample.jpg
--------------------------------------------------------------------------------
/DevExpressWinFormsExtension/Resources/Samples/LookUpSplitterSample.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kulikov-dev/DevExpress-WinForms-Extension/b8145edfa8ba211cd82803550d1cdc1b9cec7024/DevExpressWinFormsExtension/Resources/Samples/LookUpSplitterSample.jpg
--------------------------------------------------------------------------------
/DevExpressWinFormsExtension/Resources/Samples/MDISample.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kulikov-dev/DevExpress-WinForms-Extension/b8145edfa8ba211cd82803550d1cdc1b9cec7024/DevExpressWinFormsExtension/Resources/Samples/MDISample.jpg
--------------------------------------------------------------------------------
/DevExpressWinFormsExtension/Resources/Samples/PasswordTextEditSample.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kulikov-dev/DevExpress-WinForms-Extension/b8145edfa8ba211cd82803550d1cdc1b9cec7024/DevExpressWinFormsExtension/Resources/Samples/PasswordTextEditSample.jpg
--------------------------------------------------------------------------------
/DevExpressWinFormsExtension/Resources/Samples/ProgressManagerSample.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kulikov-dev/DevExpress-WinForms-Extension/b8145edfa8ba211cd82803550d1cdc1b9cec7024/DevExpressWinFormsExtension/Resources/Samples/ProgressManagerSample.jpg
--------------------------------------------------------------------------------
/DevExpressWinFormsExtension/Resources/Samples/PropertyGridControlSortingSample.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kulikov-dev/DevExpress-WinForms-Extension/b8145edfa8ba211cd82803550d1cdc1b9cec7024/DevExpressWinFormsExtension/Resources/Samples/PropertyGridControlSortingSample.jpg
--------------------------------------------------------------------------------
/DevExpressWinFormsExtension/Resources/Samples/SampleProject.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kulikov-dev/DevExpress-WinForms-Extension/b8145edfa8ba211cd82803550d1cdc1b9cec7024/DevExpressWinFormsExtension/Resources/Samples/SampleProject.jpg
--------------------------------------------------------------------------------
/DevExpressWinFormsExtension/Resources/Samples/ScreenshotCaptureSample.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kulikov-dev/DevExpress-WinForms-Extension/b8145edfa8ba211cd82803550d1cdc1b9cec7024/DevExpressWinFormsExtension/Resources/Samples/ScreenshotCaptureSample.jpg
--------------------------------------------------------------------------------
/DevExpressWinFormsExtension/Resources/Samples/SkinPreviewSample.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kulikov-dev/DevExpress-WinForms-Extension/b8145edfa8ba211cd82803550d1cdc1b9cec7024/DevExpressWinFormsExtension/Resources/Samples/SkinPreviewSample.jpg
--------------------------------------------------------------------------------
/DevExpressWinFormsExtension/Resources/Samples/TreeListSearchableSample.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kulikov-dev/DevExpress-WinForms-Extension/b8145edfa8ba211cd82803550d1cdc1b9cec7024/DevExpressWinFormsExtension/Resources/Samples/TreeListSearchableSample.jpg
--------------------------------------------------------------------------------
/DevExpressWinFormsExtension/Resources/Unlock_16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kulikov-dev/DevExpress-WinForms-Extension/b8145edfa8ba211cd82803550d1cdc1b9cec7024/DevExpressWinFormsExtension/Resources/Unlock_16.png
--------------------------------------------------------------------------------
/DevExpressWinFormsExtension/Utils/ColorExtension.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Drawing;
3 |
4 | namespace DevExpressWinFormsExtension.Utils
5 | {
6 | ///
7 | /// Extension for Color class
8 | ///
9 | public static class ColorExtension
10 | {
11 | ///
12 | /// Tints the color by the given percent
13 | ///
14 | /// The color being tinted
15 | /// The percent to tint. Ex: 0.1 will make the color 10% lighter
16 | /// The new tinted color
17 | public static Color Lighten(this Color color, float percent)
18 | {
19 | var lighting = color.GetBrightness();
20 | lighting += lighting * percent;
21 | if (lighting > 1.0)
22 | {
23 | lighting = 1;
24 | }
25 | else if (lighting <= 0)
26 | {
27 | lighting = 0.1f;
28 | }
29 |
30 | return FromHsl(color.A, color.GetHue(), color.GetSaturation(), lighting);
31 | }
32 |
33 | ///
34 | /// Tints the color by the given percent
35 | ///
36 | /// The color being tinted
37 | /// The percent to tint. Ex: 0.1 will make the color 10% darker
38 | /// The new tinted color
39 | public static Color Darken(this Color color, float percent)
40 | {
41 | var lighting = color.GetBrightness();
42 | lighting -= lighting * percent;
43 | if (lighting > 1.0)
44 | {
45 | lighting = 1;
46 | }
47 | else if (lighting <= 0)
48 | {
49 | lighting = 0;
50 | }
51 |
52 | return FromHsl(color.A, color.GetHue(), color.GetSaturation(), lighting);
53 | }
54 |
55 | ///
56 | /// Converts the HSL values to a Color
57 | ///
58 | /// The alpha
59 | /// The hue
60 | /// The saturation
61 | /// The lighting
62 | /// Changed color
63 | private static Color FromHsl(int alpha, float hue, float saturation, float lighting)
64 | {
65 | if (saturation == 0)
66 | {
67 | return Color.FromArgb(alpha, Convert.ToInt32(lighting * 255), Convert.ToInt32(lighting * 255), Convert.ToInt32(lighting * 255));
68 | }
69 |
70 | float fMax, fMid, fMin;
71 | int iSextant, iMax, iMid, iMin;
72 |
73 | if (lighting > 0.5)
74 | {
75 | fMax = lighting - (lighting * saturation) + saturation;
76 | fMin = lighting + (lighting * saturation) - saturation;
77 | }
78 | else
79 | {
80 | fMax = lighting + (lighting * saturation);
81 | fMin = lighting - (lighting * saturation);
82 | }
83 |
84 | iSextant = (int)Math.Floor(hue / 60f);
85 | if (hue >= 300f)
86 | {
87 | hue -= 360f;
88 | }
89 |
90 | hue /= 60f;
91 | hue -= 2f * (float)Math.Floor((iSextant + 1f) % 6f / 2f);
92 | if (iSextant % 2 == 0)
93 | {
94 | fMid = (hue * (fMax - fMin)) + fMin;
95 | }
96 | else
97 | {
98 | fMid = fMin - (hue * (fMax - fMin));
99 | }
100 |
101 | iMax = Convert.ToInt32(fMax * 255);
102 | iMid = Convert.ToInt32(fMid * 255);
103 | iMin = Convert.ToInt32(fMin * 255);
104 |
105 | switch (iSextant)
106 | {
107 | case 1:
108 | return Color.FromArgb(alpha, iMid, iMax, iMin);
109 | case 2:
110 | return Color.FromArgb(alpha, iMin, iMax, iMid);
111 | case 3:
112 | return Color.FromArgb(alpha, iMin, iMid, iMax);
113 | case 4:
114 | return Color.FromArgb(alpha, iMid, iMin, iMax);
115 | case 5:
116 | return Color.FromArgb(alpha, iMax, iMin, iMid);
117 | default:
118 | return Color.FromArgb(alpha, iMax, iMid, iMin);
119 | }
120 | }
121 | }
122 | }
--------------------------------------------------------------------------------
/DevExpressWinFormsExtension/Utils/EnumEditorItem.cs:
--------------------------------------------------------------------------------
1 | using DevExpressWinFormsExtension.Utils;
2 | using System;
3 |
4 | namespace DevExpressWinFormsExtension.Helpers
5 | {
6 | ///
7 | /// Wrapper for comfort using enum values in DevExpress editors
8 | ///
9 | /// Enum
10 | public class EnumEditorItem
11 | where T : Enum
12 | {
13 | ///
14 | /// Constructor with parameters
15 | ///
16 | /// Enum value
17 | public EnumEditorItem(T value)
18 | {
19 | EnumValue = value;
20 | }
21 |
22 | ///
23 | /// Enum value
24 | ///
25 | public T EnumValue { get; private set; }
26 |
27 | ///
28 | /// Get string representation of the class
29 | ///
30 | /// String representation
31 | public override string ToString()
32 | {
33 | return EnumValue.GetCaption();
34 | }
35 | }
36 | }
--------------------------------------------------------------------------------
/DevExpressWinFormsExtension/Utils/FormHelper.cs:
--------------------------------------------------------------------------------
1 | using DevExpressWinFormsExtension.DataControls.Forms;
2 | using System.Windows.Forms;
3 |
4 | namespace DevExpressWinFormsExtension.Utils
5 | {
6 | ///
7 | /// Helper to work with forms
8 | ///
9 | public static class FormHelper
10 | {
11 | ///
12 | /// Check if there are any shown form with a specific title
13 | ///
14 | /// Title to compare
15 | /// Tag data to compare
16 | /// Flag if need focus on opened form
17 | /// Flag if the form showed
18 | public static bool IsFormShown(string title, object tagData = null, bool needFocus = true)
19 | {
20 | return GetShownForm(title, tagData, needFocus) != null;
21 | }
22 |
23 | ///
24 | /// Get shown form with a specific title
25 | ///
26 | /// Title to compare
27 | /// Tag data to compare
28 | /// Flag if need focus on opened form
29 | /// Shown form
30 | public static XtraFormDev GetShownForm(string title, object tagData = null, bool needFocus = true)
31 | {
32 | XtraFormDev openForm = null;
33 |
34 | foreach (var form in Application.OpenForms)
35 | {
36 | if (form is XtraFormDev devForm && (devForm.Text == title) && (tagData == null || tagData == devForm.Tag))
37 | {
38 | openForm = devForm;
39 |
40 | break;
41 | }
42 | }
43 |
44 | if ((openForm != null) && needFocus)
45 | {
46 | openForm.Focus();
47 | }
48 |
49 | return openForm;
50 | }
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/DevExpressWinFormsExtension/Utils/MDITabsDragHelper.cs:
--------------------------------------------------------------------------------
1 | using DevExpress.Utils.Mdi;
2 | using DevExpress.XtraBars.Docking2010;
3 | using DevExpress.XtraBars.Docking2010.DragEngine;
4 | using DevExpress.XtraBars.Docking2010.Views.Tabbed;
5 | using System;
6 | using System.Windows.Forms;
7 |
8 | namespace DevExpressWinFormsExtension.Utils
9 | {
10 | ///
11 | /// Helper to process draggable operation between MDI tabs
12 | ///
13 | internal class MDITabsDragHelper : IDisposable
14 | {
15 | ///
16 | /// Document manager
17 | ///
18 | private DocumentManager _manager;
19 |
20 | ///
21 | /// Constructor with parameters
22 | ///
23 | /// Document manager
24 | public MDITabsDragHelper(DocumentManager manager)
25 | {
26 | this._manager = manager;
27 | }
28 |
29 | ///
30 | /// Set up dragging opportunity
31 | ///
32 | /// Note: have to uncheck it before MDI form closing to unsubscribe
33 | public bool SelectNewPageOnDrag
34 | {
35 | set
36 | {
37 | MdiClient.DragOver -= OnMdiClientDragOver;
38 | if (value)
39 | {
40 | MdiClient.AllowDrop = true;
41 | MdiClient.DragOver += OnMdiClientDragOver;
42 | }
43 | }
44 | }
45 |
46 | ///
47 | /// MDI client
48 | ///
49 | private MdiClient MdiClient
50 | {
51 | get
52 | {
53 | return MdiClientSubclasser.GetMdiClient(_manager.MdiParent);
54 | }
55 | }
56 |
57 | ///
58 | /// Event on dipose
59 | ///
60 | public void Dispose()
61 | {
62 | if (MdiClient == null)
63 | {
64 | return;
65 | }
66 |
67 | SelectNewPageOnDrag = false;
68 | }
69 |
70 | ///
71 | /// Event on MDI client drag over
72 | ///
73 | /// Source
74 | /// Parameters
75 | protected void OnMdiClientDragOver(object sender, DragEventArgs e)
76 | {
77 | var point = _manager.ScreenToClient(new System.Drawing.Point(e.X, e.Y));
78 | var hitInfo = _manager.CalcHitInfo(point) as TabbedViewHitInfo;
79 | if (hitInfo.Info.HitTest == LayoutElementHitTest.Header && hitInfo.Document != null)
80 | {
81 | _manager.View.ActivateDocument(hitInfo.Document.Control);
82 | }
83 | }
84 | }
85 | }
--------------------------------------------------------------------------------
/DevExpressWinFormsExtension/Utils/MdiManager/MatrixGridControl.cs:
--------------------------------------------------------------------------------
1 | using DevExpress.Utils;
2 | using DevExpress.XtraEditors;
3 | using DevExpress.XtraGrid.Views.Base;
4 | using System;
5 | using System.ComponentModel;
6 | using System.Data;
7 | using System.Drawing;
8 | using System.Windows.Forms;
9 |
10 | namespace DevExpressWinFormsExtension.Utils.MdiManager
11 | {
12 | ///
13 | /// Matrix grid control for MDI children size initialization
14 | ///
15 | [ToolboxItem(true)]
16 | public partial class MatrixGridControl : XtraUserControl
17 | {
18 | ///
19 | /// DataTable source
20 | ///
21 | private readonly DataTable dataTable = new DataTable();
22 |
23 | ///
24 | /// Parameterless constructor
25 | ///
26 | public MatrixGridControl()
27 | {
28 | InitializeComponent();
29 |
30 | SetSize(3, 3);
31 | gridControlMatrix.DataSource = dataTable;
32 | }
33 |
34 | ///
35 | /// Event on size selection
36 | ///
37 | public event EventHandler OnSizeSelected;
38 |
39 | ///
40 | /// User selected size
41 | ///
42 | public Size SelectedSize { get; set; } = new Size(1, 1);
43 |
44 | ///
45 | /// Multiply of matrix size
46 | ///
47 | public int TotalSize
48 | {
49 | get
50 | {
51 | return SelectedSize.Width * SelectedSize.Height;
52 | }
53 | }
54 |
55 | ///
56 | /// Selection color
57 | ///
58 | [Browsable(true)]
59 | [Category("Appearance")]
60 | [Description("Selection color")]
61 | public Color SelectionColor { get; set; } = Color.DodgerBlue;
62 |
63 | ///
64 | /// Set matrix size
65 | ///
66 | /// Matrix columns count
67 | /// Matrix rows count
68 | public void SetSize(int columnsCount, int rowsCount)
69 | {
70 | gridViewMatrix.BeginDataUpdate();
71 | try
72 | {
73 | dataTable.Rows.Clear();
74 | dataTable.Columns.Clear();
75 | for (var i = 0; i < columnsCount; i++)
76 | {
77 | dataTable.Columns.Add();
78 | }
79 |
80 | for (var i = 0; i < rowsCount; i++)
81 | {
82 | dataTable.Rows.Add();
83 | }
84 |
85 | dataTable.AcceptChanges();
86 | }
87 | finally
88 | {
89 | gridViewMatrix.EndDataUpdate();
90 | }
91 |
92 | UpdateRowHeight();
93 | }
94 |
95 | ///
96 | /// Update cells row height depends on rows count
97 | ///
98 | private void UpdateRowHeight()
99 | {
100 | if (dataTable.Rows.Count == 0)
101 | {
102 | return;
103 | }
104 |
105 | gridViewMatrix.RowHeight = gridControlMatrix.Height / dataTable.Rows.Count - 1;
106 | }
107 |
108 | ///
109 | /// Event on form resize
110 | ///
111 | /// Source
112 | /// Parameters
113 | private void MatrixGridControl_Resize(object sender, EventArgs e)
114 | {
115 | UpdateRowHeight();
116 | }
117 |
118 | ///
119 | /// Event on a grid mouse move
120 | ///
121 | /// Source
122 | /// Parameters
123 | private void gridControlMatrix_MouseMove(object sender, MouseEventArgs e)
124 | {
125 | var hitInfo = gridViewMatrix.CalcHitInfo(e.X, e.Y);
126 | if (hitInfo.InRowCell)
127 | {
128 | var width = hitInfo.Column.AbsoluteIndex + 1;
129 | var height = gridViewMatrix.GetDataSourceRowIndex(hitInfo.RowHandle) + 1;
130 |
131 | var tempSize = new Size(width, height);
132 | if (tempSize != SelectedSize)
133 | {
134 | SelectedSize = tempSize;
135 | Refresh();
136 | }
137 | }
138 | }
139 |
140 | ///
141 | /// Event on a grid custom draw cell
142 | ///
143 | /// Source
144 | /// Parameters
145 | private void gridViewMatrix_CustomDrawCell(object sender, RowCellCustomDrawEventArgs e)
146 | {
147 | if (e.Column.AbsoluteIndex <= SelectedSize.Width - 1 && gridViewMatrix.GetDataSourceRowIndex(e.RowHandle) <= SelectedSize.Height - 1)
148 | {
149 | e.Appearance.BackColor = SelectionColor;
150 | }
151 | else
152 | {
153 | e.Appearance.BackColor = Color.White;
154 | }
155 | }
156 |
157 | ///
158 | /// Event on a grid click
159 | ///
160 | /// Source
161 | /// Parameters
162 | private void gridControlMatrix_Click(object sender, EventArgs e)
163 | {
164 | OnSizeSelected?.Invoke(this, new EventArgs());
165 | gridViewMatrix.TopRowIndex = 0;
166 | }
167 |
168 | ///
169 | /// Event on a grid mouse wheel
170 | ///
171 | /// Source
172 | /// Parameters
173 | private void gridViewMatrix_MouseWheel(object sender, MouseEventArgs e)
174 | {
175 | (e as DXMouseEventArgs).Handled = true;
176 | }
177 | }
178 | }
179 |
--------------------------------------------------------------------------------
/DevExpressWinFormsExtension/Utils/MdiManager/MatrixGridControl.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
--------------------------------------------------------------------------------
/DevExpressWinFormsExtension/Utils/MdiManager/MdiManagerHelper.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using DevExpress.XtraEditors;
3 |
4 | namespace DevExpressWinFormsExtension.Utils.MdiManager
5 | {
6 | ///
7 | /// Helper to process MDI forms
8 | ///
9 | public static class MdiManagerHelper
10 | {
11 | ///
12 | /// Inititalize MDI children (create or remove depends on chlidrenCount)
13 | ///
14 | /// MDI parent form
15 | /// Total MDI children count on the MDI parent form
16 | /// Default type for new MDI children
17 | public static void InitMDIChildren(XtraForm mdiParent, int chlidrenCount, Type formType)
18 | {
19 | if (mdiParent.MdiChildren.Length < chlidrenCount)
20 | {
21 | for (var i = mdiParent.MdiChildren.Length; i < chlidrenCount; i++)
22 | {
23 | var newMDIChild = (XtraForm)Activator.CreateInstance(formType);
24 | newMDIChild.MdiParent = mdiParent;
25 |
26 | newMDIChild.Show();
27 | }
28 | }
29 | else if (mdiParent.MdiChildren.Length > chlidrenCount)
30 | {
31 | for (var i = mdiParent.MdiChildren.Length - 1; i >= chlidrenCount; i--)
32 | {
33 | mdiParent.MdiChildren[i].Close();
34 | }
35 | }
36 | }
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/DevExpressWinFormsExtension/Utils/NaturalStringComparer.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text.RegularExpressions;
4 |
5 | namespace DevExpressWinFormsExtension.Utils
6 | {
7 | ///
8 | /// Natural comparer
9 | ///
10 | ///
11 | /// DevExpress has it's own NaturalComparer, however it's not work for my case, such strings:
12 | /// 'S_505' and 'S_0505' will equal in DevExpress. But it shouldn't be.
13 | ///
14 | public class NaturalStringComparer : IComparer
15 | {
16 | ///
17 | /// Flag of ascending sort order
18 | ///
19 | private readonly bool isAscending;
20 |
21 | ///
22 | /// Cache
23 | ///
24 | private readonly Dictionary cache = new Dictionary();
25 |
26 | ///
27 | /// Constructor with parameters
28 | ///
29 | /// Flag of ascending sort order
30 | public NaturalStringComparer(bool inAscendingOrder = true)
31 | {
32 | isAscending = inAscendingOrder;
33 | }
34 |
35 | ///
36 | /// Compare two strings
37 | ///
38 | /// String 1
39 | /// String 2
40 | /// Result of comparing
41 | /// DO not remove!
42 | public int Compare(string x, string y)
43 | {
44 | return (this as IComparer).Compare(x, y);
45 | }
46 |
47 | ///
48 | /// Compare two strings
49 | ///
50 | /// String 1
51 | /// String 2
52 | /// Result of comparing
53 | int IComparer.Compare(string x, string y)
54 | {
55 | if (x == y)
56 | {
57 | return 0;
58 | }
59 |
60 | if (!cache.TryGetValue(x, out var x1))
61 | {
62 | x1 = Regex.Split(x.Replace(" ", string.Empty), "([0-9]+)");
63 |
64 | cache.Add(x, x1);
65 | }
66 |
67 | if (!cache.TryGetValue(y, out var y1))
68 | {
69 | y1 = Regex.Split(y.Replace(" ", string.Empty), "([0-9]+)");
70 |
71 | cache.Add(y, y1);
72 | }
73 |
74 | int returnVal;
75 |
76 | for (var i = 0; i < x1.Length && i < y1.Length; i++)
77 | {
78 | if (x1[i] == y1[i])
79 | {
80 | continue;
81 | }
82 |
83 | returnVal = StringPartsCompare(x1[i], y1[i]);
84 |
85 | return isAscending ? returnVal : -returnVal;
86 | }
87 |
88 | if (y1.Length > x1.Length)
89 | {
90 | returnVal = 1;
91 | }
92 | else if (x1.Length > y1.Length)
93 | {
94 | returnVal = -1;
95 | }
96 | else
97 | {
98 | returnVal = 0;
99 | }
100 |
101 | return isAscending ? returnVal : -returnVal;
102 | }
103 |
104 | ///
105 | /// Compare parts of the strings
106 | ///
107 | /// Part of string 1
108 | /// Part of string 2
109 | /// Result of comparing
110 | private static int StringPartsCompare(string left, string right)
111 | {
112 | if (!int.TryParse(left, out var x) || left.StartsWith("0"))
113 | {
114 | return string.Compare(left, right, StringComparison.Ordinal);
115 | }
116 |
117 | if (!int.TryParse(right, out var y) || right.StartsWith("0"))
118 | {
119 | return string.Compare(left, right, StringComparison.Ordinal);
120 | }
121 |
122 | return x.CompareTo(y);
123 | }
124 | }
125 | }
--------------------------------------------------------------------------------
/DevExpressWinFormsExtension/Utils/RegexMaskHelper.cs:
--------------------------------------------------------------------------------
1 | using System.Globalization;
2 |
3 | namespace DevExpressWinFormsExtension.Utils
4 | {
5 | ///
6 | /// Common regex patterns to use as a Mask in editors/repositories
7 | ///
8 | public static class RegexMaskHelper
9 | {
10 | ///
11 | /// Double mask
12 | ///
13 | public static string DoubleMask => string.Format("(-?[0-9]+([{0}][0-9]*)?|[{0}][0-9]+)", DecimalSeparator);
14 |
15 | ///
16 | /// Double positive mask
17 | ///
18 | public static string DoublePositiveMask => string.Format("([0-9]+([{0}][0-9]*)?|[{0}][0-9]+)", DecimalSeparator);
19 |
20 | ///
21 | /// Double positive mask with precision
22 | ///
23 | public static string DoublePositiveMaskPrecision1 => string.Format("([0-9]+([{0}][0-9]{{0,1}})?|[{0}][0-9]{{0,1}})", DecimalSeparator);
24 |
25 | ///
26 | /// Int
27 | ///
28 | public static string IntegerMask => @"-?[1-9]\d*";
29 |
30 | ///
31 | /// Positive int
32 | ///
33 | public static string IntegerPositiveMask => @"[1-9]\d*";
34 |
35 | ///
36 | /// Decimal separator for a patterns purpose
37 | ///
38 | private static string DecimalSeparator => CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator;
39 | }
40 | }
--------------------------------------------------------------------------------
/DevExpressWinFormsExtension/Utils/SkinHelper.cs:
--------------------------------------------------------------------------------
1 | using DevExpress.LookAndFeel;
2 | using DevExpress.Skins;
3 | using DevExpress.Utils.Drawing;
4 | using DevExpress.XtraEditors;
5 | using System;
6 | using System.Collections.Generic;
7 | using System.Drawing;
8 |
9 | namespace DevExpressWinFormsExtension.Utils
10 | {
11 | ///
12 | /// Utils to work with colors considering the App Theme.
13 | ///
14 | public static class SkinHelper
15 | {
16 | ///
17 | /// Dark theme title
18 | ///
19 | private const string darkThemeTitle = "Dark";
20 |
21 | ///
22 | /// Comparison of colors for Theme
23 | ///
24 | /// Key: Theme name. Value: source/translated colors
25 | private static readonly Dictionary> editorBackColors = new Dictionary>();
26 |
27 | ///
28 | /// Check if current skin is dark skin
29 | ///
30 | public static bool IsDarkSkin
31 | {
32 | get
33 | {
34 | var currentSkin = CommonSkins.GetSkin(UserLookAndFeel.Default);
35 | return currentSkin.Name.Contains(darkThemeTitle);
36 | }
37 | }
38 |
39 | ///
40 | /// Convert color to the current theme color
41 | ///
42 | /// Source color
43 | /// Converted color
44 | public static Color TranslateColor(Color sourceColor)
45 | {
46 | var currentSkin = CommonSkins.GetSkin(UserLookAndFeel.Default);
47 | if (editorBackColors.ContainsKey(currentSkin.Name) && editorBackColors[currentSkin.Name].ContainsKey(sourceColor))
48 | {
49 | return editorBackColors[currentSkin.Name][sourceColor];
50 | }
51 |
52 | var color = currentSkin.TranslateColor(sourceColor);
53 | if (!editorBackColors.ContainsKey(currentSkin.Name))
54 | {
55 | editorBackColors.Add(currentSkin.Name, new Dictionary());
56 | }
57 |
58 | editorBackColors[currentSkin.Name].Add(sourceColor, color);
59 | return color;
60 | }
61 |
62 | ///
63 | /// Get default back color of the editor
64 | ///
65 | /// Default back color
66 | public static Color GetEditorBackColor()
67 | {
68 | return TranslateColor(SystemColors.Window);
69 | }
70 |
71 | ///
72 | /// Get warning back color for the editor
73 | ///
74 | /// Warning color
75 | /// For empty or not validated values
76 | public static Color GetEditorWarningBackColor()
77 | {
78 | return TranslateColor(Color.MistyRose);
79 | }
80 |
81 | ///
82 | /// Get default text color according to the Theme
83 | ///
84 | /// Text color
85 | public static Color GetTextColor()
86 | {
87 | return TranslateColor(SystemColors.ControlText);
88 | }
89 |
90 | ///
91 | /// Get a default skin preview image
92 | ///
93 | /// Image width
94 | /// Image height
95 | /// Indent for bounds
96 | /// Image
97 | /// Useful, if need to create buttons for user to select an app theme
98 | public static Image GetSkinPreviewImage(int width, int height, int indent = 0)
99 | {
100 | var currentSkin = CommonSkins.GetSkin(UserLookAndFeel.Default);
101 | return GetSkinPreviewImage(currentSkin.Name, width, height, indent);
102 | }
103 |
104 | ///
105 | /// Get a skin preview image
106 | ///
107 | /// Skin name
108 | /// Image width
109 | /// Image height
110 | /// Indent for bounds
111 | /// Image
112 | /// Useful, if need to create buttons for user to select an app theme
113 | public static Image GetSkinPreviewImage(string skinName, int width, int height, int indent = 0)
114 | {
115 | using (var button = new SimpleButton())
116 | {
117 | var skin = SkinManager.Default.Skins[skinName];
118 | if (skin == null)
119 | {
120 | throw new ArgumentException("Skin name not found");
121 | }
122 |
123 | button.LookAndFeel.SetSkinStyle(skin.SkinName);
124 | var image = new Bitmap(width, height);
125 | using (var graphics = Graphics.FromImage(image))
126 | {
127 | var info = new StyleObjectInfoArgs(new GraphicsCache(graphics))
128 | {
129 | Bounds = new Rectangle(0, 0, width, height)
130 | };
131 |
132 | button.LookAndFeel.Painter.GroupPanel.DrawObject(info);
133 | button.LookAndFeel.Painter.Border.DrawObject(info);
134 | info.Bounds = new Rectangle(indent, indent, width - indent * 2, height - indent * 2);
135 | button.LookAndFeel.Painter.Button.DrawObject(info);
136 | }
137 |
138 | return image;
139 | }
140 | }
141 | }
142 | }
--------------------------------------------------------------------------------
/DevExpressWinFormsExtension/Utils/SolidBrushesCache.cs:
--------------------------------------------------------------------------------
1 | using Caching;
2 | using System;
3 | using System.Drawing;
4 | using System.Reflection;
5 |
6 | namespace DevExpressWinFormsExtension.Utils
7 | {
8 | ///
9 | /// Class for caching solid brushes
10 | ///
11 | /// Don't dispose brushes after using! Use Dispose on Application.Exit
12 | public static class SolidBrushesCache
13 | {
14 | ///
15 | /// Amount of brushes followed by cleaning
16 | ///
17 | private const int cacheSize = 1000;
18 |
19 | ///
20 | /// Cache of used brushes
21 | ///
22 | private static readonly LRUCache brushes = new LRUCache(cacheSize);
23 |
24 | ///
25 | /// Get SolidBrush by color
26 | ///
27 | /// Color
28 | /// SolidBrush
29 | public static SolidBrush GetBrushByColor(Color color)
30 | {
31 | var colorValue = color.GetHashCode();
32 | brushes.TryGetValue(colorValue, out var brush);
33 | if (brush != null)
34 | {
35 | //// Check if brush was disposed accidently
36 | var field = typeof(Brush).GetField("nativeBrush", BindingFlags.NonPublic | BindingFlags.Instance);
37 | var hbrush = (IntPtr)field?.GetValue(brush);
38 | if (hbrush != IntPtr.Zero)
39 | {
40 | return brush;
41 | }
42 |
43 | brushes.Remove(colorValue);
44 | }
45 |
46 | var result = new SolidBrush(color);
47 | brushes.Add(colorValue, result);
48 |
49 | return result;
50 | }
51 |
52 | ///
53 | /// Dispose all brushes in the cache
54 | ///
55 | /// Needs to be called on Application.Exit
56 | public static void Dispose()
57 | {
58 | brushes.Clear();
59 | }
60 | }
61 | }
--------------------------------------------------------------------------------