当前位置: 首页>>代码示例>>C#>>正文


C# Gtk.MessageDialog.AddButton方法代码示例

本文整理汇总了C#中Gtk.MessageDialog.AddButton方法的典型用法代码示例。如果您正苦于以下问题:C# Gtk.MessageDialog.AddButton方法的具体用法?C# Gtk.MessageDialog.AddButton怎么用?C# Gtk.MessageDialog.AddButton使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Gtk.MessageDialog的用法示例。


在下文中一共展示了Gtk.MessageDialog.AddButton方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ShowSaveCheckDialog

        public SaveCheckDialogResult ShowSaveCheckDialog()
        {
            Gtk.MessageDialog saveCheckDialog = new Gtk.MessageDialog(null, Gtk.DialogFlags.Modal, Gtk.MessageType.Question, Gtk.ButtonsType.YesNo, false, "The current document has unsaved changes. Do you wish to save those now?");
            saveCheckDialog.AddButton("Cancel", Gtk.ResponseType.Cancel);

            SaveCheckDialogResult result = SaveCheckDialogResult.Cancel;

            int dialogResult = saveCheckDialog.Run();
            if ((int)Gtk.ResponseType.Yes == dialogResult)
            {
                result = SaveCheckDialogResult.Save;
            }
            else if ((int)Gtk.ResponseType.No == dialogResult)
            {
                result = SaveCheckDialogResult.NoSave;
            }

            saveCheckDialog.Destroy();

            return result;
        }
开发者ID:alfar,项目名称:WordBuilder,代码行数:21,代码来源:FileDialogHelper.cs

示例2: ShowDialog

		public DialogResult ShowDialog(Control parent, MessageBoxButtons buttons)
		{
			Gtk.Widget c = (parent == null) ? null : (Gtk.Widget)parent.ControlObject;
			while (!(c is Gtk.Window) && c != null)
			{
				c = c.Parent;
			}
			control = new Gtk.MessageDialog((Gtk.Window)c, Gtk.DialogFlags.Modal, Convert (Type), Convert(buttons), false, Text);
			control.TypeHint = Gdk.WindowTypeHint.Dialog;
			var caption = Caption ?? ((parent != null && parent.ParentWindow != null) ? parent.ParentWindow.Title : null);
            if (!string.IsNullOrEmpty(caption)) control.Title = caption;
			if (buttons == MessageBoxButtons.YesNoCancel)
			{
				// must add cancel manually
				Gtk.Button b = (Gtk.Button)control.AddButton(Gtk.Stock.Cancel, (int)Gtk.ResponseType.Cancel);
				b.UseStock = true;
			}
			int ret = control.Run();
			control.Destroy();
			return Generator.Convert((Gtk.ResponseType)ret);
		}
开发者ID:hultqvist,项目名称:Eto,代码行数:21,代码来源:MessageBoxHandler.cs

示例3: Load

        public static void Load()
        {
            try
            {
                SetDefaultValues();

                using (FileStream stream = new FileStream(SettingsPath, FileMode.Open))
                {
                    BinaryFormatter bin = new BinaryFormatter();
                    HelperClass hc = (HelperClass)bin.Deserialize(stream);
                    hc.PushValues();
                }
            }
            catch (Exception ex)
            {
                Gtk.MessageDialog md = new Gtk.MessageDialog(null, Gtk.DialogFlags.DestroyWithParent, Gtk.MessageType.Error, Gtk.ButtonsType.Ok, "Couldn´t read Settings!" + Environment.NewLine + ex.Message);
                md.Title = "Error";
                md.AddButton("Restore Settings?", Gtk.ResponseType.Yes);
                Gtk.ResponseType result = (Gtk.ResponseType)md.Run();
                md.Destroy();

                if (result == Gtk.ResponseType.Yes) { Recreate(); }
            }
        }
开发者ID:TimeScience,项目名称:desert-deflicker,代码行数:24,代码来源:MySettings.cs

示例4: ClearRecent

		void ClearRecent ()
		{
			Gtk.MessageDialog md = new Gtk.MessageDialog (null, 
					  0,
					  Gtk.MessageType.Warning, 
					  Gtk.ButtonsType.None,
					  "<b><big>" + Catalog.GetString ("Clear the Recent Documents list?") + "</big></b>");
			
			md.Title = Catalog.GetString ("Clear Recent Documents");
			md.Icon = DockServices.Drawing.LoadIcon ("docky", 22);
			md.SecondaryText = Catalog.GetString ("If you clear the Recent Documents list, you clear the following:\n" +
				"\u2022 All items from the Places \u2192 Recent Documents menu item.\n" +
				"\u2022 All items from the recent documents list in all applications.");
			md.Modal = false;
			
			md.AddButton (Gtk.Stock.Cancel, Gtk.ResponseType.Cancel);
			md.AddButton (Gtk.Stock.Clear, Gtk.ResponseType.Ok);
			md.DefaultResponse = Gtk.ResponseType.Ok;

			md.Response += (o, args) => {
				if (args.ResponseId != Gtk.ResponseType.Cancel)
					Gtk.RecentManager.Default.PurgeItems ();
				md.Destroy ();
			};
			
			md.Show ();
		}
