Example #1
0
        private static void SetRowBackgroundColor(object iRowID, object nvMatchType, bool bDeleteRowFlag)
        {
            if (iRowID == null) return;

            System.Windows.Forms.DataGridViewRow row = NAVForm.GetSheetDataGridView().Rows.Cast<System.Windows.Forms.DataGridViewRow>()
                .Where(x => !x.IsNewRow)
                .Where(x => ((DataRowView)x.DataBoundItem).Row.Field<int>(Constants.KEY_COLUMN).Equals(iRowID))
                .FirstOrDefault();

            if (GetResetPending(row)) return;

            switch (nvMatchType)
            {
                case Constants.MATCH_ASSOCIATE:
                    row.DefaultCellStyle.BackColor = (bDeleteRowFlag) ? Constants.COLOR_MATCH_ASSOCIATE_DELETE : Constants.COLOR_MATCH_ASSOCIATE;
                    break;

                case Constants.MATCH_PRINCIPLE:
                    row.DefaultCellStyle.BackColor = (bDeleteRowFlag) ? Constants.COLOR_MATCH_PRINCIPLE_DELETE : Constants.COLOR_MATCH_PRINCIPLE;
                    break;

                default:
                    row.DefaultCellStyle.BackColor = Constants.COLOR_DEFAULT;
                    break;
            }

        }
Example #2
0
        private void InformPreferenceChanged()
        {
            switch (MessageBox.Show(string.Format(UserHelper.culture, Properties.Resources.NOTIFY_PREFERENCE_CHANGES, System.Environment.NewLine), Properties.Resources.CAPTION_RESTART_APPLICATION, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Information, MessageBoxDefaultButton.Button3))
            {
            case DialogResult.Yes:

                if (NAVForm.GetSpreadsheetChanges())
                {
                    switch (MessageBox.Show(Properties.Resources.NOTIFY_SAVEWORKBOOKCHANGES_ON_EXIT, Properties.Resources.CAPTION_SAVE_WORKBOOK, MessageBoxButtons.YesNo, MessageBoxIcon.Warning))
                    {
                    case DialogResult.Yes:

                        NAVForm.SaveWorkbook();
                        break;

                    default: break;
                    }
                }

                System.Diagnostics.Process.Start(Application.ExecutablePath);
                Close();

                break;

            default:
                SetEnablePreferenceChange(false);
                break;
            }

            SetNotifyPreferenceChange(false);
        }
Example #3
0
        internal static void AcceptDataGridViewChanges()
        {
            foreach (DataTable table in NAVForm.DataTableCollection)
            {
                table.AcceptChanges();
            }

            NAVForm.SetSheetCurrentTotal(value: string.Format(UserHelper.culture, Properties.Resources.NOTIFY_CURRENT_TOTAL, NAVForm.GetSheetDataGridView().RowCount - 1));
            NAVForm.SetSpreadsheetChanges(true);
            SetSheetDataGridViewFocus();
        }
Example #4
0
        internal static void DeleteDuplicateRows(DataTable datatable)
        {
            if (NAVForm.GetSheetDataGridView().RowCount == 0 || datatable == null)
            {
                return;
            }

            datatable.AcceptChanges();

            object[] rows = SelectDuplicateRows();

            if (rows.Any())
            {
                DeleteSelectedRows();
            }

            void DeleteSelectedRows()
            {
                for (int i = rows.Length - 1; i > -1; i--)
                {
                    int j = 0;

                    while (j < datatable.Rows.Count)
                    {
                        DataRow row = datatable.Rows[j];

                        if (row.HasVersion(DataRowVersion.Current))
                        {
                            if (row[Constants.COLUMN_PARENT_ID].Equals(rows[i]))
                            {
                                row.Delete();
                            }
                        }

                        j++;
                    }
                }

                datatable.AcceptChanges();
            }

            object[] SelectDuplicateRows()
            {
                datatable.AcceptChanges();

                return(datatable.Rows.Cast <DataRow>()
                       .Where(x => x[Constants.COLUMN_DELETE_FLAG].Equals(1) || x[Constants.COLUMN_COMPARISON].Equals(100))
                       .Select(x => x[Constants.COLUMN_PARENT_ID])
                       .Distinct()
                       .ToArray());
            }
        }
Example #5
0
        public static void ResumeDataGridViews()
        {
            System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default;

            ResumeDataGridViewDrawing();

            void ResumeDataGridViewDrawing()
            {
                NAVForm.ResumeSheetDataGridView();
                ExplorerForm.ResumeResultDataGridView();
            }

        }
Example #6
0
        public static void SuspendDataGridViews()
        {
            WorkTables.SetSheetDataGridViewFocus();

            System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;

            SuspendDataGridViewDrawing();

            void SuspendDataGridViewDrawing()
            {
                NAVForm.SuspendSheetDataGridView();
                ExplorerForm.SuspendResultDataGridView();
            }

        }
