Beispiel #1
0
 public void OnOpenMenuClick(object o, Event e)
 {
     ((Models.Form1)Model).CloseCurrentFileStream();
     FileDialog fd = new FileDialog(this.View, strings.OpenFile);
     if (ShowModalResult.OK == fd.ShowModal())
     {
         ((Models.Form1)Model).GetFileStream(string.Format(@"{0}\{1}", fd.Directory, fd.Filename));
     }
 }
Beispiel #2
0
        private static void PromptDialog(FileDialog dialog)
        {
            dialog.InitialDirectory = Directory
                .GetParent("../../").FullName; // Environment.GetFolderPath(Environment.SpecialFolder.Desktop);

            while (dialog.ShowDialog() != DialogResult.OK)
            {
                Console.WriteLine("You have to select a file, try again.");
            }
        }
 // This function doesn't work on Windows XP
 // NOT SUPPORTED ON XP
 public static void OpenFileDialogAddCustomPaths(FileDialog dialog)
 {
     try
     {
         // Import the soundfont favorites file from Keppy's Synthesizer
         using (StreamReader r = new StreamReader(System.Environment.GetEnvironmentVariable("USERPROFILE").ToString() + "\\Keppy's Synthesizer\\keppymididrv.favlist"))
         {
             string line;
             while ((line = r.ReadLine()) != null)
             {
                 dialog.CustomPlaces.Add(line);
             }
         }
     }
     catch
     {
         // Trigger nothing
     }
 }
            public static bool SelectPath(out string path)
            {
                var dlg = new FileDialog {
                    AllowedFileTypes = new string[] { Document.Current.GetFileExtension() },
                    Mode             = FileDialogMode.Save,
                    InitialDirectory = Path.GetDirectoryName(Document.Current.FullPath)
                };

                path = null;
                if (!dlg.RunModal())
                {
                    return(false);
                }
                if (!Project.Current.TryGetAssetPath(dlg.FileName, out path))
                {
                    AlertDialog.Show("Can't save the document outside the project directory");
                    return(false);
                }
                return(true);
            }
Beispiel #5
0
        public static void SetCommonImageFilter(this FileDialog fileDialog, string defaultExtension)
        {
            List <ImageCodecInfo> codecs  = ImageCodecInfo.GetImageEncoders().ToList();
            string        imageExtensions = string.Join(";", codecs.Select(ici => ici.FilenameExtension));
            List <string> separateFilters = new List <string>();

            foreach (ImageCodecInfo codec in codecs)
            {
                separateFilters.Add(string.Format("{0} Files ({1})|{1}", codec.FormatDescription, codec.FilenameExtension.ToLowerInvariant()));
            }
            fileDialog.Filter = string.Format("{0}|Image Files ({1})|{1}|All Files (*.*)|*.*", string.Join("|", separateFilters), imageExtensions.ToLowerInvariant());
            if (defaultExtension != null)
            {
                fileDialog.FilterIndex = (codecs.IndexOf(codecs.FirstOrDefault(x => x.FormatDescription.ToLowerInvariant().Contains(defaultExtension.ToLowerInvariant()))) + 1);
            }
            else
            {
                fileDialog.FilterIndex = (codecs.Count + 1);
            }
        }
Beispiel #6
0
        public static void ConvertFileDialogFilters(FileDialog fileDlg, string filter)
        {
            if (fileDlg == null)
            {
                throw new ArgumentNullException("fileDlg");
            }

            var filterParts = filter.Split('|');
            int filtersNum  = filterParts.Length / 2;

            for (int i = 0; i < filtersNum; i++)
            {
                int      idx        = i * 2;
                string   name       = filterParts[idx];
                string   exts       = filterParts[idx + 1];
                string[] extensions = exts.Split(',');

                fileDlg.Filters.Add(new FileDialogFilter(name, extensions));
            }
        }
Beispiel #7
0
        private string getFileName(FileDialog fileDialog)
        {
            fileDialog.InitialDirectory = @"c:\Temp\DataChartTest";
            fileDialog.Filter           = "xml files (*.xml)|*.xml";
            fileDialog.FilterIndex      = 2;
            fileDialog.RestoreDirectory = true;

            string fileName;

            if (fileDialog.ShowDialog() != DialogResult.OK)
            {
                fileName = string.Empty;
            }
            else
            {
                fileName = fileDialog.FileName;
            }

            return(fileName);
        }
Beispiel #8
0
 public void Execute(object parameter)
 {
     if (_saveInstantly && !string.IsNullOrEmpty(_vm.ProjectFileName))
     {
         _vm.SaveProject();
     }
     else
     {
         var fd = FileDialog.Factory(parameter as System.Windows.Window, FileDialog.Behavior.Save,
                                     FileDialog.Type.XeGameProject);
         if (fd.ShowDialog() ?? false == true)
         {
             Common.SendMessage(MessageType.Initialization, "Saving project...");
             _vm.SaveProject(fd.FileName);
             Properties.Settings.Default.FileLastOpen = fd.FileName;
             Properties.Settings.Default.Save();
             Common.SendMessage(MessageType.Idle, "Ready");
         }
     }
 }
