コード例 #1
0
        public static byte[] GetTemplateFromDisk()
        {
            //Читаем файл документа
            FileChooserDialog Chooser = new FileChooserDialog ("Выберите шаблон документа...",
                null,
                FileChooserAction.Open,
                "Отмена", ResponseType.Cancel,
                "Выбрать", ResponseType.Accept);
            FileFilter Filter = new FileFilter ();
            Filter.Name = "ODT документы и OTT шаблоны";
            Filter.AddMimeType ("application/vnd.oasis.opendocument.text");
            Filter.AddMimeType ("application/vnd.oasis.opendocument.text-template");
            Filter.AddPattern ("*.odt");
            Filter.AddPattern ("*.ott");
            Chooser.AddFilter (Filter);

            Filter = new FileFilter ();
            Filter.Name = "Все файлы";
            Filter.AddPattern ("*.*");
            Chooser.AddFilter (Filter);

            byte[] file = null;

            if ((ResponseType)Chooser.Run () == ResponseType.Accept) {
                Chooser.Hide ();
                logger.Info ("Чтение файла...");

                file = File.ReadAllBytes(Chooser.Filename);

                logger.Info ("Ok");
            }
            Chooser.Destroy ();

            return file;
        }
コード例 #2
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 ();
        }
コード例 #3
0
 private static void AddFilters(FileChooserDialog dialog) 
 {
     // Add experiment files filter
     FileFilter fileFilter = new FileFilter();
     fileFilter.AddPattern("*.teml");
     fileFilter.Name = Mono.Unix.Catalog.GetString("Experiment files (.teml)");
     dialog.AddFilter(fileFilter);
     
     //add another option of All files
     FileFilter allFilesFilter = new FileFilter();
     allFilesFilter.Name = Mono.Unix.Catalog.GetString("All files");
     allFilesFilter.AddPattern("*.*");
     dialog.AddFilter(allFilesFilter);
 }
コード例 #4
0
ファイル: ImportZipProjectAction.cs プロジェクト: moscrif/ide
        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();
        }
コード例 #5
0
ファイル: GtkFileDialog.cs プロジェクト: ivynetca/lapsestudio
        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;
        }
コード例 #6
0
        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); }
        }
コード例 #7
0
        protected void OnTargetNMMLFileButtonClicked(object sender, System.EventArgs e)
        {
            Gtk.FileChooserDialog fc =
                new Gtk.FileChooserDialog ("Target NMML file", this.Toplevel as Gtk.Window, FileChooserAction.Open,
                    "Cancel", ResponseType.Cancel,
                    "Select", ResponseType.Accept);

            Gtk.FileFilter filter = new Gtk.FileFilter ();
            filter.Name = "NMML files";
            filter.AddPattern ("*.nmml");
            fc.AddFilter (filter);

            if (mProject.TargetNMMLFile != "")
            {
                fc.SetFilename (mProject.TargetNMMLFile);
            }
            else
            {
                fc.SetFilename (mProject.BaseDirectory);
            }

            if (fc.Run () == (int)ResponseType.Accept)
            {
                string path = PathHelper.ToRelativePath (fc.Filename, mProject.BaseDirectory);

                TargetNMMLFileEntry.Text = path;
            }

            fc.Destroy ();
        }
コード例 #8
0
ファイル: Main.cs プロジェクト: torvall/pixclip-linux
        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");
        }
コード例 #9
0
ファイル: FileDialogs.cs プロジェクト: CoEST/TraceLab
        /// <summary>
        /// Adds the filters. Returns default extension
        /// </summary>
        /// <returns>The filters.</returns>
        /// <param name="dialog">Dialog.</param>
        private static string AddFilters(FileChooserDialog dialog) 
        {
            string defaultExtension = "teml";
            string cryptedFileExtension = "temlx";
            // Add experiment files filter
            FileFilter fileFilter = new FileFilter();
            fileFilter.AddPattern(string.Format("*.{0}", defaultExtension));
            fileFilter.Name = Mono.Unix.Catalog.GetString(string.Format("Experiment files (.{0})", defaultExtension));
            dialog.AddFilter(fileFilter);

            // Add experiment files filter
            //TLAB-67
        //here: we check if the file is crypted, if it's so we ask the user to insert a password. then we decrypt the file and check the 
            /// password. if the pwd is the same we contninue with the standard process, otherwise we raise and error
            FileFilter fileFilterCryptedFile = new FileFilter();
            fileFilterCryptedFile.AddPattern(string.Format("*.{0}", cryptedFileExtension));
            fileFilterCryptedFile.Name = Mono.Unix.Catalog.GetString(string.Format("Experiment files (.{0})", cryptedFileExtension));
            dialog.AddFilter(fileFilterCryptedFile);
            
            //add another option of All files
            FileFilter allFilesFilter = new FileFilter();
            allFilesFilter.Name = Mono.Unix.Catalog.GetString("All files");
            allFilesFilter.AddPattern("*.*");
            dialog.AddFilter(allFilesFilter);

            return defaultExtension;
        }
コード例 #10
0
        protected void OnButtonLoadPhotoClicked(object sender, EventArgs e)
        {
            FileChooserDialog Chooser = new FileChooserDialog ("Выберите фото для загрузки...",
                (Window)this.Toplevel,
                FileChooserAction.Open,
                "Отмена", ResponseType.Cancel,
                "Загрузить", ResponseType.Accept);

            FileFilter Filter = new FileFilter ();
            Filter.AddPixbufFormats ();
            Filter.Name = "Все изображения";
            Chooser.AddFilter (Filter);

            if ((ResponseType)Chooser.Run () == ResponseType.Accept) {
                Chooser.Hide ();
                logger.Info ("Загрузка фотографии...");

                FileStream fs = new FileStream (Chooser.Filename, FileMode.Open, FileAccess.Read);
                if (Chooser.Filename.ToLower ().EndsWith (".jpg")) {
                    using (MemoryStream ms = new MemoryStream ()) {
                        fs.CopyTo (ms);
                        ImageFile = ms.ToArray ();
                    }
                } else {
                    logger.Info ("Конвертация в jpg ...");
                    Gdk.Pixbuf image = new Gdk.Pixbuf (fs);
                    ImageFile = image.SaveToBuffer ("jpeg");
                }
                fs.Close ();
                buttonSavePhoto.Sensitive = true;
                logger.Info ("Ok");
            }
            Chooser.Destroy ();
        }
コード例 #11
0
ファイル: OpenWorkspaceAction.cs プロジェクト: moscrif/ide
        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();
        }
コード例 #12
0
ファイル: ArchiveProjectAction.cs プロジェクト: moscrif/ide
        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();
        }
コード例 #13
0
    void OnExportAsXDFActionActivated(object sender, EventArgs e)
    {
        SelectedChoice choice;
        var            responseType = DisplaySelectDataDialog(out choice);

        if (responseType == ResponseType.Cancel)
        {
            return;
        }

        string pathSuggested = ScoobyRom.Data.PathWithNewExtension(data.Rom.Path, ".xdf");
        var    fc            = new Gtk.FileChooserDialog("Export as TunerPro XDF file", this,
                                                         FileChooserAction.Save, Gtk.Stock.Cancel, ResponseType.Cancel, Gtk.Stock.Save, ResponseType.Accept);

        try {
            FileFilter filter = new FileFilter();
            filter.Name = "XDF files";
            filter.AddPattern("*.xdf");
            fc.AddFilter(filter);

            filter      = new FileFilter();
            filter.Name = "All files";
            filter.AddPattern("*");
            fc.AddFilter(filter);

            fc.DoOverwriteConfirmation = true;
            fc.SetFilename(pathSuggested);
            fc.CurrentName = System.IO.Path.GetFileName(pathSuggested);

            if (fc.Run() == (int)ResponseType.Accept)
            {
                data.SaveAsTunerProXdf(fc.Filename, choice);
            }
        } catch (Exception ex) {
            ErrorMsg("Error writing file", ex.Message);
        } finally {
            if (fc != null)
            {
                fc.Destroy();
            }
        }
    }
コード例 #14
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);
        }
コード例 #15
0
ファイル: FileDialog.cs プロジェクト: pulb/basenji
        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;
        }
コード例 #16
0
        public bool SaveFileDialog(SaveFileDialogParams saveParams, Action <SaveFileDialogParams> callback)
        {
            WinformsSystemWindow.ShowingSystemDialog = true;
            Gtk.Application.Init();

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

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

            //Set default filename and add file extension
            fc.CurrentName = saveParams.FileName + extensions[0].TrimStart('*');
            if (saveParams.InitialDirectory != null)
            {
                fc.SetCurrentFolder(saveParams.InitialDirectory);
            }

            fc.KeepAbove = true;

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

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

            WinformsSystemWindow.ShowingSystemDialog = false;

            return(true);
        }
コード例 #17
0
 private void OpenFileFromMenu(object sender, EventArgs a)
 {
     Gtk.FileChooserDialog dialog = new Gtk.FileChooserDialog("Open File", null, FileChooserAction.Open, "Open", Gtk.ResponseType.Accept, "Cancel", Gtk.ResponseType.Cancel);
     dialog.SelectMultiple = true;
     Gtk.FileFilter filter = new Gtk.FileFilter();
     filter.Name = "ogg File";
     filter.AddPattern("*.ogg");
     dialog.AddFilter(filter);
     if (dialog.Run() == (int)ResponseType.Accept)
     {
         AddSongs(dialog.Filenames);
     }
     dialog.Destroy();
 }
