My Project
ShapeRectangle.cs
查看本檔案說明文件.
1 using System;
2 using System.Collections;
3 using System.Collections.Generic;
4 using System.Linq;
5 using System.Text;
6 using System.Threading.Tasks;
7 using System.Windows;
8 using System.Windows.Media;
9 using System.Windows.Shapes;
10 
11 namespace ShapeLib.VShape
12 {
14  {
15 
16 
17  public override System.Collections.ArrayList getMenuItem()
18  {
19 
20  ArrayList ret = new ArrayList();
21 
22  shapeUI ui = new shapeUI();
23  ui.label = "Rectangle";
24 
25  System.Reflection.Assembly myAssembly = System.Reflection.Assembly.GetExecutingAssembly();
26  System.IO.Stream myStream = myAssembly.GetManifestResourceStream("ShapeLib.icons.rectangle.png");
27  ui.image = new System.Drawing.Bitmap(myStream);
28 
29 
30  ui.belong = "Shapes";
31  ui.click = this.btn_Click;
32  ret.Add(ui);
33 
34  return ret;
35  //throw new NotImplementedException();
36  }
37 
38 
39 
40  public override void DrawShape(gView gv, gPath data, Boolean bfirst)
41  {
42  if (bfirst)
43  {
44  shapeLib.Data.Status = "rest";
45  shapeLib.Data.bfirst = false;
46 
47  Rectangle myRect = new Rectangle();
48 
49  //如果要繪製中心顏色,可開啟這段
50  myRect.Stroke = new SolidColorBrush(System.Windows.Media.Color.FromRgb(data.state.colorR, data.state.colorG, data.state.colorB));
51  myRect.Width = Math.Abs(data.controlBtn4.X - data.controlBtn1.X);
52  myRect.Height = Math.Abs(data.controlBtn4.Y - data.controlBtn1.Y);
53  myRect.Margin = new Thickness(data.controlBtn1.X, data.controlBtn1.Y, 0, 0);
54  myRect.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
55  myRect.VerticalAlignment = VerticalAlignment.Center;
56  myRect.MouseLeftButtonDown += data.myLine_MouseLeftButtonDown;
57  myRect.MouseEnter += data.myLine_MouseEnter;
58  myRect.MouseLeave += data.myLine_MouseLeave;
59  myRect.StrokeThickness = shapeLib.Data.strokeT;
60  myRect.MouseLeftButtonDown += data.myLine_MouseLeftButtonDown;
61  shapeLib.Data.mygrid.Children.Add(myRect);
62  gv.baseShape.Add(myRect);
63 
64 
65  }
66  else
67  {
68  Rectangle myRect = (Rectangle)gv.baseShape[0];// =(Line) currPath.getDrawShape();
69  myRect.Width = Math.Abs(data.controlBtn4.X - data.controlBtn1.X);
70  myRect.Height = Math.Abs(data.controlBtn4.Y - data.controlBtn1.Y);
71  myRect.Margin = new Thickness(data.controlBtn1.X, data.controlBtn1.Y, 0, 0);
72 
73  }
74 
75 
76  // throw new NotImplementedException();
77  }
78 
79  public override void DisplayControlPoints(gView gv, gPath data)
80  {
81  if (gv.controlShape.Count == 0)
82  {
83  Rectangle myRect = new Rectangle();
84  myRect.Stroke = new SolidColorBrush(System.Windows.Media.Color.FromRgb(255, 0, 0));
85  myRect.Width = Math.Abs(data.controlBtn4.X - data.controlBtn1.X);
86  myRect.Height = Math.Abs(data.controlBtn4.Y - data.controlBtn1.Y);
87  myRect.Margin = new Thickness(data.controlBtn1.X, data.controlBtn1.Y, 0, 0);
88  myRect.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
89  myRect.VerticalAlignment = VerticalAlignment.Center;
90  myRect.StrokeThickness = shapeLib.Data.strokeT;
91  myRect.MouseLeftButtonDown += data.myLine_MouseLeftButtonDown;
92  myRect.MouseEnter += data.myLine_MouseEnter;
93  myRect.MouseLeave += data.myLine_MouseLeave;
94  shapeLib.Data.mygrid.Children.Add(myRect);
95  gv.controlShape.Add(myRect);
96 
97 
98  }
99  else
100  {
101  Rectangle myRect = (Rectangle)gv.controlShape[0];
102  myRect.Width = Math.Abs(data.controlBtn4.X - data.controlBtn1.X);
103  myRect.Height = Math.Abs(data.controlBtn4.Y - data.controlBtn1.Y);
104  myRect.Margin = new Thickness(data.controlBtn1.X, data.controlBtn1.Y, 0, 0);
105 
106  }
107  }
108 
109  }
110 }
static GModel Data
Definition: shapeLib.cs:42
RibbonControlEventHandler click
Definition: ShapeObj.cs:49
override System.Collections.ArrayList getMenuItem()
覆寫System.Collections.ArrayList
string belong
判斷按下Button控制項
Definition: ShapeObj.cs:53
override void DisplayControlPoints(gView gv, gPath data)
System.Windows.Point controlBtn4
Definition: GraphDoc.cs:256
某一類的形狀.包含UI 的界面,繪製方式.更新方式.新增方式
Definition: ShapeObj.cs:59
void myLine_MouseEnter(object sender, System.Windows.Input.MouseEventArgs e)
Definition: GraphDoc.cs:392
void myLine_MouseLeave(object sender, System.Windows.Input.MouseEventArgs e)
Definition: GraphDoc.cs:427
override void DrawShape(gView gv, gPath data, Boolean bfirst)
依data 繪製,如果是第一次畫要新建shape, 更新的話只要更新最後一點
定義一個UI項目
Definition: ShapeObj.cs:42
List< Shape > baseShape
Definition: gView.cs:12
System.Windows.Point controlBtn1
Definition: GraphDoc.cs:253
void myLine_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
Definition: GraphDoc.cs:435
void btn_Click(object sender, RibbonControlEventArgs e)
UI 點選
Definition: ShapeObj.cs:107
System.Drawing.Image image
Definition: ShapeObj.cs:46
List< Shape > controlShape
Definition: gView.cs:13