Esempio n. 1
0
        public void DoAutoUpdateCheck()
        {
            if (!m_Config.CheckForUpdates)
            {
                return;
            }
            if (DateTime.Now < m_Config.NextUpdateCheck)
            {
                return;
            }
            string ver;

            if (UpdatesAvailable(out ver))
            {
                MessageDialog dlg = new MessageDialog(m_Window, DialogFlags.Modal, MessageType.Info, ButtonsType.YesNo, Catalog.GetString("A new version \"{0}\" of OCM is available" + "\nWould you like to go to the download page now?"), ver);
                if ((int)ResponseType.Yes == dlg.Run())
                {
                    dlg.Hide();
                    System.Diagnostics.Process.Start("http://sourceforge.net/projects/opencachemanage/files/");
                }
                else
                {
                    dlg.Hide();
                }
            }
            m_Config.NextUpdateCheck = DateTime.Now.AddDays(m_Config.UpdateInterval);
        }
        /// <summary>
        /// Cancels the send operation
        /// </summary>
        /// <returns>
        /// True, if the user confirms cancelling <see cref="System.Boolean"/>
        /// </returns>
        private bool Cancel()
        {
            MessageDialog dlg = new MessageDialog(null, DialogFlags.Modal, MessageType.Question, ButtonsType.OkCancel,
                                                  Catalog.GetString("Are you sure you want to cancel?"));

            if ((int)ResponseType.Ok == dlg.Run())
            {
                writer.Cancel();
                dlg.Hide();
                return(true);
            }
            dlg.Hide();
            return(false);
        }
Esempio n. 3
0
        private CarritoDialog(Builder builder, Carrito carrito) : base(builder.GetRawOwnedObject("CarritoDialog"))
        {
            builder.Autoconnect(this);
            Carrito               = carrito;
            DefaultResponse       = ResponseType.Close;
            Response             += Dialog_Deleted;
            DeleteEvent          += Dialog_Deleted;
            ErrorMsg.DeleteEvent += (o, a) =>
            {
                a.RetVal = true;
                ErrorMsg.Hide();
            };

            builder.Dispose();
        }
Esempio n. 4
0
        protected virtual void onHintClick(object sender, System.EventArgs e)
        {
            MessageDialog dlg = new MessageDialog(null, DialogFlags.Modal, MessageType.Info, ButtonsType.Ok, geocache.Hint);

            dlg.Run();
            dlg.Hide();
        }
Esempio n. 5
0
        public static void LoadNewDictionaryDialog(object sender, EventArgs e)
        {
            var fch = new Gtk.FileChooserDialog("Vyberte slovník", null, FileChooserAction.Open,
                                                Stock.Open, ResponseType.Ok,
                                                Stock.Cancel, ResponseType.Cancel);
            FileFilter ff = new FileFilter();

            ff.AddPattern("*.txt");
            ff.Name = "Slovník";
            fch.AddFilter(ff);

            try {
                ResponseType choice = (ResponseType)fch.Run();
                if (choice == ResponseType.Ok)
                {
                    System.IO.StreamReader sr = new System.IO.StreamReader(fch.Filename);
                    game.dictionary = new Scrabble.Lexicon.GADDAG(sr);
                    MessageDialog info = new MessageDialog(null, DialogFlags.Modal, MessageType.Info,
                                                           ButtonsType.Close, false, null);
                    info.Text = "Slovník úspěšně načten. Obsahuje:\n" +
                                game.dictionary.WordCount + "\t\t slov\n" +
                                game.dictionary.NodeCount + "\t\t vrcholů";
                    info.Run();
                    info.Hide();
                    info.Destroy();
                }
            }
            catch {  }
            finally { fch.Destroy(); }
        }
