UserControl CreateInternalControl() { if (InstanceMember == null) { throw new NullReferenceException(nameof(InstanceMember)); } UserControl controlToAdd = null; if (InstanceMember.PreferredDisplayer != null) { controlToAdd = (UserControl)Activator.CreateInstance(InstanceMember.PreferredDisplayer); } if (controlToAdd == null) { var type = InstanceMember.PropertyType; foreach (var kvp in mTypeDisplayerAssociation) { if (kvp.Key(type)) { controlToAdd = (UserControl)Activator.CreateInstance(kvp.Value); } } } if (controlToAdd == null && InstanceMember.CustomOptions != null && InstanceMember.CustomOptions.Count != 0) { controlToAdd = new ComboBoxDisplay(); } if (controlToAdd == null) { controlToAdd = new TextBoxDisplay(); } var displayerType = controlToAdd.GetType(); foreach (var kvp in InstanceMember.PropertiesToSetOnDisplayer) { var propertyInfo = displayerType.GetProperty(kvp.Key); propertyInfo?.SetValue(controlToAdd, kvp.Value, null); } IDataUi display = (IDataUi)controlToAdd; display.InstanceMember = InstanceMember; InstanceMember.CallUiCreated(controlToAdd); // can we share them like this? Is it safe? OK? this.ContextMenu = controlToAdd.ContextMenu; return(controlToAdd); }
private UserControl CreateControlByType(InstanceMember instanceMember, Type type) { UserControl controlToAdd = null; if (instanceMember.PreferredDisplayer != null) { controlToAdd = (UserControl)Activator.CreateInstance(instanceMember.PreferredDisplayer); } if (controlToAdd == null) { foreach (var kvp in mTypeDisplayerAssociation) { if (kvp.Key(type)) { controlToAdd = (UserControl)Activator.CreateInstance(kvp.Value); } } } if (controlToAdd == null && instanceMember.CustomOptions.Count != 0) { controlToAdd = new ComboBoxDisplay(); } if (controlToAdd == null) { controlToAdd = new TextBoxDisplay(); } IDataUi display = (IDataUi)controlToAdd; display.InstanceMember = instanceMember; return(controlToAdd); }
private void ConfigForm_Load(object sender, EventArgs e) { // 現在の設定をレジストリから読み込む this.loadConfig(); int current, i; this.checkBox_FullScreen.Checked = this.useFullScreen; this.checkBox_FullSoundOFF.Checked = !this.useSound; this.checkBox_MapEffect.Checked = this.useMapEffect; this.checkBox_SpecailEffect.Checked = this.use3DEffect; // ディスプレイ設定 //Structures.Display.Display currentDisplay = this.dispCollector.getDisplay(this.ScreenWidth, this.ScreenHeight); Structures.Display.Display currentDisplay = new TricksterTools.Plugins.ConfigExtra.Structures.Display.Display(this.ScreenWidth, this.ScreenHeight); ComboBoxDisplay dispItem; current = 0; i = 0; foreach (Structures.Display.Display display in this.dispCollector.getMap()) { //dispItem = new ComboBoxDisplay(display.Gauge, display.ToString()); dispItem = new ComboBoxDisplay(display.Width, display.Height, display.ToString()); this.comboBox_Resolution.Items.Add(dispItem); //if (dispItem.Gauge == currentDisplay.Gauge) if (dispItem.Width == currentDisplay.Width && dispItem.Height == currentDisplay.Height) { current = i; } i++; } if (this.comboBox_Resolution.Items.Count > 0) { this.comboBox_Resolution.SelectedIndex = current; } // サンプリングレート設定 Structures.Sound.SampleRate currentRate = new Structures.Sound.SampleRate(); currentRate.Rate = this.SoundFreq; current = 0; i = 0; foreach (Structures.Sound.SampleRate samplerate in this.samprateCollector.getMap()) { this.comboBox_SampleRate.Items.Add(samplerate); if (samplerate.Rate == currentRate.Rate) { current = i; } i++; } this.comboBox_SampleRate.SelectedIndex = current; // ビットレート設定 Structures.Sound.Bits currentBit = new Structures.Sound.Bits(); currentBit.Bit = this.SoundBit; current = 0; i = 0; foreach (Structures.Sound.Bits bit in this.bitCollector.getMap()) { this.comboBox_Bits.Items.Add(bit); if (bit.Bit == currentBit.Bit) { current = i; } i++; } this.comboBox_Bits.SelectedIndex = current; // チャンネル設定 Structures.Sound.Channel currentChannel = new Structures.Sound.Channel(); currentChannel.ch = this.SoundChannel; current = 0; i = 0; foreach (Structures.Sound.Channel ch in this.channelCollector.getMap()) { this.comboBox_Channel.Items.Add(ch); if (ch.ch == currentChannel.ch) { current = i; } i++; } this.comboBox_Channel.SelectedIndex = current; // 画像フォーマット設定 Structures.Images.Formats currentFormat = new Structures.Images.Formats(); currentFormat.Format = this.CaptureScreenFormat; current = 0; i = 0; foreach (Structures.Images.Formats format in this.formatCollector.getMap()) { this.comboBox_FileFormat.Items.Add(format); if (format.Format == currentFormat.Format) { current = i; } i++; } this.comboBox_FileFormat.SelectedIndex = current; // JPEG画質クオリティ(圧縮率) this.trackBar_JPGOption.Value = this.CaptureScreenJPGQuality; this.label_JPGOption_QualityLevel.Text = this.CaptureScreenJPGQuality.ToString() + " %"; }
private void button_OK_Click(object sender, EventArgs e) { this.useFullScreen = this.checkBox_FullScreen.Checked; this.useSound = !this.checkBox_FullSoundOFF.Checked; this.useMapEffect = this.checkBox_MapEffect.Checked; this.use3DEffect = this.checkBox_SpecailEffect.Checked; ComboBoxDisplay combDisplay = (ComboBoxDisplay)this.comboBox_Resolution.SelectedItem; Structures.Display.DisplayCollector dispCol = new Structures.Display.DisplayCollector(); //Structures.Display.Display display = dispCol.getDisplay(combDisplay.Gauge); Structures.Display.Display display = new TricksterTools.Plugins.ConfigExtra.Structures.Display.Display(combDisplay.Width, combDisplay.Height); if (display.Width > 0 && display.Height > 0) { this.ScreenWidth = display.Width; this.ScreenHeight = display.Height; } this.SoundBit = Convert.ToInt16(this.comboBox_Bits.SelectedItem.ToString().Replace(" Bit", "")); this.SoundChannel = Convert.ToInt16(this.comboBox_Channel.SelectedItem.ToString().Replace(" Channel", "")); this.SoundFreq = Convert.ToInt32(this.comboBox_SampleRate.SelectedItem.ToString()); this.CaptureScreenFormat = (this.comboBox_FileFormat.SelectedItem.ToString() == "JPG") ? Structures.Images.ImageFormat.JPG : Structures.Images.ImageFormat.BMP; this.CaptureScreenJPGQuality = this.trackBar_JPGOption.Value; string rKeyName; // 操作するレジストリ・キーの名前 rKeyName = @"SOFTWARE\NTreev\Trickster_GCrest\Setup"; // レジストリの取得 try { // レジストリ・キーのパスを指定してレジストリを開く RegistryKey rKey = Registry.CurrentUser.CreateSubKey(rKeyName); // レジストリの値を取得 rKey.SetValue("Full Screen", ((this.useFullScreen) ? 1 : 0), RegistryValueKind.DWord); rKey.SetValue("heightPixel", this.ScreenHeight, RegistryValueKind.DWord); rKey.SetValue("widthPixel", this.ScreenWidth, RegistryValueKind.DWord); rKey.SetValue("UseSound", ((this.useSound) ? 1 : 0), RegistryValueKind.DWord); rKey.SetValue("SoundBit", this.SoundBit, RegistryValueKind.DWord); rKey.SetValue("SoundFrequency", this.SoundFreq, RegistryValueKind.DWord); int ch = 8; switch (this.SoundChannel) { case 8: ch = 4; break; case 16: ch = 8; break; case 32: ch = 16; break; case 48: ch = 32; break; } int ch3d = (ch > 16) ? 16 : ch; rKey.SetValue("2DSample", ch, RegistryValueKind.DWord); rKey.SetValue("3DSample", ch3d, RegistryValueKind.DWord); rKey.SetValue("Use3DEffect", ((this.use3DEffect) ? 1 : 0), RegistryValueKind.DWord); rKey.SetValue("UseMapEffect", ((this.useMapEffect) ? 1 : 0), RegistryValueKind.DWord); rKey.SetValue("CaptureScreenFormat", this.CaptureScreenFormat.ToString(), RegistryValueKind.String); rKey.SetValue("CaptureScreenJPGQuality", this.CaptureScreenJPGQuality, RegistryValueKind.DWord); // 開いたレジストリ・キーを閉じる rKey.Close(); // 画面サイズに依存するファイルを生成 if (!this.createFileOfScreenSize()) { MessageBox.Show("必要なファイルのコピーが行えませんでした。", "Trickster Config", MessageBoxButtons.OK, MessageBoxIcon.Warning); } ConfigExtra.updateUcf(); } catch (Exception ex) { SimpleLogger.WriteLine(ex.Message); MessageBox.Show("設定の変更に失敗しました。", "Trickster Config", MessageBoxButtons.OK, MessageBoxIcon.Error); throw ex; } this.Close(); }
private void ConfigForm_Load(object sender, EventArgs e) { // ���݂̐ݒ����W�X�g������ǂݍ��� this.loadConfig(); int current, i; this.checkBox_FullScreen.Checked = this.useFullScreen; this.checkBox_FullSoundOFF.Checked = !this.useSound; this.checkBox_MapEffect.Checked = this.useMapEffect; this.checkBox_SpecailEffect.Checked = this.use3DEffect; // �f�B�X�v���C�ݒ� //Structures.Display.Display currentDisplay = this.dispCollector.getDisplay(this.ScreenWidth, this.ScreenHeight); Structures.Display.Display currentDisplay = new TricksterTools.Plugins.ConfigExtra.Structures.Display.Display(this.ScreenWidth, this.ScreenHeight); ComboBoxDisplay dispItem; current = 0; i = 0; foreach (Structures.Display.Display display in this.dispCollector.getMap()) { //dispItem = new ComboBoxDisplay(display.Gauge, display.ToString()); dispItem = new ComboBoxDisplay(display.Width, display.Height, display.ToString()); this.comboBox_Resolution.Items.Add(dispItem); //if (dispItem.Gauge == currentDisplay.Gauge) if (dispItem.Width == currentDisplay.Width && dispItem.Height == currentDisplay.Height) { current = i; } i++; } if (this.comboBox_Resolution.Items.Count > 0) { this.comboBox_Resolution.SelectedIndex = current; } // �T���v�����O���[�g�ݒ� Structures.Sound.SampleRate currentRate = new Structures.Sound.SampleRate(); currentRate.Rate = this.SoundFreq; current = 0; i = 0; foreach (Structures.Sound.SampleRate samplerate in this.samprateCollector.getMap()) { this.comboBox_SampleRate.Items.Add(samplerate); if (samplerate.Rate == currentRate.Rate) { current = i; } i++; } this.comboBox_SampleRate.SelectedIndex = current; // �r�b�g���[�g�ݒ� Structures.Sound.Bits currentBit = new Structures.Sound.Bits(); currentBit.Bit = this.SoundBit; current = 0; i = 0; foreach (Structures.Sound.Bits bit in this.bitCollector.getMap()) { this.comboBox_Bits.Items.Add(bit); if (bit.Bit == currentBit.Bit) { current = i; } i++; } this.comboBox_Bits.SelectedIndex = current; // �`�����l���ݒ� Structures.Sound.Channel currentChannel = new Structures.Sound.Channel(); currentChannel.ch = this.SoundChannel; current = 0; i = 0; foreach (Structures.Sound.Channel ch in this.channelCollector.getMap()) { this.comboBox_Channel.Items.Add(ch); if (ch.ch == currentChannel.ch) { current = i; } i++; } this.comboBox_Channel.SelectedIndex = current; // �摜�t�H�[�}�b�g�ݒ� Structures.Images.Formats currentFormat = new Structures.Images.Formats(); currentFormat.Format = this.CaptureScreenFormat; current = 0; i = 0; foreach (Structures.Images.Formats format in this.formatCollector.getMap()) { this.comboBox_FileFormat.Items.Add(format); if (format.Format == currentFormat.Format) current = i; i++; } this.comboBox_FileFormat.SelectedIndex = current; // JPEG�掿�N�I���e�B�i���k���j this.trackBar_JPGOption.Value = this.CaptureScreenJPGQuality; this.label_JPGOption_QualityLevel.Text = this.CaptureScreenJPGQuality.ToString() + " %"; }