This repository has been archived by the owner on Sep 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
UserControl1.cs
150 lines (139 loc) · 6.15 KB
/
UserControl1.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Windows.Forms;
using DevExpress.XtraBars;
namespace MergeModules {
/// <summary>
/// Summary description for UserControl1.
/// </summary>
public class UserControl1 : System.Windows.Forms.UserControl {
private DevExpress.XtraBars.BarManager barManager1;
private DevExpress.XtraBars.BarDockControl barDockControlTop;
private DevExpress.XtraBars.BarDockControl barDockControlBottom;
private DevExpress.XtraBars.BarDockControl barDockControlLeft;
private DevExpress.XtraBars.BarDockControl barDockControlRight;
private DevExpress.XtraBars.Bar bar1;
private DevExpress.XtraBars.BarButtonItem barButtonItem1;
private IContainer components;
private DevExpress.XtraEditors.TextEdit textEdit1;
BarManager mainManager;
BarManager thisManager {
get {
return barManager1;
}
}
public UserControl1(BarManager mainManager) {
this.mainManager = mainManager;
// This call is required by the Windows.Forms Form Designer.
InitializeComponent();
// TODO: Add any initialization after the InitForm call
}
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent() {
this.components = new System.ComponentModel.Container();
this.barManager1 = new DevExpress.XtraBars.BarManager(this.components);
this.bar1 = new DevExpress.XtraBars.Bar();
this.barButtonItem1 = new DevExpress.XtraBars.BarButtonItem();
this.barDockControlTop = new DevExpress.XtraBars.BarDockControl();
this.barDockControlBottom = new DevExpress.XtraBars.BarDockControl();
this.barDockControlLeft = new DevExpress.XtraBars.BarDockControl();
this.barDockControlRight = new DevExpress.XtraBars.BarDockControl();
this.textEdit1 = new DevExpress.XtraEditors.TextEdit();
((System.ComponentModel.ISupportInitialize)(this.barManager1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.textEdit1.Properties)).BeginInit();
this.SuspendLayout();
//
// barManager1
//
this.barManager1.Bars.AddRange(new DevExpress.XtraBars.Bar[] {
this.bar1});
this.barManager1.DockControls.Add(this.barDockControlTop);
this.barManager1.DockControls.Add(this.barDockControlBottom);
this.barManager1.DockControls.Add(this.barDockControlLeft);
this.barManager1.DockControls.Add(this.barDockControlRight);
this.barManager1.Form = this;
this.barManager1.Items.AddRange(new DevExpress.XtraBars.BarItem[] {
this.barButtonItem1});
this.barManager1.MaxItemId = 1;
//
// bar1
//
this.bar1.BarName = "Custom 1";
this.bar1.DockCol = 0;
this.bar1.DockRow = 0;
this.bar1.DockStyle = DevExpress.XtraBars.BarDockStyle.Top;
this.bar1.LinksPersistInfo.AddRange(new DevExpress.XtraBars.LinkPersistInfo[] {
new DevExpress.XtraBars.LinkPersistInfo(this.barButtonItem1)});
this.bar1.Text = "Custom 1";
//
// barButtonItem1
//
this.barButtonItem1.Caption = "ModuleButton (Ctrl+M)";
this.barButtonItem1.Id = 0;
this.barButtonItem1.ItemShortcut = new DevExpress.XtraBars.BarShortcut((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.M));
this.barButtonItem1.Name = "barButtonItem1";
this.barButtonItem1.ItemClick += new DevExpress.XtraBars.ItemClickEventHandler(this.barButtonItem1_ItemClick);
//
// textEdit1
//
this.textEdit1.Location = new System.Drawing.Point(48, 88);
this.textEdit1.Name = "textEdit1";
this.textEdit1.Size = new System.Drawing.Size(100, 20);
this.textEdit1.TabIndex = 4;
//
// UserControl1
//
this.BackColor = System.Drawing.SystemColors.ControlDark;
this.Controls.Add(this.textEdit1);
this.Controls.Add(this.barDockControlLeft);
this.Controls.Add(this.barDockControlRight);
this.Controls.Add(this.barDockControlBottom);
this.Controls.Add(this.barDockControlTop);
this.Name = "UserControl1";
this.Size = new System.Drawing.Size(314, 173);
((System.ComponentModel.ISupportInitialize)(this.barManager1)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.textEdit1.Properties)).EndInit();
this.ResumeLayout(false);
}
#endregion
private void MergeToolbars(bool merge) {
foreach(Bar bar in thisManager.Bars) {
Bar mainBar = mainManager.Bars[bar.BarName];
if(mainBar != null) {
if(merge) {
mainBar.Merge(bar);
bar.Visible = false;
}
else
mainBar.UnMerge();
}
}
}
protected override void OnLoad(EventArgs e) {
base.OnLoad(e);
if(!DesignMode && mainManager != null) {
thisManager.ForceInitialize();
MergeToolbars(true);
}
}
protected override void Dispose(bool disposing) {
if(disposing) {
if(mainManager != null)
MergeToolbars(false);
if(components != null)
components.Dispose();
}
base.Dispose(disposing);
}
private void barButtonItem1_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) {
MessageBox.Show(e.Item.Caption);
}
}
}