Пример #1
0
        protected void OnButtonAddIncludeClicked(object sender, System.EventArgs e)
        {
            Gtk.FileChooserDialog dialog = new Gtk.FileChooserDialog(
                "Select D Source Folder",
                Ide.IdeApp.Workbench.RootWindow,
                Gtk.FileChooserAction.SelectFolder,
                "Cancel",
                Gtk.ResponseType.Cancel,
                "Ok",
                Gtk.ResponseType.Ok)
            {
                TransientFor   = Toplevel as Gtk.Window,
                WindowPosition = Gtk.WindowPosition.Center
            };

            if (lastDir != null)
            {
                dialog.SetCurrentFolder(lastDir);
            }
            else if (Directory.Exists(txtBinPath.Text))
            {
                dialog.SetCurrentFolder(txtBinPath.Text);
            }

            try {
                if (dialog.Run() == (int)Gtk.ResponseType.Ok)
                {
                    lastDir = dialog.Filename;
                    text_Includes.Buffer.Text += (text_Includes.Buffer.CharCount == 0 ? "" : "\n") + dialog.Filename;
                }
            } finally {
                dialog.Destroy();
            }
        }
Пример #2
0
	public VideoOpenDialog () : base(gladeFilename) {
		dialog = GetDialog() as FileChooserDialog;

		if (Base.IsDocumentLoaded && Base.Document.TextFile.IsPathRooted)
			dialog.SetCurrentFolder(Base.Document.TextFile.Directory);
		else
			dialog.SetCurrentFolder(Environment.GetFolderPath(Environment.SpecialFolder.Personal));

		SetFilters();
	}
Пример #3
0
        protected virtual void OnButtonInstallFromFileClicked(object sender, System.EventArgs e)
        {
            string[] files;
            Gtk.FileChooserDialog dlg = new Gtk.FileChooserDialog(Catalog.GetString("Install Add-in Package"), this, FileChooserAction.Open);
            try
            {
                if (lastFolder != null)
                {
                    dlg.SetCurrentFolder(lastFolder);
                }
                else
                {
                    dlg.SetCurrentFolder(Environment.GetFolderPath(Environment.SpecialFolder.Personal));
                }
                dlg.SelectMultiple = true;

                Gtk.FileFilter f = new Gtk.FileFilter();
                f.AddPattern("*.mpack");
                f.Name = Catalog.GetString("Add-in packages");
                dlg.AddFilter(f);

                f = new Gtk.FileFilter();
                f.AddPattern("*");
                f.Name = Catalog.GetString("All files");
                dlg.AddFilter(f);

                dlg.AddButton(Gtk.Stock.Cancel, ResponseType.Cancel);
                dlg.AddButton(Gtk.Stock.Open, ResponseType.Ok);
                if (dlg.Run() != (int)Gtk.ResponseType.Ok)
                {
                    return;
                }
                files      = dlg.Filenames;
                lastFolder = dlg.CurrentFolder;
            }
            finally
            {
                dlg.Destroy();
            }

            InstallDialog idlg = new InstallDialog(this, service);

            try
            {
                idlg.InitForInstall(files);
                if (idlg.Run() == (int)Gtk.ResponseType.Ok)
                {
                    LoadAll();
                }
            }
            finally
            {
                idlg.Destroy();
            }
        }
Пример #4
0
        public override WindowResponse Show()
        {
            FileChooserAction fca = FileChooserAction.Open;
            switch(DialogType)
            {
                case FileDialogType.OpenFile:
                    fca = FileChooserAction.Open;
                    break;
                case FileDialogType.SelectFolder:
                    fca = FileChooserAction.SelectFolder;
                    break;
                case FileDialogType.SaveFile:
                    fca = FileChooserAction.Save;
                    break;
            }

            fc = new FileChooserDialog(Title, null, fca, Message.GetString("Cancel"), ResponseType.Cancel, Message.GetString("Select"), ResponseType.Ok);
            fc.SetCurrentFolder(InitialDirectory);
            foreach(FileTypeFilter filter in FileTypeFilters)
            {
                FileFilter ft = new FileFilter();
                ft.Name = filter.FilterName;
                foreach(string pat in filter.Filter) ft.AddPattern("*." + pat);
                fc.AddFilter(ft);
            }
            WindowResponse resp = GtkHelper.GetResponse((ResponseType)fc.Run());
            SelectedPath = fc.Filename;
            return resp;
        }
Пример #5
0
    protected void OnLoadScoreCardActionActivated(object sender, EventArgs e)
    {
        // set default location
        string defsaveloc = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);

        defsaveloc = System.IO.Path.Combine(defsaveloc, "CombatSportsCards");

        Gtk.FileChooserDialog dirchooser = new Gtk.FileChooserDialog("Choose Load File",
                                                                     this, FileChooserAction.Open,
                                                                     "Cancel", 400,
                                                                     "Load", 200);

        dirchooser.LocalOnly = true;
        dirchooser.SetCurrentFolder(defsaveloc);

        /* TODO Once a magic header and extensions has been investigated      */
        //Gtk.FileFilter filter = new Gtk.FileFilter();
        //filter.Name = "CombatSports Score Card";
        //filter.AddPattern("*.scard");
        //fc.AddFilter(filter);

        if (dirchooser.Run() == 200)
        {
            string fpath = dirchooser.Filename;
            if (!(string.IsNullOrEmpty(fpath)))
            {
                this.LoadCard(fpath);
            }
        }

        dirchooser.Destroy();
    }
Пример #6
0
    protected void OnSaveScoreCardActionActivated(object sender, EventArgs e)
    {
        // set default save location
        string defsaveloc = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);

        defsaveloc = System.IO.Path.Combine(defsaveloc, "CombatSportsCards");
        System.IO.Directory.CreateDirectory(defsaveloc);

        Gtk.FileChooserDialog dirchooser = new Gtk.FileChooserDialog("Choose Save Directory",
                                                                     this, FileChooserAction.CreateFolder,
                                                                     "Cancel", 400,
                                                                     "Choose", 200);

        /* TODO - Add Convenience Remembered Preferred Location Here */

        dirchooser.LocalOnly   = true;
        dirchooser.CurrentName = defsaveloc;
        dirchooser.SetCurrentFolder(defsaveloc);

        /* TODO - Separate this out to it's own class file so I can call infintely on null path returns in Nautilus */

        if (dirchooser.Run() == 200)
        {
            string fpath = dirchooser.Filename;
            if (string.IsNullOrEmpty(fpath))
            {
                fpath = defsaveloc;
            }

            this.SaveCard(fpath);
        }

        dirchooser.Destroy();
    }
Пример #7
0
        // creates a custom choose dialog
        static string[] ChooseDialog(FileChooserAction action, string title, bool many)
        {
            FileChooserDialog dialog = new FileChooserDialog (title, null, action);

            if (last_folder != null)
                dialog.SetCurrentFolder (last_folder);
            if (many)
                dialog.SelectMultiple = true;

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

            int response = dialog.Run ();
            string[] ret = null;

            if ((ResponseType) response == ResponseType.Ok)
                ret = dialog.Filenames;
            if ((ResponseType) response == ResponseType.Cancel)
                ret = null;

            last_folder = dialog.CurrentFolder;
            dialog.Destroy ();

            if(ret != null && ret.Length == 0) ret = null;
            return ret;
        }
Пример #8
0
        protected override void OnActivated()
        {
            base.OnActivated();

            Gtk.FileChooserDialog fc = new Gtk.FileChooserDialog(MainClass.Languages.Translate("chose_workspace_open"), MainClass.MainWindow, FileChooserAction.Open, "Cancel", ResponseType.Cancel, "Open", ResponseType.Accept);

            FileFilter filter = new FileFilter();
            filter.Name = "Workspace files";
            filter.AddMimeType("Workspace file");
            filter.AddPattern("*.msw");
            fc.AddFilter(filter);

            if (!String.IsNullOrEmpty(MainClass.Settings.LastOpenedWorkspaceDir))
                fc.SetCurrentFolder(MainClass.Settings.LastOpenedWorkspaceDir);

            if (fc.Run() == (int)ResponseType.Accept) {

                MainClass.Settings.LastOpenedWorkspaceDir = System.IO.Path.GetDirectoryName(fc.Filename);

                //CloseActualWorkspace();
                Workspace.Workspace workspace = Workspace.Workspace.OpenWorkspace(fc.Filename);

                if (workspace != null){
                    //MainClass.Settings.RecentFiles.AddWorkspace(fc.Filename,fc.Filename);
                    MainClass.MainWindow.ReloadWorkspace(workspace,true,true);
                }

            }

            fc.Destroy();
        }
Пример #9
0
        /// <summary>
        /// Raises the activated event when the Import menu item is invoked.
        /// </summary>
        /// <param name='sender'>
        /// The Gtk.MenuItem.
        /// </param>
        /// <param name='args'>
        /// Arguments.
        /// </param>

        void OnImportActivated(object sender, EventArgs args)
        {
            var fc = new Gtk.FileChooserDialog("Choose a file to import", null,
                                               Gtk.FileChooserAction.Open, "Cancel",
                                               Gtk.ResponseType.Cancel, "Import", Gtk.ResponseType.Accept);

            try {
                fc.SetCurrentFolder("/media/LocalD/SolidProject/Tools/DataMorphose/plugins/ImportExport/test/DemoDB/Text/");
                // then create a filter for files. For example .csvdb:
                // filter is not necessary if you wish to see all files in the dialog
                Gtk.FileFilter filter = new Gtk.FileFilter();
                filter.Name = "CSV database";
                filter.AddPattern("*.csvdb");
                fc.AddFilter(filter);
                if (fc.Run() == (int)Gtk.ResponseType.Accept)
                {
                    CSVImporter importer = new CSVImporter(/*firstRawIsHeader*/ true);
                    DataModel   model    = morphose.GetModel();
                    Database    db       = importer.importDBFromFiles(fc.Filename);
                    model.BeginUpdate();
                    model.DB = db;
                    model.EndUpdate();
                }
            } finally {
                fc.Destroy();
            }
        }
Пример #10
0
    protected virtual void OnCmdCalibrationFilenameClicked(object sender, System.EventArgs e)
    {
        Gtk.FileChooserDialog fc =
            new Gtk.FileChooserDialog("Choose the calibration or robot design file to open",
                                      this,
                                      FileChooserAction.Open,
                                      "Cancel", ResponseType.Cancel,
                                      "Open", ResponseType.Accept);

        fc.SetCurrentFolder(images_directory);
        if (fc.Run() == (int)ResponseType.Accept)
        {
            String filename = fc.Filename;

            if (filename.EndsWith(".xml"))
            {
                calibration_filename = filename;
                txtCalibrationFilename.Buffer.Text = filename;
            }
            else
            {
                MessageDialog md = new MessageDialog(this,
                                                     DialogFlags.DestroyWithParent,
                                                     MessageType.Warning,
                                                     ButtonsType.Ok,
                                                     "The file you selected does not appear to be in xml format");

                md.Run();
                md.Destroy();
            }
        }
        fc.Destroy();
    }