コード例 #18
0
        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);
        }
コード例 #19
0
    protected void OnOpenActionActivated(object sender, EventArgs e)
    {
        var od = new Gtk.FileChooserDialog(null, "Open Session", this, FileChooserAction.Open, "Cancel", ResponseType.Cancel, "Open", ResponseType.Accept);

        foreach (var filter in GetFileFilters())
        {
            od.AddFilter(filter);
        }

        if (od.Run() == (int)ResponseType.Accept)
        {
            OpenSession(od.Filename);
        }
        od.Destroy();
    }
コード例 #20
0
        protected void OnTargetNMMLFileButtonClicked(object sender, System.EventArgs e)
        {
            Gtk.FileChooserDialog fc =
                new Gtk.FileChooserDialog("Target NMML file", this.Toplevel as Gtk.Window, FileChooserAction.Open,
                                          "Cancel", ResponseType.Cancel,
                                          "Select", ResponseType.Accept);

            Gtk.FileFilter filterNMML = new Gtk.FileFilter();
            filterNMML.Name = "NMML Files";
            filterNMML.AddPattern("*.nmml");

            Gtk.FileFilter filterAll = new Gtk.FileFilter();
            filterAll.Name = "All Files";
            filterAll.AddPattern("*");

            fc.AddFilter(filterNMML);
            fc.AddFilter(filterAll);

            if (mProject.TargetNMMLFile != "")
            {
                fc.SetFilename(mProject.TargetNMMLFile);
            }
            else
            {
                fc.SetFilename(mProject.BaseDirectory);
            }

            if (fc.Run() == (int)ResponseType.Accept)
            {
                string path = PathHelper.ToRelativePath(fc.Filename, mProject.BaseDirectory);

                TargetNMMLFileEntry.Text = path;
            }

            fc.Destroy();
        }
コード例 #21
0
ファイル: MainWindow.cs プロジェクト: ertseyhan/Steg
    /// <summary>
    /// Raises the button browse extract ımage file clicked event.
    /// </summary>
    protected void OnBtnBrowseExtractImageFileClicked(object sender, EventArgs e)
    {
        var imageChooser = new Gtk.FileChooserDialog("Choose the image file",
            this,
            FileChooserAction.Open,
            "Cancel", ResponseType.Cancel,
            "Open", ResponseType.Accept);

        imageChooser.AddFilter(GetImageFilters());

        if (imageChooser.Run() == (int)ResponseType.Accept) {
            txtImageFileExtract.Text = imageChooser.Filename;
        }

        imageChooser.Destroy();
    }
コード例 #22
0
ファイル: MovieEditor.cs プロジェクト: revenz/iMeta
 void BrowseForNewPoster()
 {
     using (Gtk.FileChooserDialog fc = new Gtk.FileChooserDialog("Choose a new Poster.",
                                                                 this,
                                                                 FileChooserAction.Open,
                                                                 "Cancel", ResponseType.Cancel,
                                                                 "Open", ResponseType.Accept))
     {
         fc.LocalOnly = false;
         FileFilter filter = new FileFilter();
         filter.Name = "Images";
         filter.AddMimeType("image/png");
         filter.AddMimeType("image/jpeg");
         filter.AddMimeType("image/gif");
         filter.AddPattern("*.png");
         filter.AddPattern("*.jpg");
         filter.AddPattern("*.jpeg");
         filter.AddPattern("*.jpe");
         filter.AddPattern("*.gif");
         filter.AddPattern("*.tbn");
         fc.AddFilter(filter);
         if (fc.Run() == (int)ResponseType.Accept)
         {
             try
             {
                 // get the new poster
                 string newposter = new System.IO.FileInfo(fc.Filename).FullName;
                 using (System.Drawing.Image poster = System.Drawing.Image.FromFile(newposter))
                 {
                     iMetaLibrary.Helpers.ImageHelper.SavePoster(poster, Meta.PosterFilename);
                     if (Poster != null)
                     {
                         Poster.Dispose();
                     }
                     Poster = GuiHelper.ImageToPixbuf(poster);
                     ExposeIt();
                 }
             }
             catch (Exception ex)
             {
                 MessageBox.Show(ex.Message);
             }
         }
         //Don't forget to call Destroy() or the FileChooserDialog window won't get closed.
         fc.Destroy();
     }
 }
コード例 #23
0
    protected void OnFloppyActionActivated(object sender, EventArgs e)
    {
        Gtk.FileChooserDialog fc = new Gtk.FileChooserDialog("Save File",this,FileChooserAction.Save,Gtk.Stock.Cancel,ResponseType.Cancel,Gtk.Stock.Open,ResponseType.Accept);
        Gtk.FileFilter filter = new Gtk.FileFilter();
        filter.AddPattern("Images|*.png;*.bmp;*.jpg");
        fc.AddFilter(filter);
        /*sfd.Filter = "Images|*.png;*.bmp;*.jpg";
        ImageFormat format = ImageFormat.Png;
        if (sfd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
        {
            fileManager.save(sfd.FileName.Substring(0, sfd.FileName.IndexOf('.')), map, manager, getHeight());
            backgroundMap.Image.Save(sfd.FileName, format);
        }*/
        if(fc.Run()==(int)ResponseType.Accept){

        }
    }
