private void setPreferenceControl(int index)
        {
            if (m_openPreference != null)
            {
                m_openPreference.Hide();
                this.Controls.Remove(m_openPreference);
            }

            string tag = modules.Items[index] as string;

            m_currentModule = tag;
            if (tag == "General")
            {
                m_openPreference = new GeneralPreferences();
            }
            else
            {
                Type    moduleType = (StateMaster.getModules()[tag]);
                IModule module     = Activator.CreateInstance(moduleType) as IModule;

                m_openPreference = module.getPreferenceControl();
            }

            m_openPreference.LoadValues(m_currentPreferenceData[tag]);
            this.Controls.Add(m_openPreference);
            m_openPreference.Show();
            alignWidgets();
        }
        public ModulePreferencesForm()
        {
            InitializeComponent();

            Dictionary <string, Type> moduleTypes = StateMaster.getModules();

            m_dirtyModules          = new SortedSet <string>();
            m_cachedPreferenceData  = new Dictionary <string, Dictionary <string, object> >();
            m_currentPreferenceData = new Dictionary <string, Dictionary <string, object> >();
            m_validClosing          = false;

            modules.Items.Add("General");
            m_cachedPreferenceData["General"]  = StateMaster.getPreferenceData("General");
            m_currentPreferenceData["General"] = m_cachedPreferenceData["General"];
            int index = 1;

            foreach (KeyValuePair <string, Type> kv in moduleTypes)
            {
                IModule moduleInstance = Activator.CreateInstance(kv.Value) as IModule;
                if (moduleInstance.preferencesAvailable())
                {
                    modules.Items.Add(kv.Key);
                    m_cachedPreferenceData[kv.Key]  = StateMaster.getPreferenceData(kv.Key);
                    m_currentPreferenceData[kv.Key] = m_cachedPreferenceData[kv.Key];
                    index++;
                }
            }
            Dirty = false;
            modules.SetSelected(0, true);

            m_currentModule = "General";
            m_daemonThread  = new Thread(new ThreadStart(updateDaemon));
            m_daemonThread.Start();
        }
Exemplo n.º 3
0
        public SelectModulesForm()
        {
            InitializeComponent();
            alignWidgets();
            m_hoverIndex      = -1;
            m_alreadySelected = false;

            Dictionary <string, Type> moduleList = StateMaster.getModules();

            m_modules = new List <IModule>();

            foreach (KeyValuePair <string, Type> module in moduleList)
            {
                Type    moduleType = module.Value;
                IModule moduleObj  = Activator.CreateInstance(moduleType) as IModule;

                checkedList.Items.Add(moduleObj.name());//.Key);
                if (StateMaster.isModuleActive(module.Value))
                {
                    checkedList.SetItemChecked(checkedList.Items.Count - 1, true);
                }

                string value = moduleObj.description();
                m_modules.Add(moduleObj);
            }

            m_alreadySelected = false;
        }