public static void SaveSelector(CanvasVector Canvas) { try { List <Control> controls = Canvas.GetImage().Values.ToList(); SaveFileDialog saveFD = new SaveFileDialog(); saveFD.Filter = "CSV (*.csv)|*.csv|JSON (*.json)|*.json|XML (*.xml)|*.xml|YML (*.yml)|*.yml"; DialogResult res = saveFD.ShowDialog(); if (res == DialogResult.OK) { // TODO: save file IFigureIO f = FigureIO_Selector.GetInstance(saveFD.FileName.Remove(0, saveFD.FileName.LastIndexOf('.') + 1)); f.PathToFile = saveFD.FileName; f.Write(controls); } saveFD.Dispose(); } catch { } }
public override void Action(object sender, EventArgs e) { try { List <UIElement> controls = cmd.canvasVector.GetMemento(); SaveFileDialog saveFD = new SaveFileDialog(); saveFD.Filter = "JSON (*.json)|*.json|CSV (*.csv)|*.csv|XML (*.xml)|*.xml|YML (*.yml)|*.yml"; bool?res = saveFD.ShowDialog(); if (res == true) { // TODO: save file IFigureIO f = FigureIO_Selector.GetInstance(saveFD.FileName.Remove(0, saveFD.FileName.LastIndexOf('.') + 1)); f.PathToFile = saveFD.FileName; f.Write(controls); } // need to close dialog after saving } catch { } }
public override void Action(object sender, EventArgs e) { try { List <Control> controls = cmd.canvas.GetMemento(); SaveFileDialog saveFD = new SaveFileDialog(); saveFD.Filter = "JSON (*.json)|*.json|CSV (*.csv)|*.csv|XML (*.xml)|*.xml|YML (*.yml)|*.yml"; DialogResult res = saveFD.ShowDialog(); if (res == DialogResult.OK) { // TODO: save file IFigureIO f = FigureIO_Selector.GetInstance(saveFD.FileName.Remove(0, saveFD.FileName.LastIndexOf('.') + 1)); f.PathToFile = saveFD.FileName; f.Write(controls); } saveFD.Dispose(); Form.ActiveForm.Close(); } catch { } }