예제 #1
0
        static void Open_File(object o, EventArgs args)
        {
            FileFilter filter = new FileFilter();

            filter.Name = "GameBoy ROMs";
            filter.AddPattern("*.gb");

            FileChooserDialog fs = new FileChooserDialog("Abrir una ROM de GameBoy", null, FileChooserAction.Open);

            if (_lastDir != null)
            {
                fs.SetCurrentFolder(_lastDir);
            }
            fs.AddFilter(filter);
            fs.AddButton(Gtk.Stock.Cancel, Gtk.ResponseType.Cancel);
            fs.AddButton(Gtk.Stock.Open, Gtk.ResponseType.Ok);
            fs.DefaultResponse = Gtk.ResponseType.Ok;
            fs.Action          = FileChooserAction.Open;
            fs.ShowHidden      = false;
            fs.SelectMultiple  = false;
            fs.LocalOnly       = true;
            int res = fs.Run();

            if (res == (int)ResponseType.Ok)
            {
                // Recuerda el ultimo directorio accedido
                _lastDir = fs.CurrentFolder;
                iniciarConsola(fs.Filename);
            }
            fs.Destroy();
        }
예제 #2
0
        /// <summary>
        /// Open dialog to choose the SCADA application file
        /// </summary>
        private void OpenApplication()
        {
            FileChooserDialog fileChooserDialog =
                new FileChooserDialog("Open file",
                                      null,
                                      FileChooserAction.Open);

            // Add buttons to file dialog
            fileChooserDialog.AddButton(Stock.Cancel, ResponseType.Cancel);
            fileChooserDialog.AddButton(Stock.Open, ResponseType.Ok);

            // Select file filters
            fileChooserDialog.Filter = new FileFilter();
            fileChooserDialog.Filter.AddPattern("*.scada");

            fileChooserDialog.SelectMultiple = false;

            ResponseType RetVal = (ResponseType)fileChooserDialog.Run();

            string fileName = fileChooserDialog.Filename;

            // Destroy the dialog
            fileChooserDialog.Destroy();

            // Handle the dialog's exit value
            // read the file name from Fcd.Filename
            if (RetVal == ResponseType.Ok)
            {
                // Load application's configuration file
                LoadScadaFile(fileName);
            }

            enableToolBarButtons();
        }
예제 #3
0
        private void BtnLoad_Click(object sender, EventArgs e)
        {
            var dialog = new FileChooserDialog(
                "Load configuration",
                this,
                FileChooserAction.Open);

            dialog.AddButton(Stock.Cancel, ResponseType.Cancel);
            dialog.AddButton(Stock.Open, ResponseType.Ok);
            dialog.SetCurrentFolder(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments));
            dialog.SelectMultiple = false;

            var response = (ResponseType)dialog.Run();

            if (response == ResponseType.Ok)
            {
                if (_sikInterface.LoadParamsFromFile(dialog.Filename))
                {
                    _sikInterface.SiKConfig.PropertyChanged += _boardIdentifiers.SiKConfig_PropertyChanged;
                    _dataTableControls.CreateBindings(_sikInterface.SiKConfig);
                    StatusMessage = "Parameters loaded from a config file.";
                }
                else
                {
                    StatusMessage = "Failed to load the parameters.";
                }
            }
            dialog.Dispose();
        }
예제 #4
0
 public static string?SelectFile(Window parent)
 {
     using var fc = new FileChooserDialog("XDM", parent, FileChooserAction.Open);
     try
     {
         if (parent.Group != null)
         {
             parent.Group.AddWindow(fc);
         }
         fc.AddButton(Stock.Save, ResponseType.Accept);
         fc.AddButton(Stock.Cancel, ResponseType.Cancel);
         if (fc.Run() == (int)ResponseType.Accept)
         {
             return(fc.Filename);
         }
         return(null);
     }
     finally
     {
         if (parent.Group != null)
         {
             parent.Group.RemoveWindow(fc);
         }
         fc.Destroy();
         fc.Dispose();
     }
 }
