Esempio n. 1
0
		public static void ExportShell()
		{
			var saveFileDialog = new SaveFileDialog
			{
				Title = "Export to ...",
				Filters = {new FileDialogFilter("Altman Xml", ".xml")}
			};

			if (saveFileDialog.ShowDialog(Application.Instance.MainForm) == DialogResult.Ok)
			{
				var srcfile = saveFileDialog.FileName;
				var connString = string.Format("Data Source={0}", Path.Combine(ShellManager.Host.App.AppCurrentDir, "data.db3"));
				try
				{
					var dt = GetAltmanDataTable(connString);
					if (dt.Rows.Count > 0)
					{
						var xmlString = ConvertAltmanDataTableToXml(dt);
						SaveStringToXml(srcfile, xmlString);

						MessageBox.Show(string.Format("Export {0} Shell(s)", dt.Rows.Count));
					}
					else
					{
						MessageBox.Show("No shell be exported");
					}
				}
				catch (Exception ex)
				{
					MessageBox.Show(ex.Message);
				}
			}
		}
Esempio n. 2
0
        public void Export()
        {
            using (var dialog = new SaveFileDialog { Directory = new Uri(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)) }) {
                dialog.Filters.Add(new FileDialogFilter(Desktop.Properties.Resources.TextFilterCsvFiles, Utilities.FileFilterCsv));
                dialog.Filters.Add(new FileDialogFilter(Desktop.Properties.Resources.TextFilterAllFiles, Utilities.FileFilterAll));

                if (dialog.ShowDialog(this) != DialogResult.Ok) return;

                Export(dialog.FileName);
            }
        }
        private void ExportCsv(IEnumerable <UserStringItem> collection)
        {
            //Save off a set of keys
            try
            {
                var fd = new Eto.Forms.SaveFileDialog();
                fd.Filters.Add(new FileFilter(m_csvstr, m_csv));
                fd.Filters.Add(new FileFilter(m_txtstr, m_txt));
                fd.Title = m_dialog_export_title;
                var export_result = fd.ShowDialog(RhinoEtoApp.MainWindow);

                if (export_result != DialogResult.Ok)
                {
                    return;
                }

                if (fd.CheckFileExists)
                {
                    var replace = Dialogs.ShowMessage($"{m_replace_file} {fd.FileName}",
                                                      m_dialog_export_title, ShowMessageButton.YesNoCancel, ShowMessageIcon.Question);

                    if (replace != ShowMessageResult.Yes)
                    {
                        return;
                    }

                    if (IsFileLocked(new FileInfo(fd.FileName)))
                    {
                        Dialogs.ShowMessage(m_file_locked_message, m_file_error_message_title,
                                            ShowMessageButton.OK, ShowMessageIcon.Error);
                        return;
                    }

                    File.Delete(fd.FileName);
                }


                var csv = new StringBuilder();
                foreach (var entry in collection.Select(co => $"{co.Key},{co.Value}"))
                {
                    csv.AppendLine(entry);
                }

                File.WriteAllText(fd.FileName, csv.ToString());
                RhinoApp.WriteLine($"{m_file_success} {fd.FileName}");
            }
            catch (Exception ex)
            {
                Rhino.Runtime.HostUtils.DebugString("Exception caught during Options - User Text - CSV File Export");
                Rhino.Runtime.HostUtils.ExceptionReport(ex);
            }
        }
Esempio n. 4
0
		Control SaveFile ()
		{
			var button = new Button { Text = "Save File" };
			button.Click += delegate {
				var dialog = new SaveFileDialog ();
				var result = dialog.ShowDialog (this.ParentWindow);
				if (result == DialogResult.Ok) {
					Log.Write (dialog, "Result: {0}, FileName: {1}", result, dialog.FileName);
				}
				else
					Log.Write (dialog, "Result: {0}", result);
			};
			return button;
		}
