private HWTextareaWithTwoWildCard ConvertTextareaWithTwoWildCard(XmlNode node) { HWTextareaWithTwoWildCard box = new HWTextareaWithTwoWildCard(); SetValue(box, node.Attributes); return(box); }
private ContentControl AddTextareaWithTwoWildCarde(HWTextareaWithTwoWildCard textareaWithTwoWildCard) { TextBlock text = new TextBlock(); text.VerticalAlignment = VerticalAlignment.Center; text.HorizontalAlignment = HorizontalAlignment.Stretch; int value = ConstData.Datas[textareaWithTwoWildCard.Data_type]; string connect = ""; switch (textareaWithTwoWildCard.Data_connector_type) { case "CONN_COLON": connect = ":"; break; // 冒号 “:” case "CONN_STUB": connect = "-"; break; /// CONN_STUB // 短线 “-” case "CONN_SLASH": connect = "/"; break; /// CONN_SLASH // 斜线 “/” case "CONN_BACKSLASH": connect = "\\"; break; /// CONN_BACKSLASH // 反斜线“\” case "CONN_POINT": connect = "."; break; /// CONN_POINT // 点 “.” case "CONN_PERCENT": connect = "%"; break; /// CONN_PERCENT // 百分号“%” case "CONN_SPACE": connect = " "; break; /// CONN_SPACE // 空格 “ ” } if (textareaWithTwoWildCard.Data2_type == "DATA_NULL") { text.Text = value + connect; } else { int value2 = ConstData.Datas[textareaWithTwoWildCard.Data2_type]; text.Text = value + connect + value2; } SetAlignment(text, textareaWithTwoWildCard.Alignment_type); SetFontSize(text, textareaWithTwoWildCard.Font_type); text.Foreground = new SolidColorBrush(Color.FromArgb(textareaWithTwoWildCard.Alpha, textareaWithTwoWildCard.Color_red, textareaWithTwoWildCard.Color_green, textareaWithTwoWildCard.Color_blue)); ContentControl control = new ContentControl { Width = textareaWithTwoWildCard.Drawable_width, Height = textareaWithTwoWildCard.Drawable_height, Style = (Style)Application.Current.Resources["DesignerItemStyle"] }; control.Content = text; canvas.Children.Add(control); Canvas.SetLeft(control, textareaWithTwoWildCard.Drawable_x); Canvas.SetTop(control, textareaWithTwoWildCard.Drawable_y); return(control); }
/// <summary> /// 元素属性发生变化后 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void WatchElement_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) { HWTextareaWithTwoWildCard text = watchElement.HWElement as HWTextareaWithTwoWildCard; switch (e.PropertyName) { case "X": text.Drawable_x = watchElement.X; break; case "Y": text.Drawable_y = watchElement.Y; break; case "Width": text.Drawable_width = watchElement.Width; break; case "Height": text.Drawable_height = watchElement.Height; break; } RefreshControl(); }