예제 #5
0
        public void saveFile(object sender, EventArgs args)
        {
            FileChooserDialog filesaveDialog = new FileChooserDialog("Save File", this, FileChooserAction.Save);

            filesaveDialog.AddButton(Gtk.Stock.Cancel, Gtk.ResponseType.Cancel);
            filesaveDialog.AddButton(Gtk.Stock.Save, Gtk.ResponseType.Ok);
            if (!File.Exists(activeFile))
            {
                var respone = filesaveDialog.Run();
                if (respone == (int)Gtk.ResponseType.Ok)
                {
                    activeFile = filesaveDialog.Filename;
                    string currentText = sourceView.Buffer.Text;
                    var    lm          = LanguageManager.Default;
                    var    lang        = lm.GuessLanguage(activeFile, "");
                    sourceView.Buffer.Language = lang;
                    if (lang != null)
                    {
                        languageSelectorButton.Label = lang.Name;
                    }
                    else
                    {
                        languageSelectorButton.Label = "Text";
                    }

                    statusBarLabel.Text = "Saved File";
                    previousText        = currentText;
                    headerBar.Subtitle  = activeFile;
                    headerBar.Title     = headerBarOringalText;
                    isChangeSaved       = true;

                    // StreamWriter writer = new StreamWriter(activeFile, false);
                    // writer.Write(currentText);
                    using (var stream = File.Create(activeFile))
                    {
                        using (TextWriter tw = new StreamWriter(stream))
                        {
                            tw.Write(currentText);
                        }
                    }
                    File.WriteAllText(activeFile, currentText);
                    // Console.WriteLine("ok");
                }
                // else if (respone == (int) Gtk.ResponseType.Cancel)
                // {
                //     Console.WriteLine("cancel");
                // }

                filesaveDialog.Dispose();
            }
            else
            {
                headerBar.Subtitle = activeFile;
                headerBar.Title    = headerBarOringalText;
                isChangeSaved      = true;
                string currentText = sourceView.Buffer.Text;
                previousText = currentText;
                File.WriteAllText(activeFile, currentText);
            }
        }
예제 #6
0
 void Button6_Activated(object sender, EventArgs e)
 {
     try
     {
         FileChooserDialog fileChooserDialog = new FileChooserDialog("Select project file", null, FileChooserAction.Open, new object[0]);
         fileChooserDialog.AddButton(Stock.Cancel, ResponseType.Cancel);
         fileChooserDialog.AddButton(Stock.Open, ResponseType.Ok);
         fileChooserDialog.DefaultResponse = ResponseType.Ok;
         fileChooserDialog.SelectMultiple  = false;
         FileFilter fileFilter = new FileFilter();
         fileFilter.AddMimeType("application/json");
         fileFilter.AddPattern("project.json");
         fileFilter.Name = "iCode project file (project.json)";
         fileChooserDialog.AddFilter(fileFilter);
         bool flag = fileChooserDialog.Run() == -5;
         if (flag)
         {
             ProjectManager.LoadProject(fileChooserDialog.Filename);
         }
         fileChooserDialog.Dispose();
     }
     catch (Exception ex)
     {
         ExceptionWindow.Create(ex, this).ShowAll();
     }
 }
예제 #7
0
        void on_AddButton_clicked(object sender, EventArgs args)
        {
            string lastPath = BooruApp.BooruApplication.Database.GetConfig("import.mru");

            FileChooserDialog dlg = new FileChooserDialog("Choose Images", BooruApp.BooruApplication.MainWindow, FileChooserAction.Open);

            dlg.AddButton("Open", Gtk.ResponseType.Ok);
            dlg.AddButton("Cancel", Gtk.ResponseType.Cancel);

            dlg.SelectMultiple = true;

            if (!string.IsNullOrEmpty(lastPath))
            {
                dlg.SetCurrentFolder(lastPath);
            }

            if (dlg.Run() == (int)Gtk.ResponseType.Ok)
            {
                BooruApp.BooruApplication.Database.SetConfig("import.mru", dlg.CurrentFolder);
                foreach (var path in dlg.Filenames)
                {
                    this.importer.AddImage(path);
                }
            }

            dlg.Destroy();
        }