Esempio n. 6
0
        private void _viewModel_DialogActions(object sender, CommandArgs args)
        {
            if (args.parameter.Equals("YES"))
            {
                switch (_lastCommand)
                {
                case "NewDic":
                    CustomDicManage.AddACustomDictionary(_viewModel.NewName);
                    break;

                case "ReName":
                    CustomDicManage.ChangeDictionaryName(_viewModel.OpenedDic.Name, _viewModel.NewName);
                    break;

                case "ReMove":
                    WordBook.Custom.Remove(WordBook.Custom[_viewModel.OpenedDic.DBName - 10]);
                    CustomDicManage.DeleteDictionary(_viewModel.OpenedDic.Name);
                    if (WordBook.SelectedDic == _viewModel.OpenedDic.DBName)
                    {
                        WordBook.CustomeDicCounts--;
                        WordBook.SelectedDic = WordBook.CustomeDicCounts > 10 ? WordBook.CustomeDicCounts : 5;
                    }
                    _viewModel.UpdateDicinfo();
                    VisualStateManager.GoToState(this, "BrifeInfo", true);
                    break;

                default: break;
                }
            }
            _lastCommand = null;
            NewDialog.Hide();
            MessageDialog.Hide();
        }
Esempio n. 7
0
 void HandleBattle_toolbuttonClicked(object sender, EventArgs e)
 {
     this.SetControlState(false);
     try
     {
         this.build_attack_dialog();
         this.GameEngine.Battle();
     }
     catch (Exception exp)
     {
         MessageDialog d = new MessageDialog(this.window1, DialogFlags.DestroyWithParent,
                                             MessageType.Error,
                                             ButtonsType.Close,
                                             true,
                                             "<b>{0}</b>: {1}\n<i>{2}</i>",
                                             exp.GetType().ToString(),
                                             exp.Message,
                                             exp.Source);
         d.Title = "Error";
         d.Modal = true;
         this.ConsoleWriteLine(exp.StackTrace);
         d.Run();
         d.Hide();
         d.Dispose();
     }
     this.SetControlState(true);
 }
Esempio n. 8
0
 private void UpdateDistanceFilter()
 {
     if (!String.IsNullOrEmpty(distanceEntry.Text))
     {
         try
         {
             double dist = double.Parse(distanceEntry.Text);
             if (m_app.AppConfig.ImperialUnits)
             {
                 dist = Utilities.MilesToKm(dist);
             }
             CacheStore.GlobalFilters.AddFilterCriteria(FilterList.KEY_DIST, dist);
             clearDistanceButton.Sensitive = true;
         }
         catch
         {
             MessageDialog dlg = new MessageDialog(null, DialogFlags.Modal, MessageType.Error, ButtonsType.Ok,
                                                   Catalog.GetString("Value is not a number"));
             dlg.Run();
             dlg.Hide();
             dlg.Dispose();
             distanceEntry.Changed -= OnChanged;
             distanceEntry.Text     = string.Empty;
             distanceEntry.Changed += OnChanged;;
             return;
         }
     }
     else
     {
         CacheStore.GlobalFilters.RemoveCriteria(FilterList.KEY_DIST);
         clearDistanceButton.Sensitive = false;
     }
 }
Esempio n. 9
0
        /// <summary>Carga un documento de texto.</summary>

        private void VentanaAbrir()
        {
            if (textoCodigo.Modified)
            {
                MessageDialog m = new MessageDialog(this,
                                                    Gtk.DialogFlags.Modal,
                                                    Gtk.MessageType.Question,
                                                    Gtk.ButtonsType.YesNo,
                                                    GetText("Ventana_AbrirModificado"));

                int respuesta = m.Run();
                m.Hide();
                m = null;
                if (!(respuesta == (int)Gtk.ResponseType.Yes))
                {
                    return;
                }
            }

            if (selectorAbrir == null)
            {
                selectorAbrir =
                    new Gtk.FileSelection(GetText("Ventana_DialogoA"));
                selectorAbrir.Modal             = true;
                selectorAbrir.OkButton.Clicked +=
                    new     EventHandler(SelectorAbrirOKPulsado);
                selectorAbrir.CancelButton.Clicked +=
                    new     EventHandler(SelectorCancelPulsado);
                selectorAbrir.DeleteEvent +=
                    new     DeleteEventHandler(OcultarVentana);
                selectorAbrir.Icon = IconManager.GetPixmap("gears.png");
            }
            selectorAbrir.ShowAll();
        }