Пример #11
0
        internal static string OpenExperimentDialog(Window parentWindow)
        {
            var fileChooserDialog = new Gtk.FileChooserDialog(Mono.Unix.Catalog.GetString("Open Experiment File"),
                                                              parentWindow,
                                                              FileChooserAction.Open,
                                                              Gtk.Stock.Cancel,
                                                              Gtk.ResponseType.Cancel,
                                                              Gtk.Stock.Open, Gtk.ResponseType.Ok);

            fileChooserDialog.AlternativeButtonOrder = new int[] { (int)ResponseType.Ok, (int)ResponseType.Cancel };
            fileChooserDialog.SelectMultiple         = false;

            // HERZUM SPRINT 4 TLAB-214
            fileChooserDialog.SetCurrentFolder(TraceLab.Core.Settings.Settings.GetSettings().DefaultExperimentsDirectory);
            // END SPRINT HERZUM 4 HERZUM 4: TLAB-214

            AddFilters(fileChooserDialog);

            int response = fileChooserDialog.Run();

            string filename = null;

            if (response == (int)Gtk.ResponseType.Ok)
            {
                filename = fileChooserDialog.Filename;
            }

            fileChooserDialog.Destroy();

            return(filename);
        }
Пример #12
0
        public string ChooseFilePath()
        {
            string result   = string.Empty;
            var    renderer = Xamarin.Forms.Platform.GTK.Platform.GetRenderer(Xamarin.Forms.Application.Current.MainPage) as Gtk.Widget;

            var filechooser = new Gtk.FileChooserDialog(
                Resources.Insights_Save_File,
                renderer.Toplevel as Gtk.Window,
                Gtk.FileChooserAction.Save,
                Resources.Insights_Cancel_Save,
                ResponseType.Cancel,
                Resources.Insights_Save,
                ResponseType.Accept);

            filechooser.CurrentName = string.Format($"{Resources.Insights_Save_Default_File_Name}.{Constants.ScreenshotExtension}");

            var libraryService = DependencyService.Get <ILibraryService>();

            filechooser.SetCurrentFolder(SettingsFeature.Settings.SnipsPath);

            if (filechooser.Run() == (int)ResponseType.Accept)
            {
                result = filechooser.Filename;
            }

            filechooser.Destroy();

            return(result);
        }
Пример #13
0
    protected void OnSetToonBoomBinary(object sender, EventArgs e)
    {
        Gtk.FileChooserDialog fc = new Gtk.FileChooserDialog("Set Toon Boom binary location.", this, FileChooserAction.SelectFolder, "Cancel", ResponseType.Cancel, "Select Folder.", ResponseType.Accept);
        fc.SetCurrentFolder(@"C://Program Files (x86)/Toon Boom Animation/Toon Boom Harmony 12.1 Advanced/win64/bin");

        if (fc.Run() == (int)ResponseType.Accept)
        {
            configController.SetToonBoomBinPath(fc.Filename);

            fc.Destroy();

            if (configController.Validate())
            {
                Gtk.MessageDialog dialog = new Gtk.MessageDialog(this, DialogFlags.Modal, MessageType.Info, ButtonsType.Close, "Executables found.");
                dialog.Title = "Success";
                dialog.Run();
                dialog.Destroy();
            }
            else
            {
                Gtk.MessageDialog dialog = new Gtk.MessageDialog(this, DialogFlags.Modal, MessageType.Error, ButtonsType.Close, "Executables could not be found.");
                dialog.Title = "Error";
                dialog.Run();
                dialog.Destroy();
            }
        }
        else
        {
            fc.Destroy();
        }
    }
Пример #14
0
        private void HandlerPintaCoreActionsEditSavePaletteActivated(object sender, EventArgs e)
        {
            var fcd = new Gtk.FileChooserDialog(Catalog.GetString("Save Palette File"), PintaCore.Chrome.MainWindow,
                                                FileChooserAction.Save, Gtk.Stock.Cancel, Gtk.ResponseType.Cancel,
                                                Gtk.Stock.Save, Gtk.ResponseType.Ok);

            FileFilter ffPDN = new FileFilter();

            ffPDN.AddPattern("*.txt");
            ffPDN.Name = Catalog.GetString("Paint.NET palette (*.txt)");
            fcd.AddFilter(ffPDN);

            FileFilter ffGIMP = new FileFilter();

            ffGIMP.AddPattern("*.gpl");
            ffGIMP.Name = Catalog.GetString("GIMP palette (*.gpl)");
            fcd.AddFilter(ffGIMP);

            fcd.AlternativeButtonOrder = new int[] { (int)ResponseType.Ok, (int)ResponseType.Cancel };

            if (lastPaletteDir != null)
            {
                fcd.SetCurrentFolder(lastPaletteDir);
            }

            int response = fcd.Run();

            if (response == (int)Gtk.ResponseType.Ok)
            {
                Palette.FileFormat format = (fcd.Filter == ffPDN) ? Palette.FileFormat.PDN : Palette.FileFormat.GIMP;
                PintaCore.Palette.CurrentPalette.Save(fcd.Filename, format);
            }

            fcd.Destroy();
        }
Пример #15
0
        protected override void OnActivated()
        {
            base.OnActivated();

            if(String.IsNullOrEmpty(MainClass.Workspace.FilePath)){
                MessageDialogs md = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, MainClass.Languages.Translate("workspace_not_exist"), MainClass.Languages.Translate("please_create_workspace"), Gtk.MessageType.Error);
                md.ShowDialog();
                return;
            }

            Gtk.FileChooserDialog fc = new Gtk.FileChooserDialog(MainClass.Languages.Translate("chose_project_import"), MainClass.MainWindow, FileChooserAction.Open, "Cancel", ResponseType.Cancel, "Open", ResponseType.Accept);

            if (!String.IsNullOrEmpty(MainClass.Settings.LastOpenedImportDir))
                fc.SetCurrentFolder(MainClass.Settings.LastOpenedImportDir);

            FileFilter filter = new FileFilter();
            filter.Name = "zip files";
            filter.AddMimeType("zip file");
            filter.AddPattern("*.zip");
            fc.AddFilter(filter);

            if (fc.Run() == (int)ResponseType.Accept) {

                MainClass.Settings.LastOpenedImportDir = System.IO.Path.GetDirectoryName(fc.Filename);

                MainClass.MainWindow.ImportProject(fc.Filename,true);
            }

            fc.Destroy();
        }
Пример #16
0
    /// <summary>
    /// Loads a plugin using the Add command from the Plugins menu.
    /// </summary>
    /// <param name='sender'>
    /// Sender.
    /// </param>
    /// <param name='e'>
    /// Event args.
    /// </param>
    protected void OnAddActionActivated(object sender, EventArgs e)
    {
        var fc = new Gtk.FileChooserDialog("Choose the file to open", null,
                                           Gtk.FileChooserAction.Open, "Cancel",
                                           Gtk.ResponseType.Cancel, "Open", Gtk.ResponseType.Accept);

        try {
            fc.SelectMultiple = true;
            fc.SetCurrentFolder(Environment.CurrentDirectory);
            if (fc.Run() == (int)Gtk.ResponseType.Accept)
            {
                PluginServiceContainer pluginsToAdd = new PluginServiceContainer();
                for (int i = 0; i < fc.Filenames.Length; i++)
                {
                    if (!plugins.Plugins.Exists(x => x.codeBase == fc.Filenames[i]))
                    {
                        plugins.AddPlugin(fc.Filenames[i]);
                        pluginsToAdd.AddPlugin(fc.Filenames[i]);
                    }
                }

                pluginsToAdd.LoadPlugins();
                foreach (IPlugin p in pluginsToAdd.GetServices <IPlugin>())
                {
                    p.Init(this);
                }
            }
        } finally {
            fc.Destroy();
        }
    }
Пример #17
0
        /// <summary>
        /// File picker implementation for WPF; uses the Win32 OpenFileDialog from
        /// PresentationFoundation reference assembly.
        /// </summary>
        /// <param name="allowedTypes">
        /// Specifies one or multiple allowed types. When null, all file types
        /// can be selected while picking.
        /// On WPF, specify strings like this: "Data type (*.ext)|*.ext", which
        /// corresponds how the Windows file open dialog specifies file types.
        /// </param>
        /// <returns>file data of picked file, or null when picking was cancelled</returns>
        public Task <FileData> PickFile(string[] allowedTypes = null, string defaultName = null, bool saving = false)
        {
            var picker = new Gtk.FileChooserDialog(
                saving ? "Save As" : "Open",
                null, saving ? FileChooserAction.Save : FileChooserAction.Open,
                "Cancel", ResponseType.Cancel,
                saving ? "Save As" : "Open", ResponseType.Accept
                );

            foreach (var type in allowedTypes)
            {
                var filter = new FileFilter();
                filter.AddMimeType(type);
                filter.Name = $"{type.Split('/')[0]} files (*.{type.Split('/')[1]})";
                picker.AddFilter(filter);
            }

            picker.SetCurrentFolder(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments));
            picker.CurrentName = defaultName;

            var result = picker.Run();

            if (result == (int)Gtk.ResponseType.Accept)
            {
                FileData data = new PlatformFileData(picker.Filename);

                picker.Destroy();
                return(Task.FromResult(data));
            }
            else
            {
                picker.Destroy();
                return(Task.FromResult <FileData>(null));
            }
        }
Пример #18
0
        protected override void OnActivated()
        {
            base.OnActivated();


            if (String.IsNullOrEmpty(MainClass.Workspace.FilePath))
            {
                MessageDialogs md = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, MainClass.Languages.Translate("workspace_not_exist"), MainClass.Languages.Translate("please_create_workspace"), Gtk.MessageType.Error);
                md.ShowDialog();
                return;
            }

            Gtk.FileChooserDialog fc = new Gtk.FileChooserDialog(MainClass.Languages.Translate("chose_project_import"), MainClass.MainWindow, FileChooserAction.Open, "Cancel", ResponseType.Cancel, "Open", ResponseType.Accept);

            if (!String.IsNullOrEmpty(MainClass.Settings.LastOpenedImportDir))
            {
                fc.SetCurrentFolder(MainClass.Settings.LastOpenedImportDir);
            }

            FileFilter filter = new FileFilter();

            filter.Name = "zip files";
            filter.AddMimeType("zip file");
            filter.AddPattern("*.zip");
            fc.AddFilter(filter);

            if (fc.Run() == (int)ResponseType.Accept)
            {
                MainClass.Settings.LastOpenedImportDir = System.IO.Path.GetDirectoryName(fc.Filename);

                MainClass.MainWindow.ImportProject(fc.Filename, true);
            }

            fc.Destroy();
        }
