protected void OnOpenActionActivated(object sender, EventArgs e)
        {
            OpenGame dlg = null;

            try
            {
                dlg = new OpenGame(_forum);
                dlg.Initialize();
                Gtk.ResponseType rc = (Gtk.ResponseType)dlg.Run();
                if (rc == Gtk.ResponseType.Ok)
                {
                    Boolean turbo;
                    String  url = dlg.GetURL(out turbo);
                    if (url.Length > 0)
                    {
                        ShowCounter(url, turbo, 1);
                    }
                }
            }
            finally
            {
                if (dlg != null)
                {
                    dlg.Destroy();
                }
            }
        }
Пример #2
0
        protected override void OnResponse(Gtk.ResponseType response_id)
        {
            foreach (Gtk.RadioButton button in QueenButton.Group)
            {
                if (button.Active)
                {
                    switch (button.Name)
                    {
                    case "QueenButton":
                        PromoteTo = PieceType.Queen;
                        break;

                    case "RookButton":
                        PromoteTo = PieceType.Rook;
                        break;

                    case "BishopButton":
                        PromoteTo = PieceType.Bishop;
                        break;

                    case "KnightButton":
                        PromoteTo = PieceType.Knight;
                        break;
                    }
                }
            }
        }
Пример #3
0
    protected void OnRemoveActionActivated(object sender, EventArgs e)
    {
        Gtk.ResponseType responseType  = Gtk.ResponseType.None;
        LoadedPlugins    loadedPlugins = new LoadedPlugins(plugins);

        try {
            responseType = (Gtk.ResponseType)loadedPlugins.Run();

            if (responseType == Gtk.ResponseType.Ok)
            {
                Gtk.TreeModel     model;
                Gtk.TreeIter      iter;
                Gtk.TreeSelection selection = loadedPlugins.treeView.Selection;

                selection.GetSelected(out model, out iter);

                string pluginToDelete = (model.GetValue(iter, 0).ToString());
                removePlugin(pluginToDelete);
                //plugins.RemovePlugin(pluginToDelete);
                //DockItem item = DockFrame.GetItem(pluginToDelete);
                //item.Visible = false;
                //dockFrame.RemoveItem(item);
                SaveLayout();
            }
        }
        finally {
            loadedPlugins.Hide();
            loadedPlugins.Dispose();
        }
    }
        Gtk.Button AddButton(string stockId, Gtk.ResponseType response, bool hasDefault)
        {
            Stetic.Wrapper.Button wrapper;
            Gtk.Button            button;

            button  = (Gtk.Button)Registry.NewInstance("Gtk.Button", proj);
            wrapper = (Stetic.Wrapper.Button)ObjectWrapper.Lookup(button);
            if (stockId != null)
            {
                wrapper.Type    = Button.ButtonType.StockItem;
                wrapper.StockId = stockId;
            }
            else
            {
                wrapper.Type  = Button.ButtonType.TextOnly;
                wrapper.Label = button.Name;
            }
            wrapper.ResponseId = (int)response;

            Stetic.Wrapper.Container actionArea = Stetic.Wrapper.Container.Lookup(dialog.ActionArea);
            actionArea.Add(button);

            button.CanDefault  = true;
            wrapper.HasDefault = hasDefault;

            if (stockId == Gtk.Stock.Help)
            {
                ((Gtk.ButtonBox)actionArea.Wrapped).SetChildSecondary(button, true);
            }

            return(button);
        }
Пример #5
0
    /// <summary>
    /// Ask if really continue if unsaved changes.
    /// </summary>
    /// <param name="act">What we would do ("quit", "close", "open another file" or such)</param>
    /// <returns>True if continue otherwise false</returns>
    private bool ChangeConfirm(string act)
    {
        if (UndoManager.IsDirty)
        {
            Gtk.MessageDialog md = new Gtk.MessageDialog(MainWindow,
                                                         Gtk.DialogFlags.DestroyWithParent,
                                                         Gtk.MessageType.Warning,
                                                         Gtk.ButtonsType.None,
                                                         "Continue without saving changes?" + Environment.NewLine + Environment.NewLine + "If you " + act + " without saving, changes since the last save will be discarded.");
            md.AddButton(Gtk.Stock.Cancel, Gtk.ResponseType.Cancel);
            md.AddButton("Save and close", Gtk.ResponseType.Accept);
            md.AddButton("Discard Changes", Gtk.ResponseType.Yes);

            Gtk.ResponseType result = (Gtk.ResponseType)md.Run();
            md.Destroy();
            if (result == Gtk.ResponseType.Accept)
            {
                Save(false);
                return(true);
            }
            else if (result != Gtk.ResponseType.Yes)
            {
                return(false);
            }
        }
        return(true);
    }
