Ejemplo n.º 1
0
        public bool Run(SelectFileDialogData data)
        {
            var parent = data.TransientFor ?? MessageService.RootWindow;

            CommonFileDialog dialog;

            if ((data.Action & (FileChooserAction.Open | FileChooserAction.SelectFolder)) != 0)
            {
                dialog = new CustomCommonOpenFileDialog();
            }
            else
            {
                dialog = new CommonSaveFileDialog();
            }

            dialog.SetCommonFormProperties(data);

            if (!GdkWin32.RunModalWin32Dialog(dialog, parent))
            {
                return(false);
            }

            dialog.GetCommonFormProperties(data);

            return(true);
        }
Ejemplo n.º 2
0
		public override void ShowGlobalProgressBarIndeterminate ()
		{
			if (!TaskbarManager.IsPlatformSupported)
				return;
				
			IntPtr handle = GdkWin32.HgdiobjGet (IdeApp.Workbench.RootWindow.GdkWindow);
			TaskbarManager.Instance.SetProgressState (TaskbarProgressBarState.Indeterminate, handle);
		}
Ejemplo n.º 3
0
 internal override void SetMainWindowDecorations(Gtk.Window window)
 {
     // Only initialize elements for Win7+.
     if (TaskbarManager.IsPlatformSupported)
     {
         TaskbarManager.Instance.SetApplicationIdForSpecificWindow(GdkWin32.HgdiobjGet(window.GdkWindow), BrandingService.ApplicationName);
     }
 }
Ejemplo n.º 4
0
        public override bool GetIsFullscreen(Components.Window window)
        {
            WINDOWPLACEMENT lpwndpl = new WINDOWPLACEMENT();

            lpwndpl.length = Marshal.SizeOf(lpwndpl);

            Gtk.Window controlWindow = window;
            IntPtr     handle        = GdkWin32.HgdiobjGet(controlWindow.GdkWindow);

            Win32.GetWindowPlacement(handle, ref lpwndpl);
            return(lpwndpl.showCmd == Win32.SW_SHOWMAXIMIZED);
        }
        public override void ShowGlobalProgressBarError()
        {
            if (!TaskbarManager.IsPlatformSupported)
            {
                return;
            }

            IntPtr handle = GdkWin32.HgdiobjGet(IdeApp.Workbench.RootWindow.GdkWindow);

            TaskbarManager.Instance.SetProgressState(TaskbarProgressBarState.Error, handle);
            TaskbarManager.Instance.SetProgressValue(1, 1, handle);
        }
Ejemplo n.º 6
0
		public override void SetGlobalProgressBar (double progress)
		{
			if (!TaskbarManager.IsPlatformSupported)
				return;

			IntPtr handle = GdkWin32.HgdiobjGet (IdeApp.Workbench.RootWindow.GdkWindow);
			if (progress >= 1.0) {
				TaskbarManager.Instance.SetProgressState (TaskbarProgressBarState.NoProgress, handle);
			} else {
				TaskbarManager.Instance.SetProgressState (TaskbarProgressBarState.Normal, handle);
				TaskbarManager.Instance.SetProgressValue ((int)(progress * 100f), 100, handle);
			}
		}
Ejemplo n.º 7
0
        internal override void SetMainWindowDecorations(Gtk.Window window)
        {
            Uri uri = new Uri("pack://application:,,,/WindowsPlatform;component/Styles.xaml");

            Application.Current.Resources.MergedDictionaries.Add(new ResourceDictionary()
            {
                Source = uri
            });

            // Only initialize elements for Win7+.
            if (TaskbarManager.IsPlatformSupported)
            {
                TaskbarManager.Instance.SetApplicationIdForSpecificWindow(GdkWin32.HgdiobjGet(window.GdkWindow), BrandingService.ApplicationName);
            }
        }
