private HWCircle ConvertCircle(XmlNode node) { HWCircle box = new HWCircle(); SetValue(box, node.Attributes); return(box); }
private ContentControl AddCircle(HWCircle circel) { Image image = new Image(); BitmapImage bitmapImage = ImageHelper.GetImage(circel.Res_name); image.Source = bitmapImage; image.Width = bitmapImage.PixelWidth; image.Height = bitmapImage.PixelHeight; image.Stretch = Stretch.Fill; ContentControl control = new ContentControl { Width = image.Width, Height = image.Height, Style = (Style)Application.Current.Resources["DesignerItemStyle"] }; control.Content = image; canvas.Children.Add(control); Canvas.SetLeft(control, circel.Drawable_x); Canvas.SetTop(control, circel.Drawable_y); int curValue = ConstData.Datas[circel.Data_type]; SetClip(image, new Point(circel.Drawable_x, circel.Drawable_y), new Size(circel.Drawable_width, circel.Drawable_height), new Point(circel.Circle_x, circel.Circle_y), circel.Circle_r, circel.Line_width, circel.Arc_start, circel.Arc_end, curValue); return(control); }
/// <summary> /// 刷新控件 /// </summary> private void RefreshControl() { if (WatchElement.DesignerControl != null && WatchElement.DesignerControl.Content != null && WatchElement.DesignerControl.Content is Image image) { HWCircle circel = WatchElement.HWElement as HWCircle; int curValue = ConstData.Datas[circel.Data_type]; ClockDialCreater.SetClip(image, new Point(circel.Drawable_x, circel.Drawable_y), new Size(circel.Drawable_width, circel.Drawable_height), new Point(circel.Circle_x, circel.Circle_y), circel.Circle_r, circel.Line_width, circel.Arc_start, circel.Arc_end, curValue); } }
/// <summary> /// 元素属性发生变化后 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void WatchElement_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) { HWCircle circel = watchElement.HWElement as HWCircle; switch (e.PropertyName) { case "X": circel.Drawable_x = watchElement.X; break; case "Y": circel.Drawable_y = watchElement.Y; break; case "Width": circel.Drawable_width = watchElement.Width; break; case "Height": circel.Drawable_height = watchElement.Height; break; } }