Beispiel #9
0
        public BlendMapGenerator(LineEdit inputEdit,
                                 LineEdit outputEdit,
                                 Tree sourceList,
                                 Tree morphList,
                                 Label progressLabel,
                                 ProgressBar progressBar,
                                 Button inputButton,
                                 Button outputButton,
                                 Button startButton,
                                 Button closeButton,
                                 FileDialog fileDialog,
                                 Label infoLabel,
                                 Godot.Control node,
                                 ILoggerFactory loggerFactory) : base(node, loggerFactory)
        {
            Ensure.That(inputEdit, nameof(inputEdit)).IsNotNull();
            Ensure.That(outputEdit, nameof(outputEdit)).IsNotNull();
            Ensure.That(sourceList, nameof(sourceList)).IsNotNull();
            Ensure.That(morphList, nameof(morphList)).IsNotNull();
            Ensure.That(progressLabel, nameof(progressLabel)).IsNotNull();
            Ensure.That(progressBar, nameof(progressBar)).IsNotNull();
            Ensure.That(inputButton, nameof(inputButton)).IsNotNull();
            Ensure.That(outputButton, nameof(inputButton)).IsNotNull();
            Ensure.That(startButton, nameof(startButton)).IsNotNull();
            Ensure.That(closeButton, nameof(closeButton)).IsNotNull();
            Ensure.That(fileDialog, nameof(fileDialog)).IsNotNull();
            Ensure.That(infoLabel, nameof(infoLabel)).IsNotNull();

            InputEdit     = inputEdit;
            OutputEdit    = outputEdit;
            SourceList    = sourceList;
            MorphList     = morphList;
            ProgressLabel = progressLabel;
            ProgressBar   = progressBar;
            InputButton   = inputButton;
            OutputButton  = outputButton;
            StartButton   = startButton;
            CloseButton   = closeButton;
            FileDialog    = fileDialog;
            InfoLabel     = infoLabel;
        }
Beispiel #10
0
        public MainViewModel()
        {
            Actions = new ActionsViewModel();

            PlayActionCommand = new RelayCommand(x =>
            {
                PaletteAnimator.ResetPalette();
                PaletteAnimator.PlayAction(Actions?.SelectedItem.Action);
            }, x => true);

            PlayCommandCommand = new RelayCommand(x =>
            {
                PaletteAnimator.ResetPalette();
                PaletteAnimator.PlayCommand(Actions?.SelectedItem?.SelectedItem?.Command);
            }, x => true);

            StopCommand = new RelayCommand(x =>
            {
                PaletteAnimator.ResetPalette();
                PaletteAnimator.PlayAction((PalAction)null);
            }, x => true);

            LoadImageCommand = new RelayCommand(x =>
            {
                var fd = FileDialog.Factory(null, FileDialog.Behavior.Open, FileDialog.Type.ImagePng);
                if (fd.ShowDialog() == true)
                {
                    var bitmap = new BitmapImage(new System.Uri(fd.FileName));
                    if (bitmap.Format == PixelFormats.Indexed8)
                    {
                        PaletteAnimator.LoadPalette(bitmap);
                        Spritesheet = bitmap;
                    }
                    else
                    {
                        MessageBox.Show("The selected image does not contain any palette.",
                                        "Warning", MessageBoxButton.OK, MessageBoxImage.Warning);
                    }
                }
            }, x => true);
        }
Beispiel #11
0
		private void OnChangeFolder(object sender, EventArgs e)
		{
			var dlg = new FileDialog(FileDialogMode.ChooseFolder);

			try
			{
				if (!string.IsNullOrEmpty(_mainPanel._textPath.Text))
				{
					dlg.Folder = _mainPanel._textPath.Text;
				}
				else
				{
					var folder = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
					dlg.Folder = folder;
				}
			}
			catch (Exception)
			{
			}

			dlg.Closed += (s, a) =>
			{
				if (!dlg.Result)
				{
					return;
				}

				var gameType = ResourceLoader.DetermineGameType(dlg.FilePath);
				if (gameType == null)
				{
					var messageBox = Dialog.CreateMessageBox("Error", "The game isnt supported.");
					messageBox.ShowModal(_desktop);
				}
				else
				{
					SetFolder(dlg.FilePath);
				}
			};

			dlg.ShowModal(_desktop);
		}
        public PhotosViewModel(IEnumerable <PhotoEntryViewModel> list) :
            base(list.Where(x => x.Image != null))
        {
            ExportAllCommand = new RelayCommand(o =>
            {
                FileDialog.OnFolder(folder =>
                {
                    try
                    {
                        foreach (var item in Items)
                        {
                            item.Export(Path.Combine(folder, $"Kingdom Hearts III - Photo {item.Index}.jpg"));
                        }
                    }
                    catch (Exception e)
                    {
                        MessageBox.Show(Window, $"Unable to export all the photo due to the following error:\n{e.Message}", "Error", MessageBoxButton.OK,
                                        MessageBoxImage.Error);
                    }
                });
            }, x => true);

            DeleteAllCommand = new RelayCommand(o =>
            {
                const string msg = "Do you really want to delete all the photos?\nYou still can not save if you change your mind.";
                var result       = MessageBox.Show(Window, msg, "Delete all photos", MessageBoxButton.YesNo,
                                                   MessageBoxImage.Warning);

                if (result == MessageBoxResult.Yes)
                {
                    foreach (var item in Items)
                    {
                        item.Delete();
                    }
                }

                Items.Clear();
                OnPropertyChanged(nameof(Info));
                OnPropertyChanged(nameof(Items));
            }, x => true);
        }
