示例#1
0
        static Command GenericAlert(WindowFrame parent, MessageDescription message)
        {
            if (message.ApplyToAllButton != null)
            {
                return(message.ApplyToAllButton);
            }

            IAlertDialogBackend backend = Toolkit.CurrentEngine.Backend.CreateBackend <IAlertDialogBackend> ();

            backend.Initialize(Toolkit.CurrentEngine.Context);
            if (message.Icon != null)
            {
                message.Icon.InitForToolkit(Toolkit.CurrentEngine);
            }

            using (backend) {
                Command res = null;
                Toolkit.CurrentEngine.InvokePlatformCode(delegate {
                    res = backend.Run(parent ?? RootWindow, message);
                });

                if (backend.ApplyToAll)
                {
                    message.ApplyToAllButton = res;
                }

                return(res);
            }
        }
示例#2
0
文件: Dialog.cs 项目: d5nguyenvan/xwt
 public Command Run(WindowFrame parent)
 {
     Toolkit.InvokePlatformCode(delegate {
         Backend.RunLoop((IWindowFrameBackend)WidgetRegistry.GetBackend(parent));
     });
     return(resultCommand);
 }
示例#3
0
        /// <summary>
        /// Shows the dialog.
        /// </summary>
        public bool Run(WindowFrame parentWindow)
        {
            var backend = Toolkit.CurrentEngine.Backend.CreateBackend <ISelectFontDialogBackend> ();

            if (backend == null)
            {
                backend = new DefaultSelectFontDialogBackend(parentWindow);
            }
            try {
                backend.SelectedFont = SelectedFont;
                backend.Title        = Title;
                backend.PreviewText  = PreviewText;
                bool result = false;
                Toolkit.CurrentEngine.InvokePlatformCode(delegate {
                    result = backend.Run((IWindowFrameBackend)Toolkit.GetBackend(parentWindow));
                });
                return(result);
            } catch (Exception ex) {
                Console.WriteLine(ex);
                return(false);
            } finally {
                font = backend.SelectedFont;
                backend.Dispose();
            }
        }
示例#4
0
        /// <summary>
        /// Shows the dialog.
        /// </summary>
        public bool Run(WindowFrame parentWindow)
        {
            try {
                running = true;
                Backend.Initialize(multiselect);
                if (!string.IsNullOrEmpty(currentFolder))
                {
                    Backend.CurrentFolder = currentFolder;
                }
                if (!string.IsNullOrEmpty(title))
                {
                    Backend.Title = title;
                }
                Backend.CanCreateFolders = canCreateFolders;

                bool result = false;
                BackendHost.ToolkitEngine.InvokePlatformCode(delegate {
                    result = Backend.Run((IWindowFrameBackend)Toolkit.GetBackend(parentWindow));
                });
                return(result);
            } finally {
                currentFolder = Backend.CurrentFolder;
                folder        = Backend.Folder;
                folders       = Backend.Folders;
                currentFolder = Backend.CurrentFolder;
                running       = false;
                Backend.Cleanup();
            }
        }
示例#5
0
 /// <summary>
 /// Shows the dialog.
 /// </summary>
 public bool Run(WindowFrame parentWindow)
 {
     try {
         running = true;
         Backend.Initialize(filters, multiselect, initialFileName);
         if (!string.IsNullOrEmpty(currentFolder))
         {
             Backend.CurrentFolder = currentFolder;
         }
         if (activeFilter != null)
         {
             Backend.ActiveFilter = activeFilter;
         }
         if (!string.IsNullOrEmpty(title))
         {
             Backend.Title = title;
         }
         return(Backend.Run((IWindowFrameBackend)BackendHost.ToolkitEngine.GetSafeBackend(parentWindow)));
     } finally {
         currentFolder = Backend.CurrentFolder;
         activeFilter  = Backend.ActiveFilter;
         fileName      = Backend.FileName;
         fileNames     = Backend.FileNames;
         currentFolder = Backend.CurrentFolder;
         running       = false;
         Backend.Cleanup();
     }
 }