Ejemplo n.º 8
0
		public override void ShowGlobalProgressBarError ()
		{
			if (!TaskbarManager.IsPlatformSupported)
				return;

			IntPtr handle = GdkWin32.HgdiobjGet (IdeApp.Workbench.RootWindow.GdkWindow);
			TaskbarManager.Instance.SetProgressState (TaskbarProgressBarState.Error, handle);
			TaskbarManager.Instance.SetProgressValue (1, 1, handle);

			// Added a timeout to removing the red progress bar. This is to fix the dependency on a status bar update
			// that won't happen until the status bar receives another update.
			GLib.Timeout.Add (500, delegate {
				TaskbarManager.Instance.SetProgressState (TaskbarProgressBarState.NoProgress, handle);
				return false;
			});
		}
        private void UpdateJumpList()
        {
            Taskbar.JumpList jumplist = Taskbar.JumpList.CreateJumpListForIndividualWindow(
                MonoDevelop.Core.BrandingService.ApplicationName,
                GdkWin32.HgdiobjGet(MessageService.RootWindow.GdkWindow)
                );
            jumplist.KnownCategoryToDisplay = Taskbar.JumpListKnownCategoryType.Neither;

            Taskbar.JumpListCustomCategory recentProjectsCategory = new Taskbar.JumpListCustomCategory("Recent Solutions");
            Taskbar.JumpListCustomCategory recentFilesCategory    = new Taskbar.JumpListCustomCategory("Recent Files");

            jumplist.AddCustomCategories(recentProjectsCategory, recentFilesCategory);
            jumplist.KnownCategoryOrdinalPosition = 0;

            foreach (RecentFile recentProject in recentFiles.GetProjects())
            {
                // Windows is picky about files that are added to the jumplist. Only files that MonoDevelop
                // has been registered as supported in the registry can be added.
                bool isSupportedFileExtension = this.supportedExtensions.Contains(Path.GetExtension(recentProject.FileName));
                if (isSupportedFileExtension)
                {
                    recentProjectsCategory.AddJumpListItems(new Taskbar.JumpListLink(exePath, recentProject.DisplayName)
                    {
                        Arguments     = MonoDevelop.Core.Execution.ProcessArgumentBuilder.Quote(recentProject.FileName),
                        IconReference = new Microsoft.WindowsAPICodePack.Shell.IconReference(exePath, 0),
                    });
                }
            }

            foreach (RecentFile recentFile in recentFiles.GetFiles())
            {
                if (this.supportedExtensions.Contains(Path.GetExtension(recentFile.FileName)))
                {
                    recentFilesCategory.AddJumpListItems(new Taskbar.JumpListLink(exePath, recentFile.DisplayName)
                    {
                        Arguments     = MonoDevelop.Core.Execution.ProcessArgumentBuilder.Quote(recentFile.FileName),
                        IconReference = new Microsoft.WindowsAPICodePack.Shell.IconReference(exePath, 0),
                    });
                }
            }

            jumplist.Refresh();
        }
Ejemplo n.º 10
0
        public bool Run(AddFileDialogData data)
        {
            var parent = data.TransientFor ?? MessageService.RootWindow;
            var dialog = new CommonOpenFileDialog();

            SelectFileDialogHandler.SetCommonFormProperties(data, dialog);

            var buildActionCombo = new CommonFileDialogComboBox();
            var group            = new CommonFileDialogGroupBox("overridebuildaction", "Override build action:");

            buildActionCombo.Items.Add(new CommonFileDialogComboBoxItem(GettextCatalog.GetString("Default")));
            foreach (var ba in data.BuildActions)
            {
                if (ba == "--")
                {
                    continue;
                }

                buildActionCombo.Items.Add(new CommonFileDialogComboBoxItem(ba));
            }

            buildActionCombo.SelectedIndex = 0;
            group.Items.Add(buildActionCombo);
            dialog.Controls.Add(group);

            if (!GdkWin32.RunModalWin32Dialog(dialog, parent))
            {
                return(false);
            }

            SelectFileDialogHandler.GetCommonFormProperties(data, dialog);
            var idx = buildActionCombo.SelectedIndex;

            if (idx > 0)
            {
                data.OverrideAction = buildActionCombo.Items [idx].Text;
            }

            return(true);
        }
