Exemplo n.º 1
0
        /// <summary>
        /// Display a warning indicating that it may be dangerous to change things in the dialog that
        /// is about to open when there are other applications using this project. The warning should only
        /// be shown if, in fact, other applications currently have this project open. Return true to continue,
        /// false to cancel opening the dialog.
        /// </summary>
        /// <returns></returns>
        public static bool WarnOnOpeningSingleUserDialog(LcmCache cache)
        {
            if (!SharedBackendServices.AreMultipleApplicationsConnected(cache))
            {
                return(true);
            }
            string msg = Strings.ksWarnOnOpeningSingleAppDialog.Replace("\\n", Environment.NewLine);

            return(ThreadHelper.ShowMessageBox(null, msg, Strings.ksOtherAppsUsingProjectCaption,
                                               MessageBoxButtons.OKCancel, MessageBoxIcon.Information) == DialogResult.OK);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Display a warning indicating that it may be dangerous to change things that the user has just
        /// asked to change when other applications are using this project. The warning should only be shown
        /// if, in fact, other applications currently have this project open. Return true to continue, false
        /// to discard the changes. This is typically called in response to clicking an OK button in a dialog
        /// which changes dangerous user settings.
        /// </summary>
        /// <returns></returns>
        public static bool WarnOnConfirmingSingleUserChanges(LcmCache cache)
        {
            if (!SharedBackendServices.AreMultipleApplicationsConnected(cache))
            {
                return(true);
            }
            string msg = Strings.ksWarnOnConfirmingSingleAppChanges.Replace("\\n", Environment.NewLine);

            return(ThreadHelper.ShowMessageBox(null, msg, Strings.ksNotAdvisableOtherAppsUsingProjectCaption,
                                               MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes);
        }
Exemplo n.º 3
0
        public bool OnAddCustomField(object argument)
        {
            CheckDisposed();

            // Only allow adding custom fields when a single client is connected.
            if (Cache.NumberOfRemoteClients > 1 || (Cache.ProjectId.IsLocal && Cache.NumberOfRemoteClients > 0))
            {
                MessageBoxUtils.Show(ParentForm, xWorksStrings.ksCustomFieldsCanNotBeAddedDueToRemoteClientsText,
                                     xWorksStrings.ksCustomFieldsCanNotBeAddedDueToRemoteClientsCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return(true);
            }
            if (SharedBackendServices.AreMultipleApplicationsConnected(Cache))
            {
                MessageBoxUtils.Show(ParentForm, xWorksStrings.ksCustomFieldsCanNotBeAddedDueToOtherAppsText,
                                     xWorksStrings.ksCustomFieldsCanNotBeAddedDueToOtherAppsCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return(true);
            }

            AddCustomFieldDlg.LocationType locationType = AddCustomFieldDlg.LocationType.Lexicon;
            string areaChoice = m_mediator.PropertyTable.GetStringProperty("areaChoice", string.Empty);

            switch (areaChoice)
            {
            case "lexicon":
                locationType = AddCustomFieldDlg.LocationType.Lexicon;
                break;

            case "notebook":
                locationType = AddCustomFieldDlg.LocationType.Notebook;
                break;
            }
            using (var dlg = new AddCustomFieldDlg(m_mediator, locationType))
            {
                if (dlg.ShowCustomFieldWarning(this))
                {
                    dlg.ShowDialog(this);
                }
            }

            return(true);               // handled
        }
Exemplo n.º 4
0
        public bool OnAddCustomField(object argument)
        {
            CheckDisposed();

            if (SharedBackendServices.AreMultipleApplicationsConnected(Cache))
            {
                MessageBoxUtils.Show(ParentForm, xWorksStrings.ksCustomFieldsCanNotBeAddedDueToOtherAppsText,
                                     xWorksStrings.ksCustomFieldsCanNotBeAddedDueToOtherAppsCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return(true);
            }

            AddCustomFieldDlg.LocationType locationType = AddCustomFieldDlg.LocationType.Lexicon;
            string areaChoice = m_propertyTable.GetStringProperty("areaChoice", string.Empty);

            switch (areaChoice)
            {
            case "lexicon":
                locationType = AddCustomFieldDlg.LocationType.Lexicon;
                break;

            case "notebook":
                locationType = AddCustomFieldDlg.LocationType.Notebook;
                break;

            case "textsWords":
                locationType = AddCustomFieldDlg.LocationType.Interlinear;
                break;
            }
            using (var dlg = new AddCustomFieldDlg(m_mediator, m_propertyTable, locationType))
            {
                if (dlg.ShowCustomFieldWarning(this))
                {
                    dlg.ShowDialog(this);
                }
            }

            return(true);               // handled
        }
 public void AreMultipleApplicationsConnectedWithNullCache()
 {
     Assert.IsFalse(SharedBackendServices.AreMultipleApplicationsConnected(null));
 }