Beispiel #1
0
        private void panelResizeSheet_MouseUp(object sender, MouseEventArgs e)
        {
            if (cursorActive == true)
            {
                var jsonSerializerSettings = new JsonSerializerSettings()
                {
                    TypeNameHandling = TypeNameHandling.All
                };
                VectorCanvas tmp  = VectorCanvas.GetCanvas;
                string       file = "";
                foreach (Drawfigure f in tmp.figures)
                {
                    string json = JsonConvert.SerializeObject(f, jsonSerializerSettings);
                    file += json + "|";
                }

                pictureBoxSheet.Size += (Size)e.Location;
                pictureBoxSheet.DrawToBitmap(Canvas.GetCanvas.Bmp.Bmp, pictureBoxSheet.ClientRectangle);
                VectorCanvas.GetCanvas.Init(pictureBoxSheet.Width, pictureBoxSheet.Height);

                string[] lines = file.Split(new string[] { "|" }, StringSplitOptions.RemoveEmptyEntries);
                for (int i = 0; i < lines.Length; i++)
                {
                    Drawfigure f = JsonConvert.DeserializeObject <Drawfigure>(lines[i], jsonSerializerSettings);
                    tmp.figures.Add(f);
                }
                VectorCanvas.GetCanvas.RenderWrite(pictureBoxSheet);

                cleanMemory();
            }
        }
 public VectorRepaintTool()
 {
     cursorActive = false;
     canvas       = VectorCanvas.GetCanvas;
     activeFigure = null;
     //this.figure = (IFigure)figure.Clone();
     //this.brush = (IBrush)brush.Clone();
     //this.fill = (IFill)fill.Clone();
 }
Beispiel #3
0
        private void OpenToolStripMenuItem_Click(object sender, EventArgs e) // Открыть файл
        {
            if (canvas == Canvas.GetCanvas)
            {
                string filePath;

                openFileDialog.InitialDirectory = "c:\\";
                openFileDialog.Filter           = " All files (*.*)|*.*| Portable net graphics (*.png)|*.png| Bitmap files (*.bmp)|*.bmp";
                openFileDialog.FilterIndex      = 2;
                openFileDialog.RestoreDirectory = true;

                if (openFileDialog.ShowDialog() == DialogResult.OK)
                {
                    filePath = openFileDialog.FileName;
                    pictureBoxSheet.Load(filePath + "");
                    startProgram();
                    pictureBoxSheet.DrawToBitmap(Canvas.GetCanvas.Bmp.Bmp, pictureBoxSheet.ClientRectangle);
                }
            }

            if (canvas == VectorCanvas.GetCanvas)
            {
                string[] fileContent;
                string   filePath;

                openFileDialog.InitialDirectory = "c:\\";
                saveFileDialog.Filter           = " JSON (*.json)|*.json";
                openFileDialog.FilterIndex      = 0;
                openFileDialog.RestoreDirectory = true;
                var jsonSerializerSettings = new JsonSerializerSettings()
                {
                    TypeNameHandling = TypeNameHandling.All
                };

                if (openFileDialog.ShowDialog() == DialogResult.OK)
                {
                    filePath    = openFileDialog.FileName;
                    fileContent = File.ReadAllLines(filePath);
                    VectorCanvas tmp = VectorCanvas.GetCanvas;
                    tmp.figures.Clear();
                    for (int i = 0; i < fileContent.Length; i++)
                    {
                        Drawfigure f = JsonConvert.DeserializeObject <Drawfigure>(fileContent[i], jsonSerializerSettings);
                        tmp.figures.Add(f);
                    }
                    VectorCanvas.GetCanvas.RenderWrite(pictureBoxSheet);
                }
            }
        }
Beispiel #4
0
        private void SaveToolStripMenuItem_Click(object sender, EventArgs e) // Сохранить файл
        {
            if (canvas == Canvas.GetCanvas)
            {
                saveFileDialog.Filter           = " Portable net graphics (*.png)|*.png| Bitmap files (*.bmp)|*.bmp";
                saveFileDialog.FilterIndex      = 1;
                saveFileDialog.RestoreDirectory = true;

                if (saveFileDialog.ShowDialog() == DialogResult.OK)
                {
                    Canvas.GetCanvas.Bmp.Bmp.Save(saveFileDialog.FileName);
                }
            }

            if (canvas == VectorCanvas.GetCanvas)
            {
                saveFileDialog.Filter           = " JSON (*.json)|*.json";
                saveFileDialog.FilterIndex      = 1;
                saveFileDialog.RestoreDirectory = true;
                var jsonSerializerSettings = new JsonSerializerSettings()
                {
                    TypeNameHandling = TypeNameHandling.All
                };
                if (saveFileDialog.ShowDialog() == DialogResult.OK)
                {
                    VectorCanvas tmp  = VectorCanvas.GetCanvas;
                    string       file = "";
                    foreach (Drawfigure f in tmp.figures)
                    {
                        string json = JsonConvert.SerializeObject(f, jsonSerializerSettings);
                        file += json + "\n";
                    }
                    File.WriteAllText(saveFileDialog.FileName, file);
                }
            }
        }
Beispiel #5
0
 public VectorFigureOriginalStateTool()
 {
     cursorActive = false;
     canvas       = VectorCanvas.GetCanvas;
     activeFigure = null;
 }
Beispiel #6
0
        // Point farthest;

        public VectorFigureChangeSizeTool()
        {
            cursorActive = false;
            canvas       = VectorCanvas.GetCanvas;
            activeFigure = null;
        }
 public VectorFigureTurnTool()
 {
     cursorActive = false;
     canvas       = VectorCanvas.GetCanvas;
     activeFigure = null;
 }