Exemplo n.º 1
0
        private static void RunCommandLineShell(string[] args)
        {
            bool bDisplayHelp = (args.Length > 3 && args.Length < 11);

            System.Array.Resize(ref args, 11);

            string ParentString = args[1];
            string ChildString  = args[2];

            int MatchingAlgorithm = ClassLibraryStandard.HelperMethods.IsInteger(args[3]) ? int.Parse(args[3], UserHelper.culture) : ExplorerForm.SetComparisonType(DataAccess.GetUserPreferenceByPreferenceName(Constants.DB_MATCHING_ALGORITHM));

            bool MakeCaseInsensitive = args[4] != null?ClassLibraryStandard.HelperMethods.ToBoolean(args[4]) : ClassLibraryStandard.HelperMethods.ToBoolean(DataAccess.GetUserPreferenceByPreferenceName(Constants.DB_APPLY_CASE_INSENSITIVITY));

            bool PadToEqualLength = args[5] != null?ClassLibraryStandard.HelperMethods.ToBoolean(args[5]) : ClassLibraryStandard.HelperMethods.ToBoolean(DataAccess.GetUserPreferenceByPreferenceName(Constants.DB_PAD_TEXT));

            bool RemoveWhitespace = args[6] != null?ClassLibraryStandard.HelperMethods.ToBoolean(args[6]) : ClassLibraryStandard.HelperMethods.ToBoolean(DataAccess.GetUserPreferenceByPreferenceName(Constants.DB_REMOVE_NOISE_CHARACTERS));

            bool ReverseComparison = args[7] != null?ClassLibraryStandard.HelperMethods.ToBoolean(args[7]) : ClassLibraryStandard.HelperMethods.ToBoolean(DataAccess.GetUserPreferenceByPreferenceName(Constants.DB_REVERSE_COMPARE));

            bool PhoneticFilter = args[9] != null?ClassLibraryStandard.HelperMethods.ToBoolean(args[9]) : ClassLibraryStandard.HelperMethods.ToBoolean(DataAccess.GetUserPreferenceByPreferenceName(Constants.DB_PHONETIC_FILTER));

            bool WholeWordComparison = args[10] != null?ClassLibraryStandard.HelperMethods.ToBoolean(args[10]) : ClassLibraryStandard.HelperMethods.ToBoolean(DataAccess.GetUserPreferenceByPreferenceName(Constants.DB_WHOLE_WORD_MATCH));

            if (bDisplayHelp || ((ParentString.ToLower(UserHelper.culture) == "help" || ParentString == "?") && ChildString == null))
            {
                System.Console.WriteLine(string.Format(UserHelper.culture, Properties.Resources.NOTIFY_COMMANDLINE_HELP, System.Environment.NewLine, args[0], Constants.METHOD_RATCLIFF_OBERSHELP, Constants.METHOD_LEVENSHTEIN_DISTANCE, Constants.METHOD_HAMMING_DISTANCE, Constants.METHOD_RATCLIFF_OBERSHELP_VALUE, Constants.METHOD_LEVENSHTEIN_DISTANCE_VALUE, Constants.METHOD_HAMMING_DISTANCE_VALUE));
            }

            int iCompare = ExplorerForm.GetComparisonPercentage(MatchingAlgorithm, ParentString, ChildString, RemoveWhitespace, MakeCaseInsensitive, PadToEqualLength, ReverseComparison, PhoneticFilter, WholeWordComparison);

            TraceInitialisationComplete("TRACE - Commandline method complete");
            System.Diagnostics.Trace.WriteLine(null);

            System.Environment.Exit(iCompare);
        }
Exemplo n.º 2
0
        public static void DataGridViewCellContentClick()
        {
            ExplorerForm.GetResultDataGridView().CommitEdit(System.Windows.Forms.DataGridViewDataErrorContexts.Commit);

            System.Windows.Forms.DataGridViewRow row = ExplorerForm.GetResultDataGridView().CurrentRow;

            bool bDeleteRowFlag = System.Convert.ToBoolean(row.Cells[Constants.COLUMN_DELETE_FLAG].Value, UserHelper.culture);

            switch (row.Cells[Constants.COLUMN_MATCHTYPE].Value)
            {
                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;
            }

            SetRowBackgroundColor(row.Cells[Constants.COLUMN_ROW_ID].Value, row.Cells[Constants.COLUMN_MATCHTYPE].Value, bDeleteRowFlag);
        }