예제 #8
0
    /// <summary>
    /// Picks an archive file for opening
    /// </summary>
    /// <returns>The path to the file.</returns>
    /// <param name="title">The title of the dialog.</param>
    /// <param name="fileName">The pre-selected file name.</param>
    /// <param name="patterns">File filter patters as an array of {patternName, pattern}.</param>
    /// <param name="OKLabel">The label for the OK button (where supported)</param>
    /// <param name="CancelLabel">The label for the Cancel button (where supported)</param>
    public string pickFile(string title, string fileName, string[,] patterns, string OKLabel, string CancelLabel)
    {
        FileChooserDialog dialog = new FileChooserDialog(title, this, FileChooserAction.Open);

        if (fileName != "")
        {
            dialog.CurrentName = fileName;
            dialog.SetCurrentFolder(fileName);
        }

        dialog.AddButton(CancelLabel, Gtk.ResponseType.Cancel);
        dialog.AddButton(OKLabel, Gtk.ResponseType.Accept);

        for (int i = 0; i < patterns.Length / 2; i++)
        {
            FileFilter filter = new FileFilter();
            filter.Name = patterns[i, 0];
            filter.AddPattern(patterns[i, 1]);
            dialog.AddFilter(filter);
        }

        ResponseType ret         = (ResponseType)dialog.Run();
        string       newFileName = dialog.Filename;

        dialog.Destroy();

        if (ret != ResponseType.Accept)
        {
            return("");
        }

        return(newFileName);
    }
예제 #9
0
    public bool DoSaveDialog()
    {
        bool retval = false;

        FileChooserDialog chooser = new FileChooserDialog(
            "Save Handwriting", null, FileChooserAction.Save);

        chooser.SetCurrentFolder(Environment.GetFolderPath(
                                     Environment.SpecialFolder.Personal));
        chooser.AddButton(Gtk.Stock.Cancel, ResponseType.Cancel);
        chooser.AddButton(Gtk.Stock.Ok, ResponseType.Ok);
        chooser.DefaultResponse = ResponseType.Ok;

        if (chooser.Run() == (int)ResponseType.Ok)
        {
            string        path = (new Uri(chooser.Uri)).AbsolutePath;
            XmlTextWriter xml  = new XmlTextWriter(path,
                                                   System.Text.Encoding.UTF8);
            xml.Formatting = Formatting.Indented;
            handwriting.Serialize(xml);
            xml.Close();
            hasChanged = false;
            retval     = true;
        }

        chooser.Destroy();
        return(retval);
    }
        private void OnMenuOpenActivate(object sender, EventArgs args)
        {
            FileChooserDialog chooser = new FileChooserDialog("Selecciona un fichero para abrir", (Window)mainComponentBuilderForm["mainView"], FileChooserAction.Open, Stock.Open);

            chooser.AddButton(Stock.Open, ResponseType.Accept);
            chooser.AddButton(Stock.Cancel, ResponseType.Cancel);
            chooser.SelectMultiple = false;
            ResponseType response = (ResponseType)chooser.Run();

            switch (response)
            {
            case ResponseType.Accept:
                if (chooser.Filename.Length != 0)
                {
                    DefaultContainer.Instance.Execute("ComponentBuilder", "DeserializeProject", new object[] { chooser.Filename }, this);
                }
                break;

            case ResponseType.Cancel:
                break;

            default:
                break;
            }
            chooser.Destroy();
            chooser = null;
        }
예제 #11
0
        private void OnSendFolder(object sender, EventArgs args)
        {
            FileChooserDialog chooser = new FileChooserDialog(
                Services.PlatformService.GetString("Folder to Give"),
                null,
                FileChooserAction.SelectFolder
                );

            chooser.SetCurrentFolder(Environment.GetFolderPath(Environment.SpecialFolder.Personal));
            chooser.AddButton(Stock.Cancel, ResponseType.Cancel);
            chooser.AddButton(Services.PlatformService.GetString("Give"), ResponseType.Ok);
            chooser.DefaultResponse = ResponseType.Ok;
            chooser.LocalOnly       = true;

            if (chooser.Run() == (int)ResponseType.Ok)
            {
                if (!isManual)
                {
                    Giver.Application.EnqueueFileSend(serviceInfo, chooser.Filenames);
                }
                else
                {
                    // Prompt for the info to send here
                }
            }

            chooser.Destroy();
        }
