Exemple #1
0
 public MenuItem(Command command)
     : this()
 {
     Label = command.Label;
     if (!string.IsNullOrEmpty (command.Icon))
         Image = Image.FromIcon (command.Icon, IconSize.Small);
 }
Exemple #2
0
 public void SetCommand(Command command, Action action)
 {
     Action oldAction;
     if (_commandMap.TryGetValue (command, out oldAction)) {
         _commandMap [command] = action;
     } else {
         _commandMap.Add (command, action);
     }
 }
Exemple #3
0
        public Windows()
        {
            Button b = new Button ("Show borderless window");
            PackStart (b);
            b.Clicked += delegate {
                Window w = new Window ();
                w.Decorated = false;
                Button c = new Button ("This is a window");
            //				c.Margin.SetAll (10);
                w.Content = c;
                c.Clicked += delegate {
                    w.Dispose ();
                };
                var bpos = b.ScreenBounds;
                w.Bounds = new Rectangle (bpos.X, bpos.Y + b.Size.Height, w.Bounds.Width, w.Bounds.Height);
                w.Show ();
            };
            b = new Button ("Show message dialog");
            PackStart (b);
            b.Clicked += delegate {
                MessageDialog.ShowMessage (ParentWindow, "Hi there!");
            };

            Button db = new Button ("Show custom dialog");
            PackStart (db);
            db.Clicked += delegate {
                Dialog d = new Dialog ();
                d.Title = "This is a dialog";
                Table t = new Table ();
                t.Attach (new Label ("Some field:"), 0, 1, 0, 1);
                t.Attach (new TextEntry (), 1, 2, 0, 1);
                t.Attach (new Label ("Another field:"), 0, 1, 1, 2);
                t.Attach (new TextEntry (), 1, 2, 1, 2);
                d.Content = t;

                Command custom = new Command ("Custom");
                d.Buttons.Add (new DialogButton (custom));
                d.Buttons.Add (new DialogButton ("Custom OK", Command.Ok));
                d.Buttons.Add (new DialogButton (Command.Cancel));
                d.Buttons.Add (new DialogButton (Command.Ok));

                var r = d.Run (this.ParentWindow);
                db.Label = "Result: " + r.Label;
                d.Dispose ();
            };
        }
Exemple #4
0
		/// <summary>
		/// Called when a dialog button is clicked
		/// </summary>
		/// <param name="cmd">The command</param>
		protected virtual void OnCommandActivated (Command cmd)
		{
			Respond (cmd);
		}
Exemple #5
0
		public DialogButton (string label, Image icon, Command cmd)
		{
			this.label = label;
			this.command = cmd;
			this.image = icon;
		}
Exemple #6
0
		public void HideCommand (Command cmd)
		{
			var btn = Buttons.GetCommandButton (cmd);
			if (btn != null)
				btn.Visible = false;
		}
Exemple #7
0
		public void DisableCommand (Command cmd)
		{
			var btn = Buttons.GetCommandButton (cmd);
			if (btn != null)
				btn.Sensitive = false;
		}
Exemple #8
0
		bool RequestClose ()
		{
			requestingClose = true;
			try {
				if (OnCloseRequested ()) {
					if (!responding)
						resultCommand = null;
					loopEnded = true;
					return true;
				} else
					return false;
			} finally {
				responding = false;
				requestingClose = false;
			}
		}
Exemple #9
0
 public void Respond(Command cmd)
 {
     resultCommand = cmd;
     if (!loopEnded) {
         loopEnded = true;
         Backend.EndLoop ();
     }
 }
 public RadioButtonMenuItem(Command command)
     : base(command)
 {
 }
Exemple #11
0
 public ConfirmationMessage(string primaryText, Command button)
     : this(button)
 {
     Text = primaryText;
 }
Exemple #12
0
 public ConfirmationMessage(Command button)
     : this()
 {
     ConfirmButton = button;
 }
Exemple #13
0
 public static bool Confirm(string primaryText, string secondaryText, Command button, bool confirmIsDefault)
 {
     return GenericAlert (RootWindow, StockIcons.Question, primaryText, secondaryText, confirmIsDefault ? 0 : 1, Command.Cancel, button) == button;
 }
Exemple #14
0
 public static bool Confirm(string primaryText, Command button, bool confirmIsDefault)
 {
     return Confirm (primaryText, null, button, confirmIsDefault);
 }
Exemple #15
0
 public static bool Confirm(string primaryText, Command button)
 {
     return Confirm (primaryText, null, button);
 }