开发者ID:Aurora-and-Equinox,项目名称:docky,代码行数:27,代码来源:RecentFilesProvider.cs

示例5: EmptyTrash

		void EmptyTrash ()
		{
			if (ConfirmTrashDelete) {
				Gtk.MessageDialog md = new Gtk.MessageDialog (null, 
						  0,
						  Gtk.MessageType.Warning, 
						  Gtk.ButtonsType.None,
						  "<b><big>" + Catalog.GetString ("Empty all of the items from the trash?") + "</big></b>");
				md.Icon = DockServices.Drawing.LoadIcon ("docky", 22);
				md.SecondaryText = Catalog.GetString ("If you choose to empty the trash, all items in it\n" +
					"will be permanently lost. Please note that you\n" +
					"can also delete them separately.");
				md.Modal = false;
				
				md.AddButton (Gtk.Stock.Cancel, Gtk.ResponseType.Cancel);
				md.AddButton (Catalog.GetString ("Empty _Trash"), Gtk.ResponseType.Ok);
				md.DefaultResponse = Gtk.ResponseType.Ok;

				md.Response += (o, args) => {
					if (args.ResponseId != Gtk.ResponseType.Cancel)
						PerformEmptyTrash ();
					md.Destroy ();
				};
				
				md.Show ();
			} else {
				PerformEmptyTrash ();
			}
		}
开发者ID:Aurora-and-Equinox,项目名称:docky,代码行数:29,代码来源:TrashDockItem.cs