예제 #12
0
    protected void OnSaveAsActionActivated(object sender, EventArgs e)
    {
        FileChooserDialog fcd = new FileChooserDialog("Save EasyOS project as...", this, FileChooserAction.Save);

        fcd.AddButton(Gtk.Stock.Ok, ResponseType.Ok);
        fcd.AddButton(Gtk.Stock.Cancel, ResponseType.Cancel);
        fcd.SelectMultiple = false;
        fcd.Filter         = new FileFilter();
        fcd.Filter.AddPattern("*.eos");
        fcd.DefaultResponse = ResponseType.Cancel;
        fcd.SetCurrentFolder(System.IO.Path.GetDirectoryName(currentFilePath));
        fcd.CurrentName = (System.IO.Path.GetFileName(currentFilePath).Replace(".eos", "_Copy.eos"));

        ResponseType response = (ResponseType)fcd.Run();

        if (response == Gtk.ResponseType.Ok)
        {
            string filename = fcd.Filename;
            if (!filename.EndsWith(".eos"))
            {
                filename += ".eos";
            }
            currentFilePath = filename;
            TextWriter tw = new StreamWriter(currentFilePath);
            GPrj.SaveAsXml().Save(tw);
            tw.Close();
        }
        fcd.Destroy();
    }
예제 #13
0
    private void OnChoose(object o, EventArgs args)
    {
        FileChooserDialog dialog = new FileChooserDialog("Choose resource", null, FileChooserAction.Open, new object[] { });

        dialog.AddButton(Gtk.Stock.Cancel, Gtk.ResponseType.Cancel);
        dialog.AddButton(Gtk.Stock.Open, Gtk.ResponseType.Ok);
        dialog.DefaultResponse = Gtk.ResponseType.Ok;

        dialog.Action = FileChooserAction.Open;
        dialog.SetFilename(Settings.Instance.TuxjuniorData + entry.Text);
        int result = dialog.Run();

        if (result != (int)ResponseType.Ok)
        {
            dialog.Destroy();
            return;
        }
        string path;

        if (dialog.Filename.StartsWith(Settings.Instance.TuxjuniorData))
        {
            path = dialog.Filename.Substring(Settings.Instance.TuxjuniorData.Length,
                                             dialog.Filename.Length - Settings.Instance.TuxjuniorData.Length);
        }
        else
        {
            path = System.IO.Path.GetFileName(dialog.Filename);
        }
        // Fixes backslashes on windows:
        entry.Text = path.Replace("\\", "/");
        dialog.Destroy();

        OnEntryChangeDone(entry, null);
    }
예제 #14
0
파일: Window.cs 프로젝트: MrJoe/lat
        public void OnImportActivate(object o, EventArgs args)
        {
            Connection conn = GetActiveConnection();

            if (conn == null)
            {
                return;
            }

            FileChooserDialog fcd = new FileChooserDialog(
                Mono.Unix.Catalog.GetString("Choose an LDIF file to import"),
                Gtk.Stock.Open,
                mainWindow,
                FileChooserAction.Open);

            fcd.AddButton(Gtk.Stock.Cancel, ResponseType.Cancel);
            fcd.AddButton(Gtk.Stock.Open, ResponseType.Ok);

            fcd.SelectMultiple = false;

            ResponseType response = (ResponseType)fcd.Run();

            if (response == ResponseType.Ok)
            {
                UriBuilder ub = new UriBuilder();
                ub.Scheme = "file";
                ub.Path   = fcd.Filename;

                Util.ImportData(conn, mainWindow, ub.Uri);
            }

            fcd.Destroy();
        }
예제 #15
0
        static void openButton_Clicked(object sender, EventArgs e)
        {
            FileChooserDialog fcd = new FileChooserDialog("Open page...", (Window)((Widget)sender).Toplevel, FileChooserAction.Open);

            fcd.AddButton(Stock.Cancel, ResponseType.Cancel);
            fcd.AddButton(Stock.Open, ResponseType.Ok);
            fcd.DefaultResponse = ResponseType.Ok;
            fcd.Filter          = new FileFilter();
            fcd.Filter.AddPattern("*.aspx");
            fcd.SelectMultiple = false;

            ResponseType response = (ResponseType)fcd.Run( );

            fcd.Hide();

            if (response == ResponseType.Ok && fcd.Filename != null)
            {
                using (FileStream fileStream = new FileStream(fcd.Filename, FileMode.Open))
                {
                    if (fileStream == null)
                    {
                        return;
                    }

                    host.Reset();

                    host.Load(fileStream, fcd.Filename);
                    host.Activate();
                }
            }
            fcd.Destroy();
        }