Exemple #16
0
		public RadioButtonMenuItem (Command command)
		{
			VerifyConstructorCall (this);
			LoadCommandProperties (command);
		}
Exemple #17
0
 public ConfirmationMessage(string primaryText, string secondaryText, Command button)
     : this(primaryText, button)
 {
     SecondaryText = secondaryText;
 }
Exemple #18
0
 public CheckBoxMenuItem(Command command)
     : base(command)
 {
 }
Exemple #19
0
 /// <summary>
 /// Called when a dialog button is clicked
 /// </summary>
 /// <param name="cmd">The command</param>
 protected virtual void OnCommandActivated(Command cmd)
 {
     var args = new DialogCommandActivatedEventArgs (cmd);
     if (CommandActivated != null)
         CommandActivated (this, args);
     if (!args.Handled)
         Respond (cmd);
 }
Exemple #20
0
		public void Respond (Command cmd)
		{
			resultCommand = cmd;
			responding = true;
			if (!loopEnded && !requestingClose) {
				Backend.EndLoop ();
			}
		}
Exemple #21
0
 public DialogCommandActivatedEventArgs(Command command)
 {
     Command = command;
 }
Exemple #22
0
		public void EnableCommand (Command cmd)
		{
			var btn = Buttons.GetCommandButton (cmd);
			if (btn != null)
				btn.Sensitive = true;
		}
		void OnAddConfiguration (object sender, EventArgs e)
		{
			var okCommand = new Command (GettextCatalog.GetString ("Create"));
			using (var dlg = new RunConfigurationNameDialog (ParentWindow, "", okCommand, panel.Configurations.Select (c => c.EditedConfig.Name))) {
				dlg.Title = GettextCatalog.GetString ("New Configuration");
				if (dlg.Run () == okCommand) {
					var config = new MultiItemSolutionRunConfiguration (dlg.NewName, dlg.NewName);
					panel.AddConfiguration (config);
					Fill ();
				}
			}
		}
Exemple #24
0
		public void ShowCommand (Command cmd)
		{
			var btn = Buttons.GetCommandButton (cmd);
			if (btn != null)
				btn.Visible = true;
		}
		void OnRenameConfiguration (object sender, EventArgs e)
		{
			var config = (MultiItemSolutionRunConfiguration)list.SelectedConfiguration;
			var okCommand = new Command (GettextCatalog.GetString ("Rename"));
			using (var dlg = new RunConfigurationNameDialog (ParentWindow, config.Name, okCommand, panel.Configurations.Select (c => c.EditedConfig.Name))) {
				dlg.Title = GettextCatalog.GetString ("Rename Configuration");
				if (dlg.Run () != Command.Cancel) {
					var copy = new MultiItemSolutionRunConfiguration (config, dlg.NewName);
					panel.ReplaceConfiguration (config, copy);
					Fill ();
				}
			}
		}
Exemple #26
0
		public DialogButton (string label, Command cmd)
		{
			this.label = label;
			this.command = cmd;
		}
		protected override void OnCommandActivated (Command cmd)
		{
			if (cmd == runButton.Command)
				editor.Save ();
			base.OnCommandActivated (cmd);
		}
Exemple #28
0
		public DialogButton (Command cmd)
		{
			this.command = cmd;
		}