示例#6
0
 /// <summary>
 /// Shows the dialog.
 /// </summary>
 public bool Run(WindowFrame parentWindow)
 {
     try {
         running = true;
         Backend.Initialize(filters, multiselect, initialFileName);
         if (!string.IsNullOrEmpty(currentFolder))
         {
             Backend.CurrentFolder = currentFolder;
         }
         if (activeFilter != null)
         {
             Backend.ActiveFilter = activeFilter;
         }
         if (!string.IsNullOrEmpty(title))
         {
             Backend.Title = title;
         }
         bool result = false;
         BackendHost.ToolkitEngine.InvokePlatformCode(delegate {
             result = Backend.Run((IWindowFrameBackend)Toolkit.GetBackend(parentWindow));
         });
         return(result);
     } finally {
         activeFilter = Backend.ActiveFilter;
         fileName     = Backend.FileName;
         fileNames    = Backend.FileNames;
         if (fileName != string.Empty)
         {
             currentFolder = Backend.CurrentFolder;
         }
         running = false;
         Backend.Cleanup();
     }
 }
示例#7
0
 public static void ShowMessage(WindowFrame parent, string primaryText, string secondaryText, string title, Drawing.Image icon)
 {
     if (string.IsNullOrEmpty(title))
     {
         title = parent?.Title ?? Application.TranslationCatalog.GetString("Information");
     }
     GenericAlert(parent, icon, primaryText, secondaryText, title, Command.Ok);
 }
示例#8
0
 public static void ShowError(WindowFrame parent, string primaryText, string secondaryText, string title)
 {
     if (string.IsNullOrEmpty(title))
     {
         title = parent?.Title ?? Application.TranslationCatalog.GetString("Error");
     }
     GenericAlert(parent, Toolkit.CurrentEngine.Defaults.MessageDialog.ErrorIcon, primaryText, secondaryText, title, Command.Ok);
 }
示例#9
0
        public Command Run(WindowFrame parent)
        {
            BackendHost.ToolkitEngine.ValidateObject(parent);

            BackendHost.ToolkitEngine.InvokePlatformCode(delegate {
                Backend.RunLoop((IWindowFrameBackend)Toolkit.GetBackend(parent));
            });
            return(resultCommand);
        }
示例#10
0
        public virtual Xwt.WindowFrame ShowTooltipWindow(MonoTextEditor editor, Xwt.WindowFrame tipWindow, int offset, Gdk.ModifierType modifierState, int mouseX, int mouseY, MonoDevelop.Ide.Editor.TooltipItem item)
        {
            int    w;
            double xalign;

            GetRequiredPosition(editor, tipWindow, out w, out xalign);

            ShowAndPositionTooltip(editor, tipWindow, mouseX, mouseY, w, xalign);

            return(tipWindow);
        }
示例#11
0
文件: Popover.cs 项目: silwol/xwt
 public Popover(WindowFrame parent, Widget child, Position arrowPosition)
 {
     this.arrowPosition = arrowPosition;
     backend = WidgetRegistry.CreateBackend<IPopoverBackend> (GetType ());
     backend.Init ((IWindowFrameBackend) WidgetRegistry.GetBackend (parent),
                   (IWidgetBackend) WidgetRegistry.GetBackend (child), arrowPosition);
     backend.Closed += (sender, e) => {
         if (Closed != null)
             Closed (this, EventArgs.Empty);
     };
 }
示例#12
0
		/// <summary>
		/// Shows the dialog.
		/// </summary>
		public bool Run (WindowFrame parentWindow)
		{
			var backend = Toolkit.CurrentEngine.Backend.CreateBackend<ISelectColorDialogBackend> ();
			try {
				if (color != Colors.Transparent)
					backend.Color = color;
				return backend.Run ((IWindowFrameBackend)Toolkit.CurrentEngine.GetSafeBackend (parentWindow), title, supportsAlpha);
			} finally {
				color = backend.Color;
				backend.Dispose ();
			}
		}
示例#13
0
        public Command Run(WindowFrame parent)
        {
            if (parent != null)
            {
                TransientFor = parent;
            }
            AdjustSize();

            loopEnded = false;
            BackendHost.ToolkitEngine.InvokePlatformCode(delegate {
                Backend.RunLoop((IWindowFrameBackend)Toolkit.GetBackend(parent));
            });
            return(resultCommand);
        }