Пример #19
0
        protected void SelectElementTableClicked(object sender, EventArgs e)
        {
            Gtk.FileChooserDialog fc = new Gtk.FileChooserDialog("Open xstage file.", this, FileChooserAction.Open, "Cancel", ResponseType.Cancel, "Open", ResponseType.Accept);
            fc.SetCurrentFolder(settings.GetSettingsFileLocationUri().AbsolutePath);
            FileFilter ff = new FileFilter();

            ff.AddPattern("*.xstage");
            fc.Filter = ff;

            if (fc.Run() == (int)ResponseType.Accept)
            {
                XStageProject        xsp          = XStageProject.Load(fc.Filename);
                List <XStageElement> elementTable = xsp.elements;

                elementTableUrl = fc.Filename;

                nodestore.Clear();
                foreach (XStageElement element in elementTable)
                {
                    Uri elementTableUri       = new Uri(elementTableUrl);
                    Uri elementTableDirectory = new Uri(elementTableUri, ".");

                    foreach (XStageDrawing d in element.drawings)
                    {
                        VectorFilePath vfp = new VectorFilePath();
                        vfp.Path = elementTableDirectory.OriginalString + element.rootFolder + "/" + element.elementFolder + "/" + element.elementName + "-" + d.name + ".tvg";
                        vfp.Name = element.elementName + "-" + d.name;
                        nodestore.AddNode(vfp);
                    }
                }

                Console.WriteLine(xsp.GetXmlString());
            }
            fc.Destroy();
        }
        protected void OnSaveButtonClicked(object sender, EventArgs e)
        {
            try
            {
                FileChooserDialog fc = new FileChooserDialog("Save Filterset", this, FileChooserAction.Save, "Cancel", ResponseType.Cancel, "Save", ResponseType.Accept);

                FileFilter filter = new FileFilter();
                filter.Name = "DeSERt Filterset";
                filter.AddMimeType("Filterset/fis");
                filter.AddPattern("*.fis");
                fc.AddFilter(filter);
                fc.DoOverwriteConfirmation = true;
                fc.CurrentName = FiltersetnameEntry.Text.Replace(" ", "-");
                if (Directory.Exists(MySettings.LastFilterDir)) { fc.SetCurrentFolder(MySettings.LastFilterDir); }

                ResponseType res = (ResponseType)fc.Run();
                if (res == ResponseType.Ok || res == ResponseType.Close)
                {
                    string path;
                    if (!System.IO.Path.HasExtension(fc.Filename)) { path = fc.Filename + ".fis"; }
                    else { path = fc.Filename; }
                    MySettings.LastFilterDir = System.IO.Path.GetDirectoryName(fc.Filename);
                    MySettings.Save();
                    fst.Name = FiltersetnameEntry.Text;
                    Filterset.SaveFilterset(path, fst);
                    saved = true;
                }
                fc.Destroy();
                if (res == ResponseType.Close) { this.Destroy(); }
            }
            catch (Exception ex) { ErrorReport.ReportError("Save Button (Create Filterset)", ex); }
        }
Пример #21
0
    protected void OnSaveStageAsActionActivated(object sender, System.EventArgs e)
    {
        Gtk.FileChooserDialog fcd = new Gtk.FileChooserDialog("Save stage description",
                                                              this,
                                                              FileChooserAction.Save,
                                                              "Cancel", ResponseType.Cancel,
                                                              "Save", ResponseType.Accept);

        FileFilter[] ffs = new FileFilter[1];
        ffs[0] = new FileFilter();
        ffs[0].AddPattern("*.cestage");
        ffs[0].Name = "CatEye Stage file";

        fcd.AddFilter(ffs[0]);

        fcd.CurrentName = System.IO.Path.GetFileNameWithoutExtension(mStage.RawFileName);
        fcd.SetCurrentFolder(System.IO.Path.GetDirectoryName(mStage.RawFileName));

        if (fcd.Run() == (int)Gtk.ResponseType.Accept)
        {
            string fn = fcd.Filename;
            if (System.IO.Path.GetExtension(fn).ToLower() != ".cestage")
            {
                fn += ".cestage";
            }

            mStage.SaveStage(fn);
        }
        fcd.Destroy();
    }
Пример #22
0
    //Add audiotrack dialog and corresponding procedure
    public bool AddAudioDialog()
    {
        //Checking the capacity overflow
        if (lat.Count >= Dynamic_Widgets_Audio.Count - 2)
        {
            Alert.Show(this, "The audiotrack limit has been reached");
            return(false);
        }
        //Prepare dialog and extension filters
        var temporarydialog = new Gtk.FileChooserDialog("", this, FileChooserAction.Open, "Cancel", ResponseType.Cancel, "Open", ResponseType.Accept);

        temporarydialog.SetCurrentFolder(@".");
        var filefilter_all = new FileFilter();

        filefilter_all.Name = "All Files (*.*)";
        filefilter_all.AddPattern("*.*");
        var filefilter_wave = new FileFilter();

        filefilter_wave.Name = "Standard Audio Files (*.mp3;*.wav)";
        filefilter_wave.AddPattern("*.mp3");
        filefilter_wave.AddPattern("*.wav");
        temporarydialog.AddFilter(filefilter_wave);
        temporarydialog.AddFilter(filefilter_all);
        //Check if file has been selected
        bool result = temporarydialog.Run() == (int)ResponseType.Accept;

        if (result)
        {
            //Add selected file and refresh corresponding panel
            lat.Add(new AudioTracks(temporarydialog.Filename));
            Refresh_Audio_Widgets(lat.Count);
        }
        temporarydialog.Destroy();
        return(result);
    }
Пример #23
0
        private void Activated(object sender, EventArgs e)
        {
            var fcd = new Gtk.FileChooserDialog (Catalog.GetString ("Open Image File"), PintaCore.Chrome.MainWindow,
                                FileChooserAction.Open, Gtk.Stock.Cancel, Gtk.ResponseType.Cancel,
                                Gtk.Stock.Open, Gtk.ResponseType.Ok);

            // Add image files filter
            FileFilter ff = new FileFilter ();
            ff.AddPixbufFormats ();
            ff.AddPattern ("*.ora");
            ff.Name = Catalog.GetString ("Image files");
            fcd.AddFilter (ff);

            FileFilter ff2 = new FileFilter ();
            ff2.Name = Catalog.GetString ("All files");
            ff2.AddPattern ("*.*");
            fcd.AddFilter (ff2);

            fcd.AlternativeButtonOrder = new int[] { (int)ResponseType.Ok, (int)ResponseType.Cancel };
            fcd.SetCurrentFolder (PintaCore.System.LastDialogDirectory);
            fcd.SelectMultiple = true;

            int response = fcd.Run ();

            if (response == (int)Gtk.ResponseType.Ok) {
                PintaCore.System.LastDialogDirectory = fcd.CurrentFolder;

                foreach (var file in fcd.Filenames)
                    if (PintaCore.Workspace.OpenFile (file))
                        RecentManager.Default.AddFull (fcd.Uri, PintaCore.System.RecentData);
            }

            fcd.Destroy ();
        }
Пример #24
0
        static void GetClip()
        {
            // TODO: Do not offer to save clip after selection and popup a clickable tooltip instead.
            FileChooserDialog fcd = new FileChooserDialog("PixClip - Save clip as...", null, FileChooserAction.Save, "Cancel", ResponseType.Cancel, "Save", ResponseType.Accept);
            FileFilter fltJpg = new FileFilter();
            fltJpg.AddMimeType("image/jpeg");
            fltJpg.Name = "JPEG image format";
            fcd.SetFilename("clip.jpg");
            fcd.SetCurrentFolder(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Desktop));
            fcd.AddFilter(fltJpg);

            Console.WriteLine("main: selecting save target");
            if (fcd.Run() == (int) ResponseType.Accept) {
                // TODO: Add quality setting to options form.
                // http://library.gnome.org/devel/gdk-pixbuf/stable/gdk-pixbuf-file-saving.html
                string [] keys = {"quality"};
                string [] values = {"90"};
                pixClip.Savev(fcd.Filename, "jpeg", keys, values);
                Console.WriteLine("main: image saved");
            } else {
                Console.WriteLine("main: image save canceled");
            }
            fcd.Destroy();

            Clipboard clip = Gtk.Clipboard.Get(Atom.Intern("CLIPBOARD", false));
            clip.Image = pixClip;
            Console.WriteLine("main: image added to the clipboard");
        }
Пример #25
0
        internal static string OpenExperimentDialog(Window parentWindow) 
        {
            var fileChooserDialog = new Gtk.FileChooserDialog(Mono.Unix.Catalog.GetString ("Open Experiment File"), 
                                                               parentWindow,
                                                               FileChooserAction.Open, 
                                                               Gtk.Stock.Cancel, 
                                                               Gtk.ResponseType.Cancel,
                                                               Gtk.Stock.Open, Gtk.ResponseType.Ok);

            fileChooserDialog.AlternativeButtonOrder = new int[] { (int)ResponseType.Ok, (int)ResponseType.Cancel };
            fileChooserDialog.SelectMultiple = false;

            // HERZUM SPRINT 4 TLAB-214
            fileChooserDialog.SetCurrentFolder(TraceLab.Core.Settings.Settings.GetSettings().DefaultExperimentsDirectory);
            // END SPRINT HERZUM 4 HERZUM 4: TLAB-214

            AddFilters(fileChooserDialog);

            int response = fileChooserDialog.Run();

            string filename = null;
            if(response == (int)Gtk.ResponseType.Ok) 
            {
                filename = fileChooserDialog.Filename;
            }
            
            fileChooserDialog.Destroy();

            return filename;
        }
Пример #26
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;
        }
