├── .gitignore
├── LICENSE
├── README.md
├── examples
├── dockable-windows
│ └── FormsUI.Examples.DockableWindows
│ │ ├── App.config
│ │ ├── EditorWindow.Designer.cs
│ │ ├── EditorWindow.cs
│ │ ├── EditorWindow.resx
│ │ ├── FormsUI.Examples.DockableWindows.csproj
│ │ ├── FrmMain.Designer.cs
│ │ ├── FrmMain.cs
│ │ ├── FrmMain.resx
│ │ ├── Models
│ │ ├── Note.cs
│ │ ├── NoteEditorModel.cs
│ │ └── NoteEditorWorkspace.cs
│ │ ├── NoteListWindow.Designer.cs
│ │ ├── NoteListWindow.cs
│ │ ├── NoteListWindow.resx
│ │ ├── Program.cs
│ │ ├── Properties
│ │ ├── AssemblyInfo.cs
│ │ ├── Resources.Designer.cs
│ │ ├── Resources.resx
│ │ ├── Settings.Designer.cs
│ │ └── Settings.settings
│ │ ├── Resources
│ │ ├── application_side_boxes.png
│ │ ├── cross.png
│ │ ├── disk.png
│ │ ├── folder_page.png
│ │ ├── page_white.png
│ │ ├── page_white_add.png
│ │ └── page_white_delete.png
│ │ ├── app.manifest
│ │ └── packages.config
├── wizard
│ └── FormsUI.Examples.Wizard
│ │ ├── App.config
│ │ ├── FormsUI.Examples.Wizard.csproj
│ │ ├── FrmMain.Designer.cs
│ │ ├── FrmMain.cs
│ │ ├── FrmMain.resx
│ │ ├── Installer.Designer.cs
│ │ ├── Installer.cs
│ │ ├── Installer.resx
│ │ ├── Pages
│ │ ├── FeaturePage.Designer.cs
│ │ ├── FeaturePage.cs
│ │ ├── FeaturePage.resx
│ │ ├── InstallationPage.Designer.cs
│ │ ├── InstallationPage.cs
│ │ ├── InstallationPage.resx
│ │ ├── LicensePage.Designer.cs
│ │ ├── LicensePage.cs
│ │ ├── LicensePage.resx
│ │ ├── SummaryPage.Designer.cs
│ │ ├── SummaryPage.cs
│ │ ├── SummaryPage.resx
│ │ ├── WelcomePage.Designer.cs
│ │ ├── WelcomePage.cs
│ │ └── WelcomePage.resx
│ │ ├── Program.cs
│ │ ├── Properties
│ │ ├── AssemblyInfo.cs
│ │ ├── Resources.Designer.cs
│ │ ├── Resources.resx
│ │ ├── Settings.Designer.cs
│ │ └── Settings.settings
│ │ └── Resources
│ │ └── Apache20.rtf
└── workspace
│ └── FormsUI.Examples.Workspace
│ ├── App.config
│ ├── FormsUI.Examples.Workspace.csproj
│ ├── FrmMain.Designer.cs
│ ├── FrmMain.cs
│ ├── FrmMain.resx
│ ├── Program.cs
│ ├── Properties
│ ├── AssemblyInfo.cs
│ ├── Resources.Designer.cs
│ ├── Resources.resx
│ ├── Settings.Designer.cs
│ └── Settings.settings
│ ├── Resources
│ ├── CloseDocument_16x.png
│ ├── NewFile_16x.png
│ ├── OpenFolder_16x.png
│ ├── SaveAs_16x.png
│ └── Save_16x.png
│ ├── TextEditorModel.cs
│ └── TextEditorWorkspace.cs
└── src
├── AssemblyInfo.cs
├── CodeMaid.config
├── FormsUI.Tests
├── FormsUI.Tests.csproj
├── UnitTest1.cs
└── packages.config
├── FormsUI.Windows
├── AppWindow.Designer.cs
├── AppWindow.cs
├── DockableWindow.Designer.cs
├── DockableWindow.cs
├── DockableWindowEventArgs.cs
├── DockableWindowHiddenEventArgs.cs
├── DockableWindowManager.cs
├── DockableWindowShownEventArgs.cs
├── DocumentWindow.Designer.cs
├── DocumentWindow.cs
├── FormsUI.Windows.csproj
├── IAppWindow.cs
├── MenuStripMerge.cs
├── Properties
│ └── AssemblyInfo.cs
├── ToolAction.cs
├── ToolActionManager.cs
├── ToolStripMerge.cs
├── ToolWindow.Designer.cs
├── ToolWindow.cs
├── WindowTools.cs
└── packages.config
├── FormsUI.sln
└── FormsUI
├── ComponentManager.cs
├── Controls
└── TextBoxEx.cs
├── Disposer.cs
├── Extensions
├── Extension.cs
├── ExtensionAttribute.cs
├── ExtensionException.cs
├── ExtensionLoadEventArgs.cs
├── ExtensionManager.cs
├── ExtensionSettingsProvider.cs
├── ExternalResourceLoadEventArgs.cs
├── ExternalResourceManager.cs
├── IExtensionSettings.cs
└── IResource.cs
├── FormsUI.csproj
├── FormsUIKey.snk
├── LengthyOperation.cs
├── PropertyChangedNotifier.cs
├── Utils.cs
├── Wizards
├── IWizard.cs
├── IWizardModel.cs
├── IWizardPage.cs
├── Wizard.Designer.cs
├── Wizard.cs
├── Wizard.resx
├── WizardPage.Designer.cs
├── WizardPage.cs
├── WizardPageBase.Designer.cs
├── WizardPageBase.cs
├── WizardPageDisplay.cs
└── WizardPageType.cs
└── Workspaces
├── IWorkspaceModel.cs
├── Workspace.cs
├── WorkspaceCreatedEventArgs.cs
├── WorkspaceEventArgs.cs
├── WorkspaceException.cs
├── WorkspaceModelEnricher.cs
├── WorkspaceModelVersion.cs
├── WorkspaceModelVersionAttribute.cs
├── WorkspaceOpenedEventArgs.cs
├── WorkspaceSavedEventArgs.cs
├── WorkspaceState.cs
└── WorkspaceStateChangedEventArgs.cs
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2018 Sunny Chen
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # forms-ui
2 | A Windows Forms library for solving real life problems.
3 |
--------------------------------------------------------------------------------
/examples/dockable-windows/FormsUI.Examples.DockableWindows/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/examples/dockable-windows/FormsUI.Examples.DockableWindows/EditorWindow.Designer.cs:
--------------------------------------------------------------------------------
1 | namespace FormsUI.Examples.DockableWindows
2 | {
3 | partial class EditorWindow
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.txtEditor = new System.Windows.Forms.TextBox();
32 | this.SuspendLayout();
33 | //
34 | // txtEditor
35 | //
36 | this.txtEditor.Dock = System.Windows.Forms.DockStyle.Fill;
37 | this.txtEditor.Location = new System.Drawing.Point(0, 0);
38 | this.txtEditor.Multiline = true;
39 | this.txtEditor.Name = "txtEditor";
40 | this.txtEditor.Size = new System.Drawing.Size(800, 450);
41 | this.txtEditor.TabIndex = 0;
42 | this.txtEditor.TextChanged += new System.EventHandler(this.TxtEditor_TextChanged);
43 | //
44 | // EditorWindow
45 | //
46 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
47 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
48 | this.ClientSize = new System.Drawing.Size(800, 450);
49 | this.Controls.Add(this.txtEditor);
50 | this.Name = "EditorWindow";
51 | this.Text = "EditorWindow";
52 | this.ResumeLayout(false);
53 | this.PerformLayout();
54 |
55 | }
56 |
57 | #endregion
58 |
59 | private System.Windows.Forms.TextBox txtEditor;
60 | }
61 | }
--------------------------------------------------------------------------------
/examples/dockable-windows/FormsUI.Examples.DockableWindows/EditorWindow.cs:
--------------------------------------------------------------------------------
1 | using FormsUI.Examples.DockableWindows.Models;
2 | using FormsUI.Windows;
3 | using FormsUI.Workspaces;
4 | using System;
5 | using System.Collections.Generic;
6 | using System.ComponentModel;
7 | using System.Data;
8 | using System.Drawing;
9 | using System.Linq;
10 | using System.Text;
11 | using System.Threading.Tasks;
12 | using System.Windows.Forms;
13 |
14 | namespace FormsUI.Examples.DockableWindows
15 | {
16 | public partial class EditorWindow : DocumentWindow
17 | {
18 | public EditorWindow(IAppWindow appWindow, Note note)
19 | : base(appWindow)
20 | {
21 | InitializeComponent();
22 | this.Note = note;
23 | this.txtEditor.Text = note.Content;
24 | }
25 |
26 | protected override void OnShown(EventArgs e)
27 | {
28 | base.OnShown(e);
29 | txtEditor.SelectionStart = 0;
30 | txtEditor.SelectionLength = 0;
31 | txtEditor.Focus();
32 | }
33 |
34 | public Note Note { get; }
35 |
36 | private void TxtEditor_TextChanged(object sender, EventArgs e)
37 | {
38 | Note.Content = txtEditor.Text;
39 | }
40 |
41 | protected override void OnFormClosed(FormClosedEventArgs e)
42 | {
43 | base.OnFormClosed(e);
44 | }
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/examples/dockable-windows/FormsUI.Examples.DockableWindows/FrmMain.cs:
--------------------------------------------------------------------------------
1 | using FormsUI.Examples.DockableWindows.Models;
2 | using FormsUI.Examples.DockableWindows.Properties;
3 | using FormsUI.Windows;
4 | using FormsUI.Workspaces;
5 | using System;
6 | using System.Collections.Generic;
7 | using System.ComponentModel;
8 | using System.Data;
9 | using System.Drawing;
10 | using System.Linq;
11 | using System.Text;
12 | using System.Threading.Tasks;
13 | using System.Windows.Forms;
14 | using WeifenLuo.WinFormsUI.Docking;
15 |
16 | namespace FormsUI.Examples.DockableWindows
17 | {
18 | public partial class FrmMain : AppWindow
19 | {
20 |
21 | #region Private Fields
22 |
23 | private ToolAction closeTool;
24 | private ToolAction newTool;
25 | private ToolAction openTool;
26 | private ToolAction saveAsTool;
27 | private ToolAction saveTool;
28 |
29 | #endregion Private Fields
30 |
31 | #region Public Constructors
32 |
33 | public FrmMain()
34 | {
35 | InitializeComponent();
36 | }
37 |
38 | #endregion Public Constructors
39 |
40 | #region Public Properties
41 |
42 | public override DockPanel DockArea => dockPanel;
43 |
44 | #endregion Public Properties
45 |
46 | #region Protected Methods
47 |
48 | protected override Workspace CreateWorkspace() => new NoteEditorWorkspace();
49 |
50 | protected override void OnLoad(EventArgs e)
51 | {
52 | base.OnLoad(e);
53 | RegisterTools();
54 | RegisterToolWindows();
55 | ResetMenuStates();
56 | }
57 |
58 | protected override void OnWorkspaceClosed(object sender, EventArgs e)
59 | {
60 | WindowManager.CloseWindows();
61 | }
62 | protected override void OnWorkspaceCreated(object sender, WorkspaceCreatedEventArgs e)
63 | {
64 | WindowManager.GetFirstWindow()?.Show();
65 | }
66 |
67 | protected override void OnWorkspaceStateChanged(object sender, WorkspaceStateChangedEventArgs e)
68 | {
69 | switch (e.State)
70 | {
71 | case WorkspaceState.Inactive:
72 | ResetMenuStates();
73 | break;
74 |
75 | case WorkspaceState.Clean:
76 | saveTool.Enabled = false;
77 | break;
78 |
79 | case WorkspaceState.Modified:
80 | saveTool.Enabled = true;
81 | break;
82 |
83 | case WorkspaceState.Opened:
84 | case WorkspaceState.Created:
85 | closeTool.Enabled = true;
86 | break;
87 | }
88 |
89 | base.OnWorkspaceStateChanged(sender, e);
90 | }
91 |
92 | #endregion Protected Methods
93 |
94 | #region Private Methods
95 |
96 | private void Action_Close(ToolAction toolAction)
97 | {
98 | Workspace.Close();
99 | }
100 |
101 | private void Action_New(ToolAction toolAction)
102 | {
103 | Workspace.New(model =>
104 | {
105 | var noteEditorModel = model as NoteEditorModel;
106 | noteEditorModel.Add(new Note { Title = "Note1", Content = string.Empty });
107 | return (true, noteEditorModel);
108 | });
109 | }
110 |
111 | private void Action_Open(ToolAction toolAction)
112 | {
113 | Workspace.Open();
114 | }
115 |
116 | private void Action_Save(ToolAction toolAction)
117 | {
118 | Workspace.Save();
119 | }
120 |
121 | private void Action_SaveAs(ToolAction toolAction)
122 | {
123 | Workspace.Save(true);
124 | }
125 |
126 | private void RegisterTools()
127 | {
128 | newTool = RegisterTool("newTool", "New", new ToolStripItem[] { mnuNew, tbtnNew },
129 | Action_New, tooltipText: "Creates a new workspace.", image: Resources.page_white, shortcutKeys: Keys.Control | Keys.N);
130 |
131 | openTool = RegisterTool("openTool", "&Open...", new ToolStripItem[] { mnuOpen, tbtnOpen },
132 | Action_Open, tooltipText: "Opens an existing workspace.", image: Resources.folder_page, shortcutKeys: Keys.Control | Keys.O);
133 |
134 | saveTool = RegisterTool("saveTool", "&Save", new ToolStripItem[] { mnuSave, tbtnSave },
135 | Action_Save, tooltipText: "Saves the current workspace.", image: Resources.disk, shortcutKeys: Keys.Control | Keys.S);
136 |
137 | saveAsTool = RegisterTool("saveAsTool", "Save &As...", new ToolStripItem[] { mnuSaveAs },
138 | Action_SaveAs, tooltipText: "Saves the current workspace as another file.", shortcutKeys: Keys.Control | Keys.Shift | Keys.S);
139 |
140 | closeTool = RegisterTool("closeTool", "Close", new ToolStripItem[] { mnuClose },
141 | Action_Close, tooltipText: "Closes the current workspace.", image: Resources.cross);
142 | }
143 |
144 | private void RegisterToolWindows()
145 | {
146 | RegisterToolWindow(new ToolStripItem[] { mnuNoteList, tbtnNodeList },
147 | "Note List",
148 | Resources.application_side_boxes,
149 | DockState.DockLeft, true, "Show or hide the Note List window.", Keys.F12);
150 | }
151 | private void ResetMenuStates()
152 | {
153 | newTool.Enabled = true;
154 | openTool.Enabled = true;
155 | saveTool.Enabled = false;
156 | saveAsTool.Enabled = false;
157 | closeTool.Enabled = false;
158 | }
159 |
160 | #endregion Private Methods
161 |
162 | }
163 | }
164 |
--------------------------------------------------------------------------------
/examples/dockable-windows/FormsUI.Examples.DockableWindows/Models/Note.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace FormsUI.Examples.DockableWindows.Models
8 | {
9 | public class Note : PropertyChangedNotifier
10 | {
11 | private string title;
12 | private string content;
13 |
14 | public string Title
15 | {
16 | get => title;
17 | set
18 | {
19 | if (title != value)
20 | {
21 | title = value;
22 | OnPropertyChanged(nameof(Title));
23 | }
24 | }
25 | }
26 |
27 | public string Content
28 | {
29 | get => content;
30 | set
31 | {
32 | if (content != value)
33 | {
34 | content = value;
35 | OnPropertyChanged(nameof(Content));
36 | }
37 | }
38 | }
39 |
40 | public override bool Equals(object obj)
41 | {
42 | return obj is Note note &&
43 | title == note.title &&
44 | content == note.content;
45 | }
46 |
47 | public override int GetHashCode()
48 | {
49 | var hashCode = -1490960589;
50 | hashCode = hashCode * -1521134295 + EqualityComparer.Default.GetHashCode(title);
51 | hashCode = hashCode * -1521134295 + EqualityComparer.Default.GetHashCode(content);
52 | return hashCode;
53 | }
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/examples/dockable-windows/FormsUI.Examples.DockableWindows/Models/NoteEditorModel.cs:
--------------------------------------------------------------------------------
1 | using FormsUI.Workspaces;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Collections.ObjectModel;
5 | using System.Linq;
6 | using System.Text;
7 | using System.Threading.Tasks;
8 |
9 | namespace FormsUI.Examples.DockableWindows.Models
10 | {
11 | [WorkspaceModelVersion(1, 0)]
12 | public sealed class NoteEditorModel : PropertyChangedNotifier, IWorkspaceModel
13 | {
14 | private ObservableCollection notes = new ObservableCollection();
15 |
16 | public WorkspaceModelVersion Version { get; set; }
17 |
18 | public NoteEditorModel()
19 | {
20 | BindObservableCollection(notes);
21 | }
22 |
23 | public void Add(Note note)
24 | {
25 | notes.Add(note);
26 | }
27 |
28 | public void Delete(Note note)
29 | {
30 | notes.Remove(note);
31 | }
32 |
33 | public int Count => notes.Count;
34 |
35 | public IEnumerable Notes => notes;
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/examples/dockable-windows/FormsUI.Examples.DockableWindows/Models/NoteEditorWorkspace.cs:
--------------------------------------------------------------------------------
1 | using FormsUI.Workspaces;
2 | using Newtonsoft.Json;
3 | using System;
4 | using System.Collections.Generic;
5 | using System.IO;
6 | using System.Linq;
7 | using System.Text;
8 | using System.Threading.Tasks;
9 |
10 | namespace FormsUI.Examples.DockableWindows.Models
11 | {
12 | public sealed class NoteEditorWorkspace : Workspace
13 | {
14 | private static readonly JsonSerializerSettings serializerSettings =
15 | new JsonSerializerSettings
16 | {
17 | NullValueHandling = NullValueHandling.Ignore,
18 | Formatting = Formatting.Indented
19 | };
20 |
21 | protected override string WorkspaceFileDescription => "Note Editor File";
22 |
23 | protected override string WorkspaceFileExtension => "nef";
24 |
25 | protected override string SaveDialogTitle => "Save Notes";
26 |
27 | protected override string OpenDialogTitle => "Open Notes";
28 |
29 | protected override IWorkspaceModel Create()
30 | {
31 | return new NoteEditorModel();
32 | }
33 |
34 | protected override IWorkspaceModel OpenFromFile(string fileName)
35 | {
36 | var json = File.ReadAllText(fileName);
37 | return JsonConvert.DeserializeObject(json);
38 | }
39 |
40 | protected override void SaveToFile(IWorkspaceModel model, string fileName)
41 | {
42 | var json = JsonConvert.SerializeObject(model, serializerSettings);
43 | File.WriteAllText(fileName, json);
44 | }
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/examples/dockable-windows/FormsUI.Examples.DockableWindows/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Threading.Tasks;
5 | using System.Windows.Forms;
6 |
7 | namespace FormsUI.Examples.DockableWindows
8 | {
9 | static class Program
10 | {
11 | ///
12 | /// The main entry point for the application.
13 | ///
14 | [STAThread]
15 | static void Main()
16 | {
17 | Application.EnableVisualStyles();
18 | Application.SetCompatibleTextRenderingDefault(false);
19 | Application.Run(new FrmMain());
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/examples/dockable-windows/FormsUI.Examples.DockableWindows/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("FormsUI.Examples.DockableWindows")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("FormsUI.Examples.DockableWindows")]
13 | [assembly: AssemblyCopyright("Copyright © 2019")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("c8845261-04e3-4a2c-8e15-f5d65432a7bc")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/examples/dockable-windows/FormsUI.Examples.DockableWindows/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 | namespace FormsUI.Examples.DockableWindows.Properties {
12 | using System;
13 |
14 |
15 | ///
16 | /// A strongly-typed resource class, for looking up localized strings, etc.
17 | ///
18 | // This class was auto-generated by the StronglyTypedResourceBuilder
19 | // class via a tool like ResGen or Visual Studio.
20 | // To add or remove a member, edit your .ResX file then rerun ResGen
21 | // with the /str option, or rebuild your VS project.
22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
25 | internal class Resources {
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 | /// Returns the cached ResourceManager instance used by this class.
37 | ///
38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
39 | internal static global::System.Resources.ResourceManager ResourceManager {
40 | get {
41 | if (object.ReferenceEquals(resourceMan, null)) {
42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("FormsUI.Examples.DockableWindows.Properties.Resources", typeof(Resources).Assembly);
43 | resourceMan = temp;
44 | }
45 | return resourceMan;
46 | }
47 | }
48 |
49 | ///
50 | /// Overrides the current thread's CurrentUICulture property for all
51 | /// resource lookups using this strongly typed resource class.
52 | ///
53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
54 | internal static global::System.Globalization.CultureInfo Culture {
55 | get {
56 | return resourceCulture;
57 | }
58 | set {
59 | resourceCulture = value;
60 | }
61 | }
62 |
63 | ///
64 | /// Looks up a localized resource of type System.Drawing.Bitmap.
65 | ///
66 | internal static System.Drawing.Bitmap application_side_boxes {
67 | get {
68 | object obj = ResourceManager.GetObject("application_side_boxes", resourceCulture);
69 | return ((System.Drawing.Bitmap)(obj));
70 | }
71 | }
72 |
73 | ///
74 | /// Looks up a localized resource of type System.Drawing.Bitmap.
75 | ///
76 | internal static System.Drawing.Bitmap cross {
77 | get {
78 | object obj = ResourceManager.GetObject("cross", resourceCulture);
79 | return ((System.Drawing.Bitmap)(obj));
80 | }
81 | }
82 |
83 | ///
84 | /// Looks up a localized resource of type System.Drawing.Bitmap.
85 | ///
86 | internal static System.Drawing.Bitmap disk {
87 | get {
88 | object obj = ResourceManager.GetObject("disk", resourceCulture);
89 | return ((System.Drawing.Bitmap)(obj));
90 | }
91 | }
92 |
93 | ///
94 | /// Looks up a localized resource of type System.Drawing.Bitmap.
95 | ///
96 | internal static System.Drawing.Bitmap folder_page {
97 | get {
98 | object obj = ResourceManager.GetObject("folder_page", resourceCulture);
99 | return ((System.Drawing.Bitmap)(obj));
100 | }
101 | }
102 |
103 | ///
104 | /// Looks up a localized resource of type System.Drawing.Bitmap.
105 | ///
106 | internal static System.Drawing.Bitmap page_white {
107 | get {
108 | object obj = ResourceManager.GetObject("page_white", resourceCulture);
109 | return ((System.Drawing.Bitmap)(obj));
110 | }
111 | }
112 |
113 | ///
114 | /// Looks up a localized resource of type System.Drawing.Bitmap.
115 | ///
116 | internal static System.Drawing.Bitmap page_white_add {
117 | get {
118 | object obj = ResourceManager.GetObject("page_white_add", resourceCulture);
119 | return ((System.Drawing.Bitmap)(obj));
120 | }
121 | }
122 |
123 | ///
124 | /// Looks up a localized resource of type System.Drawing.Bitmap.
125 | ///
126 | internal static System.Drawing.Bitmap page_white_delete {
127 | get {
128 | object obj = ResourceManager.GetObject("page_white_delete", resourceCulture);
129 | return ((System.Drawing.Bitmap)(obj));
130 | }
131 | }
132 | }
133 | }
134 |
--------------------------------------------------------------------------------
/examples/dockable-windows/FormsUI.Examples.DockableWindows/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 | namespace FormsUI.Examples.DockableWindows.Properties {
12 |
13 |
14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.1.0.0")]
16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
17 |
18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
19 |
20 | public static Settings Default {
21 | get {
22 | return defaultInstance;
23 | }
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/examples/dockable-windows/FormsUI.Examples.DockableWindows/Properties/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/examples/dockable-windows/FormsUI.Examples.DockableWindows/Resources/application_side_boxes.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/daxnet/forms-ui/6200413a9e81bfdfd6e3113e19cc3da6e607a11b/examples/dockable-windows/FormsUI.Examples.DockableWindows/Resources/application_side_boxes.png
--------------------------------------------------------------------------------
/examples/dockable-windows/FormsUI.Examples.DockableWindows/Resources/cross.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/daxnet/forms-ui/6200413a9e81bfdfd6e3113e19cc3da6e607a11b/examples/dockable-windows/FormsUI.Examples.DockableWindows/Resources/cross.png
--------------------------------------------------------------------------------
/examples/dockable-windows/FormsUI.Examples.DockableWindows/Resources/disk.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/daxnet/forms-ui/6200413a9e81bfdfd6e3113e19cc3da6e607a11b/examples/dockable-windows/FormsUI.Examples.DockableWindows/Resources/disk.png
--------------------------------------------------------------------------------
/examples/dockable-windows/FormsUI.Examples.DockableWindows/Resources/folder_page.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/daxnet/forms-ui/6200413a9e81bfdfd6e3113e19cc3da6e607a11b/examples/dockable-windows/FormsUI.Examples.DockableWindows/Resources/folder_page.png
--------------------------------------------------------------------------------
/examples/dockable-windows/FormsUI.Examples.DockableWindows/Resources/page_white.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/daxnet/forms-ui/6200413a9e81bfdfd6e3113e19cc3da6e607a11b/examples/dockable-windows/FormsUI.Examples.DockableWindows/Resources/page_white.png
--------------------------------------------------------------------------------
/examples/dockable-windows/FormsUI.Examples.DockableWindows/Resources/page_white_add.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/daxnet/forms-ui/6200413a9e81bfdfd6e3113e19cc3da6e607a11b/examples/dockable-windows/FormsUI.Examples.DockableWindows/Resources/page_white_add.png
--------------------------------------------------------------------------------
/examples/dockable-windows/FormsUI.Examples.DockableWindows/Resources/page_white_delete.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/daxnet/forms-ui/6200413a9e81bfdfd6e3113e19cc3da6e607a11b/examples/dockable-windows/FormsUI.Examples.DockableWindows/Resources/page_white_delete.png
--------------------------------------------------------------------------------
/examples/dockable-windows/FormsUI.Examples.DockableWindows/app.manifest:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
52 |
59 |
60 |
61 |
75 |
76 |
77 |
--------------------------------------------------------------------------------
/examples/dockable-windows/FormsUI.Examples.DockableWindows/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/examples/wizard/FormsUI.Examples.Wizard/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/examples/wizard/FormsUI.Examples.Wizard/FrmMain.Designer.cs:
--------------------------------------------------------------------------------
1 | namespace FormsUI.Examples.Wizard
2 | {
3 | partial class FrmMain
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.btnOpenWizard = new System.Windows.Forms.Button();
32 | this.SuspendLayout();
33 | //
34 | // btnOpenWizard
35 | //
36 | this.btnOpenWizard.Location = new System.Drawing.Point(76, 42);
37 | this.btnOpenWizard.Name = "btnOpenWizard";
38 | this.btnOpenWizard.Size = new System.Drawing.Size(109, 23);
39 | this.btnOpenWizard.TabIndex = 0;
40 | this.btnOpenWizard.Text = "Open Wizard...";
41 | this.btnOpenWizard.UseVisualStyleBackColor = true;
42 | this.btnOpenWizard.Click += new System.EventHandler(this.btnOpenWizard_Click);
43 | //
44 | // FrmMain
45 | //
46 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
47 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
48 | this.ClientSize = new System.Drawing.Size(267, 98);
49 | this.Controls.Add(this.btnOpenWizard);
50 | this.Name = "FrmMain";
51 | this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
52 | this.Text = "Form1";
53 | this.ResumeLayout(false);
54 |
55 | }
56 |
57 | #endregion
58 |
59 | private System.Windows.Forms.Button btnOpenWizard;
60 | }
61 | }
62 |
63 |
--------------------------------------------------------------------------------
/examples/wizard/FormsUI.Examples.Wizard/FrmMain.cs:
--------------------------------------------------------------------------------
1 | using FormsUI.Examples.Wizard.Pages;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.ComponentModel;
5 | using System.Data;
6 | using System.Drawing;
7 | using System.Linq;
8 | using System.Text;
9 | using System.Threading.Tasks;
10 | using System.Windows.Forms;
11 |
12 | namespace FormsUI.Examples.Wizard
13 | {
14 | public partial class FrmMain : Form
15 | {
16 | public FrmMain()
17 | {
18 | InitializeComponent();
19 | }
20 |
21 | private void btnOpenWizard_Click(object sender, EventArgs e)
22 | {
23 | using (var wizard = new Installer())
24 | {
25 | wizard.Add(wizard.CreatePage());
26 | wizard.Add(wizard.CreatePage());
27 | wizard.Add(wizard.CreatePage());
28 | wizard.Add(wizard.CreatePage());
29 | wizard.Add(wizard.CreatePage());
30 | wizard.ShowDialog();
31 | }
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/examples/wizard/FormsUI.Examples.Wizard/FrmMain.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 |
--------------------------------------------------------------------------------
/examples/wizard/FormsUI.Examples.Wizard/Installer.Designer.cs:
--------------------------------------------------------------------------------
1 | namespace FormsUI.Examples.Wizard
2 | {
3 | partial class Installer
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.SuspendLayout();
32 | //
33 | // Installer
34 | //
35 | this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
36 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
37 | this.ClientSize = new System.Drawing.Size(769, 503);
38 | this.Name = "Installer";
39 | this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
40 | this.Text = "Installer";
41 | this.ResumeLayout(false);
42 |
43 | }
44 |
45 | #endregion
46 | }
47 | }
--------------------------------------------------------------------------------
/examples/wizard/FormsUI.Examples.Wizard/Installer.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Data;
5 | using System.Drawing;
6 | using System.Linq;
7 | using System.Text;
8 | using System.Threading.Tasks;
9 | using System.Windows.Forms;
10 |
11 | namespace FormsUI.Examples.Wizard
12 | {
13 | public partial class Installer : Wizards.Wizard
14 | {
15 | public Installer()
16 | {
17 | InitializeComponent();
18 | }
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/examples/wizard/FormsUI.Examples.Wizard/Installer.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 |
--------------------------------------------------------------------------------
/examples/wizard/FormsUI.Examples.Wizard/Pages/FeaturePage.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Drawing;
5 | using System.Data;
6 | using System.Linq;
7 | using System.Text;
8 | using System.Threading.Tasks;
9 | using System.Windows.Forms;
10 | using System.IO;
11 | using FormsUI.Wizards;
12 |
13 | namespace FormsUI.Examples.Wizard.Pages
14 | {
15 | public partial class FeaturePage : WizardPage
16 | {
17 | public FeaturePage(Wizards.Wizard wizard)
18 | : base(new Guid(), "Features", "Choose the feature set you'd like to install, as well as the installation destination.", wizard) => InitializeComponent();
19 |
20 | protected override Task ExecuteShowAsync(IWizardPage fromPage)
21 | {
22 | var installDestination = Wizard.GetWizardParameter("feature.install-destination");
23 | if (string.IsNullOrEmpty(installDestination))
24 | {
25 | txtInstallDest.Text = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), "FormsUIExample");
26 | Wizard.AddParameter("feature.install-destination", txtInstallDest.Text);
27 | }
28 | else
29 | {
30 | txtInstallDest.Text = installDestination;
31 | }
32 |
33 | var feature = Wizard.GetWizardParameter("feature.feature");
34 | if (!feature.HasValue)
35 | {
36 | feature = 1;
37 | Wizard.AddParameter("feature.feature", feature.Value);
38 | }
39 |
40 | foreach (Control c in grpFeatureSelection.Controls)
41 | {
42 | if (c is RadioButton rb && Convert.ToInt32(rb.Tag) == feature.Value)
43 | {
44 | rb.Checked = true;
45 | }
46 | }
47 |
48 | return base.ExecuteShowAsync(fromPage);
49 | }
50 |
51 | protected override Task ValidateParametersAsync()
52 | {
53 | if (string.IsNullOrEmpty(txtInstallDest.Text))
54 | {
55 | MessageBox.Show("Please specify the installation destination.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
56 | return Task.FromResult(false);
57 | }
58 |
59 | if (!Directory.Exists(txtInstallDest.Text))
60 | {
61 | MessageBox.Show("The specified installation destination does not exist.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
62 | return Task.FromResult(false);
63 | }
64 |
65 | return base.ValidateParametersAsync();
66 | }
67 |
68 | protected override Task ExecuteBeforeLeavingAsync()
69 | {
70 | Wizard.AddParameter("feature.install-destination", txtInstallDest.Text);
71 | foreach (Control c in grpFeatureSelection.Controls)
72 | {
73 | if (c is RadioButton rb && rb.Checked)
74 | {
75 | Wizard.AddParameter("feature.feature", Convert.ToInt32(rb.Tag));
76 | }
77 | }
78 |
79 | return base.ExecuteBeforeLeavingAsync();
80 | }
81 |
82 | private void btnChoose_Click(object sender, EventArgs e)
83 | {
84 | if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
85 | {
86 | txtInstallDest.Text = folderBrowserDialog1.SelectedPath;
87 | }
88 | }
89 | }
90 | }
91 |
--------------------------------------------------------------------------------
/examples/wizard/FormsUI.Examples.Wizard/Pages/InstallationPage.Designer.cs:
--------------------------------------------------------------------------------
1 | namespace FormsUI.Examples.Wizard.Pages
2 | {
3 | partial class InstallationPage
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.SuspendLayout();
32 | //
33 | // InstallationPage
34 | //
35 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
36 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
37 | this.Name = "InstallationPage";
38 | this.Size = new System.Drawing.Size(323, 288);
39 | this.ResumeLayout(false);
40 |
41 | }
42 |
43 | #endregion
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/examples/wizard/FormsUI.Examples.Wizard/Pages/InstallationPage.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Drawing;
5 | using System.Data;
6 | using System.Linq;
7 | using System.Text;
8 | using System.Threading.Tasks;
9 | using System.Windows.Forms;
10 | using FormsUI.Wizards;
11 |
12 | namespace FormsUI.Examples.Wizard.Pages
13 | {
14 | public partial class InstallationPage : WizardPage
15 | {
16 | public InstallationPage(Wizards.Wizard wizard)
17 | : base(new Guid(), "Installing In Progress", "", wizard)
18 | {
19 | InitializeComponent();
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/examples/wizard/FormsUI.Examples.Wizard/Pages/LicensePage.Designer.cs:
--------------------------------------------------------------------------------
1 | namespace FormsUI.Examples.Wizard.Pages
2 | {
3 | partial class LicensePage
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.pnlBottom = new System.Windows.Forms.Panel();
32 | this.richTextBox1 = new System.Windows.Forms.RichTextBox();
33 | this.rbAccept = new System.Windows.Forms.RadioButton();
34 | this.rbNotAccept = new System.Windows.Forms.RadioButton();
35 | this.pnlBottom.SuspendLayout();
36 | this.SuspendLayout();
37 | //
38 | // pnlBottom
39 | //
40 | this.pnlBottom.Controls.Add(this.rbNotAccept);
41 | this.pnlBottom.Controls.Add(this.rbAccept);
42 | this.pnlBottom.Dock = System.Windows.Forms.DockStyle.Bottom;
43 | this.pnlBottom.Location = new System.Drawing.Point(0, 367);
44 | this.pnlBottom.Name = "pnlBottom";
45 | this.pnlBottom.Size = new System.Drawing.Size(711, 69);
46 | this.pnlBottom.TabIndex = 0;
47 | //
48 | // richTextBox1
49 | //
50 | this.richTextBox1.BackColor = System.Drawing.SystemColors.Window;
51 | this.richTextBox1.Dock = System.Windows.Forms.DockStyle.Fill;
52 | this.richTextBox1.Location = new System.Drawing.Point(0, 0);
53 | this.richTextBox1.Name = "richTextBox1";
54 | this.richTextBox1.ReadOnly = true;
55 | this.richTextBox1.Size = new System.Drawing.Size(711, 367);
56 | this.richTextBox1.TabIndex = 1;
57 | this.richTextBox1.Text = "";
58 | //
59 | // rbAccept
60 | //
61 | this.rbAccept.AutoSize = true;
62 | this.rbAccept.Location = new System.Drawing.Point(20, 16);
63 | this.rbAccept.Name = "rbAccept";
64 | this.rbAccept.Size = new System.Drawing.Size(138, 17);
65 | this.rbAccept.TabIndex = 0;
66 | this.rbAccept.TabStop = true;
67 | this.rbAccept.Text = "I accept the agreement.";
68 | this.rbAccept.UseVisualStyleBackColor = true;
69 | this.rbAccept.Click += new System.EventHandler(this.OnRadioButtonClicked);
70 | //
71 | // rbNotAccept
72 | //
73 | this.rbNotAccept.AutoSize = true;
74 | this.rbNotAccept.Location = new System.Drawing.Point(20, 39);
75 | this.rbNotAccept.Name = "rbNotAccept";
76 | this.rbNotAccept.Size = new System.Drawing.Size(171, 17);
77 | this.rbNotAccept.TabIndex = 1;
78 | this.rbNotAccept.TabStop = true;
79 | this.rbNotAccept.Text = "I do not accept the agreement.";
80 | this.rbNotAccept.UseVisualStyleBackColor = true;
81 | this.rbNotAccept.Click += new System.EventHandler(this.OnRadioButtonClicked);
82 | //
83 | // LicensePage
84 | //
85 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
86 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
87 | this.Controls.Add(this.richTextBox1);
88 | this.Controls.Add(this.pnlBottom);
89 | this.Name = "LicensePage";
90 | this.Size = new System.Drawing.Size(711, 436);
91 | this.pnlBottom.ResumeLayout(false);
92 | this.pnlBottom.PerformLayout();
93 | this.ResumeLayout(false);
94 |
95 | }
96 |
97 | #endregion
98 |
99 | private System.Windows.Forms.Panel pnlBottom;
100 | private System.Windows.Forms.RichTextBox richTextBox1;
101 | private System.Windows.Forms.RadioButton rbNotAccept;
102 | private System.Windows.Forms.RadioButton rbAccept;
103 | }
104 | }
105 |
--------------------------------------------------------------------------------
/examples/wizard/FormsUI.Examples.Wizard/Pages/LicensePage.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Drawing;
5 | using System.Data;
6 | using System.Linq;
7 | using System.Text;
8 | using System.Threading.Tasks;
9 | using System.Windows.Forms;
10 | using FormsUI.Wizards;
11 | using FormsUI.Examples.Wizard.Properties;
12 | using System.IO;
13 |
14 | namespace FormsUI.Examples.Wizard.Pages
15 | {
16 | public partial class LicensePage : WizardPage
17 | {
18 | public LicensePage(Wizards.Wizard wizard)
19 | : base(new Guid("{45AB2D37-3B81-4191-92EF-03134072C71B}"), "License Agreement", "Please read the license terms before installing the software.",
20 | wizard) => InitializeComponent();
21 |
22 | protected override Task ExecuteShowAsync(IWizardPage fromPage)
23 | {
24 | var license = Encoding.ASCII.GetBytes(Resources.Apache20);
25 | using (var memoryStream = new MemoryStream(license))
26 | {
27 | this.richTextBox1.LoadFile(memoryStream, RichTextBoxStreamType.RichText);
28 | }
29 |
30 | rbNotAccept.Checked = true;
31 | UpdateControls();
32 |
33 | return base.ExecuteShowAsync(fromPage);
34 | }
35 |
36 | private void OnRadioButtonClicked(object sender, EventArgs e) => UpdateControls();
37 |
38 | private void UpdateControls() => this.CanGoNextPage = rbAccept.Checked;
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/examples/wizard/FormsUI.Examples.Wizard/Pages/LicensePage.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 |
--------------------------------------------------------------------------------
/examples/wizard/FormsUI.Examples.Wizard/Pages/SummaryPage.Designer.cs:
--------------------------------------------------------------------------------
1 | namespace FormsUI.Examples.Wizard.Pages
2 | {
3 | partial class SummaryPage
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.txt = new System.Windows.Forms.TextBox();
32 | this.SuspendLayout();
33 | //
34 | // txt
35 | //
36 | this.txt.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
37 | | System.Windows.Forms.AnchorStyles.Left)
38 | | System.Windows.Forms.AnchorStyles.Right)));
39 | this.txt.Location = new System.Drawing.Point(16, 16);
40 | this.txt.Multiline = true;
41 | this.txt.Name = "txt";
42 | this.txt.ReadOnly = true;
43 | this.txt.ScrollBars = System.Windows.Forms.ScrollBars.Both;
44 | this.txt.Size = new System.Drawing.Size(493, 286);
45 | this.txt.TabIndex = 0;
46 | //
47 | // SummaryPage
48 | //
49 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
50 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
51 | this.Controls.Add(this.txt);
52 | this.Name = "SummaryPage";
53 | this.Size = new System.Drawing.Size(525, 320);
54 | this.ResumeLayout(false);
55 | this.PerformLayout();
56 |
57 | }
58 |
59 | #endregion
60 |
61 | private System.Windows.Forms.TextBox txt;
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/examples/wizard/FormsUI.Examples.Wizard/Pages/SummaryPage.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Drawing;
5 | using System.Data;
6 | using System.Linq;
7 | using System.Text;
8 | using System.Threading.Tasks;
9 | using System.Windows.Forms;
10 | using FormsUI.Wizards;
11 |
12 | namespace FormsUI.Examples.Wizard.Pages
13 | {
14 | public partial class SummaryPage : WizardPage
15 | {
16 | public SummaryPage(Wizards.Wizard wizard)
17 | : base(new Guid(), "Summary", "Please review the summary info.", wizard)
18 | {
19 | InitializeComponent();
20 | }
21 |
22 | protected override Task ExecuteShowAsync(IWizardPage fromPage)
23 | {
24 | var sb = new StringBuilder();
25 | sb.AppendLine("Installation Path:");
26 | sb.AppendLine($" {Wizard.GetWizardParameter("feature.install-destination")}");
27 | sb.AppendLine();
28 | sb.AppendLine("Feature Selection:");
29 | switch (Wizard.GetWizardParameter("feature.feature"))
30 | {
31 | case 1:
32 | sb.AppendLine(" Minimal installation");
33 | break;
34 | case 2:
35 | sb.AppendLine(" Standard installation");
36 | break;
37 | case 3:
38 | sb.AppendLine(" Full installation");
39 | break;
40 | }
41 |
42 | txt.Text = sb.ToString();
43 |
44 | this.Wizard.NextButtonText = "Install";
45 |
46 | return base.ExecuteAfterShownAsync();
47 | }
48 |
49 | protected override Task ExecuteBeforeGoingPreviousAsync()
50 | {
51 | this.Wizard.NextButtonText = "Next";
52 | return base.ExecuteBeforeGoingPreviousAsync();
53 | }
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/examples/wizard/FormsUI.Examples.Wizard/Pages/SummaryPage.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 |
--------------------------------------------------------------------------------
/examples/wizard/FormsUI.Examples.Wizard/Pages/WelcomePage.Designer.cs:
--------------------------------------------------------------------------------
1 | namespace FormsUI.Examples.Wizard.Pages
2 | {
3 | partial class WelcomePage
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.panel1 = new System.Windows.Forms.Panel();
32 | this.lblTitle = new System.Windows.Forms.Label();
33 | this.lblDescription = new System.Windows.Forms.Label();
34 | this.SuspendLayout();
35 | //
36 | // panel1
37 | //
38 | this.panel1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(192)))), ((int)(((byte)(255)))));
39 | this.panel1.Dock = System.Windows.Forms.DockStyle.Left;
40 | this.panel1.Location = new System.Drawing.Point(0, 0);
41 | this.panel1.Name = "panel1";
42 | this.panel1.Size = new System.Drawing.Size(200, 432);
43 | this.panel1.TabIndex = 0;
44 | //
45 | // lblTitle
46 | //
47 | this.lblTitle.AutoSize = true;
48 | this.lblTitle.Font = new System.Drawing.Font("Microsoft Sans Serif", 14.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
49 | this.lblTitle.Location = new System.Drawing.Point(219, 18);
50 | this.lblTitle.Name = "lblTitle";
51 | this.lblTitle.Size = new System.Drawing.Size(66, 24);
52 | this.lblTitle.TabIndex = 1;
53 | this.lblTitle.Text = "label1";
54 | //
55 | // lblDescription
56 | //
57 | this.lblDescription.AutoSize = true;
58 | this.lblDescription.Location = new System.Drawing.Point(220, 60);
59 | this.lblDescription.Name = "lblDescription";
60 | this.lblDescription.Size = new System.Drawing.Size(35, 13);
61 | this.lblDescription.TabIndex = 2;
62 | this.lblDescription.Text = "label2";
63 | //
64 | // WelcomePage
65 | //
66 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
67 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
68 | this.Controls.Add(this.lblDescription);
69 | this.Controls.Add(this.lblTitle);
70 | this.Controls.Add(this.panel1);
71 | this.Name = "WelcomePage";
72 | this.Size = new System.Drawing.Size(658, 432);
73 | this.ResumeLayout(false);
74 | this.PerformLayout();
75 |
76 | }
77 |
78 | #endregion
79 |
80 | private System.Windows.Forms.Panel panel1;
81 | private System.Windows.Forms.Label lblTitle;
82 | private System.Windows.Forms.Label lblDescription;
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/examples/wizard/FormsUI.Examples.Wizard/Pages/WelcomePage.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Drawing;
5 | using System.Data;
6 | using System.Linq;
7 | using System.Text;
8 | using System.Threading.Tasks;
9 | using System.Windows.Forms;
10 | using FormsUI.Wizards;
11 |
12 | namespace FormsUI.Examples.Wizard.Pages
13 | {
14 | public partial class WelcomePage : WizardPage
15 | {
16 | public WelcomePage(Wizards.Wizard wizard)
17 | : base(new Guid("{EB48E8A7-279D-4095-970D-F0241D2BCECE}"),
18 | "Welcome",
19 | "Welcome to the software installer.",
20 | wizard,
21 | WizardPageType.Expanded) => InitializeComponent();
22 |
23 | protected override Task ExecuteShowAsync(IWizardPage fromPage)
24 | {
25 | this.lblTitle.Text = this.Title;
26 | this.lblDescription.Text = this.Description;
27 | return base.ExecuteShowAsync(fromPage);
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/examples/wizard/FormsUI.Examples.Wizard/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Threading.Tasks;
5 | using System.Windows.Forms;
6 |
7 | namespace FormsUI.Examples.Wizard
8 | {
9 | static class Program
10 | {
11 | ///
12 | /// The main entry point for the application.
13 | ///
14 | [STAThread]
15 | static void Main()
16 | {
17 | Application.EnableVisualStyles();
18 | Application.SetCompatibleTextRenderingDefault(false);
19 | Application.Run(new FrmMain());
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/examples/wizard/FormsUI.Examples.Wizard/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("FormsUI.Examples.Wizard")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("FormsUI.Examples.Wizard")]
13 | [assembly: AssemblyCopyright("Copyright © 2018")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("68bf6ff1-5c49-4f56-ac57-8f3a39a1ad2d")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/examples/wizard/FormsUI.Examples.Wizard/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 | namespace FormsUI.Examples.Wizard.Properties {
12 | using System;
13 |
14 |
15 | ///
16 | /// A strongly-typed resource class, for looking up localized strings, etc.
17 | ///
18 | // This class was auto-generated by the StronglyTypedResourceBuilder
19 | // class via a tool like ResGen or Visual Studio.
20 | // To add or remove a member, edit your .ResX file then rerun ResGen
21 | // with the /str option, or rebuild your VS project.
22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
25 | internal class Resources {
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 | /// Returns the cached ResourceManager instance used by this class.
37 | ///
38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
39 | internal static global::System.Resources.ResourceManager ResourceManager {
40 | get {
41 | if (object.ReferenceEquals(resourceMan, null)) {
42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("FormsUI.Examples.Wizard.Properties.Resources", typeof(Resources).Assembly);
43 | resourceMan = temp;
44 | }
45 | return resourceMan;
46 | }
47 | }
48 |
49 | ///
50 | /// Overrides the current thread's CurrentUICulture property for all
51 | /// resource lookups using this strongly typed resource class.
52 | ///
53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
54 | internal static global::System.Globalization.CultureInfo Culture {
55 | get {
56 | return resourceCulture;
57 | }
58 | set {
59 | resourceCulture = value;
60 | }
61 | }
62 |
63 | ///
64 | /// Looks up a localized string similar to {\rtf1\ansi\ansicpg936\deff0\deflang1033\deflangfe2052\deftab420{\fonttbl{\f0\fswiss\fprq2\fcharset0 Tahoma;}}
65 | ///{\*\generator Msftedit 5.41.15.1515;}{\info{\horzdoc}{\*\lchars $([\'7b\'a1\'ea\'a3\'a4\'a1\'a4\'a1\'ae\'a1\'b0\'a1\'b4\'a1\'b6\'a1\'b8\'a1\'ba\'a1\'be\'a1\'b2\'a1\'bc\'a8\'94\'a9\'76\'a9\'78\'a9\'7a\'a1\'e7\'a3\'a8\'a3\'ae\'a3\'db\'a3\'fb\'a1\'ea\'a3\'a4}{\*\fchars !%),.:\'3b>?]\'7d\'a1\'e9\'a1\'a7\'a1\'e3\'a1\'a4\'a1\'a6\'a1\'a5\'a8\'44\'a1\'ac\'a1\'af\'a1\'b1\'a1\'ad\'a1\'eb\'a1\'e4\'a1\'e5?\'a [rest of string was truncated]";.
66 | ///
67 | internal static string Apache20 {
68 | get {
69 | return ResourceManager.GetString("Apache20", resourceCulture);
70 | }
71 | }
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/examples/wizard/FormsUI.Examples.Wizard/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 | namespace FormsUI.Examples.Wizard.Properties {
12 |
13 |
14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.1.0.0")]
16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
17 |
18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
19 |
20 | public static Settings Default {
21 | get {
22 | return defaultInstance;
23 | }
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/examples/wizard/FormsUI.Examples.Wizard/Properties/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/examples/workspace/FormsUI.Examples.Workspace/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/examples/workspace/FormsUI.Examples.Workspace/FormsUI.Examples.Workspace.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {6D0B42D6-3C5E-4981-9D88-1740C5942F34}
8 | WinExe
9 | FormsUI.Examples.Workspace
10 | FormsUI.Examples.Workspace
11 | v4.7.2
12 | 512
13 | true
14 | true
15 |
16 |
17 |
18 | AnyCPU
19 | true
20 | full
21 | false
22 | bin\Debug\
23 | DEBUG;TRACE
24 | prompt
25 | 4
26 |
27 |
28 | AnyCPU
29 | pdbonly
30 | true
31 | bin\Release\
32 | TRACE
33 | prompt
34 | 4
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 | Form
52 |
53 |
54 | FrmMain.cs
55 |
56 |
57 |
58 |
59 |
60 |
61 | FrmMain.cs
62 |
63 |
64 | ResXFileCodeGenerator
65 | Resources.Designer.cs
66 | Designer
67 |
68 |
69 | True
70 | Resources.resx
71 | True
72 |
73 |
74 | SettingsSingleFileGenerator
75 | Settings.Designer.cs
76 |
77 |
78 | True
79 | Settings.settings
80 | True
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 | {6ece3042-da41-4d80-8f80-aa6d2f0a96e2}
89 | FormsUI
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
--------------------------------------------------------------------------------
/examples/workspace/FormsUI.Examples.Workspace/FrmMain.cs:
--------------------------------------------------------------------------------
1 | using FormsUI.Workspaces;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.ComponentModel;
5 | using System.Data;
6 | using System.Drawing;
7 | using System.Linq;
8 | using System.Text;
9 | using System.Threading.Tasks;
10 | using System.Windows.Forms;
11 |
12 | namespace FormsUI.Examples.Workspace
13 | {
14 | public partial class FrmMain : Form
15 | {
16 | private readonly TextEditorWorkspace workspace = new TextEditorWorkspace();
17 |
18 | public FrmMain()
19 | {
20 | InitializeComponent();
21 |
22 | // Subscribe workspace events.
23 | workspace.WorkspaceCreated += Workspace_WorkspaceCreated;
24 | workspace.WorkspaceOpened += Workspace_WorkspaceOpened;
25 | workspace.WorkspaceChanged += Workspace_WorkspaceChanged;
26 | workspace.WorkspaceSaved += Workspace_WorkspaceSaved;
27 | workspace.WorkspaceClosed += Workspace_WorkspaceClosed;
28 |
29 | workspace.Close();
30 | }
31 |
32 | private void Action_New(object sender, EventArgs e)
33 | {
34 | using (new LengthyOperation(this))
35 | {
36 | workspace.New();
37 | }
38 | }
39 |
40 | private void Action_Open(object sender, EventArgs e)
41 | {
42 | using (new LengthyOperation(this))
43 | {
44 | workspace.Open();
45 | }
46 | }
47 |
48 | private void Action_Save(object sender, EventArgs e)
49 | {
50 | using (new LengthyOperation(this))
51 | {
52 | workspace.Save();
53 | }
54 | }
55 |
56 | private void Action_SaveAs(object sender, EventArgs e)
57 | {
58 | using (new LengthyOperation(this))
59 | {
60 | workspace.Save(true);
61 | }
62 | }
63 |
64 | private void Action_Close(object sender, EventArgs e)
65 | {
66 | using (new LengthyOperation(this))
67 | {
68 | workspace.Close();
69 | }
70 | }
71 |
72 | private void Workspace_WorkspaceClosed(object sender, EventArgs e)
73 | {
74 | txtMain.Enabled = false;
75 | txtMain.Text = string.Empty;
76 |
77 | mnuClose.Enabled = false;
78 | mnuSave.Enabled = false;
79 | mnuSaveAs.Enabled = false;
80 | tbtnSave.Enabled = false;
81 | statusLabel.Text = string.Empty;
82 | }
83 |
84 | private void Workspace_WorkspaceSaved(object sender, WorkspaceSavedEventArgs e)
85 | {
86 | mnuSave.Enabled = false;
87 | tbtnSave.Enabled = false;
88 | statusLabel.Text = e.FileName;
89 | }
90 |
91 | private void Workspace_WorkspaceChanged(object sender, EventArgs e)
92 | {
93 | mnuSave.Enabled = true;
94 | tbtnSave.Enabled = true;
95 | }
96 |
97 | private void Workspace_WorkspaceOpened(object sender, WorkspaceOpenedEventArgs e)
98 | {
99 | txtMain.Enabled = true;
100 | txtMain.Text = (e.Model as TextEditorModel).Text;
101 |
102 | mnuSaveAs.Enabled = true;
103 | mnuClose.Enabled = true;
104 | statusLabel.Text = e.FileName;
105 | }
106 |
107 | private void Workspace_WorkspaceCreated(object sender, WorkspaceCreatedEventArgs e)
108 | {
109 | txtMain.Enabled = true;
110 | txtMain.Text = string.Empty;
111 | txtMain.Focus();
112 |
113 | mnuClose.Enabled = true;
114 | mnuSave.Enabled = true;
115 | tbtnSave.Enabled = true;
116 | mnuSaveAs.Enabled = true;
117 | statusLabel.Text = string.Empty;
118 | }
119 |
120 | protected override void OnFormClosing(FormClosingEventArgs e)
121 | {
122 | e.Cancel = !this.workspace.Close();
123 | }
124 |
125 | protected override void OnFormClosed(FormClosedEventArgs e)
126 | {
127 | // Unsubscribe the workspace events.
128 | workspace.WorkspaceCreated -= Workspace_WorkspaceCreated;
129 | workspace.WorkspaceOpened -= Workspace_WorkspaceOpened;
130 | workspace.WorkspaceChanged -= Workspace_WorkspaceChanged;
131 | workspace.WorkspaceSaved -= Workspace_WorkspaceSaved;
132 | workspace.WorkspaceClosed -= Workspace_WorkspaceClosed;
133 | base.OnClosed(e);
134 | }
135 |
136 | private void txtMain_TextChanged(object sender, EventArgs e)
137 | {
138 | (workspace.Model as TextEditorModel).Text = txtMain.Text;
139 | }
140 | }
141 | }
142 |
--------------------------------------------------------------------------------
/examples/workspace/FormsUI.Examples.Workspace/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Threading.Tasks;
5 | using System.Windows.Forms;
6 |
7 | namespace FormsUI.Examples.Workspace
8 | {
9 | static class Program
10 | {
11 | ///
12 | /// The main entry point for the application.
13 | ///
14 | [STAThread]
15 | static void Main()
16 | {
17 | Application.EnableVisualStyles();
18 | Application.SetCompatibleTextRenderingDefault(false);
19 | Application.Run(new FrmMain());
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/examples/workspace/FormsUI.Examples.Workspace/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("FormsUI.Examples.Workspace")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("FormsUI.Examples.Workspace")]
13 | [assembly: AssemblyCopyright("Copyright © 2018")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("6d0b42d6-3c5e-4981-9d88-1740c5942f34")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/examples/workspace/FormsUI.Examples.Workspace/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 | namespace FormsUI.Examples.Workspace.Properties {
12 | using System;
13 |
14 |
15 | ///
16 | /// A strongly-typed resource class, for looking up localized strings, etc.
17 | ///
18 | // This class was auto-generated by the StronglyTypedResourceBuilder
19 | // class via a tool like ResGen or Visual Studio.
20 | // To add or remove a member, edit your .ResX file then rerun ResGen
21 | // with the /str option, or rebuild your VS project.
22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
25 | internal class Resources {
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 | /// Returns the cached ResourceManager instance used by this class.
37 | ///
38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
39 | internal static global::System.Resources.ResourceManager ResourceManager {
40 | get {
41 | if (object.ReferenceEquals(resourceMan, null)) {
42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("FormsUI.Examples.Workspace.Properties.Resources", typeof(Resources).Assembly);
43 | resourceMan = temp;
44 | }
45 | return resourceMan;
46 | }
47 | }
48 |
49 | ///
50 | /// Overrides the current thread's CurrentUICulture property for all
51 | /// resource lookups using this strongly typed resource class.
52 | ///
53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
54 | internal static global::System.Globalization.CultureInfo Culture {
55 | get {
56 | return resourceCulture;
57 | }
58 | set {
59 | resourceCulture = value;
60 | }
61 | }
62 |
63 | ///
64 | /// Looks up a localized resource of type System.Drawing.Bitmap.
65 | ///
66 | internal static System.Drawing.Bitmap CloseDocument_16x {
67 | get {
68 | object obj = ResourceManager.GetObject("CloseDocument_16x", resourceCulture);
69 | return ((System.Drawing.Bitmap)(obj));
70 | }
71 | }
72 |
73 | ///
74 | /// Looks up a localized resource of type System.Drawing.Bitmap.
75 | ///
76 | internal static System.Drawing.Bitmap NewFile_16x {
77 | get {
78 | object obj = ResourceManager.GetObject("NewFile_16x", resourceCulture);
79 | return ((System.Drawing.Bitmap)(obj));
80 | }
81 | }
82 |
83 | ///
84 | /// Looks up a localized resource of type System.Drawing.Bitmap.
85 | ///
86 | internal static System.Drawing.Bitmap OpenFolder_16x {
87 | get {
88 | object obj = ResourceManager.GetObject("OpenFolder_16x", resourceCulture);
89 | return ((System.Drawing.Bitmap)(obj));
90 | }
91 | }
92 |
93 | ///
94 | /// Looks up a localized resource of type System.Drawing.Bitmap.
95 | ///
96 | internal static System.Drawing.Bitmap Save_16x {
97 | get {
98 | object obj = ResourceManager.GetObject("Save_16x", resourceCulture);
99 | return ((System.Drawing.Bitmap)(obj));
100 | }
101 | }
102 |
103 | ///
104 | /// Looks up a localized resource of type System.Drawing.Bitmap.
105 | ///
106 | internal static System.Drawing.Bitmap SaveAs_16x {
107 | get {
108 | object obj = ResourceManager.GetObject("SaveAs_16x", resourceCulture);
109 | return ((System.Drawing.Bitmap)(obj));
110 | }
111 | }
112 | }
113 | }
114 |
--------------------------------------------------------------------------------
/examples/workspace/FormsUI.Examples.Workspace/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 | namespace FormsUI.Examples.Workspace.Properties {
12 |
13 |
14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.1.0.0")]
16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
17 |
18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
19 |
20 | public static Settings Default {
21 | get {
22 | return defaultInstance;
23 | }
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/examples/workspace/FormsUI.Examples.Workspace/Properties/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/examples/workspace/FormsUI.Examples.Workspace/Resources/CloseDocument_16x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/daxnet/forms-ui/6200413a9e81bfdfd6e3113e19cc3da6e607a11b/examples/workspace/FormsUI.Examples.Workspace/Resources/CloseDocument_16x.png
--------------------------------------------------------------------------------
/examples/workspace/FormsUI.Examples.Workspace/Resources/NewFile_16x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/daxnet/forms-ui/6200413a9e81bfdfd6e3113e19cc3da6e607a11b/examples/workspace/FormsUI.Examples.Workspace/Resources/NewFile_16x.png
--------------------------------------------------------------------------------
/examples/workspace/FormsUI.Examples.Workspace/Resources/OpenFolder_16x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/daxnet/forms-ui/6200413a9e81bfdfd6e3113e19cc3da6e607a11b/examples/workspace/FormsUI.Examples.Workspace/Resources/OpenFolder_16x.png
--------------------------------------------------------------------------------
/examples/workspace/FormsUI.Examples.Workspace/Resources/SaveAs_16x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/daxnet/forms-ui/6200413a9e81bfdfd6e3113e19cc3da6e607a11b/examples/workspace/FormsUI.Examples.Workspace/Resources/SaveAs_16x.png
--------------------------------------------------------------------------------
/examples/workspace/FormsUI.Examples.Workspace/Resources/Save_16x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/daxnet/forms-ui/6200413a9e81bfdfd6e3113e19cc3da6e607a11b/examples/workspace/FormsUI.Examples.Workspace/Resources/Save_16x.png
--------------------------------------------------------------------------------
/examples/workspace/FormsUI.Examples.Workspace/TextEditorModel.cs:
--------------------------------------------------------------------------------
1 | using FormsUI.Workspaces;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.ComponentModel;
5 | using System.Linq;
6 | using System.Text;
7 | using System.Threading.Tasks;
8 |
9 | namespace FormsUI.Examples.Workspace
10 | {
11 | public sealed class TextEditorModel : IWorkspaceModel
12 | {
13 | public WorkspaceModelVersion Version { get; set; }
14 |
15 | public TextEditorModel() { }
16 |
17 | public TextEditorModel(string text)
18 | {
19 | this.text = text;
20 | }
21 |
22 | private string text;
23 |
24 | public string Text
25 | {
26 | get => text;
27 | set
28 | {
29 | if (!string.Equals(text, value))
30 | {
31 | text = value;
32 | OnPropertyChanged(nameof(Text));
33 | }
34 | }
35 | }
36 |
37 | private void OnPropertyChanged(string propertyName) => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
38 |
39 | public event PropertyChangedEventHandler PropertyChanged;
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/examples/workspace/FormsUI.Examples.Workspace/TextEditorWorkspace.cs:
--------------------------------------------------------------------------------
1 | using FormsUI.Workspaces;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.IO;
5 | using System.Linq;
6 | using System.Text;
7 | using System.Threading.Tasks;
8 |
9 | namespace FormsUI.Examples.Workspace
10 | {
11 | public sealed class TextEditorWorkspace : Workspaces.Workspace
12 | {
13 | protected override string WorkspaceFileDescription => "Text Files";
14 |
15 | protected override string WorkspaceFileExtension => "txt";
16 |
17 | protected override IWorkspaceModel Create()
18 | {
19 | return new TextEditorModel();
20 | }
21 |
22 | protected override IWorkspaceModel OpenFromFile(string fileName)
23 | {
24 | return new TextEditorModel(File.ReadAllText(fileName));
25 | }
26 |
27 | protected override void SaveToFile(IWorkspaceModel model, string fileName)
28 | {
29 | if (model is TextEditorModel textEditorModel)
30 | {
31 | File.WriteAllText(fileName, textEditorModel.Text);
32 | }
33 | }
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/src/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Reflection;
3 | using System.Runtime.CompilerServices;
4 | using System.Runtime.InteropServices;
5 |
6 | // General Information about an assembly is controlled through the following
7 | // set of attributes. Change these attribute values to modify the information
8 | // associated with an assembly.
9 | [assembly: AssemblyTitle("FormsUI")]
10 | [assembly: AssemblyDescription("A Windows Forms library for solving real life problems.")]
11 | [assembly: AssemblyCompany("daxnet")]
12 | [assembly: AssemblyProduct("FormsUI")]
13 | [assembly: AssemblyCopyright("Copyright © 2018 by daxnet, all rights reserved.")]
14 |
15 | // Setting ComVisible to false makes the types in this assembly not visible
16 | // to COM components. If you need to access a type in this assembly from
17 | // COM, set the ComVisible attribute to true on that type.
18 | [assembly: ComVisible(false)]
19 | [assembly: CLSCompliant(true)]
20 |
21 | // The following GUID is for the ID of the typelib if this project is exposed to COM
22 | [assembly: Guid("6ece3042-da41-4d80-8f80-aa6d2f0a96e2")]
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 |
--------------------------------------------------------------------------------
/src/CodeMaid.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 | Constructors||4||Constructors
12 |
13 |
14 | Methods||8||Methods
15 |
16 |
17 | Properties||6||Properties
18 |
19 |
20 | Enums||9||Enums
21 |
22 |
23 | Destructors||5||Destructors
24 |
25 |
26 | Delegates||2||Delegates
27 |
28 |
29 | Indexers||7||Indexers
30 |
31 |
32 | Interfaces||10||Interfaces
33 |
34 |
35 | Events||3||Events
36 |
37 |
38 | True
39 |
40 |
41 | True
42 |
43 |
44 | True
45 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/src/FormsUI.Tests/FormsUI.Tests.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Debug
7 | AnyCPU
8 | {8CFFDFED-B546-45CB-B041-4EC78DFBD492}
9 | Library
10 | Properties
11 | FormsUI.Tests
12 | FormsUI.Tests
13 | v4.6.1
14 | 512
15 | {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
16 | 15.0
17 | $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)
18 | $(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages
19 | False
20 | UnitTest
21 |
22 |
23 |
24 |
25 | true
26 | full
27 | false
28 | bin\Debug\
29 | DEBUG;TRACE
30 | prompt
31 | 4
32 |
33 |
34 | pdbonly
35 | true
36 | bin\Release\
37 | TRACE
38 | prompt
39 | 4
40 |
41 |
42 |
43 | ..\packages\MSTest.TestFramework.1.3.2\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.dll
44 |
45 |
46 | ..\packages\MSTest.TestFramework.1.3.2\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll
47 |
48 |
49 |
50 |
51 |
52 |
53 | Properties\AssemblyInfo.cs
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 | This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.
65 |
66 |
67 |
68 |
69 |
70 |
--------------------------------------------------------------------------------
/src/FormsUI.Tests/UnitTest1.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Microsoft.VisualStudio.TestTools.UnitTesting;
3 |
4 | namespace FormsUI.Tests
5 | {
6 | [TestClass]
7 | public class UnitTest1
8 | {
9 | [TestMethod]
10 | public void TestMethod1()
11 | {
12 | }
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/src/FormsUI.Tests/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/src/FormsUI.Windows/AppWindow.Designer.cs:
--------------------------------------------------------------------------------
1 | namespace FormsUI.Windows
2 | {
3 | partial class AppWindow
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.components = new System.ComponentModel.Container();
32 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
33 | this.ClientSize = new System.Drawing.Size(800, 450);
34 | this.Text = "AppWindow";
35 | }
36 |
37 | #endregion
38 | }
39 | }
--------------------------------------------------------------------------------
/src/FormsUI.Windows/DockableWindow.Designer.cs:
--------------------------------------------------------------------------------
1 | namespace FormsUI.Windows
2 | {
3 | partial class DockableWindow
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.components = new System.ComponentModel.Container();
32 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
33 | this.ClientSize = new System.Drawing.Size(800, 450);
34 | this.Text = "BaseWindow";
35 | }
36 |
37 | #endregion
38 | }
39 | }
--------------------------------------------------------------------------------
/src/FormsUI.Windows/DockableWindow.cs:
--------------------------------------------------------------------------------
1 | using FormsUI.Workspaces;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.ComponentModel;
5 | using System.Data;
6 | using System.Drawing;
7 | using System.Linq;
8 | using System.Text;
9 | using System.Threading.Tasks;
10 | using System.Windows.Forms;
11 | using WeifenLuo.WinFormsUI.Docking;
12 |
13 | namespace FormsUI.Windows
14 | {
15 | public partial class DockableWindow : DockContent
16 | {
17 | #region Public Events
18 |
19 | public event EventHandler DockWindowHidden;
20 |
21 | public event EventHandler DockWindowShown;
22 |
23 | #endregion Public Events
24 |
25 | #region Protected Constructors
26 |
27 | protected DockableWindow(IAppWindow appWindow, bool hideOnClose = true)
28 | : this()
29 | {
30 | HideOnClose = hideOnClose;
31 | AppWindow = appWindow;
32 |
33 | if (AppWindow.Workspace != null)
34 | {
35 | AppWindow.Workspace.WorkspaceChanged += OnWorkspaceChanged;
36 | AppWindow.Workspace.WorkspaceClosed += OnWorkspaceClosed;
37 | AppWindow.Workspace.WorkspaceCreated += OnWorkspaceCreated;
38 | AppWindow.Workspace.WorkspaceOpened += OnWorkspaceOpened;
39 | AppWindow.Workspace.WorkspaceSaved += OnWorkspaceSaved;
40 | AppWindow.Workspace.WorkspaceStateChanged += OnWorkspaceStateChanged;
41 | }
42 | }
43 |
44 | #endregion Protected Constructors
45 |
46 | #region Private Constructors
47 |
48 | protected DockableWindow()
49 | {
50 | InitializeComponent();
51 | }
52 |
53 | #endregion Private Constructors
54 |
55 | #region Protected Properties
56 |
57 | protected IAppWindow AppWindow { get; }
58 |
59 | #endregion Protected Properties
60 |
61 | #region Public Methods
62 |
63 | public override string ToString() => Text;
64 |
65 | #endregion Public Methods
66 |
67 | #region Protected Methods
68 |
69 | protected override void OnFormClosed(FormClosedEventArgs e)
70 | {
71 | if (!HideOnClose)
72 | {
73 | Cleanup();
74 | }
75 |
76 | base.OnFormClosed(e);
77 | }
78 |
79 | protected override void OnDockStateChanged(EventArgs e)
80 | {
81 | switch (DockState)
82 | {
83 | case DockState.Hidden:
84 | this.OnDockWindowHidden(e);
85 | break;
86 | case DockState.Unknown:
87 | break;
88 | default:
89 | this.OnDockWindowShown(e);
90 | break;
91 | }
92 | }
93 |
94 | protected virtual void OnDockWindowHidden(EventArgs e)
95 | {
96 | DockWindowHidden?.Invoke(this, e);
97 | }
98 |
99 | protected virtual void OnDockWindowShown(EventArgs e)
100 | {
101 | DockWindowShown?.Invoke(this, e);
102 | }
103 |
104 | internal protected virtual void Cleanup()
105 | {
106 | if (AppWindow.Workspace != null)
107 | {
108 | AppWindow.Workspace.WorkspaceChanged -= OnWorkspaceChanged;
109 | AppWindow.Workspace.WorkspaceClosed -= OnWorkspaceClosed;
110 | AppWindow.Workspace.WorkspaceCreated -= OnWorkspaceCreated;
111 | AppWindow.Workspace.WorkspaceOpened -= OnWorkspaceOpened;
112 | AppWindow.Workspace.WorkspaceSaved -= OnWorkspaceSaved;
113 | AppWindow.Workspace.WorkspaceStateChanged -= OnWorkspaceStateChanged;
114 | }
115 | }
116 |
117 | protected virtual void OnWorkspaceChanged(object sender, EventArgs e) { }
118 |
119 | protected virtual void OnWorkspaceClosed(object sender, EventArgs e) { }
120 |
121 | protected virtual void OnWorkspaceCreated(object sender, WorkspaceCreatedEventArgs e) { }
122 |
123 | protected virtual void OnWorkspaceOpened(object sender, WorkspaceOpenedEventArgs e) { }
124 |
125 | protected virtual void OnWorkspaceSaved(object sender, WorkspaceSavedEventArgs e) { }
126 |
127 | protected virtual void OnWorkspaceStateChanged(object sender, WorkspaceStateChangedEventArgs e) { }
128 |
129 | #endregion Protected Methods
130 | }
131 | }
132 |
--------------------------------------------------------------------------------
/src/FormsUI.Windows/DockableWindowEventArgs.cs:
--------------------------------------------------------------------------------
1 | using FormsUI.Workspaces;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace FormsUI.Windows
9 | {
10 | ///
11 | /// Represents the base class of the event data that holds an instance
12 | /// of a dockable window.
13 | ///
14 | public abstract class DockableWindowEventArgs
15 | {
16 | ///
17 | /// Initializes a new instance of the class.
18 | ///
19 | /// The dockable window.
20 | protected DockableWindowEventArgs(DockableWindow dockableWindow)
21 | {
22 | DockableWindow = dockableWindow;
23 | }
24 |
25 | ///
26 | /// Gets the instance of the dockable window.
27 | ///
28 | ///
29 | /// The dockable window.
30 | ///
31 | public DockableWindow DockableWindow { get; }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/src/FormsUI.Windows/DockableWindowHiddenEventArgs.cs:
--------------------------------------------------------------------------------
1 | using FormsUI.Workspaces;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace FormsUI.Windows
9 | {
10 | public sealed class DockableWindowHiddenEventArgs : DockableWindowEventArgs
11 | {
12 | public DockableWindowHiddenEventArgs(DockableWindow dockableWindow) : base(dockableWindow)
13 | {
14 | }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/src/FormsUI.Windows/DockableWindowShownEventArgs.cs:
--------------------------------------------------------------------------------
1 | using FormsUI.Workspaces;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace FormsUI.Windows
9 | {
10 | public sealed class DockableWindowShownEventArgs : DockableWindowEventArgs
11 | {
12 | public DockableWindowShownEventArgs(DockableWindow dockableWindow) : base(dockableWindow)
13 | {
14 | }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/src/FormsUI.Windows/DocumentWindow.Designer.cs:
--------------------------------------------------------------------------------
1 | namespace FormsUI.Windows
2 | {
3 | partial class DocumentWindow
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.components = new System.ComponentModel.Container();
32 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
33 | this.ClientSize = new System.Drawing.Size(800, 450);
34 | this.Text = "DocumentWindow";
35 | }
36 |
37 | #endregion
38 | }
39 | }
--------------------------------------------------------------------------------
/src/FormsUI.Windows/DocumentWindow.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Data;
5 | using System.Drawing;
6 | using System.Linq;
7 | using System.Text;
8 | using System.Threading.Tasks;
9 | using System.Windows.Forms;
10 |
11 | namespace FormsUI.Windows
12 | {
13 | public partial class DocumentWindow : DockableWindow
14 | {
15 | public DocumentWindow(IAppWindow appWindow)
16 | : base(appWindow, false)
17 | {
18 | InitializeComponent();
19 | }
20 |
21 | protected DocumentWindow()
22 | {
23 | InitializeComponent();
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/FormsUI.Windows/FormsUI.Windows.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {D910E12B-0973-4CBB-8C29-8FBD77AB239F}
8 | Library
9 | Properties
10 | FormsUI.Windows
11 | FormsUI.Windows
12 | v4.7.2
13 | 512
14 | true
15 |
16 |
17 |
18 | true
19 | full
20 | false
21 | bin\Debug\
22 | DEBUG;TRACE
23 | prompt
24 | 4
25 |
26 |
27 | pdbonly
28 | true
29 | bin\Release\
30 | TRACE
31 | prompt
32 | 4
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 | ..\..\..\ide\packages\DockPanelSuite.3.0.6\lib\net40\WeifenLuo.WinFormsUI.Docking.dll
47 |
48 |
49 |
50 |
51 | Form
52 |
53 |
54 | AppWindow.cs
55 |
56 |
57 | Form
58 |
59 |
60 | DockableWindow.cs
61 |
62 |
63 |
64 |
65 |
66 | Form
67 |
68 |
69 | DocumentWindow.cs
70 |
71 |
72 |
73 |
74 |
75 | Component
76 |
77 |
78 | Component
79 |
80 |
81 |
82 | Component
83 |
84 |
85 | Form
86 |
87 |
88 | ToolWindow.cs
89 |
90 |
91 |
92 |
93 |
94 | {6ece3042-da41-4d80-8f80-aa6d2f0a96e2}
95 | FormsUI
96 |
97 |
98 |
99 |
100 |
101 |
102 |
--------------------------------------------------------------------------------
/src/FormsUI.Windows/IAppWindow.cs:
--------------------------------------------------------------------------------
1 | using FormsUI.Workspaces;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 | using WeifenLuo.WinFormsUI.Docking;
8 |
9 | namespace FormsUI.Windows
10 | {
11 | ///
12 | /// Represents that the implemented classes are application windows.
13 | /// An application window is a window instance which manages workspaces.
14 | /// Usually a Windows Forms application will have only one IAppWindow
15 | /// instance.
16 | ///
17 | /// The type of the workspace model.
18 | public interface IAppWindow
19 | {
20 | Workspace Workspace { get; }
21 |
22 | DockableWindowManager WindowManager { get; }
23 |
24 | DockPanel DockArea { get; }
25 |
26 | void MergeTools(WindowTools tools);
27 |
28 | void RevertMerge(WindowTools tools);
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/FormsUI.Windows/MenuStripMerge.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using System.Windows.Forms;
7 |
8 | namespace FormsUI.Windows
9 | {
10 | public sealed class MenuStripMerge
11 | {
12 | ///
13 | /// Initializes a new instance of MenuStripMerge class.
14 | ///
15 | /// The menu strip to be merged into main menu.
16 | /// The position in the main menu where the menu strip should be merged.
17 | public MenuStripMerge(ContextMenuStrip menuStrip, string targetName)
18 | : this(menuStrip, targetName, true) { }
19 |
20 | ///
21 | /// Initializes a new instance of MenuStripMerge class.
22 | ///
23 | /// The menu strip to be merged into main menu.
24 | /// The position in the main menu where the menu strip should be merged.
25 | /// A value which indicates whether the menu strip should be hidden when
26 | /// the hosting window is hidden.
27 | public MenuStripMerge(ContextMenuStrip menuStrip, string targetName, bool needHide)
28 | {
29 | MenuStrip = menuStrip;
30 | TargetName = targetName;
31 | NeedHide = needHide;
32 | }
33 |
34 | public string TargetName { get; }
35 |
36 | public ContextMenuStrip MenuStrip { get; }
37 |
38 | public bool NeedHide { get; }
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/src/FormsUI.Windows/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Reflection;
3 | using System.Runtime.CompilerServices;
4 | using System.Runtime.InteropServices;
5 |
6 | // General Information about an assembly is controlled through the following
7 | // set of attributes. Change these attribute values to modify the information
8 | // associated with an assembly.
9 | [assembly: AssemblyTitle("FormsUI.Windows")]
10 | [assembly: AssemblyDescription("")]
11 | [assembly: AssemblyConfiguration("")]
12 | [assembly: AssemblyCompany("")]
13 | [assembly: AssemblyProduct("FormsUI.Windows")]
14 | [assembly: AssemblyCopyright("Copyright © 2019")]
15 | [assembly: AssemblyTrademark("")]
16 | [assembly: AssemblyCulture("")]
17 |
18 | // Setting ComVisible to false makes the types in this assembly not visible
19 | // to COM components. If you need to access a type in this assembly from
20 | // COM, set the ComVisible attribute to true on that type.
21 | [assembly: ComVisible(false)]
22 | [assembly: CLSCompliant(true)]
23 |
24 | // The following GUID is for the ID of the typelib if this project is exposed to COM
25 | [assembly: Guid("d910e12b-0973-4cbb-8c29-8fbd77ab239f")]
26 |
27 | // Version information for an assembly consists of the following four values:
28 | //
29 | // Major Version
30 | // Minor Version
31 | // Build Number
32 | // Revision
33 | //
34 | // You can specify all the values or you can default the Build and Revision Numbers
35 | // by using the '*' as shown below:
36 | // [assembly: AssemblyVersion("1.0.*")]
37 | [assembly: AssemblyVersion("1.0.0.0")]
38 | [assembly: AssemblyFileVersion("1.0.0.0")]
39 |
--------------------------------------------------------------------------------
/src/FormsUI.Windows/ToolActionManager.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using System.Windows.Forms;
7 |
8 | namespace FormsUI.Windows
9 | {
10 | public sealed class ToolActionManager : ComponentManager
11 | {
12 | public ToolActionManager() { }
13 |
14 | public ToolActionManager(IEnumerable toolActions)
15 | : base(toolActions)
16 | { }
17 |
18 | public ToolAction this[string id] => Get(id);
19 |
20 | public ToolAction Get(string id)
21 | {
22 | if (string.IsNullOrEmpty(id))
23 | {
24 | throw new ArgumentNullException(nameof(id));
25 | }
26 |
27 | var toolAction = components.FirstOrDefault(c => string.Equals(c.Id, id));
28 | if (toolAction == null)
29 | {
30 | throw new InvalidOperationException("The action component has not been defined.");
31 | }
32 |
33 | return toolAction;
34 | }
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/src/FormsUI.Windows/ToolStripMerge.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using System.Windows.Forms;
7 |
8 | namespace FormsUI.Windows
9 | {
10 | ///
11 | /// Represents the tool strip merging strategy.
12 | ///
13 | public class ToolStripMerge
14 | {
15 | ///
16 | /// Initializes a new instance of the ToolStripMerge class.
17 | ///
18 | /// The to be merged into the main window.
19 | public ToolStripMerge(ToolStrip toolStrip)
20 | : this(null, toolStrip, true)
21 | { }
22 |
23 | ///
24 | /// Initializes a new instance of the ToolStripMerge class.
25 | ///
26 | /// The name of the target tool strip to which the current tool strip will be merged.
27 | /// The to be merged into the main window.
28 | /// A value which indicates whether the merged tool strip should
29 | /// be hidden when the window that contains this merged tool strip is hidden.
30 | public ToolStripMerge(string targetToolStripName, ToolStrip toolStrip, bool needHide)
31 | {
32 | TargetToolStripName = targetToolStripName;
33 | ToolStrip = toolStrip;
34 | NeedHide = needHide;
35 | }
36 |
37 | public ToolStripMerge(ToolStrip toolStrip, bool needHide)
38 | : this(null, toolStrip, needHide)
39 | { }
40 |
41 | ///
42 | /// Gets a value which indicates whether the merged tool strip should
43 | /// be hidden when the window that contains this merged tool strip is hidden.
44 | ///
45 | public bool NeedHide { get; }
46 |
47 | ///
48 | /// Gets the instance that is to be merged into the main window.
49 | ///
50 | public ToolStrip ToolStrip { get; }
51 |
52 | ///
53 | /// Gets the name of the target tool strip to which the current tool strip will be merged.
54 | ///
55 | ///
56 | /// The name of the target tool strip.
57 | ///
58 | public string TargetToolStripName { get; }
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/src/FormsUI.Windows/ToolWindow.Designer.cs:
--------------------------------------------------------------------------------
1 | namespace FormsUI.Windows
2 | {
3 | partial class ToolWindow
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.components = new System.ComponentModel.Container();
32 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
33 | this.ClientSize = new System.Drawing.Size(800, 450);
34 | this.Text = "ToolWindow";
35 | }
36 |
37 | #endregion
38 | }
39 | }
--------------------------------------------------------------------------------
/src/FormsUI.Windows/ToolWindow.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Data;
5 | using System.Drawing;
6 | using System.Linq;
7 | using System.Text;
8 | using System.Threading.Tasks;
9 | using System.Windows.Forms;
10 |
11 | namespace FormsUI.Windows
12 | {
13 | public partial class ToolWindow : DockableWindow
14 | {
15 | public ToolWindow(IAppWindow appWindow)
16 | : base(appWindow)
17 | {
18 | InitializeComponent();
19 | }
20 |
21 | protected ToolWindow()
22 | {
23 | InitializeComponent();
24 | }
25 |
26 | protected virtual WindowTools WindowTools => null;
27 |
28 | protected override void OnDockWindowHidden(EventArgs e)
29 | {
30 | base.OnDockWindowHidden(e);
31 | if (!(WindowTools?.IsEmpty ?? true))
32 | {
33 | AppWindow.RevertMerge(WindowTools);
34 | }
35 | }
36 |
37 | protected override void OnDockWindowShown(EventArgs e)
38 | {
39 | base.OnDockWindowShown(e);
40 | if (!(WindowTools?.IsEmpty ?? true))
41 | {
42 | AppWindow.MergeTools(WindowTools);
43 | }
44 | }
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/src/FormsUI.Windows/WindowTools.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace FormsUI.Windows
8 | {
9 | public sealed class WindowTools
10 | {
11 | public static readonly WindowTools Empty = new WindowTools();
12 |
13 | private readonly List mergingMenus = new List();
14 |
15 | private WindowTools() { }
16 |
17 | public WindowTools(ToolStripMerge mergingToolbar)
18 | {
19 | this.MergingToolbar = mergingToolbar;
20 | }
21 |
22 | public WindowTools(ToolStripMerge mergingToolbar, IEnumerable mergingMenus)
23 | : this(mergingToolbar)
24 | {
25 | this.mergingMenus.AddRange(mergingMenus);
26 | }
27 |
28 | public ToolStripMerge MergingToolbar { get; }
29 |
30 | public IEnumerable MergingMenus => mergingMenus;
31 |
32 | public bool IsEmpty => MergingToolbar == null && mergingMenus?.Count == 0;
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/src/FormsUI.Windows/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/src/FormsUI.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.29001.49
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FormsUI", "FormsUI\FormsUI.csproj", "{6ECE3042-DA41-4D80-8F80-AA6D2F0A96E2}"
7 | EndProject
8 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "examples", "examples", "{98E5E2EE-3E1E-4666-A018-CEF88039BBA0}"
9 | EndProject
10 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{CC418E18-F4CD-4958-B433-4292A0CF1B2F}"
11 | EndProject
12 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FormsUI.Tests", "FormsUI.Tests\FormsUI.Tests.csproj", "{8CFFDFED-B546-45CB-B041-4EC78DFBD492}"
13 | EndProject
14 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "extensions", "extensions", "{89213ED7-AB78-4E7C-AC5E-C594E31A3A91}"
15 | EndProject
16 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workspace", "workspace", "{5014E1F0-9D76-4386-9DF8-20427FE53233}"
17 | EndProject
18 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FormsUI.Examples.Workspace", "..\examples\workspace\FormsUI.Examples.Workspace\FormsUI.Examples.Workspace.csproj", "{6D0B42D6-3C5E-4981-9D88-1740C5942F34}"
19 | EndProject
20 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "wizard", "wizard", "{0FF07C08-B92A-4EA2-99AB-DE738EC32EB3}"
21 | EndProject
22 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FormsUI.Examples.Wizard", "..\examples\wizard\FormsUI.Examples.Wizard\FormsUI.Examples.Wizard.csproj", "{68BF6FF1-5C49-4F56-AC57-8F3A39A1AD2D}"
23 | EndProject
24 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FormsUI.Windows", "FormsUI.Windows\FormsUI.Windows.csproj", "{D910E12B-0973-4CBB-8C29-8FBD77AB239F}"
25 | EndProject
26 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "dockable-windows", "dockable-windows", "{84E85D20-DC59-4725-8CF7-3088F0686B8F}"
27 | EndProject
28 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FormsUI.Examples.DockableWindows", "..\examples\dockable-windows\FormsUI.Examples.DockableWindows\FormsUI.Examples.DockableWindows.csproj", "{C8845261-04E3-4A2C-8E15-F5D65432A7BC}"
29 | EndProject
30 | Global
31 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
32 | Debug|Any CPU = Debug|Any CPU
33 | Release|Any CPU = Release|Any CPU
34 | EndGlobalSection
35 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
36 | {6ECE3042-DA41-4D80-8F80-AA6D2F0A96E2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
37 | {6ECE3042-DA41-4D80-8F80-AA6D2F0A96E2}.Debug|Any CPU.Build.0 = Debug|Any CPU
38 | {6ECE3042-DA41-4D80-8F80-AA6D2F0A96E2}.Release|Any CPU.ActiveCfg = Release|Any CPU
39 | {6ECE3042-DA41-4D80-8F80-AA6D2F0A96E2}.Release|Any CPU.Build.0 = Release|Any CPU
40 | {8CFFDFED-B546-45CB-B041-4EC78DFBD492}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
41 | {8CFFDFED-B546-45CB-B041-4EC78DFBD492}.Debug|Any CPU.Build.0 = Debug|Any CPU
42 | {8CFFDFED-B546-45CB-B041-4EC78DFBD492}.Release|Any CPU.ActiveCfg = Release|Any CPU
43 | {8CFFDFED-B546-45CB-B041-4EC78DFBD492}.Release|Any CPU.Build.0 = Release|Any CPU
44 | {6D0B42D6-3C5E-4981-9D88-1740C5942F34}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
45 | {6D0B42D6-3C5E-4981-9D88-1740C5942F34}.Debug|Any CPU.Build.0 = Debug|Any CPU
46 | {6D0B42D6-3C5E-4981-9D88-1740C5942F34}.Release|Any CPU.ActiveCfg = Release|Any CPU
47 | {6D0B42D6-3C5E-4981-9D88-1740C5942F34}.Release|Any CPU.Build.0 = Release|Any CPU
48 | {68BF6FF1-5C49-4F56-AC57-8F3A39A1AD2D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
49 | {68BF6FF1-5C49-4F56-AC57-8F3A39A1AD2D}.Debug|Any CPU.Build.0 = Debug|Any CPU
50 | {68BF6FF1-5C49-4F56-AC57-8F3A39A1AD2D}.Release|Any CPU.ActiveCfg = Release|Any CPU
51 | {68BF6FF1-5C49-4F56-AC57-8F3A39A1AD2D}.Release|Any CPU.Build.0 = Release|Any CPU
52 | {D910E12B-0973-4CBB-8C29-8FBD77AB239F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
53 | {D910E12B-0973-4CBB-8C29-8FBD77AB239F}.Debug|Any CPU.Build.0 = Debug|Any CPU
54 | {D910E12B-0973-4CBB-8C29-8FBD77AB239F}.Release|Any CPU.ActiveCfg = Release|Any CPU
55 | {D910E12B-0973-4CBB-8C29-8FBD77AB239F}.Release|Any CPU.Build.0 = Release|Any CPU
56 | {C8845261-04E3-4A2C-8E15-F5D65432A7BC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
57 | {C8845261-04E3-4A2C-8E15-F5D65432A7BC}.Debug|Any CPU.Build.0 = Debug|Any CPU
58 | {C8845261-04E3-4A2C-8E15-F5D65432A7BC}.Release|Any CPU.ActiveCfg = Release|Any CPU
59 | {C8845261-04E3-4A2C-8E15-F5D65432A7BC}.Release|Any CPU.Build.0 = Release|Any CPU
60 | EndGlobalSection
61 | GlobalSection(SolutionProperties) = preSolution
62 | HideSolutionNode = FALSE
63 | EndGlobalSection
64 | GlobalSection(NestedProjects) = preSolution
65 | {8CFFDFED-B546-45CB-B041-4EC78DFBD492} = {CC418E18-F4CD-4958-B433-4292A0CF1B2F}
66 | {89213ED7-AB78-4E7C-AC5E-C594E31A3A91} = {98E5E2EE-3E1E-4666-A018-CEF88039BBA0}
67 | {5014E1F0-9D76-4386-9DF8-20427FE53233} = {98E5E2EE-3E1E-4666-A018-CEF88039BBA0}
68 | {6D0B42D6-3C5E-4981-9D88-1740C5942F34} = {5014E1F0-9D76-4386-9DF8-20427FE53233}
69 | {0FF07C08-B92A-4EA2-99AB-DE738EC32EB3} = {98E5E2EE-3E1E-4666-A018-CEF88039BBA0}
70 | {68BF6FF1-5C49-4F56-AC57-8F3A39A1AD2D} = {0FF07C08-B92A-4EA2-99AB-DE738EC32EB3}
71 | {84E85D20-DC59-4725-8CF7-3088F0686B8F} = {98E5E2EE-3E1E-4666-A018-CEF88039BBA0}
72 | {C8845261-04E3-4A2C-8E15-F5D65432A7BC} = {84E85D20-DC59-4725-8CF7-3088F0686B8F}
73 | EndGlobalSection
74 | GlobalSection(ExtensibilityGlobals) = postSolution
75 | SolutionGuid = {5D71F081-926C-41AC-A1AE-A8C702C7523C}
76 | EndGlobalSection
77 | EndGlobal
78 |
--------------------------------------------------------------------------------
/src/FormsUI/ComponentManager.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections;
3 | using System.Collections.Generic;
4 | using System.ComponentModel;
5 | using System.Linq;
6 | using System.Text;
7 | using System.Threading.Tasks;
8 |
9 | namespace FormsUI
10 | {
11 | ///
12 | /// Represents the component managers that manage component lifetime.
13 | ///
14 | /// The type of the component.
15 | public abstract class ComponentManager : Component, ICollection
16 | where TComponent : class, IComponent
17 | {
18 | #region Protected Fields
19 |
20 | protected readonly List components = new List();
21 |
22 | #endregion Protected Fields
23 |
24 | #region Private Fields
25 |
26 | private bool disposed = false;
27 |
28 | #endregion Private Fields
29 |
30 | #region Protected Constructors
31 |
32 | protected ComponentManager() { }
33 |
34 | protected ComponentManager(IEnumerable components) => this.components.AddRange(components);
35 |
36 | #endregion Protected Constructors
37 |
38 | #region Public Properties
39 |
40 | public int Count => components.Count;
41 |
42 | public bool IsReadOnly => false;
43 |
44 | #endregion Public Properties
45 |
46 | #region Public Methods
47 |
48 | public void Add(TComponent item) => components.Add(item);
49 |
50 | public void Clear() => components.Clear();
51 |
52 | public bool Contains(TComponent item) => components.Contains(item);
53 |
54 | public void CopyTo(TComponent[] array, int arrayIndex) => components.CopyTo(array, arrayIndex);
55 |
56 | public IEnumerator GetEnumerator() => components.GetEnumerator();
57 |
58 | IEnumerator IEnumerable.GetEnumerator() => components.GetEnumerator();
59 |
60 | public bool Remove(TComponent item) => components.Remove(item);
61 |
62 | #endregion Public Methods
63 |
64 | #region Protected Methods
65 |
66 | protected override void Dispose(bool disposing)
67 | {
68 | if (!disposed)
69 | {
70 | if (disposing)
71 | {
72 | foreach (var item in components)
73 | {
74 | item.Dispose();
75 | }
76 |
77 | components.Clear();
78 | }
79 |
80 | disposed = true;
81 | }
82 | }
83 |
84 | #endregion Protected Methods
85 |
86 | }
87 | }
88 |
--------------------------------------------------------------------------------
/src/FormsUI/Controls/TextBoxEx.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 | using System.Windows.Forms;
8 |
9 | namespace FormsUI.Controls
10 | {
11 | public class TextBoxEx : TextBox
12 | {
13 |
14 | public event EventHandler ShowCueChanged;
15 |
16 | private bool showCue;
17 |
18 | [Category("Appearance")]
19 | [Description("Specifies whether the cue text (watermark) should be shown on the text box.")]
20 | public bool ShowCue
21 | {
22 | get
23 | {
24 | return showCue;
25 | }
26 | set
27 | {
28 | if (showCue != value)
29 | {
30 | showCue = value;
31 | OnShowCueChanged(EventArgs.Empty);
32 | }
33 | }
34 | }
35 |
36 | private string cue;
37 |
38 |
39 | protected virtual void OnShowCueChanged(EventArgs e)
40 | {
41 | ShowCueChanged?.Invoke(this, e);
42 | }
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/src/FormsUI/Disposer.cs:
--------------------------------------------------------------------------------
1 |
2 | using System;
3 | using System.ComponentModel;
4 |
5 | namespace FormsUI
6 | {
7 | ///
8 | /// Represents a component which can be responsible for disposing non-component objects during
9 | /// its dispose phase.
10 | ///
11 | public sealed class Disposer : Component
12 | {
13 | #region Private Fields
14 |
15 | private readonly Action disposeDelegation;
16 |
17 | #endregion Private Fields
18 |
19 | #region Public Constructors
20 |
21 | ///
22 | /// Initializes a new instance of the class.
23 | ///
24 | /// The dispose delegation.
25 | public Disposer(Action disposeDelegation)
26 | {
27 | this.disposeDelegation = disposeDelegation;
28 | }
29 |
30 | #endregion Public Constructors
31 |
32 | #region Protected Methods
33 |
34 | ///
35 | /// Releases the unmanaged resources used by the and optionally releases the managed resources.
37 | ///
38 | ///
39 | /// true to release both managed and unmanaged resources; false to release only unmanaged resources.
40 | ///
41 | protected override void Dispose(bool disposing)
42 | {
43 | base.Dispose(disposing);
44 | this.disposeDelegation(disposing);
45 | }
46 |
47 | #endregion Protected Methods
48 | }
49 | }
--------------------------------------------------------------------------------
/src/FormsUI/Extensions/ExtensionAttribute.cs:
--------------------------------------------------------------------------------
1 |
2 | using System;
3 |
4 | namespace FormsUI.Extensions
5 | {
6 | ///
7 | /// Represents that the decorated classes are extensions.
8 | ///
9 | [AttributeUsage(AttributeTargets.Class, AllowMultiple=false, Inherited=false)]
10 | public sealed class ExtensionAttribute : Attribute
11 | {
12 |
13 | #region Public Constructors
14 |
15 | ///
16 | /// Initializes a new instance of the class.
17 | ///
18 | /// The unique identifier of the extension.
19 | /// The name of the extension.
20 | public ExtensionAttribute(string id, string name)
21 | {
22 | this.Id = new Guid(id);
23 | this.Name = name;
24 | }
25 |
26 | ///
27 | /// Initializes a new instance of the class.
28 | ///
29 | /// The unique identifier of the extension.
30 | /// The name of the extension.
31 | /// Type of the provider which provides the settings capability for the decorated extension.
32 | public ExtensionAttribute(string id, string name, Type settingProviderType)
33 | : this(id, name)
34 | {
35 | this.SettingProviderType = settingProviderType;
36 | }
37 |
38 | #endregion Public Constructors
39 |
40 | #region Public Properties
41 |
42 | ///
43 | /// Gets the unique identifier of the decorated extension.
44 | ///
45 | ///
46 | /// The unique identifier of the decorated extension.
47 | ///
48 | public Guid Id { get; }
49 |
50 | ///
51 | /// Gets the name of the decorated extension.
52 | ///
53 | ///
54 | /// The name of the decorated extension.
55 | ///
56 | public string Name { get; }
57 |
58 | ///
59 | /// Gets the type of the provider which provides the settings capability for the decorated extension.
60 | ///
61 | ///
62 | /// The type of the setting provider.
63 | ///
64 | public Type SettingProviderType { get; }
65 |
66 | #endregion Public Properties
67 |
68 | #region Public Methods
69 |
70 | ///
71 | /// Returns a that represents this instance.
72 | ///
73 | ///
74 | /// A that represents this instance.
75 | ///
76 | public override string ToString()
77 | {
78 | return this.Id.ToString();
79 | }
80 |
81 | #endregion Public Methods
82 |
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/src/FormsUI/Extensions/ExtensionException.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace FormsUI.Extensions
8 | {
9 | public sealed class ExtensionException : Exception
10 | {
11 | public ExtensionException(string message)
12 | : base(message) { }
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/src/FormsUI/Extensions/ExtensionLoadEventArgs.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace FormsUI.Extensions
4 | {
5 | ///
6 | /// Represents the class that carries the event data when the extension is being loading or has
7 | /// been loaded.
8 | ///
9 | internal sealed class ExtensionLoadEventArgs : EventArgs
10 | {
11 | #region Ctor
12 | ///
13 | /// Initializes a new instance of the class.
14 | ///
15 | public ExtensionLoadEventArgs() { }
16 |
17 | ///
18 | /// Initializes a new instance of the class.
19 | ///
20 | /// Name of the extension.
21 | public ExtensionLoadEventArgs(string extensionName)
22 | {
23 | this.ExtensionName = extensionName;
24 | }
25 | #endregion
26 |
27 | #region Public Properties
28 | ///
29 | /// Gets or sets the name of the extension.
30 | ///
31 | ///
32 | /// The name of the extension.
33 | ///
34 | public string ExtensionName { get; set; }
35 | #endregion
36 |
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/src/FormsUI/Extensions/ExtensionManager.cs:
--------------------------------------------------------------------------------
1 |
2 | using System;
3 | using System.Collections.Generic;
4 | using System.IO;
5 | using System.Linq;
6 | using System.Reflection;
7 | using System.Windows.Forms;
8 |
9 | namespace FormsUI.Extensions
10 | {
11 | ///
12 | /// Represents the Extension Manager that registers and manages the extensions.
13 | ///
14 | public sealed class ExtensionManager : ExternalResourceManager
15 | {
16 | private const string ExtensionsFolder = "extensions";
17 |
18 | #region Public Constructors
19 |
20 | ///
21 | /// Initializes a new instance of the class.
22 | ///
23 | /// The path which contains the extension assemblies.
24 | public ExtensionManager(string path)
25 | : base(path, "*.dll")
26 | {
27 |
28 | }
29 |
30 | ///
31 | /// Initializes a new instance of the class.
32 | ///
33 | /// The boolean value indicates whether the searching of the extensions should
34 | /// be based on the extensions sub folder.
35 | public ExtensionManager(bool searchFromExtensionsFolder = true)
36 | : this(searchFromExtensionsFolder ? Path.Combine(Application.StartupPath, ExtensionsFolder) : Application.StartupPath)
37 | {
38 |
39 | }
40 |
41 | #endregion Public Constructors
42 |
43 | #region Public Properties
44 |
45 | ///
46 | /// Gets all of the registered extensions.
47 | ///
48 | ///
49 | /// All extensions.
50 | ///
51 | public IEnumerable> AllExtensions
52 | {
53 | get
54 | {
55 | return this.Resources;
56 | }
57 | }
58 |
59 | #endregion Public Properties
60 |
61 | #region Public Methods
62 |
63 | ///
64 | /// Gets all the registered extensions with the specified extension type.
65 | ///
66 | /// The type of the extension to be retrieved
67 | /// A list of registered extensions that have the same type.
68 | public IEnumerable GetExtensions()
69 | where TExtension : Extension => Resources.Values.Where(t => t.GetType().IsSubclassOf(typeof(TExtension))).Select(p => (TExtension)p);
70 |
71 | #endregion Public Methods
72 |
73 | #region Protected Methods
74 |
75 | ///
76 | /// Loads the resources from the given file.
77 | ///
78 | /// The name of the file from which the resources are loaded.
79 | /// A list of loaded extensions.
80 | protected override IEnumerable LoadResources(string fileName)
81 | {
82 | var assembly = Assembly.LoadFile(fileName);
83 | var result = new List();
84 | foreach (var type in assembly.GetExportedTypes())
85 | {
86 | if (type.IsDefined(typeof (ExtensionAttribute)) &&
87 | type.IsSubclassOf(typeof (Extension)))
88 | {
89 | try
90 | {
91 | var extensionLoaded = (Extension) Activator.CreateInstance(type);
92 | this.OnResourceLoaded(extensionLoaded);
93 | result.Add(extensionLoaded);
94 | }
95 | catch
96 | {
97 | }
98 | }
99 | }
100 | return result;
101 | }
102 |
103 | #endregion Protected Methods
104 | }
105 | }
106 |
--------------------------------------------------------------------------------
/src/FormsUI/Extensions/ExternalResourceLoadEventArgs.cs:
--------------------------------------------------------------------------------
1 |
2 | using System;
3 |
4 | namespace FormsUI.Extensions
5 | {
6 | ///
7 | /// Represents the object that carries the data of resource loaded event.
8 | ///
9 | /// The type of the resource.
10 | public sealed class ExternalResourceLoadEventArgs : EventArgs
11 | where TResource : class, IResource
12 | {
13 | #region Ctor
14 |
15 | ///
16 | /// Initializes a new instance of the class.
17 | ///
18 | public ExternalResourceLoadEventArgs()
19 | {
20 | }
21 |
22 | ///
23 | /// Initializes a new instance of the class.
24 | ///
25 | /// The resource.
26 | public ExternalResourceLoadEventArgs(TResource resource)
27 | {
28 | this.Resource = resource;
29 | }
30 | #endregion
31 |
32 | #region Public Properties
33 |
34 | ///
35 | /// Gets or sets the resource.
36 | ///
37 | ///
38 | /// The resource.
39 | ///
40 | public TResource Resource { get; set; }
41 | #endregion
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/src/FormsUI/Extensions/ExternalResourceManager.cs:
--------------------------------------------------------------------------------
1 |
2 | using System;
3 | using System.Collections.Generic;
4 | using System.IO;
5 | using System.Linq;
6 |
7 | namespace FormsUI.Extensions
8 | {
9 | ///
10 | /// Represents the base class of the external resource manager.
11 | ///
12 | /// The type of the resource.
13 | public abstract class ExternalResourceManager
14 | where TResource : class, IResource
15 | {
16 | #region Private Fields
17 | private readonly string path;
18 | private readonly string searchPattern;
19 | #endregion
20 |
21 | #region Ctor
22 | ///
23 | /// Initializes a new instance of the class.
24 | ///
25 | /// The path from which the resource is searching.
26 | /// The search pattern.
27 | protected ExternalResourceManager(string path, string searchPattern)
28 | {
29 | this.path = path;
30 | this.searchPattern = searchPattern;
31 | }
32 | #endregion
33 |
34 | #region Public Events
35 |
36 | ///
37 | /// The event that occurs when the resource is loaded.
38 | ///
39 | public event EventHandler> ResourceLoaded;
40 | #endregion
41 |
42 | #region Protected Methods
43 |
44 | ///
45 | /// The event handler method which will be invoked when the resource is loaded.
46 | ///
47 | /// The resource.
48 | protected virtual void OnResourceLoaded(TResource resource)
49 | {
50 | this.ResourceLoaded?.Invoke(this, new ExternalResourceLoadEventArgs(resource));
51 | }
52 |
53 | ///
54 | /// Loads the resources from the given file.
55 | ///
56 | /// Name of the file from which the resources are loaded.
57 | /// A list of resource instances.
58 | protected abstract IEnumerable LoadResources(string fileName);
59 |
60 | #endregion
61 |
62 | #region Protected Properties
63 |
64 | ///
65 | /// Gets all the resources that have been loaded to the current manager.
66 | ///
67 | ///
68 | /// The resources.
69 | ///
70 | protected Dictionary Resources { get; } = new Dictionary();
71 | #endregion
72 |
73 | #region Public Properties
74 |
75 | ///
76 | /// Gets a value indicating whether this instance has resource.
77 | ///
78 | ///
79 | /// true if this instance has resource; otherwise, false.
80 | ///
81 | public bool HasResource
82 | {
83 | get { return this.Resources.Count > 0; }
84 | }
85 | #endregion
86 |
87 | #region Public Methods
88 |
89 | ///
90 | /// Loads the resources into the current manager.
91 | ///
92 | public void Load()
93 | {
94 | if (Directory.Exists(this.path))
95 | {
96 | var resourceFiles = Directory.EnumerateFiles(this.path, this.searchPattern, SearchOption.AllDirectories);
97 |
98 | foreach (var resourceFile in resourceFiles)
99 | {
100 | try
101 | {
102 | var res = LoadResources(resourceFile);
103 | if (res != null && res.Any())
104 | {
105 | foreach (var resource in res)
106 | {
107 | this.Resources.Add(resource.Id, resource);
108 | }
109 | }
110 | }
111 | catch
112 | {
113 | }
114 | }
115 | }
116 | }
117 |
118 | ///
119 | /// Gets the resource by using its unique key identifier from the current manager.
120 | ///
121 | /// The unique key identifier of the resource.
122 | /// The resource instance.
123 | public TResource GetByKey(Guid key)
124 | {
125 | return this.Resources[key];
126 | }
127 |
128 | #endregion
129 | }
130 | }
131 |
--------------------------------------------------------------------------------
/src/FormsUI/Extensions/IExtensionSettings.cs:
--------------------------------------------------------------------------------
1 |
2 | namespace FormsUI.Extensions
3 | {
4 |
5 | ///
6 | /// Represents that the implemented classes are the extension settings that
7 | /// carries the setting data of the extensions.
8 | ///
9 | public interface IExtensionSettings
10 | {
11 | }
12 | }
13 |
14 |
--------------------------------------------------------------------------------
/src/FormsUI/Extensions/IResource.cs:
--------------------------------------------------------------------------------
1 |
2 | using System;
3 |
4 | namespace FormsUI.Extensions
5 | {
6 | ///
7 | /// Represents that the implemented classes are the resources.
8 | ///
9 | public interface IResource
10 | {
11 | ///
12 | /// Gets or sets the identifier of the resource.
13 | ///
14 | ///
15 | /// The identifier of the resource.
16 | ///
17 | Guid Id { get; set; }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/src/FormsUI/FormsUI.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {6ECE3042-DA41-4D80-8F80-AA6D2F0A96E2}
8 | Library
9 | Properties
10 | FormsUI
11 | FormsUI
12 | v4.7.2
13 | 512
14 | true
15 |
16 |
17 |
18 | true
19 | full
20 | false
21 | ..\..\build\
22 | DEBUG;TRACE
23 | prompt
24 | 4
25 |
26 |
27 | pdbonly
28 | true
29 | ..\..\build\
30 | TRACE
31 | prompt
32 | 4
33 |
34 |
35 | true
36 |
37 |
38 | FormsUIKey.snk
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 | Properties\AssemblyInfo.cs
55 |
56 |
57 | Component
58 |
59 |
60 | Component
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 | Component
77 |
78 |
79 |
80 |
81 |
82 | Form
83 |
84 |
85 | Wizard.cs
86 |
87 |
88 | UserControl
89 |
90 |
91 | WizardPage.cs
92 |
93 |
94 | UserControl
95 |
96 |
97 | WizardPageBase.cs
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 | Wizard.cs
121 |
122 |
123 |
124 |
--------------------------------------------------------------------------------
/src/FormsUI/FormsUIKey.snk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/daxnet/forms-ui/6200413a9e81bfdfd6e3113e19cc3da6e607a11b/src/FormsUI/FormsUIKey.snk
--------------------------------------------------------------------------------
/src/FormsUI/LengthyOperation.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using System.Windows.Forms;
7 |
8 | namespace FormsUI
9 | {
10 | ///
11 | /// Provides a scoped context that updates the UI cursor, in which the long-running operation will be executed.
12 | ///
13 | ///
14 | public sealed class LengthyOperation : IDisposable
15 | {
16 | #region Private Fields
17 |
18 | private readonly Control parent;
19 |
20 | #endregion Private Fields
21 |
22 | #region Public Constructors
23 |
24 | ///
25 | /// Initializes a new instance of the class.
26 | ///
27 | /// The parent control on which the long-running operation is going to execute.
28 | public LengthyOperation(Control parent)
29 | {
30 | this.parent = parent;
31 | parent.Cursor = Cursors.WaitCursor;
32 | }
33 |
34 | #endregion Public Constructors
35 |
36 | #region Public Methods
37 |
38 | ///
39 | /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
40 | ///
41 | public void Dispose()
42 | {
43 | parent.Cursor = Cursors.Default;
44 | }
45 |
46 | #endregion Public Methods
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/src/FormsUI/PropertyChangedNotifier.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Collections.ObjectModel;
4 | using System.Collections.Specialized;
5 | using System.ComponentModel;
6 | using System.Linq;
7 | using System.Text;
8 | using System.Threading.Tasks;
9 |
10 | namespace FormsUI
11 | {
12 | public abstract class PropertyChangedNotifier : INotifyPropertyChanged
13 | {
14 | #region Public Events
15 |
16 | public event PropertyChangedEventHandler PropertyChanged;
17 |
18 | #endregion Public Events
19 |
20 | #region Protected Methods
21 |
22 | protected void BindObject(T obj)
23 | where T : INotifyPropertyChanged
24 | {
25 | if (obj != null)
26 | {
27 | obj.PropertyChanged += Obj_PropertyChanged;
28 | }
29 | }
30 |
31 | protected void BindObservableCollection(ObservableCollection collection)
32 | {
33 | collection.CollectionChanged += Collection_CollectionChanged;
34 | }
35 |
36 | protected virtual void OnPropertyChanged(string propertyName)
37 | => this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
38 |
39 | protected void UnbindObject(T obj)
40 | where T : INotifyPropertyChanged
41 | {
42 | if (obj != null)
43 | {
44 | obj.PropertyChanged -= Obj_PropertyChanged;
45 | }
46 | }
47 | protected void UnbindObservableCollection(ObservableCollection collection)
48 | {
49 | foreach (var item in collection)
50 | {
51 | if (item is PropertyChangedNotifier notifier)
52 | {
53 | UnbindObject(notifier);
54 | }
55 | }
56 |
57 | collection.CollectionChanged -= Collection_CollectionChanged;
58 | }
59 |
60 | #endregion Protected Methods
61 |
62 | #region Private Methods
63 |
64 | private void Collection_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
65 | {
66 | switch (e.Action)
67 | {
68 | case NotifyCollectionChangedAction.Add:
69 | foreach (var item in e.NewItems)
70 | {
71 | if (item is PropertyChangedNotifier notifier)
72 | {
73 | BindObject(notifier);
74 | }
75 | }
76 | break;
77 | case NotifyCollectionChangedAction.Remove:
78 | foreach (var item in e.OldItems)
79 | {
80 | if (item is PropertyChangedNotifier notifier)
81 | {
82 | UnbindObject(notifier);
83 | }
84 | }
85 | break;
86 | default:
87 | break;
88 | }
89 |
90 | this.OnPropertyChanged(sender.GetType().Name);
91 | }
92 |
93 | private void Obj_PropertyChanged(object sender, PropertyChangedEventArgs e)
94 | {
95 | this.PropertyChanged?.Invoke(sender, e);
96 | }
97 |
98 | #endregion Private Methods
99 | }
100 | }
101 |
--------------------------------------------------------------------------------
/src/FormsUI/Utils.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Security;
5 | using System.Security.Permissions;
6 | using System.Text;
7 | using System.Threading.Tasks;
8 |
9 | namespace FormsUI
10 | {
11 | ///
12 | /// Provides the utility methods for internal use.
13 | ///
14 | internal static class Utils
15 | {
16 | ///
17 | /// Determines whether the user has the write permission to the specified directory.
18 | ///
19 | /// Name of the directory.
20 | ///
21 | /// true if the user has the write permission to the specified directory; otherwise, false.
22 | ///
23 | public static bool HasWritePermission(string directoryName)
24 | {
25 | var permissionSet = new PermissionSet(PermissionState.None);
26 | var writePermission = new FileIOPermission(FileIOPermissionAccess.Write, directoryName);
27 | permissionSet.AddPermission(writePermission);
28 | return permissionSet.IsSubsetOf(AppDomain.CurrentDomain.PermissionSet);
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/src/FormsUI/Wizards/IWizard.cs:
--------------------------------------------------------------------------------
1 |
2 | using System.Collections.Generic;
3 |
4 | namespace FormsUI.Wizards
5 | {
6 | ///
7 | /// Represents that the implemented classes are wizards.
8 | ///
9 | public interface IWizard : ICollection
10 | {
11 | #region Public Properties
12 |
13 | ///
14 | /// Gets the parameters of the wizard.
15 | ///
16 | IEnumerable> Parameters { get; }
17 |
18 | ///
19 | /// Gets or sets the text of the wizard. Usually this text will be displayed as the title of
20 | /// the wizard form.
21 | ///
22 | /// The text of the wizard.
23 | string Text { get; set; }
24 |
25 | #endregion Public Properties
26 |
27 | #region Public Methods
28 |
29 | ///
30 | /// The factory method for creating a wizard page with specific wizard type.
31 | ///
32 | /// The type of the wizard page to be created.
33 | /// A instance that is created.
34 | T CreatePage() where T : WizardPageBase;
35 |
36 | #endregion Public Methods
37 | }
38 | }
--------------------------------------------------------------------------------
/src/FormsUI/Wizards/IWizardModel.cs:
--------------------------------------------------------------------------------
1 |
2 | using System;
3 |
4 | namespace FormsUI.Wizards
5 | {
6 | ///
7 | /// Represents that the implemented classes are data models for wizard page.
8 | ///
9 | [Obsolete]
10 | public interface IWizardModel
11 | {
12 | }
13 | }
--------------------------------------------------------------------------------
/src/FormsUI/Wizards/IWizardPage.cs:
--------------------------------------------------------------------------------
1 |
2 | using System;
3 | using System.Windows.Forms;
4 |
5 | namespace FormsUI.Wizards
6 | {
7 | ///
8 | /// Represents that the implemented classes are wizard pages.
9 | ///
10 | public interface IWizardPage
11 | {
12 | #region Public Events
13 |
14 | ///
15 | /// Occurs when the navigation states have been updated via CanGoCancel ,
16 | /// CanGoFinishPage , CanGoNextPage and CanGoPreviousPage properties.
17 | ///
18 | event EventHandler NavigationStateUpdated;
19 |
20 | #endregion Public Events
21 |
22 | #region Public Properties
23 |
24 | ///
25 | /// Gets a value indicating whether the wizard operation can be canceled and the wizard
26 | /// form can be closed.
27 | ///
28 | ///
29 | /// true if the wizard operation can be canceled and the wizard form can be
30 | /// closed; otherwise, false .
31 | ///
32 | bool CanGoCancel { get; }
33 |
34 | ///
35 | /// Gets a value indicating whether the wizard can finish directly and the wizard form can
36 | /// be closed.
37 | ///
38 | ///
39 | /// true if the wizard can finish directly and the wizard form can be closed;
40 | /// otherwise, false .
41 | ///
42 | bool CanGoFinishPage { get; }
43 |
44 | ///
45 | /// Gets a value indicating whether the wizard can go to the next page.
46 | ///
47 | ///
48 | /// true if the wizard can go to the next page; otherwise, false .
49 | ///
50 | bool CanGoNextPage { get; }
51 |
52 | ///
53 | /// Gets a value indicating whether the wizard can go to the previous page.
54 | ///
55 | ///
56 | /// true if the wizard can go to the previous page; otherwise, false .
57 | ///
58 | bool CanGoPreviousPage { get; }
59 |
60 | ///
61 | /// Gets the description of the current wizard page. This description text will be displayed
62 | /// on top of the wizard.
63 | ///
64 | /// The description of the current wizard page.
65 | string Description { get; }
66 |
67 | ///
68 | /// Gets the presentation of the wizard page. The presentation is a which can be designed in Windows Forms designer.
70 | ///
71 | /// The presentation of the wizard page.
72 | UserControl Presentation { get; }
73 |
74 | ///
75 | /// Gets the title of the current wizard page. This title text will be displayed on top of
76 | /// the wizard.
77 | ///
78 | /// The title of the current wizard page.
79 | string Title { get; }
80 |
81 | ///
82 | /// Gets the type of the current wizard page.
83 | ///
84 | /// The type of the current wizard page.
85 | WizardPageType Type { get; }
86 |
87 | ///
88 | /// Gets the instance of class, which contains the current wizard page.
89 | ///
90 | /// The wizard that contains the current wizard page.
91 | Wizard Wizard { get; }
92 |
93 | #endregion Public Properties
94 | }
95 | }
--------------------------------------------------------------------------------
/src/FormsUI/Wizards/Wizard.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 |
--------------------------------------------------------------------------------
/src/FormsUI/Wizards/WizardPage.Designer.cs:
--------------------------------------------------------------------------------
1 | namespace FormsUI.Wizards
2 | {
3 | partial class WizardPage
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 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
33 | }
34 |
35 | #endregion
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/src/FormsUI/Wizards/WizardPageBase.Designer.cs:
--------------------------------------------------------------------------------
1 | namespace FormsUI.Wizards
2 | {
3 | partial class WizardPageBase
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 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
33 | }
34 |
35 | #endregion
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/src/FormsUI/Wizards/WizardPageDisplay.cs:
--------------------------------------------------------------------------------
1 |
2 | namespace FormsUI.Wizards
3 | {
4 | ///
5 | /// Represents the display behavior of a wizard page.
6 | ///
7 | public enum WizardPageDisplay
8 | {
9 | ///
10 | /// Indicates that the wizard page should be shown on the wizard.
11 | ///
12 | Show,
13 |
14 | ///
15 | /// Indicates that the wizard page should be hidden from the wizard.
16 | ///
17 | Hide
18 | }
19 | }
--------------------------------------------------------------------------------
/src/FormsUI/Wizards/WizardPageType.cs:
--------------------------------------------------------------------------------
1 | namespace FormsUI.Wizards
2 | {
3 | ///
4 | /// Represents the types of a wizard page.
5 | ///
6 | public enum WizardPageType
7 | {
8 | ///
9 | /// Indicates that the title area will be shown on top of the wizard form when opening the
10 | /// current wizard page.
11 | ///
12 | Standard,
13 |
14 | ///
15 | /// Indicates that the title area will be hidden from the wizard form when opening the
16 | /// current wizard page.
17 | ///
18 | Expanded
19 | }
20 | }
--------------------------------------------------------------------------------
/src/FormsUI/Workspaces/IWorkspaceModel.cs:
--------------------------------------------------------------------------------
1 |
2 | using System.ComponentModel;
3 |
4 | namespace FormsUI.Workspaces
5 | {
6 | ///
7 | /// Represents that the implemented classes are workspace models.
8 | ///
9 | ///
10 | public interface IWorkspaceModel : INotifyPropertyChanged
11 | {
12 | #region Public Properties
13 |
14 | ///
15 | /// Gets or sets the persisted version of the workspace model.
16 | ///
17 | ///
18 | /// The version.
19 | ///
20 | WorkspaceModelVersion Version { get; set; }
21 |
22 | #endregion Public Properties
23 | }
24 | }
--------------------------------------------------------------------------------
/src/FormsUI/Workspaces/WorkspaceCreatedEventArgs.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace FormsUI.Workspaces
9 | {
10 | public sealed class WorkspaceCreatedEventArgs : EventArgs
11 | {
12 | public WorkspaceCreatedEventArgs(IWorkspaceModel model)
13 | {
14 | this.Model = model;
15 | }
16 |
17 | public IWorkspaceModel Model { get; }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/src/FormsUI/Workspaces/WorkspaceEventArgs.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace FormsUI.Workspaces
9 | {
10 | public class WorkspaceEventArgs : EventArgs
11 | {
12 | public WorkspaceEventArgs(string fileName, IWorkspaceModel model)
13 | {
14 | this.FileName = fileName;
15 | this.Model = model;
16 | }
17 |
18 | public string FileName { get; }
19 |
20 | public IWorkspaceModel Model { get; }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/src/FormsUI/Workspaces/WorkspaceException.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace FormsUI.Workspaces
8 | {
9 | public class WorkspaceException : Exception
10 | {
11 | public WorkspaceException(string message)
12 | : base(message)
13 | { }
14 |
15 | public WorkspaceException()
16 | { }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/src/FormsUI/Workspaces/WorkspaceModelEnricher.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace FormsUI.Workspaces
8 | {
9 | ///
10 | /// Represents a group of methods that enrich the specified workspace model.
11 | ///
12 | /// The workspace model to be enriched.
13 | /// The enriched workspace model.
14 | public delegate (bool, IWorkspaceModel) WorkspaceModelEnricher(IWorkspaceModel input);
15 | }
16 |
--------------------------------------------------------------------------------
/src/FormsUI/Workspaces/WorkspaceModelVersion.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace FormsUI.Workspaces
8 | {
9 | ///
10 | /// Represents the version of the workspace model.
11 | ///
12 | public sealed class WorkspaceModelVersion
13 | {
14 | public static readonly WorkspaceModelVersion Zero = new WorkspaceModelVersion(0, 0);
15 | public static readonly WorkspaceModelVersion One = new WorkspaceModelVersion(1, 0);
16 |
17 | private WorkspaceModelVersion() { }
18 |
19 | public WorkspaceModelVersion(int major, int minor)
20 | {
21 | Major = major;
22 | Minor = minor;
23 | }
24 |
25 | public WorkspaceModelVersion(string versionString)
26 | {
27 | var parts = versionString.Split('.');
28 | if (!int.TryParse(parts[0].Trim(), out var major))
29 | {
30 | throw new ArgumentException("Given version string is not in a correct format.", nameof(versionString));
31 | }
32 |
33 | if (!int.TryParse(parts[1].Trim(), out var minor))
34 | {
35 | throw new ArgumentException("Given version string is not in a correct format.", nameof(versionString));
36 | }
37 |
38 | Major = major;
39 | Minor = minor;
40 | }
41 |
42 | public int Major { get; set; }
43 |
44 | public int Minor { get; set; }
45 |
46 | public override string ToString() => $"{Major}.{Minor}";
47 |
48 | public override int GetHashCode() => Major.GetHashCode() ^ Minor.GetHashCode();
49 |
50 | public override bool Equals(object obj)
51 | {
52 | if (ReferenceEquals(this, obj))
53 | {
54 | return true;
55 | }
56 |
57 | if (obj == null)
58 | {
59 | return false;
60 | }
61 |
62 | if (obj is WorkspaceModelVersion wmv)
63 | {
64 | return wmv.Major.Equals(Major) &&
65 | wmv.Minor.Equals(Minor);
66 | }
67 |
68 | return false;
69 | }
70 |
71 | public static bool operator ==(WorkspaceModelVersion a, WorkspaceModelVersion b) => Equals(a, b);
72 |
73 | public static bool operator !=(WorkspaceModelVersion a, WorkspaceModelVersion b) => !(a == b);
74 |
75 | public static bool operator >(WorkspaceModelVersion a, WorkspaceModelVersion b)
76 | {
77 | if (a.Major > b.Major)
78 | {
79 | return true;
80 | }
81 | else if (a.Major == b.Major)
82 | {
83 | return a.Minor > b.Minor;
84 | }
85 | else
86 | {
87 | return false;
88 | }
89 | }
90 |
91 | public static bool operator <(WorkspaceModelVersion a, WorkspaceModelVersion b)
92 | {
93 | return a != b && !(a > b);
94 | }
95 | }
96 | }
97 |
--------------------------------------------------------------------------------
/src/FormsUI/Workspaces/WorkspaceModelVersionAttribute.cs:
--------------------------------------------------------------------------------
1 |
2 | using System;
3 |
4 | namespace FormsUI.Workspaces
5 | {
6 | ///
7 | /// Represents the version of the decorated workspace model.
8 | ///
9 | ///
10 | [AttributeUsage(AttributeTargets.Class)]
11 | public sealed class WorkspaceModelVersionAttribute : Attribute
12 | {
13 | #region Public Constructors
14 |
15 | ///
16 | /// Initializes a new instance of the class.
17 | ///
18 | /// The major version of the workspace model.
19 | /// The minor version of the workspace model.
20 | public WorkspaceModelVersionAttribute(int major, int minor)
21 | {
22 | Version = new WorkspaceModelVersion(major, minor);
23 | }
24 |
25 | #endregion Public Constructors
26 |
27 | #region Public Properties
28 |
29 | ///
30 | /// Gets the version of the workspace model.
31 | ///
32 | ///
33 | /// The version.
34 | ///
35 | public WorkspaceModelVersion Version { get; }
36 |
37 | #endregion Public Properties
38 | }
39 | }
--------------------------------------------------------------------------------
/src/FormsUI/Workspaces/WorkspaceOpenedEventArgs.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace FormsUI.Workspaces
9 | {
10 | public sealed class WorkspaceOpenedEventArgs : WorkspaceEventArgs
11 | {
12 | public WorkspaceOpenedEventArgs(string fileName, IWorkspaceModel model)
13 | : base(fileName, model)
14 | {
15 | }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/FormsUI/Workspaces/WorkspaceSavedEventArgs.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace FormsUI.Workspaces
9 | {
10 | public sealed class WorkspaceSavedEventArgs : WorkspaceEventArgs
11 | {
12 | public WorkspaceSavedEventArgs(string fileName, IWorkspaceModel model) : base(fileName, model)
13 | {
14 | }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/src/FormsUI/Workspaces/WorkspaceState.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace FormsUI.Workspaces
8 | {
9 | ///
10 | /// Represents different states of a workspace.
11 | ///
12 | [Flags]
13 | public enum WorkspaceState
14 | {
15 | ///
16 | /// Indicates that the workspace is inactive, usually when the application has just started without a
17 | /// workspace opened, or a workspace has been closed.
18 | ///
19 | Inactive = 0B0000_0000,
20 |
21 | ///
22 | /// Indicates that the workspace is active, which means it can either be in the Clean state or in the
23 | /// Modified state.
24 | ///
25 | Active = 0B0000_0001,
26 |
27 | ///
28 | /// Indicates that the workspace is clean, which means the user has saved the changes and the workspace
29 | /// model is consistent with the model saved on the disk.
30 | ///
31 | Clean = 0B0000_0011,
32 |
33 | ///
34 | /// Indicates that the workspace has been modified.
35 | ///
36 | Modified = 0B0000_0101,
37 |
38 | ///
39 | /// Indicates that the workspace has just been created.
40 | ///
41 | Created = 0B0000_1000,
42 |
43 | ///
44 | /// Indicates that the workspace was just opened.
45 | ///
46 | Opened = 0B0001_0000
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/src/FormsUI/Workspaces/WorkspaceStateChangedEventArgs.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace FormsUI.Workspaces
8 | {
9 | public sealed class WorkspaceStateChangedEventArgs : EventArgs
10 | {
11 | public WorkspaceStateChangedEventArgs(WorkspaceState state) => State = state;
12 |
13 |
14 | public WorkspaceState State { get; }
15 |
16 | public override string ToString() => State.ToString();
17 | }
18 | }
19 |
--------------------------------------------------------------------------------