示例#14
0
        /// <summary>
        /// Shows the dialog.
        /// </summary>
        public bool Run(WindowFrame parentWindow)
        {
            var backend = WidgetRegistry.CreateBackend <ISelectColorDialogBackend> (GetType());

            try {
                if (color != Colors.Transparent)
                {
                    backend.Color = color;
                }
                return(backend.Run((IWindowFrameBackend)WidgetRegistry.GetBackend(parentWindow), title, supportsAlpha));
            } finally {
                color = backend.Color;
                backend.Dispose();
            }
        }
示例#15
0
        /// <summary>
        /// Shows the dialog.
        /// </summary>
        public bool Run(WindowFrame parentWindow)
        {
            var backend = Toolkit.CurrentEngine.Backend.CreateBackend <ISelectColorDialogBackend> ();

            try {
                if (color != Colors.Transparent)
                {
                    backend.Color = color;
                }
                return(backend.Run((IWindowFrameBackend)Toolkit.GetBackend(parentWindow), title, supportsAlpha));
            } finally {
                color = backend.Color;
                backend.Dispose();
            }
        }
示例#16
0
        static Command GenericAlert(WindowFrame parent, Xwt.Drawing.Image icon, string primaryText, string secondaryText, int defaultButton, params Command[] buttons)
        {
            GenericMessage message = new GenericMessage()
            {
                Icon          = icon,
                Text          = primaryText,
                SecondaryText = secondaryText,
                DefaultButton = defaultButton
            };

            foreach (Command but in buttons)
            {
                message.Buttons.Add(but);
            }

            return(GenericAlert(parent, message));
        }
示例#17
0
        internal static void ShowAndPositionTooltip(MonoTextEditor editor, Xwt.WindowFrame tipWindow, int mouseX, int mouseY, int width, double xalign)
        {
            int ox = 0, oy = 0;

            if (editor.GdkWindow != null)
            {
                editor.GdkWindow.GetOrigin(out ox, out oy);
            }

            width += 10;

            int x = mouseX + ox + editor.Allocation.X;
            int y = mouseY + oy + editor.Allocation.Y;

            Gdk.Rectangle geometry = editor.Screen.GetUsableMonitorGeometry(editor.Screen.GetMonitorAtPoint(x, y));

            x -= (int)((double)width * xalign);
            y += 10;

            if (x + width >= geometry.X + geometry.Width)
            {
                x = geometry.X + geometry.Width - width;
            }
            if (x < geometry.Left)
            {
                x = geometry.Left;
            }

            int h = (int)tipWindow.Height;

            if (y + h >= geometry.Y + geometry.Height)
            {
                y = geometry.Y + geometry.Height - h;
            }
            if (y < geometry.Top)
            {
                y = geometry.Top;
            }

            tipWindow.Location = new Xwt.Point(x, y);

            tipWindow.Show();
        }
示例#18
0
        /// <summary>
        /// Shows the dialog.
        /// </summary>
        public bool Run(WindowFrame parentWindow)
        {
            var backend = Toolkit.CurrentEngine.Backend.CreateBackend <ISelectColorDialogBackend> ();

            try {
                if (color != Colors.Transparent)
                {
                    backend.Color = color;
                }
                bool result = false;
                Toolkit.CurrentEngine.InvokePlatformCode(delegate {
                    result = backend.Run((IWindowFrameBackend)Toolkit.GetBackend(parentWindow), title, supportsAlpha);
                });
                return(result);
            } finally {
                color = backend.Color;
                backend.Dispose();
            }
        }
示例#19
0
        public DefaultSelectFontDialogBackend(WindowFrame parentWindow)
        {
            parent = parentWindow;

            fontDialog        = new Dialog();
            fontDialog.Width  = 500;
            fontDialog.Height = 300;

            VBox box = new VBox();

            fontSelector              = new FontSelector();
            fontSelector.FontChanged += (sender, e) => SelectedFont = fontSelector.SelectedFont;
            box.PackStart(fontSelector, true);

            fontDialog.Content = box;

            fontDialog.Buttons.Add(new DialogButton(Command.Cancel));
            fontDialog.Buttons.Add(new DialogButton(Command.Ok));
        }