コード例 #24
0
        /// <summary>
        /// Choose file to save contacts.
        /// </summary>
        private string ChooseFileToSave(string dialogTitle)
        {
            string fileToSave = "";

            // New dialog to save sim contacts on file
            Gtk.FileChooserDialog FileBox = new Gtk.FileChooserDialog(dialogTitle,
                                                                      MainWindow,
                                                                      FileChooserAction.Save,
                                                                      GlobalObjUI.LMan.GetString("cancellbl"), Gtk.ResponseType.Cancel,
                                                                      GlobalObjUI.LMan.GetString("savelbl"), Gtk.ResponseType.Accept);

            // Filter for using only monosim files
            Gtk.FileFilter myFilter = new Gtk.FileFilter();
            myFilter.AddPattern("*.monosim");
            myFilter.Name = "monosim files";
            FileBox.AddFilter(myFilter);

            // Manage result of dialog box
            FileBox.Icon = Gdk.Pixbuf.LoadFromResource("monosim.png");
            int retFileBox = FileBox.Run();

            if ((ResponseType)retFileBox == Gtk.ResponseType.Accept)
            {
                // path of a right file returned
                fileToSave = FileBox.Filename;

                string chkfile = fileToSave.PadLeft(9).ToLower();
                if (chkfile.Substring(chkfile.Length - 8) != ".monosim")
                {
                    fileToSave += ".monosim";
                }

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

            return(fileToSave);
        }
コード例 #25
0
        /// <summary>
        /// Open command file
        /// </summary>
        private void OpenCommandFile()
        {
            // New dialog for select command file
            Gtk.FileChooserDialog FileBox =
                new Gtk.FileChooserDialog(GlobalObj.LMan.GetString("selectfile"),
                                          MainWindow,
                                          FileChooserAction.Open,
                                          GlobalObj.LMan.GetString("cancellbl"),
                                          Gtk.ResponseType.Cancel,
                                          GlobalObj.LMan.GetString("openlbl"),
                                          Gtk.ResponseType.Accept);

            // Filter to use only comex files
            Gtk.FileFilter myFilter = new Gtk.FileFilter();
            myFilter.AddPattern("*.comex");
            myFilter.Name = "comex project files (*.comex)";
            FileBox.AddFilter(myFilter);

            // Manage result of dialog box
            FileBox.Icon = Gdk.Pixbuf.LoadFromResource("comex_256.png");
            int retFileBox = FileBox.Run();

            if ((ResponseType)retFileBox == Gtk.ResponseType.Accept)
            {
                // path of a right file returned
                commandFilePath = FileBox.Filename;
                commandFileName = System.IO.Path.GetFileNameWithoutExtension(commandFilePath);
                log.Debug("file selected: " + commandFilePath);

                UpdateGuiForCommandFile();



                FileBox.Destroy();
                FileBox.Dispose();
            }
            else
            {
                // nothing returned
                FileBox.Destroy();
                FileBox.Dispose();
                return;
            }
        }
コード例 #26
0
        protected virtual void OnOpenActionActivated(object sender, System.EventArgs e)
        {
            Gtk.FileChooserDialog fc = new Gtk.FileChooserDialog("Choose the Monoreports file to open", ((Gtk.Window) this.Toplevel), FileChooserAction.Open, "Cancel", ResponseType.Cancel, "Open", ResponseType.Accept);
            var fileFilter           = new FileFilter {
                Name = "Monoreports project"
            };

            fileFilter.AddPattern("*.mrp");
            fc.AddFilter(fileFilter);

            if (fc.Run() == (int)ResponseType.Accept)
            {
                ShowInPropertyGrid(null);
                designService.Load(fc.Filename);
            }

            fc.Destroy();
            workspaceService.InvalidateDesignArea();
        }
コード例 #27
0
ファイル: FileDialogHelper.cs プロジェクト: Jodan-pz/spoolpad
 public static string OpenFile( string title, params string[] extensions )
 {
     FileChooserDialog fd = new FileChooserDialog(title, null, FileChooserAction.Open, Gtk.Stock.Cancel, ResponseType.Cancel, Gtk.Stock.Open, ResponseType.Accept);
     foreach (string ext in extensions) {
         string[] filter = ext.Split('|');
         FileFilter temp = new FileFilter();
         temp.Name = filter[0];
         temp.AddPattern("*." + filter[1]);
         fd.AddFilter(temp);
     }
     try {
         if (fd.Run() == (int)ResponseType.Accept) {
             return fd.Filename;
         }
     } finally {
         fd.Destroy();
     }
     return null;
 }
コード例 #28
0
        protected void OnAddFileClicked(object sender, System.EventArgs e)
        {
            var filter = new FileFilter();

            filter.Name = "CSV files";
            filter.AddPattern("*.csv");
            filter.AddPattern("*.txt");
            filter.AddPattern("*.*");
            var fc = new Gtk.FileChooserDialog("Select File(s) to Import", null, FileChooserAction.Open, "Cancel", ResponseType.Cancel, "Open", ResponseType.Accept);

            fc.SelectMultiple = true;
            fc.AddFilter(filter);

            if (fc.Run() == (int)ResponseType.Accept)
            {
                Console.WriteLine(fc.Filenames);
            }
            fc.Destroy();
        }
コード例 #29
0
ファイル: TextureWidget.cs プロジェクト: xyzzys/Psiga
        protected void importPNG_Clicked(object sender, EventArgs e)
        {
            if (Atlas != null)
            {
                return;
            }
            Gtk.Window window   = null;
            Widget     toplevel = Toplevel;

            if (toplevel.IsTopLevel)
            {
                window = toplevel as Gtk.Window;
            }
            Gtk.FileChooserDialog fileChooser =
                new Gtk.FileChooserDialog("Save PNG",
                                          window,
                                          FileChooserAction.Open,
                                          "Cancel", ResponseType.Cancel,
                                          "Open", ResponseType.Accept);
            var filter = new FileFilter();

            filter.Name = "PNG Image (*.png)";
            filter.AddPattern("*.png");
            fileChooser.AddFilter(filter);
            if (fileChooser.Run() == (int)ResponseType.Accept)
            {
                var file   = (Bitmap)Bitmap.FromFile(fileChooser.Filename);
                var locked = file.LockBits(
                    new System.Drawing.Rectangle(0, 0, file.Width, file.Height),
                    System.Drawing.Imaging.ImageLockMode.ReadOnly,
                    System.Drawing.Imaging.PixelFormat.Format32bppArgb);
                byte[] newData = new byte[file.Width * file.Height * 4];
                Marshal.Copy(locked.Scan0, newData, 0, newData.Length);
                file.UnlockBits(locked);
                Texture.BGRAtoRGBA(newData);
                viewing.Texture.SetRgbaData(newData);
                TextureCache.Flush(viewing);
                decompressed = null;
                LoadTextureAsync();
            }

            fileChooser.Destroy();
        }
コード例 #30
0
        protected virtual void OnSaveActionActivated(object sender, System.EventArgs e)
        {
            Gtk.FileChooserDialog fc = new Gtk.FileChooserDialog("Choose Monoreports file to save", ((Gtk.Window) this.Toplevel), FileChooserAction.Save, "Cancel", ResponseType.Cancel, "Save", ResponseType.Accept);
            var fileFilter           = new FileFilter {
                Name = "Monoreports project"
            };

            fileFilter.AddPattern("*.mrp");
            fc.AddFilter(fileFilter);
            fc.CurrentName = "untiteled.mrp";

            designService.Report.DataSource = null;
            if (fc.Run() == (int)ResponseType.Accept)
            {
                designService.Save(fc.Filename);
            }

            fc.Destroy();
        }
コード例 #31
0
ファイル: MainWindow.cs プロジェクト: jasemagee/FontWhiz
    protected void OnGenerateButtonReleased(object sender, EventArgs e)
    {
        var fileChooserDialog = new FileChooserDialog (
            "Select a PNG", this,
            FileChooserAction.Save,
             "Cancel", ResponseType.Cancel,
            "Save", ResponseType.Accept);

        var fileFilter = new FileFilter ();
        fileFilter.Name = "png";
        fileFilter.AddMimeType ("image/png");
        fileFilter.AddPattern ("*.png");

        fileChooserDialog.AddFilter (fileFilter);

        if (fileChooserDialog.Run () == (int)ResponseType.Accept) {
            string filename = fileChooserDialog.Filename;
            bool continueSave = true;

            if (System.IO.Path.GetExtension (filename) != ".png")
                filename = System.IO.Path.ChangeExtension (filename, "png");

            if (File.Exists (filename)) {
                var messageDialog = new MessageDialog (this,
                                                      DialogFlags.Modal,
                                                      MessageType.Question,
                                                      ButtonsType.OkCancel,
                                                      "{0} already exists. Overwrite?",
                                                       filename);

                if (messageDialog.Run () != (int)ResponseType.Ok)
                    continueSave = false;

                messageDialog.Destroy ();
            }

            if (continueSave)
                File.Copy (previewimage.File, filename, true);
        }

        fileChooserDialog.Destroy ();
    }
コード例 #32
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);

            foreach (var format in PintaCore.System.PaletteFormats.Formats)
            {
                if (!format.IsReadOnly())
                {
                    FileFilter fileFilter = format.Filter;
                    fcd.AddFilter(fileFilter);
                }
            }

            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)
            {
                var format = PintaCore.System.PaletteFormats.Formats.FirstOrDefault(f => f.Filter == fcd.Filter);

                string finalFileName = fcd.Filename;

                string extension = System.IO.Path.GetExtension(fcd.Filename);

                if (string.IsNullOrEmpty(extension))
                {
                    finalFileName += "." + format.Extensions.First();
                }

                PintaCore.Palette.CurrentPalette.Save(finalFileName, format.Saver);
            }

            fcd.Destroy();
        }
コード例 #33
0
    protected void OnSaveAsActionActivated(object sender, EventArgs e)
    {
        var od = new Gtk.FileChooserDialog(null, "Save Session", this, FileChooserAction.Save, "Cancel", ResponseType.Cancel, "Save", ResponseType.Accept);

        foreach (var filter in GetFileFilters())
        {
            od.AddFilter(filter);
        }

        if (od.Run() == (int)ResponseType.Accept)
        {
            SessionFileName = od.Filename;
            if (string.IsNullOrEmpty(System.IO.Path.GetExtension(SessionFileName)))
            {
                SessionFileName += ".gpz";
            }
            SaveSession();
        }
        od.Destroy();
    }
コード例 #34
0
    public void OnOpenActivate(object o, EventArgs args)
    {
        string filename = null;

        //FileSelection openFileDialog = new FileSelection ("Open File");
        Gtk.FileFilter txtFileFilter = new Gtk.FileFilter();
        txtFileFilter.AddPattern("*.txt");
        txtFileFilter.Name = "Plain Text";
        Gtk.FileChooserDialog openFileDialog = new Gtk.FileChooserDialog("Open file", mindFire, FileChooserAction.Open, Stock.Cancel, ResponseType.Cancel, Stock.Open, ResponseType.Ok);
        //openFileDialog.Complete ("*.txt");
        //openFileDialog.HideFileopButtons ();
        openFileDialog.AddFilter(txtFileFilter);
        openFileDialog.Run();
        filename = openFileDialog.Filename;
        if (File.Exists(filename))
        {
            // Check mimetype
            OpenFile(filename);
        }
        openFileDialog.Destroy();
    }
コード例 #35
0
 private void OnImageSelectButtonClicked(object sender, EventArgs args)
 {
     FileChooserDialog fileChooser = new FileChooserDialog (
         "Choose an image file to open",
         this,
         FileChooserAction.Open,
         "Cancel", ResponseType.Cancel,
         "Open", ResponseType.Accept);
     var filter = new FileFilter ();
     filter.Name = "Images";
     filter.AddMimeType ("image/*");
     fileChooser.AddFilter (filter);
     if (fileChooser.Run() == (int)ResponseType.Accept)
     {
         _model.ImageUri = new Uri (fileChooser.Filename);
         RenderBaseImagePreview ();
         RenderKaleidoscope ();
     }
     fileChooser.Destroy();
     filter.Destroy ();
 }
コード例 #36
0
ファイル: Helpers.cs プロジェクト: dineshkummarc/longomatch
        public static Pixbuf OpenImage(Gtk.Window toplevel)
        {
            Pixbuf pimage = null;
            StreamReader file;
            FileChooserDialog fChooser;

            fChooser = new FileChooserDialog(Catalog.GetString("Choose an image"),
                                             toplevel, FileChooserAction.Open,
                                             "gtk-cancel",ResponseType.Cancel,
                                             "gtk-open",ResponseType.Accept);
            fChooser.AddFilter(GetFileFilter());
            if(fChooser.Run() == (int)ResponseType.Accept)	{
                // For Win32 compatibility we need to open the image file
                // using a StreamReader. Gdk.Pixbuf(string filePath) uses GLib to open the
                // input file and doesn't support Win32 files path encoding
                file = new StreamReader(fChooser.Filename);
                pimage= new Gdk.Pixbuf(file.BaseStream);
                file.Close();
            }
            fChooser.Destroy();
            return pimage;
        }