Esempio n. 10
0
        /// <summary>Crea un nuevo documento.</summary>

        private void VentanaNuevo()
        {
            if (textoCodigo.Modified)
            {
                MessageDialog m = new MessageDialog(
                    this,
                    Gtk.DialogFlags.Modal,
                    Gtk.MessageType.Question,
                    Gtk.ButtonsType.YesNo,
                    GetText("Ventana_NuevoModificado"));


                int respuesta = m.Run();
                m.Hide();
                m = null;
                if (!(respuesta == (int)Gtk.ResponseType.Yes))
                {
                    return;
                }
            }
            nombreFichero        = null;
            textoCodigo.Text     = "";
            textoCodigo.Modified = false;
            textoErrores.Text    = "";
            textoResultado.Text  = "";
        }
 public static void ShowWarningMessage(Window window, string message)
 {
     Dialog dialog = new MessageDialog(window, DialogFlags.DestroyWithParent | DialogFlags.Modal,
             MessageType.Warning, ButtonsType.Ok, message);
         dialog.Run();
         dialog.Hide();
 }
Esempio n. 12
0
    public static void ShowInfoMessageModal(Window window, string message)
    {
        Dialog dialog = new MessageDialog(window, DialogFlags.DestroyWithParent | DialogFlags.Modal,
                                          MessageType.Info, ButtonsType.Ok, message);

        dialog.Run();
        dialog.Hide();
    }
Esempio n. 13
0
 void HandleM_viewNavigationRequested(object o, WebKit.NavigationRequestedArgs args)
 {
     if (contentLoaded)
     {
         m_view.StopLoading();
         if (args.Request.Uri.StartsWith("ocm://"))
         {
             string[] request = args.Request.Uri.Substring(6).Split('/');
             if (request[0].Equals("deleteLog"))
             {
                 MessageDialog dlg = new MessageDialog(null, DialogFlags.Modal, MessageType.Question, ButtonsType.YesNo, Mono.Unix.Catalog.GetString("Are you sure you wish to delete this log?"));
                 if (((int)ResponseType.Yes) == dlg.Run())
                 {
                     dlg.Hide();
                     m_App.CacheStore.PurgeLogsByKey(new String[] { request[1] });
                     m_App.RefreshAll();
                 }
                 dlg.Hide();
             }
             else if (request[0].Equals("editLog"))
             {
                 OfflineLogDialog dlg = new OfflineLogDialog();
                 dlg.MainWin    = m_Win;
                 dlg.useFullLog = true;
                 ocmengine.CacheLog log = m_App.CacheStore.GetCacheLogByKey(request[1]);
                 dlg.Log = log;
                 if ((int)ResponseType.Ok == dlg.Run())
                 {
                     log = dlg.Log;
                     m_App.CacheStore.AddLog(log.CacheCode, log);
                     dlg.Hide();
                     m_App.RefreshAll();
                 }
                 dlg.Hide();
             }
         }
         else
         {
             // System.Diagnostics.Process.Start(args.Request.Uri);
             Helper.ProcessStartURL(args.Request.Uri);
         }
     }
 }
Esempio n. 14
0
 void on_about1_activate(object o, EventArgs e)
 {
     using (Dialog dialog = new MessageDialog(null, DialogFlags.DestroyWithParent,
                                              MessageType.Info, ButtonsType.Close,
                                              "MapDesigner by Hugh Perkins\n\nBuilt using C#, GTK#, GTK, Tao, SDL, OpenGL, Spring"))
     {
         dialog.Run();
         dialog.Hide();
     }
 }
 private void ModalDialogWindowWork(MessageType messageType, string message)
 {
     using (_dialog = new MessageDialog(_parentWindow, DialogFlags.Modal, messageType, ButtonsType.Ok, message))
     {
         var response = _dialog.Run();
         if ((ResponseType)response == ResponseType.Ok)
         {
             _dialog.Hide();
         }
     }
 }
        protected virtual void OnRestoreButtonClicked(object sender, System.EventArgs e)
        {
            MessageDialog dlg = new MessageDialog(null, DialogFlags.Modal, MessageType.Question, ButtonsType.YesNo, String.Format(Catalog.GetString("Are really want to delete all maps and restore the default maps?")));

            if ((int)ResponseType.Yes == dlg.Run())
            {
                m_maps = MapManager.GetMapsFromFile("maps/defaultmaps.xml");
                ReloadMaps();
            }
            dlg.Hide();
        }
 private void ShowDialog(string text, MessageType type)
 {
     using (Dialog dialog = new MessageDialog(this,
                                              DialogFlags.DestroyWithParent,
                                              type,
                                              ButtonsType.Ok,
                                              text))
     {
         dialog.Run();
         dialog.Hide();
     }
 }