Пример #6
0
 public void AddButton(string stock_id, Gtk.ResponseType response, bool isDefault)
 {
     Gtk.Button button = new Gtk.Button(stock_id);
     button.CanDefault = true;
     button.Show();
     AddButton(button, response, isDefault);
 }
Пример #7
0
        static private bool DlgSelectFile(string back, string title, Gtk.Window main, Gtk.FileChooserAction action, ref string fileName, string filter)
        {
            var dlg = new Gtk.FileChooserDialog(
                back, title, main, action,
                "Cancel", Gtk.ResponseType.Cancel,
                "Ok", Gtk.ResponseType.Ok
                );

            var fileFilter = new  Gtk.FileFilter();

            try {
                fileFilter.Name = filter.Substring(filter.IndexOf(".") + 1) + " files";
            } catch (Exception) {
                fileFilter.Name = filter;
            }

            fileFilter.AddPattern(filter);
            dlg.AddFilter(fileFilter);
            dlg.SetFilename(fileName);
            Gtk.ResponseType result = (Gtk.ResponseType)dlg.Run();

            fileName = dlg.Filename;
            dlg.Destroy();
            return(result == Gtk.ResponseType.Ok);
        }
Пример #8
0
        public static DialogResult ToEto(this Gtk.ResponseType result)
        {
            switch (result)
            {
            case Gtk.ResponseType.None:
                return(DialogResult.None);

            case Gtk.ResponseType.Reject:
                return(DialogResult.Abort);

            case Gtk.ResponseType.Accept:
                return(DialogResult.Ignore);

            case Gtk.ResponseType.Ok:
                return(DialogResult.Ok);

            case Gtk.ResponseType.Cancel:
                return(DialogResult.Cancel);

            case Gtk.ResponseType.Yes:
                return(DialogResult.Yes);

            case Gtk.ResponseType.No:
                return(DialogResult.No);

            default:
                return(DialogResult.None);
            }
        }
Пример #9
0
        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();
                }
            }
        }
Пример #10
0
        protected void AddButton(string stock_id, Gtk.ResponseType response, bool is_default)
        {
            Gtk.Button button = new Gtk.Button(stock_id);
            button.CanDefault = true;

            AddButton(button, response, is_default);
        }
Пример #11
0
    // Shows a dialogue to the user and lets him cancel the operation. The dialog information depends on
    // this class configuration: depends if the session is going to be inserted in a new session or an
    // existing one.
    // Returns
    public Gtk.ResponseType showImportConfirmation()
    {
        string message;
        string sessionName = getSessionName(sourceFile, sourceSession);

        if (importsToNew())
        {
            // We don't need any confirmation to import into a new session (the user could delete it easily if it was a mistake)
            return(Gtk.ResponseType.Ok);
        }
        else
        {
            // If the user is importing it into an existing session we require a confirmation.
            // This is very hard to Undo.
            string sessionInformation = String.Format(Catalog.GetString("Session name: {0}\n" +
                                                                        "from file: {1}"), sessionName, sourceFile);
            message = String.Format(Catalog.GetString("The current session will be modified. The data from:") + "\n\n" +
                                    sessionInformation + "\n\n" +
                                    Catalog.GetString("Will be imported into the current session."));

            Gtk.MessageDialog confirmationDialog = new Gtk.MessageDialog(parentWindow, Gtk.DialogFlags.Modal, Gtk.MessageType.Question, Gtk.ButtonsType.OkCancel, message);
            confirmationDialog.Title = Catalog.GetString("Import session?");
            Gtk.ResponseType response = (Gtk.ResponseType)confirmationDialog.Run();

            confirmationDialog.Destroy();

            return(response);
        }
    }