Пример #27
0
        /// <summary>
        /// Shows the save dialog.
        /// </summary>
        /// <returns>
        /// The save dialog.
        /// </returns>
        /// <param name='dlg'>
        /// Parent [obsolet]
        /// </param>
        public static string ShowSaveDialog(Gtk.Dialog dlg, string FilterName = "Regex", string FilterContent = "*.rgx")
        {
            try {
                Gtk.FileChooserDialog fc  = new Gtk.FileChooserDialog(Catalog.GetString("SavingTitle"), null, FileChooserAction.Save, "Speichern", ResponseType.Accept, "Abbrechen", ResponseType.Cancel);
                FileFilter            flt = new FileFilter();
                if (FilterContent == "*.rgx")
                {
                    flt.Name = Catalog.GetString("Regex - Projects");
                    flt.AddPattern("*.rgx");
                }
                else
                {
                    flt.Name = FilterName;
                    flt.AddPattern(FilterContent);
                }
                fc.Filter = flt;
                string filename = "";
                fc.SetCurrentFolder(new libTerminus.cPathEnvironment().const_start_path);

                //Run the Dialog
                if (fc.Run() == (int)ResponseType.Accept)
                {
                    filename = fc.Filename;
                    filename = cTerminus.getCorrectedString(filename);
                }
                fc.Destroy();
                return(filename);
            } catch (Exception ex) {
                MessageBox.Show(ex.Message, cTerminus.g_programName, ButtonsType.Close, MessageType.Error);
                return("");
            }
        }
Пример #28
0
        public static string ShowBrowseFolderDialog(string title, ref string defaultPath)
        {
            Gtk.FileChooserDialog filechooser =
                new Gtk.FileChooserDialog("Choose the file to save",
                                          null,
                                          FileChooserAction.Save,
                                          "Cancel", ResponseType.Cancel,
                                          "Save", ResponseType.Accept);

            filechooser.Modal           = true;
            filechooser.Action          = FileChooserAction.SelectFolder;
            filechooser.SkipTaskbarHint = true;
            filechooser.TransientFor    = FamiStudioForm.Instance;
            filechooser.SetCurrentFolder(defaultPath);

            string filename = null;

            if (filechooser.Run() == (int)ResponseType.Accept)
            {
                filename    = filechooser.Filename;
                defaultPath = Path.GetDirectoryName(filename);
            }

            filechooser.Destroy();

            return(filename);
        }
Пример #29
0
    protected void OnFileAddedClicked(object sender, EventArgs e)
    {
        Gtk.FileChooserDialog fc = new Gtk.FileChooserDialog("Choose file.", this, FileChooserAction.Open, "Cancel", ResponseType.Cancel, "Select File", ResponseType.Accept);
        fc.SetCurrentFolder(exportSettingsController.GetSettingsFileLocationUri().AbsolutePath);
        FileFilter ff = new FileFilter();

        ff.AddPattern("*.tvg");
        fc.Filter         = ff;
        fc.SelectMultiple = true;
        if (fc.Run() == (int)ResponseType.Accept)
        {
            foreach (String filename in fc.Filenames)
            {
                String consoleOut;

                Uri settingsFileLocation = exportSettingsController.GetSettingsFileLocationUri();

                Uri selectedFile = new Uri(filename);
                Uri relative     = settingsFileLocation.MakeRelativeUri(selectedFile);

                exportSettingsController.AddFile(relative, System.IO.Path.GetFileName(filename), out consoleOut);
                WriteLine(consoleOut);
                consoleOut = "";
            }
        }
        fc.Destroy();
    }
Пример #30
0
        private void OpenFileButton_Clicked(object sender, EventArgs e)
        {
            var fileChooser = new FileChooserDialog("Pick a file", this.Window, FileChooserAction.Open, "Cancel", ResponseType.Cancel, "Open", ResponseType.Accept);
            fileChooser.Filter = new FileFilter();
            fileChooser.Filter.AddPattern("*.xt");
#if DEBUG
            fileChooser.SetCurrentFolder(@"c:\tmp\traces");
#endif
            var result = (ResponseType)Enum.ToObject(typeof(ResponseType), fileChooser.Run());
            switch (result)
            {
                case ResponseType.Accept:
                    var filename = fileChooser.Filename;
                    Parser parser = null;
                    fileChooser.Destroy();
                    try
                    {
                        parser = Parser.ParseFile(filename);
                    }
                    catch (Exception ex)
                    {
                        var dlg = new MessageDialog(this.Window, DialogFlags.Modal, MessageType.Error, ButtonsType.Ok, "Failed to load/parse the selected file! \r\nSome indication: " + ex.Message);
                        dlg.Run();
                    }
                    if (parser != null)
                    {
                        ShowTraces(parser);
                    }
                    break;
                case ResponseType.Cancel:
                case ResponseType.DeleteEvent:
                    fileChooser.Destroy();
                    break;
            }
        }
Пример #31
0
		protected virtual void OpenClicked (object sender, System.EventArgs e)
		{
			FileChooserDialog dlg = new FileChooserDialog (
				GettextCatalog.GetString ("Select Executable"), null, FileChooserAction.Open,
				"gtk-cancel", ResponseType.Cancel,
				"gtk-open", ResponseType.Accept
			);
			dlg.SelectMultiple = false;
			dlg.LocalOnly = true;
			dlg.Modal = true;
			dlg.SetCurrentFolder (Environment.GetFolderPath (Environment.SpecialFolder.Personal));
			
			FileFilter filterExe = new FileFilter ();
			filterExe.AddPattern ("*.exe");
			filterExe.Name = GettextCatalog.GetString ("Executables");
			FileFilter filterAll = new FileFilter ();
			filterAll.AddPattern ("*");
			filterAll.Name = GettextCatalog.GetString ("All files");
			dlg.AddFilter (filterExe);
			dlg.AddFilter (filterAll);

			if (dlg.Run () == (int)ResponseType.Accept)
				entryExecutable.Text = dlg.Filename;
			dlg.Destroy ();
		}
Пример #32
0
        // HERZUM SPRINT 4: TLAB-214
        internal static bool SelectCatalogDialog(Window parentWindow, out string selectedDirectory, string defaultDirectory)
        // END HERZUM SPRINT 4: TLAB-214
        {
            var fileChooserDialog = new Gtk.FileChooserDialog(Mono.Unix.Catalog.GetString("Select Directory..."),
                                                              parentWindow,
                                                              FileChooserAction.SelectFolder,
                                                              Gtk.Stock.Cancel,
                                                              Gtk.ResponseType.Cancel,
                                                              Gtk.Stock.Open, Gtk.ResponseType.Ok);

            fileChooserDialog.AlternativeButtonOrder = new int[] { (int)ResponseType.Ok, (int)ResponseType.Cancel };
            fileChooserDialog.SelectMultiple         = false;

            // HERZUM SPRINT 4 TLAB-214
            if (defaultDirectory != null)
            {
                fileChooserDialog.SetCurrentFolder(defaultDirectory);
            }
            // END SPRINT HERZUM 4 HERZUM 4: TLAB-214

            int response = fileChooserDialog.Run();

            if (response == (int)Gtk.ResponseType.Ok)
            {
                selectedDirectory = fileChooserDialog.Filename;
                fileChooserDialog.Destroy();
                return(true);
            }
            else
            {
                selectedDirectory = "";
                fileChooserDialog.Destroy();
                return(false);
            }
        }
Пример #33
0
        protected void LoadProbeClicked(object sender, EventArgs e)
        {
            Gtk.FileChooserDialog fcd = new Gtk.FileChooserDialog("Open File", null, Gtk.FileChooserAction.Open);
            fcd.AddButton(Gtk.Stock.Cancel, Gtk.ResponseType.Cancel);
            fcd.AddButton(Gtk.Stock.Open, Gtk.ResponseType.Ok);
            fcd.DefaultResponse = Gtk.ResponseType.Ok;
            fcd.SelectMultiple  = false;

            Gtk.FileFilter filter = new FileFilter
            {
                Name = "NIRS probe"
            };
            filter.AddMimeType("XML");
            filter.AddMimeType("Matlab");
            filter.AddPattern("*.SD");
            filter.AddPattern("*.xml");
            fcd.Filter = filter;

            fcd.SetCurrentFolder(MainClass.win.settings.PROBEDIR);

            Gtk.ResponseType response = (Gtk.ResponseType)fcd.Run();
            if (response == Gtk.ResponseType.Ok)
            {
                probe = nirs.io.LoadProbe(fcd.Filename);
                Sdgdraw(sender, e);
            }
            probefilename = fcd.Filename;
            fcd.Destroy();
        }
Пример #34
0
        private bool SaveAs(IEditor se)
        {
            bool   saveStatus = false;
            string filePath   = se.FileName;

            var dlg = new Gtk.FileChooserDialog("Save as...", MainClass.MainWindow, FileChooserAction.Save, "Cancel", ResponseType.Cancel, "Save", ResponseType.Accept);

            if (filePath != null)
            {
                string fileName = System.IO.Path.GetFileName(filePath);
                string fileDir  = System.IO.Path.GetDirectoryName(filePath);

                dlg.CurrentName = fileName;
                dlg.SetCurrentFolder(fileDir);
            }

            if (dlg.Run() == (int)ResponseType.Accept)
            {
                saveStatus = se.SaveAs(dlg.Filename);
                NotebookEditorLabel nl = (NotebookEditorLabel)this.GetTabLabel(se.Control);
                if (nl != null)
                {
                    nl.SetNewName(se.FileName);
                }
            }
            dlg.Destroy();
            return(saveStatus);
        }
Пример #35
0
        protected override void OnActivated()
        {
            base.OnActivated();

            if(String.IsNullOrEmpty(MainClass.Workspace.FilePath)){
                MessageDialogs md = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, MainClass.Languages.Translate("workspace_not_exist"), MainClass.Languages.Translate("please_create_workspace"), Gtk.MessageType.Error);
                md.ShowDialog();
                return;
            }

            Gtk.FileChooserDialog fc = new Gtk.FileChooserDialog(MainClass.Languages.Translate("save_project_export"), MainClass.MainWindow, FileChooserAction.Save, "Cancel", ResponseType.Cancel, "Save", ResponseType.Accept);

            if (!String.IsNullOrEmpty(MainClass.Settings.LastOpenedExportDir))
                fc.SetCurrentFolder(MainClass.Settings.LastOpenedExportDir);

            FileFilter filter = new FileFilter();
            filter.Name = "zip files";
            filter.AddMimeType("zip file");
            filter.AddPattern("*.zip");
            fc.AddFilter(filter);

            string appname = "";
            int typ = -1;
            Gtk.TreeIter ti = new Gtk.TreeIter();
            MainClass.MainWindow.WorkspaceTree.GetSelectedFile(out appname, out typ, out ti);

            if (String.IsNullOrEmpty(appname)){
                return;
            }

            Project p = MainClass.Workspace.FindProject_byApp(appname, true);

            if(p== null){
                return;
            }

            fc.CurrentName =p.ProjectName+"_"+p.AppFile.Version.Replace(".","_") ;
            //fc.SetFilename(p.ProjectName);

            if (fc.Run() != (int)ResponseType.Accept) {
                fc.Destroy();
                return;
            }

            string name =fc.Filename;

            string ext = System.IO.Path.GetExtension(name);

            if(ext.ToLower() != ".zip"){
                name = name+".zip";
            }

            if(p!= null){
                p.Export(name,true);
                MainClass.Settings.LastOpenedExportDir = System.IO.Path.GetDirectoryName(fc.Filename);
            }
            fc.Destroy();
        }
