static public void UP(object sender, MouseEventArgs e) { mousePosition = e.Location; isRoomSelected = false; switch (Mode) { case modePlacement.moveVinosku: Mode = modePlacement.doNothing_NOSCALEMODE; break; case modePlacement.dragVertex: Mode = modePlacement.doNothing_NOSCALEMODE; break; case modePlacement.moveRoom: Mode = modePlacement.doNothing_NOSCALEMODE; break; case modePlacement.dragShkaf: Mode = modePlacement.doNothing_NOSCALEMODE; break; case modePlacement.scaleSomething: Mode = modePlacement.doNothing_SCALEMODE; break; } }
static public void DOWN(object sender, MouseEventArgs e) { mousePosition = e.Location; if (e.Button == MouseButtons.Right) { movable = null; isDrawSelected = false; if (isWireSelected) { movable = Schemes_Editor.wires[SelectedWireIndex]; ContextMenu menushka = new ContextMenu(new MenuItem[] { new MenuItem("Добавить выноску", handler), new MenuItem("Удалить", handler), new MenuItem("Удалить узел", handler), new MenuItem("Изменить название", handler) }); menushka.Show(father.pictureBox3, e.Location); return; } for (int i = Schemes_Editor.mainWorkList.Count - 1; i > -1; i--) { if (Schemes_Editor.mainWorkList[i].inside(e.Location, localSheet)) { if (Schemes_Editor.mainWorkList[i] is boxes) { movable = Schemes_Editor.mainWorkList[i]; isDrawSelected = true; ContextMenu menushka = new ContextMenu(new MenuItem[] { new MenuItem("Добавить выноску", handler), new MenuItem("Копировать", handler), new MenuItem("Удалить", handler), new MenuItem("Изменить название", handler) }); menushka.Show(father.pictureBox3, e.Location); return; } if (Schemes_Editor.mainWorkList[i] is free) { movable = Schemes_Editor.mainWorkList[i]; isDrawSelected = true; ContextMenu menushka = new ContextMenu(new MenuItem[] { new MenuItem("Добавить выноску", handler), new MenuItem("Копировать", handler), new MenuItem("Удалить", handler), new MenuItem("Изменить название", handler) }); menushka.Show(father.pictureBox3, e.Location); return; } break; } } for (int i = 0; i < Schemes_Editor.rooms.Count; i++) { if (Schemes_Editor.rooms[i].inside(e.Location, localSheet)) { isRoomSelected = true; movable = Schemes_Editor.rooms[i]; ContextMenu menushka = new ContextMenu(new MenuItem[] { new MenuItem("Удалить", handler), new MenuItem("Изменить название", handler) }); menushka.Show(father.pictureBox3, e.Location); return; } } } else { switch (Mode) { case modePlacement.doNothing_NOSCALEMODE: movable = null; isRoomSelected = false; if (isWireSelected) { var t = Schemes_Editor.wires[SelectedWireIndex].inside(localSheet, e.Location); if (t.isExists) { VertexNumber = t.ExistingIndex; if (VertexNumber != -1) { Mode = modePlacement.dragVertex; movable = 1; } } else //создать новую опорную точку { VertexNumber = Schemes_Editor.wires[SelectedWireIndex].insertPoint(t.vertex, localSheet); if (VertexNumber != -1) { Mode = modePlacement.dragVertex; movable = 1; } } } if (movable != null) { break; } for (int i = Schemes_Editor.mainWorkList.Count - 1; i > -1; i--) { if (Schemes_Editor.mainWorkList[i].inside(e.Location, localSheet)) { if (Schemes_Editor.mainWorkList[i] is boxes) { Prev = new Point(e.Location.X - ((boxes)Schemes_Editor.mainWorkList[i]).locations[localSheet].X, e.Location.Y - ((boxes)Schemes_Editor.mainWorkList[i]).locations[localSheet].Y); Mode = modePlacement.dragShkaf; movable = Schemes_Editor.mainWorkList[i]; break; } if (Schemes_Editor.mainWorkList[i] is free) { Prev = new Point(e.Location.X - ((free)Schemes_Editor.mainWorkList[i]).locations[localSheet].X, e.Location.Y - ((free)Schemes_Editor.mainWorkList[i]).locations[localSheet].Y); Mode = modePlacement.dragShkaf; movable = Schemes_Editor.mainWorkList[i]; break; } } } if (movable != null) { break; } else { for (int i = 0; i < Schemes_Editor.rooms.Count; i++) { if (Schemes_Editor.rooms[i].inside(e.Location, localSheet)) { isRoomSelected = true; Prev = new Point(e.Location.X - Schemes_Editor.rooms[i].locations[localSheet].X, e.Location.Y - Schemes_Editor.rooms[i].locations[localSheet].Y); movable = Schemes_Editor.rooms[i]; Mode = modePlacement.moveRoom; } } } break; case modePlacement.doNothing_SCALEMODE: moveTargetIndex = -1; isRoomSelected = false; for (int i = 0; i < Schemes_Editor.mainWorkList.Count; i++) { //if (Schemes_Editor.mainWorkList[i] is wire_s) // continue; if (Schemes_Editor.mainWorkList[i] is inboxes) { continue; } int a = Schemes_Editor.mainWorkList[i].locations[localSheet].X, b = Schemes_Editor.mainWorkList[i].locations[localSheet].Y, c = Schemes_Editor.mainWorkList[i].locations[localSheet].X + Schemes_Editor.mainWorkList[i].scales[localSheet].X, d = Schemes_Editor.mainWorkList[i].locations[localSheet].Y + Schemes_Editor.mainWorkList[i].scales[localSheet].Y; if (Schemes_Editor.distance(new Point(a, b), e.Location) < 20) { scalePoint = new Point(a, b); moveTargetIndex = i; pointNum = 0; Mode = modePlacement.scaleSomething; break; } if (Schemes_Editor.distance(new Point(a, d), e.Location) < 20) { scalePoint = new Point(a, d); moveTargetIndex = i; pointNum = 3; Mode = modePlacement.scaleSomething; break; } if (Schemes_Editor.distance(new Point(c, b), e.Location) < 20) { scalePoint = new Point(c, b); moveTargetIndex = i; pointNum = 1; Mode = modePlacement.scaleSomething; break; } if (Schemes_Editor.distance(new Point(c, d), e.Location) < 20) { scalePoint = new Point(c, d); moveTargetIndex = i; pointNum = 2; Mode = modePlacement.scaleSomething; break; } } if (moveTargetIndex != -1) { break; } else { for (int i = 0; i < Schemes_Editor.rooms.Count; i++) { int a = Schemes_Editor.rooms[i].locations[localSheet].X, b = Schemes_Editor.rooms[i].locations[localSheet].Y, c = Schemes_Editor.rooms[i].locations[localSheet].X + Schemes_Editor.rooms[i].locations[localSheet].Width, d = Schemes_Editor.rooms[i].locations[localSheet].Y + Schemes_Editor.rooms[i].locations[localSheet].Height; if (Schemes_Editor.distance(new Point(a, b), e.Location) < 20) { isRoomSelected = true; scalePoint = new Point(a, b); moveTargetIndex = i; pointNum = 0; Mode = modePlacement.scaleSomething; break; } if (Schemes_Editor.distance(new Point(a, d), e.Location) < 20) { isRoomSelected = true; scalePoint = new Point(a, d); moveTargetIndex = i; pointNum = 3; Mode = modePlacement.scaleSomething; break; } if (Schemes_Editor.distance(new Point(c, b), e.Location) < 20) { isRoomSelected = true; scalePoint = new Point(c, b); moveTargetIndex = i; pointNum = 1; Mode = modePlacement.scaleSomething; break; } if (Schemes_Editor.distance(new Point(c, d), e.Location) < 20) { isRoomSelected = true; scalePoint = new Point(c, d); moveTargetIndex = i; pointNum = 2; Mode = modePlacement.scaleSomething; break; } } } break; } } }
private static void handler(object sender, EventArgs e) { if (isDrawSelected) { switch (((MenuItem)sender).Text) { case "Изменить название": RoomCreator cr = new RoomCreator(); if (cr.ShowDialog() == DialogResult.OK) { movable.labels[localSheet] = cr.roomName; } break; case "Добавить выноску": ((drawer)movable).createVinosku(localSheet); movable = ((drawer)movable); Mode = modePlacement.moveVinosku; break; case "Копировать": father.copy(movable.globalId, movable); break; case "Удалить": foreach (var i in Schemes_Editor.wires) { if (i.firstEquip.localID == ((drawer)movable).localID) { var t = ((Wire)movable); if (t.firstEquip is inboxes) { ((inboxes)t.firstEquip).seized[Schemes_Editor.mainList.Find(x => x.id == ((inboxes)t.firstEquip).globalId).compatibilities.FindIndex(x => x.interfaceType.id == t.OtherFirst.interfaceType.id)]--; } if (t.secondEquip is inboxes) { ((inboxes)t.secondEquip).seized[Schemes_Editor.mainList.Find(x => x.id == ((inboxes)t.secondEquip).globalId).compatibilities.FindIndex(x => x.interfaceType.id == t.OtherSecond.interfaceType.id)]--; } Schemes_Editor.wires.RemoveAll(x => x.localID == t.localID); } if (i.secondEquip.localID == ((drawer)movable).localID) { var t = ((Wire)movable); if (t.firstEquip is inboxes) { ((inboxes)t.firstEquip).seized[Schemes_Editor.mainList.Find(x => x.id == ((inboxes)t.firstEquip).globalId).compatibilities.FindIndex(x => x.interfaceType.id == t.OtherFirst.interfaceType.id)]--; } if (t.secondEquip is inboxes) { ((inboxes)t.secondEquip).seized[Schemes_Editor.mainList.Find(x => x.id == ((inboxes)t.secondEquip).globalId).compatibilities.FindIndex(x => x.interfaceType.id == t.OtherSecond.interfaceType.id)]--; } Schemes_Editor.wires.RemoveAll(x => x.localID == t.localID); } Schemes_Editor.mainWorkList.RemoveAll(x => x.localID == ((drawer)movable).localID); } break; } } if (isRoomSelected) { switch (((MenuItem)sender).Text) { case "Изменить название": RoomCreator cr = new RoomCreator(); if (cr.ShowDialog() == DialogResult.OK) { movable.labels[localSheet] = cr.roomName; } break; case "Удалить": var t = ((Wire)movable); if (t.firstEquip is inboxes) { ((inboxes)t.firstEquip).seized[Schemes_Editor.mainList.Find(x => x.id == ((inboxes)t.firstEquip).globalId).compatibilities.FindIndex(x => x.interfaceType.id == t.OtherFirst.interfaceType.id)]--; } if (t.secondEquip is inboxes) { ((inboxes)t.secondEquip).seized[Schemes_Editor.mainList.Find(x => x.id == ((inboxes)t.secondEquip).globalId).compatibilities.FindIndex(x => x.interfaceType.id == t.OtherSecond.interfaceType.id)]--; } Schemes_Editor.wires.RemoveAll(x => x.localID == t.localID); break; } } if (isWireSelected) { switch (((MenuItem)sender).Text) { case "Изменить название": RoomCreator cr = new RoomCreator(); if (cr.ShowDialog() == DialogResult.OK) { movable.labels[localSheet] = cr.roomName; } break; case "Добавить выноску": Schemes_Editor.wires[SelectedWireIndex].createVinosku(Schemes_Editor.wires[SelectedWireIndex].inside(localSheet, mousePosition).vertex, localSheet); movable = Schemes_Editor.wires[SelectedWireIndex]; Mode = modePlacement.moveVinosku; break; case "Удалить": var t = ((Wire)movable); if (t.firstEquip is inboxes) { ((inboxes)t.firstEquip).seized[Schemes_Editor.mainList.Find(x => x.id == ((inboxes)t.firstEquip).globalId).compatibilities.FindIndex(x => x.interfaceType.id == t.OtherFirst.interfaceType.id)]--; } if (t.secondEquip is inboxes) { ((inboxes)t.secondEquip).seized[Schemes_Editor.mainList.Find(x => x.id == ((inboxes)t.secondEquip).globalId).compatibilities.FindIndex(x => x.interfaceType.id == t.OtherSecond.interfaceType.id)]--; } Schemes_Editor.wires.RemoveAll(x => x.localID == t.localID); break; case "Удалить узел": var tt = ((Wire)movable).inside(localSheet, mousePosition); if (tt.vertex.X != -1 && tt.isExists) { ((Wire)movable).points[localSheet].RemoveAll(x => x.X == tt.vertex.X && x.Y == tt.vertex.Y); } break; } } }