Пример #12
0
        protected void OnRemoveActionActivated(object sender, EventArgs e)
        {
            Gtk.ResponseType responseType  = Gtk.ResponseType.None;
            LoadedPlugins    loadedPlugins = new LoadedPlugins(plugins);

            try {
                responseType = (Gtk.ResponseType)loadedPlugins.Run();

                if (responseType == Gtk.ResponseType.Ok)
                {
                    Gtk.TreeModel  treeModel;
                    Gtk.TreeIter   iter;
                    Gtk.TreePath[] selectedRows = null;
                    selectedRows = loadedPlugins.treeView.Selection.GetSelectedRows();

                    for (int i = 0; i < selectedRows.Length; i++)
                    {
                        loadedPlugins.lsLoadedPlugins.GetIter(out iter, selectedRows[i]);
                        string          pluginPath = (string)loadedPlugins.lsLoadedPlugins.GetValue(iter, 0);
                        PluginInfo      pluginInfo = plugins.Plugins.Find(x => x.codeBase == pluginPath);
                        List <IService> services   = plugins.GetServices(pluginInfo);

                        foreach (IService service in services)
                        {
                            plugins.RemovePlugin(pluginInfo.codeBase);
                            (service as IPlugin).UnInit(null);
                        }
                    }
                }
            }
            finally {
                loadedPlugins.Hide();
            }
        }
        protected void OnBtnEODClicked(object sender, EventArgs e)
        {
            DayTimes dlg = null;

            try
            {
                dlg = new DayTimes(_voteCount);

                Gtk.ResponseType rc = (Gtk.ResponseType)dlg.Run();
                if (rc == Gtk.ResponseType.Ok)
                {
                    Int32    day;
                    Int32    startPost;
                    DateTime endTime;
                    dlg.GetDayBoundaries(out day, out startPost, out endTime);
                    _voteCount.SetDayBoundaries(day, startPost, endTime);
                    _voteCount.ChangeDay(day);
                    _voteCount.Refresh();
                }
            }
            finally
            {
                if (dlg != null)
                {
                    dlg.Destroy();
                }
            }
        }
        public static void SaveFile()
        {
            if (openFile == "")
            {
                Gtk.FileChooserDialog fcd = new Gtk.FileChooserDialog("Save File", null, Gtk.FileChooserAction.Save);
                fcd.AddButton(Gtk.Stock.Cancel, Gtk.ResponseType.Cancel);
                fcd.AddButton(Gtk.Stock.Open, Gtk.ResponseType.Ok);
                fcd.DefaultResponse = Gtk.ResponseType.Ok;
                fcd.SelectMultiple  = false;

                Gtk.ResponseType response = (Gtk.ResponseType)fcd.Run();
                if (response != Gtk.ResponseType.Ok)
                {
                    fcd.Destroy();
                    return;
                }

                SetOpenFile(fcd.Filename);
                fcd.Destroy();
            }
            using (StreamWriter sr = new StreamWriter(openFile))
            {
                sr.Write(TextEditorApp.MainWindow.View.Buffer.Text);
            }
        }