Пример #36
0
        public static string[] ShowOpenFileDialog(string title, string extensions, ref string defaultPath, bool multiselect, Window parentWindow = null)
        {
            var extensionList = GetExtensionList(extensions);

            Gtk.Rc.ResetStyles(Gtk.Settings.GetForScreen(Gdk.Screen.Default));
            Gtk.Rc.ReparseAll();

            Gtk.FileChooserDialog filechooser =
                new Gtk.FileChooserDialog(title,
                                          null,
                                          FileChooserAction.Open,
                                          "Cancel", ResponseType.Cancel,
                                          "Open", ResponseType.Accept);

            filechooser.Modal           = true;
            filechooser.SkipTaskbarHint = true;
            filechooser.TransientFor    = parentWindow != null ? parentWindow : FamiStudioForm.Instance;
            filechooser.SetCurrentFolder(defaultPath);
            filechooser.SelectMultiple = multiselect;

            if (extensionList.Length > 0)
            {
                filechooser.Filter = new FileFilter();
                foreach (var ext in extensionList)
                {
                    filechooser.Filter.AddPattern($"*.{ext}");
                }
            }

            string[] filenames = null;
            if (filechooser.Run() == (int)ResponseType.Accept)
            {
                if (multiselect)
                {
                    filenames = filechooser.Filenames;
                    if (filenames.Length > 0)
                    {
                        defaultPath = Path.GetDirectoryName(filenames[0]);
                    }
                }
                else
                {
                    var filename = filechooser.Filename;
                    if (!string.IsNullOrEmpty(filename))
                    {
                        defaultPath = Path.GetDirectoryName(filename);
                        filenames   = new[] { filename };
                    }
                }
            }

            filechooser.Destroy();

            return(filenames);
        }
Пример #37
0
        public bool OpenFileDialog(OpenFileDialogParams openParams, Action <OpenFileDialogParams> callback)
        {
            WinformsSystemWindow.ShowingSystemDialog = true;
            Gtk.Application.Init();

            Gtk.FileChooserDialog fc =
                new Gtk.FileChooserDialog(openParams.Title,
                                          null,
                                          FileChooserAction.Open,
                                          "Cancel", ResponseType.Cancel,
                                          "Open", ResponseType.Accept);

            if (openParams.InitialDirectory != null)
            {
                fc.SetCurrentFolder(openParams.InitialDirectory);
            }
            fc.SelectMultiple = openParams.MultiSelect;

            Gtk.FileFilter filter = new Gtk.FileFilter();
            filter.Name = openParams.Filter.Split('|')[0];
            string[] extensions = openParams.Filter.Split('|') [1].Split(';');
            foreach (string e in extensions)
            {
                filter.AddPattern(e.ToLower());
                filter.AddPattern(e.ToUpper());
            }
            fc.AddFilter(filter);

            // fc.Show();
            // fc.Present();
            fc.KeepAbove = true;

            if (fc.Run() == (int)ResponseType.Accept)
            {
                this.LastDirectoryUsed = Path.GetDirectoryName(fc.Filename);
                openParams.FileNames   = fc.Filenames;
                openParams.FileName    = fc.Filename;
                UiThread.RunOnIdle(() =>
                {
                    callback(openParams);
                });
            }

            fc.Destroy();
            while (Gtk.Application.EventsPending())
            {
                Gtk.Main.Iteration();
            }

            WinformsSystemWindow.ShowingSystemDialog = false;

            return(true);
        }
Пример #38
0
        public static string ShowSaveFileDialog(string title, string extensions, ref string defaultPath)
        {
            var extensionList = GetExtensionList(extensions);

#if FAMISTUDIO_MACOS
            var filename = MacUtils.ShowSaveDialog(title, extensionList, defaultPath);
            if (!string.IsNullOrEmpty(filename))
            {
                defaultPath = Path.GetDirectoryName(filename);
            }
            return(filename);
#else
            Gtk.FileChooserDialog filechooser =
                new Gtk.FileChooserDialog(title,
                                          null,
                                          FileChooserAction.Save,
                                          "Cancel", ResponseType.Cancel,
                                          "Save", ResponseType.Accept);

            filechooser.KeepAbove       = true;
            filechooser.Modal           = true;
            filechooser.SkipTaskbarHint = true;
            filechooser.TransientFor    = FamiStudioForm.Instance;
            filechooser.SetCurrentFolder(defaultPath);

            filechooser.Filter = new FileFilter();
            foreach (var ext in extensionList)
            {
                filechooser.Filter.AddPattern($"*.{ext}");
            }

            string filename = null;
            if (filechooser.Run() == (int)ResponseType.Accept)
            {
                filename = filechooser.Filename;

                // GTK file chooser does not add the extension automatically.
                var extension        = Path.GetExtension(filename).ToLower();
                var desiredExtension = $".{extensionList[0]}";

                if (extension != desiredExtension)
                {
                    filename = Path.ChangeExtension(filename, desiredExtension);
                }

                defaultPath = Path.GetDirectoryName(filename);
            }

            filechooser.Destroy();

            return(filename);
#endif
        }
Пример #39
0
        private void Activated(object sender, EventArgs e)
        {
            var fcd = new Gtk.FileChooserDialog(Catalog.GetString("Open Image File"), PintaCore.Chrome.MainWindow,
                                                FileChooserAction.Open, Gtk.Stock.Cancel, Gtk.ResponseType.Cancel,
                                                Gtk.Stock.Open, Gtk.ResponseType.Ok);

            // Add image files filter
            FileFilter ff = new FileFilter();

            foreach (var format in PintaCore.System.ImageFormats.Formats)
            {
                if (!format.IsWriteOnly())
                {
                    foreach (var ext in format.Extensions)
                    {
                        ff.AddPattern(string.Format("*.{0}", ext));
                    }
                }
            }

            ff.Name = Catalog.GetString("Image files");
            fcd.AddFilter(ff);

            FileFilter ff2 = new FileFilter();

            ff2.Name = Catalog.GetString("All files");
            ff2.AddPattern("*.*");
            fcd.AddFilter(ff2);

            fcd.AlternativeButtonOrder = new int[] { (int)ResponseType.Ok, (int)ResponseType.Cancel };
            fcd.SetCurrentFolder(PintaCore.System.GetDialogDirectory());
            fcd.SelectMultiple = true;

            fcd.AddImagePreview();

            int response = fcd.Run();

            if (response == (int)Gtk.ResponseType.Ok)
            {
                PintaCore.System.LastDialogDirectory = fcd.CurrentFolder;

                foreach (var file in fcd.Filenames)
                {
                    if (PintaCore.Workspace.OpenFile(file, fcd))
                    {
                        RecentManager.Default.AddFull(fcd.Uri, PintaCore.System.RecentData);
                    }
                }
            }

            fcd.Destroy();
        }
Пример #40
0
        public void Save()
        {
            Gtk.FileChooserDialog fc = new Gtk.FileChooserDialog(MainClass.Languages.Translate("save_path"), MainClass.MainWindow, FileChooserAction.Save, MainClass.Languages.Translate("cancel"), ResponseType.Cancel, MainClass.Languages.Translate("save"), ResponseType.Accept);
            fc.SetCurrentFolder(MainClass.Workspace.RootDirectory);

            if (fc.Run() == (int)ResponseType.Accept)
            {
                System.IO.StreamWriter write = new System.IO.StreamWriter(fc.Filename);
                write.Write(buffer.Text);
                write.Close();
            }
            fc.Destroy();
        }
Пример #41
0
    protected void on_SaveSongFileAs(object sender, EventArgs e)
    {
        Gtk.FileChooserDialog filechooser =
            new Gtk.FileChooserDialog("Save the song file",
                                      this,
                                      FileChooserAction.Save,
                                      "Cancel", ResponseType.Cancel,
                                      "Save As", ResponseType.Accept);

        FileFilter filter = new FileFilter();

        filter.AddPattern("*.pro");

        filechooser.Filter = filter;

        if (!string.IsNullOrEmpty(_currentSong.FilePath))
        {
            filechooser.SetFilename(_currentSong.FilePath);
        }
        else
        {
            string title = _currentSong.Title.Trim();
            title = title.Replace("/", "-");
            title = title.Replace("\\", "-");
            title = title.Replace(".", "");
            filechooser.CurrentName = title;
        }


        string folder = _appSettings.DefaultFolder;

        if (!string.IsNullOrEmpty(folder) &&
            System.IO.Directory.Exists(folder))
        {
            filechooser.SetCurrentFolder(folder);
        }


        if (filechooser.Run() == (int)ResponseType.Accept)
        {
            string fileName = filechooser.Filename;
            fileName = fileName + ".pro";

            _currentSong.FilePath = fileName;
            FileOperations.SaveSongFile(_currentSong);

            CheckStatuses();
        }

        filechooser.Destroy();
    }
Пример #42
0
	protected FileOpenDialog (bool toEnableVideo, string title) : base(gladeFilename) {
		dialog = GetDialog() as FileChooserDialog;
		dialog.Title = title;

		InitEncodingComboBox();

		if (toEnableVideo)
			EnableVideo();

		string startFolder = GetStartFolder();
		dialog.SetCurrentFolder(startFolder);

		SetFilters();
	}