Beispiel #13
0
    public override void _Ready()
    {
        cb_skip = GetNode <CheckBox>("Panel/VBoxContainer/hb_cue3/CheckBox");
        GD.Print("Started Emulator settings Scene");
        selected_emulator = EMULATOR.None;
        fileDialog        = GetNode <FileDialog>("FileDialog");

        le_bios = GetNode <LineEdit>("Panel/VBoxContainer/hb_bios/le_bios");
        le_exe  = GetNode <LineEdit>("Panel/VBoxContainer/hb_exe/le_exe");
        le_cue  = GetNode <LineEdit>("Panel/VBoxContainer/hb_cue/le_cue");

        bt_open_bios = GetNode <Button>("Panel/VBoxContainer/hb_bios/bt_open_bios");
        bt_open_cue  = GetNode <Button>("Panel/VBoxContainer/hb_cue/bt_open_cue");
        bt_open_exe  = GetNode <Button>("Panel/VBoxContainer/hb_exe/bt_open_exe");

        bt_cancel = GetNode <Button>("Panel/VBoxContainer/hb_buttons/bt_cancel");
        bt_test   = GetNode <Button>("Panel/VBoxContainer/hb_buttons/bt_test");
        bt_done   = GetNode <Button>("Panel/VBoxContainer/hb_buttons/bt_done");

        ob_option = GetNode <OptionButton>("Panel/VBoxContainer/hb_emulator/ob_emulator");

        bt_cancel.Visible = false;

        dataEmulator = DataManager.LoadEmulator();

        if (dataEmulator != null)
        {
            int id = dataEmulator.selectedID;
            ob_option.Select(id + 1);
            ob_option.EmitSignal("item_selected", id + 1);
            cb_skip.Pressed = dataEmulator.skipWindow;
            GD.Print("loaded data from emulator");
        }
        else
        {
            dataEmulator = new DataEmulator();
            GD.Print("create a new data for emulator");
        }

        Connect("output", this, "OnOutput");
    }
        public ImportSettingsPage() :
            base("Cancel")
        {
            var container = new FlowLayoutWidget(FlowDirection.TopToBottom);

            contentRow.AddChild(container);

            var newPrinterButton = new RadioButton("Import as new printer profile".Localize(), textColor: ActiveTheme.Instance.PrimaryTextColor);

            newPrinterButton.CheckedStateChanged += (s, e) => importMode = "new";
            newPrinterButton.Checked              = true;
            container.AddChild(newPrinterButton);
            this.importMode = "new";

            var mergeButton = new RadioButton("Merge into current printer profile".Localize(), textColor: ActiveTheme.Instance.PrimaryTextColor);

            mergeButton.CheckedStateChanged += (s, e) => importMode = "merge";
            container.AddChild(mergeButton);

            var replaceButton = new RadioButton("Replace current printer profile".Localize(), textColor: ActiveTheme.Instance.PrimaryTextColor);

            replaceButton.CheckedStateChanged += (s, e) => importMode = "replace";
            container.AddChild(replaceButton);

            var importButton = textImageButtonFactory.Generate("Import Settings".Localize());

            importButton.Click += (s, e) => UiThread.RunOnIdle(() =>
            {
                FileDialog.OpenFileDialog(
                    new OpenFileDialogParams("settings files|*.ini;*.printer,"),
                    (dialogParams) => ImportSettingsFile(dialogParams.FileName));
            });

            importButton.Visible = true;
            cancelButton.Visible = true;

            //Add buttons to buttonContainer
            footerRow.AddChild(importButton);
            footerRow.AddChild(new HorizontalSpacer());
            footerRow.AddChild(cancelButton);
        }
 public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
 {
     if ((provider != null) && (((IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService))) != null))
     {
         if (this.fileDialog == null)
         {
             this.fileDialog        = new OpenFileDialog();
             this.fileDialog.Title  = System.Design.SR.GetString("XMLFilePicker_Caption");
             this.fileDialog.Filter = System.Design.SR.GetString("XMLFilePicker_Filter");
         }
         if (value != null)
         {
             this.fileDialog.FileName = value.ToString();
         }
         if (this.fileDialog.ShowDialog() == DialogResult.OK)
         {
             value = this.fileDialog.FileName;
         }
     }
     return(value);
 }
