示例#1
0
 public SerialFigure(Figure.Figure fig)
 {
     X1        = fig.X1;
     X2        = fig.X2;
     Y1        = fig.Y1;
     Y2        = fig.Y2;
     penColor  = fig.pen.color;
     penWidth  = fig.pen.Width;
     Name      = fig.GetName();
     Direction = fig.Direction;
     if (fig is MyInterfaces.IFillingable)
     {
         isFilled = ((MyInterfaces.IFillingable)fig).isFilled;
     }
     figtype      = fig.GetType().ToString();
     isUserFigure = fig.isUserFigure;
     if (fig is UserFigure)
     {
         Hash = ((UserFigure)fig).SourceFigures.CalculateHash();
     }
     else
     {
         Hash = 0;
     }
 }
示例#2
0
 private void ChangePen(Figure.Figure fig)
 {
     btnConfirm.Enabled = true;
     grEdit.Clear(Color.Transparent);
     grRez.Clear(Color.Transparent);
     grMajor.Clear(Color.Transparent);
     grTemp.Clear(Color.Transparent);
     FigList.DrawAllExcept(grMajor, CurrFig);
     fig.ChangePen(CurrPen);
     fig.Draw(grTemp);
     if (fig is MyInterfaces.IFillingable)
     {
         if (((MyInterfaces.IFillingable)fig).isFilled)
         {
             ((MyInterfaces.IFillingable)fig).Fill(grTemp);
         }
     }
     if (fig is MyInterfaces.ISelectable)
     {
         ((MyInterfaces.ISelectable)fig).SelectFigure(grEdit);
     }
     grMajor.DrawImage(Layers[3], 0, 0);
     grRez.DrawImage(Layers[2], 0, 0);
     grMajor.DrawImage(Layers[1], 0, 0);
     pictureBox1.Refresh();
 }
        public Cursor ChangeCursor(MouseEventArgs e, Figure.Figure fig)
        {
            int S = 10;

            switch (fig.Direction)
            {
            case 0:
            {
                for (int i = 0; i < 9; i++)
                {
                    if (e.X < Arr[i].X + S && e.X > Arr[i].X - S && e.Y <Arr[i].Y + S && e.Y> Arr[i].Y - S)
                    {
                        return(CursNWSE[i]);
                    }
                }
                return(CursNWSE[9]);
            }

            case 1:
            {
                for (int i = 0; i < 9; i++)
                {
                    if (e.X < Arr[i].X + S && e.X > Arr[i].X - S && e.Y <Arr[i].Y + S && e.Y> Arr[i].Y - S)
                    {
                        return(CursNESW[i]);
                    }
                }
                return(CursNESW[9]);
            }

            case 2:
            {
                for (int i = 0; i < 9; i++)
                {
                    if (e.X < Arr[i].X + S && e.X > Arr[i].X - S && e.Y <Arr[i].Y + S && e.Y> Arr[i].Y - S)
                    {
                        return(CursNWSE[i]);
                    }
                }
                return(CursNWSE[9]);
            }

            case 3:
            {
                for (int i = 0; i < 9; i++)
                {
                    if (e.X < Arr[i].X + S && e.X > Arr[i].X - S && e.Y <Arr[i].Y + S && e.Y> Arr[i].Y - S)
                    {
                        return(CursNESW[i]);
                    }
                }
                return(CursNESW[9]);
            }

            default: { return(Cursors.Default); }
            }
        }
示例#4
0
 private void ConnectFiguresAssemblies()
 {
     try
     {
         foreach (var lib in DllList)
         {
             Assembly asm = Assembly.LoadFile(lib);
             Type[]   typ = asm.GetTypes();
             figure = (Figure.Figure)Activator.CreateInstance(typ[0], new Object[] { CurrPen, 0, 0, 0, 0 });
             bool isExist = false;
             foreach (var i in NamesList)
             {
                 if (figure.GetName() == i)
                 {
                     isExist = true;
                 }
             }
             if (!isExist)
             {
                 var nextRB = new RadioButton();
                 nextRB.Parent = grboxFigures;
                 nextRB.Left   = 8;
                 nextRB.Top    = StartRBPos;
                 nextRB.Width  = 100;
                 nextRB.Height = 21;
                 TypesList.Add(typ[0]);
                 if (figure.GetName().Length > 11)
                 {
                     nextRB.Text = figure.GetName().Substring(0, 10);
                 }
                 else
                 {
                     nextRB.Text = figure.GetName();
                 }
                 nextRB.CheckedChanged += (a, b) => {
                     FigParams = new Object[] { CurrPen, 0, 0, 0, 0 };
                     figure    = (Figure.Figure)Activator.CreateInstance(typ[0], FigParams);
                     isChanged = true;
                     isPointer = false;
                 };
                 StartRBPos    += 27;
                 nextRB.Checked = true;
                 NamesList.Add(figure.GetName());
             }
             else
             {
                 MessageBoxWrongDll("There is a repeated figure name \"" + figure.GetName() + "\" in assemblies.");
             }
         }
     }
     catch (Exception e)
     {
         MessageBoxException(e.Message);
     }
 }