示例6: AddFilesToProject

		/// <summary>
		/// Adds files to a project, potentially asking the user whether to move, copy or link the files.
		/// </summary>
		public IList<ProjectFile> AddFilesToProject (Project project, FilePath[] files, FilePath[] targetPaths,
			string buildAction)
		{
			Debug.Assert (project != null);
			Debug.Assert (files != null);
			Debug.Assert (targetPaths != null);
			Debug.Assert (files.Length == targetPaths.Length);
			
			int action = -1;
			IProgressMonitor monitor = null;
			
			if (files.Length > 10) {
				monitor = new MessageDialogProgressMonitor (true);
				monitor.BeginTask (GettextCatalog.GetString("Adding files..."), files.Length);
			}
			
			var newFileList = new List<ProjectFile> ();
			
			//project.AddFile (string) does linear search for duplicate file, so instead we use this HashSet and 
			//and add the ProjectFiles directly. With large project and many files, this should really help perf.
			//Also, this is a better check because we handle vpaths and links.
			//FIXME: it would be really nice if project.Files maintained these hashmaps
			var vpathsInProject = new HashSet<FilePath> (project.Files.Select (pf => pf.ProjectVirtualPath));
			var filesInProject = new Dictionary<FilePath,ProjectFile> ();
			foreach (var pf in project.Files)
				filesInProject [pf.FilePath] = pf;
			
			using (monitor)
			{
				for (int i = 0; i < files.Length; i++) {
					FilePath file = files[i];
					
					if (monitor != null) {
						monitor.Log.WriteLine (file);
						monitor.Step (1);
					}
					
					if (FileService.IsDirectory (file)) {
						//FIXME: warning about skipping?
						newFileList.Add (null);
						continue;
					}
					
					FilePath targetPath = targetPaths[i].CanonicalPath;
					Debug.Assert (targetPath.IsChildPathOf (project.BaseDirectory));
					
					var vpath = targetPath.ToRelative (project.BaseDirectory);
					if (vpathsInProject.Contains (vpath)) {
						MessageService.ShowWarning (GettextCatalog.GetString (
							"There is a already a file or link in the project with the name '{0}'", vpath));
						continue;
					}
					
					string fileBuildAction = buildAction;
					if (string.IsNullOrEmpty (buildAction))
						fileBuildAction = project.GetDefaultBuildAction (file);
					
					//files in the target directory get added directly in their current location without moving/copying
					if (file.CanonicalPath == targetPath) {
						//FIXME: MD project system doesn't cope with duplicate includes - project save/load will remove the file
						ProjectFile pf;
						if (filesInProject.TryGetValue (targetPath, out pf)) {
							var link = pf.Link;
							MessageService.ShowWarning (GettextCatalog.GetString (
								"The link '{0}' in the project already includes the file '{1}'", link, file));
							continue;
						}
						pf = new ProjectFile (file, fileBuildAction);
						vpathsInProject.Add (pf.ProjectVirtualPath);
						filesInProject [pf.FilePath] = pf;
						newFileList.Add (pf);
						continue;
					}
					
					//for files outside the project directory, we ask the user whether to move, copy or link
					var md = new Gtk.MessageDialog (
						 IdeApp.Workbench.RootWindow,
						 Gtk.DialogFlags.Modal | Gtk.DialogFlags.DestroyWithParent,
						 Gtk.MessageType.Question, Gtk.ButtonsType.None,
						 GettextCatalog.GetString ("The file {0} is outside the target directory. What would you like to do?", file));

					try {
						Gtk.CheckButton remember = null;
						if (files.Length > 1) {
							remember = new Gtk.CheckButton (GettextCatalog.GetString ("Use the same action for all selected files."));
							md.VBox.PackStart (remember, false, false, 0);
						}
						
						const int ACTION_LINK = 3;
						const int ACTION_COPY = 1;
						const int ACTION_MOVE = 2;
						
						md.AddButton (GettextCatalog.GetString ("_Link"), ACTION_LINK);
						md.AddButton (Gtk.Stock.Copy, ACTION_COPY);
						md.AddButton (GettextCatalog.GetString ("_Move"), ACTION_MOVE);
						md.AddButton (Gtk.Stock.Cancel, Gtk.ResponseType.Cancel);
						md.VBox.ShowAll ();
//.........这里部分代码省略.........
开发者ID:thild,项目名称:monodevelop,代码行数:101,代码来源:ProjectOperations.cs

示例7: AddFilesToProject

		/// <summary>
		/// Adds files to a project, potentially asking the user whether to move, copy or link the files.
		/// </summary>
		public IList<ProjectFile> AddFilesToProject (Project project, FilePath[] files, FilePath targetDirectory,
			string buildAction)
		{
			int action = -1;
			IProgressMonitor monitor = null;
			
			if (files.Length > 10) {
				monitor = new MessageDialogProgressMonitor (true);
				monitor.BeginTask (GettextCatalog.GetString("Adding files..."), files.Length);
			}
			
			var newFileList = new List<ProjectFile> ();
			
			using (monitor) {
				foreach (FilePath file in files) {
					if (monitor != null) {
						monitor.Log.WriteLine (file);
						monitor.Step (1);
					}
					
					if (FileService.IsDirectory (file)) {
						//FIXME: warning about skipping?
						newFileList.Add (null);
						continue;
					}
					
					//files in the project directory get added directly in their current location without moving/copying
					if (file.IsChildPathOf (project.BaseDirectory)) {
						newFileList.Add (project.AddFile (file, buildAction));
						continue;
					}
					
					//for files outside the project directory, we ask the user whether to move, copy or link
					var md = new Gtk.MessageDialog (
						 IdeApp.Workbench.RootWindow,
						 Gtk.DialogFlags.Modal | Gtk.DialogFlags.DestroyWithParent,
						 Gtk.MessageType.Question, Gtk.ButtonsType.None,
						 GettextCatalog.GetString ("The file {0} is outside the project directory. What would you like to do?", file));

					try {
						Gtk.CheckButton remember = null;
						if (files.Length > 1) {
							remember = new Gtk.CheckButton (GettextCatalog.GetString ("Use the same action for all selected files."));
							md.VBox.PackStart (remember, false, false, 0);
						}
						
						const int ACTION_LINK = 3;
						const int ACTION_COPY = 1;
						const int ACTION_MOVE = 2;
						
						md.AddButton (GettextCatalog.GetString ("_Link"), ACTION_LINK);
						md.AddButton (Gtk.Stock.Copy, ACTION_COPY);
						md.AddButton (GettextCatalog.GetString ("_Move"), ACTION_MOVE);
						md.AddButton (Gtk.Stock.Cancel, Gtk.ResponseType.Cancel);
						md.VBox.ShowAll ();
						
						int ret = -1;
						if (action < 0) {
							ret = MessageService.RunCustomDialog (md);
							if (ret < 0)
								return newFileList;
							if (remember != null && remember.Active) action = ret;
						} else {
							ret = action;
						}
						
						var targetName = targetDirectory.Combine (file.FileName);
						
						if (ret == ACTION_LINK) {
							var pf = project.AddFile (file, buildAction);
							pf.Link = project.GetRelativeChildPath (targetName);
							newFileList.Add (pf);
							continue;
						}
						
						try {
							if (MoveCopyFile (file, targetName, ret == ACTION_MOVE))
								newFileList.Add (project.AddFile (targetName, buildAction));
							else
								newFileList.Add (null);
						}
						catch (Exception ex) {
							MessageService.ShowException (ex, GettextCatalog.GetString (
								"An error occurred while attempt to move/copy that file. Please check your permissions."));
							newFileList.Add (null);
						}
					} finally {
						md.Destroy ();
					}
				}
			}
			return newFileList;
		}
开发者ID:Ein,项目名称:monodevelop,代码行数:96,代码来源:ProjectOperations.cs


注:本文中的Gtk.MessageDialog.AddButton方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。