Пример #15
0
        public static string SaveFile(IEnumerable <FileSpecification> fileSpecifications)
        {
            using (var fcd = new Gtk.FileChooserDialog("Save File", null, Gtk.FileChooserAction.Save))
            {
                fcd.Filter = new Gtk.FileFilter();
                foreach (var specification in fileSpecifications)
                {
                    foreach (var extension in specification.FileExtensions)
                    {
                        fcd.Filter.AddPattern($"*{extension}");
                    }
                }

                fcd.AddButton(Gtk.Stock.Cancel, Gtk.ResponseType.Cancel);
                fcd.AddButton(Gtk.Stock.Save, Gtk.ResponseType.Ok);
                fcd.DefaultResponse = Gtk.ResponseType.Ok;
                fcd.SelectMultiple  = false;
                Gtk.ResponseType response = (Gtk.ResponseType)fcd.Run();
                if (response == Gtk.ResponseType.Ok)
                {
                    return(fcd.Filename);
                }
            }

            return(null);
        }
        protected void OnBtnPlayerListClicked(object sender, EventArgs e)
        {
            PlayerList dlg = null;

            try
            {
                List <String> players = new List <String>(_voteCount.GetPlayerList());
                dlg = new PlayerList(players);

                Gtk.ResponseType rc = (Gtk.ResponseType)dlg.Run();
                if (rc == Gtk.ResponseType.Ok)
                {
                    _voteCount.Census.Clear();
                    players = dlg.GetPlayers();
                    foreach (String p in players)
                    {
                        if (p.Length > 0)
                        {
                            AddToRoster(p);
                        }
                    }
                    _voteCount.CommitRosterChanges();
                    _voteCount.Refresh();
                }
            }
            finally
            {
                if (dlg != null)
                {
                    dlg.Destroy();
                }
            }
        }
Пример #17
0
 protected override void OnResponse(Gtk.ResponseType response_id)
 {
     Debug.WriteLine("Cancel dialog repsonse.");
     if (Canceled != null)
     {
         Canceled(this, EventArgs.Empty);
     }
 }
Пример #18
0
 public Gtk.Button AddCustomButton(string message, Gtk.ResponseType response, bool isDefault)
 {
     Gtk.Button button = new Gtk.Button();
     button.Label      = message;
     button.CanDefault = true;
     button.Show();
     AddButton(button, response, isDefault);
     return(button);
 }
Пример #19
0
        protected override void OnResponse (Gtk.ResponseType response_id)
        {
            if (DepthButton.Active) {
                Measure = StrengthMeasure.Depth;
            } else {
                Measure = StrengthMeasure.Time;
            }

            Value = (int)StrengthValue.Value;
        }
Пример #20
0
        private void InternalResponse(Gtk.ResponseType response_id)
        {
            ResponseNativeDelegate unmanaged = class_abi.BaseOverride <ResponseNativeDelegate>(this.LookupGType(), "response");

            if (unmanaged == null)
            {
                return;
            }

            unmanaged(this.Handle, (int)response_id);
        }
Пример #21
0
        private void AddButton(Gtk.Button button, Gtk.ResponseType response, bool is_default)
        {
            button.Show();

            AddActionWidget(button, response);

            if (is_default)
            {
                DefaultResponse = response;
            }
        }
Пример #22
0
        private void AddButton(Gtk.Button button, Gtk.ResponseType response, bool isDefault)
        {
            AddActionWidget(button, response);

            if (isDefault)
            {
                Default         = button;
                DefaultResponse = response;
                button.GrabDefault();
            }
        }
Пример #23
0
        private void _OnActivated(object sender, EventArgs e)
        {
            Trace.Call(sender, e);

            try {
                if (!(Text.Length > 0))
                {
                    return;
                }

                if (Text.IndexOf("\n") != -1)
                {
                    // seems to be a paste, so let's break it apart
                    string[] msgParts = Text.Split(new char[] { '\n' });
                    if (msgParts.Length > 3)
                    {
                        string msg = String.Format(_("You are going to paste {0} lines. Do you want to continue?"),
                                                   msgParts.Length);
                        Gtk.MessageDialog md = new Gtk.MessageDialog(
                            Frontend.MainWindow,
                            Gtk.DialogFlags.Modal,
                            Gtk.MessageType.Warning,
                            Gtk.ButtonsType.YesNo,
                            msg);
                        Gtk.ResponseType res = (Gtk.ResponseType)md.Run();
                        md.Destroy();
                        if (res != Gtk.ResponseType.Yes)
                        {
                            Text = String.Empty;
                            return;
                        }
                    }
                    foreach (string msg in msgParts)
                    {
                        ExecuteCommand(msg);
                    }
                }
                else
                {
                    ExecuteCommand(Text);
                    AddToHistory(Text, _History.Count - _HistoryPosition);
                    // reset history position to last entry
                    _HistoryPosition = _History.Count - 1;
                }
                Text = String.Empty;
            } catch (Exception ex) {
#if LOG4NET
                _Logger.Error(ex);
#endif
                Frontend.ShowException(null, ex);
            }
        }
