private void button1_Click(object sender, EventArgs e) { /** * ISettings tempSet = new CarSignalSettings(); * ModuleConfig.SaveSettings(tempSet, "test.config"); * Application.Exit(); * */ /** * SettingPair tsp = new SettingPair(); * tsp.ImplementClass = new CarSignalSettings().GetType(); * tsp.FilePath = "test.config"; * CSettings csetting = new CSetup(tsp).Settings as CSettings; * */ SettingPair sp1 = new SettingPair(); sp1.ImplementClass = new CarSignalSettings().GetType(); sp1.FilePath = "CarSignal.config"; SettingPair sp2 = new SettingPair(); sp2.ImplementClass = new MotorSignalSettings().GetType(); sp2.FilePath = "MotorSignal.config"; ExamSetup setupFrm = new ExamSetup(); Dictionary <string, SettingPair> tempSettings = new Dictionary <string, SettingPair>(); tempSettings.Add("汽车设置", sp1); tempSettings.Add("Test 2", sp2); setupFrm.ConfigTable = tempSettings; setupFrm.Show(); }
private void comBoxType_SelectedIndexChanged(object sender, EventArgs e) { SettingPair setPair = _configTable[comBoxType.Text]; _currentSetup = new CSetup(setPair); SignalConfigures sigConf = ((CSettings)_currentSetup.Settings).SignConfig; sigLen.GAN_LENGTH = sigConf.GanLength; sigLen.XIAN_LENGTH = sigConf.XianLength; sigLen.CHE_LENGTH = sigConf.CheLength; picBoxChe = new PictureBox[sigLen.CHE_LENGTH]; this.carPane.Controls.Clear(); for (int i = 0; i < sigLen.CHE_LENGTH; i++) { picBoxChe[i] = new PictureBox(); picBoxChe[i].Width = 20; picBoxChe[i].Height = 20; picBoxChe[i].Top = 0; picBoxChe[i].BackColor = Color.DarkSeaGreen; picBoxChe[i].Left = i * 50; this.carPane.Controls.Add(picBoxChe[i]); } picBoxGan = new PictureBox[sigLen.GAN_LENGTH]; this.ganPane.Controls.Clear(); for (int i = 0; i < sigLen.GAN_LENGTH; i++) { picBoxGan[i] = new PictureBox(); picBoxGan[i].Width = 20; picBoxGan[i].Height = 20; picBoxGan[i].Top = 0; picBoxGan[i].BackColor = Color.DarkSeaGreen; picBoxGan[i].Left = i * 50; picBoxGan[i].Show(); this.ganPane.Controls.Add(picBoxGan[i]); } picBoxXian = new PictureBox[sigLen.XIAN_LENGTH]; this.xianPane.Controls.Clear(); for (int i = 0; i < sigLen.XIAN_LENGTH; i++) { picBoxXian[i] = new PictureBox(); picBoxXian[i].Width = 20; picBoxXian[i].Height = 20; picBoxXian[i].Top = 0; picBoxXian[i].BackColor = Color.DarkSeaGreen; picBoxXian[i].Left = i * 50; picBoxXian[i].Show(); this.xianPane.Controls.Add(picBoxXian[i]); } }
private void SetPrint_Form_Load(object sender, EventArgs e) { if (_configTable != null) { _tabTable = new Dictionary <TabItem, CSetup>(); IDictionaryEnumerator dicEnum = _configTable.GetEnumerator(); while (dicEnum.MoveNext()) { DictionaryEntry ent = dicEnum.Entry; TabItem tab = new TabItem(); tab.Text = (string)ent.Key; tab.Click += new EventHandler(tab_Click); SettingPair set = (SettingPair)ent.Value; CSetup temp = new CSetup(set); CSettings csetting = (CSettings)temp.Settings; PrintSettings psetting = csetting.PrintConfig; TabControlPanel tabControlPanel = new TabControlPanel(); tab.AttachedControl = tabControlPanel; tabControlPanel.Dock = System.Windows.Forms.DockStyle.Fill; tabControlPanel.Location = new System.Drawing.Point(0, 26); tabControlPanel.Name = (string)ent.Key; tabControlPanel.Size = new System.Drawing.Size(409, 440); tabControlPanel.TabItem = tab; PrintSetupPanel prtSetPane = new PrintSetupPanel(); tabControlPanel.Controls.Add(prtSetPane); tabCtrl.Controls.Add(tabControlPanel); this.tabCtrl.Tabs.Add(tab); _tabTable.Add(tab, temp); } if (this.tabCtrl.Tabs.Count > 0) { _currentSetup = _tabTable[this.tabCtrl.SelectedTab]; _currentSetupPanel = (PrintSetupPanel)this.tabCtrl.SelectedPanel.Controls[0]; CSettings csetting = (CSettings)_currentSetup.Settings; PrintSettings settings = csetting.PrintConfig; _currentSetupPanel.SetValues(settings); InitializePrintFormComponent(settings); } } }
/// <inheritdoc/> public override void Execute(object parameter) { if (parameter is SettingManager manager) { SettingPair language = manager.GetValue("Language"); if (language != null) { data = language.GetValue <string>(); } } ExecutionDone(); }
/// <summary> /// Write a value to the setting file using the default connection string /// </summary> /// <param name="key">The key of the setting to use</param> /// <param name="value">The value to use for the setting</param> /// <returns>True if writing was successful</returns> public void AddValue(string key, object value) { if (settings == null) { settings = new HashSet <SettingPair>(); } SettingPair loadedValue = GetValue(key); if (loadedValue == null) { settings.Add(new SettingPair(key, value)); return; } loadedValue.ChangeValue(value); }
private void ExamSetup_Load(object sender, EventArgs e) { if (_configTable != null) { _tabTable = new Dictionary <TabItem, CSetup>(); IDictionaryEnumerator dicEnum = _configTable.GetEnumerator(); while (dicEnum.MoveNext()) { DictionaryEntry ent = dicEnum.Entry; TabItem tab = new TabItem(); tab.Text = (string)ent.Key; tab.Click += new EventHandler(tab_Click); SettingPair set = (SettingPair)ent.Value; CSetup temp = new CSetup(set); PropertyGrid pg = new PropertyGrid(); pg.Dock = System.Windows.Forms.DockStyle.Fill; pg.SelectedObject = temp.Settings; TabControlPanel tabControlPanel = new TabControlPanel(); tab.AttachedControl = tabControlPanel; tabControlPanel.Dock = System.Windows.Forms.DockStyle.Fill; tabControlPanel.Location = new System.Drawing.Point(0, 26); tabControlPanel.Name = (string)ent.Key; //tabControlPanel.Padding = new System.Windows.Forms.Padding(1); tabControlPanel.Size = new System.Drawing.Size(409, 440); //tabControlPanel.TabIndex = 1; tabControlPanel.TabItem = tab; tabControlPanel.Controls.Add(pg); tabCtrl.Controls.Add(tabControlPanel); this.tabCtrl.Tabs.Add(tab); _tabTable.Add(tab, temp); } if (this.tabCtrl.Tabs.Count > 0) { _currentSetup = _tabTable[this.tabCtrl.SelectedTab]; } } }
/// <inheritdoc/> public override bool ConditionFullfilled(object parameter) { SettingPair pair = settingManager.GetValue(settingToCheck); if (pair == null) { return(false); } if (pair.ValueType == typeof(bool)) { return(pair.GetValue <bool>()); } return(false); }
/// <summary> /// Create a new instance of this command /// </summary> /// <param name="settingManager">The settings manager to use</param> /// <param name="settingName">The setting name to change</param> /// <param name="forceReload">Force reload before saving</param> public ChangeSettingCommand( SettingManager settingManager, string settingName, bool forceReload ) { this.settingManager = settingManager; this.settingName = settingName; this.forceReload = forceReload; SettingPair pair = settingManager.GetValue(settingName); if (pair == null) { return; } settingType = pair.ValueType; }
private Dictionary <string, SettingPair> GetOptionConfigTable() { Dictionary <string, SettingPair> tempSettings = new Dictionary <string, SettingPair>(); foreach (ClsInfo clsinfo in appconfig.Options.Option) { Type t = AssemblyInfoFactory.GetType(clsinfo.ClsFilePath, clsinfo.ClsName); SettingPair sp = new SettingPair(); sp.ImplementClass = t; sp.FilePath = clsinfo.ConfigFilePath; tempSettings.Add(clsinfo.Name, sp); } return(tempSettings); }
private void button3_Click(object sender, EventArgs e) { SettingPair sp1 = new SettingPair(); sp1.ImplementClass = new MotorSignalSettings().GetType(); sp1.FilePath = "3WheelMotorSignal.config"; SettingPair sp2 = new SettingPair(); sp2.ImplementClass = new MotorSignalSettings().GetType(); sp2.FilePath = "MotorSignal.config"; Dictionary <string, SettingPair> tempSettings = new Dictionary <string, SettingPair>(); tempSettings.Add("三轮", sp1); tempSettings.Add("二轮", sp2); AssemblyInfoPair monInfo = AssemblyInfoFactory.GetAssemblyInfo(typeof(Cn.Youdundianzi.Share.Signal.Motor.MotorMonitor)); GXTest testFrm = new GXTest(tempSettings, monInfo); testFrm.Show(); }
private void button2_Click(object sender, EventArgs e) { SettingPair sp1 = new SettingPair(); sp1.ImplementClass = new MotorSignalSettings().GetType(); sp1.FilePath = "3WheelMotorSignal.config"; SettingPair sp2 = new SettingPair(); sp2.ImplementClass = new MotorSignalSettings().GetType(); sp2.FilePath = "MotorSignal.config"; //GXSetup setupFrm = new GXSetup(SetupDialogType.ADMIN_PB); //GXSetup setupFrm = new GXSetup(SetupDialogType.PB); GXSetup setupFrm = new GXSetup(SetupDialogType.QF); Dictionary <string, SettingPair> tempSettings = new Dictionary <string, SettingPair>(); tempSettings.Add("三轮取反", sp1); tempSettings.Add("二轮取反", sp2); setupFrm.ConfigTable = tempSettings; setupFrm.Show(); }
public CSetup(SettingPair set) { _settings = ModuleConfig.GetSettings(set.ImplementClass, set.FilePath); this._configFilePath = set.FilePath; }
private void ExamFrm_Load(object sender, EventArgs e) { if (_pracConfig == null) { MessageBox.Show("ExamConfig属性未赋值。"); this.Close(); return; } if (IsExam) { this.Text = "考试窗口"; } else { this.Text = "练习窗口"; } // //读取设置文件,准备环境设置 // //用哪个setting SettingPair sp = new SettingPair(); sp.ImplementClass = AssemblyInfoFactory.GetType(PracticeConfig.Setting.ClsFilePath, PracticeConfig.Setting.ClsName); sp.FilePath = PracticeConfig.Setting.ConfigFilePath; ISettings setting = new CSetup(sp).Settings; CSettings csetting = setting as CSettings; // //创建Monitor,Translator,StateManager。 //准备考试核心引擎 // //用哪个monitor AssemblyInfoPair monInfo = AssemblyInfoFactory.GetAssemblyInfo(PracticeConfig.Monitor.ClsFilePath, PracticeConfig.Monitor.ClsName); mon = SignalMonitorFactory.CreateSignalMonitor(monInfo, setting); //用哪个translator AssemblyInfoPair transInfo = AssemblyInfoFactory.GetAssemblyInfo(PracticeConfig.Translator.ClsFilePath, PracticeConfig.Translator.ClsName); translator = TranslatorFactory.CreateTranslater(transInfo, mon); //用哪个statemanager AssemblyInfoPair stateMgrInfo = AssemblyInfoFactory.GetAssemblyInfo(PracticeConfig.StateManager.ClsFilePath, PracticeConfig.StateManager.ClsName); stateMgr = StateManagerFactory.CreateStateManager(stateMgrInfo, translator, setting); // //创建考试启动停止控件 //实现单会合考试 examCtrl.Anchor = AnchorStyles.None; examCtrl.Dock = DockStyle.Fill; this.paneExamCtrl.Controls.Add(examCtrl); //ExamCtrl控件必须先被add到其父窗口中,然后再进行Initialize examCtrl.InitializeExamComponent(setting, mon, translator, stateMgr); //初始化声音控件(基础声音控件类) SoundCtrl soundCtrl = new SoundCtrl(); //初始化显示牌控件 SettingPair spDisplay = new SettingPair(); spDisplay.ImplementClass = AssemblyInfoFactory.GetType(PracticeConfig.LEDConfig.ClsFilePath, PracticeConfig.LEDConfig.ClsName); spDisplay.FilePath = PracticeConfig.LEDConfig.ConfigFilePath; ISettings dissettings = new CSetup(spDisplay).Settings; DisplayConfig dispalySetting = dissettings as DisplayConfig; displaycomm = DisplayFactory.CreateDisplay(PracticeConfig.LED.ClsFilePath, PracticeConfig.LED.ClsName, dispalySetting); //初始化摄像头 Camera camera = new Camera(0); camera.Anchor = AnchorStyles.None; camera.Dock = DockStyle.Fill; this.groupPanelVideo.Controls.Add(camera); this.Move += new EventHandler(camera.Camera_Move); this.FormClosing += new FormClosingEventHandler(camera.Camera_Closing); if (IsExam) { string[] cxs = ExamConfig.LicenseList.Split(new char[] { ';' }); //初始化车型列表 List <string> cxList = new List <string>(cxs); //用哪个Candidate Infomation Panel CandExamCtrl candExamPane; if (ExamConfig.HasQueue) { //初始化排队列表 CandidateQuery candQuery = new CandidateQuery(); candQuery.Anchor = AnchorStyles.None; candQuery.Dock = DockStyle.Fill; this.paneXQueueList.Controls.Add(candQuery); candExamPane = (CandExamCtrl)CreateModule(ExamConfig.ExamCtrl.ClsFilePath, ExamConfig.ExamCtrl.ClsName, new object[] { candQuery }); } else { candExamPane = (CandExamCtrl)CreateModule(ExamConfig.ExamCtrl.ClsFilePath, ExamConfig.ExamCtrl.ClsName, new object[] { }); } candExamPane.Dock = DockStyle.Fill; candExamPane.InitializeCandExamCtrlComponent(examCtrl, csetting, cxList); this.groupPanelCandInfo.Controls.Add(candExamPane); //结果显示控件 ExamResultPanel resultPanel = new ExamResultPanel(); resultPanel.Anchor = AnchorStyles.None; resultPanel.Dock = DockStyle.Fill; candExamPane.ExamResultReady += new ExamResultDelegate(resultPanel.SetResultText); this.paneXResult.Controls.Add(resultPanel); candExamPane.SoundChange += new MessageDelegate(soundCtrl.PlayText); //注册candExamCtrl的声音变化事件回调函数 candExamPane.LEDDisplayChange += new MessageDelegate(displaycomm.ShowText); //注册candExamCtrl的显示牌变化事件回调函数 candExamPane.CameraChannelChange += new IntegerDelegate(camera.SetChannel); //注册candExamCtrl的摄像头变化事件回调函数 } //创建考试状态显示面板 //单会合考试级别扩展功能 ExamStatusDisplayPanel statePane = new ExamStatusDisplayPanel(); statePane.Anchor = AnchorStyles.None; statePane.InitializeExamComponent(stateMgr); this.paneXStatus.Controls.Add(statePane); //创建信号显示面板 SignalDisplay signaldisplay = new SignalDisplay(mon); signaldisplay.Anchor = AnchorStyles.None; signaldisplay.Dock = DockStyle.Fill; this.paneXSignalDisp.Controls.Add(signaldisplay); //用哪个DisplayPanel BaseModelDisplayPanel modelDisplayPane = (BaseModelDisplayPanel)CreateModule(PracticeConfig.ModelDisplay.ClsFilePath, PracticeConfig.ModelDisplay.ClsName, new object[] { }); modelDisplayPane.Anchor = AnchorStyles.None; modelDisplayPane.InitializeExamComponent(csetting, mon, stateMgr); this.groupPanelModelDisp.Controls.Add(modelDisplayPane); }
private void GXQufan_Load(object sender, EventArgs e) { if (_configTable != null) { _tabTable = new Dictionary <TabItem, CSetup>(); IDictionaryEnumerator dicEnum = _configTable.GetEnumerator(); while (dicEnum.MoveNext()) { DictionaryEntry ent = dicEnum.Entry; TabItem tab = new TabItem(); tab.Text = (string)ent.Key; tab.Click += new EventHandler(tab_Click); SettingPair set = (SettingPair)ent.Value; CSetup temp = new CSetup(set); TabControlPanel tabControlPanel = new TabControlPanel(); tab.AttachedControl = tabControlPanel; tabControlPanel.Dock = System.Windows.Forms.DockStyle.Fill; tabControlPanel.Location = new System.Drawing.Point(0, 26); tabControlPanel.Name = (string)ent.Key; tabControlPanel.Size = new System.Drawing.Size(464, 300); tabControlPanel.TabItem = tab; GroupBox groupBoxGan = new GroupBox(); groupBoxGan.Location = new Point(12, 20); groupBoxGan.Size = new Size(400, 90); groupBoxGan.Text = "杆信号"; GroupBox groupBoxXian = new GroupBox(); groupBoxXian.Location = new Point(12, 125); groupBoxXian.Size = new Size(400, 90); groupBoxXian.Text = "线信号"; CheckBox[] gan; CheckBox[] xian; SignalConfigures tempSigConf = ((CSettings)temp.Settings).SignConfig; gan = new CheckBox[tempSigConf.GanLength]; xian = new CheckBox[tempSigConf.XianLength]; int tempGanVal = 0; int tempXianVal = 0; switch (_type) { case SetupDialogType.QF: this.Text = "取反"; tempGanVal = tempSigConf.AdminQFGan; tempXianVal = tempSigConf.AdminQFXian; break; case SetupDialogType.PB: this.Text = "屏蔽"; tempGanVal = tempSigConf.PBGan; tempXianVal = tempSigConf.PBXian; break; case SetupDialogType.ADMIN_PB: this.Text = "管理员屏蔽"; tempGanVal = tempSigConf.AdminPBGan; tempXianVal = tempSigConf.AdminPBXian; break; } for (int i = 0; i < gan.Length; i++) { gan[i] = new CheckBox(); groupBoxGan.Controls.Add(gan[i]); gan[i].AutoSize = true; gan[i].Location = new System.Drawing.Point(43 + i * 32, 38); gan[i].Text = Convert.ToString(i + 1); gan[i].Size = new System.Drawing.Size(36, 16); gan[i].UseVisualStyleBackColor = true; gan[i].Click += new System.EventHandler(Gan_Click); if (((tempGanVal >> i) & 1) == 1) { gan[i].Checked = true; } else { gan[i].Checked = false; } } for (int i = 0; i < xian.Length; i++) { xian[i] = new CheckBox(); groupBoxXian.Controls.Add(xian[i]); xian[i].AutoSize = true; xian[i].Location = new System.Drawing.Point(43 + i * 32, 38); xian[i].Text = Convert.ToString(i + 1); xian[i].Size = new System.Drawing.Size(36, 16); xian[i].UseVisualStyleBackColor = true; xian[i].Click += new System.EventHandler(Xian_Click); if (((tempXianVal >> i) & 1) == 1) { xian[i].Checked = true; } else { xian[i].Checked = false; } } tabControlPanel.Controls.Add(groupBoxGan); tabControlPanel.Controls.Add(groupBoxXian); tabCtrl.Controls.Add(tabControlPanel); this.tabCtrl.Tabs.Add(tab); _tabTable.Add(tab, temp); } if (this.tabCtrl.Tabs.Count > 0) { _currentSetup = _tabTable[this.tabCtrl.SelectedTab]; _currentSigConf = ((CSettings)_currentSetup.Settings).SignConfig; } } }
private void button4_Click(object sender, EventArgs e) { // //读取设置文件,准备环境设置 // //用哪个setting SettingPair sp1 = new SettingPair(); //sp1.ImplementClass = new MotorSignalSettings().GetType(); sp1.ImplementClass = new TractorSignalSettings().GetType(); sp1.FilePath = "TractorSignal.config"; ISettings setting = new CSetup(sp1).Settings; CSettings csetting = setting as CSettings; // //创建Monitor,Translator,StateManager。 //准备考试核心引擎 // //用哪个monitor //AssemblyInfoPair monInfo = AssemblyInfoFactory.GetAssemblyInfo(typeof(Cn.Youdundianzi.Share.Signal.Motor.MotorMonitor)); //AssemblyInfoPair monInfo = AssemblyInfoFactory.GetAssemblyInfo(typeof(Cn.Youdundianzi.Share.Signal.Car.OldCarMonitor)); AssemblyInfoPair monInfo = AssemblyInfoFactory.GetAssemblyInfo(typeof(Cn.Youdundianzi.Share.Signal.Car.TractorMonitor)); ISignalMonitor mon = SignalMonitorFactory.CreateSignalMonitor(monInfo, setting); //用哪个translator //AssemblyInfoPair transInfo = AssemblyInfoFactory.GetAssemblyInfo(typeof(Cn.Youdundianzi.Exam.MotorSignalTranslator)); AssemblyInfoPair transInfo = AssemblyInfoFactory.GetAssemblyInfo(typeof(Cn.Youdundianzi.Exam.CarSignalTranslator)); ITranslator translator = TranslatorFactory.CreateTranslater(transInfo, mon); //用哪个statemanager //AssemblyInfoPair stateMgrInfo = AssemblyInfoFactory.GetAssemblyInfo(typeof(Cn.Youdundianzi.Exam.State.MotorState.MotorStateManager)); //AssemblyInfoPair stateMgrInfo = AssemblyInfoFactory.GetAssemblyInfo(typeof(Cn.Youdundianzi.Exam.State.PureLineCarState.CarStateManager)); AssemblyInfoPair stateMgrInfo = AssemblyInfoFactory.GetAssemblyInfo(typeof(Cn.Youdundianzi.Exam.State.Tractor.TractorStateManager)); IStateManager stateMgr = StateManagerFactory.CreateStateManager(stateMgrInfo, translator, setting); // //创建考试启动停止控件 //实现单会合考试 ExamCtrlPanel examCtrl = new ExamCtrlPanel(); examCtrl.Location = new System.Drawing.Point(0, 0); this.ctrlPanel.Controls.Add(examCtrl); //ExamCtrl控件必须先被add到其父窗口中,然后再进行Initialize examCtrl.InitializeExamComponent(setting, mon, translator, stateMgr); //创建考试状态显示面板 //单会合考试级别扩展功能 ExamStatusDisplayPanel statePane = new ExamStatusDisplayPanel(); statePane.Location = new System.Drawing.Point(0, 100); statePane.BorderStyle = BorderStyle.Fixed3D; statePane.InitializeExamComponent(stateMgr); this.ctrlPanel.Controls.Add(statePane); //创建信号显示面板 SignalDisplay signaldisplay = new SignalDisplay(mon); signaldisplay.Location = new System.Drawing.Point(0, 20); //sd.BorderStyle = BorderStyle.Fixed3D; this.ctrlPanel.Controls.Add(signaldisplay); //用哪个DisplayPanel //BaseModelDisplayPanel modelDisplayPane = new Cn.Youdundianzi.Share.Module.ModelDisplay.Car.CarModelDisplayPanel(); BaseModelDisplayPanel modelDisplayPane = new Cn.Youdundianzi.Share.Module.ModelDisplay.Car.TractorModelDisplayPanel(); modelDisplayPane.Location = new System.Drawing.Point(200, 0); modelDisplayPane.InitializeExamComponent(csetting, mon, stateMgr); this.ctrlPanel.Controls.Add(modelDisplayPane); /** * //初始化车型列表 * List<string> cxList = new List<string>(2); * cxList.Add("A"); * cxList.Add("B"); * * //初始化排队列表 * CandidateQuery candQuery = new CandidateQuery(); * candQuery.Location = new System.Drawing.Point(550, 20); * //sd.BorderStyle = BorderStyle.Fixed3D; * this.ctrlPanel.Controls.Add(candQuery); * * //用哪个Candidate Infomation Panel * CandExamCtrl candExamPane = new Cn.Youdundianzi.Share.Module.CandidateInfo.LocalInputPanel(); * candExamPane.Location = new System.Drawing.Point(0, 150); * candExamPane.InitializeCandExamCtrlComponent(examCtrl, csetting, cxList); * this.ctrlPanel.Controls.Add(candExamPane); * * //初始化声音控件(基础声音控件类) * SoundCtrl soundCtrl = new SoundCtrl(); * candExamPane.SoundChange += new MessageDelegate(soundCtrl.PlayText); //注册candExamCtrl的声音变化事件回调函数 * * //初始化显示牌控件 * //------------------------------------------------------------------------------ * string LEDAssemblyFilePath = Application.StartupPath + "\\LEDDisplay.dll"; * * SettingPair spDisplay = new SettingPair(); * spDisplay.ImplementClass = AssemblyInfoFactory.GetType(LEDAssemblyFilePath, csetting.DisplayPaneConfig.DisplayConfigClass); * spDisplay.FilePath = csetting.DisplayPaneConfig.DisplayConfigFilePath; * * ISettings dissettings = new CSetup(spDisplay).Settings; * DisplayConfig dispalySetting = dissettings as DisplayConfig; * IDisplaycomm displaycomm = DisplayFactory.CreateDisplay(LEDAssemblyFilePath, csetting.DisplayPaneConfig.DisplayCommClass, dispalySetting); * candExamPane.LEDDisplayChange += new MessageDelegate(displaycomm.ShowText); //注册candExamCtrl的显示牌变化事件回调函数 * * * //初始化摄像头 * Camera camera = new Camera(0); * camera.Location = new System.Drawing.Point(200, 400); * camera.Size = new Size(400, 300); * camera.BorderStyle = BorderStyle.Fixed3D; * this.ctrlPanel.Controls.Add(camera); * candExamPane.CameraChannelChange += new IntegerDelegate(camera.SetChannel); //注册candExamCtrl的摄像头变化事件回调函数 * * //结果显示控件 * ExamResultPanel resultPanel = new ExamResultPanel(); * resultPanel.Location = new System.Drawing.Point(0, 400); * resultPanel.Size = new Size(210, 110); * resultPanel.BorderStyle = BorderStyle.FixedSingle; * candExamPane.ExamResultReady += new ExamResultDelegate(resultPanel.SetResultText); **/ }
private void Sound_Test_Form_Load(object sender, EventArgs e) { if (_configTable != null) { _tabTable = new Dictionary <TabItem, CSetup>(); IDictionaryEnumerator dicEnum = _configTable.GetEnumerator(); while (dicEnum.MoveNext()) { DictionaryEntry ent = dicEnum.Entry; TabItem tab = new TabItem(); tab.Text = (string)ent.Key; tab.Click += new EventHandler(tabCtrl_Click); SettingPair set = (SettingPair)ent.Value; CSetup temp = new CSetup(set); TabControlPanel tabControlPanel = new TabControlPanel(); tab.AttachedControl = tabControlPanel; tabControlPanel.Dock = System.Windows.Forms.DockStyle.Fill; tabControlPanel.Location = new System.Drawing.Point(0, 26); tabControlPanel.Name = (string)ent.Key; tabControlPanel.Size = new System.Drawing.Size(306, 150); tabControlPanel.TabItem = tab; //Ìí¼Ó×Ô¼ºµÄ¿Ø¼þ GroupBox tempGroupBox = new GroupBox(); tempGroupBox.Dock = DockStyle.Fill; tempGroupBox.Name = "tempGroupBox"; tempGroupBox.Text = "ÓïÒôÉèÖÃ"; Label tempLabel = new Label(); tempLabel.Location = new Point(10, 17); tempLabel.Size = new Size(300, 20); tempLabel.Text = "ÇëÑ¡ÔñÉùÒô£¬²¢ÊäÈë²âÊÔÓï¾ä¡£"; tempGroupBox.Controls.Add(tempLabel); ComboBox tempComboBox = new ComboBox(); int i = 0; foreach (ISpeechObjectToken spObj in spObjs) { tempComboBox.Items.Add(spObj.GetDescription(i++)); } try { tempComboBox.SelectedIndex = ((CSettings)temp.Settings).SoundConfig.VoiceIndex; } catch {} tempComboBox.DropDownStyle = ComboBoxStyle.DropDownList; tempComboBox.Name = "comboBox"; tempComboBox.Location = new Point(20, 40); tempComboBox.Size = new Size(260, 20); tempComboBox.SelectedIndexChanged += new EventHandler(comboBoxVoiceList_SelectedIndexChanged); tempGroupBox.Controls.Add(tempComboBox); TextBox tempTxtBox = new TextBox(); tempTxtBox.Name = "txtBox"; tempTxtBox.Location = new Point(20, 80); tempTxtBox.Size = new Size(260, 20); tempGroupBox.Controls.Add(tempTxtBox); Button previewBtn = new Button(); previewBtn.Location = new Point(220, 120); previewBtn.Size = new Size(80, 25); previewBtn.Text = "²¥·ÅÉùÒô"; previewBtn.Click += new EventHandler(buttonPreview_Click); tempGroupBox.Controls.Add(previewBtn); //×Ô¼ºµÄ¿Ø¼þÌí¼ÓÍê±Ï tabControlPanel.Controls.Add(tempGroupBox); tabCtrl.Controls.Add(tabControlPanel); this.tabCtrl.Tabs.Add(tab); _tabTable.Add(tab, temp); } if (this.tabCtrl.Tabs.Count > 0) { _currentSetup = _tabTable[this.tabCtrl.SelectedTab]; _currentVoiceIndex = ((ComboBox)tabCtrl.SelectedPanel.Controls.Find("comboBox", true)[0]).SelectedIndex; _currentTxtBox = (TextBox)tabCtrl.SelectedPanel.Controls.Find("txtBox", true)[0]; } } }
/// <summary> /// This will directly get you the value from a setting pair /// </summary> /// <typeparam name="T">The type to load</typeparam> /// <param name="key">The key to search for</param> /// <returns>The requested setting</returns> public T GetValue <T>(string key) { SettingPair pair = GetValue(key); return(pair == null ? default : pair.GetValue <T>()); }