Example #7
0
        internal static DataTable BuildParentTable()
        {
            using (DataTable table = new DataTable())
            {
                DataColumn column = new DataColumn
                {
                    DataType   = System.Type.GetType("System.Int32"),
                    ColumnName = Constants.COLUMN_ROW_ID,
                    ReadOnly   = true,
                    Unique     = true
                };

                table.Columns.Add(column);

                column = new DataColumn
                {
                    DataType   = System.Type.GetType("System.String"),
                    ColumnName = Constants.COLUMN_DATA
                };

                table.Columns.Add(column);

                DataColumn[] PrimaryKeyColumns = new DataColumn[1];
                PrimaryKeyColumns[0] = table.Columns[Constants.KEY_COLUMN];
                table.PrimaryKey     = PrimaryKeyColumns;

                if (NAVForm.GetSheetDataGridView() != null)
                {
                    PopulateParentTable();
                }

                return(table);

                void PopulateParentTable()
                {
                    int SheetDataGridViewColumnCount = NAVForm.GetSheetDataGridView().Columns.GetColumnCount(System.Windows.Forms.DataGridViewElementStates.Visible);

                    if (SheetDataGridViewColumnCount > 0)
                    {
                        foreach (System.Windows.Forms.DataGridViewRow row in NAVForm.GetSheetDataGridView().Rows)
                        {
                            if (row.IsNewRow)
                            {
                                break;
                            }

                            if (row.Cells[Constants.KEY_COLUMN].Value != null)
                            {
                                System.Text.StringBuilder ConcatenateRow = new System.Text.StringBuilder();

                                foreach (System.Windows.Forms.DataGridViewCell cell in row.Cells)
                                {
                                    if ((cell.OwningColumn.Visible == true) && (cell.OwningColumn.Name != Constants.KEY_COLUMN))
                                    {
                                        ConcatenateRow.Append(cell.Value + " ");
                                    }
                                }

                                string ConcatenateRowToString = ConcatenateRow.ToString().TrimEnd((char)32);

                                while (ConcatenateRowToString.Contains("  "))
                                {
                                    ConcatenateRowToString = ConcatenateRowToString.Replace("  ", " ");
                                }

                                DataRow tableRow = table.NewRow();
                                tableRow[Constants.COLUMN_ROW_ID] = row.Cells[Constants.KEY_COLUMN].Value;
                                tableRow[Constants.COLUMN_DATA]   = ConcatenateRowToString.TrimEnd();
                                table.Rows.Add(tableRow);
                            }
                        }

                        table.AcceptChanges();
                    }
                }
            }
        }
Example #8
0
 internal static void SetSheetDataGridViewFocus()
 {
     NAVForm.GetSheetDataGridView().CurrentCell = NAVForm.GetSheetDataGridView().FirstDisplayedCell;
     NAVForm.GetSheetDataGridView().Focus();
 }