示例#5
0
 public bool Remove(Figure.Figure item)
 {
     if (figures.Remove(item))
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
 public ActivePoints(Figure.Figure fig)
 {
     Arr[1].X = fig.X1; Arr[1].Y = fig.Y1;
     Arr[2].X = (fig.X1 + fig.X2) / 2; Arr[2].Y = fig.Y1;
     Arr[3].X = fig.X2; Arr[3].Y = fig.Y1;
     Arr[4].X = fig.X2; Arr[4].Y = (fig.Y1 + fig.Y2) / 2;
     Arr[5].X = fig.X2; Arr[5].Y = fig.Y2;
     Arr[6].X = (fig.X1 + fig.X2) / 2; Arr[6].Y = fig.Y2;
     Arr[7].X = fig.X1; Arr[7].Y = fig.Y2;
     Arr[8].X = fig.X1; Arr[8].Y = (fig.Y1 + fig.Y2) / 2;
     Arr[0].X = (fig.X1 + fig.X2) / 2; Arr[0].Y = (fig.Y1 + fig.Y2) / 2;
 }
示例#7
0
        private void ConnectUserFigures()
        {
            try
            {
                foreach (var figpath in UserFigsList)
                {
                    var fs = new FileStream(figpath, FileMode.OpenOrCreate, FileAccess.ReadWrite);
                    userfigsbinser = new MyCustomFiguresBinarySerializer();
                    var tmplist = userfigsbinser.LoadFiguresList(fs, TypesList, UserNamesList, SourceLists);
                    fs.Close();
                    SourceLists.Add(tmplist);
                    int length = (Application.StartupPath.ToString() + "\\" + UserFiguresPath).Length;

                    var nextRB = new RadioButton();
                    nextRB.Parent = grboxFigures;
                    nextRB.Left   = 8;
                    nextRB.Top    = StartRBPos;
                    StartRBPos   += 27;
                    nextRB.Width  = 100;
                    nextRB.Height = 21;
                    string tmpstr = figpath.Substring(length + 1);
                    var    name   = tmpstr.Remove(tmpstr.Length - 4);
                    nextRB.Text = name;
                    UserNamesList.Add(name);

                    nextRB.CheckedChanged += (a, b) => {
                        try
                        {
                            CurrentList = tmplist;
                            CurrentName = name;
                            FigParams   = new Object[] { CurrentName, CurrentList, CurrPen, 0, 0, 0, 0 };
                            figure      = (Figure.Figure)Activator.CreateInstance(Type.GetType("Lab1.UserFigure"), FigParams);
                            isChanged   = true;
                            isPointer   = false;
                        }
                        catch (Exception ee)
                        {
                            MessageBoxException(ee.Message);
                        }
                    };
                }
            }
            catch (Exception e)
            {
                MessageBoxException(e.Message);
            }
        }
示例#8
0
 private void MD_NewFigureBegin(MouseEventArgs ee)
 {
     btnBack.Enabled = true;
     if (!isChanged)
     {
         figure = (Figure.Figure)Activator.CreateInstance(figure.GetType(), FigParams);
     }
     FigList.Add(figure);
     if (FigList.Last is MyInterfaces.IFillingable)
     {
         ((MyInterfaces.IFillingable)figure).isFilled = isFill;
     }
     FigList.Last.X1 = ee.X;
     FigList.Last.Y1 = ee.Y;
     grMajor.DrawImage(Layers[2], 0, 0);
     grTemp.Clear(Color.Transparent);
     isPressed = true;
     isChanged = false;
 }
示例#9
0
 public void Add(Figure.Figure item)
 {
     figures.Add(item);
 }
示例#10
0
        private void btnMkUsrFig_Click(object sender, EventArgs e)
        {
            isOpenFile = true;
            string name = Microsoft.VisualBasic.Interaction.InputBox("Creating figure...", "Enter name:");

            {
                if (name != "")
                {
                    if (!IsExistName(name))
                    {
                        FileStream fs = new FileStream(Application.StartupPath.ToString() + "\\" + UserFiguresPath + "\\" + name + "." + UserFiguresExtension,
                                                       FileMode.OpenOrCreate, FileAccess.ReadWrite);
                        userfigsbinser = new MyCustomFiguresBinarySerializer();
                        var transformer = new UserFiguresTransformer();
                        var tmplist     = transformer.TransformToFullList(FigList);
                        userfigsbinser.SaveFiguresList(fs, tmplist);
                        fs.Close();

                        for (int i = 0; i < tmplist.Size(); i++)
                        {
                            usrlst.Add(tmplist.Item(i).Copy());
                        }

                        SourceLists.Add(usrlst);
                        typ = Type.GetType("Lab1.UserFigure");
                        var nextRB = new RadioButton();
                        nextRB.Parent = grboxFigures;
                        nextRB.Left   = 8;
                        nextRB.Top    = StartRBPos;
                        StartRBPos   += 27;
                        nextRB.Width  = 100;
                        nextRB.Height = 21;
                        nextRB.Text   = name;
                        UserNamesList.Add(name);

                        nextRB.CheckedChanged += (a, b) =>
                        {
                            try
                            {
                                CurrentList = usrlst;
                                CurrentName = name;
                                FigParams   = new Object[] { CurrentName, CurrentList, CurrPen, 0, 0, 0, 0 };
                                figure      = (Figure.Figure)Activator.CreateInstance(typ, FigParams);
                                isChanged   = true;
                                isPointer   = false;
                            }
                            catch (Exception ee)
                            {
                                MessageBoxException(ee.Message);
                            }
                        };
                    }
                    else
                    {
                        MessageBoxError("Such name is already exist.", "Error");
                    }
                }
                else
                {
                    MessageBoxError("Field couldn't be empty.", "Error");
                }
            }
            isOpenFile = false;
        }