Example #1
0
        void openEditDialog()
        {
            foreach (var el in figures)
            {
                if (el.Owner.DeviceType == Device.DeviceTypes.PhysicalMachine && el.Xpos == xCheck && el.Ypos == yCheck)
                {
                    edit    = true;
                    PhM     = new PhysicMachineForm();
                    PhM.Tag = this;
                    PhM.Show();

                    return;
                }
                else if (el.Owner.DeviceType == Device.DeviceTypes.TaskGenerator && el.Xpos == xCheck && el.Ypos == yCheck)
                {
                    edit   = true;
                    TG     = new TaskGeneratorForm();
                    TG.Tag = this;
                    TG.Show();

                    return;
                }
            }

            foreach (var el in lines)
            {
                if ((el.X1 == xCheck && el.Y1 == yCheck && el.X2 == wCheck && el.Y2 == hCheck) ||
                    (el.X2 == xCheck && el.Y2 == yCheck && el.X1 == wCheck && el.Y1 == hCheck))
                {
                    edit        = true;
                    Connect     = new ConnectForm();
                    Connect.Tag = this;
                    Connect.Show();

                    return;
                }
            }
        }
Example #2
0
        private void groundBox_MouseUp(object sender, MouseEventArgs e)
        {
            if (placeSomething != "")
            {
                X = e.Location.X;
                Y = e.Location.Y;

                if (!checkPosition(X, Y, sizeW, sizeH) && placeSomething != "З'єднати")
                {
                    return;
                }

                if (placeSomething == "Фізична машина")
                {
                    PhM     = new PhysicMachineForm();
                    PhM.Tag = this;
                    PhM.Show();
                }
                else if (placeSomething == "Генератор задач")
                {
                    if (Controller.getInstance().Generator == null)
                    {
                        TG     = new TaskGeneratorForm();
                        TG.Tag = this;
                        TG.Show();
                    }
                    else
                    {
                        MessageBox.Show("Generator already exists", "Error");
                    }
                }
                else if (placeSomething == "Маршрутизатор")
                {
                    Figure fig = new Figure(X, Y, sizeW, sizeH);
                    graphics.FillRectangle(brushR, X, Y, sizeW, sizeH);
                    figures.Add(fig);
                    groundBox.Image = bmp;
                    Controller.getInstance().Devices.Add(new Router(fig));
                }
                else if (placeSomething == "З'єднати" && checkFigure(X, Y) && X1 != xCheck && Y1 != yCheck)
                {
                    figReturn2 = returnFigure(X, Y);

                    if (Controller.getInstance().FindLink(figReturn1.Owner, figReturn2.Owner) == null)
                    {
                        if (X1 < X)
                        {
                            X1 += W1;
                            X2  = xCheck;
                        }
                        else
                        {
                            X2 = xCheck + wCheck;
                        }

                        if (Y1 < Y)
                        {
                            Y1 += H1;
                            Y2  = yCheck;
                        }
                        else
                        {
                            Y2 = yCheck + hCheck;
                        }

                        Connect     = new ConnectForm();
                        Connect.Tag = this;
                        Connect.Show();
                    }
                    else
                    {
                        MessageBox.Show("Devices already connected", "Error");
                    }
                }

                placeSomething = "";
            }
        }