예제 #1
0
        private void LoadScheme(string path)
        {
            filename    = path;
            modified    = false;
            dragElement = null;
            connectLine = null;
            menuElement = null;
            move        = false;
            scheme?.Dispose();
            scheme = null;

            if (string.IsNullOrEmpty(path))
            {
                scheme   = new DrawableScheme(pictureBox.Width, pictureBox.Height);
                filename = null;
            }
            else
            {
                try
                {
                    using (var file = File.Open(path, FileMode.Open))
                        scheme = DrawableSchemeStorage.Load(file);
                }
                catch (Exception exception)
                {
                    ShowError(String.Format(Resource.Localization.Error_PathOpen, path), exception);

                    filename = null;
                    scheme   = new DrawableScheme(pictureBox.Width, pictureBox.Height);
                }
            }

            DrawScheme();
        }
예제 #2
0
        private void saveAsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (saveFileDialog.ShowDialog() == DialogResult.OK)
            {
                using (var file = saveFileDialog.OpenFile())
                    DrawableSchemeStorage.Save(scheme, file);

                filename = saveFileDialog.FileName;

                modified = false;
            }
        }
예제 #3
0
        private void saveToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(filename))
            {
                using (var file = File.Open(filename, FileMode.Create))
                    DrawableSchemeStorage.Save(scheme, file);

                modified = false;
            }
            else
            {
                saveAsToolStripMenuItem_Click(sender, e);
            }
        }
예제 #4
0
        public static void Save(DrawableScheme scheme, Stream stream)
        {
            #region arguments check

            if (stream == null)
            {
                throw new ArgumentNullException(nameof(stream));
            }
            if (!stream.CanWrite)
            {
                throw new ArgumentException("The stream must be writeable.", nameof(stream));
            }

            #endregion

            using (var streamWriter = new StreamWriter(stream))
                streamWriter.Write(DrawableSchemeStorage.Save(scheme));
        }