My Project
C:/Users/Lab_411_02/Desktop/Violet1 - dox/violet/violet/Ribbon1.cs
查看本檔案說明文件.
1 using System;
2 using System.Collections.Generic;
3 using System.Linq;
4 using System.Text;
5 using Microsoft.Office.Tools.Ribbon;
6 using Microsoft.Office.Tools.Word;
7 using System.Collections;
8 using ShapeLib.VShape;
9 
10 
11 namespace violet
12 {
13  public partial class Ribbon1
14  {
15  public Form1 f;
16  double backGroundColor = 0.2;
18  {
22  if (f == null)
23  {
24  f = new Form1();
25  backGroundColor = 0.2;
26  int formHeight = (int)(f.setFormSize("h") / 1.7);
27  int formWidth = (int)(f.setFormSize("w") / 1.7);
28  f.Size = new System.Drawing.Size(formWidth, formHeight);
29  f.TopMost = true;
31  f.Disposed += new EventHandler(f_Disposed);
32  }
33  return (IForm)f;
34  }
35  //create form
36 
37 
38  public void Construt(ShapeObj obj)
39  {
40  ArrayList list = obj.getMenuItem();
41  // RibbonGroup group3 = this.Factory.CreateRibbonGroup();
42  // RibbonTab tab = Factory.CreateRibbonTab();
43 
44  foreach (shapeUI ui in list)
45  {
46  switch (ui.uitype)
47  {
48  case shapeUIType.RibbonBigButton:
49  RibbonButton uiobj = this.Factory.CreateRibbonButton();
50  uiobj.Click += (RibbonControlEventHandler)ui.click;
51  uiobj.Label = ui.label;
52  uiobj.Image = ui.image;
53  uiobj.ControlSize = Microsoft.Office.Core.RibbonControlSize.RibbonControlSizeLarge;
54 
55  addByName(uiobj, ui.belong);
56  break;
57  case shapeUIType.RibbonSmallButton:
58  RibbonButton uisobj = this.Factory.CreateRibbonButton();
59  uisobj.Click += (RibbonControlEventHandler)ui.click;
60 
61  if (ui.image != null)
62  {
63  uisobj.ShowImage = true;
64  uisobj.Name = ui.label;
65  }
66  else
67  uisobj.Label = ui.label;
68 
69  uisobj.Image = ui.image;
70  uisobj.ControlSize = Microsoft.Office.Core.RibbonControlSize.RibbonControlSizeRegular;
71 
72  addByName(uisobj, ui.belong);
73  break;
74 
75  case shapeUIType.RibbonGroup:
76  RibbonGroup uig = this.Factory.CreateRibbonGroup();
77  uig.Label = ui.label;
78  tab1.Groups.Add(uig);
79 
80  break;
81  case shapeUIType.RibbonMenu:
82  RibbonMenu rim = Factory.CreateRibbonMenu();
83  rim.Label = ui.label;
84  rim.Image = ui.image;
85  addByName(rim, ui.belong);
86  break;
87  }
88 
89 
90 
91  }
92 
93  //tab.Groups.Add(group3);
94  //Tabs.Add(tab);
95 
96  }
97 
98 
99  void addByName(RibbonControl uiobj, String name)
100  {
101  if (uiobj != null)
102  {
103  foreach (RibbonGroup gr in tab1.Groups)
104  {
105  if (gr.Label == name)
106  {
107  gr.SuspendLayout();
108  gr.Items.Add(uiobj);
109  gr.ResumeLayout(false);
110  gr.PerformLayout();
111  break;
112  }
113 
114 
115  foreach (RibbonControl rc in gr.Items)
116  {
117  if (rc is RibbonMenu)
118  {
119  RibbonMenu rm = (RibbonMenu)rc;
120  if (rm.Label == name)
121  {
122  rm.SuspendLayout();
123  rm.Items.Add(uiobj);
124  rm.ResumeLayout(false);
125  rm.PerformLayout();
126  break;
127  }
128  }
129 
130  }
131  }
132 
133 
134  }
135 
136  }
137 
138 
139  void f_Disposed(object sender, EventArgs e)
140  {
141  f = null;
142  }
143 
144  private void Ribbon1_Load(object sender, RibbonUIEventArgs e)
145  {
146  int i = 0;
147  //Check();
148  }
149 
150  private void clear_Click(object sender, RibbonControlEventArgs e)
151  {
152  if (f != null)
153  {
154  Check();
155  f.TopMost = false;
156  f.ClearDrawing();
157  f.TopMost = true;
158  }
159  }
160  private void bgp_Click(object sender, RibbonControlEventArgs e)
161  {
162  if (f != null)
163  {
164  if (backGroundColor != 0)
165  {
166  backGroundColor = 0;
168  }
169  else
170  {
171  backGroundColor = 0.2;
173  }
174  }
175  }
176 
177  private void red_btn_Click(object sender, RibbonControlEventArgs e)
178  {
179  if (f != null)
180  f.setColorType("red");
181  }
182  private void button7_Click(object sender, RibbonControlEventArgs e)
183  {
184  if (f != null)
185  f.setColorType("orange");
186  }
187  private void yellow_btn_Click(object sender, RibbonControlEventArgs e)
188  {
189  if (f != null)
190  f.setColorType("yellow");
191  }
192  private void green_btn_Click(object sender, RibbonControlEventArgs e)
193  {
194  if (f != null)
195  f.setColorType("green");
196  }
197  private void black_btn_Click(object sender, RibbonControlEventArgs e)
198  {
199  if (f != null)
200  f.setColorType("black");
201  }
202  private void blue_btn_Click(object sender, RibbonControlEventArgs e)
203  {
204  if (f != null)
205  f.setColorType("blue");
206  }
207  private void violet_Click(object sender, RibbonControlEventArgs e)
208  {
209  if (f != null)
210  f.setColorType("violet");
211  }
212  private void gray_Click(object sender, RibbonControlEventArgs e)
213  {
214  if (f != null)
215  f.setColorType("gray");
216  }
217  private void white_btn_Click(object sender, RibbonControlEventArgs e)
218  {
219  if (f != null)
220  f.setColorType("white");
221  }
222  private void px1_Click(object sender, RibbonControlEventArgs e)
223  {
224  if (f != null)
225  f.setStrokeType(1);
226  }
227  private void px3_Click(object sender, RibbonControlEventArgs e)
228  {
229  if (f != null)
230  f.setStrokeType(3);
231  }
232  private void px5_Click(object sender, RibbonControlEventArgs e)
233  {
234  if (f != null)
235  f.setStrokeType(5);
236  }
237  private void px8_Click(object sender, RibbonControlEventArgs e)
238  {
239  if (f != null)
240  f.setStrokeType(8);
241  }
242  //selection mode
243  private void selBtn_Click(object sender, RibbonControlEventArgs e)
244  {
245  Check();
246  //f.setDrawType(5);
247 
248  shapeLib.Data.UItype = -1;
249 
250  }
251  private void redo_Click(object sender, RibbonControlEventArgs e)
252  {
253  if (f != null)
254  f.setAction(1);
255  }
256  private void undo_Click(object sender, RibbonControlEventArgs e)
257  {
258  if (f != null)
259  f.setAction(0);
260  }
261 
265  public void initPath(string xml)
266  {
267  Check();
268  f.initpath(xml);
269  f.setDrawType(5);
270  f.Show();
271  }
272  }
273 }
void bgp_Click(object sender, RibbonControlEventArgs e)
Definition: Ribbon1.cs:160
static GModel Data
Definition: shapeLib.cs:42
void setDrawType(int ntype)
設定目前動作
Definition: Form1.cs:64
必要的設計工具變數。
Definition: Ribbon1.cs:13
RibbonControlEventHandler click
Definition: ShapeObj.cs:49
void addByName(RibbonControl uiobj, String name)
Definition: Ribbon1.cs:99
void green_btn_Click(object sender, RibbonControlEventArgs e)
Definition: Ribbon1.cs:192
void clear_Click(object sender, RibbonControlEventArgs e)
Definition: Ribbon1.cs:150
void setStrokeType(int ntype)
設定線條粗細
Definition: Form1.cs:90
string belong
判斷按下Button控制項
Definition: ShapeObj.cs:53
void f_Disposed(object sender, EventArgs e)
Definition: Ribbon1.cs:139
void px5_Click(object sender, RibbonControlEventArgs e)
Definition: Ribbon1.cs:232
double backGroundColor
Definition: Ribbon1.cs:16
void yellow_btn_Click(object sender, RibbonControlEventArgs e)
Definition: Ribbon1.cs:187
void px8_Click(object sender, RibbonControlEventArgs e)
Definition: Ribbon1.cs:237
internal Microsoft.Office.Tools.Ribbon.RibbonTab tab1
void initpath(string xml)
載入XML
Definition: Form1.cs:98
void px3_Click(object sender, RibbonControlEventArgs e)
Definition: Ribbon1.cs:227
void selBtn_Click(object sender, RibbonControlEventArgs e)
Definition: Ribbon1.cs:243
void px1_Click(object sender, RibbonControlEventArgs e)
Definition: Ribbon1.cs:222
void blue_btn_Click(object sender, RibbonControlEventArgs e)
Definition: Ribbon1.cs:202
void red_btn_Click(object sender, RibbonControlEventArgs e)
Definition: Ribbon1.cs:177
shapeUIType uitype
Definition: ShapeObj.cs:45
void gray_Click(object sender, RibbonControlEventArgs e)
Definition: Ribbon1.cs:212
某一類的形狀.包含UI 的界面,繪製方式.更新方式.新增方式
Definition: ShapeObj.cs:59
void ClearDrawing()
清除畫布
Definition: Form1.cs:82
void undo_Click(object sender, RibbonControlEventArgs e)
Definition: Ribbon1.cs:256
void drawBackgroundLine(double Sop)
繪製背景格線
Definition: Form1.cs:39
使UNIX上開發的C程式移植到windows上 /summary>
Definition: Form1.cs:19
IForm Check()
Definition: Ribbon1.cs:17
void setColorType(String colorName)
設定顏色
Definition: Form1.cs:74
void redo_Click(object sender, RibbonControlEventArgs e)
Definition: Ribbon1.cs:251
shapeUIType
建構不同UI 時使用
Definition: ShapeObj.cs:31
void initPath(string xml)
載入圖片
Definition: Ribbon1.cs:265
定義一個UI項目
Definition: ShapeObj.cs:42
void violet_Click(object sender, RibbonControlEventArgs e)
Definition: Ribbon1.cs:207
void Construt(ShapeObj obj)
Definition: Ribbon1.cs:38
void black_btn_Click(object sender, RibbonControlEventArgs e)
Definition: Ribbon1.cs:197
void Ribbon1_Load(object sender, RibbonUIEventArgs e)
Definition: Ribbon1.cs:144
System.Drawing.Image image
Definition: ShapeObj.cs:46
virtual System.Collections.ArrayList getMenuItem()
覆寫System.Collections.ArrayList
Definition: ShapeObj.cs:67
void white_btn_Click(object sender, RibbonControlEventArgs e)
Definition: Ribbon1.cs:217
void setAction(int act)
選擇使用Redo或Undo
Definition: Form1.cs:106
void button7_Click(object sender, RibbonControlEventArgs e)
Definition: Ribbon1.cs:182
double setFormSize(String ctype)
取得設定用的畫布大小
Definition: Form1.cs:50