コード例 #37
0
ファイル: MainWindow.cs プロジェクト: Drenn1/zoragen-gtk
        private void SaveAsFile()
        {
            GetControlValues();
            Gtk.FileChooserDialog fc =
                new Gtk.FileChooserDialog("Choose the file to save",
                                          this,
                                          FileChooserAction.Save,
                                          "Cancel", ResponseType.Cancel,
                                          "Save", ResponseType.Accept);
            var filter = new FileFilter();

            filter.Name = "Zora Files";
            filter.AddPattern("*.zora");
            fc.AddFilter(filter);

            if (fc.Run() == (int)ResponseType.Accept)
            {
                _info.Write(fc.Filename);
                _currentFile = fc.Filename;
            }
            //Don't forget to call Destroy() or the FileChooserDialog window won't get closed.
            fc.Destroy();
        }
コード例 #38
0
ファイル: FileDialogHelper.cs プロジェクト: Jodan-pz/spoolpad
 public static string SaveFile( string title, string fileName, params string[] extensions )
 {
     string extension = Path.GetExtension(fileName);
     FileChooserDialog fd = new FileChooserDialog(title, null, FileChooserAction.Save, Gtk.Stock.Cancel, ResponseType.Cancel, Gtk.Stock.Save, ResponseType.Accept);
     fd.CurrentName = fileName;
     foreach (string ext in extensions) {
         string[] filter = ext.Split('|');
         FileFilter temp = new FileFilter();
         temp.Name = filter[0];
         temp.AddPattern("*." + filter[1]);
         fd.AddFilter(temp);
     }
     try {
         if (fd.Run() == (int)ResponseType.Accept) {
             if (!fd.Filename.EndsWith(extension))
                 return fd.Filename + "." + extension;
             return fd.Filename;
         }
     } finally {
         fd.Destroy();
     }
     return null;
 }
コード例 #39
0
ファイル: MainController.cs プロジェクト: snorp/vmx-manager
        public void OnAddExisting(object o, EventArgs args)
        {
            FileChooserDialog dialog = new FileChooserDialog (Catalog.GetString ("Choose a virtual machine file"),
                                                              window,
                                                              FileChooserAction.Open, Stock.Cancel,
                                                              ResponseType.Cancel, Stock.Open, ResponseType.Ok);

            dialog.LocalOnly = true;

            FileFilter filter = new FileFilter ();
            filter.Name = Catalog.GetString ("Virtual Machines");
            filter.AddPattern ("*.vmx");

            dialog.AddFilter (filter);
            ResponseType result = (ResponseType) dialog.Run ();
            if (result == ResponseType.Ok) {
                foreach (string file in dialog.Filenames) {
                    manager.AddMachine (new VirtualMachine (file));
                }
            }

            dialog.Destroy ();
        }
コード例 #40
0
        public void LoadPlugin(ProxyFrame proxy)
        {
            if (proxy == null)
            {
                return;
            }

            var od = new Gtk.FileChooserDialog(null, "Load Plugin", null, FileChooserAction.Open, "Cancel", ResponseType.Cancel, "Open", ResponseType.Accept);

            foreach (var filter in GetFileFilters())
            {
                od.AddFilter(filter);
            }

            if (od.Run() == (int)ResponseType.Accept)
            {
                PluginInfo plugin = new PluginInfo();
                plugin.Path = od.Filename;
                bool found = false;
                Store.Foreach((model, path, iter) =>
                {
                    var item = model.GetValue(iter, 0) as PluginInfo;
                    if (null != item && item.Path == plugin.Path)
                    {
                        return(found = true);
                    }

                    return(false);
                });

                if (!found && LoadAssembly(plugin, proxy))
                {
                    Store.AppendValues(plugin);
                }
            }
            od.Destroy();
        }
コード例 #41
0
ファイル: OpenWorkspaceAction.cs プロジェクト: anthrax3/ide-1
        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();
        }
コード例 #42
0
		protected void ApplyFilter(FileChooserDialog dlg)
		{
			if (string.IsNullOrEmpty(Filter))
				return;

			var parts = Filter.Split('|');
			if (parts.Length % 2 != 0)
				return;

			ResetFilter(dlg);

			for (int i = 0; i < parts.Length - 1; i += 2)
			{
				var filter = new FileFilter();
				filter.Name = parts[i];
				var patterns = parts[i + 1].Split(';');
				foreach (var pattern in patterns)
					filter.AddPattern(pattern.Trim());
				dlg.AddFilter(filter);
			}

			if (FilterIndex > 0 && FilterIndex <= dlg.Filters.Length)
				dlg.Filter = dlg.Filters[FilterIndex - 1];
		}
コード例 #43
0
        protected virtual void OnInstallClicked(object sender, System.EventArgs e)
        {
            GLib.File             file           = null;
            Gtk.FileChooserDialog script_chooser = new Gtk.FileChooserDialog("Helpers", this, FileChooserAction.Open, Gtk.Stock.Cancel, ResponseType.Cancel, Catalog.GetString("_Select"), ResponseType.Ok);
            FileFilter            filter         = new FileFilter();

            filter.AddPattern("*.tar");
            filter.Name = Catalog.GetString(".tar Archives");
            script_chooser.AddFilter(filter);

            if ((ResponseType)script_chooser.Run() == ResponseType.Ok)
            {
                file = GLib.FileFactory.NewForPath(script_chooser.Filename);
            }

            script_chooser.Destroy();

            if (file == null)
            {
                return;
            }

            DockServices.Helpers.InstallHelper(file.Path);
        }
コード例 #44
0
    //Function shows the custom dialog based on provided action description
    string ShowCustomDialog(FileChooserAction fca, string action)
    {
        var temporarydialog = new Gtk.FileChooserDialog("", this, fca, "Cancel", ResponseType.Cancel, action, ResponseType.Accept);

        temporarydialog.SetCurrentFolder(@".");
        //Only *.pro files are supposed to be supported
        var filefilter = new FileFilter();

        filefilter.Name = "Project Files (*.pro)";
        filefilter.AddPattern("*.pro");
        temporarydialog.AddFilter(filefilter);
        //Returns empty string on cancellation, filename otherwise.
        string export = string.Empty;

        if (temporarydialog.Run() == (int)ResponseType.Accept)
        {
            export = temporarydialog.Filename;
            //Check if extension is presented, enforce its presence
            string export_ext = System.IO.Path.GetExtension(export);
            export += export_ext == ".pro" ? string.Empty : ".pro";
        }
        temporarydialog.Destroy();
        return(export);
    }
コード例 #45
0
ファイル: MainWindow.cs プロジェクト: Blizz9/FanCut
    protected void OnOpenActionActivated(object sender, EventArgs e)
    {
        FileChooserDialog openD = new FileChooserDialog("Open file",
                                      this, FileChooserAction.Open,
                                      Stock.Cancel, ResponseType.Cancel,
                                      Stock.Open, ResponseType.Accept);
        FileFilter filter = new FileFilter();
        filter.Name = "INES rom (*.nes)";
        filter.AddMimeType("Ines");
        filter.AddPattern("*.nes");
        openD.AddFilter(filter);

        openD.SetFilename(MyNesGTK.Settings.LastUsedFile);
        if (openD.Run() == (int)ResponseType.Accept)
        {
            MyNesGTK.Settings.LastUsedFile = openD.Filename;
            LoadRom(openD.Filename);
        }
        openD.Destroy();
    }
コード例 #46
0
ファイル: MainWindow.cs プロジェクト: ertseyhan/Steg
    /// <summary>
    /// Raises the button browse text file clicked event.
    /// </summary>
    protected void OnBtnBrowseTextFileClicked(object sender, EventArgs e)
    {
        var _filterText = new FileFilter();
        _filterText.Name = "Text Files";
        _filterText.AddPattern("*.txt");

        var textChooser = new Gtk.FileChooserDialog("Choose the text file",
            this,
            FileChooserAction.Open,
            "Cancel", ResponseType.Cancel,
            "Open", ResponseType.Accept);

        textChooser.AddFilter(_filterText);
        if (textChooser.Run() == (int)ResponseType.Accept) {
            txtTextFilePathEmbed.Text = textChooser.Filename;
        }

        textChooser.Destroy();
    }
コード例 #47
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();
        }
コード例 #48
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;
        }