Esempio n. 5
0
		void ItemDownload_Executed(object sender, EventArgs e)
		{
			var selectFile = _status.FileGridView.SelectedItem as FileInfoView;
			if (selectFile != null)
			{
				var webFile = selectFile.FullName;
				var name = Path.GetFileName(webFile);
				var saveFileDialog = new SaveFileDialog();
				saveFileDialog.Title = "Save File As";
				saveFileDialog.FileName = name;
				if (DialogResult.Ok == saveFileDialog.ShowDialog(_status.FileGridView))
				{
					DownloadFile(webFile, saveFileDialog.FileName);
				}
			}
		}
Esempio n. 6
0
		Control SaveFileWithFilters ()
		{
			var button = new Button { Text = "Save File With Filters" };
			button.Click += delegate {
				var dialog = new SaveFileDialog ();

				dialog.Filters = GetFilters ("Auto Detect");

				var result = dialog.ShowDialog (this.ParentWindow);
				if (result == DialogResult.Ok) {
					Log.Write (dialog, "Result: {0}, CurrentFilter: {1}, FileName: {2}", result, dialog.CurrentFilter, dialog.FileName);
				}
				else
					Log.Write (dialog, "Result: {0}", result);
			};
			return button;
		}
Esempio n. 7
0
        /// <summary>
        /// Display an save file dialog and returns the selected (specified) file name, null otherwise.
        /// </summary>
        /// <param name="windowTitle">Window title.</param>
        /// <param name="extensions">File extension mask.</param>
        /// <returns>Selected (specified) file name, null otherwise</returns>
        public static string SaveFile(string windowTitle = "Save file", params string[] extensions)
        {
            string fileName = null;

            using (SaveFileDialog dialog = new SaveFileDialog())
            {
                dialog.Title = windowTitle;
                dialog.Filters.Add(new FileDialogFilter("(Default)", extensions));
    
                var result = dialog.ShowDialog(null);
                if (result == DialogResult.Ok)
                    fileName = dialog.FileName;
            }

            return fileName;
        }
Esempio n. 8
0
        public PlotHandler()
        {
            var pview = new global::OxyPlot.WindowsForms.PlotView();

            Control = pview;

            ContextMenu cmenu = new ContextMenu();

            cmenu.Items.Add(new ButtonMenuItem((sender, e) =>
            {
                var pngExporter = new PngExporter {
                    Width = pview.Width, Height = pview.Height, Background = OxyColors.White
                };
                var bitmap = pngExporter.ExportToBitmap(pview.Model);
                System.Windows.Forms.Clipboard.SetImage(bitmap);
            })
            {
                Text = "Copy"
            });

            cmenu.Items.Add(new ButtonMenuItem((sender, e) =>
            {
                var pngExporter = new PngExporter {
                    Width = pview.Width * 2, Height = pview.Height * 2, Background = OxyColors.White
                };
                var bitmap = pngExporter.ExportToBitmap(pview.Model);
                System.Windows.Forms.Clipboard.SetImage(bitmap);
            })
            {
                Text = "Copy @ 2x"
            });

            cmenu.Items.Add(new ButtonMenuItem((sender, e) =>
            {
                var pngExporter = new PngExporter {
                    Width = pview.Width * 3, Height = pview.Height * 3, Background = OxyColors.White
                };
                var bitmap = pngExporter.ExportToBitmap(pview.Model);
                System.Windows.Forms.Clipboard.SetImage(bitmap);
            })
            {
                Text = "Copy @ 3x"
            });

            cmenu.Items.Add(new ButtonMenuItem((sender, e) =>
            {
                var sfd = new SaveFileDialog();

                sfd.Title = "Save Chart to PNG";
                sfd.Filters.Add(new FileFilter("PNG File", new string[] { ".png" }));
                sfd.CurrentFilterIndex = 0;

                if (sfd.ShowDialog(this.Widget) == DialogResult.Ok)
                {
                    var pngExporter = new PngExporter {
                        Width = pview.Width, Height = pview.Height, Background = OxyColors.White
                    };
                    pngExporter.ExportToFile(Model, sfd.FileName);
                }
            })
            {
                Text = "Save to File"
            });

            cmenu.Items.Add(new ButtonMenuItem((sender, e) =>
            {
                var sfd = new SaveFileDialog();

                sfd.Title = "Save Chart to PNG";
                sfd.Filters.Add(new FileFilter("PNG File", new string[] { ".png" }));
                sfd.CurrentFilterIndex = 0;

                if (sfd.ShowDialog(this.Widget) == DialogResult.Ok)
                {
                    var pngExporter = new PngExporter {
                        Width = pview.Width * 2, Height = pview.Height * 2, Background = OxyColors.White
                    };
                    pngExporter.ExportToFile(Model, sfd.FileName);
                }
            })
            {
                Text = "Save to File @ 2x"
            });

            cmenu.Items.Add(new ButtonMenuItem((sender, e) =>
            {
                var sfd = new SaveFileDialog();

                sfd.Title = "Save Chart to PNG";
                sfd.Filters.Add(new FileFilter("PNG File", new string[] { ".png" }));
                sfd.CurrentFilterIndex = 0;

                if (sfd.ShowDialog(this.Widget) == DialogResult.Ok)
                {
                    var pngExporter = new PngExporter {
                        Width = pview.Width * 3, Height = pview.Height * 3, Background = OxyColors.White
                    };
                    pngExporter.ExportToFile(Model, sfd.FileName);
                }
            })
            {
                Text = "Save to File @ 3x"
            });

            cmenu.Items.Add(new ButtonMenuItem((sender, e) =>
            {
                pview.Model.ResetAllAxes();
                pview.Model.InvalidatePlot(false);
            })
            {
                Text = "Reset to Default View"
            });

            this.ContextMenu = cmenu;
        }