示例#20
0
        static Command GenericAlert(WindowFrame parent, MessageDescription message)
        {
            if (message.ApplyToAllButton != null)
            {
                return(message.ApplyToAllButton);
            }

            IAlertDialogBackend backend = WidgetRegistry.CreateBackend <IAlertDialogBackend> (typeof(IAlertDialogBackend));

            using (backend) {
                var res = backend.Run(parent ?? RootWindow, message);

                if (backend.ApplyToAll)
                {
                    message.ApplyToAllButton = res;
                }

                return(res);
            }
        }
示例#21
0
        public RunConfigurationNameDialog(Xwt.WindowFrame parent, string name, Command action, IEnumerable <string> invalidNames)
        {
            TransientFor      = parent;
            Resizable         = false;
            Width             = 300;
            this.invalidNames = invalidNames;
            mainBox           = new VBox();
            var box = new HBox();

            mainBox.PackStart(box, true);
            box.PackStart(new Label(GettextCatalog.GetString("Name")), false);
            entry      = new TextEntry();
            entry.Text = name ?? "";
            box.PackStart(entry, true);
            Content = mainBox;

            Buttons.Add(new DialogButton(Command.Cancel));
            Buttons.Add(okButton = new DialogButton(action));
            this.DefaultCommand  = okButton.Command;
            entry.Activated     += Entry_Activated;
            entry.Changed       += (s, o) => UpdateControls();
        }
示例#22
0
 /// <summary>
 /// Shows the dialog.
 /// </summary>
 public bool Run(WindowFrame parentWindow)
 {
     try {
         running = true;
         Backend.Initialize(multiselect);
         if (!string.IsNullOrEmpty(currentFolder))
         {
             Backend.CurrentFolder = currentFolder;
         }
         if (!string.IsNullOrEmpty(title))
         {
             Backend.Title = title;
         }
         return(Backend.Run((IWindowFrameBackend)WidgetRegistry.GetBackend(parentWindow)));
     } finally {
         currentFolder = Backend.CurrentFolder;
         folder        = Backend.Folder;
         folders       = Backend.Folders;
         currentFolder = Backend.CurrentFolder;
         running       = false;
         Backend.Cleanup();
     }
 }
示例#23
0
文件: Dialog.cs 项目: m13253/xwt
		public Command Run (WindowFrame parent)
		{
			BackendHost.ToolkitEngine.ValidateObject (parent);
			if (parent != null)
				TransientFor = parent;
			AdjustSize ();

			loopEnded = false;
			BackendHost.ToolkitEngine.InvokePlatformCode (delegate {
				Backend.RunLoop ((IWindowFrameBackend) Toolkit.GetBackend (parent));
			});
			return resultCommand;
		}
示例#24
0
文件: FileDialog.cs 项目: garuma/xwt
 /// <summary>
 /// Shows the dialog.
 /// </summary>
 public bool Run(WindowFrame parentWindow)
 {
     try {
         running = true;
         Backend.Initialize (filters, multiselect, initialFileName);
         if (!string.IsNullOrEmpty (currentFolder))
             Backend.CurrentFolder = currentFolder;
         if (activeFilter != null)
             Backend.ActiveFilter = activeFilter;
         if (!string.IsNullOrEmpty (title))
             Backend.Title = title;
         return Backend.Run ((IWindowFrameBackend)backendHost.ToolkitEngine.GetSafeBackend (parentWindow));
     } finally {
         currentFolder = Backend.CurrentFolder;
         activeFilter = Backend.ActiveFilter;
         fileName = Backend.FileName;
         fileNames = Backend.FileNames;
         currentFolder = Backend.CurrentFolder;
         running = false;
         Backend.Cleanup ();
     }
 }
示例#25
0
 public static void ShowWarning(WindowFrame parent, string primaryText, string secondaryText)
 {
     GenericAlert(parent, StockIcons.Warning, primaryText, secondaryText, Command.Ok);
 }
示例#26
0
 public static void ShowError(WindowFrame parent, string primaryText)
 {
     ShowError(parent, primaryText, null);
 }
示例#27
0
 static Command GenericAlert(WindowFrame parent, Xwt.Drawing.Image icon, string primaryText, string secondaryText, params Command[] buttons)
 {
     return(GenericAlert(parent, icon, primaryText, secondaryText, buttons.Length - 1, buttons));
 }
示例#28
0
 public static void ShowMessage(WindowFrame parent, string primaryText, string secondaryText)
 {
     ShowMessage(parent, StockIcons.Information, primaryText, secondaryText);
 }
