My Project
ShapeCircle.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 {
13  public class ShapeCircle : ShapeObj
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 = "Circle";
24 
25  System.Reflection.Assembly myAssembly = System.Reflection.Assembly.GetExecutingAssembly();
26  System.IO.Stream myStream = myAssembly.GetManifestResourceStream("ShapeLib.icons.circle.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 
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  Ellipse myEllipse = new Ellipse();
47  // Create a SolidColorBrush with a red color to fill the
48  // Ellipse with.
49 
50  myEllipse.Stroke = new SolidColorBrush(Color.FromRgb(data.state.colorR, data.state.colorG, data.state.colorB));
51  // Set the width and height of the Ellipse.
52  myEllipse.Width = Math.Abs(data.controlBtn4.X - data.controlBtn1.X);
53  myEllipse.Height = Math.Abs(data.controlBtn4.Y- data.controlBtn1.Y);
54  myEllipse.Margin = new Thickness(data.controlBtn1.X, data.controlBtn1.Y, 0, 0);
55  myEllipse.StrokeThickness = shapeLib.Data.strokeT;
56  myEllipse.MouseLeftButtonDown += data.myLine_MouseLeftButtonDown;
57  myEllipse.MouseEnter += data.myLine_MouseEnter;
58  myEllipse.MouseLeave += data.myLine_MouseLeave;
59  shapeLib.Data.mygrid.Children.Add(myEllipse);
60  gv.baseShape.Add(myEllipse);
61  }
62  else
63  {
64  Ellipse myEllipse = (Ellipse)gv.baseShape[0];
65  myEllipse.Width = Math.Abs(data.controlBtn4.X - data.controlBtn1.X);
66  myEllipse.Height = Math.Abs(data.controlBtn4.Y - data.controlBtn1.Y);
67  myEllipse.Margin = new Thickness(data.controlBtn1.X, data.controlBtn1.Y, 0, 0);
68  }
69  }
70 
71 
72  }
73 }
static GModel Data
Definition: shapeLib.cs:42
RibbonControlEventHandler click
Definition: ShapeObj.cs:49
string belong
判斷按下Button控制項
Definition: ShapeObj.cs:53
override void DrawShape(gView gv, gPath data, Boolean bfirst)
依data 繪製,如果是第一次畫要新建shape, 更新的話只要更新最後一點
Definition: ShapeCircle.cs:40
override System.Collections.ArrayList getMenuItem()
覆寫System.Collections.ArrayList
Definition: ShapeCircle.cs:17
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
System.Drawing.Image image
Definition: ShapeObj.cs:46