コード例 #49
0
        protected void OnPdfActionActivated(object sender, System.EventArgs e)
        {
            // *********************************
            object[] param = new object[4];
            param[0] = "Cancel";
            param[1] = Gtk.ResponseType.Cancel;
            param[2] = "Save";
            param[3] = Gtk.ResponseType.Accept;

            Gtk.FileChooserDialog fc =
                new Gtk.FileChooserDialog("Save File As",
                                          null,
                                          Gtk.FileChooserAction.Save,
                                          param);

            fc.CurrentName = DefaultExportFileName ?? report.Name;

            Gtk.FileFilter pdfFilter = new Gtk.FileFilter();
            pdfFilter.Name = "PDF";

            Gtk.FileFilter csvFilter = new Gtk.FileFilter();
            csvFilter.Name = "CSV";

            Gtk.FileFilter asphtmlFilter = new Gtk.FileFilter();
            asphtmlFilter.Name = "ASP HTML";

            Gtk.FileFilter excel2007 = new Gtk.FileFilter();
            excel2007.Name = "Excel 2007";

            Gtk.FileFilter htmlFilter = new Gtk.FileFilter();
            htmlFilter.Name = "HTML";

            Gtk.FileFilter mhtmlFilter = new Gtk.FileFilter();
            mhtmlFilter.Name = "MHTML";

            Gtk.FileFilter rtfFilter = new Gtk.FileFilter();
            rtfFilter.Name = "RTF";

            Gtk.FileFilter xmlFilter = new Gtk.FileFilter();
            xmlFilter.Name = "XML";

            fc.AddFilter(pdfFilter);
            fc.AddFilter(csvFilter);
            fc.AddFilter(asphtmlFilter);
            fc.AddFilter(excel2007);
            fc.AddFilter(htmlFilter);
            fc.AddFilter(mhtmlFilter);
            fc.AddFilter(xmlFilter);

            if (fc.Run() == (int)Gtk.ResponseType.Accept)
            {
                try
                {
                    // Must use the RunGetData before each export or there is no data.
                    report.RunGetData(this.Parameters);

                    string filename = fc.Filename;
                    OutputPresentationType exportType = OutputPresentationType.PDF;
                    if (fc.Filter.Name == "CSV")
                    {
                        exportType = OutputPresentationType.CSV;
                        if (filename.ToLower().Trim().EndsWith(".csv") == false)
                        {
                            filename = filename + ".csv";
                        }
                    }
                    else if (fc.Filter.Name == "PDF")
                    {
                        exportType = OutputPresentationType.PDF;
                        if (filename.ToLower().Trim().EndsWith(".pdf") == false)
                        {
                            filename = filename + ".pdf";
                        }
                    }
                    else if (fc.Filter.Name == "ASP HTML")
                    {
                        exportType = OutputPresentationType.ASPHTML;
                        if (filename.ToLower().Trim().EndsWith(".asphtml") == false)
                        {
                            filename = filename + ".asphtml";
                        }
                    }
                    else if (fc.Filter.Name == "Excel 2007")
                    {
                        exportType = OutputPresentationType.Excel;
                        if (filename.ToLower().Trim().EndsWith(".xlsx") == false)
                        {
                            filename = filename + ".xlsx";
                        }
                    }
                    else if (fc.Filter.Name == "HTML")
                    {
                        exportType = OutputPresentationType.HTML;
                        if (filename.ToLower().Trim().EndsWith(".html") == false)
                        {
                            filename = filename + ".html";
                        }
                    }
                    else if (fc.Filter.Name == "MHTML")
                    {
                        exportType = OutputPresentationType.MHTML;
                        if (filename.ToLower().Trim().EndsWith(".mhtml") == false)
                        {
                            filename = filename + ".mhtml";
                        }
                    }
                    else if (fc.Filter.Name == "XML")
                    {
                        exportType = OutputPresentationType.XML;
                        if (filename.ToLower().Trim().EndsWith(".xml") == false)
                        {
                            filename = filename + ".xml";
                        }
                    }

                    ExportReport(report, filename, exportType);
                }
                catch (Exception ex)
                {
                    Gtk.MessageDialog m = new Gtk.MessageDialog(null, Gtk.DialogFlags.Modal, Gtk.MessageType.Info,
                                                                Gtk.ButtonsType.Ok, false,
                                                                "Error Saving Copy of PDF." + System.Environment.NewLine + ex.Message);

                    m.Run();
                    m.Destroy();
                }
            }
            //Don't forget to call Destroy() or the FileChooserDialog window won't get closed.
            fc.Destroy();
        }
コード例 #50
0
        private void OnProjectMenuOpenItem(
			object sender,
			EventArgs e)
        {
            // We need an open file dialog box and use that to select the project.
            var dialog = new FileChooserDialog(
                "Open Author Intrusion Project",
                this,
                FileChooserAction.Open,
                "Cancel",
                ResponseType.Cancel,
                "Open",
                ResponseType.Accept);

            // Set up the filter on the dialog.
            var filter = new FileFilter
            {
                Name = "Project Files"
            };
            filter.AddMimeType("binary/x-author-intrusion");
            filter.AddPattern("*.aiproj");
            dialog.AddFilter(filter);

            // Show the dialog and process the results.
            try
            {
                // Show the dialog and get the button the user selected.
                int results = dialog.Run();

                // If the user accepted a file, then use that to open the file.
                if (results != (int) ResponseType.Accept)
                {
                    return;
                }

                // Get the project file and load it.
                var file = new FileInfo(dialog.Filename);

                if (!file.Exists)
                {
                    return;
                }

                // Open the project.
                OpenProject(file);
            }
            finally
            {
                // Destroy the dialog the box.
                dialog.Destroy();
            }
        }
コード例 #51
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);
        }