Esempio n. 18
0
 public void AddTool(ExternalTool tool)
 {
     if (m_tools.ContainsKey(tool.Name))
     {
         MessageDialog dlg = new MessageDialog(null, DialogFlags.Modal, MessageType.Question, ButtonsType.YesNo,
                                               String.Format(Catalog.GetString("Are you sure you wish to " +
                                                                               "overwrite \"{0}\"?"), tool.Name));
         if ((int)ResponseType.Yes != dlg.Run())
         {
             dlg.Hide();
             return;
         }
         else
         {
             dlg.Hide();
             m_tools.Remove(tool.Name);
         }
     }
     m_tools.Add(tool.Name, tool);
     UpdateETFile();
 }
Esempio n. 19
0
 public void AddFilter(QuickFilter filter)
 {
     if (m_filters.ContainsKey(filter.Name))
     {
         MessageDialog dlg = new MessageDialog(null, DialogFlags.Modal, MessageType.Question, ButtonsType.YesNo,
                                               String.Format(Catalog.GetString("Are you sure you wish to " +
                                                                               "overwrite \"{0}\"?"), filter.Name));
         if ((int)ResponseType.Yes != dlg.Run())
         {
             dlg.Hide();
             return;
         }
         else
         {
             dlg.Hide();
             m_filters.Remove(filter.Name);
         }
     }
     m_filters.Add(filter.Name, filter);
     UpdateQFFile();
 }
Esempio n. 20
0
    public void GameOver(string causaDaMorte)
    {
        isGameOver = true;
        Dialog dialog = new MessageDialog(this,
                                          DialogFlags.Modal | DialogFlags.DestroyWithParent,
                                          MessageType.Info,
                                          ButtonsType.Ok,
                                          $"Perdeu{Environment.NewLine}Causa da morte: {causaDaMorte}");

        dialog.Run();
        dialog.Hide();
    }
Esempio n. 21
0
        protected virtual void OnRemoveClick(object sender, System.EventArgs e)
        {
            MessageDialog dlg = new MessageDialog(this, DialogFlags.Modal, MessageType.Question, ButtonsType.YesNo,
                                                  Catalog.GetString("Are you sure you want to remove this filter?"));

            if ((int)ResponseType.No == dlg.Run())
            {
                dlg.Hide();
                dlg.Dispose();
                return;
            }

            dlg.Hide();
            dlg.Dispose();
            Gtk.TreeIter  itr;
            Gtk.TreeModel model;
            if (conditionList.Selection.GetSelected(out model, out itr))
            {
                m_Store.Remove(ref itr);
            }
        }
Esempio n. 22
0
 public void AddProfile(GPSProfile prof)
 {
     if (m_profiles.ContainsKey(prof.Name))
     {
         MessageDialog dlg = new MessageDialog(null, DialogFlags.Modal, MessageType.Question, ButtonsType.YesNo,
                                               String.Format(Catalog.GetString("Are you sure you wish to " +
                                                                               "overwrite \"{0}\"?"), prof.Name));
         if ((int)ResponseType.Yes != dlg.Run())
         {
             dlg.Hide();
             return;
         }
         else
         {
             dlg.Hide();
             m_profiles.Remove(prof.Name);
         }
     }
     m_profiles.Add(prof.Name, prof);
     UpdateProfFile();
 }
Esempio n. 23
0
 private void PopupErrorMessage(IndexOutOfRangeException e)
 {
     using (var errorDialog = new MessageDialog(this,
                                                DialogFlags.DestroyWithParent,
                                                MessageType.Error,
                                                ButtonsType.Close,
                                                e.Message))
     {
         errorDialog.Run();
         errorDialog.ShowAll();
         errorDialog.Hide();
     }
 }
