/// <summary> /// 属性型オプションの有無判定と属性値の取得 /// </summary> /// <param name="value">属性値の <code>out parameter</code> </param> /// <param name="names">判定するオプション名(複数指定可)</param> /// <returns>解析したコマンドライン引数 <code>args</code> に、 /// 指定した属性型オプションが含まれる場合は <code>true</code> を、 /// 含まれていない場合は <code>false</code> を返し、 /// 含まれる場合はその <seealso cref="PropertyOption.value"/> を /// <code>out parameter</code> に設定します。 /// </returns> /// <seealso cref="PropertyOption"/> public bool Prop(out string value, params string[] names) { foreach (var name in names) { if (this.properties.ContainsKey(name)) { PropertyOption prop = this.properties[name]; value = prop.value; return(true); } } value = null; return(false); }
List <WidgetViewModBase> GetEligibleWidgets_Toolbar(PropertyOption type) { var ListWidget = _Selection.GetSelectedWidgets().OfType <WidgetViewModBase>().ToList <WidgetViewModBase>(); switch (type) { case PropertyOption.Option_Border: return(ListWidget.FindAll(k => k.IsSupportBorber == true)); case PropertyOption.Option_Text: return(ListWidget.FindAll(k => k.IsSupportText == true)); case PropertyOption.Option_LineArrow: return(ListWidget.FindAll(k => k.IsSupportArrowStyle == true)); case PropertyOption.Option_TextHor: return(ListWidget.FindAll(k => k.IsSupportTextHorAlign == true)); case PropertyOption.Option_TextVer: return(ListWidget.FindAll(k => k.IsSupportTextVerAlign == true)); case PropertyOption.Option_Bullet: return(ListWidget.FindAll(k => k.IsSupportTextRotate == true)); case PropertyOption.OPtion_BackColor: return(ListWidget.FindAll(k => k.IsSupportBackground == true)); case PropertyOption.Option_TextRotate: return(ListWidget.FindAll(k => k.IsSupportTextRotate == true)); case PropertyOption.Option_WidgetRotate: return(ListWidget.FindAll(k => k.IsSupportRotate == true)); case PropertyOption.Option_CornerRadius: return(ListWidget.FindAll(k => k.IsSupportCornerRadius == true)); default: System.Diagnostics.Debug.Assert(false, "GetEligibleWidgets_Toolbar function error!"); return(null); } }
internal DictionaryPropertyDescriptor(IDictionary d, PropertyOption option) : base(option.Text ?? option.Name, null) { values = d; this.Option = option; var attrs = new List <Attribute>(); if (!string.IsNullOrEmpty(option.Description)) { attrs.Add(new DescriptionAttribute(option.Description)); } if (option.Choices != null && option.Choices.Length > 0) { attrs.Add(new TypeConverterAttribute(typeof(ChoiceConverter))); } if (!string.IsNullOrWhiteSpace(option.TypeName)) { attrs.Add(new EditorAttribute(typeof(PropertyOptionEditor), typeof(UITypeEditor))); } this.attrs = new AttributeCollection(attrs.ToArray()); }
public bool IsSupportProperty_Toolbar(PropertyOption type) { List <WidgetViewModBase> allSelects = _Selection.GetSelectedWidgets().OfType <WidgetViewModBase>().ToList <WidgetViewModBase>(); switch (type) { case PropertyOption.Option_Border: return(allSelects.Exists(k => k.IsSupportBorber == true)); case PropertyOption.OPtion_BackColor: return(allSelects.Exists(k => k.IsSupportBackground == true)); case PropertyOption.Option_Bullet: return(allSelects.Exists(k => k.IsSupportTextRotate == true)); case PropertyOption.Option_LineArrow: return(allSelects.Exists(k => k.IsSupportArrowStyle == true)); case PropertyOption.Option_Text: return(allSelects.Exists(k => k.IsSupportText == true)); case PropertyOption.Option_TextHor: return(allSelects.Exists(k => k.IsSupportTextHorAlign == true)); case PropertyOption.Option_TextVer: return(allSelects.Exists(k => k.IsSupportTextVerAlign == true)); case PropertyOption.Option_TextRotate: return(allSelects.Exists(k => k.IsSupportTextRotate == true)); case PropertyOption.Option_WidgetRotate: return(allSelects.Exists(k => k.IsSupportRotate == true)); case PropertyOption.Option_CornerRadius: return(allSelects.Exists(k => k.IsSupportCornerRadius == true)); } System.Diagnostics.Debug.Assert(false, "IsSupportProperty_Toolbar type error"); return(false); }
public void Add(string arg) { if (arg.startsWith("/", "-")) { #region オプションのパース string option = arg.TrimStart('/', '-'); // ■ xxx=xxx aaa:bbb 形式の場合はプロパティオプション string[] token = { null, null }; if (option.slice(out token[0], out token[1], '=', ':')) { PropertyOption prop = new PropertyOption(token[0], token[1]); if (!this.properties.ContainsKey(prop.Name)) { this.properties.Add(prop.Name, prop); this.options.Add(prop); } } // ■プロパティ形式でない場合は単なるスイッチオプション。 else { ValueOption value = new ValueOption(option); if (!this.values.ContainsKey(value.Name)) { this.values.Add(value.Name, value); this.options.Add(value); } } #endregion } else { #region パラメータ this.parameters.Add(arg); #endregion } }
public bool IsSupportProperty_Panel(PropertyOption type) { var allSelects = GetSelectionWidget();; switch (type) { case PropertyOption.Option_Border: return(allSelects.Exists(k => k.IsSupportBorber == true)); case PropertyOption.OPtion_BackColor: return(allSelects.Exists(k => k.IsSupportBackground == true)); case PropertyOption.Option_Bullet: return(allSelects.Exists(k => k.IsSupportTextRotate == true)); case PropertyOption.Option_LineArrow: return(allSelects.Exists(k => k.IsSupportArrowStyle == true)); case PropertyOption.Option_Text: return(allSelects.Exists(k => k.IsSupportText == true)); case PropertyOption.Option_TextHor: return(allSelects.Exists(k => k.IsSupportTextHorAlign == true)); case PropertyOption.Option_TextVer: return(allSelects.Exists(k => k.IsSupportTextVerAlign == true)); case PropertyOption.Option_WidgetRotate: return(allSelects.Exists(k => k.IsSupportRotate == true)); case PropertyOption.Option_TextRotate: return(allSelects.Exists(k => k.IsSupportTextRotate == true)); case PropertyOption.Option_CornerRadius: return(allSelects.Exists(k => k.IsSupportCornerRadius == true)); } System.Diagnostics.Debug.Assert(false, "IsSupportProperty_Panel function error!"); return(false); }
private void AssignValueInternal(object convertedValue, ICommand command) { if (!PropertyOption.PropertyType.IsMultiValuedType()) { PropertyOption.SetValue(command, convertedValue, null); } else { if (_miAddMethod == null) { throw new InvalidOperationException(); } var optionValue = PropertyOption.GetValue(command, null); if (optionValue == null) { if (PropertyOption.CanWrite) { optionValue = Activator.CreateInstance(PropertyOption.PropertyType); PropertyOption.SetValue(command, optionValue, null); } else { throw new CommandLineParserException(Constants.ExceptionMessages.ParserMultiValueOptionIsNullAndHasNoSetter(DisplayInfo.Name, CommandMetadata.Name)); } } if (PropertyOption.PropertyType.IsCollectionType()) { _miAddMethod.Invoke(optionValue, new[] { convertedValue }); } else { var targetTupleValue = (Tuple <object, object>)convertedValue; _miAddMethod.Invoke(PropertyOption.GetValue(command, null), new[] { targetTupleValue.Item1, targetTupleValue.Item2 }); } } }
private void ProcessOption(XmlElement parentElement, TreeNode parentTreeNode, Dictionary <String, PropertyOption> options) { foreach (XmlNode child in parentElement.ChildNodes) { var element = child as XmlElement; if (element != null) { if ("option".Equals(child.Name)) { string name = element.GetAttribute("name"); var node = new TreeNode(name); node.SelectedImageIndex = node.ImageIndex = int.Parse(element.GetAttribute("imageId")); if (parentTreeNode == null) { optionTree.Nodes.Add(node); } else { parentTreeNode.Nodes.Add(node); } PropertyOption option = null; if (options.ContainsKey(name)) { option = options[name]; } else { option = new PropertyOption(name); options.Add(name, option); } try { ProcessOption(element, node, option.Options); } catch (Exception) { int i = 0; } } else if ("controls".Equals(child.Name)) { var properties = new Dictionary <string, PropertyOption>(); foreach (XmlNode control in element.ChildNodes) { var xmlElement = control as XmlElement; if (xmlElement != null) { string _label = xmlElement.GetAttribute("label"); string _name = xmlElement.GetAttribute("name"); string _default = xmlElement.GetAttribute("default"); string _class = xmlElement.GetAttribute("class"); string _description = xmlElement.GetAttribute("description"); string _category = xmlElement.GetAttribute("category"); object _value = ATMLContext.GetProperty(_name); if (!string.IsNullOrEmpty(_class)) { if (_value == null) { _value = "String".Equals(_class) ? _default : "double".Equals(_class) ? double.Parse(_default) : "int".Equals(_class) ? int.Parse(_default) : "Int32".Equals(_class) ? Int32.Parse(_default) : "Boolean".Equals(_class) ? "1" == _default : "Color".Equals(_class) ? ColorTranslator.FromHtml(_default) : Activator.CreateInstance(Type.GetType(_class)); } PropertyOption option = null; if (options.ContainsKey(_name)) { option = options[_name]; } else { option = new PropertyOption(_name); option.Description = _description; option.Category = _category; option.Label = _label; options.Add(_name, option); } option.Value = _value; properties.Add(_name, option); } } } if (parentTreeNode != null) { parentTreeNode.Tag = properties; } } } } }
private void ProcessOption(XmlElement parentElement, TreeNode parentTreeNode, Dictionary<String, PropertyOption> options ) { foreach (XmlNode child in parentElement.ChildNodes) { var element = child as XmlElement; if (element != null) { if ("option".Equals(child.Name)) { string name = element.GetAttribute("name"); var node = new TreeNode(name); node.SelectedImageIndex = node.ImageIndex = int.Parse(element.GetAttribute("imageId")); if (parentTreeNode == null) optionTree.Nodes.Add(node); else parentTreeNode.Nodes.Add(node); PropertyOption option = null; if (options.ContainsKey(name)) option = options[name]; else { option = new PropertyOption(name); options.Add(name, option); } try { ProcessOption(element, node, option.Options); } catch (Exception) { int i = 0; } } else if ("controls".Equals(child.Name)) { var properties = new Dictionary<string, PropertyOption>(); foreach (XmlNode control in element.ChildNodes) { var xmlElement = control as XmlElement; if (xmlElement != null) { string _label = xmlElement.GetAttribute("label"); string _name = xmlElement.GetAttribute("name"); string _default = xmlElement.GetAttribute("default"); string _class = xmlElement.GetAttribute("class"); string _description = xmlElement.GetAttribute("description"); string _category = xmlElement.GetAttribute("category"); object _value = ATMLContext.GetProperty(_name); if (!string.IsNullOrEmpty(_class)) { if( _value == null ) _value = "String".Equals(_class) ? _default : "double".Equals(_class) ? double.Parse(_default) : "int".Equals(_class) ? int.Parse(_default) : "Int32".Equals(_class) ? Int32.Parse(_default) : "Boolean".Equals(_class) ? "1"==_default : "Color".Equals(_class) ? ColorTranslator.FromHtml(_default) : Activator.CreateInstance(Type.GetType(_class)); PropertyOption option = null; if (options.ContainsKey(_name)) option = options[_name]; else { option = new PropertyOption(_name); option.Description = _description; option.Category = _category; option.Label = _label; options.Add(_name, option); } option.Value = _value; properties.Add(_name, option); } } } if (parentTreeNode != null) parentTreeNode.Tag = properties; } } } }
public Bar(PropertyOption prop) { this.prop = prop; }