コード例 #52
0
ファイル: ReportViewer.cs プロジェクト: dukus/My-FyiReporting
        protected void OnPdfActionActivated(object sender, System.EventArgs e)
        {
            // *********************************
            object[] param = new object[4];
            param[0] = Strings.ButtonCancel_Text;
            param[1] = Gtk.ResponseType.Cancel;
            param[2] = Strings.ButtonSave_Text;
            param[3] = Gtk.ResponseType.Accept;

            Gtk.FileChooserDialog fc =
                new Gtk.FileChooserDialog(Strings.FileChooser_SaveFileTo_Title,
                                          null,
                                          Gtk.FileChooserAction.Save,
                                          param);

            fc.CurrentName = DefaultExportFileName ?? report.Name;

            if (!restrictedOutputPresentationTypes.Contains(OutputPresentationType.PDF))
            {
                Gtk.FileFilter pdfFilter = new Gtk.FileFilter {
                    Name = "PDF"
                };
                var extensionPDF = ".pdf";
                pdfFilter.AddPattern($"*{extensionPDF}");
                fc.AddFilter(pdfFilter);
            }

            if (!restrictedOutputPresentationTypes.Contains(OutputPresentationType.CSV))
            {
                Gtk.FileFilter csvFilter = new Gtk.FileFilter {
                    Name = "CSV"
                };
                var extensionCSV = ".csv";
                csvFilter.AddPattern($"*{extensionCSV}");
                fc.AddFilter(csvFilter);
            }

            if (!restrictedOutputPresentationTypes.Contains(OutputPresentationType.ExcelTableOnly))
            {
                Gtk.FileFilter excel2007Data = new Gtk.FileFilter {
                    Name = "Excel no formatting (Fast)"
                };
                var extensionXLSX = ".xlsx";
                excel2007Data.AddPattern($"*{extensionXLSX}");
                fc.AddFilter(excel2007Data);
            }

            if (!restrictedOutputPresentationTypes.Contains(OutputPresentationType.Excel2007))
            {
                Gtk.FileFilter excel2007 = new Gtk.FileFilter {
                    Name = "Excel with formatting (Slow)"
                };
                var extensionXLSX = ".xlsx";
                excel2007.AddPattern($"*{extensionXLSX}");
                fc.AddFilter(excel2007);
            }

            if (!restrictedOutputPresentationTypes.Contains(OutputPresentationType.TIF))
            {
                Gtk.FileFilter tiffFilter = new Gtk.FileFilter {
                    Name = "TIFF"
                };
                var extensionTIFF = ".tiff";
                tiffFilter.AddPattern($"*{extensionTIFF}");
                fc.AddFilter(tiffFilter);
            }

            if (!restrictedOutputPresentationTypes.Contains(OutputPresentationType.ASPHTML))
            {
                Gtk.FileFilter asphtmlFilter = new Gtk.FileFilter {
                    Name = "ASP HTML"
                };
                var extensionASPHTML = ".asphtml";
                asphtmlFilter.AddPattern($"*{extensionASPHTML}");
                fc.AddFilter(asphtmlFilter);
            }

            if (!restrictedOutputPresentationTypes.Contains(OutputPresentationType.HTML))
            {
                Gtk.FileFilter htmlFilter = new Gtk.FileFilter {
                    Name = "HTML"
                };
                var extensionHTML = ".html";
                htmlFilter.AddPattern($"*{extensionHTML}");
                fc.AddFilter(htmlFilter);
            }

            if (!restrictedOutputPresentationTypes.Contains(OutputPresentationType.MHTML))
            {
                Gtk.FileFilter mhtmlFilter = new Gtk.FileFilter {
                    Name = "MHTML"
                };
                var extensionMHTML = ".mhtml";
                mhtmlFilter.AddPattern($"*{extensionMHTML}");
                fc.AddFilter(mhtmlFilter);
            }

            if (!restrictedOutputPresentationTypes.Contains(OutputPresentationType.XML))
            {
                Gtk.FileFilter xmlFilter = new Gtk.FileFilter {
                    Name = "XML"
                };
                var extensionXML = ".xml";
                xmlFilter.AddPattern($"*{extensionXML}");
                fc.AddFilter(xmlFilter);
            }

            if (!fc.Filters.Any())
            {
                Gtk.MessageDialog m = new Gtk.MessageDialog(null, Gtk.DialogFlags.Modal, Gtk.MessageType.Info,
                                                            Gtk.ButtonsType.Ok, false,
                                                            "Export in all document formats is prohibited");

                m.WindowPosition = WindowPosition.Center;
                m.Run();
                m.Destroy();
                return;
            }

            if (fc.Run() == (int)Gtk.ResponseType.Accept)
            {
                try
                {
                    string searchPattern = "*";

                    string filename = fc.Filename;
                    OutputPresentationType exportType = OutputPresentationType.PDF;
                    if (fc.Filter.Name == "CSV")
                    {
                        exportType = OutputPresentationType.CSV;
                        if (filename.ToLower().Trim().EndsWith(".csv") == false)
                        {
                            filename      = filename + ".csv";
                            searchPattern = "*.csv";
                        }
                    }
                    else if (fc.Filter.Name == "PDF")
                    {
                        exportType = OutputPresentationType.PDF;
                        if (filename.ToLower().Trim().EndsWith(".pdf") == false)
                        {
                            filename      = filename + ".pdf";
                            searchPattern = "*.pdf";
                        }
                    }
                    else if (fc.Filter.Name == "Excel 2007 Data")
                    {
                        exportType = OutputPresentationType.ExcelTableOnly;
                        if (filename.ToLower().Trim().EndsWith(".xlsx") == false)
                        {
                            filename      = filename + ".xlsx";
                            searchPattern = "*.xlsx";
                        }
                    }
                    else if (fc.Filter.Name == "Excel 2007")
                    {
                        exportType = OutputPresentationType.Excel2007;
                        if (filename.ToLower().Trim().EndsWith(".xlsx") == false)
                        {
                            filename      = filename + ".xlsx";
                            searchPattern = "*.xlsx";
                        }
                    }
                    else if (fc.Filter.Name == "TIFF")
                    {
                        exportType = OutputPresentationType.TIF;
                        if (filename.ToLower().Trim().EndsWith(".tif") == false)
                        {
                            filename      = filename + ".tif";
                            searchPattern = "*.tif";
                        }
                    }
                    else if (fc.Filter.Name == "ASP HTML")
                    {
                        exportType = OutputPresentationType.ASPHTML;
                        if (filename.ToLower().Trim().EndsWith(".asphtml") == false)
                        {
                            filename      = filename + ".asphtml";
                            searchPattern = "*.asphtml";
                        }
                    }
                    else if (fc.Filter.Name == "HTML")
                    {
                        exportType = OutputPresentationType.HTML;
                        if (filename.ToLower().Trim().EndsWith(".html") == false)
                        {
                            filename      = filename + ".html";
                            searchPattern = "*.html";
                        }
                    }
                    else if (fc.Filter.Name == "MHTML")
                    {
                        exportType = OutputPresentationType.MHTML;
                        if (filename.ToLower().Trim().EndsWith(".mhtml") == false)
                        {
                            filename      = filename + ".mhtml";
                            searchPattern = "*.mhtml";
                        }
                    }
                    else if (fc.Filter.Name == "XML")
                    {
                        exportType = OutputPresentationType.XML;
                        if (filename.ToLower().Trim().EndsWith(".xml") == false)
                        {
                            filename      = filename + ".xml";
                            searchPattern = "*.xml";
                        }
                    }


                    string directory = filename.Remove(filename.LastIndexOf(@"\") + 1);

                    var files = Directory.GetFiles(directory, searchPattern);

                    //Check for files with same name in directory
                    if (files.Any())
                    {
                        for (int i = 0; i < files.Length; i++)
                        {
                            if (files[i] == filename)
                            {
                                //If found files with the same name in directory
                                MessageDialog m = new Gtk.MessageDialog(null, DialogFlags.Modal, MessageType.Question,
                                                                        Gtk.ButtonsType.YesNo, false,
                                                                        Strings.SaveToFile_CheckIf_SameFilesInDir);

                                m.SetPosition(WindowPosition.Center);
                                ResponseType result = (ResponseType)m.Run();
                                m.Destroy();
                                if (result == ResponseType.Yes)
                                {
                                    // Must use the RunGetData before each export or there is no data.
                                    report.RunGetData(this.Parameters);
                                    ExportReport(report, filename, exportType);
                                    break;
                                }
                                else
                                {
                                    break;
                                }
                            }

                            if (i + 1 == files.Length && files[i] != filename)
                            {
                                //If no files with the same name found in directory
                                // Must use the RunGetData before each export or there is no data.
                                report.RunGetData(this.Parameters);
                                ExportReport(report, filename, exportType);
                                break;
                            }
                        }
                    }
                    else
                    {
                        //If no files found in directory
                        // Must use the RunGetData before each export or there is no data.
                        report.RunGetData(this.Parameters);
                        ExportReport(report, filename, exportType);
                    }
                }
                catch (Exception ex)
                {
                    Gtk.MessageDialog m = new Gtk.MessageDialog(null, Gtk.DialogFlags.Modal, Gtk.MessageType.Info,
                                                                Gtk.ButtonsType.Ok, false,
                                                                "Error Saving Copy of PDF." + System.Environment.NewLine + ex.Message);

                    m.Run();
                    m.Destroy();
                }
            }
            //Don't forget to call Destroy() or the FileChooserDialog window won't get closed.
            fc.Destroy();
        }
コード例 #53
0
    private Application(Options opts)
    {
        selection = new TileSelection();

        Glade.XML.CustomHandler = GladeCustomWidgetHandler;
        Glade.XML gxml = new Glade.XML("editor.glade", "MainWindow");
        gxml.Autoconnect(this);

        if (MainWindow == null)
        {
            throw new Exception("Couldn't resolve all widgets");
        }

        ((GameObjectListWidget)ToolGObjectsProps).SetGtkFrame(fGObjects);

        Tileset.LoadEditorImages = true;

        // Initialize status bar for PrintStatus()
        printStatusContextID = sbMain.GetContextId("PrintStatus");
        printStatusMessageID = sbMain.Push(printStatusContextID, "Welcome to Supertux-Editor.");

        MainWindow.DeleteEvent += OnDelete;

        MainWindow.SetSizeRequest(900, 675);
        MainWindowTitlePrefix = MainWindow.Title;
        UpdateTitlebar();
        UpdateRecentDocuments();
        MainWindow.Icon = EditorStock.WindowIcon;
        //HACK: not a typo, EditorStock adds icons to the stock only when called 2x or more..
        MainWindow.Icon = EditorStock.WindowIcon;
        MainWindow.ShowAll();

        // Manually set icons for Tools, automatic stock initialization is broken on some systems
        ToolSelect.StockId       = EditorStock.ToolSelect;
        ToolTiles.StockId        = EditorStock.ToolTiles;
        ToolObjects.StockId      = EditorStock.ToolObjects;
        ToolBrush.StockId        = EditorStock.ToolBrush;
        ToolFill.StockId         = EditorStock.ToolFill;
        ToolReplace.StockId      = EditorStock.ToolReplace;
        ToolPath.StockId         = EditorStock.ToolPath;
        ToolButtonCamera.StockId = EditorStock.Camera;

        // Hide some extra widgets (because MainWindow.ShowAll(); showed them all)
        fGObjects.Visible = false;
        if (Settings.Instance.ToolboxOnRight)
        {
            aTools.Reparent(fToolsRight);
            fToolsLeft.Hide();
        }
        else
        {
            aTools.Reparent(fToolsLeft);
            fToolsRight.Hide();
        }


        // Tool "Select" is selected by default - call its event handler
        OnToolSelect(null, null);

        //Setup drag destination for "files"
        Gtk.Drag.DestSet(MainWindow, Gtk.DestDefaults.All, target_table,
                         Gdk.DragAction.Default |
                         Gdk.DragAction.Copy |
                         Gdk.DragAction.Move |
                         Gdk.DragAction.Link |
                         Gdk.DragAction.Private |
                         Gdk.DragAction.Ask);
        MainWindow.DragDataReceived += OnDragDataReceived;

        fileChooser = new Gtk.FileChooserDialog("Choose a Level", MainWindow, Gtk.FileChooserAction.Open, new object[] {});
        if (!Directory.Exists(Settings.Instance.LastDirectoryName))             //noexistent (or null) LastDirectoryName, resetting to default
        {
            if (Settings.Instance.SupertuxData != null)
            {
                Settings.Instance.LastDirectoryName = System.IO.Path.Combine(Settings.Instance.SupertuxData, "levels") + System.IO.Path.DirectorySeparatorChar;
            }
            else
            {
                Settings.Instance.LastDirectoryName = Environment.ExpandEnvironmentVariables("%HOME%");
            }
        }
        fileChooser.SetCurrentFolder(Settings.Instance.LastDirectoryName);
        fileChooser.AddButton(Gtk.Stock.Cancel, Gtk.ResponseType.Cancel);
        fileChooser.AddButton(Gtk.Stock.Ok, Gtk.ResponseType.Ok);
        fileChooser.DefaultResponse = Gtk.ResponseType.Ok;
        Gtk.FileFilter filter = new Gtk.FileFilter();
        filter.Name = "Supertux Levels and Worldmaps";
        filter.AddPattern("*.stl");
        filter.AddPattern("*.stwm");
        fileChooser.AddFilter(filter);
        Gtk.FileFilter levelfilter = new Gtk.FileFilter();
        levelfilter.Name = "Supertux Levels";
        levelfilter.AddPattern("*.stl");
        fileChooser.AddFilter(levelfilter);
        Gtk.FileFilter worldmapfilter = new Gtk.FileFilter();
        worldmapfilter.Name = "Supertux Worldmaps";
        worldmapfilter.AddPattern("*.stwm");
        fileChooser.AddFilter(worldmapfilter);
        Gtk.FileFilter brushfilter = new Gtk.FileFilter();
        brushfilter.Name = "Supertux-Editor Brushes";
        brushfilter.AddPattern("*.csv");
        fileChooser.AddFilter(brushfilter);
        Gtk.FileFilter all = new Gtk.FileFilter();
        all.Name = "All Files";
        all.AddPattern("*");
        fileChooser.AddFilter(all);
        if (Settings.Instance.SupertuxData != null)
        {
            try {
                fileChooser.AddShortcutFolder(System.IO.Path.Combine(Settings.Instance.SupertuxData, "levels"));
            } catch (Exception e) {
                LogManager.Log(LogLevel.Warning, "Couldn't add supertux level directory to File Chooser: " + e.Message);
            }
        }

        if (opts.FileNames.Count > 0)
        {
            Load(opts.FileNames[0]);
        }

        UndoManager.OnAddCommand += OnUndoManager;
        UndoManager.OnRedo       += OnUndoManager;
        UndoManager.OnUndo       += OnUndoManager;

        editorApplication = this;

        PrintStatus("Welcome to Supertux-Editor.");
    }
コード例 #54
0
        protected virtual void OnExporerTreeviewButtonPressEvent(object o, Gtk.ButtonPressEventArgs args)
        {
            TreePath path;

            exporerTreeview.GetPathAtPos((int)args.Event.X, (int)args.Event.Y, out path);
            if (path != null)
            {
                if (args.Event.Button == 3)
                {
                    Gtk.MenuItem addNewMenuItem = null;
                    if (path.Depth > 1)
                    {
                        int index = path.Indices [1];
                        if ((index == 2 || index == 1) && path.Depth == 2)
                        {
                            /*TODO 3tk - at the moment user added datafields are disabled
                             *  Gtk.Menu jBox = new Gtk.Menu ();
                             *  if (index == 1) {
                             *          addNewMenuItem = new MenuItem ("add field");
                             *
                             *  } else {
                             *          addNewMenuItem = new MenuItem ("add parameter");
                             *  }
                             *  jBox.Add (addNewMenuItem);
                             *
                             *  addNewMenuItem.Activated += delegate(object sender, EventArgs e) {
                             *          PropertyFieldEditor pfe = new PropertyFieldEditor ();
                             *          pfe.Response += delegate(object oo, ResponseArgs argss) {
                             *                  if (argss.ResponseId == ResponseType.Ok) {
                             *                          if (index == 1){
                             *                                  //DesignService.Report.Fields.Add (new PropertyDataField (){ Name = pfe.PropertyName});
                             *                                  updateTreeNode(dataFieldsNode,designService.Report.DataFields);
                             *
                             *                          }else {
                             *                                  //DesignService.Report.Parameters.Add (new PropertyDataField< (){ Name = pfe.PropertyName, DefaultValue = pfe.DefaultValue });
                             *                                  updateTreeNode(parametersNode,designService.Report.Parameters);
                             *                          }
                             *
                             *                          pfe.Destroy ();
                             *
                             *                  }else {
                             *                          pfe.Destroy ();
                             *                  }
                             *          };
                             *          pfe.Show ();
                             *  };
                             *
                             *  jBox.ShowAll ();
                             *  jBox.Popup ();
                             */
                        }
                        else if (index == 4 && path.Depth == 2)
                        {
                            Gtk.Menu jBox = new Gtk.Menu();

                            addNewMenuItem = new MenuItem("add image");
                            jBox.Add(addNewMenuItem);
                            addNewMenuItem.Activated += delegate(object sender, EventArgs e) {
                                Gtk.FileChooserDialog fc = new Gtk.FileChooserDialog("Choose the Monoreports file to open", null, FileChooserAction.Open, "Cancel", ResponseType.Cancel, "Open", ResponseType.Accept);
                                var fileFilter           = new FileFilter {
                                    Name = "Images"
                                };
                                fileFilter.AddPattern("*.jpg");
                                fileFilter.AddPattern("*.png");
                                fileFilter.AddPattern("*.gif");
                                fileFilter.AddPattern("*.JPG");
                                fileFilter.AddPattern("*.PNG");
                                fileFilter.AddPattern("*.GIF");
                                fc.AddFilter(fileFilter);

                                if (fc.Run() == (int)ResponseType.Accept)
                                {
                                    System.IO.FileStream file = System.IO.File.OpenRead(fc.Filename);

                                    byte[] bytes = new byte[file.Length];
                                    file.Read(bytes, 0, (int)file.Length);
                                    string fileName = System.IO.Path.GetFileName(fc.Filename);
                                    designService.Report.ResourceRepository.Add(fileName, bytes);
                                    designService.PixbufRepository.AddOrUpdatePixbufByName(fileName);
                                    file.Close();
                                }

                                fc.Destroy();
                                updateTreeNode(imagesNode, designService.Report.ResourceRepository);
                            };
                            jBox.ShowAll();
                            jBox.Popup();
                        }
                    }
                }
                else if (args.Event.Button == 1)
                {
                    if (path.Depth == 3)
                    {
                        int index = path.Indices [1];

                        if (index == 1)
                        {
                            Workspace.ShowInPropertyGrid(designService.Report.DataFields[path.Indices[2]]);
                        }
                        else if (index == 0)
                        {
                            Workspace.ShowInPropertyGrid(designService.Report.Parameters[path.Indices[2]]);
                        }
                    }
                }
            }
        }
コード例 #55
0
    protected void ReloadData(object sender, EventArgs e)
    {
        string result = null;

        Gtk.FileChooserDialog saveDialog = new Gtk.FileChooserDialog("Load File", null, Gtk.FileChooserAction.Open, "Cancel", Gtk.ResponseType.Cancel, "Load", Gtk.ResponseType.Accept);
        Gtk.FileFilter        fileFilter = new FileFilter();
        fileFilter.AddPattern("*.nirs");
        fileFilter.Name = ".nirs";
        saveDialog.AddFilter(fileFilter);
        Gtk.FileFilter fileFilter2 = new FileFilter();
        fileFilter.AddPattern("*.snirf");
        fileFilter.Name = ".snirf";
        saveDialog.AddFilter(fileFilter2);
        if (saveDialog.Run() == (int)Gtk.ResponseType.Accept)
        {
            result = saveDialog.Filename;

            if (nirsdata == null)
            {
                nirsdata = new List <nirs.core.Data>();
            }
            nirsdata.Clear();
            if (result.Contains(".nirs"))
            {
                nirsdata.Add(nirs.io.readDOTnirs(result));
            }
            else if (result.Contains(".snirf"))
            {
                nirs.core.Data[] datas = nirs.io.readSNIRF(result);
                nirsdata.Add(datas[0]);
            }
            for (int i = 0; i < nirsdata[0].probe.ChannelMap.Length; i++)
            {
                nirsdata[0].probe.ChannelMap[i].datasubtype = string.Format("raw {0}",
                                                                            nirsdata[0].probe.ChannelMap[i].datasubtype);
            }
            _handles.dataListStore.AppendValues(result, "Previously recorded file");

            Gtk.ListStore ClearList = new Gtk.ListStore(typeof(string));
            MainClass.win._handles.whichdata.Model = ClearList;

            List <string> datatypes = new List <string>();
            for (int ii = 0; ii < nirsdata[0].probe.ChannelMap.Length; ii++)
            {
                datatypes.Add(nirsdata[0].probe.ChannelMap[ii].datasubtype);
            }
            datatypes = datatypes.Distinct().ToList();

            foreach (string s in datatypes)
            {
                MainClass.win._handles.whichdata.AppendText(s);
            }

            MainClass.win._handles.whichdata.Active = 0;

            combobox_whichdata.Sensitive     = true;
            combobox_selectview.Sensitive    = true;
            checkbutton_autoscaleY.Sensitive = true;
            checkbutton_timeWindow.Sensitive = true;
            entry_timeWindow.Sensitive       = true;
            checkbuttonYmax.Sensitive        = true;
            checkbuttonYmin.Sensitive        = true;
            entryYmax.Sensitive = true;
            entryYmin.Sensitive = true;
        }

        saveDialog.Destroy();
        drawingarea_SDG.QueueDraw();
        drawingarea_Data.QueueDraw();
        drawingarea_SDG2.QueueDraw();
        drawingarea_Data2.QueueDraw();
    }
コード例 #56
0
ファイル: MainWindow.cs プロジェクト: Blizz9/FanCut
    protected void OnSaveActionActivated(object sender, EventArgs e)
    {
        if (gameInfoList == null)
        {
            Gtk.MessageDialog dialog = new Gtk.MessageDialog(this,
                                           Gtk.DialogFlags.DestroyWithParent,
                                           Gtk.MessageType.Error,
                                           Gtk.ButtonsType.Ok,
                                           "No info entry to save !!");

            dialog.Run();
            dialog.Destroy();
            return;
        }

        FileChooserDialog openD = new FileChooserDialog("Save text file",
                                      this, FileChooserAction.Save,
                                      Stock.Cancel, ResponseType.Cancel,
                                      Stock.Save, ResponseType.Accept);
        FileFilter filter = new FileFilter();
        filter.Name = "Text file (*.txt)";
        filter.AddMimeType("Text");
        filter.AddPattern("*.txt");
        openD.AddFilter(filter);
        openD.SetFilename(filechooserwidget2.Filename.Replace(".nes", ".txt"));
        if (openD.Run() == (int)ResponseType.Accept)
        {
            File.WriteAllLines(openD.Filename, gameInfoLines.ToArray(), System.Text.Encoding.UTF8);
            try
            {
                Process.Start(openD.Filename);
            }
            catch
            {
            }
        }
        openD.Destroy();
    }
コード例 #57
0
        public PeriodicTableUI(PeriodicTableLogic logic, PeriodicTableRenderer renderer)
        {
            Application.Init();
            aboutDialog = new AboutDialog();
            GladeXml dlg_main = new GladeXml(null, "main.glade", "mainWindow", null);

            dlg_main.Autoconnect(this);
            chunkSelect.Active = true;
            loader             = new Loader(logic, mainWindow);
            generate.Clicked  += new EventHandler(delegate(object sender, EventArgs e)
            {
                if (!string.IsNullOrEmpty(text.Buffer.Text))
                {
                    MemoryStream ms = new MemoryStream();
                    (loadedBitmap = renderer.Render(logic.Spell(text.Buffer.Text, chunkSelect.Active && !elementSearch.Active ? PeriodicTableLogic.SearchAlgorithm.ChunkSearch : PeriodicTableLogic.SearchAlgorithm.ElementBased))).Save(ms, ImageFormat.Png);
                    output.Clear();
                    ms.Position = 0;
                    using (Pixbuf oldPixbuf = output.Pixbuf)
                        output.Pixbuf = new Pixbuf(ms);
                }
                else
                {
                    MessageDialog md = new MessageDialog(mainWindow, DialogFlags.DestroyWithParent, MessageType.Error, ButtonsType.Close, "Please enter text into the conversion field");
                    md.Run();
                    md.Destroy();
                }
                UpdateSensitivity();
            });
            saveAs.Clicked += new EventHandler(delegate(object sender, EventArgs e)
            {
                FileChooserDialog fc = new Gtk.FileChooserDialog("Save As...", mainWindow, FileChooserAction.Save, "Cancel", ResponseType.Cancel, "Save", ResponseType.Accept)
                {
                    DoOverwriteConfirmation = true
                };
                FileFilter filter = new FileFilter();
                filter.Name       = "PNG images";
                filter.AddMimeType("image/png");
                filter.AddPattern("*.png");
                fc.AddFilter(filter);
                if (fc.Run() == (int)ResponseType.Accept)
                {
                    Stream file = File.Open(string.IsNullOrEmpty(Path.GetExtension(fc.Filename)) ? (fc.Filename + ".png") : fc.Filename, FileMode.OpenOrCreate);
                    loadedBitmap.Save(file, ImageFormat.Png);
                    file.Close();
                }
                fc.Destroy();
            });
            about.Clicked += new EventHandler(delegate(object sender, EventArgs e)
            {
                aboutDialog.Run();
            });
            mainWindow.DeleteEvent += new DeleteEventHandler(delegate(object sender, DeleteEventArgs e)
            {
                Application.Quit();
            });
            Assembly asm = Assembly.GetExecutingAssembly();

            aboutDialog.ProgramName = (asm.GetCustomAttributes(typeof(AssemblyTitleAttribute), false)[0] as AssemblyTitleAttribute).Title;
            aboutDialog.Version     = asm.GetName().Version.ToString();
            aboutDialog.Comments    = (asm.GetCustomAttributes(typeof(AssemblyDescriptionAttribute), false)[0] as AssemblyDescriptionAttribute).Description;
            aboutDialog.Copyright   = (asm.GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false)[0] as AssemblyCopyrightAttribute).Copyright;
            aboutDialog.License     = license;
            aboutDialog.Authors     = authors;
        }
コード例 #58
0
ファイル: ProjectsManager.cs プロジェクト: GNOME/longomatch
        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();
        }