Beispiel #16
0
        private void browseJsonFile(TextBox filePathTextBox)
        {
            FileDialog d = Mode == Mode.Pack ? (FileDialog) new OpenFileDialog() : (FileDialog) new SaveFileDialog();

            d.DefaultExt = "json";
            d.Filter     = "JSON files (*.json)|*.json";
            if (savPathTextBox.Text == "")
            {
                d.InitialDirectory = Path.Combine(GetKnownFolderPath(localLowGuid), savePath);
            }
            else
            {
                d.FileName = filePathTextBox.Text;
            }

            if (d.ShowDialog() == DialogResult.OK)
            {
                filePathTextBox.Text           = d.FileName;
                filePathTextBox.SelectionStart = filePathTextBox.Text.Length;
            }
        }
Beispiel #17
0
 /// <summary>
 /// Browse button was clicked by user.
 /// </summary>
 /// <param name="sender">Sender object</param>
 /// <param name="e">The params</param>
 private void OnBrowseButtonClicked(object sender, EventArgs e)
 {
     try
     {
         IFileDialog dialog = new FileDialog()
         {
             Prompt   = "Choose files",
             Action   = FileDialog.FileActionType.Open,
             FileType = "CSV Files (*.csv)|*.csv|All Files (*.*)|*.*",
         };
         string[] files = dialog.GetFiles();
         if (files != null && files.Length > 0)
         {
             explorerPresenter.CommandHistory.Add(new Commands.ChangeProperty(input, "FullFileNames", files));
         }
     }
     catch (Exception err)
     {
         explorerPresenter.MainPresenter.ShowError(err);
     }
 }
Beispiel #18
0
 protected override void Load()
 {
     Title = "Librelancer";
     imGui = new ImGuiHelper(this, DpiScale);
     RenderContext.PushViewport(0, 0, Width, Height);
     FileDialog.RegisterParent(this);
     freelancerFolder = new TextBuffer(512);
     config           = GameConfig.Create();
     freelancerFolder.SetText(config.FreelancerPath);
     resolutionX     = config.BufferWidth;
     resolutionY     = config.BufferHeight;
     vsync           = config.Settings.VSync;
     skipIntroMovies = !config.IntroMovies;
     masterVolume    = config.Settings.MasterVolume;
     musicVolume     = config.Settings.MusicVolume;
     sfxVolume       = config.Settings.SfxVolume;
     if (Program.introForceDisable)
     {
         skipIntroMovies = true;
     }
 }
Beispiel #19
0
        /// <summary>
        /// Opens a "FileDialog" prompt window and returns the Dialog Result if blocking, otherwise DialogResult.OK.
        /// Call will block if a delegate isn't passed.
        /// </summary>
        /// <param name="fd">Reference of a FileDialog </param>
        /// <param name="onfinish">If a delegate is passed, then it doesn't block.</param>
        /// <returns></returns>
        public static DialogResult FileDialog(ref FileDialog fd, onDialogFinished onfinish = null)
        {
            DialogResult dr = new DialogResult();
            Oper         o  = new Oper(ref fd, ref dr)
            {
                _callback = onfinish
            };
            Thread thread = new Thread(() => FileDialog_DoWork(o));

            thread.SetApartmentState(ApartmentState.STA);
            thread.Start();
            if (onfinish != null)
            {
                return(DialogResult.OK);
            }
            while (!o._isFinished)
            {
                Thread.Sleep(100);
            }
            return(o._dr);
        }
Beispiel #20
0
        public static GeneratorType?GetSelectedGeneratorType(FileDialog dialog)
        {
            switch (dialog.FilterIndex)
            {
            case 1:
                switch (Path.GetExtension(dialog.FileName))
                {
                case ".l": return(GeneratorType.Lexer);

                case ".y": return(GeneratorType.Parser);

                default: return(null);
                }

            case 2: return(GeneratorType.Lexer);

            case 3: return(GeneratorType.Parser);

            default: return(null);
            }
        }
Beispiel #21
0
        public void SaveSettingsFile()
        {
            var fileDialog = new FileDialog(FileDialogMode.SaveFile);

            fileDialog.ShowModal(Desktop);

            fileDialog.Closed += (s, a) =>
            {
                if (!fileDialog.Result)
                {
                    return;
                }

                using (StreamWriter sr = File.CreateText(fileDialog.FilePath))
                {
                    JsonSerializer serializer = new JsonSerializer();
                    serializer.TypeNameHandling = TypeNameHandling.All;
                    serializer.Serialize(sr, simSettings);
                }
            };
        }