Exemplo n.º 3
0
        public static void SetDataGridViewRowBackgroundColour()
        {
            foreach (System.Windows.Forms.DataGridViewRow row in ExplorerForm.GetResultDataGridView().Rows)
            {
                bool bDeleteRowFlag = System.Convert.ToBoolean(row.Cells[Constants.COLUMN_DELETE_FLAG].Value, UserHelper.culture);

                switch (row.Cells[Constants.COLUMN_MATCHTYPE].Value)
                {
                    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;
                }

                SetRowBackgroundColor(row.Cells[Constants.COLUMN_ROW_ID].Value, row.Cells[Constants.COLUMN_MATCHTYPE].Value, bDeleteRowFlag);
            }

        }
Exemplo n.º 4
0
        internal static void DeleteRowsMenuItemClick()
        {
            System.Collections.ArrayList keyArray = new System.Collections.ArrayList();

            int rowCount = GetDistinctRows();

            if (rowCount < 2)
            {
                ExplorerForm.DeleteSelectedRows(keyArray);
            }
            else
            {
                ConfirmDeleteRows();
            }

            int GetDistinctRows()
            {
                foreach (System.Windows.Forms.DataGridViewRow row in ExplorerForm.GetResultDataGridView().Rows)
                {
                    if (row.IsNewRow)
                    {
                        break;
                    }

                    if ((string)row.Cells[Constants.COLUMN_MATCHTYPE].Value == Constants.MATCH_ASSOCIATE)
                    {
                        int i = (int)row.Cells[Constants.COLUMN_ROW_ID].Value;

                        if (!keyArray.Contains(i))
                        {
                            keyArray.Add(i);
                        }
                    }
                }

                return(keyArray.Count);
            }

            void ConfirmDeleteRows()
            {
                switch (System.Windows.Forms.MessageBox.Show(string.Format(UserHelper.culture, Properties.Resources.NOTIFY_DELETE_ROWSCOUNT, System.Environment.NewLine, rowCount), Properties.Resources.CAPTION_COMPARE, System.Windows.Forms.MessageBoxButtons.YesNoCancel, System.Windows.Forms.MessageBoxIcon.Exclamation, System.Windows.Forms.MessageBoxDefaultButton.Button3))
                {
                case System.Windows.Forms.DialogResult.Yes:

                    ExplorerForm.DeleteSelectedRows(keyArray);
                    break;

                default:

                    break;
                }
            }
        }
Exemplo n.º 5
0
        private static bool GetResetPending(System.Windows.Forms.DataGridViewRow row)
        {
            if (row == null) return true;

            if (row.IsNewRow)
            {
                if (row.Index == 0) ExplorerForm.ResetExplorerForm();
                return true;
            }

            return false;
        }
Exemplo n.º 6
0
        public static void ResumeDataGridViews()
        {
            System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default;

            ResumeDataGridViewDrawing();

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

        }
Exemplo n.º 7
0
        public static void SuspendDataGridViews()
        {
            WorkTables.SetSheetDataGridViewFocus();

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

            SuspendDataGridViewDrawing();

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

        }
Exemplo n.º 8
0
        private void SheetDataGridViewMouseDownEvent(object sender, MouseEventArgs e)
        {
            int columns = SheetDataGridView.Columns.GetColumnCount(DataGridViewElementStates.Visible);
            int rows    = (ExplorerForm.GetResultDataGridView().RowCount == 0) ? 0 : SheetDataGridView.Rows.GetRowCount(DataGridViewElementStates.Visible);
            int row     = (columns == 0) ? 0 : SheetDataGridView.RowCount;

            DeleteColumnMenuItem.Enabled   = columns != 0;
            DeleteRowsMenuItem.Enabled     = rows != 0;
            DeleteRowMenuItem.Enabled      = row != 0;
            RestoreColumnsMenuItem.Enabled = columns < GetSheetColumnInitialTotal();

            if (e.Button == MouseButtons.Right)
            {
                DataGridView.HitTestInfo hitTest = SheetDataGridView.HitTest(e.X, e.Y);

                switch (hitTest.Type)
                {
                case DataGridViewHitTestType.ColumnHeader:

                    SheetDataGridView.ClearSelection();
                    SheetDataGridView.CurrentCell = SheetDataGridView[hitTest.ColumnIndex, 0];
                    break;

                case DataGridViewHitTestType.RowHeader:

                    if (columns != 0)
                    {
                        SheetDataGridView.ClearSelection();
                        SheetDataGridView.CurrentCell = SheetDataGridView[SheetDataGridView.Columns.GetFirstColumn(DataGridViewElementStates.Visible).DisplayIndex, hitTest.RowIndex];
                    }
                    break;

                case DataGridViewHitTestType.Cell:

                    if (hitTest.RowIndex >= 0)
                    {
                        SheetDataGridView.ClearSelection();
                        SheetDataGridView.CurrentCell = SheetDataGridView[hitTest.ColumnIndex, hitTest.RowIndex];
                    }
                    break;

                default:

                    DeleteColumnMenuItem.Enabled = false;
                    break;
                }
            }
        }
