/// ------------------------------------------------------------------------------------
 /// <summary>
 ///
 /// </summary>
 /// ------------------------------------------------------------------------------------
 public static void Initialize(ProjectSettingsDlg dlg)
 {
     if (dlg != null)
     {
         new ProjectSettingsDlgDataSourceSkippingHelper(dlg);
     }
 }
        /// ------------------------------------------------------------------------------------
        /// <summary>
        ///
        /// </summary>
        /// ------------------------------------------------------------------------------------
        private void m_dialog_FormClosed(object sender, FormClosedEventArgs e)
        {
            m_dialog.FormClosed -= m_dialog_FormClosed;

            try
            {
                // Before the grid's settings get saved by the call to SaveSettings below,
                // remove the column we added in the grid so it's display order (and all
                // that stuff) don't get saved. Put this in a try/catch because, it
                // triggers the row enter event in the dialog and the event handler in the
                // dialog references an object that's already null by this point.
                m_grid.Columns.Remove(kLoadColName);
            }
            catch { }

            // Since we interupted the settings being saved in out OnDialogSaveSettings
            // method, force the settings to be saved now.
            ReflectionHelper.CallMethod(m_dialog, "SaveSettings", null);

            if (m_grid != null)
            {
                // Release our event handlers from the grid.
                m_grid.RowsAdded   -= grid_RowsAdded;
                m_grid.RowsRemoved -= m_grid_RowsRemoved;
                m_grid.ColumnDisplayIndexChanged -= m_grid_ColumnDisplayIndexChanged;
                m_grid.CellValueChanged          -= m_grid_CellValueChanged;
                m_grid = null;
            }

            m_dialog = null;
            PaApp.MsgMediator.RemoveColleague(this);
        }
示例#3
0
        private void Settings_Click(object sender, EventArgs e)
        {
            var origCursor = Cursor;

            Cursor = Cursors.WaitCursor;
            var model = new ProjectSettingsViewModel(m_project);

            using (var dlg = new ProjectSettingsDlg(model))
            {
                var result = dlg.ShowDialog(this);
                Cursor = origCursor;
                if (result != DialogResult.OK)
                {
                    return;
                }

                m_project.UpdateSettings(model);
                SaveCurrentProject();

                if (dlg.UpdatedBundle != null)
                {
                    Analytics.Track("UpdateProjectFromBundleData", new Dictionary <string, string>
                    {
                        { "language", m_project.LanguageIsoCode },
                        { "ID", m_project.Id },
                        { "recordingProjectName", m_project.Name },
                        { "bundlePathChanged", (m_project.OriginalBundlePath != model.BundlePath).ToString() }
                    });
                    var project = m_project.UpdateProjectFromBundleData(dlg.UpdatedBundle);
                    project.OriginalBundlePath = model.BundlePath;
                    SetProject(project);
                }
            }
            UpdateDisplayOfProjectInfo();
        }
示例#4
0
        private void ShowProjectScriptPresenterDlg(Func <ProjectExporter, Form> getProjectScriptPresenterDlg)
        {
            EnsureGroupsAreInSynchWithCharactersInUse();

            var model = new ProjectSettingsViewModel(m_project);

            while (m_project.ReferenceText == null)
            {
                string msg;
                using (var dlg = new ProjectSettingsDlg(model))
                {
                    var msgFmt = LocalizationManager.GetString("Project.UnavailableReferenceText",
                                                               "This project uses the {0} reference text, which is no longer available. " +
                                                               "If possible, put the required reference text files in" +
                                                               "\r\n   {1}\r\n" +
                                                               "and then click Retry to use the {0} reference text.\r\n" +
                                                               "Otherwise, to continue and temporarily use the English reference text, click Ignore.\r\n" +
                                                               "Note: to permanently change the reference text used by this project, open the {2} " +
                                                               "dialog box and select the desired reference text on the {3} tab page.");
                    msg = String.Format(msgFmt, m_project.UiReferenceTextName,
                                        m_project.ReferenceTextIdentifier.ProjectFolder,
                                        dlg.Text, dlg.ReferenceTextTabPageName);
                }
                switch (MessageBox.Show(msg, Program.kProduct, MessageBoxButtons.AbortRetryIgnore))
                {
                case DialogResult.Abort: return;

                case DialogResult.Ignore:
                    m_project.ReferenceText = ReferenceText.GetStandardReferenceText(ReferenceTextType.English);
                    break;
                }
            }

            var exporter = new ProjectExporter(m_project);

            if (!IsOkToExport(exporter))
            {
                return;
            }

            using (var dlg = getProjectScriptPresenterDlg(exporter))
            {
                ShowModalDialogWithWaitCursor(dlg);
                ShowLastLocation();
            }
        }
        /// ------------------------------------------------------------------------------------
        /// <summary>
        ///
        /// </summary>
        /// ------------------------------------------------------------------------------------
        public ProjectSettingsDlgDataSourceSkippingHelper(ProjectSettingsDlg dlg)
        {
            m_dialog             = dlg;
            m_dialog.FormClosed += m_dialog_FormClosed;

            m_grid = ReflectionHelper.GetField(m_dialog, "m_grid") as SilGrid;
            if (m_grid == null)
            {
                return;
            }

            // Add our column to allow the user to specify (via check boxes) the
            // data sources he wants PA to skip when loading data sources.
            DataGridViewColumn col = SilGrid.CreateCheckBoxColumn(kLoadColName);

            col.HeaderText = Properties.Resources.kstidLoadColumnHeadingText;
            col.Resizable  = DataGridViewTriState.False;
            m_grid.Columns.Insert(0, col);
            m_grid.AutoResizeColumn(0, DataGridViewAutoSizeColumnMode.ColumnHeader);
            m_grid.RowsAdded += grid_RowsAddedOnLoad;
            m_grid.ColumnDisplayIndexChanged += m_grid_ColumnDisplayIndexChanged;

            PaApp.MsgMediator.AddColleague(this);

            // This is some experimental code used to see if I can remove the click event for
            // one of the drop-down menu options for adding a data source so that I could
            // insert my own click event in order to bring up a different dialog for adding
            // an FW data source. The other dialog would allow the user to choose different
            // queries for reading FW databases.
            //try
            //{
            //    ToolStripMenuItem cmnu = ReflectionHelper.GetField(m_dialog, "cmnuAddOtherDataSource") as ToolStripMenuItem;
            //    Delegate d = Delegate.CreateDelegate(typeof(EventHandler), m_dialog, "cmnuAddOtherDataSource_Click");
            //    EventInfo ei = typeof(ToolStripMenuItem).GetEvent("Click");
            //    ei.RemoveEventHandler(cmnu, d);
            //}
            //catch { }
        }