Beispiel #22
0
 protected override void Load()
 {
     Title     = "System Viewer";
     guiHelper = new ImGuiHelper(this);
     FileDialog.RegisterParent(this);
     Viewport = new ViewportManager(this.RenderState);
     Viewport.Push(0, 0, 800, 600);
     Billboards = new Billboards();
     Nebulae    = new NebulaVertices();
     Resources  = new GameResourceManager(this);
     Renderer2D = new Renderer2D(this.RenderState);
     RichText   = Renderer2D.CreateRichTextEngine();
     Services.Add(Billboards);
     Services.Add(Nebulae);
     Services.Add(Resources);
     Services.Add(Renderer2D);
     fontMan = new FontManager(this);
     fontMan.ConstructDefaultFonts();
     Services.Add(fontMan);
     Services.Add(new GameConfig());
 }
Beispiel #23
0
        public override void Execute()
        {
            var dlg = new FileDialog {
                AllowedFileTypes = new string[] { "layout" },
                Mode             = FileDialogMode.Save
            };

            if (dlg.RunModal())
            {
                string path = dlg.FileName;
                try {
                    var state = DockManager.Instance.ExportState();
                    using (var fileStream = new FileStream(path, FileMode.OpenOrCreate)) {
                        serializer.ToStream(state, fileStream);
                    }
                }
                catch (System.Exception e) {
                    AlertDialog.Show(e.Message);
                }
            }
        }
Beispiel #24
0
        private static void AddFilterToDialog(FileDialog fd, string filterName, params string[] extensions)
        {
            var sb = new StringBuilder();

            foreach (var ext in extensions)
            {
                if (sb.Length == 0)
                {
                    sb.Append(ext);
                }
                else
                {
                    sb.AppendFormat(";{0}", ext);
                }
            }

            fd.Filter += string.Format("{2}{0} ({1})|{1}",
                                       filterName,
                                       sb,
                                       (fd.Filter.Length > 0) ? "|" : "");
        }
Beispiel #25
0
        void createPartsSheetsButton_Click(object sender, EventArgs mouseEvent)
        {
                        #if !__ANDROID__
            List <PrintItem> parts = QueueData.Instance.CreateReadOnlyPartList();

            FileDialog.SaveFileDialog(
                new SaveFileDialogParams("Save Parts Sheet|*.pdf"),
                (saveParams) =>
            {
                string partFileName = saveParams.FileName;

                if (!partFileName.StartsWith("" + Path.DirectorySeparatorChar))
                {
                    partFileName = Path.DirectorySeparatorChar + partFileName;
                }

                PartsSheet currentPartsInQueue = new PartsSheet(parts, partFileName);
                currentPartsInQueue.SaveSheets();
            });
                        #endif
        }
Beispiel #26
0
        /// <summary>
        /// Save the SQL query as specified
        /// </summary>
        private void OnSaveAsClicked(object sender, EventArgs e)
        {
            try
            {
                IFileDialog fileDialog = new FileDialog()
                {
                    Prompt   = "Select query file.",
                    Action   = FileDialog.FileActionType.Save,
                    FileType = "SQL files (*.sql)|*.sql|Text files (*.txt)|*.txt"
                };

                string filename = fileDialog.GetFile();
                fileentry.Text = filename;

                File.WriteAllText(filename, Sql);
            }
            catch (Exception error)
            {
                ShowError(error);
            }
        }
Beispiel #27
0
        public void onFileOpen(object sender, EventArgs e)
        {
            FileDialog fd = sender as FileDialog;

            string filePath = fd.SelectedFileFullPath;

            //try {
            string ext = Path.GetExtension(filePath);

            if (string.Equals(ext, ".sln", StringComparison.InvariantCultureIgnoreCase))
            {
                CurrentSolution  = new SolutionView(this, filePath);
                LastOpenSolution = filePath;
                //				}else if (string.Equals (ext, ".csproj", StringComparison.InvariantCultureIgnoreCase)) {
                //					currentProject = new Project (filePath);
            }

            /*} catch (Exception ex) {
             *      LoadIMLFragment ("<MessageBox Message='" + ex.Message + "\n" + "' MsgType='Error'/>");
             * }*/
        }
