コード例 #1
0
ファイル: ExecutionAttributes.cs プロジェクト: mind0n/hive
		public bool Validate(SettingTag tag)
		{
			object value = tag.Value;
			if (IsRequired)
			{
				if (value == null)
				{
					return false;
				}
				if (value is string)
				{
					if (string.IsNullOrEmpty(value.ToString()))
					{
						return false;
					}
					else
					{
						if (tag.EditorType == 0 && tag.Target != null && tag.Target is SetCommand)
						{
							SetCommand cmd = (SetCommand)tag.Target;
							if (cmd.Id.EndsWith("path", StringComparison.OrdinalIgnoreCase) || cmd.Id.EndsWith("dir", StringComparison.OrdinalIgnoreCase) || cmd.Id.EndsWith("directory", StringComparison.OrdinalIgnoreCase))
							{
								
								if (!cmd.Value.ToString().EndsWith("\\"))
								{
									cmd.Value = cmd.Value.ToString() + "\\";
								}
							}
						}
						return true;
					}
				}
			}
			return true;
		}
コード例 #2
0
ファイル: AutoSettingPanel.cs プロジェクト: mind0n/hive
		public SettingTag AddCmdItem(string name, CommandNode target, string field, int editorType = 0, bool isReadonly = false)
		{
			if (target == null)
			{
				return null;
			}
			UICommandNode ucmd = null;
			if (target is UICommandNode)
			{
				ucmd = (UICommandNode)target;
			}
			PathBrowser pb = new PathBrowser();
			ComboBox rd = new ComboBox();
			TextBox editor = new TextBox();
			CheckBox ck = new CheckBox();
			Label lb = new Label { Text = name, AutoSize = true };
			if (!string.IsNullOrEmpty(target.Editor) && editors.ContainsKey(target.Editor))
			{
				editorType = editors[target.Editor];
			}
			editor.AllowDrop = true;
            editor.MouseDoubleClick += new MouseEventHandler(editor_MouseDoubleClick);
			ck.Enabled = !isReadonly;
			editor.Enabled = !isReadonly;
			rd.Enabled = !isReadonly;
			lb.MouseDown += new MouseEventHandler(lb_MouseDown);
			SettingTag rlt = null;
			FieldInfo f = target.GetType().GetField(field);
			if (f != null)
			{
				rlt = new SettingTag { FieldInfo = f, Target = target };
				lb.Tag = rlt;
				object value = f.GetValue(target);
				rlt.EditorType = editorType;
				rlt.LabelControl = lb;
				if (editorType == 1)
				{
					rlt.EditControl = ck;
					ck.Tag = rlt;
					ck.Checked = value != null ? bool.Parse(value.ToString()) : false;
					ck.CheckedChanged += new EventHandler(ck_CheckedChanged);
					UpdatePos(lb, ck);
					NotifyUINode(ucmd, ck, lb);
				}
				else if (editorType == 2)
				{
					ArrayCommand arr = target as ArrayCommand;
					if (arr != null)
					{
						//rd.DataSource = null;
						rd.Items.Clear();	 
						rlt.EditControl = rd;
						rd.Tag = rlt;
						//rd.DataSource = arr.GetList();
						rd.Items.AddRange(arr.GetList());
						rd.SelectedIndex = arr.SelectedIndex;
						rd.SelectedIndexChanged += new EventHandler(rd_SelectedIndexChanged);						
						UpdatePos(lb, rd);
						NotifyUINode(ucmd, rd, lb);
					}
				}
				else if (editorType == 3)
				{
					rlt.EditControl = pb;
					pb.Tag = rlt;
					if (value != null)
					{
						pb.StartupPath = value.ToString();
					}
					pb.OnTextChanged+=new Action<PathBrowser>(pb_OnTextChanged);
					UpdatePos(lb, pb);
					NotifyUINode(ucmd, pb, lb);
				}
				else
				{
					if (lb.Text.IndexOf("pwd", StringComparison.OrdinalIgnoreCase) >= 0 || lb.Text.IndexOf("password", StringComparison.OrdinalIgnoreCase) >= 0)
					{
						editor.PasswordChar = '*';
					}
					editor.DragEnter += new DragEventHandler(editor_DragEnter);
					editor.DragDrop += new DragEventHandler(editor_DragDrop);
					if (editorType == 4)
					{
						editor.WordWrap = false;
						editor.ScrollBars = ScrollBars.Both;
						editor.Multiline = true;
						editor.Height = 100;
					}
					rlt.EditControl = editor;
					rlt.Id = lb.Text;
					rlt.EditorType = 0;
					editor.Tag = rlt;
					editor.Text = value != null ? value.ToString() : string.Empty;
					editor.TextChanged += new EventHandler(editor_TextChanged);
					UpdatePos(lb, editor);
					NotifyUINode(ucmd, editor, lb);
				}
			}
			return rlt;
		}
コード例 #3
0
ファイル: AutoSettingPanel.cs プロジェクト: mind0n/hive
		public SettingTag AddItem(string name, object target, string field)
		{
			Label lb = new Label { Text = name, AutoSize = true };
			TextBox editor = new TextBox();
			SettingTag rlt = null;
			FieldInfo f = target.GetType().GetField(field);
			if (f != null)
			{
				rlt = new SettingTag { FieldInfo = f, Target = target, Attribute = new ParameterAttribute { IsRequired = true } };
				rlt.LabelControl = lb;
				lb.Tag = rlt;
				object value = f.GetValue(target);
				editor.Tag = rlt;
				editor.Text = value != null ? value.ToString() : string.Empty;
				editor.TextChanged += new EventHandler(editor_TextChanged);
				UpdatePos(lb, editor);
			}
			return rlt;
		}