Beispiel #1
0
        /// <summary>
        /// Open file
        /// </summary>
        void FileOpenCommand(object sender, ExecutedRoutedEventArgs args)
        {
            if (!PromptToSave())
            {
                return;
            }

            // Show Open File dialog
            OpenFileDialog dlg = new OpenFileDialog();

            dlg.Filter           = "XML files (*.xml)|*.xml|All Files|*.*";
            dlg.DefaultExt       = "xml";
            dlg.InitialDirectory = SettingsManager.ApplicationSettings.InitialDirectory;
            dlg.RestoreDirectory = true;

            if (dlg.ShowDialog().GetValueOrDefault() != true)
            {
                return;
            }

            try
            {
                // Load file
                drawingCanvas.Load(dlg.FileName);
            }
            catch (DrawingCanvasException e)
            {
                ShowError(e.Message);
                mruManager.Delete(dlg.FileName);
                return;
            }

            this.fileName = dlg.FileName;
            UpdateTitle();
            mruManager.Add(this.fileName);

            // Remember initial directory
            SettingsManager.ApplicationSettings.InitialDirectory = System.IO.Path.GetDirectoryName(dlg.FileName);
        }