Beispiel #28
0
        public override void _Ready()
        {
            GetTree().SetScreenStretch(SceneTree.StretchMode.Mode2d, SceneTree.StretchAspect.Ignore, new Vector2(1920, 1080));
            OS.SetWindowMaximized(true);

            _graphEdit           = GetNode <GraphEdit>("VBoxContainer/GraphEdit");
            _resourcePreloader   = GetNode <ResourcePreloader>("ResourcePreloader");
            _eventSelectorDialog = GetNode <WindowDialog>("EventSelectorDialog");
            _nodeSelectorDialog  = GetNode <WindowDialog>("NodeSelectorDialog");
            _openFileDialog      = GetNode <FileDialog>("OpenFileDialog");
            _saveFileDialog      = GetNode <FileDialog>("SaveFileDialog");

            var eventItemList = _eventSelectorDialog.GetNode <ItemList>("VBoxContainer/ItemList");

            foreach (var key in GameEventDispatcher.GameEventMapping.Keys)
            {
                var evt = GameEventDispatcher.GameEventMapping[key];
                eventItemList.AddItem(evt.DisplayName);
            }
            eventItemList.Connect("item_activated", this, nameof(OnQuestEventItemActivated));

            var nodeItemList = _nodeSelectorDialog.GetNode <ItemList>("VBoxContainer/ItemList");

            nodeItemList.AddItem(nameof(QuestStartNode));
            nodeItemList.AddItem(nameof(QuestStageNode));
            nodeItemList.AddItem(nameof(QuestEventNode));
            nodeItemList.AddItem(nameof(QuestCompleteNode));
            nodeItemList.AddItem(nameof(QuestRewardNode));
            nodeItemList.Connect("item_activated", this, nameof(OnNodeSelectorSelected));

            GetNode("VBoxContainer/HBoxContainer/AddNode").Connect("pressed", this, nameof(OnAddNodePressed));
            GetNode("VBoxContainer/HBoxContainer/SaveButton").Connect("pressed", this, nameof(OnSaveButtonPressed));
            GetNode("VBoxContainer/HBoxContainer/OpenButton").Connect("pressed", this, nameof(OnOpenButtonPressed));

            _graphEdit.Connect("connection_request", this, nameof(OnConnectionRequest));
            _graphEdit.Connect("disconnection_request", this, nameof(OnDisconnectRequest));

            _openFileDialog.Connect("file_selected", this, nameof(OnFileSelected));
            _saveFileDialog.Connect("file_selected", this, nameof(OnSaveFileSelected));
        }
Beispiel #29
0
        private FileDialogResult ShowFileDialog(object ownerViewModel, FileDialog dialog, string title, IList <FileType> fileTypes, FileType defaultFileType, string defaultFileName)
        {
            if (!string.IsNullOrEmpty(title))
            {
                dialog.Title = title;
            }
            List <FileType> fileTypesList = fileTypes.ToList();
            int             filterIndex   = fileTypesList.IndexOf(defaultFileType);

            if (filterIndex >= 0)
            {
                dialog.FilterIndex = filterIndex + 1;
            }
            if (!string.IsNullOrEmpty(defaultFileName))
            {
                dialog.FileName = Path.GetFileName(defaultFileName);
                string directory = Path.GetDirectoryName(defaultFileName);
                if (!string.IsNullOrEmpty(directory))
                {
                    dialog.InitialDirectory = directory;
                }
            }

            dialog.Filter = CreateFilter(fileTypesList);
            if (dialog.ShowDialog(FindOwnerWindow(ownerViewModel)) == true)
            {
                filterIndex = dialog.FilterIndex - 1;
                if (filterIndex >= 0 && filterIndex < fileTypesList.Count)
                {
                    defaultFileType = fileTypesList[filterIndex];
                }
                else
                {
                    defaultFileType = null;
                }
                return(new FileDialogResult(dialog.FileName, defaultFileType));
            }

            return(new FileDialogResult());
        }
Beispiel #30
0
        ///<summary>When isImport is true, prompts users to select file and returns the full file path if OK clicked, otherwise an empty string.
        ///When isImport is false (export), prompts user to select a file destination if OK clicked, otherwise an empty string..</summary>
        private string GetFilenameFromUser(bool isImport)
        {
            Cursor = Cursors.WaitCursor;
            string initialDirectory = "";

            if (Directory.Exists(PrefC.GetString(PrefName.DocPath)))
            {
                initialDirectory = PrefC.GetString(PrefName.DocPath);
            }
            else if (Directory.Exists("C:\\"))
            {
                initialDirectory = "C:\\";
            }
            FileDialog dlg = null;

            if (isImport)
            {
                dlg = new OpenFileDialog();
            }
            else              //Export
            {
                dlg             = new SaveFileDialog();
                dlg.Filter      = "(*.txt)|*.txt|All files (*.*)|*.*";
                dlg.FilterIndex = 1;
                dlg.DefaultExt  = ".txt";
                dlg.FileName    = "ExportedMedications.txt";
            }
            dlg.InitialDirectory = initialDirectory;
            if (dlg.ShowDialog() != DialogResult.OK)
            {
                dlg = null;
            }
            else if (isImport && !File.Exists(dlg.FileName))
            {
                MsgBox.Show(this, "Error accessing file.");
                dlg = null;
            }
            Cursor = Cursors.Default;
            return(dlg == null ? "" : dlg.FileName);
        }
Beispiel #31
0
        void loadFile_Click(object sender, MouseEventArgs mouseEvent)
        {
            OpenFileDialogParams openParams = new OpenFileDialogParams("Select an STL file, Select a GCODE file|*.stl;*.gcode", multiSelect: true);

            FileDialog.OpenFileDialog(ref openParams);
            if (openParams.FileNames != null)
            {
                foreach (string loadedFileName in openParams.FileNames)
                {
                    PrintItem printItem = new PrintItem();
                    printItem.Name                  = System.IO.Path.GetFileNameWithoutExtension(loadedFileName);
                    printItem.FileLocation          = System.IO.Path.GetFullPath(loadedFileName);
                    printItem.PrintItemCollectionID = ToolsListControl.Instance.LibraryCollection.Id;
                    printItem.Commit();

                    ToolsListItem queueItem = new ToolsListItem(new PrintItemWrapper(printItem));
                    ToolsListControl.Instance.AddChild(queueItem);
                }
                ToolsListControl.Instance.Invalidate();
            }
            ToolsListControl.Instance.SaveLibraryItems();
        }