Exemple #29
0
        public Windows()
        {
            Button bp = new Button ("Show borderless window");
            PackStart (bp);
            bp.Clicked += delegate {
                Window w = new Window ();
                w.Decorated = false;
                Button c = new Button ("This is a window");
            //				c.Margin.SetAll (10);
                w.Content = c;
                c.Clicked += delegate {
                    w.Dispose ();
                };
                var bpos = bp.ScreenBounds;
                w.ScreenBounds = new Rectangle (bpos.X, bpos.Y + bp.Size.Height, w.Width, w.Height);
                w.Show ();
            };
            Button b = new Button ("Show message dialog");
            PackStart (b);
            b.Clicked += delegate {
                MessageDialog.ShowMessage (ParentWindow, "Hi there!");
            };

            Button db = new Button ("Show custom dialog");
            PackStart (db);
            db.Clicked += delegate {
                Dialog d = new Dialog ();
                d.Title = "This is a dialog";
                Table t = new Table ();
                t.Add (new Label ("Some field:"), 0, 0);
                t.Add (new TextEntry (), 1, 0);
                t.Add (new Label ("Another field:"), 0, 1);
                t.Add (new TextEntry (), 1, 1);
                d.Content = t;
                d.CloseRequested += delegate(object sender, CloseRequestedEventArgs args) {
                    args.AllowClose = MessageDialog.Confirm ("Really close?", Command.Close);
                };

                Command custom = new Command ("Custom");
                d.Buttons.Add (new DialogButton (custom));
                d.Buttons.Add (new DialogButton ("Custom OK", Command.Ok));
                d.Buttons.Add (new DialogButton (Command.Cancel));
                d.Buttons.Add (new DialogButton (Command.Ok));

                var r = d.Run (this.ParentWindow);
                db.Label = "Result: " + (r != null ? r.Label : "(Closed)");
                d.Dispose ();
            };

            b = new Button ("Show Open File dialog");
            PackStart (b);
            b.Clicked += delegate {
                OpenFileDialog dlg = new OpenFileDialog ("Select a file");
                dlg.InitialFileName = "Some file";
                dlg.Multiselect = true;
                dlg.Filters.Add (new FileDialogFilter ("Xwt files", "*.xwt"));
                dlg.Filters.Add (new FileDialogFilter ("All files", "*.*"));
                if (dlg.Run ())
                    MessageDialog.ShowMessage ("Files have been selected!", string.Join ("\n", dlg.FileNames));
            };

            b = new Button ("Show Save File dialog");
            PackStart (b);
            b.Clicked += delegate {
                SaveFileDialog dlg = new SaveFileDialog ("Select a file");
                dlg.InitialFileName = "Some file";
                dlg.Multiselect = true;
                dlg.Filters.Add (new FileDialogFilter ("Xwt files", "*.xwt"));
                dlg.Filters.Add (new FileDialogFilter ("All files", "*.*"));
                if (dlg.Run ())
                    MessageDialog.ShowMessage ("Files have been selected!", string.Join ("\n", dlg.FileNames));
            };

            b = new Button ("Show Select Folder dialog (Multi select)");
            PackStart (b);
            b.Clicked += delegate {
                SelectFolderDialog dlg = new SelectFolderDialog ("Select some folder");
                dlg.Multiselect = true;
                if (dlg.Run ())
                    MessageDialog.ShowMessage ("Folders have been selected!", string.Join ("\n", dlg.Folders));
            };

            b = new Button ("Show Select Folder dialog (Single select)");
            PackStart (b);
            b.Clicked += delegate {
                SelectFolderDialog dlg = new SelectFolderDialog ("Select a folder");
                dlg.Multiselect = false;
                if (dlg.Run ())
                    MessageDialog.ShowMessage ("Folders have been selected!", string.Join ("\n", dlg.Folders));
            };

            b = new Button ("Show Select Folder dialog (Single select, allow creation)");
            PackStart (b);
            b.Clicked += delegate {
                SelectFolderDialog dlg = new SelectFolderDialog ("Select or create a folder");
                dlg.Multiselect = false;
                dlg.CanCreateFolders = true;
                if (dlg.Run ())
                    MessageDialog.ShowMessage ("Folders have been selected/created!", string.Join ("\n", dlg.Folders));
            };

            b = new Button ("Show Select Color dialog");
            PackStart (b);
            b.Clicked += delegate {
                SelectColorDialog dlg = new SelectColorDialog ("Select a color");
                dlg.SupportsAlpha = true;
                dlg.Color = Xwt.Drawing.Colors.AliceBlue;
                if (dlg.Run (ParentWindow))
                    MessageDialog.ShowMessage ("A color has been selected!", dlg.Color.ToString ());
            };

            b = new Button("Show window shown event");
            PackStart(b);
            b.Clicked += delegate
            {
                Window w = new Window();
                w.Decorated = false;
                Button c = new Button("This is a window with events on");
                w.Content = c;
                c.Clicked += delegate
                {
                    w.Dispose();
                };
                w.Shown += (sender, args) => MessageDialog.ShowMessage("My Parent has been shown");
                w.Hidden += (sender, args) => MessageDialog.ShowMessage("My Parent has been hidden");

                w.Show();

            };

            b = new Button("Show dialog with dynamically updating content");
            PackStart(b);
            b.Clicked += delegate
            {
                var dialog = new Dialog ();
                dialog.Content = new Label ("Hello World");
                Xwt.Application.TimeoutInvoke (TimeSpan.FromSeconds (2), () => {
                    dialog.Content = new Label ("Goodbye World");
                    return false;
                });
                dialog.Run ();
            };
        }