예제 #16
0
        static void toolboxAddButton_Clicked(object sender, EventArgs e)
        {
            FileChooserDialog fcd = new FileChooserDialog("Add custom controls...", (Window)((Widget)sender).Toplevel, FileChooserAction.Open);

            fcd.AddButton(Stock.Cancel, ResponseType.Cancel);
            fcd.AddButton(Stock.Open, ResponseType.Ok);
            fcd.DefaultResponse = ResponseType.Ok;
            fcd.Filter          = new FileFilter();
            fcd.Filter.AddPattern("*.dll");
            fcd.SelectMultiple = false;

            ResponseType response = (ResponseType)fcd.Run( );

            fcd.Hide();

            if (response == ResponseType.Ok && fcd.Filename != null)
            {
                try{
                    System.Reflection.Assembly a = System.Reflection.Assembly.LoadFrom(fcd.Filename);
                    toolboxService.PopulateFromAssembly(a);
                }
                catch (Exception ex) {
                    //TODO: handle this better!
                    System.Diagnostics.Trace.WriteLine("Could not load assembly \"" + fcd.Filename + "\".");
                }
            }
            fcd.Destroy();
        }
예제 #17
0
        //Will load in multiple files, or a folder of files which will be matched against
        //loaded templates
        public static List <Tuple <string, List <PointD> > > loadBatchPoints()
        {
            List <Tuple <string, List <PointD> > > result = new List <Tuple <string, List <PointD> > > ();

            //Setup of dialog and limiting it to only XML files
            FileChooserDialog fileChooser = new FileChooserDialog("Open Files", null, FileChooserAction.Open);

            fileChooser.AddButton(Stock.Cancel, ResponseType.Cancel);
            fileChooser.AddButton(Stock.Open, ResponseType.Ok);

            fileChooser.Filter = new FileFilter();
            fileChooser.Filter.AddPattern("*.xml");

            string tmp    = System.IO.Directory.GetCurrentDirectory();
            string newTmp = tmp + "/../../Gestures/RecordedDataPoints/";

            fileChooser.SetCurrentFolder(newTmp);

            fileChooser.SelectMultiple = true;

            ResponseType retVal = (ResponseType)fileChooser.Run();

            if (retVal == ResponseType.Ok)
            {
                foreach (string file in fileChooser.Filenames)
                {
                    result.Add(XMLParser.BatchLoadPoints(file));
                }
            }

            fileChooser.Destroy();
            return(result);
        }
예제 #18
0
        static void saveButton_Clicked(object sender, EventArgs e)
        {
            FileChooserDialog fcd = new FileChooserDialog("Save page as...", (Window)((Widget)sender).Toplevel, FileChooserAction.Save);

            fcd.AddButton(Stock.Cancel, ResponseType.Cancel);
            fcd.AddButton(Stock.Save, ResponseType.Ok);
            fcd.DefaultResponse = ResponseType.Ok;
            fcd.Filter          = new FileFilter();
            fcd.Filter.AddPattern("*.aspx");
            fcd.SelectMultiple = false;
            fcd.SetFilename(((System.Web.UI.Control)host.RootComponent).ID + ".aspx");

            ResponseType response = (ResponseType)fcd.Run();

            fcd.Hide();

            if (response == ResponseType.Ok && fcd.Filename != null)
            {
                using (FileStream fileStream = new FileStream(fcd.Filename, FileMode.Create))
                {
                    if (fileStream == null)
                    {
                        return;
                    }
                    host.SaveDocument(fileStream);
                }
            }
            fcd.Destroy();
        }
