My Project
Sproerty.cs
查看本檔案說明文件.
1 using System;
2 using System.Collections.Generic;
3 using System.Linq;
4 using System.Text;
5 using System.Threading.Tasks;
6 using ShapeLib.VShape;
7 using System.Collections;
8 using Microsoft.Office.Tools.Ribbon;
9 using System.Drawing;
10 
11 namespace ShapeLib.VShape
12 {
14  {
15  public override System.Collections.ArrayList getMenuItem()
16  {
17  ArrayList ret = new ArrayList();
18 
19  shapeUI ui = new shapeUI();
20  ui.uitype = shapeUIType.RibbonGroup;
21  ui.label = "Colors";
22  ret.Add(ui);
23 
24 
25 
26 
27 
28  ui = new shapeUI();
29  ui.uitype = shapeUIType.RibbonSmallButton;
30  ui.label = "Red";
31 
32  System.Reflection.Assembly myAssembly = System.Reflection.Assembly.GetExecutingAssembly();
33  System.IO.Stream myStream = myAssembly.GetManifestResourceStream("ShapeLib.icons.red.png");
34  ui.image = new System.Drawing.Bitmap(myStream);
35 
36 
37 
38  ui.click = btn_Click;
39  ui.belong = "Colors";
40  ret.Add(ui);
41 
42  ui = new shapeUI();
43  ui.uitype = shapeUIType.RibbonSmallButton;
44  ui.label = "Green";
45 
46  myStream = myAssembly.GetManifestResourceStream("ShapeLib.icons.green.png");
47  ui.image = new System.Drawing.Bitmap(myStream);
48 
49 
50 
51  ui.click = btn_Click;
52  ui.belong = "Colors";
53  ret.Add(ui);
54 
55  ui = new shapeUI();
56  ui.uitype = shapeUIType.RibbonSmallButton;
57  ui.label = "Blue";
58  myStream = myAssembly.GetManifestResourceStream("ShapeLib.icons.blue.png");
59  ui.image = new System.Drawing.Bitmap(myStream);
60 
61 
62  ui.click = btn_Click;
63  ui.belong = "Colors";
64  ret.Add(ui);
65 
66  ui = new shapeUI();
67  ui.uitype = shapeUIType.RibbonSmallButton;
68  ui.label = "Black";
69  myStream = myAssembly.GetManifestResourceStream("ShapeLib.icons.black.png");
70  ui.image = new System.Drawing.Bitmap(myStream);
71 
72 
73  ui.click = btn_Click;
74  ui.belong = "Colors";
75  ret.Add(ui);
76 
77  ui = new shapeUI();
78  ui.uitype = shapeUIType.RibbonSmallButton;
79  ui.label = "White";
80  myStream = myAssembly.GetManifestResourceStream("ShapeLib.icons.white1.png");
81  ui.image = new System.Drawing.Bitmap(myStream);
82 
83 
84  ui.click = btn_Click;
85  ui.belong = "Colors";
86  ret.Add(ui);
87 
88  ui = new shapeUI();
89  ui.uitype = shapeUIType.RibbonSmallButton;
90  ui.label = "Yellow";
91  myStream = myAssembly.GetManifestResourceStream("ShapeLib.icons.yellow.png");
92  ui.image = new System.Drawing.Bitmap(myStream);
93 
94 
95  ui.click = btn_Click;
96  ui.belong = "Colors";
97  ret.Add(ui);
98 
99  ui = new shapeUI();
100  ui.uitype = shapeUIType.RibbonSmallButton;
101  ui.label = "Orange";
102  myStream = myAssembly.GetManifestResourceStream("ShapeLib.icons.orange.png");
103  ui.image = new System.Drawing.Bitmap(myStream);
104 
105 
106  ui.click = btn_Click;
107  ui.belong = "Colors";
108  ret.Add(ui);
109  return ret;
110  }
111 
112  new void btn_Click(object sender, RibbonControlEventArgs e)
113  {
114  RibbonButton btn = sender as RibbonButton;
115  if ( btn!= null)
116  {
117  String txt = btn.Label;
118 
119  if (String.IsNullOrEmpty(txt))
120  txt = btn.Name;
121 
122  switch(txt)
123  {
124  case "Red":
125  shapeLib.Data.colorR = 255;
126  shapeLib.Data.colorG = 0;
127  shapeLib.Data.colorB = 0;
128  break;
129  case "Orange":
130  shapeLib.Data.colorR = 255;
131  shapeLib.Data.colorG = 165;
132  shapeLib.Data.colorB = 0;
133  break;
134  case "Yellow":
135  shapeLib.Data.colorR = 255;
136  shapeLib.Data.colorG = 230;
137  shapeLib.Data.colorB = 0;
138  break;
139  case "Green":
140  shapeLib.Data.colorR = 0;
141  shapeLib.Data.colorG = 128;
142  shapeLib.Data.colorB = 0;
143  break;
144  case "Blue":
145  shapeLib.Data.colorR = 0;
146  shapeLib.Data.colorG = 0;
147  shapeLib.Data.colorB = 128;
148  break;
149  case "Black":
150  shapeLib.Data.colorR = 0;
151  shapeLib.Data.colorG = 0;
152  shapeLib.Data.colorB = 0;
153  break;
154  case "white":
155  shapeLib.Data.colorR = 255;
156  shapeLib.Data.colorG = 255;
157  shapeLib.Data.colorB = 255;
158  break;
159  case "Violet":
160  shapeLib.Data.colorR = 138;
161  shapeLib.Data.colorG = 43;
162  shapeLib.Data.colorB = 226;
163  break;
164  case "Gray":
165  shapeLib.Data.colorR = 128;
166  shapeLib.Data.colorG = 128;
167  shapeLib.Data.colorB = 128;
168  break;
169 break;
170 
171  case "White":
172  shapeLib.Data.colorR = 255;
173  shapeLib.Data.colorG = 255;
174  shapeLib.Data.colorB = 255;
175 
176  break;
177 
178  }
179 
180  }
181  }
182 
183  }
184 }
static GModel Data
Definition: shapeLib.cs:42
RibbonControlEventHandler click
Definition: ShapeObj.cs:49
string belong
判斷按下Button控制項
Definition: ShapeObj.cs:53
shapeUIType uitype
Definition: ShapeObj.cs:45
某一類的形狀.包含UI 的界面,繪製方式.更新方式.新增方式
Definition: ShapeObj.cs:59
override System.Collections.ArrayList getMenuItem()
覆寫System.Collections.ArrayList
Definition: Sproerty.cs:15
shapeUIType
建構不同UI 時使用
Definition: ShapeObj.cs:31
定義一個UI項目
Definition: ShapeObj.cs:42
new void btn_Click(object sender, RibbonControlEventArgs e)
Definition: Sproerty.cs:112
System.Drawing.Image image
Definition: ShapeObj.cs:46