Пример #1
0
        private void DeleteRectBlue(RectangleBlue Rect)
        {
            CmdDeleteRectangleBlue CmdDeleteRect = new CmdDeleteRectangleBlue();

            CmdDeleteRect.Execute(Rect);
            CmdDeleteRect.hierarchyID = Rect.HierarchyID;
        }
Пример #2
0
        private void DeleteRectBlue_Inverse(RectangleBlue Rect)
        {
            CmdDeleteRectangleBlue CmdDeleteRect = new CmdDeleteRectangleBlue();

            CmdDeleteRect.Unexecute(Rect);
            Objects.Add(Rect);
            CmdDeleteRect.hierarchyID = Rect.HierarchyID;
        }
Пример #3
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            this.IsChecked_btnRectRed  = false;
            this.IsChecked_btnRectBlue = false;
            this.IsChecked_btnSelect   = false;

            if (Selected.Count == 1)
            {
                for (int i = 0; i < Objects.Count; i++)
                {
                    if (Selected[0] == Objects[i])
                    {
                        Objects[i].Moved   = false;
                        Objects[i].Deleted = true;
                        if (Objects[i].Name == "Rectangle Red")
                        {
                            CmdDeleteRectangleRed CmdDeleteEventOne = new CmdDeleteRectangleRed();
                            Rect_Red                     = (RectangleRed)Objects[i];
                            Rect_Red.Username            = Username;
                            CmdDeleteEventOne.ID_Command = Guid.NewGuid();
                            CmdDeleteEventOne.Execute(Rect_Red);
                            CmdDeleteEventOne.hierarchyID = Rect.HierarchyID;

                            Command_manager = Manager.SaveCommand(CmdDeleteEventOne, CmdDeleteEventOne.isUndo, CmdDeleteEventOne.isRedo);
                            BinaryFormatter bf = new BinaryFormatter();
                            using (MemoryStream data = new MemoryStream())
                            {
                                bf.Serialize(data, CmdDeleteEventOne);
                                ServerStream_priv.Write(data.ToArray(), 0, data.ToArray().Length);
                                ServerStream_priv.Flush();
                            }
                        }
                        else if (Objects[i].Name == "Rectangle Blue")
                        {
                            CmdDeleteRectangleBlue CmdDeleteEventTwo = new CmdDeleteRectangleBlue();
                            Rect_Blue                    = (RectangleBlue)Objects[i];
                            Rect_Blue.Username           = Username;
                            CmdDeleteEventTwo.ID_Command = Guid.NewGuid();
                            CmdDeleteEventTwo.Execute(Rect_Blue);
                            CmdDeleteEventTwo.hierarchyID = Rect.HierarchyID;

                            Command_manager = Manager.SaveCommand(CmdDeleteEventTwo, CmdDeleteEventTwo.isUndo, CmdDeleteEventTwo.isRedo);
                            BinaryFormatter bf = new BinaryFormatter();
                            using (MemoryStream data = new MemoryStream())
                            {
                                bf.Serialize(data, CmdDeleteEventTwo);
                                ServerStream_priv.Write(data.ToArray(), 0, data.ToArray().Length);
                                ServerStream_priv.Flush();
                            }
                        }
                        else if (Objects[i].Name == "Relation")
                        {
                            CmdDeleteRelation CmdDeleteRelation = new CmdDeleteRelation();
                            Rel          = (Relation)Objects[i];
                            Rel.Username = Username;
                            CmdDeleteRelation.ID_Command = Guid.NewGuid();
                            CmdDeleteRelation.Execute(Rel);
                            CmdDeleteRelation.hierarchyID = Rel.HierarchyID;

                            Command_manager = Manager.SaveCommand(CmdDeleteRelation, CmdDeleteRelation.isUndo, CmdDeleteRelation.isRedo);
                            BinaryFormatter bf = new BinaryFormatter();
                            using (MemoryStream data = new MemoryStream())
                            {
                                bf.Serialize(data, CmdDeleteRelation);
                                ServerStream_priv.Write(data.ToArray(), 0, data.ToArray().Length);
                                ServerStream_priv.Flush();
                            }
                        }
                        Selected.Clear();
                        break;
                    }
                }
            }
        }