My Project
ShapeTriangle.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 = "Triangle";
25  System.Reflection.Assembly myAssembly = System.Reflection.Assembly.GetExecutingAssembly();
26  System.IO.Stream myStream = myAssembly.GetManifestResourceStream("ShapeLib.icons.triangle.png");
27  ui.image = new System.Drawing.Bitmap(myStream);
28 
29 
30 
31  ui.belong = "Shapes";
32  ui.click = this.btn_Click;
33  ret.Add(ui);
34 
35  return ret;
36  //throw new NotImplementedException();
37  }
38 
39  public override void DrawShape(gView gv, gPath data, Boolean bfirst)
40  {
41  if (bfirst)
42  {
43  shapeLib.Data.Status = "rest";
44  shapeLib.Data.bfirst = false;
45 
46  Polygon myTri = new Polygon();
47 
48  // //如果要繪製中心顏色,可開啟這段
49  myTri.Stroke = new SolidColorBrush(System.Windows.Media.Color.FromRgb(data.state.colorR, data.state.colorG, data.state.colorB));
50  PointCollection Points = new PointCollection();
51 
52  Points.Add(new System.Windows.Point(data.controlBtn1.X + (data.controlBtn4.X - data.controlBtn1.X) / 2, data.controlBtn1.Y));
53  Points.Add(new System.Windows.Point(data.controlBtn1.X , data.controlBtn4.Y));
54  Points.Add(new System.Windows.Point(data.controlBtn4.X , data.controlBtn4.Y));
55  // Points.Add(new System.Windows.Point(data.controlBtn1.X + (data.controlBtn4.X - data.controlBtn1.X) / 2, data.controlBtn1.Y));
56 
57  myTri.Points = new PointCollection(Points);
58  myTri.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
59  myTri.VerticalAlignment = VerticalAlignment.Center;
60  myTri.StrokeThickness = shapeLib.Data.strokeT;
61  myTri.MouseLeftButtonDown += data.myLine_MouseLeftButtonDown;
62  myTri.MouseEnter += data.myLine_MouseEnter;
63  myTri.MouseLeave += data.myLine_MouseLeave;
64  shapeLib.Data.mygrid.Children.Add(myTri);
65  gv.baseShape.Add(myTri);
66 
67  }
68  else
69  {
70  Polygon myTri = (Polygon)gv.baseShape[0];// =(Line) currPath.getDrawShape();
71  PointCollection Points = new PointCollection();
72  Points.Add(new System.Windows.Point(data.controlBtn1.X + (data.controlBtn4.X - data.controlBtn1.X) / 2, data.controlBtn1.Y));
73  Points.Add(new System.Windows.Point(data.controlBtn1.X, data.controlBtn4.Y));
74  Points.Add(new System.Windows.Point(data.controlBtn4.X, data.controlBtn4.Y));
75  // Points.Add(new System.Windows.Point(data.controlBtn1.X + (data.controlBtn4.X - data.controlBtn1.X) / 2, data.controlBtn1.Y));
76  myTri.Points = new PointCollection(Points);
77 
78  }
79 
80 
81  // throw new NotImplementedException();
82  }
83 
84  public override void DisplayControlPoints(gView gv, gPath data)
85  {
86  if (gv.controlShape.Count == 0)
87  {
88  Polyline myTri = new Polyline();
89 
90  // //如果要繪製中心顏色,可開啟這段
91  myTri.Stroke = new SolidColorBrush(System.Windows.Media.Color.FromRgb(255, 255, 0));
92  PointCollection Points = new PointCollection();
93  Points.Add(new System.Windows.Point(data.controlBtn1.X + (data.controlBtn4.X - data.controlBtn1.X) / 2, data.controlBtn1.Y));
94  Points.Add(new System.Windows.Point(data.controlBtn1.X, data.controlBtn4.Y));
95  Points.Add(new System.Windows.Point(data.controlBtn4.X, data.controlBtn4.Y));
96  Points.Add(new System.Windows.Point(data.controlBtn1.X + (data.controlBtn4.X - data.controlBtn1.X) / 2, data.controlBtn1.Y));
97  myTri.Points = new PointCollection(Points);
98  myTri.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
99  myTri.VerticalAlignment = VerticalAlignment.Center;
100  myTri.StrokeThickness = shapeLib.Data.strokeT;
101  myTri.MouseLeftButtonDown += data.myLine_MouseLeftButtonDown;
102  myTri.MouseEnter += data.myLine_MouseEnter;
103  myTri.MouseLeave += data.myLine_MouseLeave;
104  shapeLib.Data.mygrid.Children.Add(myTri);
105  gv.controlShape.Add(myTri);
106 
107  }
108 
109  else
110  {
111  Polyline myTri = (Polyline)gv.controlShape[0];// =(Line) currPath.getDrawShape();
112  PointCollection Points = new PointCollection();
113  Points.Add(new System.Windows.Point(data.controlBtn1.X + (data.controlBtn4.X - data.controlBtn1.X) / 2, data.controlBtn1.Y));
114  Points.Add(new System.Windows.Point(data.controlBtn1.X, data.controlBtn4.Y));
115  Points.Add(new System.Windows.Point(data.controlBtn4.X, data.controlBtn4.Y));
116  Points.Add(new System.Windows.Point(data.controlBtn1.X + (data.controlBtn4.X - data.controlBtn1.X) / 2, data.controlBtn1.Y));
117  myTri.Points = new PointCollection(Points);
118  }
119 
120  }
121  }
122 }
override void DisplayControlPoints(gView gv, gPath data)
static GModel Data
Definition: shapeLib.cs:42
RibbonControlEventHandler click
Definition: ShapeObj.cs:49
string belong
判斷按下Button控制項
Definition: ShapeObj.cs:53
override System.Collections.ArrayList getMenuItem()
覆寫System.Collections.ArrayList
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
override void DrawShape(gView gv, gPath data, Boolean bfirst)
依data 繪製,如果是第一次畫要新建shape, 更新的話只要更新最後一點
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