public Option(TextBox bind, string objBind, Props bind_property, bool Ray = false) { if (bind_property != Props.Name) { IsDouble = true; } else { IsDouble = false; } if (IsDouble) { param = "0,000000"; } else { param = ""; } boundTextBox = bind; if (Ray) { boundObj = ObjectCollection.Instance.GetRayByName(objBind); } else { boundObj = ObjectCollection.Instance.GetObjectByName(objBind); } bind_p = bind_property; boundTextBox.Leave += new EventHandler(boundTextBox_Leave); boundTextBox.KeyUp += new KeyEventHandler(boundTextBox_KeyUp); boundObj.ObjectChanged += new EventHandler <EventArgs>(boundObj_ObjectChanged); prevtext = ""; }
public override void Action(Point cursorCoordinates) { if (counter == 0) { p1 = cursorCoordinates; var a = ObjectCollection.Instance.objects; foreach (var b in a) { if (b is BrightPoint) { if (b.DistanceToPointS(p1) <= 6) { bound = (BrightPoint)b; } } } if (bound == null) { GenNew = true; bound = new BrightPoint(ObjectProto.GenName(ObjectProto.GetSpec(ObjectTypes.BrightPoint)), p1); } else { p1 = bound.Coordinates; } counter++; } else { p2 = cursorCoordinates; counter = 2; CodeFunctions.CreateRay(p1, p2, bound, GenNew); Deactivate(); } }
private void contextMenuStrip1_Opening(object sender, CancelEventArgs e) { //TODO: Generate context menu for the main display if (!(activeInstrument is InstrumentSelectAndMove)) { e.Cancel = true; return; } SelectedItem = X.Select(simpleGL1.PointToClient(MousePosition)); if (SelectedItem != null) { contextMenuStrip1.Items.Clear(); ToolStripItem x = contextMenuStrip1.Items.Add(SelectedItem.Name); x.Enabled = false; ToolStripItem z = contextMenuStrip1.Items.Add(STranslation.T["RemoveObject"], null, x_MouseUp); x.Click += new EventHandler(x_MouseUp); z = contextMenuStrip1.Items.Add(STranslation.T["Copy"], null, z_MouseUp); } else { contextMenuStrip1.Items.Clear(); ToolStripItem z = contextMenuStrip1.Items.Add(STranslation.T["Pastle"], null, p_MouseUp); if (PastleObj == null) { z.Enabled = false; } //ToolStripItem x = contextMenuStrip1.Items.Add("null"); //x.Enabled = false; } }
void z_MouseUp(object sender, EventArgs e) { PastleObj = SelectedItem; string h = PastleObj.GenerateSaveString(); PastleObj = SaveLoad.Instance.ConstructObject(PastleObj.GetTypeSpecifier(), h); }
private void copyToolStripMenuItem_Click(object sender, EventArgs e) { if (SelectedItem != null) { PastleObj = SelectedItem; string h = PastleObj.GenerateSaveString(); PastleObj = SaveLoad.Instance.ConstructObject(PastleObj.GetTypeSpecifier(), h); } }
public Option(ComboBox bind, string objBind, Props bind_property) { IsCombo = true; boundComboBox = bind; boundObj = ObjectCollection.Instance.GetObjectByName(objBind); boundComboBox.SelectedIndexChanged += new EventHandler(boundComboBox_SelectedIndexChanged); boundObj.ObjectChanged += new EventHandler <EventArgs>(boundObj_ObjectChanged); bind_p = bind_property; prevtext = ""; }
void Instance_OnSelectedChange(object sender, SelectedChangeArgs e) { //groupBox1.Controls.Clear(); SelectedItem = e.NewItem; if (e.NewItem == null) { return; } if (e.NewItem is Mirror) { } }
private void simpleGL1_MouseDown(object sender, MouseEventArgs e) { if (activeInstrument is InstrumentHand && e.Button == MouseButtons.Left) { key_down = true; } if (activeInstrument is InstrumentSelectAndMove && e.Button == MouseButtons.Left) { SelectedItem = ObjectCollection.Instance.Select(e.Location); key_down = true; } }
void groupBox1_OnUserSelect(object sender, EventArgs e) { if (groupBox1.selected_name != null) { if (groupBox1.is_ray) { SelectedItem = ObjectCollection.Instance.Select(X.GetRayByName(groupBox1.selected_name), false); } else { SelectedItem = ObjectCollection.Instance.Select(X.GetObjectByName(groupBox1.selected_name), false); } } }
private void simpleGL1_MouseUp(object sender, MouseEventArgs e) { key_down = false; if (e.Button == MouseButtons.Left) { activeInstrument.Action(new Point(e.X, e.Y)); if (activeInstrument is InstrumentSelectAndMove) { SelectedItem = X.Select(new Point(e.X, e.Y)); } prev_point_set = false; } cursor_c = new Point(e.X, e.Y); }
public override void Action(Point cursorCoordinates) { if (count == 0) { p1 = cursorCoordinates; count++; } else { if (count == 1 && cursorCoordinates != p1.ToScreen()) { p2 = cursorCoordinates; count++; } else { if (count == 2 && cursorCoordinates != p1.ToScreen() && cursorCoordinates != p2.ToScreen()) { p3 = cursorCoordinates; count++; } else if (count == 3 && cursorCoordinates != p1.ToScreen() && cursorCoordinates != p2.ToScreen() && cursorCoordinates != p3.ToScreen()) { if (!(SystemCoordinates.InOneLine(p1, p3, p2) && SystemCoordinates.InOneLine(p1, cursorCoordinates, p2))) { p4 = cursorCoordinates; count++; } } if (count == 4) { Line aa = new Line(p1, p2, false); ObjectCollection.Instance.AddObject( new Lense(ObjectProto.GenName(ObjectProto.GetSpec(ObjectTypes.Lense)), aa.Center, p1, p3, p2, p1, p4, p2)); Deactivate(); } } } }
private void pastleToolStripMenuItem_Click(object sender, EventArgs e) { if (PastleObj != null) { string h = PastleObj.GenerateSaveString(); PastleObj = SaveLoad.Instance.ConstructObject(PastleObj.GetTypeSpecifier(), h); PastleObj.Name = ObjectProto.GenName(PastleObj.GetTypeSpecifier(), PastleObj.GetTypeSpecifier() == ObjectProto.GetSpec(ObjectTypes.Ray)); int id = -1; if (!(PastleObj is Ray)) { ObjectCollection.Instance.AddObject(PastleObj); } else { ((Ray)PastleObj).Angle = new Angle(((Ray)PastleObj).Angle.GetInDegrees() + 30, false); id = ObjectCollection.Instance.AddRay(PastleObj.Name, PastleObj.Coordinates, ((Ray)PastleObj).Angle, ((Ray)PastleObj).BoundPoint, true); } if (PastleObj is Ray) { SelectedItem = ObjectCollection.Instance.Select(ObjectCollection.Instance.GetRayByID(id)); } else { SelectedItem = ObjectCollection.Instance.Select(PastleObj); } if (!(PastleObj is Ray)) { SystemCoordinates tmp = new SystemCoordinates(PastleObj.Coordinates); Point X = tmp; X.X += 10; X.Y += 10; PastleObj.Coordinates = new SystemCoordinates(X); } PastleObj = SaveLoad.Instance.ConstructObject(PastleObj.GetTypeSpecifier(), PastleObj.GenerateSaveString()); } }
public override void Action(Point cursorCoordinates) { if (count == 0) { c1 = cursorCoordinates; count++; } else if (count == 1 && c1.ToScreen() != cursorCoordinates) { c2 = cursorCoordinates; count++; } else if (count == 2 && c1.ToScreen() != cursorCoordinates && c2.ToScreen() != cursorCoordinates && !SystemCoordinates.InOneLine(c1, c2, cursorCoordinates)) { c3 = cursorCoordinates; count++; Circle a = new Circle(c1, c3, c2); ObjectCollection.Instance.AddObject( new SphereMirror(ObjectProto.GenName(ObjectProto.GetSpec(ObjectTypes.SphereMirror)), a.Center, a.Radius, c1, c3, c2, control_modifier)); Deactivate(); } }
public static void AddSphere(SystemCoordinates c, DoubleExtention l) { string name = ObjectProto.GenName(ObjectProto.GetSpec(ObjectTypes.Sphere)); ObjectCollection.Instance.AddObject(new Sphere(name, c, l, 1.2)); }
public static void AddPoly(SystemCoordinates[] x) { string name = ObjectProto.GenName(ObjectProto.GetSpec(ObjectTypes.Polygon)); ObjectCollection.Instance.AddObject(new OPolygon(new Polygon(x), 1.2, name)); }
public static void CreateRay(Point p1, Point p2, BrightPoint bpoint, bool GenNew) { string s1 = ObjectProto.GenName(ObjectProto.GetSpec(ObjectTypes.Ray), true); ObjectCollection.Instance.AddRay(s1, p1, p2, bpoint, GenNew); }
private void Form1_KeyUp(object sender, KeyEventArgs e) { SaveLoad.Instance.HookManager_KeyUp(sender, e); if (e.KeyCode == Keys.Escape) { if (!(activeInstrument is InstrumentSelectAndMove)) { SelectNewInstrument(InstrumentSelectAndMove.Instance); } } if (e.KeyCode == System.Windows.Forms.Keys.LControlKey || e.KeyCode == System.Windows.Forms.Keys.RControlKey || e.KeyCode == System.Windows.Forms.Keys.ControlKey) { ctrl = false; } if (ctrl && e.KeyCode == Keys.C && SelectedItem != null) { PastleObj = SelectedItem; string h = PastleObj.GenerateSaveString(); PastleObj = SaveLoad.Instance.ConstructObject(PastleObj.GetTypeSpecifier(), h); } if (ctrl && e.KeyCode == Keys.V && PastleObj != null) { string h = PastleObj.GenerateSaveString(); PastleObj = SaveLoad.Instance.ConstructObject(PastleObj.GetTypeSpecifier(), h); PastleObj.Name = ObjectProto.GenName(PastleObj.GetTypeSpecifier(), PastleObj.GetTypeSpecifier() == ObjectProto.GetSpec(ObjectTypes.Ray)); int id = -1; if (!(PastleObj is Ray)) { ObjectCollection.Instance.AddObject(PastleObj); } else { ((Ray)PastleObj).Angle = new Angle(((Ray)PastleObj).Angle.GetInDegrees() + 30, false); id = ObjectCollection.Instance.AddRay(PastleObj.Name, PastleObj.Coordinates, ((Ray)PastleObj).Angle, ((Ray)PastleObj).BoundPoint, true); } if (PastleObj is Ray) { SelectedItem = ObjectCollection.Instance.Select(ObjectCollection.Instance.GetRayByID(id)); } else { SelectedItem = ObjectCollection.Instance.Select(PastleObj); } if (!(PastleObj is Ray)) { SystemCoordinates tmp = new SystemCoordinates(PastleObj.Coordinates); Point X = tmp; X.X += 10; X.Y += 10; PastleObj.Coordinates = new SystemCoordinates(X); } PastleObj = SaveLoad.Instance.ConstructObject(PastleObj.GetTypeSpecifier(), PastleObj.GenerateSaveString()); } if (SelectedItem != null && e.KeyCode == Keys.Delete) { X.DeleteObjectRay(SelectedItem); } /*if (e.KeyCode == System.Windows.Forms.Keys.LControlKey || e.KeyCode == System.Windows.Forms.Keys.RControlKey || e.KeyCode == System.Windows.Forms.Keys.ControlKey) * ((InstrumentMirror)instruments_bindage[pictureBox3]).ControlPressed(false);*/ }
public static void AddBrightPoint(SystemCoordinates c) { string s1 = ObjectProto.GenName(ObjectProto.GetSpec(ObjectTypes.BrightPoint)); ObjectCollection.Instance.AddObject(new BrightPoint(s1, c)); }
public override void Action(Point cursorCoordinates) { if (count == 0) { p1 = cursorCoordinates; count++; } else if (count == 1 && cursorCoordinates != p1.ToScreen()) { p2 = cursorCoordinates; count++; } else if (count == 2 && cursorCoordinates != p1.ToScreen() && cursorCoordinates != p2.ToScreen()) { Line x = p1 + p2; DoubleExtention l = x.DistanceToPoint(cursorCoordinates); Line z = x.BuildOrthogonalLine(p2); z.BuildAngle(); if (z.AngleForOnePointLines == new Angle(90, false) || z.AngleForOnePointLines == new Angle(90, false)) { z.FirstEnd = new SystemCoordinates(p2.X, p2.Y + l); z.SecondEnd = new SystemCoordinates(p2.X, p2.Y - l); } else { z.FirstEnd = new SystemCoordinates(p2.X + l * z.AngleForOnePointLines.cos(), p2.Y + l * z.AngleForOnePointLines.sin()); z.SecondEnd = new SystemCoordinates(p2.X - l * z.AngleForOnePointLines.cos(), p2.Y + l * z.AngleForOnePointLines.sin()); } Line u = x.BuildOrthogonalLine(p1); u.BuildAngle(); if (u.AngleForOnePointLines == new Angle(90, false) || u.AngleForOnePointLines == new Angle(90, false)) { u.FirstEnd = new SystemCoordinates(p1.X, p1.Y + l); u.SecondEnd = new SystemCoordinates(p1.X, p1.Y - l); } else { u.FirstEnd = new SystemCoordinates(p1.X + l * u.AngleForOnePointLines.cos(), p1.Y + l * u.AngleForOnePointLines.sin()); u.SecondEnd = new SystemCoordinates(p1.X - l * u.AngleForOnePointLines.cos(), p1.Y + l * u.AngleForOnePointLines.sin()); } p1 = z.FirstEnd; p3 = z.SecondEnd; p4 = u.FirstEnd; p6 = u.SecondEnd; count++; } else if (count == 3 && cursorCoordinates != p1.ToScreen() && cursorCoordinates != p3.ToScreen() && cursorCoordinates != p4.ToScreen() && cursorCoordinates != p6.ToScreen()) { p2 = cursorCoordinates; count++; } else if (count == 4 && cursorCoordinates != p1.ToScreen() && cursorCoordinates != p3.ToScreen() && cursorCoordinates != p4.ToScreen() && cursorCoordinates != p6.ToScreen() && p2.ToScreen() != cursorCoordinates) { p5 = cursorCoordinates; count++; } if (count == 5) { SystemCoordinates center; if (p1.Distance(p4) > p1.Distance(p6)) { Line z = new Line(p1, p4, false); Line u = new Line(p3, p6, false); bool isect, equal; center = z.IntersectWithLine(u, out isect, out equal); } else { Line z = new Line(p1, p6, false); Line u = new Line(p3, p4, false); bool isect, equal; center = z.IntersectWithLine(u, out isect, out equal); } if (p1.Distance(p4) < p1.Distance(p6)) { ObjectCollection.Instance.AddObject( new Lense(ObjectProto.GenName(ObjectProto.GetSpec(ObjectTypes.Lense)), center, p1, p2, p4, p3, p5, p6)); } else { ObjectCollection.Instance.AddObject( new Lense(ObjectProto.GenName(ObjectProto.GetSpec(ObjectTypes.Lense)), center, p1, p2, p6, p3, p5, p4)); } Deactivate(); } }
public static void AddMirror(SystemCoordinates c, Angle a, DoubleExtention Length) { string s1 = ObjectProto.GenName(ObjectProto.GetSpec(ObjectTypes.Mirror)); ObjectCollection.Instance.AddObject(new Mirror(s1, c, a, Length)); }