예제 #19
0
        void saveAs(object sender, System.EventArgs e)
        {
            var filter = (FileFilter)Builder.GetObject("FileFilter");

            filter.Name = "TaskManager";
            var fileChooser = new  FileChooserDialog("Guardar...", MainWindow, FileChooserAction.Save);

            fileChooser.AddButton("_Guardar", ResponseType.Ok);
            fileChooser.AddButton("_Cancelar", ResponseType.Cancel);
            fileChooser.DefaultResponse         = ResponseType.Ok;
            fileChooser.DoOverwriteConfirmation = true;
            fileChooser.AddFilter(filter);
            var resp = (ResponseType)fileChooser.Run();

            if (resp == ResponseType.Ok)
            {
                try
                {
                    CurrentFile = fileChooser.Filename;
                    Tasks.Save(CurrentFile);
                    StatusBar.Push(0, "Guardado");
                }
                catch (Exception ex)
                {
                    StatusBar.Push(0, "Error guardando archivo");
                    Debug.WriteLine(ex);
                }
            }
            fileChooser.Destroy();
        }
예제 #20
0
        void load(object sender, System.EventArgs e)
        {
            var filter = (FileFilter)Builder.GetObject("FileFilter");

            filter.Name = "TaskManager";
            var fileChooser = new  FileChooserDialog("Abrir...", null, FileChooserAction.Open);

            fileChooser.AddButton("_Abrir", ResponseType.Ok);
            fileChooser.AddButton("_Cancelar", ResponseType.Cancel);
            fileChooser.DefaultResponse = ResponseType.Ok;
            fileChooser.AddFilter(filter);
            var resp = (ResponseType)fileChooser.Run();

            if (resp == ResponseType.Ok)
            {
                try
                {
                    Tasks = TaskCollection.Load(fileChooser.Filename);
                    FilterOptions.Tasks = Tasks;
                    rebuildStore();
                    buildCats();
                    CurrentFile = fileChooser.Filename;
                    StatusBar.Push(0, "Archivo cargado");
                    expandTasks();
                }
                catch (Exception ex)
                {
                    StatusBar.Push(0, "Error cargando archivo");
                    Debug.WriteLine("Something is wrong.\n" + ex);
                }
            }
            fileChooser.Destroy();
        }
예제 #21
0
        public SaveFile(Window w, string s)
        {
            FileChooserDialog filechooser = new FileChooserDialog("Save file...", w, FileChooserAction.Save);

            filechooser.AddButton(Stock.Cancel, ResponseType.Cancel);
            filechooser.AddButton(Stock.Save, ResponseType.Ok);

            filechooser.Filter = new FileFilter();
            filechooser.Filter.AddPattern("*.cas");

            if (filechooser.Run() == (int)ResponseType.Ok)
            {
                Export.WriteToCasFile(s, filechooser.Name);
            }

            /*
             * if (filechooser.Run () == (int)ResponseType.Ok) {
             *  filechooser.Name = s;
             * } else {
             *
             * }
             */

            filechooser.Destroy();
        }
예제 #22
0
		void OpenAction_Activated(object sender, EventArgs e)
		{
			// Let the user select a file to open.
			var dialog = new FileChooserDialog(
				string.Format("Open file - {0}", BaseTitle),
				this, FileChooserAction.Open);

			dialog.AddButton(Stock.Cancel, ResponseType.Cancel);
			dialog.AddButton(Stock.Open, ResponseType.Ok);

			// Try to start file selection from current file,
			// if there is one.
			//
			// This enables the user to successively open files
			// from the same directory, e.g., from a collection
			// of notes files.
			if (!string.IsNullOrEmpty(_FilePath))
				dialog.SetFilename(_FilePath);

			int result = dialog.Run();
			string filePath = dialog.Filename;
			dialog.Destroy();

			// Check that the user did in fact give confirmation.
			if (result != (int)ResponseType.Ok)
				return;

			// Actually open the file.
			LoadFile(filePath);
		}
