Ejemplo n.º 1
0
 public void Unexecute()
 {
     for (int i = 0; i < groups.Count; i++)
     {
         for (int j = 0; j < groups[i].Count(); j++)
         {
             for (int k = vector.Count() - 1; k >= 0; k--)
             {
                 if (vector[k] == groups[i][j])
                 {
                     vector[k].ChangeGrouped(true);
                     vector.RemoveAt(k);
                 }
             }
         }
         vector.Add(groups[i]);
     }
     for (int i = 0; i < vector.Count(); i++)
     {
         if (vector[i].IsSticky())
         {
             for (int j = 0; j < vector.Count(); j++)
             {
                 if (vector[j].IsToStick(vector[i]) && !vector[j].IsSticked() && (i != j))
                 {
                     vector[j].ChangeSticked(true);
                     vector[j].AddObserver(vector[i]);
                     vector[i].AddObserver(vector[j]);
                 }
             }
         }
     }
 }
Ejemplo n.º 2
0
 public void Unexecute()
 {
     for (int i = 0; i < not_sticky.Count; i++)
     {
         not_sticky[i].ChangeSticky(false);
     }
     vector.Remove(group);
     for (int i = 0; i < group.Count(); i++)
     {
         group[i].ChangeColor(colors[i]);
         group[i].ChangeGrouped(false);
         vector.Add(group[i]);
     }
     for (int i = 0; i < vector.Count(); i++)
     {
         if (vector[i].IsSticky())
         {
             for (int j = 0; j < vector.Count(); j++)
             {
                 if (vector[j].IsToStick(vector[i]) && !vector[j].IsSticked() && (i != j))
                 {
                     vector[j].ChangeSticked(true);
                     vector[j].AddObserver(vector[i]);
                     vector[i].AddObserver(vector[j]);
                 }
             }
         }
     }
 }
Ejemplo n.º 3
0
        public bool Execute(EditorForm form)
        {
            if (form.GetState() != EditorForm.Figures.Nothing)
            {
                switch (form.GetState())
                {
                case EditorForm.Figures.Circle:
                    figure = new Circle(form.GetPointForAdd().X, form.GetPointForAdd().Y);
                    break;

                case EditorForm.Figures.Rectangle:
                    figure = new Rectangle(form.GetPointForAdd().X, form.GetPointForAdd().Y);
                    break;

                case EditorForm.Figures.Section:
                    figure = new Section(form.GetPointForAdd().X, form.GetPointForAdd().Y);
                    break;

                case EditorForm.Figures.Triangle:
                    figure = new Triangle(form.GetPointForAdd().X, form.GetPointForAdd().Y);
                    break;
                }
                vector = form.GetStorage();
                vector.Add(figure);
                form.ChangeState(EditorForm.Figures.Nothing);
                return(true);
            }
            return(false);
        }
Ejemplo n.º 4
0
 private void createSomeObjectsToolStripMenuItem_Click(object sender, EventArgs e)
 {
     vector.Add(new Circle(329, 123));
     vector.Add(new Circle(401, 123, 20, Color.Blue));
     vector.Add(new Circle(363, 140, 70, Color.Green));
     vector.Add(new Section(364, 185, 60, Color.Green));
     vector.Add(new Section(512, 245, 60, Color.Green));
     vector.Add(new Section(211, 245, 60, Color.Green));
     vector.Add(new Triangle(279, 349, 30, Color.Green));
     vector.Add(new Triangle(439, 349, 30, Color.Green));
     vector.Add(new Rectangle(361, 271, 120, Color.Green));
     panel1.Refresh();
 }
Ejemplo n.º 5
0
        public bool Execute(EditorForm form)
        {
            bool flag = false;

            vector = form.GetStorage();
            Group newGroup = new Group();

            newGroup.ChangeSelected(true);
            bool stickyGroup = false;

            for (int i = 0; i < vector.Count(); i++)
            {
                if (vector[i].IsSticky() && vector[i].IsSelected())
                {
                    stickyGroup = true;
                    break;
                }
            }
            for (int i = vector.Count() - 1; i >= 0; i--)
            {
                if (vector[i].IsSelected())
                {
                    vector[i].ChangeGrouped(true);
                    if (stickyGroup && !vector[i].IsSticky())
                    {
                        not_sticky.Add(vector[i]);
                    }
                    if (vector[i].IsSticky() || vector[i].IsSticked())
                    {
                        List <Observer> list = vector[i].GetObservers();
                        for (int j = list.Count - 1; j > 0; j--)
                        {
                            ((Figure)list[j]).RemoveObserver(vector[i]);
                        }
                    }
                    colors.Add(vector[i].GetColor());
                    vector[i].ChangeColor(Color.Green);
                    newGroup.Add(vector[i]);
                    vector.RemoveAt(i);
                }
            }
            if (newGroup.Count() != 0)
            {
                flag = true;
                if (stickyGroup)
                {
                    newGroup.ChangeSticky(true);
                }
                vector.Add(newGroup);
                group = newGroup;
            }
            return(flag);
        }
Ejemplo n.º 6
0
        public bool Execute(EditorForm form)
        {
            bool flag = false;

            vector = form.GetStorage();
            for (int i = vector.Count() - 1; i >= 0; i--)
            {
                if ((vector[i] is Group) && vector[i].IsSelected())
                {
                    flag = true;
                    groups.Add((Group)vector[i]);
                    if (vector[i].IsSticky() || vector[i].IsSticked())
                    {
                        List <Observer> list = vector[i].GetObservers();
                        for (int j = 1; j < list.Count; j++)
                        {
                            ((Figure)list[j]).RemoveObserver(vector[i]);
                        }
                    }
                    if (vector[i].IsSticked())
                    {
                        vector[i].ChangeSticked(false);
                    }
                    for (int j = 0; j < ((Group)vector[i]).Count(); j++)
                    {
                        ((Group)vector[i])[j].ChangeGrouped(false);
                        if (((Group)vector[i])[j] is Group)
                        {
                            for (int k = 0; k < ((Group)((Group)vector[i])[j]).Count(); k++)
                            {
                                ((Group)((Group)vector[i])[j])[k].ChangeGrouped(true);
                            }
                        }
                        vector.Add(((Group)vector[i])[j]);
                    }
                    vector.RemoveAt(i);
                }
            }
            return(flag);
        }
Ejemplo n.º 7
0
 public void Unexecute()
 {
     for (int i = 0; i < shapes.Count; i++)
     {
         vector.Add(shapes[i]);
     }
     for (int i = 0; i < vector.Count(); i++)
     {
         if (vector[i].IsSticky())
         {
             for (int j = 0; j < vector.Count(); j++)
             {
                 if (vector[j].IsToStick(vector[i]) && !vector[j].IsSticked() && (i != j))
                 {
                     vector[j].ChangeSticked(true);
                     vector[j].AddObserver(vector[i]);
                     vector[i].AddObserver(vector[j]);
                 }
             }
         }
     }
 }