示例#1
0
文件: Canvas.cs 项目: MGnuskina/Tasks
 private void loadToolStripMenuItem_Click(object sender, EventArgs e)
 {
     openFileDialog1.Title  = "Open";
     openFileDialog1.Filter = "XML file|*.xml|JSON file|*.json|CSV file|*.csv|YAML file|*.yaml";
     if (openFileDialog1.ShowDialog() == DialogResult.OK)
     {
         ShapeOriginator originator = new ShapeOriginator();
         string          path       = openFileDialog1.FileName;
         IWorkWithFiles  openFile   = LSFactory.findExtention(path);
         originator.SetMemento(new ShapeMemento(openFile.Load(path)));
         SetControls(originator);
     }
     openFileDialog1.Dispose();
 }
示例#2
0
文件: Canvas.cs 项目: MGnuskina/Tasks
 private void saveToolStripMenuItem_Click(object sender, EventArgs e)
 {
     saveFileDialog1.Title  = "Save";
     saveFileDialog1.Filter = "XML file|*.xml|JSON file|*.json|CSV file|*.csv|YAML file|*.yaml";
     if (saveFileDialog1.ShowDialog() == DialogResult.OK)
     {
         ShapeOriginator originator = new ShapeOriginator();
         SetOriginator(originator);
         string         path     = saveFileDialog1.FileName;
         IWorkWithFiles saveFile = LSFactory.findExtention(path);
         saveFile.Save(originator.CreateMemento().GetMemento(), path);
     }
     saveFileDialog1.Dispose();
 }