Пример #43
0
    protected void OnOpen(object o, EventArgs e)
    {
        if (!ChangeConfirm("load a new level"))
        {
            return;
        }
        fileChooser.Title  = "Choose a Level";
        fileChooser.Action = Gtk.FileChooserAction.Open;
        fileChooser.SetCurrentFolder(Settings.Instance.LastDirectoryName);
        fileChooser.Filter = fileChooser.Filters[0];
        int result = fileChooser.Run();

        fileChooser.Hide();
        if (result != (int)Gtk.ResponseType.Ok)
        {
            return;
        }

        Settings.Instance.LastDirectoryName = fileChooser.CurrentFolder;
        Settings.Instance.Save();
        Load(fileChooser.Filename);
        EditProperties(CurrentLevel, "Level");
    }
        public override bool OpenFileDialog(OpenFileDialogParams openParams, Action <OpenFileDialogParams> callback)
        {
            WidgetForWindowsFormsAbstract.MainWindowsFormsWindow.ShowingSystemDialog = true;

            Gtk.FileChooserDialog fc =
                new Gtk.FileChooserDialog(openParams.Title,
                                          null,
                                          FileChooserAction.Open,
                                          "Cancel", ResponseType.Cancel,
                                          "Open", ResponseType.Accept);

            fc.SetCurrentFolder(openParams.InitialDirectory);
            fc.SelectMultiple = openParams.MultiSelect;

            Gtk.FileFilter filter = new Gtk.FileFilter();
            filter.Name = openParams.Filter.Split('|')[0];
            string[] extensions = openParams.Filter.Split('|') [1].Split(';');
            foreach (string e in extensions)
            {
                filter.AddPattern(e.ToLower());
                filter.AddPattern(e.ToUpper());
            }
            fc.AddFilter(filter);

            Gtk.Application.Init();

            if (fc.Run() == (int)ResponseType.Accept)
            {
                openParams.FileNames = fc.Filenames;
                openParams.FileName  = fc.Filename;
                UiThread.RunOnIdle((state) =>
                {
                    OpenFileDialogParams openParamsIn = state as OpenFileDialogParams;
                    if (openParamsIn != null)
                    {
                        callback(openParamsIn);
                    }
                }, openParams);
            }

            fc.Destroy();
            while (Gtk.Application.EventsPending())
            {
                Gtk.Main.Iteration();
            }

            WidgetForWindowsFormsAbstract.MainWindowsFormsWindow.ShowingSystemDialog = false;

            return(true);
        }
Пример #45
0
 private void OnBrowseButtonClicked(object sender, EventArgs args)
 {
     FileChooserDialog chooser = new FileChooserDialog ("Select a path:", (Window)preferencesForm["preferencesDialog"], FileChooserAction.SelectFolder, Stock.Ok);
     if (defaultOutputPathEntry.Text.Length != 0) {
         chooser.SetCurrentFolder (defaultOutputPathEntry.Text);
     }
     chooser.AddButton (Stock.Ok, ResponseType.Accept);
     ResponseType responseType = (ResponseType) chooser.Run ();
     switch (responseType) {
         case ResponseType.Accept:
             defaultOutputPathEntry.Text = chooser.CurrentFolder;
             break;
         default:
             break;
     }
     chooser.Destroy ();
 }
Пример #46
0
        protected void ButtonBrowse_Clicked(object sender, EventArgs e)
        {
            var dialog = new FileChooserDialog("Add Content Folder",
                             _window,
                             FileChooserAction.SelectFolder,
                             "Cancel", ResponseType.Cancel,
                             "Open", ResponseType.Accept);
            dialog.SetCurrentFolder(_window._controller.GetFullPath(entryPath.Text));

            var responseId = dialog.Run();
            var fileName = dialog.Filename;
            dialog.Destroy();

            if (responseId != (int)ResponseType.Accept)
                return;
            
            var pathUri = new Uri(fileName);
            entryPath.Text = Uri.UnescapeDataString(_projectLocation.MakeRelativeUri(pathUri).ToString().Replace('/', System.IO.Path.DirectorySeparatorChar));
            entryPath.Position = entryPath.Text.Length;
        }
Пример #47
0
    protected virtual void OnExecuteActionActivated(object sender, System.EventArgs e)
    {
        FileChooserDialog dialog =
            new FileChooserDialog ("Profile Application", null, FileChooserAction.Open,
                           Gtk.Stock.Cancel, Gtk.ResponseType.Cancel,
                           Gtk.Stock.Open, Gtk.ResponseType.Ok);

        if (lastFolder != null)
            dialog.SetCurrentFolder (lastFolder);

        int response = dialog.Run ();
        try {
            if (response == (int)Gtk.ResponseType.Ok) {
                lastFolder = dialog.CurrentFolder;
                ProfileApplication (dialog.Filename);
            }
        } finally {
            dialog.Destroy ();
        }
    }
Пример #48
0
        void ButtonOpenClicked(object sender, EventArgs args)
        {
            FileChooserDialog dialog = new FileChooserDialog ("Open an Swf", this, FileChooserAction.Open, new object[] { "Cancel", ResponseType.Cancel, "Open", ResponseType.Accept });
            FileFilter filter = new FileFilter ();
            filter.AddPattern ("*.[sS][wW][fF]");
            dialog.Filter = filter;
            dialog.SetCurrentFolder (Environment.GetFolderPath (Environment.SpecialFolder.Personal));

            if (dialog.Run () == (int)ResponseType.Accept)
            {
                URL url = URL.NewFromInput (dialog.Filename);

                GtkPlayer player = new GtkPlayer (null);
                player.Url = url;

                _swf.Player = player;

                player.Playing = true;
            }

            dialog.Destroy ();
        }
Пример #49
0
        public static ResponseType Show(FileChooserAction action, Window parent, string title, out string filename)
        {
            FileChooserDialog fc = null;
            switch(action) {
                case FileChooserAction.Open:
                    fc = new FileChooserDialog(title, parent, FileChooserAction.Open, Stock.Cancel, ResponseType.Cancel, Stock.Open, ResponseType.Ok);
                    break;
                case FileChooserAction.Save:
                    fc = new FileChooserDialog(title, parent, FileChooserAction.Save, Stock.Cancel, ResponseType.Cancel, Stock.Save, ResponseType.Ok);
                    break;
                case FileChooserAction.CreateFolder:
                    throw new NotImplementedException();
                case FileChooserAction.SelectFolder:
                    throw new NotImplementedException();
            }

            fc.SetCurrentFolder(Environment.GetFolderPath(Environment.SpecialFolder.Personal));

            fc.Modal				= true;
            fc.DestroyWithParent	= true;
            fc.SkipTaskbarHint		= true;
            fc.Icon					= App.DefaultWindowIcon;

            FileFilter ff;
            ff = new FileFilter();
            ff.Name = S._("VolumeDatabase files");
            ff.AddPattern("*.vdb");
            fc.AddFilter(ff);

            ff = new FileFilter();
            ff.Name = S._("All files");
            ff.AddPattern("*.*");
            fc.AddFilter(ff);

            ResponseType r = (ResponseType)fc.Run();
            filename = fc.Filename;
            fc.Destroy();
            return r;
        }
Пример #50
0
        public PropertyGridTable ()
        {
            Build();

            items = new List<TreeItem> ();
            pitems = new List<TreeItem> ();
            eitems = new List<EventItem> ();
            nulliter = new TreeIter ();
            sortgroup = true;

            var column1 = new TreeViewColumn ();
            column1.Sizing = TreeViewColumnSizing.Fixed;
            column1.FixedWidth = 100;
            column1.Resizable = true;
            column1.Title = "Name";

            var textCell1 = new CellRendererText ();
            textCell1.Underline = Pango.Underline.Single;
            column1.PackStart (textCell1, false);

            var textCell2 = new CellRendererText ();
            column1.PackStart (textCell2, false);

            var idCell = new CellRendererText ();
            idCell.Visible = false;
            column1.PackStart (idCell, false);

            treeview1.AppendColumn (column1);

            var column2 = new TreeViewColumn ();
            column2.Sizing = TreeViewColumnSizing.Fixed;
            column2.Resizable = true;
            column2.Title = "Value";

            var editTextCell = new CellRendererText ();

            editTextCell.Edited += delegate(object o, EditedArgs args) {
                #if GTK2
                TreeModel model;
                #elif GTK3
                ITreeModel model;
                #endif
                TreeIter iter;

                if (treeview1.Selection.GetSelected (out model, out iter)) {

                    int id = Convert.ToInt32(model.GetValue(iter, 11));

                    for(int i = 0;i < eitems.Count;i++)
                    {
                        if(eitems[i].id == id)
                        {
                            if(eitems[i].eventHandler != null)
                            {
                                var fwidget = new FalseWidget(args.NewText);
                                eitems[i].eventHandler(fwidget, EventArgs.Empty);
                                model.SetValue(iter, 4, args.NewText);
                                break;
                            }
                        }
                    }
                }
            };

            column2.PackStart (editTextCell, false);

            var editTextCell2 = new CellRendererText ();
            editTextCell2.Editable = true;
            editTextCell2.EditingStarted += delegate {
                #if GTK2
                TreeModel model;
                #elif GTK3
                ITreeModel model;
                #endif
                TreeIter iter;

                if (treeview1.Selection.GetSelected (out model, out iter)) {

                    var dialog = new CollectionEditorDialog(model.GetValue(iter, 14).ToString(), window);
                    dialog.TransientFor = window;
                    if(dialog.Run() == (int)ResponseType.Ok)
                    {
                        int id = Convert.ToInt32(model.GetValue(iter, 11));

                        for(int i = 0;i < eitems.Count;i++)
                        {
                            if(eitems[i].id == id)
                            {
                                if(eitems[i].eventHandler != null)
                                {
                                    var fwidget = new FalseWidget(dialog.text);
                                    eitems[i].eventHandler(fwidget, EventArgs.Empty);
                                    model.SetValue(iter, 14, dialog.text);
                                    break;
                                }
                            }
                        }
                    }
                }
            };
            column2.PackStart (editTextCell2, false);

            var editTextCell4 = new CellRendererText ();
            editTextCell4.Editable = true;
            editTextCell4.EditingStarted += delegate {
                #if GTK2
                TreeModel model;
                #elif GTK3
                ITreeModel model;
                #endif
                TreeIter iter;

                if (treeview1.Selection.GetSelected (out model, out iter)) {

                    var dialog = new ColorPickerDialog(model.GetValue(iter, 15).ToString());
                    dialog.TransientFor = window;
                    if(dialog.Run() == (int)ResponseType.Ok)
                    {
                        int id = Convert.ToInt32(model.GetValue(iter, 11));

                        for(int i = 0;i < eitems.Count;i++)
                        {
                            if(eitems[i].id == id)
                            {
                                if(eitems[i].eventHandler != null)
                                {
                                    var fwidget = new FalseWidget(dialog.data);
                                    eitems[i].eventHandler(fwidget, EventArgs.Empty);
                                    model.SetValue(iter, 15, dialog.data);
                                    break;
                                }
                            }
                        }
                    }
                }
            };
            column2.PackStart (editTextCell4, false);

            var editTextCell3 = new CellRendererText ();
            editTextCell3.Visible = false;
            column2.PackStart (editTextCell3, false);

            var comboCell = new CellRendererCombo ();
            comboCell.TextColumn = 0;
            comboCell.IsExpanded = true;
            comboCell.Editable = true;
            comboCell.HasEntry = false;
            comboCell.Edited += delegate(object o, EditedArgs args) {
                #if GTK2
                TreeModel model;
                #elif GTK3
                ITreeModel model;
                #endif
                TreeIter iter;

                if (treeview1.Selection.GetSelected (out model, out iter)) {

                    int id = Convert.ToInt32(model.GetValue(iter, 11));

                    for(int i = 0;i < eitems.Count;i++)
                    {
                        if(eitems[i].id == id)
                        {
                            if(eitems[i].eventHandler != null && args.NewText != null && args.NewText != "")
                            {
                                var fwidget = new FalseWidget(args.NewText);
                                eitems[i].eventHandler(fwidget, EventArgs.Empty);
                                model.SetValue(iter, 8, args.NewText);
                                break;
                            }
                        }
                    }
                }
            };

            column2.PackStart (comboCell , false);

            var editFilePathCell = new CellRendererText();
            editFilePathCell.Editable = true;
            editFilePathCell.EditingStarted += delegate(object o, EditingStartedArgs args) {
                #if GTK2
                TreeModel model;
                #elif GTK3
                ITreeModel model;
                #endif
                TreeIter iter;

                if (treeview1.Selection.GetSelected (out model, out iter)) {

                    var dialog = new FileChooserDialog("Add Content Folder",
                        window,
                        FileChooserAction.SelectFolder,
                        "Cancel", ResponseType.Cancel,
                        "Open", ResponseType.Accept);
                    dialog.SetCurrentFolder (window._controller.GetFullPath(model.GetValue(iter, 17).ToString()));

                    int responseid = dialog.Run();
                    string fileName = dialog.Filename;
                    dialog.Destroy();

                    if(responseid == (int)ResponseType.Accept)
                    {
                        int id = Convert.ToInt32(model.GetValue(iter, 11));

                        for(int i = 0;i < eitems.Count;i++)
                        {
                            if(eitems[i].id == id)
                            {
                                if(eitems[i].eventHandler != null)
                                {
                                    string pl = ((PipelineController)window._controller).ProjectLocation;
                                    if (!pl.EndsWith(System.IO.Path.DirectorySeparatorChar.ToString()))
                                        pl += System.IO.Path.DirectorySeparatorChar;

                                    Uri folderUri = new Uri(pl);
                                    Uri pathUri = new Uri(fileName);

                                    string newpath = Uri.UnescapeDataString(folderUri.MakeRelativeUri(pathUri).ToString().Replace('/', System.IO.Path.DirectorySeparatorChar));

                                    var fwidget = new FalseWidget(newpath);
                                    eitems[i].eventHandler(fwidget, EventArgs.Empty);
                                    model.SetValue(iter, 17, newpath);
                                    break;
                                }
                            }
                        }
                    }
                }
            };
            column2.PackStart (editFilePathCell, false);

            treeview1.AppendColumn (column2);

            column1.AddAttribute (textCell1, "text", 0);
            column1.AddAttribute (textCell1, "visible", 1);
            column1.AddAttribute (textCell2, "text", 2);
            column1.AddAttribute (textCell2, "visible", 3);
            column2.AddAttribute (editTextCell, "text", 4);
            column2.AddAttribute (editTextCell, "visible", 5);
            column2.AddAttribute (editTextCell, "editable", 6);
            column2.AddAttribute (comboCell, "model", 7);
            column2.AddAttribute (comboCell, "text", 8);
            column2.AddAttribute (comboCell, "editable", 9);
            column2.AddAttribute (comboCell, "visible", 10);
            column1.AddAttribute (idCell, "text", 11);
            column2.AddAttribute (editTextCell2, "text", 12);
            column2.AddAttribute (editTextCell2, "visible", 13);
            column2.AddAttribute (editTextCell3, "text", 14);
            column2.AddAttribute (editTextCell4, "text", 15);
            column2.AddAttribute (editTextCell4, "visible", 16);
            column2.AddAttribute (editFilePathCell, "text", 17);
            column2.AddAttribute (editFilePathCell, "visible", 18);

            listStore = new TreeStore (typeof (string), typeof(bool), typeof (string), typeof(bool), typeof (string), typeof(bool), typeof(bool), typeof(TreeStore), typeof(string), typeof(bool), typeof(bool), typeof(string), typeof(string), typeof(bool), typeof(string), typeof(string), typeof(bool), typeof(string), typeof(bool));
            treeview1.Model = listStore;
        }