예제 #23
0
        private void BtnSave_Click(object sender, EventArgs e)
        {
            var dialog = new FileChooserDialog(
                "Save configuration",
                this,
                FileChooserAction.Save);

            dialog.AddButton(Stock.Cancel, ResponseType.Cancel);
            dialog.AddButton(Stock.Save, ResponseType.Ok);
            dialog.SetCurrentFolder(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments));
            dialog.SelectMultiple = false;

            var response = (ResponseType)dialog.Run();

            if (response == ResponseType.Ok)
            {
                if (_sikInterface.SaveParamsToFile(dialog.Filename))
                {
                    StatusMessage = "Parameters saved to a backup file.";
                }
                else
                {
                    StatusMessage = "Failed to save the parameters file.";
                }
            }
            dialog.Dispose();
        }
예제 #24
0
        protected void OnButton41Clicked(object sender, EventArgs e)
        {
            // Download config to local
            FileChooserDialog folderChoose = new FileChooserDialog("Choose configuration download path", null, FileChooserAction.SelectFolder);

            folderChoose.AddButton("Cancel", (int)ResponseType.Cancel);
            folderChoose.AddButton("Select", (int)ResponseType.Ok);
            if (folderChoose.Run() == (int)ResponseType.Ok)
            {
                //TODO
                List <String> config = GetConfigFromTreeview(treeview3);
                                #if DEBUG
                foreach (var line in config)
                {
                    Debug.WriteLine(line);
                }
                                #endif
                File.WriteAllLines(folderChoose.Filename + "/load_server_runtime_config", config);
                config = GetConfigFromTreeview(treeview6);
                                #if DEBUG
                foreach (var line in config)
                {
                    Debug.WriteLine(line);
                }
                                #endif
                File.WriteAllLines(folderChoose.Filename + "/load_client_runtime_config", config);
            }
            folderChoose.Destroy();
        }
예제 #25
0
 public static string?SaveFile(Window parent, string?path)
 {
     using var fc = new FileChooserDialog("XDM", parent, FileChooserAction.Save);
     if (!string.IsNullOrEmpty(path))
     {
         var dir = Path.GetDirectoryName(path);
         fc.SetFilename(Path.GetFileName(path));
         fc.SetCurrentFolderFile(GLib.FileFactory.NewForPath(dir));
     }
     try
     {
         if (parent.Group != null)
         {
             parent.Group.AddWindow(fc);
         }
         fc.AddButton(Stock.Save, ResponseType.Accept);
         fc.AddButton(Stock.Cancel, ResponseType.Cancel);
         if (fc.Run() == (int)ResponseType.Accept)
         {
             return(fc.Filename);
         }
         return(null);
     }
     finally
     {
         if (parent.Group != null)
         {
             parent.Group.RemoveWindow(fc);
         }
         fc.Destroy();
         fc.Dispose();
     }
 }
예제 #26
0
        private void Open(FileChooserAction action)
        {
            string title = Catalog.GetString("Open");

            if (action == FileChooserAction.SelectFolder)
            {
                title = Catalog.GetString("Select Folder");
            }

            FileChooserDialog chooser = new FileChooserDialog(title,
                                                              window,
                                                              action);

            chooser.AddButton(Stock.Cancel, ResponseType.Cancel);
            chooser.AddButton(Stock.Open, ResponseType.Ok);

            chooser.SetUri(uri.ToString());
            int response = chooser.Run();

            if ((ResponseType)response == ResponseType.Ok)
            {
                CurrentUri = new System.Uri(chooser.Uri);
            }


            chooser.Destroy();
        }
        private void buttonCacheLocationClick(object sender, EventArgs e)
        {
            Log.Debug("buttonCacheLocationClick");
            // Thanks Petteri Kautonen - http://mono.1490590.n4.nabble.com/Gtk-sharp-list-FileOpenDialog-td1544553.html
            var dialog = new FileChooserDialog("Select folder to save the cached thumbnails:",
                                               null, FileChooserAction.SelectFolder);

            var preferences = getModelFromFields();

            dialog.SetCurrentFolder(preferences.CacheLocation);

            dialog.AddButton(Stock.Cancel, ResponseType.Cancel);
            dialog.AddButton(Stock.Ok, ResponseType.Ok);

            var result = (ResponseType)dialog.Run();

            if (result == ResponseType.Ok)
            {
                Preferences.CacheLocation = preferences.CacheLocation = dialog.CurrentFolder;
                setFieldsFromModel(preferences);
                SetCacheSize();
            }

            dialog.Destroy();
        }
