/// <summary> /// 新增一个可拖拽的视频(摄像头) /// </summary> /// <param name="name"></param> /// <param name="size"></param> /// <param name="point"></param> /// <param name="source">IP,Port,ChannelUserName,Password</param> /// <returns></returns> public DragVideo AddDragVideo(string name, Size size, Point point, string source) { int childCount = this.Children.Count; DragVideo shape = new DragVideo() { CtrlName = string.IsNullOrEmpty(name) ? Guid.NewGuid().ToString("N") : name, Name = "DragVideo" + childCount.ToString(), Width = size.Width, Height = size.Height, Position = point, ZIndex = childCount, BelongCanvas = this, //设置为当前Canvas IsReadOnly = this.IsReadOnly, //只读 Text = source, }; shape.DragDelta += DragDelta; shape.DragStarted += DragStarted; shape.DragCompleted += DragCompleted; bSaved = false; DragThumbs.Add(shape); this.Children.Add(shape); //添加到界面上 Canvas.SetZIndex(shape, shape.ZIndex); //设置界面ZIndex属性 shape.IsSelected = !IsReadOnly; return(shape); }
/// <summary> /// 新增一个可拖拽图片 /// </summary> /// <param name="size">图片大小</param> /// <param name="point">图片位置</param> /// <param name="source">图片目录</param> /// <param name="background"></param> /// <param name="borderBrush"></param> /// <param name="zIndex">顺序</param> /// <returns></returns> public DragImage AddDragImage(string name, Size size, Point point, ImageSource source, Brush background, Brush borderBrush, int zIndex) { int childCount = this.Children.Count; DragImage tb = new DragImage() { CtrlName = string.IsNullOrEmpty(name) ? Guid.NewGuid().ToString("N"): name, Background = background, BorderBrush = borderBrush, Name = "DragImage" + childCount.ToString(), Width = size.Width, Height = size.Height, Position = point, ZIndex = zIndex, BelongCanvas = this, //设置为当前Canvas IsReadOnly = this.IsReadOnly, //只读 Source = source, }; tb.DragDelta += DragDelta; tb.DragStarted += DragStarted; tb.DragCompleted += DragCompleted; bSaved = false; DragThumbs.Add(tb); this.Children.Add(tb); //添加到界面上 Canvas.SetZIndex(tb, zIndex); //设置界面ZIndex属性 tb.IsSelected = !IsReadOnly; return(tb); }
/// <summary> /// 新增一个可拖拽的圆形 /// </summary> /// <param name="name"></param> /// <param name="size"></param> /// <param name="background"></param> /// <param name="borderBrush"></param> /// <returns></returns> public DragCircle AddDragCircle(string name, Size size, Point point, Brush background, Brush borderBrush, string sText = "") { int childCount = this.Children.Count; DragCircle shape = new DragCircle() { CtrlName = string.IsNullOrEmpty(name) ? Guid.NewGuid().ToString("N") : name, Background = background, BorderBrush = borderBrush, Name = "DragCircle" + childCount.ToString(), Width = size.Width, Height = size.Height, Position = point, ZIndex = childCount, BelongCanvas = this, //设置为当前Canvas IsReadOnly = this.IsReadOnly, //只读 Text = sText, BasicShapeType = EmBasicShape.Ellipse, }; shape.DragDelta += DragDelta; shape.DragStarted += DragStarted; shape.DragCompleted += DragCompleted; bSaved = false; DragThumbs.Add(shape); this.Children.Add(shape); //添加到界面上 Canvas.SetZIndex(shape, shape.ZIndex); //设置界面ZIndex属性 shape.IsSelected = !IsReadOnly; return(shape); }