Ejemplo n.º 11
0
        public bool Run(OpenFileDialogData data)
        {
            var parent = data.TransientFor ?? MessageService.RootWindow;
            CommonFileDialog dialog;

            if (data.Action == FileChooserAction.Open)
            {
                dialog = new CustomCommonOpenFileDialog {
                    EnsureFileExists = true
                };
            }
            else
            {
                dialog = new CustomCommonSaveFileDialog();
            }

            dialog.SetCommonFormProperties(data);

            CustomCommonFileDialogComboBox encodingCombo = null;

            if (data.ShowEncodingSelector)
            {
                var group = new CommonFileDialogGroupBox("encoding", "Encoding:");
                encodingCombo = new CustomCommonFileDialogComboBox();

                BuildEncodingsCombo(encodingCombo, data.Action != FileChooserAction.Save, data.Encoding);
                group.Items.Add(encodingCombo);
                dialog.Controls.Add(group);

                encodingCombo.SelectedIndexChanged += (sender, e) => {
                    if (encodingCombo.SelectedIndex == encodingCombo.Items.Count - 1)
                    {
                        var dlg = new System.Windows.Window {
                            Title         = "Choose encodings",
                            Content       = new SelectEncodingControl(),
                            SizeToContent = SizeToContent.WidthAndHeight
                        };
                        if (dlg.ShowDialog().Value)
                        {
                            BuildEncodingsCombo(encodingCombo, data.Action != FileChooserAction.Save, data.Encoding);
                            dialog.ApplyControlPropertyChange("Items", encodingCombo);
                        }
                    }
                };
            }

            CustomCommonFileDialogComboBox viewerCombo   = null;
            CommonFileDialogCheckBox       closeSolution = null;

            if (data.ShowViewerSelector && data.Action == FileChooserAction.Open)
            {
                var group = new CommonFileDialogGroupBox("openWith", "Open with:");

                viewerCombo = new CustomCommonFileDialogComboBox {
                    Enabled = false
                };
                group.Items.Add(viewerCombo);
                dialog.Controls.Add(group);

                if (encodingCombo != null || IdeApp.Workspace.IsOpen)
                {
                    viewerCombo.SelectedIndexChanged += (o, e) => {
                        bool solutionWorkbenchSelected = ((ViewerComboItem)viewerCombo.Items [viewerCombo.SelectedIndex]).Viewer == null;
                        if (closeSolution != null)
                        {
                            closeSolution.Visible = solutionWorkbenchSelected;
                        }
                        if (encodingCombo != null)
                        {
                            encodingCombo.Enabled = !solutionWorkbenchSelected;
                        }
                    };
                }

                if (IdeApp.Workspace.IsOpen)
                {
                    var group2 = new CommonFileDialogGroupBox();

                    // "Close current workspace" is too long and splits the text on 2 lines.
                    closeSolution = new CommonFileDialogCheckBox("Close workspace", true)
                    {
                        Visible = false
                    };
                    group2.Items.Add(closeSolution);
                    dialog.Controls.Add(group2);
                }

                dialog.SelectionChanged += (sender, e) => {
                    try {
                        var  files    = GetSelectedItems(dialog);
                        var  file     = files.Count == 0 ? null : files[0];
                        bool hasBench = FillViewers(viewerCombo, file);
                        if (closeSolution != null)
                        {
                            closeSolution.Visible = hasBench;
                        }
                        if (encodingCombo != null)
                        {
                            encodingCombo.Enabled = !hasBench;
                        }
                        dialog.ApplyControlPropertyChange("Items", viewerCombo);
                    } catch (Exception ex) {
                        LoggingService.LogInternalError(ex);
                    }
                };
            }

            if (!GdkWin32.RunModalWin32Dialog(dialog, parent))
            {
                return(false);
            }

            dialog.GetCommonFormProperties(data);
            if (encodingCombo != null)
            {
                data.Encoding = ((EncodingComboItem)encodingCombo.Items [encodingCombo.SelectedIndex]).Encoding;
            }

            if (viewerCombo != null)
            {
                if (closeSolution != null)
                {
                    data.CloseCurrentWorkspace = closeSolution.Visible && closeSolution.IsChecked;
                }
                int index = viewerCombo.SelectedIndex;
                if (index != -1)
                {
                    data.SelectedViewer = ((ViewerComboItem)viewerCombo.Items [index]).Viewer;
                }
            }

            return(true);
        }
Ejemplo n.º 12
0
 public GtkWin32Proxy(Gtk.Window gtkWindow)
 {
     Handle = GdkWin32.HgdiobjGet(gtkWindow.RootWindow);
 }