Exemplo n.º 1
0
        /*
         * public static void ExportToCSV(Project project) {
         *      FileChooserDialog fChooser;
         *      FileFilter filter;
         *      string outputFile;
         *      CSVExport export;
         *
         *      fChooser = new FileChooserDialog(Catalog.GetString("Select Export File"),
         *                                       window,
         *                                       FileChooserAction.Save,
         *                                       "gtk-cancel",ResponseType.Cancel,
         *                                       "gtk-save",ResponseType.Accept);
         *      fChooser.SetCurrentFolder(MainClass.HomeDir());
         *      fChooser.DoOverwriteConfirmation = true;
         *      filter = new FileFilter();
         *      filter.Name = "CSV File";
         *      filter.AddPattern("*.csv");
         *      fChooser.AddFilter(filter);
         *      if(fChooser.Run() == (int)ResponseType.Accept) {
         *              outputFile=fChooser.Filename;
         *              outputFile = System.IO.Path.ChangeExtension(outputFile,"csv");
         *              export = new CSVExport(project, outputFile);
         *              export.WriteToFile();
         *      }
         *      fChooser.Destroy();
         * }*/

        private void CreateThumbnails(Project project)
        {
            MultimediaFactory factory;
            IFramesCapturer   capturer;
            BusyDialog        dialog;

            dialog = new BusyDialog();
            dialog.TransientFor = mainWindow;
            dialog.Message      = Catalog.GetString("Creating video thumbnails. This can take a while.");
            dialog.Show();
            dialog.Pulse();

            /* Create all the thumbnails */
            factory  = new MultimediaFactory();
            capturer = factory.getFramesCapturer();
            capturer.Open(project.Description.File.FilePath);
            foreach (Play play in project.AllPlays())
            {
                try {
                    capturer.SeekTime(play.Start.MSeconds + ((play.Stop - play.Start).MSeconds / 2),
                                      true);
                    play.Miniature = capturer.GetCurrentFrame(Constants.THUMBNAIL_MAX_WIDTH,
                                                              Constants.THUMBNAIL_MAX_HEIGHT);
                    dialog.Pulse();
                } catch (Exception ex) {
                    Log.Exception(ex);
                }
            }
            capturer.Dispose();
            dialog.Destroy();
        }
Exemplo n.º 2
0
        private void DoTranslationUpdate(IList <Translation> translations)
        {
            _agsEditor.SaveGameFiles();
            CompileMessages errors = (CompileMessages)BusyDialog.Show("Please wait while the translation(s) are updated...", new BusyDialog.ProcessingHandler(UpdateTranslationsProcess), translations);

            _guiController.ShowOutputPanel(errors);
            _guiController.ShowMessage("Translation(s) updated.", MessageBoxIcon.Information);
        }
Exemplo n.º 3
0
        public IBusyDialog BusyDialog(string message)
        {
            BusyDialog dialog;

            dialog = new BusyDialog();
            dialog.TransientFor = mainWindow as Gtk.Window;
            dialog.Message      = message;
            return(dialog);
        }
Exemplo n.º 4
0
        private void btnDeleteSelected_Click(object sender, EventArgs e)
        {
            using (var uow = UnitOfWorkFactory.CreateUnitOfWork())
            {
                List <ClientEntity> itemsToDelete = new List <ClientEntity>();
                var undeletableIds   = uow.ClientRepository.GetClientIdsLinkedToFarms();
                int undeletableCount = 0;
                foreach (DataGridViewRow row in dataGridClients.Rows)
                {
                    ClientEntity doc = (ClientEntity)row.DataBoundItem;
                    if (Convert.ToBoolean(row.Cells[0].Value))
                    {
                        itemsToDelete.Add(doc);

                        if (undeletableIds.Contains(doc.Id))
                        {
                            undeletableCount++;
                        }
                    }
                }

                if (itemsToDelete.Count() > 0)
                {
                    if (undeletableCount > 0)
                    {
                        if (MessageBox.Show(string.Format("{0} client(s) cannot be deleted because they are linked to one or more farms. Would you like to continue?", undeletableCount), "Info", MessageBoxButtons.YesNo) == DialogResult.No)
                        {
                            return;
                        }
                        itemsToDelete.RemoveAll(doc => undeletableIds.Contains(doc.Id));
                    }

                    if (itemsToDelete.Count() > 0 && MessageBox.Show("Are you sure you want to delete the " + itemsToDelete.Count.ToString() + " selected clients(s)?", "Delete?", MessageBoxButtons.YesNo) == DialogResult.Yes)
                    {
                        BusyDialog dialog = new BusyDialog();
                        dialog.ShowMessage("Deleting...", this.FindForm());
                        //await CottonDBMS.Cloud.Caching.ClientCache.InvalidateAsync();
                        uow.ClientRepository.BulkDelete(itemsToDelete);
                        uow.SaveChanges();
                        dialog.Close();
                        refresh();
                    }
                }
                else
                {
                    MessageBox.Show("No records were selected to delete.");
                }
            }
        }
