Esempio n. 1
0
        static void Main()
        {
            try
            {
                System.Threading.Thread.CurrentThread.CurrentCulture   = UserHelper.culture;
                System.Threading.Thread.CurrentThread.CurrentUICulture = UserHelper.culture;

                System.Windows.Forms.Application.EnableVisualStyles();
                System.Windows.Forms.Application.SetCompatibleTextRenderingDefault(false);

                InitialiseApplication();

                void InitialiseApplication()
                {
                    using (SplashScreen SplashWindow = new SplashScreen())
                    {
                        System.Threading.Thread SplashThread = new System.Threading.Thread(new System.Threading.ThreadStart(() => System.Windows.Forms.Application.Run(SplashWindow)));
                        SplashThread.SetApartmentState(System.Threading.ApartmentState.MTA);
                        SplashThread.Start();

                        LogHelper.GetLogState();

                        using (NAVPanelForm ApplicationWindow = new NAVPanelForm())
                        {
                            ApplicationWindow.Load += ApplicationWindowLoad;
                            System.Windows.Forms.Application.Run(ApplicationWindow);

                            void ApplicationWindowLoad(object sender, EventArgs e)
                            {
                                if (SplashWindow != null && !SplashWindow.Disposing && !SplashWindow.IsDisposed)
                                {
                                    SplashWindow.Invoke(new Action(() => SplashWindow.Close()));
                                }

                                ApplicationWindow.TopMost = true;
                                ApplicationWindow.Activate();
                                ApplicationWindow.TopMost = false;
                            }
                        }
                    }
                }
            }
            catch (NullReferenceException ex)
            {
                LogHelper.FatalException(Properties.Resources.NOTIFY_SQLNULLREFERENCE_ERROR, Properties.Resources.CAPTION_APPLICATION, ex);
            }
        }
Esempio n. 2
0
        private void RestoreDefaultsButtonClick(object sender, EventArgs e)
        {
            Button restoreDefaultsButton = (Button)sender;

            if (restoreDefaultsButton != null)
            {
                switch (MessageBox.Show(string.Format(UserHelper.culture, Properties.Resources.NOTIFY_RESTORE_PREFERENCES, Environment.NewLine), Properties.Resources.CAPTION_PREFERENCES, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button3))
                {
                case DialogResult.Yes:

                    RestoreControls();
                    break;

                default:

                    break;
                }

                NAVPanelForm.SetNotifyPreferenceChange(false);
            }

            void RestoreControls()
            {
                foreach (Control control in Controls)
                {
                    if ((control is TextBox) || (control is ComboBox))
                    {
                        if (ClassLibraryStandard.StringMethods.InString(control.Name, Constants.CONTROL_VALUE_SYMBOL))
                        {
                            if (control.Enabled)
                            {
                                string[] controlName       = control.Name.Split(new string[] { Constants.CONTROL_VALUE_SYMBOL }, StringSplitOptions.None);
                                int      iUserPreferenceID = int.Parse(controlName[1], UserHelper.culture);

                                control.Text = (control is ComboBox) ? (ClassLibraryStandard.HelperMethods.ToBoolean(RestoreDefaults(iUserPreferenceID)) ? Properties.Resources.FIELD_VALUE_YES : Properties.Resources.FIELD_VALUE_NO) : RestoreDefaults(iUserPreferenceID);
                            }
                        }
                    }
                }
            }
        }
