private string DefaultFileName()
        {
            string imagePath = this.imageExportFolder.Value;

            if (!Mainframe.IsDirectoryPathValid(imagePath))
            {
                imagePath = Mainframe.DefaultPictureFolder();
            }
            string name = string.Format(CultureInfo.InvariantCulture, "{0}.{1}.{2}",
                                        this.editor.Project.Name,
                                        this.editor.Project.LogicalCircuit.Name,
                                        this.Encoder.Name
                                        );

            return(Path.Combine(imagePath, name));
        }
示例#2
0
 private void InsertImage()
 {
     try {
         OpenFileDialog dialog = new OpenFileDialog {
             InitialDirectory = Mainframe.IsDirectoryPathValid(this.openImageFolder.Value) ? this.openImageFolder.Value : Mainframe.DefaultPictureFolder(),
             Filter           = Properties.Resources.ImageFileFilter,
             FilterIndex      = 0
         };
         bool?result = dialog.ShowDialog(this);
         if (result.HasValue && result.Value)
         {
             string path = dialog.FileName;
             this.openImageFolder.Value = Path.GetDirectoryName(path);
             if (Uri.TryCreate(path, UriKind.Absolute, out Uri uri))
             {
                 Image image = new Image();
                 image.BeginInit();
                 image.Source   = new BitmapImage(uri);
                 image.MaxWidth = image.Source.Width;
                 image.EndInit();
                 Span span = new Span(this.editor.Selection.End, this.editor.Selection.End);
                 span.Inlines.Add(image);
             }
         }
     } catch (Exception exception) {
         App.Mainframe.ReportException(exception);
     }
 }