Beispiel #32
0
        void LoadFiles()
        {
            var prev = FileDialog.Filter;

            try
            {
                string mask = GetMask();
                FileDialog.Filter = mask + " files | " + mask;
                if (FileDialog.ShowDialog() == DialogResult.OK)
                {
                    foreach (var f in FileDialog.FileNames)
                    {
                        AddFile(f);
                    }
                }
                _sorter();
            }
            finally
            {
                FileDialog.Filter = prev;
            }
        }
        /// <summary>
        /// Set the initial directory and filename properties of a file dialog to match a particular path.
        /// </summary>
        /// <param name="fd">The file dialog to set the properties of.</param>
        /// <param name="path">The path to set as the initial selection in the dialog.</param>
        public static void SetDirectoryAndFilename(this FileDialog fd, string path)
        {
            if (fd is null)
            {
                throw new ArgumentNullException(nameof(fd));
            }
            if (string.IsNullOrWhiteSpace(path))
            {
                fd.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
                fd.FileName         = "";
                return;
            }
            string folder = Path.GetDirectoryName(path);

            if (Directory.Exists(folder))
            {
                fd.InitialDirectory = folder;
            }
            string fn = Path.GetFileName(path);

            fd.FileName = fn;
        }
 /// <summary>
 /// Saves the file dialog folder.
 /// </summary>
 /// <param name="key">The key.</param>
 /// <param name="regKeyName">Name of the reg key.</param>
 /// <param name="dialog">The dialog.</param>
 private void SaveFileDialogFolder(RegistryKey key, string regKeyName, FileDialog dialog)
 {
     string fileName = dialog.FileName;
     if (fileName != null && fileName.Length > 0)
     {
         FileInfo fileInfo = new FileInfo(fileName);
         key.SetValue(regKeyName, fileInfo.DirectoryName);
     }
 }
 /// <summary>
 /// Loads the folder dialog.
 /// </summary>
 /// <param name="dialog">The dialog.</param>
 /// <param name="folder">The folder.</param>
 private void LoadFolderDialog(string folder, FileDialog dialog)
 {
     if (folder != null && folder.Length > 0)
     {
         dialog.InitialDirectory = folder;
     }
 }
Beispiel #36
0
 public void OnSaveAsMenuClick(object o, Event e)
 {
     FileDialog fd = new FileDialog(this.View, strings.SaveFile);
     fd.WindowStyle = WindowStyles.FD_SAVE;
     if (ShowModalResult.OK == fd.ShowModal())
     {
         ((Models.Form1)Model).SaveFileStream(string.Format(@"{0}\{1}", fd.Directory, fd.Filename), ((Views.Form1)this.View).text.Value, false);
     }
 }