Exemplo n.º 9
0
        private static void SaveAsLastFileOpened(string fileName)
        {
            if (fileName != null)
            {
                Dapper.DynamicParameters param = new Dapper.DynamicParameters();

                param.Add("@" + Constants.COLUMN_USER_ID, UserHelper.UserPropertiesModel.iUserID);
                param.Add("@" + Constants.COLUMN_USER_LAST_FILENAME_OPENED, fileName);
                param.Add("@" + Constants.COLUMN_USER_LAST_TAB_FOCUS, UserHelper.UserStateModel.nvLastTabFocus);
                param.Add("@" + Constants.COLUMN_USER_LAST_TABLE_FOCUS, UserHelper.UserStateModel.nvLastTableFocus);
                param.Add("@" + Constants.COLUMN_USER_BUILD_VERSION, Constants.BUILD_VERSION);

                DataAccess.InsertUserStateLogEntry(param);
                UserHelper.UserStateModel.nvLastFilenameOpened = fileName;
                ExplorerForm.ResetExplorerForm();
            }
        }
Exemplo n.º 10
0
        private static void RestoreColumnMenuItemClickEvent()
        {
            DataGridViewColumn firstVisibleColumn = SheetDataGridView.Columns.GetFirstColumn(DataGridViewElementStates.Visible);
            bool bComparisonRebuild = false;

            foreach (DataGridViewColumn column in SheetDataGridView.Columns)
            {
                if (column.Name != Constants.KEY_COLUMN)
                {
                    if (!column.Visible)
                    {
                        column.Visible     = true;
                        bComparisonRebuild = true;
                    }
                }
            }

            if (bComparisonRebuild)
            {
                if (firstVisibleColumn != SheetDataGridView.Columns.GetFirstColumn(DataGridViewElementStates.Visible))
                {
                    ClassLibraryFramework.DataGridViewMethods.SortOnFirstVisibleColumn(SheetDataGridView);
                }

                ComparisonReset();
            }

            if (ExplorerForm.GetResultDataGridView() != null)
            {
                if (ExplorerForm.GetResultDataGridView().Rows.Count == 0)
                {
                    ClassLibraryFramework.DataGridViewMethods.SetBackgroundColour(SheetDataGridView, Constants.COLOR_DEFAULT);
                }
            }

            WorkTables.SetSheetDataGridViewFocus();
        }