Esempio n. 9
0
		void _itemSaveAs_Click(object sender, EventArgs e)
		{
		    var data = _dataTableResult;
			if (data != null)
			{
				var saveFileDialog = new SaveFileDialog
				{
					Filters =
					{
					    new FileDialogFilter("CSV(Comma Separated Values)|*.csv"),
					    new FileDialogFilter("TSV(Tab Separated Values)|*.txt")
					}
				};
				if (DialogResult.Ok == saveFileDialog.ShowDialog(_gridViewResult))
				{
					var fileName = saveFileDialog.FileName;
				    switch (saveFileDialog.CurrentFilterIndex)
				    {
				        case 0:
				            SaveAs(data, fileName);
				            break;
				        case 1:
				            SaveAs(data, fileName, "\t");
				            break;
				    }
				}
			}
		}
Esempio n. 10
0
 void _itemSaveAsCsv_Click(object sender, EventArgs e)
 {
     object dataSource = _gridViewResult.DataStore;
     if (dataSource != null)
     {
         var saveFileDialog = new SaveFileDialog
         {
             Filters = { new FileDialogFilter("CSV|*.CSV") }
         };
         if (DialogResult.Ok == saveFileDialog.ShowDialog(_gridViewResult))
         {
             var fileName = saveFileDialog.FileName;
             SaveAsCsv(dataSource as DataTable, fileName);
         }
     }
 }
Esempio n. 11
0
		Control SaveFileWithFilters()
		{
			var button = new Button { Text = "Save File With Filters" };
			button.Click += delegate
			{
				var dialog = new SaveFileDialog
				{
					Filters =
					{
						new FileDialogFilter("Auto Detect", ".png", ".jpg", ".jpeg", ".gif", ".tiff"),
						"PNG Files|.png",
						new FileDialogFilter("JPeg Files", ".jpg", ".jpeg"),
						new FileDialogFilter("GIF Files", ".gif"),
						new FileDialogFilter("TIFF Files", ".tiff"),
					}
				};
				SetAttributes(dialog);

				var result = dialog.ShowDialog(ParentWindow);
				if (result == DialogResult.Ok)
				{
					Log.Write(dialog, "Result: {0}, CurrentFilter: {1}, FileName: {2}", result, dialog.CurrentFilter, dialog.FileName);
				}
				else
					Log.Write(dialog, "Result: {0}", result);
			};
			return button;
		}