Пример #24
0
        public bool PerformRetrySkip()
        {
            error_response   = Gtk.ResponseType.None;
            RetrySkipVisible = true;

            error_response_event     = new AutoResetEvent(false);
            error_response_ack_event = new AutoResetEvent(false);
            error_response_event.WaitOne();

            RetrySkipVisible = false;

            return(error_response == Gtk.ResponseType.Yes);
        }
Пример #25
0
        private void SaveFile(Message msg)
        {
            Gtk.FileChooserDialog fcd = new Gtk.FileChooserDialog("Save File", null, Gtk.FileChooserAction.SelectFolder);
            fcd.AddButton(Gtk.Stock.Cancel, Gtk.ResponseType.Cancel);
            fcd.AddButton(Gtk.Stock.Save, Gtk.ResponseType.Ok);
            fcd.DefaultResponse = Gtk.ResponseType.Ok;
            fcd.SelectMultiple  = false;

            Gtk.ResponseType response = (Gtk.ResponseType)fcd.Run();
            if (response == Gtk.ResponseType.Ok)
            {
                File.WriteAllBytes(fcd.Filename + "/" + msg.fileName, msg.file);
            }
            fcd.Destroy();
        }
Пример #26
0
        protected void AddButton(Gdk.Pixbuf pixbuf, string label_text, Gtk.ResponseType response, bool is_default)
        {
            Gtk.Button button = new Gtk.Button();
            Gtk.Image  image  = new Gtk.Image(pixbuf);
            // NOTE: This property is new to GTK+ 2.10, but we don't
            //       really need the line because we're just setting
            //       it to the default value anyway.
            //button.ImagePosition = Gtk.PositionType.Left;
            button.Image        = image;
            button.Label        = label_text;
            button.UseUnderline = true;
            button.CanDefault   = true;

            AddButton(button, response, is_default);
        }
Пример #27
0
        public void Run()
        {
            Gtk.FileChooserDialog fcd = new Gtk.FileChooserDialog("Open File", null, Gtk.FileChooserAction.Open);
            fcd.AddButton(Gtk.Stock.Cancel, Gtk.ResponseType.Cancel);
            fcd.AddButton(Gtk.Stock.Open, Gtk.ResponseType.Ok);
            fcd.DefaultResponse = Gtk.ResponseType.Ok;
            fcd.SelectMultiple  = false;

            Gtk.ResponseType response = (Gtk.ResponseType)fcd.Run();
            if (response == Gtk.ResponseType.Ok)
            {
                TextEditorApp.OpenFile(fcd.Filename);
            }
            fcd.Destroy();
        }
Пример #28
0
        private void InternalResponse(Gtk.ResponseType response_id)
        {
            ResponseNativeDelegate unmanaged = null;

            unsafe {
                IntPtr *raw_ptr = (IntPtr *)(((long)this.LookupGType().GetThresholdType().GetClassPtr()) + (long)class_abi.GetFieldOffset("response"));
                unmanaged = (ResponseNativeDelegate)Marshal.GetDelegateForFunctionPointer(*raw_ptr, typeof(ResponseNativeDelegate));
            }
            if (unmanaged == null)
            {
                return;
            }

            unmanaged(this.Handle, (int)response_id);
        }
