private static void OnColorChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { var control = d as Item; if (e.NewValue != e.OldValue) { control.IconColor = Colors.GetColor(control.Color); //if (control.Color == ColorTypes.White) //{ // control.Foreground = Colors.GetFromString("#323130"); // control.BorderBrush = Colors.GetFromString("#8A8886"); // control.BorderThickness = new Thickness(1); //} //else //{ // control.Foreground = Colors.GetColor(ColorTypes.White); // control.BorderBrush = control.Background; // control.BorderThickness = new Thickness(0); //} } }
public Item() { DefaultStyleKey = typeof(Item); Foreground = Colors.GetFromString("#323130"); BorderThickness = new Thickness(0); }
/// <summary> /// 验证输入是否有效 /// </summary> private void Valid(InputBox inputTextBox) { inputTextBox.BorderBrush = FindResource("InputBorderBrush") as SolidColorBrush; if (inputTextBox == null) { return; } if (inputTextBox.Text == string.Empty) { return; } //验证操作结果变量 var matchs = Regex.Matches(inputTextBox.Text, @"\{(?<id>[0-9]{1,5})\.(?<key>[0-9]{1,25})\}"); foreach (Match match in matchs) { var id = int.Parse(match.Groups["id"].Value); var key = int.Parse(match.Groups["key"].Value); //判断action是否存在 var action = ActionContainer.ActionItems.Where(m => m.Action.ID == id && m.Action.Index < Action.Index).FirstOrDefault(); if (action == null) { inputTextBox.BorderBrush = Colors.GetColor(ColorTypes.Red); break; } //判断action是否支持该变量 var results = ActionData.GetActionResults(action.Action.ActionType); if (!results.Where(m => m.ID == key).Any()) { inputTextBox.BorderBrush = Colors.GetColor(ColorTypes.Red); break; } } //验证事件变量 var eventVariableMatchs = Regex.Matches(inputTextBox.Text, @"\{(?<key>[a-zA-Z]{1,25})\}"); if (eventVariableMatchs.Count > 0) { if (!EventVariableData.Variables.ContainsKey(ActionContainer.EventType)) { inputTextBox.BorderBrush = Colors.GetColor(ColorTypes.Red); return; } var eventVariables = EventVariableData.Variables[ActionContainer.EventType]; foreach (Match match in eventVariableMatchs) { var key = match.Groups["key"].Value; if (!eventVariables.ContainsKey(key)) { inputTextBox.BorderBrush = Colors.GetColor(ColorTypes.Red); break; } } } //验证全局变量 var variables = Regex.Matches(inputTextBox.Text, @"\{@(?<key>[a-zA-Z]{1,25})\}"); if (variables.Count > 0) { foreach (Match variable in variables) { var key = variable.Groups["key"].Value; if (!GlobalVariable.Variables.ContainsKey(key)) { inputTextBox.BorderBrush = Colors.GetColor(ColorTypes.Red); break; } } } }