コード例 #59
0
        protected virtual void OnPdfActionActivated(object sender, System.EventArgs e)
        {
            // *********************************
            object[] param = new object[4];
            param[0] = "Cancel";
            param[1] = Gtk.ResponseType.Cancel;
            param[2] = "Save";
            param[3] = Gtk.ResponseType.Accept;

            Gtk.FileChooserDialog fc =
                new Gtk.FileChooserDialog("Save File As",
                    null,
                    Gtk.FileChooserAction.Save,
                    param);

            Gtk.FileFilter pdfFilter = new Gtk.FileFilter();
            pdfFilter.Name = "PDF";

            Gtk.FileFilter csvFilter = new Gtk.FileFilter();
            csvFilter.Name = "CSV";

            Gtk.FileFilter asphtmlFilter = new Gtk.FileFilter();
            asphtmlFilter.Name = "ASP HTML";

            Gtk.FileFilter excel2003 = new Gtk.FileFilter();
            excel2003.Name = "Excel 2003";

            Gtk.FileFilter htmlFilter = new Gtk.FileFilter();
            htmlFilter.Name = "HTML";

            Gtk.FileFilter mhtmlFilter = new Gtk.FileFilter();
            mhtmlFilter.Name = "MHTML";

            Gtk.FileFilter rtfFilter = new Gtk.FileFilter();
            rtfFilter.Name = "RTF";

            Gtk.FileFilter xmlFilter = new Gtk.FileFilter();
            xmlFilter.Name = "XML";

            fc.AddFilter(pdfFilter);
            fc.AddFilter(csvFilter);
            fc.AddFilter(asphtmlFilter);
            fc.AddFilter(excel2003);
            fc.AddFilter(htmlFilter);
            fc.AddFilter(mhtmlFilter);
            fc.AddFilter(xmlFilter);

            if (fc.Run() == (int)Gtk.ResponseType.Accept)
            {
                try
                {
                    // Must use the RunGetData before each export or there is no data.
                    report.RunGetData(this.Parameters);

                    string filename = fc.Filename;
                    OutputPresentationType exportType = OutputPresentationType.PDF;
                    if (fc.Filter.Name == "CSV")
                    {
                        exportType = OutputPresentationType.CSV;
                        if (filename.ToLower().Trim().EndsWith(".csv") == false)
                        {
                            filename = filename + ".csv";
                        }
                    }
                    else if (fc.Filter.Name == "PDF")
                    {
                        exportType = OutputPresentationType.PDF;
                        if (filename.ToLower().Trim().EndsWith(".pdf") == false)
                        {
                            filename = filename + ".pdf";
                        }
                    }
                    else if (fc.Filter.Name == "ASP HTML")
                    {
                        exportType = OutputPresentationType.ASPHTML;
                        if (filename.ToLower().Trim().EndsWith(".asphtml") == false)
                        {
                            filename = filename + ".asphtml";
                        }
                    }
                    else if (fc.Filter.Name == "Excel 2003")
                    {
                        exportType = OutputPresentationType.Excel;
                        if (filename.ToLower().Trim().EndsWith(".xlsx") == false)
                        {
                            filename = filename + ".xlsx";
                        }
                    }
                    else if (fc.Filter.Name == "HTML")
                    {
                        exportType = OutputPresentationType.HTML;
                        if (filename.ToLower().Trim().EndsWith(".html") == false)
                        {
                            filename = filename + ".html";
                        }
                    }
                    else if (fc.Filter.Name == "MHTML")
                    {
                        exportType = OutputPresentationType.MHTML;
                        if (filename.ToLower().Trim().EndsWith(".mhtml") == false)
                        {
                            filename = filename + ".mhtml";
                        }
                    }
                    else if (fc.Filter.Name == "XML")
                    {
                        exportType = OutputPresentationType.XML;
                        if (filename.ToLower().Trim().EndsWith(".xml") == false)
                        {
                            filename = filename + ".xml";
                        }
                    }

                    ExportReport(report, filename, exportType);
                }
                catch (Exception ex)
                {
                    Gtk.MessageDialog m = new Gtk.MessageDialog(null, Gtk.DialogFlags.Modal, Gtk.MessageType.Info,
                               Gtk.ButtonsType.Ok, false,
                               "Error Saving Copy of PDF." + System.Environment.NewLine + ex.Message);

                    m.Run();
                    m.Destroy();
                }
            }
            //Don't forget to call Destroy() or the FileChooserDialog window won't get closed.
            fc.Destroy();
        }
