Esempio n. 1
0
        private void Save(string fileName)
        {
            try {
                if ( this.doc != null ) {
                    this.doc.FileName = fileName;
                    DocumentPersistence docSaver = new XmlDocumentPersistence( this.doc );
                    docSaver.Save( fileName );
                    this.ActivateGui();
                }
            }
            catch(XmlException exc)
            {
                MessageBox.Show(
                    this,
                    StringsL18n.Get( StringsL18n.StringId.ErManagingXML )
                    + ": " + exc.Message,
                    AppInfo.Name,
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error
                );
            }
            catch(IOException exc)
            {
                MessageBox.Show(
                    this,
                    StringsL18n.Get( StringsL18n.StringId.ErAccessingFile )
                    + ": " + exc.Message,
                    AppInfo.Name,
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error
                );
            }
            finally {
                this.SetStatus();
            }

            return;
        }
Esempio n. 2
0
        private void OnOpen()
        {
            var dlgOpenFile = new OpenFileDialog();

            this.OnClose();

            try {
                dlgOpenFile.Title = AppInfo.Name;
                dlgOpenFile.DefaultExt = XmlDocumentPersistence.DefaultExt;
                dlgOpenFile.CheckPathExists = true;
                dlgOpenFile.CheckFileExists = true;
                dlgOpenFile.Filter = AppInfo.Name
                    + " (*." + XmlDocumentPersistence.DefaultExt + ")"
                    + "|*." + XmlDocumentPersistence.DefaultExt;
                dlgOpenFile.InitialDirectory = filePath;

                if ( dlgOpenFile.ShowDialog() == DialogResult.OK ) {
                    this.filePath = Path.GetDirectoryName( dlgOpenFile.FileName );
                    DocumentPersistence docLoader = new XmlDocumentPersistence( null );
                    this.doc = docLoader.Load( dlgOpenFile.FileName );
                    this.doc.FileName = dlgOpenFile.FileName;

                    this.UpdatePlanning();
                    this.ChangeToListTab();
                    this.ActivateGui();
                }
            }
            catch(XmlException exc)
            {
                MessageBox.Show(
                    this,
                    StringsL18n.Get( StringsL18n.StringId.ErManagingXML )
                    + ": " + exc.Message,
                    AppInfo.Name,
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error
                );
            }
            catch(IOException exc)
            {
                MessageBox.Show(
                    this,
                    StringsL18n.Get( StringsL18n.StringId.ErAccessingFile )
                    + ": " + exc.Message,
                    AppInfo.Name,
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error
                );
            }
            finally {
                this.SetStatus();
            }

            return;
        }