Пример #51
0
        protected virtual void OnExportbuttonClicked(object sender, System.EventArgs e)
        {
            FileChooserDialog fChooser = new FileChooserDialog(Catalog.GetString("Save Project"),
                            (Gtk.Window)Toplevel,
                            FileChooserAction.Save,
                            "gtk-cancel",ResponseType.Cancel,
                            "gtk-save",ResponseType.Accept);
            fChooser.SetCurrentFolder(Config.HomeDir);
            FileFilter filter = new FileFilter();
            filter.Name = Constants.PROJECT_NAME;
            filter.AddPattern(Constants.PROJECT_EXT);

            fChooser.AddFilter(filter);
            if(fChooser.Run() == (int)ResponseType.Accept) {
                Project.Export(projectdetails.GetProject(), fChooser.Filename);
            }
            fChooser.Destroy();
        }
Пример #52
0
        /// <summary>
        /// Generate report file
        /// </summary>
        private void SaveReport()
        {
            if (tabContainer.NPages < 1)
            {
                // If there isn't any selected tab, exit
                return;
            }

            string selectedFile = "";

            Gtk.FileChooserDialog FileBox =
                new Gtk.FileChooserDialog(GlobalData.GetLanguageKeyValue("FILESAVE"),
                                          MainWindow,
                                          FileChooserAction.Save,
                                          GlobalData.GetLanguageKeyValue("BTNCANCEL"),
                                          Gtk.ResponseType.Cancel,
                                          GlobalData.GetLanguageKeyValue("BTNSAVE"),
                                          Gtk.ResponseType.Accept);

            FileBox.WindowPosition= WindowPosition.CenterOnParent;
            FileFilter filter = new FileFilter();
            filter.AddPattern("*.report");
            filter.Name = "Report file (*.report)";
            FileBox.AddFilter(filter);

            // Manage result of dialog box
            FileBox.Icon = Gdk.Pixbuf.LoadFromResource("themonospot.png");
            FileBox.SetCurrentFolder(GlobalData.bFactory.DefaultPath);
            int retFileBox = FileBox.Run();
            if ((ResponseType)retFileBox == Gtk.ResponseType.Accept)
            {
                    // path of a right file returned
                    selectedFile = FileBox.Filename.ToString();
                    FileBox.Destroy();
                    FileBox.Dispose();

            }
            else
            {
                    // nothing returned
                    FileBox.Destroy();
                    FileBox.Dispose();
                    return;
            }

            // generate report
            GlobalData.bFactory
                .SaveReportFile(fiEntity[tabContainer.Page].Video,
                                fiEntity[tabContainer.Page].Audio,
                                fiEntity[tabContainer.Page].FileName,
                                selectedFile,
                                fiEntity[tabContainer.Page].PluginUsed);

            // Message of report generated
            MessageDialog dlg = new MessageDialog(MainWindow,
                                                  DialogFlags.Modal,
                                                  MessageType.Info,
                                                  ButtonsType.Ok,
                                                  GlobalData.GetLanguageKeyValue("SAVEREPORTMSG") + "\r\n" +
                                                  fiEntity[tabContainer.Page].FileName);
            dlg.Title = GlobalData.GetLanguageKeyValue("SAVEREPORTWIN");
            dlg.Run();
            dlg.Destroy();
            return;
        }
Пример #53
0
        /// <summary>
        /// Try to open all file contained in a specific
        /// folder (optional also in her subfolders)
        /// </summary>
        private void OpenFolder(bool recursive)
        {
            string selectedFolder = "";

            Gtk.FileChooserDialog FileBox =
                new Gtk.FileChooserDialog(GlobalData.GetLanguageKeyValue("FOLDEROPEN"),
                                          MainWindow,
                                          FileChooserAction.SelectFolder,
                                          GlobalData.GetLanguageKeyValue("BTNCANCEL"),
                                          Gtk.ResponseType.Cancel,
                                          GlobalData.GetLanguageKeyValue("BTNOPEN"),
                                          Gtk.ResponseType.Accept);

            FileBox.WindowPosition= WindowPosition.CenterOnParent;

            // Manage result of dialog box
            FileBox.Icon = Gdk.Pixbuf.LoadFromResource("themonospot.png");
            FileBox.SetCurrentFolder(GlobalData.bFactory.DefaultPath);
            int retFileBox = FileBox.Run();
            if ((ResponseType)retFileBox == Gtk.ResponseType.Accept)
            {
                    // path of a right file returned
                    selectedFolder = FileBox.Filename.ToString();
                    FileBox.Destroy();
                    FileBox.Dispose();

            }
            else
            {
                    // nothing returned
                    FileBox.Destroy();
                    FileBox.Dispose();
                    return;
            }

            if (selectedFolder == "")
            {
                return;
            }

            // Recall other constructor
            OpenFolder(selectedFolder, recursive);
        }
Пример #54
0
        private void OpenFile()
        {
            string selectedFile = "";

            Gtk.FileChooserDialog FileBox =
                new Gtk.FileChooserDialog(GlobalData.GetLanguageKeyValue("FILEOPEN"),
                                          MainWindow,
                                          FileChooserAction.Open,
                                          GlobalData.GetLanguageKeyValue("BTNCANCEL"),
                                          Gtk.ResponseType.Cancel,
                                          GlobalData.GetLanguageKeyValue("BTNOPEN"),
                                          Gtk.ResponseType.Accept);

            FileBox.WindowPosition= WindowPosition.CenterOnParent;
            FileFilter filter = new FileFilter();
            filter.Name = GlobalData.FileDialogExtensions;
            string[] managedExt = GlobalData.bFactory.GetManagedExtentions();

            for (int j=0; j<managedExt.Length; j++)
            {
                filter.AddPattern("*." + managedExt[j]);
            }

            FileBox.AddFilter(filter);

            // Manage result of dialog box
            FileBox.Icon = Gdk.Pixbuf.LoadFromResource("themonospot.png");
            FileBox.SetCurrentFolder(GlobalData.bFactory.DefaultPath);
            int retFileBox = FileBox.Run();
            if ((ResponseType)retFileBox == Gtk.ResponseType.Accept)
            {
                    // path of a right file returned
                    selectedFile = FileBox.Filename.ToString();
                    FileBox.Destroy();
                    FileBox.Dispose();

            }
            else
            {
                    // nothing returned
                    FileBox.Destroy();
                    FileBox.Dispose();
                    return;
            }

            if (selectedFile == "")
            {
                return;
            }

            // recall other constructor
            OpenFile(selectedFile);
        }