Esempio n. 3
0
        private static void UpdatePreference(int iUserPreferenceID, bool bPreference, string nvPreferenceValue)
        {
            try
            {
                int iPreference = (bPreference) ? 1 : 0;

                Dapper.DynamicParameters param = new Dapper.DynamicParameters();

                param.Add("@" + Constants.COLUMN_USER_PREFERENCE_ID, iUserPreferenceID);
                param.Add("@" + Constants.COLUMN_USER_PREFERENCE_FLAG, iPreference);
                param.Add("@" + Constants.COLUMN_USER_PREFERENCE_VALUE, nvPreferenceValue);

                DataAccess.UpdateUserPreference(param);

                for (int rowIndex = 0; rowIndex < UserPreferencesDataTable.Rows.Count; rowIndex++)
                {
                    if (int.Parse(UserPreferencesDataTable.Rows[rowIndex][Constants.COLUMN_USER_PREFERENCE_ID].ToString().Trim(), UserHelper.culture) == iUserPreferenceID)
                    {
                        System.Collections.Generic.Dictionary <int, NAVChangePreferencesModel> map = new System.Collections.Generic.Dictionary <int, NAVChangePreferencesModel>()
                        {
                            { 1, new NAVChangePreferencesModel
                              {
                                  iPreferenceID           = iUserPreferenceID,
                                  iClientPreferenceTypeID = int.Parse(UserPreferencesDataTable.Rows[rowIndex][Constants.COLUMN_CLIENT_PREFERENCE_TYPE_ID].ToString().Trim(), UserHelper.culture),
                                  nvClientPreferenceType  = UserPreferencesDataTable.Rows[rowIndex][Constants.COLUMN_CLIENT_PREFERENCE_TYPE].ToString().Trim(),
                                  nvClientPreferenceName  = UserPreferencesDataTable.Rows[rowIndex][Constants.COLUMN_CLIENT_PREFERENCE_NAME].ToString().Trim(),
                                  nvPreferenceValue       = nvPreferenceValue,
                                  bPreference             = ClassLibraryStandard.HelperMethods.ToBoolean(bPreference.ToString(UserHelper.culture)),
                                  bClientValueRequired    = ClassLibraryStandard.HelperMethods.ToBoolean(UserPreferencesDataTable.Rows[rowIndex][Constants.COLUMN_CLIENT_VALUE_REQUIRED_FLAG].ToString()),
                                  bClientOverride         = ClassLibraryStandard.HelperMethods.ToBoolean(UserPreferencesDataTable.Rows[rowIndex][Constants.COLUMN_CLIENT_OVERRIDE_FLAG].ToString()),
                                  bSystemOverride         = ClassLibraryStandard.HelperMethods.ToBoolean(UserPreferencesDataTable.Rows[rowIndex][Constants.COLUMN_SYSTEM_OVERRIDE_FLAG].ToString())
                              } }
                        };

                        NAVPanelForm.ApplyPreferenceChange(map);
                        SetRequiredNotificationChange();

                        void SetRequiredNotificationChange()
                        {
                            NAVPanelForm.SetNotifyPreferenceChange(true);

                            string nvClientPreferenceType = map[1].nvClientPreferenceType.Trim();
                            string nvClientPreferenceName = map[1].nvClientPreferenceName.Trim();

                            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: 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: break;
                                }

                                break;

                            case Constants.DB_ABBREVIATION_TAB_PERMISSIONS:

                                switch (nvClientPreferenceName)
                                {
                                case Constants.DB_REPLACE_WORDS:
                                    NAVPanelForm.SetNotifyPreferenceChange(false);
                                    break;

                                case Constants.DB_PERMIT_DEFAULTS:
                                    NAVPanelForm.SetNotifyPreferenceChange(false);
                                    break;

                                case Constants.DB_PULL_ABBREVIATIONS:
                                    NAVPanelForm.SetNotifyPreferenceChange(false);
                                    break;

                                case Constants.DB_DELETE_ABBREVIATIONS: break;

                                case Constants.DB_ADD_NEW_ABBREVIATIONS: break;

                                case Constants.DB_EDIT_ABBREVIATIONS: break;

                                default: break;
                                }

                                break;

                            case Constants.DB_ERROR_LOG_PREFERENCES:

                                switch (nvClientPreferenceName)
                                {
                                case Constants.DB_LOG_ERRORS:
                                    NAVPanelForm.SetNotifyPreferenceChange(false);
                                    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: 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: 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: 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: break;
                                }

                                break;

                            default:

                                break;
                            }
                        }

                        return;
                    }
                }
            }
            catch (System.Data.SqlClient.SqlException ex)
            {
                MessageBox.Show(Properties.Resources.NOTIFY_PREFERENCE_CELL, Properties.Resources.CAPTION_PREFERENCES, MessageBoxButtons.OK, MessageBoxIcon.Error);
                if (log != null)
                {
                    log.Error(Properties.Resources.NOTIFY_PREFERENCE_CELL, ex);
                }
            }
        }