码迷,mamicode.com
首页 > 其他好文 > 详细

DevExpress美化应用程序

时间:2016-05-08 16:53:07      阅读:1231      评论:0      收藏:0      [点我收藏+]

标签:

技术分享技术分享技术分享技术分享技术分享技术分享

 1 using System;
 2 using System.Globalization;
 3 using System.Windows.Forms;
 4 using DevExpress.Printing.Core;
 5 
 6 namespace WinFormDevSkinDemo
 7 {
 8     static class Program
 9     {
10         /// <summary>
11         /// 应用程序的主入口点。
12         /// </summary>
13         [STAThread]
14         static void Main()
15         {
16             //System.Threading.Thread.CurrentThread.CurrentUICulture = new CultureInfo("zh-CN");
17             DevExpress.UserSkins.BonusSkins.Register();
18             DevExpress.Skins.SkinManager.EnableFormSkins();
19             DevExpress.Skins.SkinManager.Default.RegisterAssembly(typeof(DevExpress.UserSkins.SkinProject2).Assembly); 
20             Application.EnableVisualStyles();
21             Application.SetCompatibleTextRenderingDefault(false);
22             Application.Run(new Form1());
23         }
24     }
25 }
 1 using System;
 2 using System.Data;
 3 using System.Windows.Forms;
 4 using DevExpress.XtraBars;
 5 
 6 namespace WinFormDevSkinDemo
 7 {
 8     public partial class Form1 : DevExpress.XtraEditors.XtraForm
 9     {
10         public Form1()
11         {
12             InitializeComponent();
13         }
14         DataView dataView;
15         private void Form1_Load(object sender, EventArgs e)
16         {
17             this.Text = "DevExpress 控件演示";
18             DevExpress.LookAndFeel.UserLookAndFeel.Default.SetSkinStyle("Office 2010 Black");
19 
20             foreach (DevExpress.Skins.SkinContainer skinContainer in DevExpress.Skins.SkinManager.Default.Skins)
21             {
22                 comboBoxEdit1.Properties.Items.Add(skinContainer.SkinName);
23             }
24             InitSkins();
25 
26             string DBFileName = DevExpress.Utils.FilesHelper.FindingFileName(Application.StartupPath, "Data\\Products.xml");if (DBFileName != "")
27             {
28                 DataSet dataSet = new DataSet();
29                 dataSet.ReadXml(DBFileName);gridControl1.DataSource = dataView = dataSet.Tables[0].DefaultView;
30             }
31         }
32 
33         private void comboBoxEdit1_SelectedValueChanged(object sender, EventArgs e)
34         {
35             DevExpress.LookAndFeel.UserLookAndFeel.Default.SetSkinStyle(comboBoxEdit1.Text);
36 
37         }
38 
39         private string skinMask = "皮肤: ";
40 
41         private void InitSkins()
42         {
43             barManager1.ForceInitialize();
44             foreach (DevExpress.Skins.SkinContainer cnt in DevExpress.Skins.SkinManager.Default.Skins)
45             {
46                 BarButtonItem item = new BarButtonItem(barManager1, skinMask + cnt.SkinName);
47                 iPaintStyle.AddItem(item);
48                 item.ItemClick += new ItemClickEventHandler(OnSkinClick);
49             }
50         }
51 
52         private void OnSkinClick(object sender, ItemClickEventArgs e)
53         {
54             string skinName = e.Item.Caption.Replace(skinMask, "");
55             DevExpress.LookAndFeel.UserLookAndFeel.Default.SetSkinStyle(skinName);
56             barManager1.GetController().PaintStyleName = "Skin";
57             iPaintStyle.Caption = iPaintStyle.Hint = e.Item.Caption;
58             iPaintStyle.Hint = iPaintStyle.Caption;
59             iPaintStyle.ImageIndex = -1;
60         }
61 
62         private void barEditItem1_EditValueChanged(object sender, EventArgs e)
63         {
64             DevExpress.XtraEditors.XtraMessageBox.Show(this,barEditItem1.EditValue.ToString());}
65 
66         private void gridControl1_Click(object sender, EventArgs e)
67         {
68 
69         }
70 
71     }
72 }
  1 namespace WinFormDevSkinDemo
  2 {
  3     partial class Form1
  4     {
  5         /// <summary>
  6         /// 必需的设计器变量。
  7         /// </summary>
  8         private System.ComponentModel.IContainer components = null;
  9 
 10         /// <summary>
 11         /// 清理所有正在使用的资源。
 12         /// </summary>
 13         /// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
 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 窗体设计器生成的代码
 24 
 25         /// <summary>
 26         /// 设计器支持所需的方法 - 不要
 27         /// 使用代码编辑器修改此方法的内容。
 28         /// </summary>
 29         private void InitializeComponent()
 30         {
 31             this.components = new System.ComponentModel.Container();
 32             System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
 33             this.comboBoxEdit1 = new DevExpress.XtraEditors.ComboBoxEdit();
 34             this.barManager1 = new DevExpress.XtraBars.BarManager(this.components);
 35             this.bar1 = new DevExpress.XtraBars.Bar();
 36             this.iPaintStyle = new DevExpress.XtraBars.BarSubItem();
 37             this.barEditItem1 = new DevExpress.XtraBars.BarEditItem();
 38             this.repositoryItemImageComboBox1 = new DevExpress.XtraEditors.Repository.RepositoryItemImageComboBox();
 39             this.imageCollection1 = new DevExpress.Utils.ImageCollection(this.components);
 40             this.bar2 = new DevExpress.XtraBars.Bar();
 41             this.skinBarSubItem1 = new DevExpress.XtraBars.SkinBarSubItem();
 42             this.bar3 = new DevExpress.XtraBars.Bar();
 43             this.barDockControlTop = new DevExpress.XtraBars.BarDockControl();
 44             this.barDockControlBottom = new DevExpress.XtraBars.BarDockControl();
 45             this.barDockControlLeft = new DevExpress.XtraBars.BarDockControl();
 46             this.barDockControlRight = new DevExpress.XtraBars.BarDockControl();
 47             this.gridControl1 = new DevExpress.XtraGrid.GridControl();
 48             this.gridView1 = new DevExpress.XtraGrid.Views.Grid.GridView();
 49             this.gridColumn1 = new DevExpress.XtraGrid.Columns.GridColumn();
 50             this.gridColumn2 = new DevExpress.XtraGrid.Columns.GridColumn();
 51             this.gridColumn3 = new DevExpress.XtraGrid.Columns.GridColumn();
 52             this.gridColumn4 = new DevExpress.XtraGrid.Columns.GridColumn();
 53             this.gridColumn5 = new DevExpress.XtraGrid.Columns.GridColumn();
 54             this.gridColumn6 = new DevExpress.XtraGrid.Columns.GridColumn();
 55             this.gridColumn7 = new DevExpress.XtraGrid.Columns.GridColumn();
 56             this.gridColumn8 = new DevExpress.XtraGrid.Columns.GridColumn();
 57             this.gridColumn9 = new DevExpress.XtraGrid.Columns.GridColumn();
 58             ((System.ComponentModel.ISupportInitialize)(this.comboBoxEdit1.Properties)).BeginInit();
 59             ((System.ComponentModel.ISupportInitialize)(this.barManager1)).BeginInit();
 60             ((System.ComponentModel.ISupportInitialize)(this.repositoryItemImageComboBox1)).BeginInit();
 61             ((System.ComponentModel.ISupportInitialize)(this.imageCollection1)).BeginInit();
 62             ((System.ComponentModel.ISupportInitialize)(this.gridControl1)).BeginInit();
 63             ((System.ComponentModel.ISupportInitialize)(this.gridView1)).BeginInit();
 64             this.SuspendLayout();
 65             // 
 66             // comboBoxEdit1
 67             // 
 68             resources.ApplyResources(this.comboBoxEdit1, "comboBoxEdit1");
 69             this.comboBoxEdit1.Name = "comboBoxEdit1";
 70             this.comboBoxEdit1.Properties.Buttons.AddRange(new DevExpress.XtraEditors.Controls.EditorButton[] {
 71             new DevExpress.XtraEditors.Controls.EditorButton(((DevExpress.XtraEditors.Controls.ButtonPredefines)(resources.GetObject("comboBoxEdit1.Properties.Buttons"))))});
 72             this.comboBoxEdit1.Properties.DropDownRows = 20;
 73             this.comboBoxEdit1.Properties.LookAndFeel.SkinName = "Office 2010 Black";
 74             this.comboBoxEdit1.SelectedValueChanged += new System.EventHandler(this.comboBoxEdit1_SelectedValueChanged);
 75             // 
 76             // barManager1
 77             // 
 78             this.barManager1.Bars.AddRange(new DevExpress.XtraBars.Bar[] {
 79             this.bar1,
 80             this.bar2,
 81             this.bar3});
 82             this.barManager1.DockControls.Add(this.barDockControlTop);
 83             this.barManager1.DockControls.Add(this.barDockControlBottom);
 84             this.barManager1.DockControls.Add(this.barDockControlLeft);
 85             this.barManager1.DockControls.Add(this.barDockControlRight);
 86             this.barManager1.Form = this;
 87             this.barManager1.Items.AddRange(new DevExpress.XtraBars.BarItem[] {
 88             this.skinBarSubItem1,
 89             this.iPaintStyle,
 90             this.barEditItem1});
 91             this.barManager1.MainMenu = this.bar2;
 92             this.barManager1.MaxItemId = 4;
 93             this.barManager1.RepositoryItems.AddRange(new DevExpress.XtraEditors.Repository.RepositoryItem[] {
 94             this.repositoryItemImageComboBox1});
 95             this.barManager1.StatusBar = this.bar3;
 96             // 
 97             // bar1
 98             // 
 99             this.bar1.BarName = "Tools";
100             this.bar1.DockCol = 0;
101             this.bar1.DockRow = 1;
102             this.bar1.DockStyle = DevExpress.XtraBars.BarDockStyle.Top;
103             this.bar1.LinksPersistInfo.AddRange(new DevExpress.XtraBars.LinkPersistInfo[] {
104             new DevExpress.XtraBars.LinkPersistInfo(this.iPaintStyle),
105             new DevExpress.XtraBars.LinkPersistInfo(this.barEditItem1)});
106             resources.ApplyResources(this.bar1, "bar1");
107             // 
108             // iPaintStyle
109             // 
110             resources.ApplyResources(this.iPaintStyle, "iPaintStyle");
111             this.iPaintStyle.Glyph = ((System.Drawing.Image)(resources.GetObject("iPaintStyle.Glyph")));
112             this.iPaintStyle.Id = 1;
113             this.iPaintStyle.Name = "iPaintStyle";
114             this.iPaintStyle.PaintStyle = DevExpress.XtraBars.BarItemPaintStyle.CaptionGlyph;
115             // 
116             // barEditItem1
117             // 
118             resources.ApplyResources(this.barEditItem1, "barEditItem1");
119             this.barEditItem1.Edit = this.repositoryItemImageComboBox1;
120             this.barEditItem1.EditValue = "";
121             this.barEditItem1.Id = 2;
122             this.barEditItem1.Name = "barEditItem1";
123             this.barEditItem1.PaintStyle = DevExpress.XtraBars.BarItemPaintStyle.Caption;
124             this.barEditItem1.EditValueChanged += new System.EventHandler(this.barEditItem1_EditValueChanged);
125             // 
126             // repositoryItemImageComboBox1
127             // 
128             resources.ApplyResources(this.repositoryItemImageComboBox1, "repositoryItemImageComboBox1");
129             this.repositoryItemImageComboBox1.Buttons.AddRange(new DevExpress.XtraEditors.Controls.EditorButton[] {
130             new DevExpress.XtraEditors.Controls.EditorButton(((DevExpress.XtraEditors.Controls.ButtonPredefines)(resources.GetObject("repositoryItemImageComboBox1.Buttons"))))});
131             this.repositoryItemImageComboBox1.Items.AddRange(new DevExpress.XtraEditors.Controls.ImageComboBoxItem[] {
132             new DevExpress.XtraEditors.Controls.ImageComboBoxItem(resources.GetString("repositoryItemImageComboBox1.Items"), resources.GetString("repositoryItemImageComboBox1.Items1"), ((int)(resources.GetObject("repositoryItemImageComboBox1.Items2")))),
133             new DevExpress.XtraEditors.Controls.ImageComboBoxItem(resources.GetString("repositoryItemImageComboBox1.Items3"), resources.GetString("repositoryItemImageComboBox1.Items4"), ((int)(resources.GetObject("repositoryItemImageComboBox1.Items5")))),
134             new DevExpress.XtraEditors.Controls.ImageComboBoxItem(resources.GetString("repositoryItemImageComboBox1.Items6"), resources.GetString("repositoryItemImageComboBox1.Items7"), ((int)(resources.GetObject("repositoryItemImageComboBox1.Items8")))),
135             new DevExpress.XtraEditors.Controls.ImageComboBoxItem(resources.GetString("repositoryItemImageComboBox1.Items9"), resources.GetString("repositoryItemImageComboBox1.Items10"), ((int)(resources.GetObject("repositoryItemImageComboBox1.Items11")))),
136             new DevExpress.XtraEditors.Controls.ImageComboBoxItem(resources.GetString("repositoryItemImageComboBox1.Items12"), resources.GetString("repositoryItemImageComboBox1.Items13"), ((int)(resources.GetObject("repositoryItemImageComboBox1.Items14"))))});
137             this.repositoryItemImageComboBox1.Name = "repositoryItemImageComboBox1";
138             this.repositoryItemImageComboBox1.SmallImages = this.imageCollection1;
139             // 
140             // imageCollection1
141             // 
142             this.imageCollection1.ImageStream = ((DevExpress.Utils.ImageCollectionStreamer)(resources.GetObject("imageCollection1.ImageStream")));
143             this.imageCollection1.InsertGalleryImage("add_16x16.png", "images/actions/add_16x16.png", DevExpress.Images.ImageResourceCache.Default.GetImage("images/actions/add_16x16.png"), 0);
144             this.imageCollection1.Images.SetKeyName(0, "add_16x16.png");
145             this.imageCollection1.InsertGalleryImage("cancel_16x16.png", "images/actions/cancel_16x16.png", DevExpress.Images.ImageResourceCache.Default.GetImage("images/actions/cancel_16x16.png"), 1);
146             this.imageCollection1.Images.SetKeyName(1, "cancel_16x16.png");
147             this.imageCollection1.InsertGalleryImage("open_16x16.png", "images/actions/open_16x16.png", DevExpress.Images.ImageResourceCache.Default.GetImage("images/actions/open_16x16.png"), 2);
148             this.imageCollection1.Images.SetKeyName(2, "open_16x16.png");
149             this.imageCollection1.InsertGalleryImage("reset_16x16.png", "images/actions/reset_16x16.png", DevExpress.Images.ImageResourceCache.Default.GetImage("images/actions/reset_16x16.png"), 3);
150             this.imageCollection1.Images.SetKeyName(3, "reset_16x16.png");
151             this.imageCollection1.InsertGalleryImage("pie_16x16.png", "images/chart/pie_16x16.png", DevExpress.Images.ImageResourceCache.Default.GetImage("images/chart/pie_16x16.png"), 4);
152             this.imageCollection1.Images.SetKeyName(4, "pie_16x16.png");
153             // 
154             // bar2
155             // 
156             this.bar2.BarName = "Main menu";
157             this.bar2.DockCol = 0;
158             this.bar2.DockRow = 0;
159             this.bar2.DockStyle = DevExpress.XtraBars.BarDockStyle.Top;
160             this.bar2.LinksPersistInfo.AddRange(new DevExpress.XtraBars.LinkPersistInfo[] {
161             new DevExpress.XtraBars.LinkPersistInfo(this.skinBarSubItem1)});
162             this.bar2.OptionsBar.MultiLine = true;
163             this.bar2.OptionsBar.UseWholeRow = true;
164             resources.ApplyResources(this.bar2, "bar2");
165             // 
166             // skinBarSubItem1
167             // 
168             resources.ApplyResources(this.skinBarSubItem1, "skinBarSubItem1");
169             this.skinBarSubItem1.Id = 0;
170             this.skinBarSubItem1.Name = "skinBarSubItem1";
171             // 
172             // bar3
173             // 
174             this.bar3.BarName = "Status bar";
175             this.bar3.CanDockStyle = DevExpress.XtraBars.BarCanDockStyle.Bottom;
176             this.bar3.DockCol = 0;
177             this.bar3.DockRow = 0;
178             this.bar3.DockStyle = DevExpress.XtraBars.BarDockStyle.Bottom;
179             this.bar3.OptionsBar.AllowQuickCustomization = false;
180             this.bar3.OptionsBar.DrawDragBorder = false;
181             this.bar3.OptionsBar.UseWholeRow = true;
182             resources.ApplyResources(this.bar3, "bar3");
183             // 
184             // barDockControlTop
185             // 
186             this.barDockControlTop.CausesValidation = false;
187             resources.ApplyResources(this.barDockControlTop, "barDockControlTop");
188             // 
189             // barDockControlBottom
190             // 
191             this.barDockControlBottom.CausesValidation = false;
192             resources.ApplyResources(this.barDockControlBottom, "barDockControlBottom");
193             // 
194             // barDockControlLeft
195             // 
196             this.barDockControlLeft.CausesValidation = false;
197             resources.ApplyResources(this.barDockControlLeft, "barDockControlLeft");
198             // 
199             // barDockControlRight
200             // 
201             this.barDockControlRight.CausesValidation = false;
202             resources.ApplyResources(this.barDockControlRight, "barDockControlRight");
203             // 
204             // gridControl1
205             // 
206             resources.ApplyResources(this.gridControl1, "gridControl1");
207             this.gridControl1.MainView = this.gridView1;
208             this.gridControl1.MenuManager = this.barManager1;
209             this.gridControl1.Name = "gridControl1";
210             this.gridControl1.ViewCollection.AddRange(new DevExpress.XtraGrid.Views.Base.BaseView[] {
211             this.gridView1});
212             this.gridControl1.Click += new System.EventHandler(this.gridControl1_Click);
213             // 
214             // gridView1
215             // 
216             this.gridView1.Columns.AddRange(new DevExpress.XtraGrid.Columns.GridColumn[] {
217             this.gridColumn1,
218             this.gridColumn2,
219             this.gridColumn3,
220             this.gridColumn4,
221             this.gridColumn5,
222             this.gridColumn6,
223             this.gridColumn7,
224             this.gridColumn8,
225             this.gridColumn9});
226             this.gridView1.GridControl = this.gridControl1;
227             this.gridView1.Name = "gridView1";
228             this.gridView1.OptionsView.ShowGroupPanel = false;
229             // 
230             // gridColumn1
231             // 
232             resources.ApplyResources(this.gridColumn1, "gridColumn1");
233             this.gridColumn1.FieldName = "ProductID";
234             this.gridColumn1.Name = "gridColumn1";
235             // 
236             // gridColumn2
237             // 
238             resources.ApplyResources(this.gridColumn2, "gridColumn2");
239             this.gridColumn2.FieldName = "ProductName";
240             this.gridColumn2.Name = "gridColumn2";
241             // 
242             // gridColumn3
243             // 
244             resources.ApplyResources(this.gridColumn3, "gridColumn3");
245             this.gridColumn3.FieldName = "CategoryID";
246             this.gridColumn3.Name = "gridColumn3";
247             // 
248             // gridColumn4
249             // 
250             resources.ApplyResources(this.gridColumn4, "gridColumn4");
251             this.gridColumn4.FieldName = "QuantityPerUnit";
252             this.gridColumn4.Name = "gridColumn4";
253             // 
254             // gridColumn5
255             // 
256             resources.ApplyResources(this.gridColumn5, "gridColumn5");
257             this.gridColumn5.FieldName = "UnitPrice";
258             this.gridColumn5.Name = "gridColumn5";
259             // 
260             // gridColumn6
261             // 
262             resources.ApplyResources(this.gridColumn6, "gridColumn6");
263             this.gridColumn6.FieldName = "UnitsInStock";
264             this.gridColumn6.Name = "gridColumn6";
265             // 
266             // gridColumn7
267             // 
268             resources.ApplyResources(this.gridColumn7, "gridColumn7");
269             this.gridColumn7.FieldName = "Discontinued";
270             this.gridColumn7.Name = "gridColumn7";
271             // 
272             // gridColumn8
273             // 
274             resources.ApplyResources(this.gridColumn8, "gridColumn8");
275             this.gridColumn8.FieldName = "UnitsOnOrder";
276             this.gridColumn8.Name = "gridColumn8";
277             // 
278             // gridColumn9
279             // 
280             resources.ApplyResources(this.gridColumn9, "gridColumn9");
281             this.gridColumn9.FieldName = "LastOrder";
282             this.gridColumn9.Name = "gridColumn9";
283             // 
284             // Form1
285             // 
286             resources.ApplyResources(this, "$this");
287             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
288             this.Controls.Add(this.gridControl1);
289             this.Controls.Add(this.comboBoxEdit1);
290             this.Controls.Add(this.barDockControlLeft);
291             this.Controls.Add(this.barDockControlRight);
292             this.Controls.Add(this.barDockControlBottom);
293             this.Controls.Add(this.barDockControlTop);
294             this.Name = "Form1";
295             this.Load += new System.EventHandler(this.Form1_Load);
296             ((System.ComponentModel.ISupportInitialize)(this.comboBoxEdit1.Properties)).EndInit();
297             ((System.ComponentModel.ISupportInitialize)(this.barManager1)).EndInit();
298             ((System.ComponentModel.ISupportInitialize)(this.repositoryItemImageComboBox1)).EndInit();
299             ((System.ComponentModel.ISupportInitialize)(this.imageCollection1)).EndInit();
300             ((System.ComponentModel.ISupportInitialize)(this.gridControl1)).EndInit();
301             ((System.ComponentModel.ISupportInitialize)(this.gridView1)).EndInit();
302             this.ResumeLayout(false);
303 
304         }
305 
306         #endregion
307 
308         private DevExpress.XtraEditors.ComboBoxEdit comboBoxEdit1;
309         private DevExpress.XtraBars.BarManager barManager1;
310         private DevExpress.XtraBars.Bar bar1;
311         private DevExpress.XtraBars.Bar bar2;
312         private DevExpress.XtraBars.SkinBarSubItem skinBarSubItem1;
313         private DevExpress.XtraBars.Bar bar3;
314         private DevExpress.XtraBars.BarDockControl barDockControlTop;
315         private DevExpress.XtraBars.BarDockControl barDockControlBottom;
316         private DevExpress.XtraBars.BarDockControl barDockControlLeft;
317         private DevExpress.XtraBars.BarDockControl barDockControlRight;
318         private DevExpress.XtraBars.BarSubItem iPaintStyle;
319         private DevExpress.XtraBars.BarEditItem barEditItem1;
320         private DevExpress.XtraEditors.Repository.RepositoryItemImageComboBox repositoryItemImageComboBox1;
321         private DevExpress.Utils.ImageCollection imageCollection1;
322         private DevExpress.XtraGrid.GridControl gridControl1;
323         private DevExpress.XtraGrid.Views.Grid.GridView gridView1;
324         private DevExpress.XtraGrid.Columns.GridColumn gridColumn1;
325         private DevExpress.XtraGrid.Columns.GridColumn gridColumn2;
326         private DevExpress.XtraGrid.Columns.GridColumn gridColumn3;
327         private DevExpress.XtraGrid.Columns.GridColumn gridColumn4;
328         private DevExpress.XtraGrid.Columns.GridColumn gridColumn5;
329         private DevExpress.XtraGrid.Columns.GridColumn gridColumn6;
330         private DevExpress.XtraGrid.Columns.GridColumn gridColumn7;
331         private DevExpress.XtraGrid.Columns.GridColumn gridColumn8;
332         private DevExpress.XtraGrid.Columns.GridColumn gridColumn9;
333 
334     }
335 }

 

DevExpress美化应用程序

标签:

原文地址:http://www.cnblogs.com/linhongquan/p/5470725.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!