Esempio n. 24
0
        protected virtual void OnDeleteAllClick(object sender, System.EventArgs e)
        {
            MessageDialog dlg = new MessageDialog(this, DialogFlags.Modal, MessageType.Warning, ButtonsType.YesNo,
                                                  Catalog.GetString("Are you sure you want to remove all field notes?"));

            try
            {
                if ((int)ResponseType.Yes == dlg.Run())
                {
                    FieldNotesHandler.ClearFieldNotes(m_Win.App.AppConfig.FieldNotesFile);
                    m_Logs.Clear();
                    PopulateLogs(m_Logs);
                }
                dlg.Hide();
                dlg.Dispose();
            }
            catch (Exception e1)
            {
                dlg.Hide();
                OCMApp.ShowException(e1);
            }
        }
Esempio n. 25
0
 private void PopupDialog(Receipt receipt)
 {
     using (var md = new MessageDialog(this,
                                       DialogFlags.DestroyWithParent,
                                       MessageType.Info,
                                       ButtonsType.Close,
                                       receipt.ToString()))
     {
         md.Run();
         md.ShowAll();
         md.Hide();
     }
 }
    public void Apply(Player player)
    {
        const int delayMessage = 10; // Show message in 5 s

        MessageDialog message = MessageDialog.Instance();

        message.SetMessage(string.Format("Gain extra turn \"{0}\" into \"{1}\" area", amountTurn, targetArea));

        message.Show();
        StartCountdown(delayMessage, () =>
        {
            message.Hide();
        });
    }
Esempio n. 27
0
        private void MessageDialogClicked(object o, EventArgs args)
        {
            using (Dialog dialog = new MessageDialog(this,
                                                     DialogFlags.Modal | DialogFlags.DestroyWithParent,
                                                     MessageType.Info,
                                                     ButtonsType.Ok,
                                                     "This message box has been popped up the following\nnumber of times:\n\n {0}",
                                                     i)) {
                dialog.Run();
                dialog.Hide();
            }

            i++;
        }
Esempio n. 28
0
        /// <summary>
        /// Searches the cache description for HTML IMG tags and downloads the file
        /// to the local file system
        /// </summary>
        public void GrabImages()
        {
            string baseURL = String.Empty;

            if (m_cache.URL != null)
            {
                baseURL = m_cache.URL.Scheme + "://" + m_cache.URL.Host;
            }
            const string    IMG     = "(<[Ii][Mm][Gg])([^sS][^rR]*)([Ss][Rr][Cc]\\s?=\\s?)\"([^\"]*)\"([^>]*>)";
            MatchCollection matches = Regex.Matches(m_Win.CacheList.SelectedCache.LongDesc, IMG);

            if (matches.Count == 0)
            {
                MessageDialog mdlg = new MessageDialog(null, DialogFlags.Modal, MessageType.Info, ButtonsType.Ok, Catalog.GetString("No Images Found."));
                mdlg.Run();
                mdlg.Hide();
                return;
            }

            List <string> files        = new List <string>();
            string        imagesFolder = GetImagesFolder();

            if (!Directory.Exists(imagesFolder))
            {
                Directory.CreateDirectory(imagesFolder);
            }

            foreach (Match match in matches)
            {
                string url = match.Groups[4].Value;
                if (!url.Contains("://"))
                {
                    if (url.StartsWith("/"))
                    {
                        url = baseURL + url;
                    }
                    else
                    {
                        url = baseURL + "/" + url;
                    }
                }
                files.Add(url);
            }

            FileDownloadProgress dlg = new FileDownloadProgress();

            dlg.Icon = m_Win.Icon;
            dlg.Start(files, imagesFolder);
            SetCache(m_Win.CacheList.SelectedCache);
        }
Esempio n. 29
0
        protected virtual void OnDeleteClicked(object sender, System.EventArgs e)
        {
            ExternalTool  tool = GetSelectedTool();
            MessageDialog dlg  = new MessageDialog(this, DialogFlags.Modal, MessageType.Question,
                                                   ButtonsType.YesNo, Catalog.GetString("Are you sure you wish to delete '{0}'"),
                                                   tool.Name);

            if ((int)ResponseType.Yes == dlg.Run())
            {
                m_toolList.DeleteTool(tool.Name);
                RefreshList();
            }
            dlg.Hide();
        }
