My Project
ShaperightTriangle.cs
查看本檔案說明文件.
1 using System;
2 using System.Collections;
3 using System.Collections.Generic;
4 using System.Drawing;
5 using System.Linq;
6 using System.Text;
7 using System.Threading.Tasks;
8 using System.Windows;
9 using System.Windows.Media;
10 using System.Windows.Shapes;
11 
12 namespace ShapeLib.VShape
13 {
15  {
16 
17 
18  public override System.Collections.ArrayList getMenuItem()
19  {
20 
21  ArrayList ret = new ArrayList();
22 
23  shapeUI ui = new shapeUI();
24  ui.label = "Right Triangle";
25 
26  System.Reflection.Assembly myAssembly = System.Reflection.Assembly.GetExecutingAssembly();
27  System.IO.Stream myStream = myAssembly.GetManifestResourceStream("ShapeLib.icons.right-triangle.png");
28  ui.image = new System.Drawing.Bitmap(myStream);
29 
30 
31 
32  ui.belong = "Shapes";
33  ui.click = this.btn_Click;
34  ret.Add(ui);
35 
36  return ret;
37  //throw new NotImplementedException();
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  Polygon myTri = new Polygon();
48 
49  // //如果要繪製中心顏色,可開啟這段
50  SolidColorBrush mySolidColorBrush = new SolidColorBrush();
51  myTri.Stroke = new SolidColorBrush(System.Windows.Media.Color.FromRgb(data.state.colorR, data.state.colorG, data.state.colorB));
52  PointCollection Points = new PointCollection();
53  Points.Add(data.controlBtn1);
54  Points.Add(data.controlBtn3);
55  Points.Add(data.controlBtn4);
56  // Points.Add(data.controlBtn1);
57 
58 
59  myTri.Points = new PointCollection(Points);
60  myTri.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
61  myTri.VerticalAlignment = VerticalAlignment.Center;
62  myTri.StrokeThickness = shapeLib.Data.strokeT;
63  myTri.MouseLeftButtonDown += data.myLine_MouseLeftButtonDown;
64  myTri.MouseEnter += data.myLine_MouseEnter;
65  myTri.MouseLeave += data.myLine_MouseLeave;
66  shapeLib.Data.mygrid.Children.Add(myTri);
67  gv.baseShape.Add(myTri);
68 
69  }
70  else
71  {
72  Polygon myTri = (Polygon)gv.baseShape[0];// =(Line) currPath.getDrawShape();
73  PointCollection Points = new PointCollection();
74  Points.Add(data.controlBtn1);
75  Points.Add(data.controlBtn3);
76  Points.Add(data.controlBtn4);
77  // Points.Add(data.controlBtn1);
78  myTri.Points = new PointCollection(Points);
79 
80  }
81 
82 
83  // throw new NotImplementedException();
84  }
85 
86  public override void DisplayControlPoints(gView gv, gPath data)
87  {
88  if (gv.controlShape.Count == 0)
89  {
90  Polyline myTri = new Polyline();
91 
92  // //如果要繪製中心顏色,可開啟這段
93  myTri.Stroke = new SolidColorBrush(System.Windows.Media.Color.FromRgb(0, 0, 255));
94  PointCollection Points = new PointCollection();
95  Points.Add(data.controlBtn1);
96  Points.Add (data.controlBtn3);
97  Points.Add(data.controlBtn4);
98  Points.Add(data.controlBtn1);
99  myTri.Points = new PointCollection(Points);
100  myTri.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
101  myTri.VerticalAlignment = VerticalAlignment.Center;
102  myTri.StrokeThickness = shapeLib.Data.strokeT;
103  myTri.MouseLeftButtonDown += data.myLine_MouseLeftButtonDown;
104  myTri.MouseEnter += data.myLine_MouseEnter;
105  myTri.MouseLeave += data.myLine_MouseLeave;
106  shapeLib.Data.mygrid.Children.Add(myTri);
107  gv.controlShape.Add(myTri);
108 
109  }
110 
111  else
112  {
113  Polyline myTri = (Polyline)gv.controlShape[0];// =(Line) currPath.getDrawShape();
114  PointCollection Points = new PointCollection();
115  Points.Add(data.controlBtn1);
116  Points.Add(data.controlBtn3);
117  Points.Add(data.controlBtn4);
118  Points.Add(data.controlBtn1);
119 
120  myTri.Points = new PointCollection(Points);
121  }
122 
123  }
124  }
125 }
static GModel Data
Definition: shapeLib.cs:42
RibbonControlEventHandler click
Definition: ShapeObj.cs:49
string belong
判斷按下Button控制項
Definition: ShapeObj.cs:53
System.Windows.Point controlBtn3
Definition: GraphDoc.cs:255
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
定義一個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
override System.Collections.ArrayList getMenuItem()
覆寫System.Collections.ArrayList
System.Drawing.Image image
Definition: ShapeObj.cs:46
override void DisplayControlPoints(gView gv, gPath data)
override void DrawShape(gView gv, gPath data, Boolean bfirst)
依data 繪製,如果是第一次畫要新建shape, 更新的話只要更新最後一點
List< Shape > controlShape
Definition: gView.cs:13