コード例 #60
0
ファイル: TextureWidget.cs プロジェクト: xyzzys/Psiga
        protected void onExportPNG(object sender, EventArgs e)
        {
            Gtk.Window window   = null;
            Widget     toplevel = Toplevel;

            if (toplevel.IsTopLevel)
            {
                window = toplevel as Gtk.Window;
            }
            Gtk.FileChooserDialog fileChooser =
                new Gtk.FileChooserDialog("Save PNG",
                                          window,
                                          FileChooserAction.Save,
                                          "Cancel", ResponseType.Cancel,
                                          "Save", ResponseType.Accept);
            var filter = new FileFilter();

            filter.Name = "PNG Image (*.png)";
            filter.AddPattern("*.png");
            fileChooser.AddFilter(filter);

            if (fileChooser.Run() == (int)ResponseType.Accept)
            {
                if (decompressed != null)
                {
                    ImageSurface buf;
                    if (Atlas == null)
                    {
                        buf = new ImageSurface(
                            decompressed, Format.Argb32,
                            viewing.Texture.Width, viewing.Texture.Height,
                            viewing.Texture.Width * 4);
                    }
                    else
                    {
                        int top    = Atlas.Rect.Top;
                        int left   = Atlas.Rect.Left;
                        int right  = Atlas.Rect.Right;
                        int bottom = Atlas.Rect.Bottom;
                        unsafe
                        {
                            fixed(byte *dcu = decompressed)
                            {
                                buf = new ImageSurface(
                                    (IntPtr)(dcu + (top * viewing.Texture.Width + left) * 4), Format.Argb32,
                                    Atlas.Rect.Width, Atlas.Rect.Height,
                                    viewing.Texture.Width * 4);
                            }
                        }
                    }
                    var filename = fileChooser.Filename;
                    if (!filename.EndsWith(".png"))
                    {
                        filename = fileChooser.Filename + ".png";
                    }
                    buf.WriteToPng(filename);
                    buf.Dispose();
                }
            }

            fileChooser.Destroy();
        }