Esempio n. 30
0
        public void CreateDB()
        {
            FileChooserDialog dlg = new FileChooserDialog(Catalog.GetString("Create database"), null, FileChooserAction.Save, Catalog.GetString("Cancel"), ResponseType.Cancel, Catalog.GetString("Save"), ResponseType.Accept);

            dlg.SetCurrentFolder(AppConfig.DataDirectory);
            dlg.CurrentName = "newdb.ocm";
            FileFilter filter = new FileFilter();

            filter.Name = "OCM Databases";
            filter.AddPattern("*.ocm");
            dlg.AddFilter(filter);
            if (dlg.Run() == (int)ResponseType.Accept)
            {
                if (System.IO.File.Exists(dlg.Filename))
                {
                    dlg.Hide();
                    MessageDialog mdlg = new MessageDialog(null, DialogFlags.Modal, MessageType.Warning, ButtonsType.YesNo, Catalog.GetString("Are you sure you want to overwrite '{0}'"), dlg.Filename);
                    if ((int)ResponseType.No == mdlg.Run())
                    {
                        mdlg.Hide();
                        return;
                    }
                    else
                    {
                        mdlg.Hide();
                        System.IO.File.Delete(dlg.Filename);
                    }
                }
                dlg.Hide();
                AppConfig.DBFile = dlg.Filename;
                m_Store          = new FileStore(dlg.Filename);
                return;
            }
            dlg.Destroy();
            return;
        }
Esempio n. 31
0
    // Called when the state of the playable is set to Paused
    public override void OnBehaviourPause(Playable playable, FrameData info)
    {
        Debug.Log(MethodInfo.GetCurrentMethod().Name + " textString:" + textString);

        // 完了直前のPauseなら
        if (isPauseOnPreFinish)
        {
            // 特に何もしない
        }
        else
        {
            // 非表示にする
            messageDialog.Hide();
        }
    }
            private void OnGameMessage(object o, string user,
						    GameMessageType type)
            {
                string msg;
                switch (type)
                  {
                  case GameMessageType.Draw:
                      msg = "<big><b>{0} offers a draw</b>.\nDo you want to agree?</big>";
                      break;
                  case GameMessageType.Abort:
                      msg = "<big><b>{0} wants to abort the game</b>.\nDo you want to agree?</big>";
                      break;
                  default:
                      return;
                  }
                MessageDialog dlg = new MessageDialog (null,
                                       DialogFlags.
                                       Modal,
                                       MessageType.
                                       Question,
                                       ButtonsType.
                                       YesNo,
                                       true,
                                       msg,
                                       user);
                dlg.Modal = false;
                int ret = dlg.Run ();
                if (ret == (int) ResponseType.Yes)
                    client.CommandSender.
                        SendCommand ("accept " +
                                 user);
                else if (ret == (int) ResponseType.No)
                    client.CommandSender.
                        SendCommand ("decline " +
                                 user);
                dlg.Hide ();
                dlg.Dispose ();
            }
            private void OnConnectionError(object o,
							string reason)
            {
                client.Stop ();
                // show error
                MessageDialog md = new MessageDialog (null,
                                      DialogFlags.
                                      DestroyWithParent,
                                      MessageType.
                                      Error,
                                      ButtonsType.
                                      Close,
                                      String.
                                      Format
                                      ("<b>{0}</b>",
                                       reason));

                md.Run ();
                md.Hide ();
                md.Dispose ();

                menubar.disconnectMenuItem.Sensitive = false;
                menubar.connectMenuItem.Sensitive = true;
                //configwidget.Sensitive = true;
                //Authenticate ();
            }