Exemplo n.º 5
0
        private void ReplaceGameTextWithTranslation(Translation translation)
        {
            _agsEditor.SaveGameFiles();

            if (!CheckAllTranslationsAreWritable())
            {
                return;
            }

            translation.LoadData();
            CompileMessages errors = (CompileMessages)BusyDialog.Show("Please wait while the game text is replaced...", new BusyDialog.ProcessingHandler(ReplaceGameTextWithTranslationProcess), translation);

            _guiController.ShowOutputPanel(errors);
            Factory.Events.OnRefreshAllComponentsFromGame();
            _agsEditor.SaveGameFiles();
            _guiController.ShowMessage("Game text replaced with the translation text.", MessageBoxIcon.Information);
        }
Exemplo n.º 6
0
        public IBusyDialog BusyDialog(string message, object parent = null)
        {
            BusyDialog dialog;
            Window     parentWindow;

            if (parent != null)
            {
                parentWindow = (parent as Widget).Toplevel as Gtk.Window;
            }
            else
            {
                parentWindow = mainWindow as Gtk.Window;
            }
            dialog         = new BusyDialog(parentWindow);
            dialog.Message = message;
            return(dialog);
        }
Exemplo n.º 7
0
        private void CheckForUpdates()
        {
            try
            {
                string dataDownload = (string)BusyDialog.Show("Please wait while we check for updates...", new BusyDialog.ProcessingHandler(DownloadUpdateStatusThread), null);

                XmlDocument doc = new XmlDocument();
                doc.LoadXml(dataDownload);
                string             newVersionName;
                VersionCheckStatus status = CompareVersionWithXML(doc, "CurrentVersion", out newVersionName);

                if (status == VersionCheckStatus.ServerNewer)
                {
                    if (_guiController.ShowQuestion("A newer version of AGS (" + newVersionName + ") is available on the AGS website. Would you like to go there now?") == DialogResult.Yes)
                    {
                        LaunchBrowserAtAGSWebsite();
                    }
                }
                else if (status == VersionCheckStatus.ThisNewer)
                {
                    // This is newer than the website version, so it must be a beta
                    // version. So, see if a newer beta is available.
                    status = CompareVersionWithXML(doc, "BetaVersion", out newVersionName);
                    if (status == VersionCheckStatus.ServerNewer)
                    {
                        if (_guiController.ShowQuestion("A newer beta version of AGS (" + newVersionName + ") is available on the AGS forums. Would you like to go there now?") == DialogResult.Yes)
                        {
                            LaunchBrowserAtAGSForums();
                        }
                    }
                    else
                    {
                        _guiController.ShowMessage("There are no further beta updates at this time.", MessageBoxIcon.Information);
                    }
                }
                else
                {
                    _guiController.ShowMessage("This version of AGS is up to date.", MessageBoxIcon.Information);
                }
            }
            catch (Exception ex)
            {
                _guiController.ShowMessage("Unable to check for updates. Your internet connection may be down.\nPlease visit the AGS website to see if an updated version is available.\n\nError details: " + ex.Message, MessageBoxIcon.Warning);
            }
        }
Exemplo n.º 8
0
        public void Run(Form form = null)
        {
            Action run = () =>
            {
                while (m_actions.Count > 0)
                {
                    try
                    {
                        m_actions[0].Run();
                    }
                    catch (Exception ex)
                    {
                        Dbg.Log(ex.Message);
                    }
                    finally
                    {
                        m_actions.RemoveAt(0);
                    }
                }
            };

            var dlg = new BusyDialog();

            var task = new Task(run, TaskCreationOptions.LongRunning);

            task.OnSuccess(dlg.Dispose);
            task.Start();

            if (form != null)
            {
                dlg.ShowDialog(form);
            }
            else
            {
                dlg.ShowDialog();
            }

            Save();
        }
Exemplo n.º 9
0
    public static T Execute <T>(DependencyObject parent, Func <T> action)
    {
        Window parentWindow = null;

        if (parent is Window)
        {
            parentWindow = parent as Window;
        }
        else
        {
            parentWindow = Window.GetWindow(parent);
        }
        T          val = default(T);
        Exception  le  = null;
        BusyDialog bd  = new BusyDialog();

        bd.Owner = parentWindow;
        ThreadPool.QueueUserWorkItem((o) =>
        {
            try
            {
                val = action();
            }
            catch (Exception ex)
            {
                le = ex;
            }
            bd.EndDialog();
        });
        bd.ShowDialog();
        if (le != null)
        {
            Trace.WriteLine(le.ToString());
            throw new Exception("Execute Exception", le);
        }
        return(val);
    }