Пример #55
0
        protected virtual void OnSavebuttonClicked(object sender, System.EventArgs e)
        {
            string filename;
            FileChooserDialog fChooser;
            FileFilter filter = new FileFilter();
            filter.Name = "PNG Images";
            filter.AddPattern("*.png");

            fChooser = new FileChooserDialog(Catalog.GetString("Save File as..."),
                                             (Gtk.Window)this.Toplevel,
                                             FileChooserAction.Save,
                                             "gtk-cancel",ResponseType.Cancel,
                                             "gtk-save",ResponseType.Accept);
            fChooser.SetCurrentFolder(Config.SnapshotsDir());
            fChooser.Filter = filter;
            fChooser.DoOverwriteConfirmation = true;

            if(fChooser.Run() == (int)ResponseType.Accept) {
                filename = fChooser.Filename;
                if(System.IO.Path.GetExtension(filename) != "png")
                    filename += ".png";
                drawingwidget1.SaveAll(filename);
            }
            fChooser.Destroy();
        }
Пример #56
0
    private void AddKeyframe()
    {
        try
        {
            if (PPfileOpened)
            {
                FileChooserDialog fc = new FileChooserDialog("Open PP3", this, FileChooserAction.Open, "Cancel", ResponseType.Cancel, "Open", ResponseType.Accept);
                if (Directory.Exists(MySettings.LastPPDir)) { fc.SetCurrentFolder(MySettings.LastPPDir); }

                FileFilter filter = new FileFilter();
                filter.Name = "Postprocessing Profile";
                filter.AddPattern("*.pp3");
                fc.AddFilter(filter);

                if (fc.Run() == (int)ResponseType.Accept)
                {
                    TreeIter iter;
                    table.GetIter(out iter, ValueTable.Selection.GetSelectedRows()[0]);
                    int index = table.GetPath(iter).Indices[0];
                    string name = System.IO.Path.GetFileName(fc.Filename);
                    MySettings.LastPPDir = System.IO.Path.GetDirectoryName(fc.Filename);
                    MySettings.Save();

                    AllFiles[index].PP3 = new PP3Values(fc.Filename);
                    AllFiles[index].IsKeyframe = true;
                    UpdateTable();

                    int c = 0;
                    if (BrightnessCalculated){ c = 1;}
                    GCurves.GCurve tmp;
                    CurveSelectBox.Model.GetIterFirst(out iter);
                    List<double> values = AllFiles[index].PP3.GetAllInterpolateValues();

                    for (int i = 0; i < CurveSelectBox.Model.IterNChildren() - c; i++)
                    {
                        if (c == 1 && i == 0) { CurveSelectBox.Model.IterNext(ref iter); }
                        AllCurves.Curves.TryGetValue((string)CurveSelectBox.Model.GetValue(iter, 0), out tmp);
                        CurveSelectBox.Model.IterNext(ref iter);
                        tmp.AddPoint(index, (float)values[i], true);
                    }

                    UpdateInfo(InfoType.Keyframe, 0);
                }
                fc.Destroy();
            }
            else { UpdateInfo(InfoType.PPFile, 0); }
        }
        catch (Exception ex) { ReportError("Open Keyframe", ex); }
    }
Пример #57
0
    private void OpenDarkframe(TableChangeType type)
    {
        try
        {
            FileChooserDialog fc = new FileChooserDialog("Open Darkframe", this, FileChooserAction.Open, "Cancel", ResponseType.Cancel, "Open", ResponseType.Accept);

            #region Add FileFilter

            FileFilter filter = new FileFilter();
            filter.Name = "Images";
            filter.AddPattern("*.jpg");
            filter.AddPattern("*.jpeg");
            filter.AddPattern("*.CR2");
            filter.AddPattern("*.CRW");
            filter.AddPattern("*.png");
            filter.AddPattern("*.tif");
            filter.AddPattern("*.tiff");
            filter.AddPattern("*.DNG");
            filter.AddPattern("*.NEF");
            filter.AddPattern("*.x3f");
            filter.AddPattern("*.srw");
            filter.AddPattern("*.srf");
            filter.AddPattern("*.sr2");
            filter.AddPattern("*.arw");
            filter.AddPattern("*.erf");
            filter.AddPattern("*.pef");
            filter.AddPattern("*.raf");
            filter.AddPattern("*.3fr");
            filter.AddPattern("*.fff");
            filter.AddPattern("*.dcr");
            filter.AddPattern("*.dcs");
            filter.AddPattern("*.kdc");
            filter.AddPattern("*.rwl");
            filter.AddPattern("*.mrw");
            filter.AddPattern("*.mdc");
            filter.AddPattern("*.nrw");
            filter.AddPattern("*.orf");
            filter.AddPattern("*.rw2");
            fc.AddFilter(filter);
            filter = new FileFilter();
            filter.Name = "All Files";
            filter.AddPattern("*.*");
            fc.AddFilter(filter);

            #endregion

            if (Directory.Exists(MySettings.LastFilterDir)) { fc.SetCurrentFolder(MySettings.LastFilterDir); }

            if (fc.Run() == (int)ResponseType.Accept)
            {
                TreeIter iter;
                table.GetIter(out iter, ValueTable.Selection.GetSelectedRows()[0]);
                int index = table.GetPath(iter).Indices[0];
                string name = System.IO.Path.GetFileName(fc.Filename);
                MySettings.LastFilterDir = System.IO.Path.GetDirectoryName(fc.Filename);
                MySettings.Save();

                switch (type)
                {
                    case TableChangeType.Single:
                        AllFiles[index].PP3.RAW.DarkFrame = fc.Filename;
                        break;
                    case TableChangeType.TillEnd:
                        for (int i = index; i < AllFiles.Count; i++) { AllFiles[index].PP3.RAW.DarkFrame = fc.Filename; }
                        break;
                    case TableChangeType.TillNext:
                        for (int i = index; i < AllFiles.Count; i++)
                        {
                            if (!String.IsNullOrEmpty(AllFiles[index].PP3.RAW.DarkFrame)) { AllFiles[index].PP3.RAW.DarkFrame = fc.Filename; }
                            else { break; }
                        }
                        break;
                }
                UpdateTable();
                UpdateInfo(InfoType.Darkframe, 0);
            }
            fc.Destroy();
        }
        catch (Exception ex) { ReportError("Open Darkframe", ex); }
    }
Пример #58
0
    private void OpenFilter(TableChangeType type)
    {
        try
        {
            FileChooserDialog fc = new FileChooserDialog("Open Filterset", this, FileChooserAction.Open, "Cancel", ResponseType.Cancel, "Open", ResponseType.Accept);

            FileFilter filter = new FileFilter();
            filter.Name = "DeSERt Filterset";
            filter.AddMimeType("Filterset/fis");
            filter.AddPattern("*.fis");
            fc.AddFilter(filter);
            if (Directory.Exists(MySettings.LastFilterDir)) { fc.SetCurrentFolder(MySettings.LastFilterDir); }

            if (fc.Run() == (int)ResponseType.Accept)
            {
                TreeIter iter;
                table.GetIter(out iter, ValueTable.Selection.GetSelectedRows()[0]);
                int index = table.GetPath(iter).Indices[0];
                string name = System.IO.Path.GetFileName(fc.Filename);
                MySettings.LastFilterDir = System.IO.Path.GetDirectoryName(fc.Filename);
                MySettings.Save();

                Filterset CurFilter;
                switch (type)
                {
                    case TableChangeType.Single:
                        AllFiles[index].Filter = Filterset.OpenFilterset(fc.Filename);
                        break;
                    case TableChangeType.TillEnd:
                        CurFilter = Filterset.OpenFilterset(fc.Filename);
                        for (int i = index; i < AllFiles.Count; i++) { AllFiles[index].Filter = CurFilter; }
                        break;
                    case TableChangeType.TillNext:
                        CurFilter = Filterset.OpenFilterset(fc.Filename);
                        for (int i = index; i < AllFiles.Count; i++)
                        {
                            if (AllFiles[index].Filter == null) { AllFiles[index].Filter = CurFilter; }
                            else { break; }
                        }
                        break;
                }
                UpdateTable();
                UpdateInfo(InfoType.Filterset, 0);
            }
            fc.Destroy();
        }
        catch (Exception ex) { ReportError("Open Filterset", ex); }
    }
Пример #59
0
    private void StartOpenProjectWorker()
    {
        if (AskForSaving() != ResponseType.Cancel)
        {
            FileChooserDialog fc = new FileChooserDialog("Open Project", this, FileChooserAction.Open, "Cancel", ResponseType.Cancel, "Open", ResponseType.Accept);

            FileFilter filter = new FileFilter();
            filter.Name = "DeSERt Project";
            filter.AddMimeType("Project/depro");
            filter.AddPattern("*.depro");
            fc.AddFilter(filter);
            if (Directory.Exists(MySettings.LastProjDir)) { fc.SetCurrentFolder(MySettings.LastProjDir); }

            if (fc.Run() == (int)ResponseType.Accept)
            {
                ResetProject();
                ProjectSavePath = fc.Filename;
                UpdateInfo(InfoType.Opening, 0);
                MySettings.LastProjDir = System.IO.Path.GetDirectoryName(fc.Filename);
                MySettings.Save();
                OpenBackground.RunWorkerAsync();
            }
            fc.Destroy();
        }
    }
Пример #60
0
    private void StartSaveProjectWorker(bool askForPath)
    {
        ResponseType res = ResponseType.None;

        if (ProjectSaved) { return; }
        else if (!askForPath && !String.IsNullOrEmpty(ProjectSavePath)) { res = ResponseType.Accept; }
        else
        {
            FileChooserDialog fc = new FileChooserDialog("Save Project", this, FileChooserAction.Save, "Cancel", ResponseType.Cancel, "Save", ResponseType.Accept);

            FileFilter filter = new FileFilter();
            filter.Name = "DeSERt Project";
            filter.AddMimeType("Project/depro");
            filter.AddPattern("*.depro");
            fc.AddFilter(filter);
            if (Directory.Exists(MySettings.LastProjDir)) { fc.SetCurrentFolder(MySettings.LastProjDir); }
            fc.DoOverwriteConfirmation = true;
            res = (ResponseType)fc.Run();
            if (!System.IO.Path.HasExtension(fc.Filename)) { ProjectSavePath = fc.Filename + ".depro"; }
            else { ProjectSavePath = fc.Filename; }
            fc.Destroy();
        }

        if (res == ResponseType.Accept)
        {
            MySettings.LastProjDir = System.IO.Path.GetDirectoryName(ProjectSavePath);
            MySettings.Save();
            UpdateInfo(InfoType.Saving, 0);
            SaveBackground.RunWorkerAsync();
        }
    }