Exemple #30
0
        public Windows()
        {
            Button b = new Button ("Show borderless window");
            PackStart (b);
            b.Clicked += delegate {
                Window w = new Window ();
                w.Decorated = false;
                Button c = new Button ("This is a window");
            //				c.Margin.SetAll (10);
                w.Content = c;
                c.Clicked += delegate {
                    w.Dispose ();
                };
                var bpos = b.ScreenBounds;
                w.ScreenBounds = new Rectangle (bpos.X, bpos.Y + b.Size.Height, w.Width, w.Height);
                w.Show ();
            };
            b = new Button ("Show message dialog");
            PackStart (b);
            b.Clicked += delegate {
                MessageDialog.ShowMessage (ParentWindow, "Hi there!");
            };

            Button db = new Button ("Show custom dialog");
            PackStart (db);
            db.Clicked += delegate {
                Dialog d = new Dialog ();
                d.Title = "This is a dialog";
                Table t = new Table ();
                t.Attach (new Label ("Some field:"), 0, 1, 0, 1);
                t.Attach (new TextEntry (), 1, 2, 0, 1);
                t.Attach (new Label ("Another field:"), 0, 1, 1, 2);
                t.Attach (new TextEntry (), 1, 2, 1, 2);
                d.Content = t;

                Command custom = new Command ("Custom");
                d.Buttons.Add (new DialogButton (custom));
                d.Buttons.Add (new DialogButton ("Custom OK", Command.Ok));
                d.Buttons.Add (new DialogButton (Command.Cancel));
                d.Buttons.Add (new DialogButton (Command.Ok));

                var r = d.Run (this.ParentWindow);
                db.Label = "Result: " + r.Label;
                d.Dispose ();
            };

            b = new Button ("Show Open File dialog");
            PackStart (b);
            b.Clicked += delegate {
                OpenFileDialog dlg = new OpenFileDialog ("Select a file");
                dlg.InitialFileName = "Some file";
                dlg.Multiselect = true;
                dlg.Filters.Add (new FileDialogFilter ("Xwt files", "*.xwt"));
                dlg.Filters.Add (new FileDialogFilter ("All files", "*.*"));
                if (dlg.Run ())
                    MessageDialog.ShowMessage ("Files have been selected!", string.Join ("\n", dlg.FileNames));
            };

            b = new Button ("Show Save File dialog");
            PackStart (b);
            b.Clicked += delegate {
                SaveFileDialog dlg = new SaveFileDialog ("Select a file");
                dlg.InitialFileName = "Some file";
                dlg.Multiselect = true;
                dlg.Filters.Add (new FileDialogFilter ("Xwt files", "*.xwt"));
                dlg.Filters.Add (new FileDialogFilter ("All files", "*.*"));
                if (dlg.Run ())
                    MessageDialog.ShowMessage ("Files have been selected!", string.Join ("\n", dlg.FileNames));
            };

            b = new Button ("Show Select Folder dialog (Multi select)");
            PackStart (b);
            b.Clicked += delegate {
                SelectFolderDialog dlg = new SelectFolderDialog ("Select some folder");
                dlg.Multiselect = true;
                if (dlg.Run ())
                    MessageDialog.ShowMessage ("Folders have been selected!", string.Join ("\n", dlg.Folders));
            };

            b = new Button ("Show Select Folder dialog (Single select)");
            PackStart (b);
            b.Clicked += delegate {
                SelectFolderDialog dlg = new SelectFolderDialog ("Select a folder");
                dlg.Multiselect = false;
                if (dlg.Run ())
                    MessageDialog.ShowMessage ("Folders have been selected!", string.Join ("\n", dlg.Folders));
            };

            b = new Button ("Show Select Color dialog");
            PackStart (b);
            b.Clicked += delegate {
                SelectColorDialog dlg = new SelectColorDialog ("Select a color");
                dlg.SupportsAlpha = true;
                dlg.Color = Xwt.Drawing.Colors.AliceBlue;
                if (dlg.Run (ParentWindow))
                    MessageDialog.ShowMessage ("A color has been selected!", dlg.Color.ToString ());
            };

            b = new Button("Show window shown event");
            PackStart(b);
            b.Clicked += delegate
            {
                Window w = new Window();
                w.Decorated = false;
                Button c = new Button("This is a window with events on");
                w.Content = c;
                c.Clicked += delegate
                {
                    w.Dispose();
                };
                w.Shown += (sender, args) => MessageDialog.ShowMessage("My Parent has been shown");
                w.Hidden += (sender, args) => MessageDialog.ShowMessage("My Parent has been hidden");

                w.Show();

            };
        }
 public DialogButton GetCommandButton(Command cmd)
 {
     return(this.FirstOrDefault(b => b.Command == cmd));
 }