예제 #1
0
        protected override bool RunDefault()
        {
            var win = new FileSelectorDialog(Title, Action.ToGtkAction());

            win.SelectedEncoding     = Encoding != null ? Encoding.CodePage : 0;
            win.ShowEncodingSelector = ShowEncodingSelector;
            win.ShowViewerSelector   = ShowViewerSelector;

            SetDefaultProperties(win);

            try {
                var result = MessageService.RunCustomDialog(win, TransientFor ?? MessageService.RootWindow);
                if (result == (int)Gtk.ResponseType.Ok)
                {
                    GetDefaultProperties(win);
                    data.Encoding = win.SelectedEncoding > 0 ? Encoding.GetEncoding(win.SelectedEncoding) : null;
                    data.CloseCurrentWorkspace = win.CloseCurrentWorkspace;
                    data.SelectedViewer        = win.SelectedViewer;
                    return(true);
                }
                else
                {
                    return(false);
                }
            } finally {
                win.Destroy();
                win.Dispose();
            }
        }
예제 #2
0
        protected override bool RunDefault()
        {
            var win = new FileSelectorDialog(Title, Action.ToGtkAction());

            win.SelectedEncoding     = Encoding != null ? Encoding.CodePage : 0;
            win.ShowEncodingSelector = ShowEncodingSelector;
            win.ShowViewerSelector   = ShowViewerSelector;
            bool pathAlreadySet = false;

            win.CurrentFolderChanged += (s, e) => {
                var selectedPath = data.OnDirectoryChanged(this, win.CurrentFolder);
                if (selectedPath.IsNull)
                {
                    return;
                }
                data.SelectedFiles = new FilePath [] { selectedPath };
                pathAlreadySet     = true;
                win.Respond(Gtk.ResponseType.Cancel);
            };

            SetDefaultProperties(win);

            try {
                var result = MessageService.RunCustomDialog(win, TransientFor ?? MessageService.RootWindow);
                if (result == (int)Gtk.ResponseType.Ok)
                {
                    GetDefaultProperties(win);
                    data.Encoding = win.SelectedEncoding > 0 ? Encoding.GetEncoding(win.SelectedEncoding) : null;
                    data.CloseCurrentWorkspace = win.CloseCurrentWorkspace;
                    data.SelectedViewer        = win.SelectedViewer;
                    return(true);
                }
                else
                {
                    return(pathAlreadySet);
                }
            } finally {
                win.Destroy();
                win.Dispose();
            }
        }