Exemplo n.º 11
0
        private void InitializePreferencesForm()
        {
            UserPreferencesDataTable = ClassLibraryStandard.DataTableMethods.GetDataTable(DataAccess.GetUserPreferences());

            BuildFormControls();

            void BuildFormControls()
            {
                using (ClassLibraryFramework.DrawingInteropServices.PauseDrawing(this))
                {
                    int axisY = 0;

                    for (int rowIndex = 0; rowIndex < UserPreferencesDataTable.Rows.Count; rowIndex++)
                    {
                        if (GroupHeaderRequired(rowIndex))
                        {
                            GroupHeaderInsert(rowIndex, axisY);
                            axisY += 19;
                        }

                        PreferenceNameInsert(rowIndex, axisY);
                        PreferenceValueInsert(rowIndex, axisY);

                        axisY += 19;
                    }

                    RestoreDefaultsButton(axisY += 10);

                    axisY += 5;

                    PreferenceDescriptionHeaderInsert(axisY += 19);
                    PreferenceDescriptionInsert(axisY       += 19);

                    InstantiatePreferenceDelegates();
                }
            }

            void RestoreDefaultsButton(int axisY)
            {
                Button restoreDefaultsButton = new Button
                {
                    Anchor   = (AnchorStyles.Top | AnchorStyles.Right),
                    Name     = Constants.CONTROL_RESTOREBUTTON_SYMBOL,
                    Location = new System.Drawing.Point(351, axisY),
                    Size     = new System.Drawing.Size(100, 23),
                    Text     = Properties.Resources.CONTROL_RESTOREBUTTON_TEXT,
                    UseVisualStyleBackColor = true,
                    FlatStyle = FlatStyle.Flat,
                    TabIndex  = 1000
                };

                PreferenceToolTips.SetToolTip(restoreDefaultsButton, Properties.Resources.TOOLTIP_RESTOREDEFAULTSBUTTON);

                restoreDefaultsButton.FlatAppearance.BorderColor = System.Drawing.Color.Gainsboro;
                restoreDefaultsButton.Enter += PreferenceDescriptionLeave;
                restoreDefaultsButton.Click += RestoreDefaultsButtonClick;

                Controls.Add(restoreDefaultsButton);
            }

            void PreferenceDescriptionHeaderInsert(int axisY)
            {
                TextBox PreferenceDescriptionHeader = new TextBox
                {
                    Name        = Constants.CONTROL_PREFERENCEHEADER_SYMBOL,
                    Text        = null,
                    Anchor      = ((AnchorStyles.Top | AnchorStyles.Left) | AnchorStyles.Right),
                    BackColor   = Constants.COLOR_DEFAULT_BACKCOLOR,
                    BorderStyle = BorderStyle.None,
                    Cursor      = Cursors.Arrow,
                    ReadOnly    = true,
                    Location    = new System.Drawing.Point(0, axisY),
                    Margin      = new Padding(3, 3, 3, 3),
                    Multiline   = false,
                    Size        = new System.Drawing.Size(451, 85),
                    TabIndex    = 0,
                    TabStop     = false
                };

                PreferenceDescriptionHeader.GotFocus += (s1, e1) => { ClassLibraryStandard.TextBoxInteropServices.HideCaret(PreferenceDescriptionHeader.Handle); };

                Controls.Add(PreferenceDescriptionHeader);
            }

            void PreferenceDescriptionInsert(int axisY)
            {
                TextBox PreferenceDescription = new TextBox
                {
                    Name        = Constants.CONTROL_PREFERENCEDESCRIPTION_SYMBOL,
                    Text        = null,
                    Anchor      = ((AnchorStyles.Top | AnchorStyles.Left) | AnchorStyles.Right),
                    BackColor   = Constants.COLOR_DEFAULT_BACKCOLOR,
                    BorderStyle = BorderStyle.None,
                    Cursor      = Cursors.Arrow,
                    ReadOnly    = true,
                    Location    = new System.Drawing.Point(0, axisY),
                    Margin      = new Padding(3, 3, 3, 3),
                    Multiline   = true,
                    Size        = new System.Drawing.Size(451, 85),
                    TabIndex    = 0,
                    TabStop     = false
                };

                PreferenceDescription.GotFocus += (s1, e1) => { ClassLibraryStandard.TextBoxInteropServices.HideCaret(PreferenceDescription.Handle); };

                Controls.Add(PreferenceDescription);
            }

            void GroupHeaderInsert(int rowIndex, int axisY)
            {
                string controlName = Constants.CONTROL_DIVIDER_SYMBOL + UserPreferencesDataTable.Rows[rowIndex][Constants.COLUMN_USER_PREFERENCE_ID].ToString().Trim();

                TextBox DividerTextBox = new TextBox
                {
                    Name        = controlName,
                    Location    = new System.Drawing.Point(0, axisY),
                    Text        = UserPreferencesDataTable.Rows[rowIndex][Constants.COLUMN_CLIENT_PREFERENCE_TYPE].ToString().Trim(),
                    Anchor      = ((AnchorStyles.Top | AnchorStyles.Left) | AnchorStyles.Right),
                    BackColor   = Constants.COLOR_MATCH_ASSOCIATE,
                    ForeColor   = Constants.COLOR_DEFAULT_TEXT,
                    BorderStyle = BorderStyle.FixedSingle,
                    Cursor      = Cursors.Arrow,
                    ReadOnly    = true,
                    Font        = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))),
                    RightToLeft = RightToLeft.No,
                    Size        = new System.Drawing.Size(451, 20),
                    TabIndex    = rowIndex + 500
                };

                DividerTextBox.GotFocus += (s1, e1) => { ClassLibraryStandard.TextBoxInteropServices.HideCaret(DividerTextBox.Handle); };

                DividerTextBox.Enter   += PreferenceDescriptionLeave;
                DividerTextBox.Enter   += TextBoxBackColorChange;
                DividerTextBox.Leave   += TextBoxBackColorChange;
                DividerTextBox.KeyDown += TextBoxKeyDown;

                Controls.Add(DividerTextBox);
            }

            void PreferenceNameInsert(int rowIndex, int axisY)
            {
                string controlName = Constants.CONTROL_PREFERENCE_SYMBOL + UserPreferencesDataTable.Rows[rowIndex][Constants.COLUMN_USER_PREFERENCE_ID].ToString().Trim();

                TextBox PreferenceTextBox = new TextBox
                {
                    Name                  = controlName,
                    Location              = new System.Drawing.Point(0, axisY),
                    Text                  = UserPreferencesDataTable.Rows[rowIndex][Constants.COLUMN_CLIENT_PREFERENCE_NAME].ToString().Trim(),
                    Anchor                = ((((AnchorStyles.Top | AnchorStyles.Bottom) | AnchorStyles.Left))),
                    BackColor             = Constants.COLOR_MATCH_ASSOCIATE,
                    ForeColor             = Constants.COLOR_DEFAULT_TEXT,
                    BorderStyle           = BorderStyle.FixedSingle,
                    Cursor                = Cursors.Arrow,
                    ReadOnly              = true,
                    Font                  = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))),
                    RightToLeft           = RightToLeft.No,
                    Size                  = new System.Drawing.Size(135, 20),
                    AccessibleDescription = UserPreferencesDataTable.Rows[rowIndex][Constants.COLUMN_CLIENT_PREFERENCE_DESCRIPTION].ToString().Trim(),
                    AccessibleName        = UserPreferencesDataTable.Rows[rowIndex][Constants.COLUMN_CLIENT_PREFERENCE_NAME].ToString().Trim(),
                    TabIndex              = rowIndex + 500
                };

                PreferenceTextBox.GotFocus += (s1, e1) => { ClassLibraryStandard.TextBoxInteropServices.HideCaret(PreferenceTextBox.Handle); };

                PreferenceTextBox.Enter   += TextBoxBackColorChange;
                PreferenceTextBox.Enter   += PreferenceDescriptionEnter;
                PreferenceTextBox.Leave   += TextBoxBackColorChange;
                PreferenceTextBox.KeyDown += TextBoxKeyDown;

                Controls.Add(PreferenceTextBox);
            }

            void PreferenceValueInsert(int rowIndex, int axisY)
            {
                string controlName            = Constants.CONTROL_VALUE_SYMBOL + UserPreferencesDataTable.Rows[rowIndex][Constants.COLUMN_USER_PREFERENCE_ID].ToString().Trim();
                string nvClientPreferenceName = UserPreferencesDataTable.Rows[rowIndex][Constants.COLUMN_CLIENT_PREFERENCE_NAME].ToString().Trim();

                bool bClientOverride = ClassLibraryStandard.HelperMethods.ToBoolean(UserPreferencesDataTable.Rows[rowIndex][Constants.COLUMN_CLIENT_OVERRIDE_FLAG].ToString());
                bool bSystemOverride = ClassLibraryStandard.HelperMethods.ToBoolean(UserPreferencesDataTable.Rows[rowIndex][Constants.COLUMN_SYSTEM_OVERRIDE_FLAG].ToString());

                if (ClassLibraryStandard.HelperMethods.ToBoolean(UserPreferencesDataTable.Rows[rowIndex][Constants.COLUMN_CLIENT_VALUE_REQUIRED_FLAG].ToString()))
                {
                    switch (nvClientPreferenceName)
                    {
                    case Constants.DB_MATCHING_ALGORITHM:
                        BuildListValueComboBox();
                        break;

                    default:
                        BuildValueTextBox();
                        break;
                    }
                }
                else
                {
                    BuildValueComboBox();
                }

                void BuildListValueComboBox()
                {
                    ClassLibraryFramework.ComboBoxEx ListValueComboBox = new ClassLibraryFramework.ComboBoxEx
                    {
                        Name                  = controlName,
                        Location              = new System.Drawing.Point(134, axisY - 1),
                        Anchor                = (((((AnchorStyles.Top | AnchorStyles.Bottom) | AnchorStyles.Left) | AnchorStyles.Right))),
                        BackColor             = Constants.COLOR_DEFAULT,
                        ForeColor             = (bClientOverride || bSystemOverride) ? System.Drawing.Color.DimGray : System.Drawing.Color.Black,
                        FormattingEnabled     = true,
                        RightToLeft           = RightToLeft.No,
                        Size                  = new System.Drawing.Size(317, 21),
                        AccessibleDescription = UserPreferencesDataTable.Rows[rowIndex][Constants.COLUMN_CLIENT_PREFERENCE_DESCRIPTION].ToString().Trim(),
                        AccessibleDefaultActionDescription = UserPreferencesDataTable.Rows[rowIndex][Constants.COLUMN_USER_PREFERENCE_VALUE].ToString().Trim(),
                        AccessibleName = nvClientPreferenceName,
                        TabIndex       = rowIndex
                    };

                    switch (nvClientPreferenceName)
                    {
                    case Constants.DB_MATCHING_ALGORITHM:
                        ListValueComboBox.Items.AddRange(new object[] { Constants.METHOD_RATCLIFF_OBERSHELP, Constants.METHOD_LEVENSHTEIN_DISTANCE, Constants.METHOD_HAMMING_DISTANCE });
                        ListValueComboBox.SelectedIndex = ExplorerForm.GetComparisonType(UserPreferencesDataTable.Rows[rowIndex][Constants.COLUMN_USER_PREFERENCE_VALUE].ToString().Trim());
                        break;

                    default:
                        ListValueComboBox.Items.AddRange(new object[] { Properties.Resources.FIELD_VALUE_YES, Properties.Resources.FIELD_VALUE_NO });
                        ListValueComboBox.SelectedIndex = ListValueComboBox.Items.IndexOf(ClassLibraryStandard.HelperMethods.ToBoolean(UserPreferencesDataTable.Rows[rowIndex][Constants.COLUMN_USER_PREFERENCE_FLAG].ToString()) ? Properties.Resources.FIELD_VALUE_YES : Properties.Resources.FIELD_VALUE_NO);
                        break;
                    }

                    ListValueComboBox.Enter += PreferenceDescriptionEnter;
                    if (bClientOverride || bSystemOverride)
                    {
                        ListValueComboBox.Enabled = false;
                    }
                    if (ListValueComboBox.Enabled)
                    {
                        ListValueComboBox.TextChanged += UpdatePreferenceAttribute;
                    }

                    Controls.Add(ListValueComboBox);
                }

                void BuildValueTextBox()
                {
                    TextBox ValueTextBox = new TextBox
                    {
                        Name                  = controlName,
                        Location              = new System.Drawing.Point(134, axisY),
                        Text                  = UserPreferencesDataTable.Rows[rowIndex][Constants.COLUMN_USER_PREFERENCE_VALUE].ToString().Trim(),
                        Anchor                = (((((AnchorStyles.Top | AnchorStyles.Bottom) | AnchorStyles.Left) | AnchorStyles.Right))),
                        BackColor             = Constants.COLOR_DEFAULT,
                        ForeColor             = (bClientOverride || bSystemOverride) ? System.Drawing.Color.DimGray : System.Drawing.Color.Black,
                        MaxLength             = 1000,
                        RightToLeft           = RightToLeft.No,
                        Size                  = new System.Drawing.Size(317, 20),
                        AccessibleDescription = UserPreferencesDataTable.Rows[rowIndex][Constants.COLUMN_CLIENT_PREFERENCE_DESCRIPTION].ToString().Trim(),
                        AccessibleDefaultActionDescription = UserPreferencesDataTable.Rows[rowIndex][Constants.COLUMN_USER_PREFERENCE_VALUE].ToString().Trim(),
                        AccessibleName = nvClientPreferenceName,
                        TabIndex       = rowIndex
                    };

                    ValueTextBox.Enter += PreferenceDescriptionEnter;
                    if (bClientOverride || bSystemOverride)
                    {
                        ValueTextBox.Enabled = false;
                    }
                    if (ValueTextBox.Enabled)
                    {
                        ValueTextBox.Leave += UpdatePreferenceAttribute;
                    }

                    Controls.Add(ValueTextBox);
                }

                void BuildValueComboBox()
                {
                    ClassLibraryFramework.ComboBoxEx ValueComboBox = new ClassLibraryFramework.ComboBoxEx
                    {
                        Name                  = controlName,
                        Location              = new System.Drawing.Point(134, axisY - 1),
                        Anchor                = (((((AnchorStyles.Top | AnchorStyles.Bottom) | AnchorStyles.Left) | AnchorStyles.Right))),
                        BackColor             = Constants.COLOR_DEFAULT,
                        ForeColor             = (bClientOverride || bSystemOverride) ? System.Drawing.Color.DimGray : System.Drawing.Color.Black,
                        FormattingEnabled     = true,
                        RightToLeft           = RightToLeft.No,
                        Size                  = new System.Drawing.Size(317, 21),
                        AccessibleDescription = UserPreferencesDataTable.Rows[rowIndex][Constants.COLUMN_CLIENT_PREFERENCE_DESCRIPTION].ToString().Trim(),
                        AccessibleDefaultActionDescription = UserPreferencesDataTable.Rows[rowIndex][Constants.COLUMN_USER_PREFERENCE_VALUE].ToString().Trim(),
                        AccessibleName = nvClientPreferenceName,
                        TabIndex       = rowIndex
                    };

                    ValueComboBox.Items.AddRange(new object[] { Properties.Resources.FIELD_VALUE_YES, Properties.Resources.FIELD_VALUE_NO });
                    ValueComboBox.SelectedIndex = ValueComboBox.Items.IndexOf(ClassLibraryStandard.HelperMethods.ToBoolean(UserPreferencesDataTable.Rows[rowIndex][Constants.COLUMN_USER_PREFERENCE_FLAG].ToString()) ? Properties.Resources.FIELD_VALUE_YES : Properties.Resources.FIELD_VALUE_NO);
                    ValueComboBox.Enter        += PreferenceDescriptionEnter;
                    if (bClientOverride || bSystemOverride)
                    {
                        ValueComboBox.Enabled = false;
                    }
                    if (ValueComboBox.Enabled)
                    {
                        ValueComboBox.TextChanged += UpdatePreferenceAttribute;
                    }

                    Controls.Add(ValueComboBox);
                }
            }

            bool GroupHeaderRequired(int rowIndex)
            {
                if (UserPreferencesDataTable != null)
                {
                    if (rowIndex == 0)
                    {
                        return(true);
                    }
                    else
                    {
                        return(UserPreferencesDataTable.Rows[rowIndex - 1][Constants.COLUMN_CLIENT_PREFERENCE_TYPE].ToString().Trim() != UserPreferencesDataTable.Rows[rowIndex][Constants.COLUMN_CLIENT_PREFERENCE_TYPE].ToString().Trim());
                    }
                }

                return(false);
            }
        }
