Exemple #1
0
        private void updatePreferences(ListViewItem lvItem)
        {
            if (lvItem == null || lvItem.Tag == null)
            {
                return;
            }

            lock (syncobj)
            {
                string key = lvItem.Tag as string;
                if (horizontalTabs1.TabActive == tabUserSettings)
                {
                    if (dictUserPreferencesFromConfig.ContainsKey(key))
                    {
                        PreferenceSettings p = dictUserPreferencesFromConfig[key];
                        p.value = lvItem.Checked;
                        dictUserPreferencesFromConfig[key] = p;
                    }
                }
                else if (horizontalTabs1.TabActive == tabDeviceSettings)
                {
                    if (dictDevicePreferencesFromConfig.ContainsKey(key))
                    {
                        PreferenceSettings p = dictDevicePreferencesFromConfig[key];
                        p.value = lvItem.Checked;
                        dictDevicePreferencesFromConfig[key] = p;
                    }
                }
                else
                {
                }
            }
            ChangeSaveButtonGraphics();
        }
Exemple #2
0
        private bool IsPreferencesDirty(Dictionary <string, PreferenceSettings> dictSettings, Dictionary <string, bool> dictPreferences)
        {
            if (dictSettings == null || dictPreferences == null)
            {
                return(false);
            }

            bool bDirty = false;
            IDictionaryEnumerator aEnumerator = dictSettings.GetEnumerator();

            while (aEnumerator.MoveNext())
            {
                PreferenceSettings s   = (PreferenceSettings)aEnumerator.Value;
                string             key = (string)aEnumerator.Key;
                bool bValue            = s.value;
                bool bMasterValue      = dictPreferences[key];

                if (bValue != bMasterValue)
                {
                    bDirty = true;
                    break;
                }
            }
            return(bDirty);
        }
Exemple #3
0
        private void getPreferences(Dictionary <string, PreferenceSettings> dictSettings, Dictionary <string, bool> dictPreferences)
        {
            if (dictSettings == null || dictPreferences == null)
            {
                return;
            }

            dictPreferences.Clear();

            string key;
            bool   bValue;
            IDictionaryEnumerator aEnumerator = dictSettings.GetEnumerator();

            while (aEnumerator.MoveNext())
            {
                PreferenceSettings s = (PreferenceSettings)aEnumerator.Value;
                key    = (string)aEnumerator.Key;
                bValue = s.value;
                dictPreferences.Add(key, bValue);
            }
        }
Exemple #4
0
        public void refreshList(Dictionary <string, PreferenceSettings> dictSettings)
        {
            if (dictSettings == null)
            {
                return;
            }

            this.listView_UserPref.ItemChecked -= new System.Windows.Forms.ItemCheckedEventHandler(this.listView_UserPref_HandleItemChecked);

            listView_UserPref.SuspendLayout();
            listView_UserPref.Items.Clear();
            if (dictSettings.Count > 0)
            {
                ListViewItem lvItem;
                ListViewItem.ListViewSubItem lvSubItem;
                IDictionaryEnumerator        aEnumerator = dictSettings.GetEnumerator();
                while (aEnumerator.MoveNext())
                {
                    PreferenceSettings s   = (PreferenceSettings)aEnumerator.Value;
                    string             key = (string)aEnumerator.Key;

                    // Sunny to do
                    lvItem         = new ListViewItem();
                    lvSubItem      = new ListViewItem.ListViewSubItem();
                    lvItem.Tag     = key;
                    lvItem.Text    = dictSettings[key].displayName;
                    lvItem.Checked = dictSettings[key].value;
                    lvSubItem.Tag  = dictSettings[key].helpString;
                    lvItem.SubItems.Add(lvSubItem);
                    listView_UserPref.Items.Add(lvItem);
                }

                aEnumerator = dictSettings.GetEnumerator();
                while (aEnumerator.MoveNext())
                {
                    PreferenceSettings s   = (PreferenceSettings)aEnumerator.Value;
                    string             key = (string)aEnumerator.Key;

                    // Add help button
                    GUI_Controls.GUIButton b = new GUI_Controls.GUIButton();
                    b.Size = new Size(BUTTON_SIZE, BUTTON_SIZE);

                    List <Image> ilist = new List <Image>();
                    ilist.Clear();
                    ilist.Add(Properties.Resources.PF_BTN01S_details_STD);
                    ilist.Add(Properties.Resources.PF_BTN01S_details_OVER);
                    ilist.Add(Properties.Resources.PF_BTN01S_details_OVER);
                    ilist.Add(Properties.Resources.PF_BTN01S_details_CLICK);
                    b.ChangeGraphics(ilist);

                    b.Tag    = dictSettings[key].helpString;
                    b.Click += new EventHandler(b_Click);

                    for (int i = 0; i < listView_UserPref.Items.Count; i++)
                    {
                        ListViewItem lvItemTemp = listView_UserPref.Items[i];
                        string       temp       = lvItemTemp.Tag as string;
                        if (temp == key)
                        {
                            // Put it in the second column of every row
                            listView_UserPref.AddEmbeddedControl(b, 1, lvItemTemp.Index);
                            break;
                        }
                    }
                }
            }

            this.listView_UserPref.ItemChecked += new System.Windows.Forms.ItemCheckedEventHandler(this.listView_UserPref_HandleItemChecked);
            listView_UserPref.ResumeLayout(true);
        }