Esempio n. 34
0
            private static bool AskForConfirmation(Window win,
								string text)
            {
                MessageDialog md = new MessageDialog (win,
                                      DialogFlags.
                                      DestroyWithParent,
                                      MessageType.
                                      Question,
                                      ButtonsType.
                                      YesNo,
                                      String.
                                      Format
                                      ("<b>{0}</b>",
                                       text));

                int res = md.Run ();
                md.Hide ();
                md.Dispose ();
                return res == (int) ResponseType.Yes;
            }
            private void ShowChallengeDialog(MatchChallenge mc)
            {
                StringBuilder buf = new StringBuilder ();
                string rating;

                if (mc.OpponentsRating != 0)
                    rating = mc.OpponentsRating.
                        ToString ();
                else
                    rating = "----";
                buf.Append (String.
                        Format
                        ("<big><b>{0} ({1}) wants to play a {2} game</b></big>\n",
                         mc.Opponent, rating,
                         mc.Category));
                buf.Append (String.
                        Format
                        ("<b><u>Time:</u> {0} </b><i>mins</i>, <b><u>Increment:</u></b> {1}\n",
                         mc.Time, mc.Increment));
                if (mc.Color != null)
                    buf.Append (String.
                            Format
                            ("\n<b><u>Color:</u></b> {0}\n",
                             mc.Color));

                buf.Append
                    ("\n\n<b>Do you want to play?</b>");

                MessageDialog dlg = new MessageDialog (null,
                                       DialogFlags.
                                       Modal,
                                       MessageType.
                                       Question,
                                       ButtonsType.
                                       YesNo,
                                       true,
                                       buf.
                                       ToString
                                       ());
                dlg.Modal = false;
                dlg.GrabFocus ();
                int ret = dlg.Run ();
                if (ret == (int) ResponseType.Yes)
                    client.CommandSender.
                        SendCommand ("accept");
                else if (ret == (int) ResponseType.No)
                    client.CommandSender.
                        SendCommand ("decline");
                dlg.Hide ();
                dlg.Dispose ();
            }
Esempio n. 36
0
	public void StartCompare (WaitCallback done)
	{		
		AdditionalInfoWindow.Visible = false;
		
		progressbar1.Visible = true;						
		progressbar1.Adjustment.Lower = 0;
		progressbar1.Adjustment.Upper = 100;

		// clear our existing content
		if (context != null)
			context.StopCompare ();

		// Go to the actual tree page.
		notebook1.Page = 0;
		
		// now generate new content asynchronously
		context = new CompareContext (reference_loader, target_loader);

		context.ProgressChanged += delegate (object sender, CompareProgressChangedEventArgs e) {
			Application.Invoke (delegate {
				Status = e.Message;
				Progress = e.Progress;
			});
		};
		
		context.Error += delegate (object sender, CompareErrorEventArgs e) {
			Application.Invoke (delegate {
				Console.WriteLine ("ERROR: {0}", e.Message);
				MessageDialog md = new MessageDialog (this, 0, MessageType.Error, ButtonsType.Ok, false,
				                                      e.Message);
				md.Response += delegate (object s, ResponseArgs ra) {
					md.Hide ();
				};
				md.Show();
				Status = String.Format ("Comparison failed at {0}", DateTime.Now);
				Progress = 0.0;
				progressbar1.Visible = false;
			});
		};

		context.Finished += delegate (object sender, EventArgs e) {
			Application.Invoke (delegate {
				DateTime finish_time = DateTime.Now;

				if (context.Comparison != null) {
					Status = String.Format ("Comparison completed at {0}", finish_time);
					
					context.Comparison.PropagateCounts ();
					PopulateTreeFromComparison (context.Comparison);
					Progress = 0.0;

					CompareHistory[] history = Config.Recent[0].History;
				
					if (history == null || history.Length == 0 ||
					    (history[history.Length-1].Extras != context.Comparison.Extra ||
					     history[history.Length-1].Errors != context.Comparison.Warning ||
					     history[history.Length-1].Missing != context.Comparison.Missing ||
					     history[history.Length-1].Niexs != context.Comparison.Niex ||
					     history[history.Length-1].Todos != context.Comparison.Todo)) {
	
						CompareHistory history_entry = new CompareHistory();
						history_entry.CompareTime = finish_time;
						history_entry.Extras = context.Comparison.Extra;
						history_entry.Errors = context.Comparison.Warning;
						history_entry.Missing = context.Comparison.Missing;
						history_entry.Niexs = context.Comparison.Niex;
						history_entry.Todos = context.Comparison.Todo;
						Config.Recent[0].AddHistoryEntry (history_entry);
						Config.Save ();
					}
				} else
					Status = "Comparison not completed - no data returned.";
				
				done (this);
				progressbar1.Visible = false;
			});
		};
		treeStore.Clear ();
		context.Compare ();
	}