Exemplo n.º 12
0
 private void SheetDataGridViewCellValueChanged(object sender, DataGridViewCellEventArgs e)
 {
     ExplorerForm.SheetDataGridViewCellValueChanged();
 }
Exemplo n.º 13
0
 private static void DeleteSelectedRows(System.Collections.ArrayList keyArray = null)
 {
     ExplorerForm.DeleteSelectedRows(keyArray);
 }
Exemplo n.º 14
0
 private static void ComparisonReset()
 {
     SetSpreadsheetChanges(true);
     ExplorerForm.ResetExplorerForm();
 }
Exemplo n.º 15
0
        internal static void ApplyPreferenceChange(System.Collections.Generic.Dictionary <int, NAVChangePreferencesModel> map)
        {
            if (map != null)
            {
                string nvClientPreferenceType = map[1].nvClientPreferenceType.Trim();
                string nvClientPreferenceName = map[1].nvClientPreferenceName.Trim();
                bool   bPreference            = map[1].bPreference;

                switch (nvClientPreferenceType)
                {
                case Constants.DB_SLIDE_PANEL_TAB_VIEWS:

                    switch (nvClientPreferenceName)
                    {
                    case Constants.DB_HIDE_ABBREVIATIONS: break;

                    case Constants.DB_HIDE_EXPLORER: break;

                    case Constants.DB_OPEN_LAST_TAB: break;

                    default: ClientPreferenceNameError(); break;
                    }

                    break;

                case Constants.DB_IMPORT_FILE_PERMISSIONS:

                    switch (nvClientPreferenceName)
                    {
                    case Constants.DB_ORDER_COLUMNS: break;

                    case Constants.DB_DELETE_ROWS: break;

                    case Constants.DB_EDIT_CELLS: break;

                    case Constants.DB_CREATE_ROWS: break;

                    case Constants.DB_OPEN_LAST_FILE: break;

                    case Constants.DB_OPEN_LAST_WORKSHEET: break;

                    default: ClientPreferenceNameError(); break;
                    }

                    break;

                case Constants.DB_ABBREVIATION_TAB_PERMISSIONS:

                    switch (nvClientPreferenceName)
                    {
                    case Constants.DB_REPLACE_WORDS:
                        UserHelper.SetReplaceAllWords(bPreference);
                        ExplorerForm.SetComparisonReset(true);
                        break;

                    case Constants.DB_PERMIT_DEFAULTS:
                        UserHelper.SetReplaceDefaultWordsOnly(bPreference);
                        ExplorerForm.SetComparisonReset(true);
                        break;

                    case Constants.DB_PULL_ABBREVIATIONS:
                        UserHelper.SetPullAbbreviations(bPreference);
                        ExplorerForm.SetComparisonReset(true);
                        break;

                    case Constants.DB_DELETE_ABBREVIATIONS: break;

                    case Constants.DB_ADD_NEW_ABBREVIATIONS: break;

                    case Constants.DB_EDIT_ABBREVIATIONS: break;

                    default: ClientPreferenceNameError(); break;
                    }

                    break;

                case Constants.DB_ERROR_LOG_PREFERENCES:

                    switch (nvClientPreferenceName)
                    {
                    case Constants.DB_LOG_ERRORS:
                        UserHelper.SetLogErrors(bPreference);
                        break;

                    case Constants.DB_LOG_ERRORS_TO_FILE: break;         // TO DO: log4net - disabled (redundant?)

                    case Constants.DB_ERROR_LOG_FILE_LOCATION: break;    // TO DO: log4net - disabled (redundant?)

                    case Constants.DB_ERROR_LOG_MAXIMUM_SIZE: break;     // TO DO: log4net - disabled (redundant?)

                    case Constants.DB_ERROR_LOG_ARCHIVE_TOTAL: break;    // TO DO: log4net - disabled (redundant?)

                    default: ClientPreferenceNameError(); break;
                    }

                    break;

                case Constants.DB_DATA_CONNECTION_ATTRIBUTES:

                    switch (nvClientPreferenceName)
                    {
                    case Constants.DB_CLOUD_CONNECTION_STRING: break;         // TO DO: return value in ConnectionHelper.cs - disabled (redundant?)

                    case Constants.DB_LOCAL_CONNECTION_STRING: break;         // TO DO: return value in ConnectionHelper.cs - disabled (redundant?)

                    default: ClientPreferenceNameError(); break;
                    }

                    break;

                case Constants.DB_USER_INTERFACE_THEMES:

                    switch (nvClientPreferenceName)
                    {
                    case Constants.DB_COLOUR_SCHEME: break;         // TO DO: future imiplementation - disabled

                    case Constants.DB_INTERFACE_LANGUAGE: break;    // TO DO: future imiplementation - disabled

                    case Constants.DB_APPLY_RTL_ORIENTATION: break; // TO DO: future imiplementation - disabled

                    default: ClientPreferenceNameError(); break;
                    }

                    break;

                case Constants.DB_SEARCH_PREFERENCES:

                    switch (nvClientPreferenceName)
                    {
                    case Constants.DB_PULL_ABBREVIATIONS: break;

                    case Constants.DB_REMOVE_NOISE_CHARACTERS: break;

                    case Constants.DB_APPLY_CASE_INSENSITIVITY: break;

                    case Constants.DB_PAD_TEXT: break;

                    case Constants.DB_REVERSE_COMPARE: break;

                    case Constants.DB_MATCH_ABBREVIATIONS: break;

                    case Constants.DB_PHONETIC_FILTER: break;

                    case Constants.DB_WHOLE_WORD_MATCH: break;

                    case Constants.DB_PERCENTAGE_INTEREST: break;

                    case Constants.DB_MATCHING_ALGORITHM: break;

                    default: ClientPreferenceNameError(); break;
                    }

                    break;

                default:

                    ClientPreferenceTypeError();
                    break;
                }

                void ClientPreferenceTypeError()
                {
                    SetNotifyPreferenceChange(false);
                    MessageBox.Show(string.Format(UserHelper.culture, Properties.Resources.NOTIFY_UPDATE_PREFERENCE, nvClientPreferenceName, nvClientPreferenceType), Properties.Resources.CAPTION_PREFERENCES_ERROR, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    if (log != null)
                    {
                        log.Error(string.Format(UserHelper.culture, Properties.Resources.NOTIFY_UPDATE_PREFERENCE, nvClientPreferenceName, nvClientPreferenceType));
                    }
                }

                void ClientPreferenceNameError()
                {
                    MessageBox.Show(string.Format(UserHelper.culture, Properties.Resources.NOTIFY_UPDATE_PREFERENCENAME, nvClientPreferenceName), Properties.Resources.CAPTION_PREFERENCES_ERROR, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    if (log != null)
                    {
                        log.Error(string.Format(UserHelper.culture, Properties.Resources.NOTIFY_UPDATE_PREFERENCENAME, nvClientPreferenceName));
                    }
                }
            }
        }
Exemplo n.º 16
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();
                }
            }
        }