Exemple #5
0
        public bool LoadUserPreferences(string userName)
        {
            if (string.IsNullOrEmpty(userName) && !bIsNewUser)
            {
                return(false);
            }

            string logMSG = "";

            logMSG = ":Load " + userName + "preferences";

            dictMasterUserPreferences.Clear();
            dictMasterDevicePreferences.Clear();

            if (bIsNewUser)
            {
                RoboSep_UserDB.getInstance().getDefaultUserAndDevicePreferences(dictMasterUserPreferences, dictMasterDevicePreferences);
            }
            else
            {
                Dictionary <string, bool> dictUserDefault   = new Dictionary <string, bool>();
                Dictionary <string, bool> dictDeviceDefault = new Dictionary <string, bool>();
                RoboSep_UserDB.getInstance().getDefaultUserAndDevicePreferences(dictUserDefault, dictDeviceDefault);
                RoboSep_UserDB.getInstance().getUserAndDevicePreferences(userName, dictMasterUserPreferences, dictMasterDevicePreferences);

                bool bUserDirty   = UpdateDefaultPreferences(dictUserDefault, dictMasterUserPreferences);
                bool bDeviceDirty = UpdateDefaultPreferences(dictDeviceDefault, dictMasterDevicePreferences);

                if (bUserDirty || bDeviceDirty)
                {
                    // Update the user preferences file
                    UserDetails.SaveUserPreferences(userName, dictMasterUserPreferences, dictMasterDevicePreferences);
                }
            }

            if (dictMasterUserPreferences.Count > 0)
            {
                //enumerate the keys
                string dispName, helpString;
                dictUserPreferencesFromConfig.Clear();
                IDictionaryEnumerator aEnumerator = dictMasterUserPreferences.GetEnumerator();
                while (aEnumerator.MoveNext())
                {
                    dispName   = LanguageINI.GetString((string)aEnumerator.Key);
                    helpString = LanguageINI.GetString((string)aEnumerator.Key + "Help");

                    if (string.IsNullOrEmpty(dispName))
                    {
                        dispName = (string)aEnumerator.Key;
                    }

                    if (string.IsNullOrEmpty(helpString))
                    {
                        helpString = (string)aEnumerator.Key;
                    }

                    PreferenceSettings s = new PreferenceSettings((bool)aEnumerator.Value, dispName, helpString);
                    dictUserPreferencesFromConfig.Add((string)aEnumerator.Key, s);
                }
            }

            if (dictMasterDevicePreferences.Count > 0)
            {
                //enumerate the keys
                string dispName, helpString;
                dictDevicePreferencesFromConfig.Clear();
                IDictionaryEnumerator aEnumerator = dictMasterDevicePreferences.GetEnumerator();
                while (aEnumerator.MoveNext())
                {
                    dispName   = LanguageINI.GetString((string)aEnumerator.Key);
                    helpString = LanguageINI.GetString((string)aEnumerator.Key + "Help");
                    if (string.IsNullOrEmpty(dispName))
                    {
                        dispName = (string)aEnumerator.Key;
                    }
                    if (string.IsNullOrEmpty(helpString))
                    {
                        helpString = (string)aEnumerator.Key;
                    }

                    PreferenceSettings s = new PreferenceSettings((bool)aEnumerator.Value, dispName, helpString);
                    dictDevicePreferencesFromConfig.Add((string)aEnumerator.Key, s);
                }
            }

            // LOG
            logMSG = "Get user preferences settings";
            //  (logMSG);
            LogFile.AddMessage(System.Diagnostics.TraceLevel.Info, logMSG);
            return(true);
        }