示例#29
0
文件: Widget.cs 项目: joncham/xwt
 internal void SetParentWindow(WindowFrame win)
 {
     parentWindow = win;
 }
示例#30
0
 static Command GenericAlert(WindowFrame parent, Xwt.Drawing.Image icon, string primaryText, string secondaryText, params Command[] buttons)
 {
     return GenericAlert (parent, icon, primaryText, secondaryText, buttons.Length - 1, buttons);
 }
示例#31
0
		public DefaultSelectFontDialogBackend (WindowFrame parentWindow)
		{
			parent = parentWindow;

			fontDialog = new Dialog ();
			fontDialog.Width = 500;
			fontDialog.Height = 300;

			VBox box = new VBox ();
			fontSelector = new FontSelector ();
			fontSelector.FontChanged += (sender, e) => SelectedFont = fontSelector.SelectedFont;
			box.PackStart (fontSelector, true);

			fontDialog.Content = box;

			fontDialog.Buttons.Add (new DialogButton (Command.Cancel));
			fontDialog.Buttons.Add (new DialogButton (Command.Ok));
		}
示例#32
0
 public static void ShowMessage(WindowFrame parent, string primaryText, string secondaryText, Drawing.Image icon)
 {
     GenericAlert (parent, icon, primaryText, secondaryText, Command.Ok);
 }
		public new bool Run (WindowFrame parentWindow)
		{
			return base.Run (parentWindow) == Command.Ok;
		}
示例#34
0
 /// <summary>
 /// Shows the dialog.
 /// </summary>
 public bool Run(WindowFrame parentWindow)
 {
     try {
         running = true;
         Backend.Initialize (multiselect);
         if (!string.IsNullOrEmpty (currentFolder))
             Backend.CurrentFolder = currentFolder;
         if (!string.IsNullOrEmpty (title))
             Backend.Title = title;
         return Backend.Run ((IWindowFrameBackend)BackendHost.ToolkitEngine.GetSafeBackend (parentWindow));
     } finally {
         currentFolder = Backend.CurrentFolder;
         folder = Backend.Folder;
         folders = Backend.Folders;
         currentFolder = Backend.CurrentFolder;
         running = false;
         Backend.Cleanup ();
     }
 }
示例#35
0
文件: Dialog.cs 项目: garuma/xwt
        public Command Run(WindowFrame parent)
        {
            BackendHost.ToolkitEngine.ValidateObject (parent);

            BackendHost.ToolkitEngine.InvokePlatformCode (delegate {
                Backend.RunLoop ((IWindowFrameBackend) Toolkit.GetBackend (parent));
            });
            return resultCommand;
        }
示例#36
0
        static Command GenericAlert(WindowFrame parent, MessageDescription message)
        {
            if (message.ApplyToAllButton != null)
                return message.ApplyToAllButton;

            IAlertDialogBackend backend = Toolkit.CurrentEngine.Backend.CreateBackend<IAlertDialogBackend> ();
            backend.Initialize (Toolkit.CurrentEngine.Context);

            using (backend) {
                var res = backend.Run (parent ?? RootWindow, message);

                if (backend.ApplyToAll)
                    message.ApplyToAllButton = res;

                return res;
            }
        }
示例#37
0
 public Command Run(WindowFrame parent)
 {
     Toolkit.InvokePlatformCode (delegate {
         Backend.RunLoop ((IWindowFrameBackend) WidgetRegistry.GetBackend (parent));
     });
     return resultCommand;
 }
示例#38
0
 public static bool Confirm(WindowFrame window, string primaryText, string secondaryText, Drawing.Image icon, Command button)
 {
     return GenericAlert (window, icon, primaryText, secondaryText, Command.Cancel, button) == button;
 }
示例#39
0
 public static void ShowMessage(WindowFrame parent, string primaryText, string secondaryText)
 {
     GenericAlert (parent, StockIcons.Information, primaryText, secondaryText, Command.Ok);
 }
示例#40
0
 public static Command AskQuestion(WindowFrame window, QuestionMessage message)
 {
     return(GenericAlert(window, message));
 }
示例#41
0
 public static void ShowMessage(WindowFrame parent, Xwt.Drawing.Image icon, string primaryText, string secondaryText)
 {
     GenericAlert(parent, icon, primaryText, secondaryText, Command.Ok);
 }