Exemplo n.º 10
0
        bool RegisterClient()
        {
            var busyDlg = new BusyDialog();

            busyDlg.Message = "Initialisation...";


            Action <Task <IEnumerable <ProfileInfo> > > onSuccess = t => busyDlg.Dispose();

            Action <Task> onErr = t =>
            {
                busyDlg.Dispose();
                //System.Windows.Forms.MessageBox.Show(t.Exception.InnerException.Message , null);
            };

            IEnumerable <ProfileInfo> profiles = null;
            var task = new Task <IEnumerable <ProfileInfo> >(() => profiles = Program.DialogManager.Profiles,
                                                             TaskCreationOptions.LongRunning);

            task.OnSuccess(onSuccess);
            task.OnError(onErr);

            task.Start();
            busyDlg.ShowDialog();

            if (profiles == null || !profiles.Any())
            {
                System.Windows.Forms.MessageBox.Show("Aucune réponse du serveur. Veuillez réessayer ultérieurement.",
                                                     AppText.APP_NAME, System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);

                Exit();
                return(false);
            }

            ClientInfo clInfo;

            using (var dlg = new ProfileDialog(profiles))
            {
                if (dlg.ShowDialog() != System.Windows.Forms.DialogResult.OK)
                {
                    Exit();
                }

                clInfo = ClientInfo.CreateClient(dlg.SelectedProfile.ProfileID);
                clInfo.ContaclEMail = dlg.ContactEMail;
                clInfo.ContactName  = dlg.Contact;
                clInfo.ContactPhone = dlg.ContactPhone;
            }


            using (var dlg = new ConnectionDialog(clInfo))
            {
                dlg.ShowDialog();

                if (!dlg.IsRegistered)
                {
                    Exit();
                    return(false);
                }

                m_clInfo = Program.Settings.ClientInfo;
                DialogEngin.WriteHubDialog(SettingsManager.GetClientDialogFilePath(m_clInfo.ClientID),
                                           m_clInfo.ClientID, Enumerable.Empty <Message>());
            }

            return(true);
        }
Exemplo n.º 11
0
        void PostSetInfoMessage()
        {
            ClientInfo curClInfo = Program.Settings.ClientInfo;
            var        clInfo    = new ClientInfo(curClInfo.ClientID, curClInfo.ProfileID);

            clInfo.ContaclEMail = m_tbEmail.Text.Trim();
            clInfo.ContactName  = m_tbContact.Text.Trim();
            clInfo.ContactPhone = m_tbPhone.Text.Trim();

            byte[] msgData = clInfo.GetBytes();

            var dlg = new BusyDialog();

            Func <bool> postMessage = () =>
            {
                const int TIME_TO_SLEEP = 10 * 1000;
                int       nbAttempts    = 3;


                while (--nbAttempts >= 0)
                {
                    dlg.Message = "Envoi  des données vers le serveur...";
                    uint msgID = Program.DialogManager.SendMessage(Message_t.SetInfo, msgData);

                    if (msgID == 0)
                    {
                        continue;
                    }

                    dlg.Message = "En attente de la réponse du serveur...";
                    Thread.Sleep(TIME_TO_SLEEP);

                    dlg.Message = "Réception des données à partir du serveur...";
                    HubCore.DLG.Message resp = Program.DialogManager.ReceiveMessage(msgID);

                    Dbg.Assert(resp == null || resp.MessageCode == Message_t.Ok);

                    if (resp != null)
                    {
                        dlg.Message = "Transfert terminé.";
                        break;
                    }
                }

                return(nbAttempts >= 0);
            };

            Action <Task> onErr = t =>
            {
                dlg.Dispose();

                if (t.Exception != null)
                {
                    Dbg.Log(t.Exception.InnerException.Message);
                    Program.DialogManager.PostLog("Changement des informations utilisateur. Erreur lors de l'envoi: " +
                                                  t.Exception.InnerException.Message, true);
                }

                MessageBox.Show("Impossible de se connecter au serveur distant. Veuillez réessayer ultérieurement.",
                                null,
                                MessageBoxButtons.OK);
            };

            Action <Task <bool> > onSuccess = t =>
            {
                if (t.Result == false)
                {
                    onErr(t);
                }
                else
                {
                    Program.Settings.ClientInfo = clInfo;
                    ClientInfoChanged?.Invoke();
                    dlg.Dispose();
                }
            };

            var task = new Task <bool>(postMessage, TaskCreationOptions.LongRunning);

            task.OnSuccess(onSuccess);
            task.OnError(onErr);
            task.Start();
            dlg.ShowDialog();
        }