Example #1
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);
        }
Example #2
0
        public bool Execute(EditorForm form)
        {
            bool flag = false;

            vector = form.GetStorage();
            for (int i = vector.Count() - 1; i >= 0; i--)
            {
                if (vector[i].IsSelected())
                {
                    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]);
                        }
                        if (vector[i].IsSticked())
                        {
                            vector[i].ChangeSticked(false);
                        }
                    }
                    flag = true;
                    shapes.Add(vector[i]);
                    vector.RemoveAt(i);
                }
            }
            return(flag);
        }
Example #3
0
        public bool Execute(EditorForm form)
        {
            bool     flag   = false;
            MyVector vector = form.GetStorage();

            for (int i = 0; i < vector.Count(); i++)
            {
                if (vector[i].IsSelected() && vector[i].IsSticky())
                {
                    flag = true;
                    shapes.Add(vector[i]);
                    listOfObs.Add(new List <Observer>());
                    List <Observer> list = vector[i].GetObservers();
                    for (int j = list.Count - 1; j > 0; j--)
                    {
                        listOfObs[shapes.Count - 1].Add(list[j]);
                        ((Figure)list[j]).RemoveObserver(vector[i]);
                        ((Figure)list[j]).ChangeSticked(false);
                        list.RemoveAt(j);
                    }
                    vector[i].ChangeSticky(false);
                    vector[i].ChangeSelected(false);
                }
            }
            return(flag);
        }
Example #4
0
        public bool Execute(EditorForm form)
        {
            bool flag = false;

            vector = form.GetStorage();
            if (delta > 0)
            {
                for (int i = 0; i < vector.Count(); i++)
                {
                    if (vector[i].IsSelected() && !vector[i].IsSticked() && !vector[i].IsObstacle(form.GetPanelWidth(), form.GetPanelHeight()))
                    {
                        flag = true;
                        shapes.Add(vector[i]);
                        vector[i].Scale(delta);
                    }
                }
                return(flag);
            }
            for (int i = 0; i < vector.Count(); i++)
            {
                if (vector[i].IsSelected() && !vector[i].IsSticked() && !vector[i].IsTooSmall())
                {
                    flag = true;
                    shapes.Add(vector[i]);
                    vector[i].Scale(delta);
                }
            }
            return(flag);
        }
Example #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);
        }
Example #6
0
        public bool Execute(EditorForm form)
        {
            bool     flag   = false;
            MyVector vector = form.GetStorage();

            for (int i = 0; i < vector.Count(); i++)
            {
                if (vector[i].IsAreaCatchFigure(form.GetFirstPointForSelected(), form.GetSecondPointForSelected()) && !vector[i].IsSelected())
                {
                    flag = true;
                    shapes.Add(vector[i]);
                    vector[i].ChangeSelected(selected);
                }
            }
            return(flag);
        }
Example #7
0
        public bool Execute(EditorForm form)
        {
            bool     flag   = false;
            MyVector vector = form.GetStorage();

            for (int i = 0; i < vector.Count(); i++)
            {
                if (vector[i].IsClickCatchFigure(form.GetFirstPointForSelected()))
                {
                    flag = true;
                    shapes.Add(vector[i]);
                    vector[i].InvertSelected();
                }
            }
            return(flag);
        }
Example #8
0
        public bool Execute(EditorForm form)
        {
            bool     flag   = false;
            MyVector vector = form.GetStorage();

            for (int i = 0; i < vector.Count(); i++)
            {
                if (vector[i].IsSelected() && !vector[i].IsSticky())
                {
                    flag = true;
                    shapes.Add(vector[i]);
                    vector[i].ChangeSticky(true);
                    vector[i].ChangeSelected(false);
                }
            }
            return(flag);
        }
Example #9
0
        public bool Execute(EditorForm form)
        {
            bool     flag   = false;
            MyVector vector = form.GetStorage();
            int      side   = 0;

            if (delta_x < 0)
            {
                side = 1;
            }
            if (delta_x > 0)
            {
                side = 3;
            }
            if (delta_y < 0)
            {
                side = 2;
            }
            if (delta_y > 0)
            {
                side = 4;
            }
            for (int i = 0; i < vector.Count(); i++)
            {
                vector[i].ResetObstacles();
                List <Observer> list = vector[i].GetObservers();
                for (int j = 0; j < list.Count; j++)
                {
                    ((Figure)list[j]).ResetObstacles();
                    ((Figure)list[j]).FillArrayForMove(ref ((Figure)list[j]).GetObstacles(), form.GetPanelWidth(), form.GetPanelHeight());
                    ((Observable)list[j]).NotifyAboutObstacle();
                }
                vector[i].FillArrayForMove(ref vector[i].GetObstacles(), form.GetPanelWidth(), form.GetPanelHeight());
                if (vector[i].IsSelected() && !vector[i].IsSticked() && !vector[i].GetObstacles()[side])
                {
                    flag = true;
                    shapes.Add(vector[i]);
                    vector[i].Move(delta_x, delta_y);
                }
            }
            return(flag);
        }
Example #10
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);
        }
Example #11
0
        public bool Execute(EditorForm form)
        {
            bool     flag   = false;
            MyVector vector = form.GetStorage();

            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))
                        {
                            flag = true;
                            sticked_shapes.Add(vector[j]);
                            vector[j].ChangeSticked(true);
                            vector[i].AddObserver(vector[j]);
                            vector[j].AddObserver(vector[i]);
                        }
                    }
                }
            }
            return(flag);
        }