示例#42
0
 public static void ShowWarning(WindowFrame parent, string primaryText, string secondaryText)
 {
     GenericAlert (parent, StockIcons.Warning, primaryText, secondaryText, Command.Ok);
 }
示例#43
0
 public static void ShowMessage(WindowFrame parent, string primaryText)
 {
     ShowMessage (parent, primaryText, null);
 }
示例#44
0
		/// <summary>
		/// Shows the dialog.
		/// </summary>
		public bool Run (WindowFrame parentWindow, Action<Color> colorChangedCallback)
		{
			if(backend.Color != Colors.Transparent) {
				backend.Color = backend.Color;
			}
			return backend.Run((IWindowFrameBackend)Toolkit.CurrentEngine.GetSafeBackend(parentWindow), title, supportsAlpha, colorChangedCallback);
		}
示例#45
0
 public static void ShowWarning(WindowFrame parent, string primaryText)
 {
     ShowWarning(parent, primaryText, null);
 }
示例#46
0
 public static void ShowWarning(WindowFrame parent, string primaryText, string secondaryText)
 {
     ShowWarning(parent, primaryText, secondaryText, string.Empty);
 }
示例#47
0
 public static void ShowMessage(WindowFrame parent, string primaryText)
 {
     ShowMessage(parent, primaryText, null);
 }
示例#48
0
 public static void ShowWarning(WindowFrame parent, string primaryText)
 {
     ShowWarning (parent, primaryText, null);
 }
示例#49
0
 public static void ShowError(WindowFrame parent, string primaryText)
 {
     ShowError (parent, primaryText, null);
 }
示例#50
0
 internal void SetParentWindow(WindowFrame win)
 {
     parentWindow = win;
 }
示例#51
0
 public static bool Confirm(WindowFrame window, string primaryText, string secondaryText, Command button)
 {
     return GenericAlert (window, Toolkit.CurrentEngine.Defaults.MessageDialog.QuestionIcon, primaryText, secondaryText, Command.Cancel, button) == button;
 }
示例#52
0
        static Command GenericAlert(WindowFrame parent, Xwt.Drawing.Image icon, string primaryText, string secondaryText, int defaultButton, params Command[] buttons)
        {
            GenericMessage message = new GenericMessage () {
                Icon = icon,
                Text = primaryText,
                SecondaryText = secondaryText,
                DefaultButton = defaultButton
            };
            foreach (Command but in buttons)
                message.Buttons.Add (but);

            return GenericAlert (parent, message);
        }
示例#53
0
 /// <summary>
 /// Shows the dialog.
 /// </summary>
 public bool Run(WindowFrame parentWindow)
 {
     var backend = WidgetRegistry.CreateBackend<ISelectColorDialogBackend> (GetType ());
     try {
         if (color != Colors.Transparent)
             backend.Color = color;
         return backend.Run ((IWindowFrameBackend)WidgetRegistry.GetBackend (parentWindow), title, supportsAlpha);
     } finally {
         color = backend.Color;
         backend.Dispose ();
     }
 }
示例#54
0
 public static void ShowWarning(WindowFrame parent, string primaryText, string secondaryText)
 {
     GenericAlert (parent, Toolkit.CurrentEngine.Defaults.MessageDialog.WarningIcon, primaryText, secondaryText, Command.Ok);
 }
示例#55
0
		/// <summary>
		/// Shows the dialog.
		/// </summary>
		public bool Run (WindowFrame parentWindow)
		{
			var backend = Toolkit.CurrentEngine.Backend.CreateBackend<ISelectFontDialogBackend> ();
			if (backend == null)
				backend = new DefaultSelectFontDialogBackend (parentWindow);
			try {
				backend.SelectedFont = SelectedFont;
				backend.Title = Title;
				backend.PreviewText = PreviewText;
				return backend.Run ((IWindowFrameBackend)Toolkit.CurrentEngine.GetSafeBackend (parentWindow));
			} catch (Exception ex) {
				Console.WriteLine (ex);
				return false;
			} finally {
				font = backend.SelectedFont;
				backend.Dispose ();
			}
		}
示例#56
0
		public bool Run (WindowFrame parent)
		{
			var cmd = Dialog.Run (parent);
			return cmd == Command.Ok;
		}