예제 #28
0
        void OnSaveBinaryValueActivate(object o, EventArgs args)
        {
            FileChooserDialog fcd = new FileChooserDialog(
                Mono.Unix.Catalog.GetString("Save binary as"),
                Gtk.Stock.Save,
                null,
                FileChooserAction.Save);

            fcd.AddButton(Gtk.Stock.Cancel, ResponseType.Cancel);
            fcd.AddButton(Gtk.Stock.Save, ResponseType.Ok);

            fcd.SelectMultiple = false;

            ResponseType response = (ResponseType)fcd.Run();

            if (response == ResponseType.Ok)
            {
                string        attributeName = GetAttributeName();
                LdapEntry     le            = conn.Data.GetEntry(currentDN);
                LdapAttribute la            = le.getAttribute(attributeName);

                WriteBytesToFile(fcd.Filename, SupportClass.ToByteArray(la.ByteValue));
            }

            fcd.Destroy();
        }
예제 #29
0
        protected virtual FileChooserDialog CreateFileChooserDialog()
        {
            // TODO: set parent
            var dlg = new FileChooserDialog(Title, null, Action);

            dlg.Response += HandleDlgResponse;

            if (ShowHelp)
            {
                dlg.AddButton(FileDialogStrings.Help, ResponseType.Help);
            }
            dlg.AddButton(FileDialogStrings.Cancel, ResponseType.Cancel);
            dlg.AddButton(AcceptButtonText, ResponseType.Accept);

            dlg.LocalOnly      = true;
            dlg.SelectMultiple = Multiselect;
            if (!string.IsNullOrEmpty(InitialDirectory))
            {
                dlg.SetCurrentFolder(InitialDirectory);
            }
            if (!string.IsNullOrEmpty(FileName))
            {
                dlg.SetFilename(FileName);
            }

            ApplyFilter(dlg);

            return(dlg);
        }
예제 #30
0
        void Open(FileChooserAction action)
        {
            string title = Strings.Open;

            if (action == FileChooserAction.SelectFolder)
            {
                title = Strings.SelectFolder;
            }

            var chooser = new FileChooserDialog(title,
                                                Window,
                                                action);

            chooser.AddButton(Stock.Cancel, ResponseType.Cancel);
            chooser.AddButton(Stock.Open, ResponseType.Ok);

            chooser.SetUri(uri.ToString());
            int response = chooser.Run();

            if ((ResponseType)response == ResponseType.Ok)
            {
                CurrentUri = new Uri(chooser.Uri, true);
            }


            chooser.Destroy();
        }
예제 #31
0
        private void OnBrowseClicked(object o, EventArgs args)
        {
            FileChooserDialog chooser = new FileChooserDialog(
                Catalog.GetString("Open Location"),
                null,
                FileChooserAction.Open
            );

            chooser.SetCurrentFolder(Environment.GetFolderPath(Environment.SpecialFolder.Personal));
            chooser.AddButton(Stock.Cancel, ResponseType.Cancel);
            chooser.AddButton(Stock.Open, ResponseType.Ok);
            chooser.DefaultResponse = ResponseType.Ok;
            chooser.LocalOnly = false;

            if(chooser.Run() == (int)ResponseType.Ok) {
                address_entry.Entry.Text = chooser.Uri;
            }

            chooser.Destroy();
        }
예제 #32
0
 public void OpenDialog(bool multipleFiles, params FileTypes[] fileTypes)
 {
     fcd = new FileChooserDialog("Choose Files", null, FileChooserAction.Open, ButtonsType.Ok);
     fcd.AddButton("Open", ResponseType.Ok);
     fcd.AddFilter(Utils.FileTypesToGtkFilter(fileTypes));
     fcd.SelectMultiple = true;
     fcd.Run();
 }
예제 #33
0
 public void OpenDialog(params FileTypes[] fileTypes)
 {
     fcd = new FileChooserDialog("Choose Path", null, FileChooserAction.Save, ButtonsType.Ok);
     fcd.AddButton("Save", ResponseType.Ok);
     FileFilter filter = new FileFilter();
     fcd.AddFilter(Utils.FileTypesToGtkFilter(fileTypes));
     fcd.Run();
 }