private static Control CreateCustomControl(string name, Type settingType, string value, ModuleBase module, Page page) { if (settingType.IsEnum) { DropDownList ddl = new DropDownList(); ddl.ID = name; for (int i = 0; i < Enum.GetValues(settingType).Length; i++) { string option = Enum.GetName(settingType, i); ddl.Items.Add(new ListItem(option, option)); } ListItem li = ddl.Items.FindByText(value); if (li != null) { li.Selected = true; } return(ddl); } if (settingType.IsSubclassOf(typeof(EnumrableSetting))) { EnumrableSetting setting = Activator.CreateInstance(settingType) as EnumrableSetting; if (setting != null) { setting.Module = module; return(setting.BindDataToDropDownList(name, value)); } return(null); } if (settingType.IsSubclassOf(typeof(TreeViewSetting))) { TreeViewSetting setting = Activator.CreateInstance(settingType) as TreeViewSetting; if (setting != null) { setting.Module = module; setting.Page = page; return(setting.GetTreeView(name, value)); } return(null); } return(null); }
private void Save_Click(object sender, EventArgs e) { if (MyCommon.IsNetworkAvailable() && (this.ShortUrlPanel.ComboBoxAutoShortUrlFirst.SelectedIndex == (int)MyCommon.UrlConverter.Bitly || this.ShortUrlPanel.ComboBoxAutoShortUrlFirst.SelectedIndex == (int)MyCommon.UrlConverter.Jmp)) { // bit.ly 短縮機能実装のプライバシー問題の暫定対応 // bit.ly 使用時はログインIDとAPIキーの指定を必須とする // 参照: http://sourceforge.jp/projects/opentween/lists/archive/dev/2012-January/000020.html if (string.IsNullOrEmpty(this.ShortUrlPanel.TextBitlyId.Text) || string.IsNullOrEmpty(this.ShortUrlPanel.TextBitlyPw.Text)) { MessageBox.Show("bit.ly のログイン名とAPIキーの指定は必須項目です。", Application.ProductName); _ValidationError = true; TreeViewSetting.SelectedNode = TreeViewSetting.Nodes["ConnectionNode"].Nodes["ShortUrlNode"]; // 動作タブを選択 TreeViewSetting.Select(); this.ShortUrlPanel.TextBitlyId.Focus(); return; } if (!BitlyValidation(this.ShortUrlPanel.TextBitlyId.Text, this.ShortUrlPanel.TextBitlyPw.Text)) { MessageBox.Show(Properties.Resources.SettingSave_ClickText1); _ValidationError = true; TreeViewSetting.SelectedNode = TreeViewSetting.Nodes["ConnectionNode"].Nodes["ShortUrlNode"]; // 動作タブを選択 TreeViewSetting.Select(); this.ShortUrlPanel.TextBitlyId.Focus(); return; } else { _ValidationError = false; } } else { _ValidationError = false; } }