Beispiel #37
0
 /* STAShowDialog takes a FileDialog and shows it on a background STA thread and returns the results.
  * Usage:
  *   OpenFileDialog d = new OpenFileDialog();
  *   DialogResult ret = STAShowDialog(d);
  *   if (ret == DialogResult.OK)
  *      MessageBox.Show(d.FileName);
  */
 public static DialogResult STAShowDialog(FileDialog dialog)
 {
     DialogState state = new DialogState();
     state.dialog = dialog;
     System.Threading.Thread t = new System.Threading.Thread(state.ThreadProcShowDialog);
     t.SetApartmentState(System.Threading.ApartmentState.STA);
     t.Start();
     t.Join();
     return state.result;
 }
        private void SalvarSelos()
        {
            if (!String.IsNullOrEmpty(arquivo.NomeArquivo))
            {
                arquivo.Salvar();

                Android.Widget.Toast.MakeText(this,
                    GetString(Resource.String.saveMessage), ToastLength.Long).Show();

                return;
            }

            FileDialog dialog = new FileDialog(this, FileDialog.DialogMode.Save);

            dialog.OnPositive += delegate
            {
                if (!String.IsNullOrEmpty(dialog.FileName))
                {
                    arquivo.NomeArquivo = dialog.FileName;

                    arquivo.Salvar();

                    Android.Widget.Toast.MakeText(this,
                        GetString(Resource.String.saveMessage), ToastLength.Long).Show();
                }
            };

     
            dialog.Show();
        }
        private void CarregarSelos()
        {
            FileDialog dialog = new FileDialog(this, FileDialog.DialogMode.Load);

            dialog.OnPositive += delegate 
            {
                if (!String.IsNullOrEmpty(dialog.FileName))
                {
                    arquivo.NomeArquivo = dialog.FileName;

                    arquivo.Carregar();
                    adapter.Selos = arquivo.Selos;
                    adapter.NotifyDataSetChanged();

                    Android.Widget.Toast.MakeText(this, "TESTE: LISTA CARREGADA", ToastLength.Long);
                }
            };
 

            dialog.Show();           
        }
 // NOT SUPPORTED ON XP
 public static void OpenFileDialogAddCustomPaths(FileDialog dialog) // Allows you to add favorites to the SoundfontImport dialog
 {
     try
     {
         // Import the blacklist file
         using (StreamReader r = new StreamReader(System.Environment.GetEnvironmentVariable("USERPROFILE").ToString() + "\\Keppy's Synthesizer\\keppymididrv.favlist"))
         {
             string line;
             while ((line = r.ReadLine()) != null)
             {
                 dialog.CustomPlaces.Add(line);
             }
             return;
         }
     }
     catch
     {
         return;
     }
 }
        private void FileDialog_Accept(FileDialog dlg, IntPtr handle)
        {
            IntPtr gslist = Internal.GTK.Methods.gtk_file_chooser_get_filenames (handle);

            uint length = Internal.GLib.Methods.g_slist_length (gslist);
            dlg.SelectedFileNames.Clear ();
            for (uint i = 0; i < length; i++) {
                string fileName = Internal.GLib.Methods.g_slist_nth_data (gslist, i);
                dlg.SelectedFileNames.Add (fileName);
            }

            Internal.GLib.Methods.g_slist_free (gslist);
        }
 private void InternalCreateFileDialog(out FileDialog dialog)
 {
     ApplicationInstance.CreateFileDialog(out  dialog);
 }
        private IntPtr FileDialog_Create(FileDialog dlg)
        {
            string title = dlg.Title;

            Internal.GTK.Constants.GtkFileChooserAction fca = Internal.GTK.Constants.GtkFileChooserAction.Open;
            switch (dlg.Mode) {
                case FileDialogMode.CreateFolder:
                {
                    fca = Internal.GTK.Constants.GtkFileChooserAction.CreateFolder;
                    if (title == null)
                        title = "Create Folder";
                    break;
                }
                case FileDialogMode.Open:
                {
                    fca = Internal.GTK.Constants.GtkFileChooserAction.Open;
                    if (title == null)
                        title = "Open";
                    break;
                }
                case FileDialogMode.Save:
                {
                    fca = Internal.GTK.Constants.GtkFileChooserAction.Save;
                    if (title == null)
                        title = "Save";
                    break;
                }
                case FileDialogMode.SelectFolder:
                {
                    fca = Internal.GTK.Constants.GtkFileChooserAction.SelectFolder;
                    if (title == null)
                        title = "Select Folder";
                    break;
                }
            }

            IntPtr handle = Internal.GTK.Methods.gtk_file_chooser_dialog_new (title, CommonDialog_GetParentHandle(dlg), fca);

            string accept_button = "gtk-save";
            string cancel_button = "gtk-cancel";

            switch (dlg.Mode) {
                case FileDialogMode.CreateFolder:
                case FileDialogMode.Save:
                {
                    accept_button = mvarStockIDs [StockType.Save];
                    break;
                }
                case FileDialogMode.SelectFolder:
                case FileDialogMode.Open:
                {
                    accept_button = mvarStockIDs [StockType.Open];
                    break;
                }
            }

            switch (System.Environment.OSVersion.Platform) {
                case PlatformID.MacOSX:
                case PlatformID.Unix:
                {
                    // buttons go cancel, then accept
                    Internal.GTK.Methods.gtk_dialog_add_button (handle, cancel_button, Internal.GTK.Constants.GtkResponseType.Cancel);
                    Internal.GTK.Methods.gtk_dialog_add_button (handle, accept_button, Internal.GTK.Constants.GtkResponseType.Accept);
                    break;
                }
                case PlatformID.Win32NT:
                case PlatformID.Win32S:
                case PlatformID.Win32Windows:
                case PlatformID.WinCE:
                case PlatformID.Xbox:
                {
                    // buttons go accept, then cancel
                    Internal.GTK.Methods.gtk_dialog_add_button (handle, accept_button, Internal.GTK.Constants.GtkResponseType.Accept);
                    Internal.GTK.Methods.gtk_dialog_add_button (handle, cancel_button, Internal.GTK.Constants.GtkResponseType.Cancel);
                    break;
                }
            }

            Internal.GTK.Methods.gtk_file_chooser_set_select_multiple (handle, dlg.MultiSelect);
            return handle;
        }
 public static Gnome.Vfs.Uri SaveFile(string title)
 {
         FileDialog fd = new FileDialog (title, Gtk.FileChooserAction.Save);
         return fd.GetUri ();
 }
 public void CreateFileDialog(out FileDialog dialog)
 {
     InternalCreateFileDialog(out  dialog);
 }