Ejemplo n.º 1
0
        private void ExportAsImage(ConceptUsecase useCase)
        {
            var currentDisplay = useCase.GetCurrentDisplay();

            if (currentDisplay != null && currentDisplay.Data != null)
            {
                var saveFileDialog = new FileDialogMemento {
                    DefaultExt = "tif",
                    Filter     = "TIF-Image|*.tif|All Files|*.*",
                };

                if (useCase.FileDialogShow(saveFileDialog, false) == DialogResult.Ok)
                {
                    var image =
                        new ImageExporter(currentDisplay.Data, currentDisplay.Layout)
                    {
                        StyleSheet = currentDisplay.StyleSheet
                    }
                    .ExportImage();
                    if (image != null)
                    {
                        image.Save(saveFileDialog.FileName, ImageFormat.Tiff);
                        image.Dispose();
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public void ExportAsImageImpl(ConceptUsecase useCase)
        {
            var currentDisplay = useCase.GetCurrentDisplay();

            if (currentDisplay != null && currentDisplay.Data != null)
            {
                var saveFileDialog = new FileDialogMemento {
                    DefaultExt = "png",
                    Filter     = "PNG-Image|*.png|All Files|*.*",
                };

                if (useCase.FileDialogShow(saveFileDialog, false) == DialogResult.Ok)
                {
                    var image =
                        new ImageExporter(currentDisplay.Data, currentDisplay.Layout)
                    {
                        StyleSheet = currentDisplay.StyleSheet
                    }
                    .ExportImage();
                    if (image != null)
                    {
                        image.Save(saveFileDialog.FileName, ImageFileType.Png);
                        image.Dispose();
                    }
                }
            }
        }
Ejemplo n.º 3
0
        public void ImportRawSource()
        {
            Save();
            Close(Data);
            bool tryIt = true;

            while (tryIt && MessageBoxShow("Open a new, non exisiting file", "RawImport", MessageBoxButtons.OkCancel) == DialogResult.Ok)
            {
                var fileDialog = new FileDialogMemento();
                DefaultDialogValues(fileDialog, WriteFilter);
                DefaultDialogValues(OpenFileDialog, ReadFilter);

                if (FileDialogShow(fileDialog, true) == DialogResult.Ok)
                {
                    var sinkFile = fileDialog.FileName;
                    fileDialog.ResetFileName();
                    if (File.Exists(sinkFile))
                    {
                        continue;
                    }
                    if (tryIt = MessageBoxShow("Open the file to import", "RawImport", MessageBoxButtons.OkCancel) == DialogResult.Ok)
                    {
                        if (FileDialogShow(OpenFileDialog, true) == DialogResult.Ok)
                        {
                            var sourceFile = OpenFileDialog.FileName;
                            if (!File.Exists(sourceFile))
                            {
                                MessageBoxShow("File does not exist", "RawImport", MessageBoxButtons.Ok);
                                break;
                            }

                            tryIt = false;
                            var sourceInfo         = Iori.FromFileName(sourceFile);
                            var sinkIo             = ThingGraphIoManager.GetSinkIO(Iori.FromFileName(sinkFile), IoMode.Write) as ThingGraphIo;
                            ThingGraphContent sink = null;

                            try {
                                sink = sinkIo.Open(Iori.FromFileName(sinkFile));
                                var repairer = Registry.Pooled <ThingGraphRepairPool>()
                                               .Find(sourceInfo.Extension, IoMode.Read) as IPipe <Iori, IThingGraph>;
                                this.AttachProgress(repairer as IProgress);
                                repairer.Use(Iori.FromFileName(sourceFile), sink.Data);
                            } catch (Exception ex) {
                                Registry.Pooled <IExceptionHandler>()
                                .Catch(new Exception("Raw import failed: " + ex.Message, ex), MessageType.OK);
                                sinkIo.Close(sink);
                                File.Delete(sinkFile);
                            }
                            sinkIo.Close(sink);
                            MessageBoxShow("Import successfull", "RawImport", MessageBoxButtons.Ok);
                            this.Open(Iori.FromFileName(sinkFile));
                            OpenFileDialog.ResetFileName();
                        }
                    }
                }
            }
        }
Ejemplo n.º 4
0
 private void FileDialogSetValue(FileDialog source, FileDialogMemento target)
 {
     target.Title            = source.Title;
     target.FileName         = source.FileName;
     target.FileNames        = source.FileNames;
     target.InitialDirectory = source.CurrentFolder;
     target.Filter           = GetFilters(source.Filters);
     target.FilterIndex      = source.Filters.IndexOf(source.ActiveFilter);
     if (target.FilterIndex >= 0 && !Path.HasExtension(target.FileName))
     {
         target.FileName += "." + source.ActiveFilter.Patterns.First().Remove(0, 2);
     }
 }
Ejemplo n.º 5
0
        private void FileDialogSetValue(FileDialogMemento source, FileDialog target)
        {
            target.Title           = source.Title;
            target.InitialFileName = IoUtils.NiceFileName(source.FileName);
            target.CurrentFolder   = source.InitialDirectory;
            var filters = source.Filter.Split('|');

            for (int i = 0; i < filters.Length; i += 2)
            {
                var exts = filters[i + 1].Split(';');
                target.Filters.Add(new FileDialogFilter(filters[i], exts));
            }

            target.ActiveFilter = target.Filters[source.FilterIndex];
            var saveDialog = target as SaveFileDialog;
        }
Ejemplo n.º 6
0
        public static void FileDialogSetValue(FileDialogMemento target, FileDialog source)
        {
            target.DefaultExt = source.DefaultExt;

            target.Filter           = source.Filter;
            target.FilterIndex      = source.FilterIndex;
            target.InitialDirectory = source.InitialDirectory;
            target.Title            = source.Title;

            target.FileName  = source.FileName;
            target.FileNames = source.FileNames;
            var saveDialog = source as SaveFileDialog;

            if (saveDialog != null)
            {
                target.OverwritePrompt = saveDialog.OverwritePrompt;
            }
        }
Ejemplo n.º 7
0
        public DialogResult FileDialogShow(FileDialogMemento value, bool open)
        {
            FileDialogVidget fileDialog = null;

            if (open)
            {
                fileDialog = new OpenfileDialogVidget(value);
            }
            else
            {
                fileDialog = new SavefileDialogVidget(value);
            }
            var result = DialogResult.Cancel;

            if (fileDialog.Run())
            {
                result = DialogResult.Ok;
            }
            fileDialog.Dispose();

            return(result);
        }
Ejemplo n.º 8
0
        public static void FileDialogSetValue(FileDialog target, FileDialogMemento source)
        {
            target.AddExtension       = true;
            target.AutoUpgradeEnabled = true;
            target.CheckFileExists    = false;
            target.CheckPathExists    = false;
            target.DefaultExt         = source.DefaultExt;
            target.DereferenceLinks   = true;
            target.FileName           = IoUtils.NiceFileName(source.FileName);
            target.Filter             = source.Filter;
            target.FilterIndex        = source.FilterIndex;
            target.InitialDirectory   = source.InitialDirectory;
            target.RestoreDirectory   = false;
            target.ShowHelp           = false;
            target.Title         = source.Title;
            target.ValidateNames = true;
            var saveDialog = target as SaveFileDialog;

            if (saveDialog != null)
            {
                saveDialog.OverwritePrompt = source.OverwritePrompt;
            }
        }
Ejemplo n.º 9
0
 public virtual void Compose(FileDialogMemento dialog)
 {
     this._dialog = dialog;
 }
Ejemplo n.º 10
0
 public void DefaultDialogValues(FileDialogMemento dialog, string filter)
 {
     dialog.Filter          = filter + "All Files|*.*";
     dialog.DefaultExt      = "";
     dialog.OverwritePrompt = true;
 }