Пример #29
0
        public static bool ShowReconnectDialog(Gtk.Window parent)
        {
            Trace.Call(parent);

            Gtk.MessageDialog md = new Gtk.MessageDialog(parent,
                                                         Gtk.DialogFlags.Modal, Gtk.MessageType.Error,
                                                         Gtk.ButtonsType.OkCancel, _("The frontend has lost the connection to the server.\nDo you want to reconnect now?"));
            Gtk.ResponseType res = (Gtk.ResponseType)md.Run();
            md.Destroy();

            if (res != Gtk.ResponseType.Ok)
            {
                Quit();
                return(false);
            }

            while (true)
            {
                try {
                    Frontend.ReconnectEngineToGUI();
                    // yay, we made it
                    _InReconnectHandler = false;
                    break;
                } catch (Exception e) {
#if LOG4NET
                    _Logger.Error("ShowReconnectDialog(): Reconnect failed, exception:", e);
#endif
                    var msg = _("Reconnecting to the server has failed.\nDo you want to try again?");
                    // the parent window is hidden (MainWindow) at this
                    // point thus modal doesn't make sense here
                    md = new Gtk.MessageDialog(parent,
                                               Gtk.DialogFlags.DestroyWithParent,
                                               Gtk.MessageType.Error,
                                               Gtk.ButtonsType.OkCancel, msg);
                    md.SetPosition(Gtk.WindowPosition.CenterAlways);
                    res = (Gtk.ResponseType)md.Run();
                    md.Destroy();

                    if (res != Gtk.ResponseType.Ok)
                    {
                        // give up
                        Quit();
                        return(false);
                    }
                }
            }
            return(true);
        }
Пример #30
0
        private void AddButton(Gtk.Button button, Gtk.ResponseType response, bool is_default)
        {
            button.Show();

            AddActionWidget(button, response);

            if (is_default)
            {
                DefaultResponse = response;
                button.AddAccelerator("activate",
                                      accel_group,
                                      (uint)Gdk.Key.Escape,
                                      0,
                                      Gtk.AccelFlags.Visible);
            }
        }
Пример #31
0
		void Install ()
		{
			insSeparator.Visible = true;
			boxProgress.Visible = true;
			buttonOk.Sensitive = false;
			
			string txt;
			string errmessage;
			string warnmessage;
			
			ThreadStart oper;
				
			if (uninstallIds == null) {
				installMonitor = new InstallMonitor (globalProgressLabel, mainProgressBar, Catalog.GetString ("Installing Add-ins"));
				oper = new ThreadStart (RunInstall);
				errmessage = Catalog.GetString ("The installation failed!");
				warnmessage = Catalog.GetString ("The installation has completed with warnings.");
			} else {
				installMonitor = new InstallMonitor (globalProgressLabel, mainProgressBar, Catalog.GetString ("Uninstalling Add-ins"));
				oper = new ThreadStart (RunUninstall);
				errmessage = Catalog.GetString ("The uninstallation failed!");
				warnmessage = Catalog.GetString ("The uninstallation has completed with warnings.");
			}
			
			installing = true;
			oper ();
			installing = false;
			
			buttonCancel.Visible = false;
			buttonOk.Label = Gtk.Stock.Close;
			buttonOk.UseStock = true;
			
			if (installMonitor.Success && installMonitor.Warnings.Count == 0) {
				Respond (Gtk.ResponseType.Ok);
				return;
			} else if (installMonitor.Success) {
				txt = "<b>" + warnmessage + "</b>\n\n";
				foreach (string s in installMonitor.Warnings)
					txt += GLib.Markup.EscapeText (s) + "\n";
				response = Gtk.ResponseType.Ok;
				buttonOk.Sensitive = true;
			} else {
				buttonCancel.Label = Gtk.Stock.Close;
				buttonCancel.UseStock = true;
				txt = "<span foreground=\"red\"><b>" + errmessage + "</b></span>\n\n";
				foreach (string s in installMonitor.Errors)
					txt += GLib.Markup.EscapeText (s) + "\n";
				response = Gtk.ResponseType.Cancel;
				buttonOk.Sensitive = true;
			}
			
			ShowMessage (txt);
		}
		public bool PerformRetrySkip ()
		{
			error_response = Gtk.ResponseType.None;
			RetrySkipVisible = true;

			error_response_event = new AutoResetEvent (false);
			error_response_ack_event = new AutoResetEvent (false);
			error_response_event.WaitOne ();

			RetrySkipVisible = false;

			return (error_response == Gtk.ResponseType.Yes);
		}
		private void HandleRetryClicked (object obj, EventArgs args)
		{
			error_response = Gtk.ResponseType.Yes;
			error_response_event.Set ();
		}
		private void HandleSkipClicked (object obj, EventArgs args)
		{
			error_response = Gtk.ResponseType.No;
			error_response_event.Set ();
		}