Esempio n. 12
0
        void OnButtonSaveAsClick(object sender, EventArgs e)
        {
            using (var dialog = new SaveFileDialog { Directory = new Uri(Environment.GetFolderPath(Environment.SpecialFolder.MyPictures)) }) {
                dialog.Filters.Add(new FileDialogFilter(Desktop.Properties.Resources.TextFilterPngFiles, Utilities.FileFilterPng));
                dialog.Filters.Add(new FileDialogFilter(Desktop.Properties.Resources.TextFilterAllFiles, Utilities.FileFilterAll));

                if (dialog.ShowDialog(this) != DialogResult.Ok) return;

                var fileName = dialog.FileName;
                Task.Factory.StartNew(() => SaveQrCodeImage(ImageViewQrCode.Image, fileName));
            }
        }
Esempio n. 13
0
 public string SaveFile()
 {
     using (var fileDialog = new SaveFileDialog())
         return fileDialog.ShowDialog(Owner) == DialogResult.Ok ? fileDialog.FileName : null;
 }
Esempio n. 14
-1
        /// <summary>
        /// 
        /// </summary>
        private void InitializeMenu()
        {
            #region File

            var newCommand = new Command()
            {
                MenuText = "&New",
                Shortcut = Application.Instance.CommonModifier | Keys.N
            };

            newCommand.Executed +=
            (s, e) =>
            {
                _context.Commands.NewCommand.Execute(null);
                if (_context.Invalidate != null)
                {
                    _context.Invalidate();
                }
            };

            var openCommand = new Command()
            {
                MenuText = "&Open...",
                Shortcut = Application.Instance.CommonModifier | Keys.O
            };

            openCommand.Executed +=
            (s, e) =>
            {
                var dlg = new OpenFileDialog();
                dlg.Filters.Add(new FileDialogFilter("Project", ".project"));
                dlg.Filters.Add(new FileDialogFilter("All", ".*"));

                var result = dlg.ShowDialog(this);
                if (result == DialogResult.Ok)
                {
                    _context.Open(dlg.FileName);
                    if (_context.Invalidate != null)
                    {
                        _context.Invalidate();
                    }
                }
            };

            var saveAsCommand = new Command()
            {
                MenuText = "Save &As...",
                Shortcut = Application.Instance.CommonModifier | Keys.S
            };

            saveAsCommand.Executed +=
            (s, e) =>
            {
                var dlg = new SaveFileDialog();
                dlg.Filters.Add(new FileDialogFilter("Project", ".project"));
                dlg.Filters.Add(new FileDialogFilter("All", ".*"));
                dlg.FileName = _context.Editor.Project.Name;
                var result = dlg.ShowDialog(this);
                if (result == DialogResult.Ok)
                {
                    _context.Save(dlg.FileName);
                }
            };

            var exportCommand = new Command()
            {
                MenuText = "&Export...",
                Shortcut = Application.Instance.CommonModifier | Keys.E
            };

            exportCommand.Executed +=
            (s, e) =>
            {
                var dlg = new SaveFileDialog();
                dlg.Filters.Add(new FileDialogFilter("Pdf", ".pdf"));
                dlg.Filters.Add(new FileDialogFilter("Dxf", ".dxf"));
                dlg.Filters.Add(new FileDialogFilter("All", ".*"));

                dlg.FileName = _context.Editor.Project.Name;
                var result = dlg.ShowDialog(this);
                if (result == DialogResult.Ok)
                {
                    string path = dlg.FileName;
                    int filterIndex = dlg.CurrentFilterIndex;
                    switch (filterIndex)
                    {
                        case 0:
                            _context.ExportAsPdf(path, _context.Editor.Project);
                            Process.Start(path);
                            break;
                        case 1:
                            _context.ExportAsDxf(path);
                            Process.Start(path);
                            break;
                        default:
                            break;
                    }
                }
            };

            var exitCommand = new Command()
            {
                MenuText = "E&xit",
                Shortcut = Application.Instance.AlternateModifier | Keys.F4
            };

            exitCommand.Executed +=
            (s, e) =>
            {
                Application.Instance.Quit();
            };

            #endregion

            #region Tool

            var noneTool = new Command()
            {
                MenuText = "&None",
                Shortcut = Keys.N
            };

            noneTool.Executed +=
            (s, e) =>
            {
                _context.Commands.ToolNoneCommand.Execute(null);
            };

            var selectionTool = new Command()
            {
                MenuText = "&Selection",
                Shortcut = Keys.S
            };

            selectionTool.Executed +=
            (s, e) =>
            {
                _context.Commands.ToolSelectionCommand.Execute(null);
            };

            var pointTool = new Command()
            {
                MenuText = "&Point",
                Shortcut = Keys.P
            };

            pointTool.Executed +=
            (s, e) =>
            {
                _context.Commands.ToolPointCommand.Execute(null);
            };

            var lineTool = new Command()
            {
                MenuText = "&Line",
                Shortcut = Keys.L
            };

            lineTool.Executed +=
            (s, e) =>
            {
                _context.Commands.ToolLineCommand.Execute(null);
            };

            var arcTool = new Command()
            {
                MenuText = "&Arc",
                Shortcut = Keys.A
            };

            arcTool.Executed +=
            (s, e) =>
            {
                _context.Commands.ToolArcCommand.Execute(null);
            };

            var bezierTool = new Command()
            {
                MenuText = "&Bezier",
                Shortcut = Keys.B
            };

            bezierTool.Executed +=
            (s, e) =>
            {
                _context.Commands.ToolBezierCommand.Execute(null);
            };

            var qbezierTool = new Command()
            {
                MenuText = "&QBezier",
                Shortcut = Keys.Q
            };

            qbezierTool.Executed +=
            (s, e) =>
            {
                _context.Commands.ToolQBezierCommand.Execute(null);
            };

            var pathTool = new Command()
            {
                MenuText = "Pat&h",
                Shortcut = Keys.H
            };

            pathTool.Executed +=
            (s, e) =>
            {
                _context.Commands.ToolPathCommand.Execute(null);
            };

            var rectangleTool = new Command()
            {
                MenuText = "&Rectangle",
                Shortcut = Keys.R
            };

            rectangleTool.Executed +=
            (s, e) =>
            {
                _context.Commands.ToolRectangleCommand.Execute(null);
            };

            var ellipseTool = new Command()
            {
                MenuText = "&Ellipse",
                Shortcut = Keys.E
            };

            ellipseTool.Executed +=
            (s, e) =>
            {
                _context.Commands.ToolEllipseCommand.Execute(null);
            };

            var textTool = new Command()
            {
                MenuText = "&Text",
                Shortcut = Keys.T
            };

            textTool.Executed +=
            (s, e) =>
            {
                _context.Commands.ToolTextCommand.Execute(null);
            };

            var imageTool = new Command()
            {
                MenuText = "&Image",
                Shortcut = Keys.I
            };

            imageTool.Executed +=
            (s, e) =>
            {
                _context.Commands.ToolImageCommand.Execute(null);
            };

            #endregion

            #region Edit

            var undoCommand = new Command()
            {
                MenuText = "&Undo",
                Shortcut = Application.Instance.CommonModifier | Keys.Z
            };

            undoCommand.Executed +=
            (s, e) =>
            {
                _context.Commands.UndoCommand.Execute(null);
            };

            var redoCommand = new Command()
            {
                MenuText = "&Redo",
                Shortcut = Application.Instance.CommonModifier | Keys.Y
            };

            redoCommand.Executed +=
            (s, e) =>
            {
                _context.Commands.RedoCommand.Execute(null);
            };

            var cutCommand = new Command()
            {
                MenuText = "Cu&t",
                Shortcut = Application.Instance.CommonModifier | Keys.X
            };

            cutCommand.Executed +=
            (s, e) =>
            {
                _context.Commands.CutCommand.Execute(null);
            };

            var copyCommand = new Command()
            {
                MenuText = "&Copy",
                Shortcut = Application.Instance.CommonModifier | Keys.C
            };

            copyCommand.Executed +=
            (s, e) =>
            {
                _context.Commands.CopyCommand.Execute(null);
            };

            var pasteCommand = new Command()
            {
                MenuText = "&Paste",
                Shortcut = Application.Instance.CommonModifier | Keys.V
            };

            pasteCommand.Executed +=
            (s, e) =>
            {
                _context.Commands.PasteCommand.Execute(null);
            };

            var deleteCommand = new Command()
            {
                MenuText = "&Delete",
                Shortcut = Keys.Delete
            };

            deleteCommand.Executed +=
            (s, e) =>
            {
                _context.Commands.DeleteCommand.Execute(null);
            };

            var selectAllCommand = new Command()
            {
                MenuText = "Select &All",
                Shortcut = Application.Instance.CommonModifier | Keys.A
            };

            selectAllCommand.Executed +=
            (s, e) =>
            {
                _context.Commands.SelectAllCommand.Execute(null);
            };

            var deSelectAllCommand = new Command()
            {
                MenuText = "De&select All",
                Shortcut = Keys.Escape
            };

            deSelectAllCommand.Executed +=
            (s, e) =>
            {
                _context.Commands.DeselectAllCommand.Execute(null);
            };

            var clearAllCommand = new Command()
            {
                MenuText = "Cl&ear All"
            };

            clearAllCommand.Executed +=
            (s, e) =>
            {
                _context.Commands.ClearAllCommand.Execute(null);
            };

            var groupCommand = new Command()
            {
                MenuText = "&Group",
                Shortcut = Application.Instance.CommonModifier | Keys.G
            };

            groupCommand.Executed +=
            (s, e) =>
            {
                _context.Commands.GroupCommand.Execute(null);
            };

            var ungroupCommand = new Command()
            {
                MenuText = "U&ngroup",
                Shortcut = Application.Instance.CommonModifier | Keys.U
            };

            ungroupCommand.Executed +=
            (s, e) =>
            {
                _context.Commands.UngroupCommand.Execute(null);
            };

            #endregion

            #region Menu

            var fileMenu = new ButtonMenuItem()
            {
                Text = "&File",
                Items =
                {
                    newCommand,
                    new SeparatorMenuItem(),
                    openCommand,
                    new SeparatorMenuItem(),
                    saveAsCommand,
                    new SeparatorMenuItem(),
                    exportCommand
                }
            };

            var editMenu = new ButtonMenuItem()
            {
                Text = "&Edit",
                Items =
                {
                    undoCommand,
                    redoCommand,
                    new SeparatorMenuItem(),
                    cutCommand,
                    copyCommand,
                    pasteCommand,
                    deleteCommand,
                    new SeparatorMenuItem(),
                    selectAllCommand,
                    deSelectAllCommand,
                    new SeparatorMenuItem(),
                    clearAllCommand,
                    new SeparatorMenuItem(),
                    groupCommand,
                    ungroupCommand
                }
            };

            var toolMenu = new ButtonMenuItem()
            {
                Text = "&Tool",
                Items =
                {
                    noneTool,
                    new SeparatorMenuItem(),
                    selectionTool,
                    new SeparatorMenuItem(),
                    pointTool,
                    new SeparatorMenuItem(),
                    lineTool,
                    arcTool,
                    bezierTool,
                    qbezierTool,
                    new SeparatorMenuItem(),
                    pathTool,
                    new SeparatorMenuItem(),
                    rectangleTool,
                    ellipseTool,
                    new SeparatorMenuItem(),
                    textTool,
                    new SeparatorMenuItem(),
                    imageTool
                }
            };

            var aboutCommand = new Command()
            {
                MenuText = "&About..."
            };
            aboutCommand.Executed +=
            (s, e) =>
            {
                MessageBox.Show(this, Platform.ID);
            };

            Menu = new MenuBar
            {
                Items =
                {
                    fileMenu,
                    editMenu,
                    toolMenu
                },
                QuitItem = exitCommand,
                AboutItem = aboutCommand
            };

            #endregion
        }