private void SaveAs(string fileName)
 {
     try
     {
         if (String.IsNullOrEmpty(fileName))
         {
             FileSelector fileSelector = new FileSelector(FileSelectorFilters.Circuits);
             fileSelector.FileName = fileName;
             if (fileSelector.ExecuteSaveDialog())
             {
                 fileName = fileSelector.FileName;
             }
         }
         if (String.IsNullOrEmpty(fileName) == false)
         {
             CircuitData data = CircuitConverter.Instance.ConvertFromCircuit(circuitEditor.Circuit);
             data.Signals = SignalConverter.Instance.ConvertFromSignalList(circuitEditor.SignalList);
             CircuitSerializer.SerializeCircuit(fileName, data);
             m_Persistent = true;
             FileName     = fileName;
         }
     }
     catch (Exception e)
     {
         string msg = e.Message;
         if (e.InnerException != null)
         {
             msg += "\n" + e.InnerException.Message;
         }
         MessageBox.Show(msg + "\n-----\n" + e.StackTrace, "Exception", MessageBoxButtons.OK, MessageBoxIcon.Stop);
     }
 }
 private void SaveAs(string fileName)
 {
     try
     {
         if (String.IsNullOrEmpty(fileName))
         {
             FileSelector fileSelector = new FileSelector(FileSelectorFilters.Symbols);
             fileSelector.FileName = fileName;
             if (fileSelector.ExecuteSaveDialog())
             {
                 fileName = fileSelector.FileName;
             }
         }
         if (String.IsNullOrEmpty(fileName) == false)
         {
             SymbolData data = SymbolConverter.Instance.ConvertFromSymbol(symbolEditor.Symbol);
             SymbolSerializer.SerializeSymbol(fileName, data);
             m_Persistent = true;
             FileName     = fileName;
         }
     }
     catch (Exception e)
     {
         string msg = e.Message;
         if (e.InnerException != null)
         {
             msg += "\n" + e.InnerException.Message;
         }
         MessageBox.Show(msg + "\n-----\n" + e.StackTrace, "Exception", MessageBoxButtons.OK, MessageBoxIcon.Stop);
     }
 }
Пример #3
0
        private void OpenSymbol(object sender, EventArgs e)
        {
            FileSelector fileSelector = new FileSelector(FileSelectorFilters.Symbols);

            fileSelector.FileName = textBox_Symbol.Text;
            if (fileSelector.ExecuteOpenDialog())
            {
                textBox_Symbol.Text = fileSelector.FileName;
            }
            CheckSelection();
        }
Пример #4
0
        public DockContent ExecuteOpenFileDialog()
        {
            try
            {
                FileSelector fileSelector = new FileSelector(FileSelectorFilters.AnyFile | FileSelectorFilters.Circuits | FileSelectorFilters.Symbols);
                if (fileSelector.ExecuteOpenDialog())
                {
                    ISaveableDocument editor = null;
                    switch (fileSelector.UsedFilter)
                    {
                    case FileSelectorFilters.Circuits:
                        editor = CreateNewEditorForm();
                        break;

                    case FileSelectorFilters.Symbols:
                        editor = CreateNewSymbolForm();
                        break;
                    }
                    if (editor.LoadDocument(fileSelector.FileName))
                    {
                        HandleRecentFiles(fileSelector.FileName, fileSelector.UsedFilter);

                        return(editor as DockContent);
                    }
                    else
                    {
                        (editor as Form).Dispose();
                    }
                }
            }
            catch (Exception ex)
            {
                //TODO: Exception Handling
                MessageBox.Show(ex.Message + "\n-----\n" + ex.StackTrace, "Exception", MessageBoxButtons.OK, MessageBoxIcon.Stop);
            }
            return(null);
        }