Example #9
0
        private void InitializePanels()
        {
            BackColor = Constants.COLOR_DEFAULT_BACKCOLOR;

            SetNotifyPreferenceChange(false);
            SetEnablePreferenceChange(true);

            InitializeLeftPanelForm();
            InitializeRightPanelForm();

            initializeCaptions();
            initializeToolTips();

            LogHelper.TraceInitialisationComplete();

            void NAVFormShownEventHandler(object sender, EventArgs e)
            {
                UpdateHelper.CheckForUpdates();
            }

            void initializeCaptions()
            {
                Text                    = ConnectionHelper.ApplicationName();
                TABExplorer.Text        = Properties.Resources.CAPTION_TAB_EXPLORER;
                TABPreferences.Text     = Properties.Resources.CAPTION_TAB_PREFERENCES;
                TABAbbreviations.Text   = Properties.Resources.CAPTION_TAB_ABBREVIATIONS;
                LABELExplorer.Text      = Properties.Resources.CAPTION_SIMILARITY;
                LABELPreferences.Text   = Properties.Resources.CAPTION_PREFERENCES;
                LABELAbbreviations.Text = Properties.Resources.CAPTION_ABBREVIATIONS;
            }

            void initializeToolTips()
            {
                TABToolTips.SetToolTip(PanelSliderPictureBox, Properties.Resources.TOOLTIP_PANELSLIDERPICTUREBOX);
                TABToolTips.SetToolTip(NewButton, Properties.Resources.TOOLTIP_NEWBUTTON);
                TABToolTips.SetToolTip(DeleteButton, Properties.Resources.TOOLTIP_DELETEBUTTON);

                nvWord.ToolTipText                    = Properties.Resources.TOOLTIP_WORDTEXT;
                nvAbbreviation.ToolTipText            = Properties.Resources.TOOLTIP_ABBREVIATIONTEXT;
                nvAbbreviationDescription.ToolTipText = Properties.Resources.TOOLTIP_ABBREVIATIONDESCRIPTIONTEXT;
                bAlwaysUse.ToolTipText                = Properties.Resources.TOOLTIP_ALWAYSUSETEXT;
            }

            void InitializeLeftPanelForm()
            {
                NAVFormSplitContainer.BackColor       = Constants.COLOR_DEFAULT_BACKCOLOR;
                NAVFormSplitContainer.Panel2Collapsed = true;

                NAVForm.Shown += new EventHandler(NAVFormShownEventHandler);

                NAVForm.TopLevel        = false;
                NAVForm.FormBorderStyle = FormBorderStyle.None;
                NAVForm.Parent          = NAVFormSplitContainer.Panel1;
                NAVForm.Dock            = DockStyle.Fill;

                NAVForm.Show();
            }

            void InitializeRightPanelForm()
            {
                Cursor = Cursors.WaitCursor;

                InitializeAbbreviations();
                InitializePreferences();
                InitializeExplorer();

                Cursor = Cursors.Default;

                void InitializeAbbreviations()
                {
                    AbbreviationsDataGridView.ReadOnly                 = !EditAbbreviations;
                    AbbreviationsDataGridView.AllowUserToAddRows       = false;
                    AbbreviationsDataGridView.AllowUserToDeleteRows    = false;
                    AbbreviationsDataGridView.AllowUserToOrderColumns  = true;
                    AbbreviationsDataGridView.AllowUserToResizeColumns = false;
                    AbbreviationsDataGridView.AllowUserToResizeRows    = false;

                    try
                    {
                        AbbreviationTypeComboBox.BackColor             = Constants.COLOR_DEFAULT_BACKCOLOR;
                        AbbreviationTypeComboBox.DataSource            = DataAccess.GetAbbreviationTypes();
                        AbbreviationTypeComboBox.DisplayMember         = Constants.COLUMN_ABBREVIATION_TYPE;
                        AbbreviationTypeComboBox.SelectedIndexChanged += (object sender, EventArgs e) => GetAbbreviationDataGridView();
                    }
                    catch (System.Data.SqlClient.SqlException ex)
                    {
                        MessageBox.Show(Properties.Resources.NOTIFY_ABBREVIATION_FAIL, Properties.Resources.CAPTION_ABBREVIATIONS, MessageBoxButtons.OK, MessageBoxIcon.Error);
                        if (log != null)
                        {
                            log.Error(Properties.Resources.NOTIFY_ABBREVIATION_FAIL, ex);
                        }
                    }

                    NAVPanelFormTabControl.SelectedIndexChanged += TABPreferencesLeave;

                    AbbreviationsDataGridView.CellValueChanged += AbbreviationsCellValueChanged;
                    AbbreviationsDataGridView.RowValidating    += AbbreviationsRowValidating;
                    AbbreviationsDataGridView.MouseDown        += AbbreviationsDataGridViewMouseDownEvent;
                    AbbreviationsDataGridView.MouseUp          += AbbreviationsMouseUp;

                    AbbreviationMenuItemDelete.Enabled = DeleteAbbreviations;
                    AbbreviationMenuItemNew.Enabled    = AddNewAbbreviations;

                    DeleteButton.Enabled = DeleteAbbreviations;
                    NewButton.Enabled    = AddNewAbbreviations;

                    using (ClassLibraryFramework.DrawingInteropServices.PauseDrawing(AbbreviationsDataGridView))
                    {
                        if (HideAbbreviations)
                        {
                            if (NAVPanelFormTabControl.TabPages.Contains(TABAbbreviations))
                            {
                                NAVPanelFormTabControl.TabPages.Remove(TABAbbreviations);
                            }
                        }
                        else
                        {
                            GetAbbreviationDataGridView();
                        }

                        if (HideExplorer)
                        {
                            if (NAVPanelFormTabControl.TabPages.Contains(TABExplorer))
                            {
                                NAVPanelFormTabControl.TabPages.Remove(TABExplorer);
                            }
                        }
                    }
                }

                void InitializeExplorer()
                {
                    ExplorerForm explorerForm = new ExplorerForm()
                    {
                        TopLevel        = false,
                        FormBorderStyle = FormBorderStyle.None,
                        Dock            = DockStyle.Fill
                    };

                    ExplorerFormPanel.BackColor = Constants.COLOR_DEFAULT_WINDOW;

                    ExplorerFormPanel.Controls.Add(explorerForm);
                    explorerForm.Show();
                }

                void InitializePreferences()
                {
                    PreferencesForm preferencesForm = new PreferencesForm
                    {
                        TopLevel        = false,
                        FormBorderStyle = FormBorderStyle.None,
                        Dock            = DockStyle.Fill
                    };

                    TABPreferences.BackColor = Constants.COLOR_DEFAULT_WINDOW;

                    PreferenceFormPanel.Controls.Add(preferencesForm);
                    preferencesForm.Show();
                }
            }
        }