コード例 #1
0
        public void updateElementAttr(DControl dControl, bool isDesign)
        {
            Width   = dControl.width;
            Height  = dControl.height;
            Margin  = new Thickness(dControl.left, dControl.top, 0, 0);
            Opacity = dControl.opacity / 100.0;
            //this.currDControl = dControl;
            TransformGroup  group           = (TransformGroup)RenderTransform;
            RotateTransform rotateTransform = TransformGroupUtil.GetRotateTransform(group);

            rotateTransform.Angle = dControl.rotateAngle;
        }
コード例 #2
0
        //
        private void Submit_Button_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrWhiteSpace(width.Text))
            {
                MessageBox.Show("请填写宽度;"); return;
            }
            else if (!DataUtil.isInt(width.Text.ToString()))
            {
                MessageBox.Show("宽度必须是整数;"); return;
            }
            if (string.IsNullOrWhiteSpace(height.Text.ToString()))
            {
                MessageBox.Show("请填写高度;"); return;
            }
            else if (!DataUtil.isInt(height.Text.ToString()))
            {
                MessageBox.Show("高度必须是整数;"); return;
            }
            if (string.IsNullOrWhiteSpace(left.Text.ToString()))
            {
                MessageBox.Show("请填写左边距;"); return;
            }
            else if (!DataUtil.isInt(left.Text.ToString()))
            {
                MessageBox.Show("左边距请填写整数;"); return;
            }
            if (string.IsNullOrWhiteSpace(top.Text.ToString()))
            {
                MessageBox.Show("请填写上边距;"); return;
            }
            else if (!DataUtil.isInt(top.Text.ToString()))
            {
                MessageBox.Show("上边距请填写整数;"); return;
            }
            if (string.IsNullOrWhiteSpace(opacity.Text.ToString()))
            {
                MessageBox.Show("请填写透明度;"); return;
            }
            else if (!DataUtil.isInt(opacity.Text.ToString()))
            {
                MessageBox.Show("透明度请填写整数;"); return;
            }
            else
            {
                Int32 opacityVal = Convert.ToInt32(opacity.Text.ToString());
                if (opacityVal < 0 || opacityVal > 100)
                {
                    MessageBox.Show("透明度为0-100内的整数;"); return;
                }
            }

            if (string.IsNullOrWhiteSpace(rotateAngle.Text))
            {
                MessageBox.Show("请填写旋转角度;"); return;
            }
            else if (!DataUtil.isInt(rotateAngle.Text.ToString()))
            {
                MessageBox.Show("旋转角度必须是整数;"); return;
            }
            else
            {
                Int32 rotateAngleVal = Convert.ToInt32(rotateAngle.Text.ToString());
                if (rotateAngleVal < 0 || rotateAngleVal > 360)
                {
                    MessageBox.Show("旋转角度为0-360内的整数;"); return;
                }
            }


            //更新到数据库
            DControl dControl = dControlBll.get(currDControl.id);

            dControl.width       = int.Parse(width.Text);
            dControl.height      = int.Parse(height.Text);
            dControl.left        = int.Parse(left.Text);
            dControl.top         = int.Parse(top.Text);
            dControl.isClickShow = (Boolean)isClickShow.IsChecked;
            dControl.opacity     = int.Parse(opacity.Text);
            dControl.isTab       = (Boolean)isTab.IsChecked;
            dControl.rotateAngle = int.Parse(rotateAngle.Text);
            dControlBll.update(dControl);



            //更新页面控件信息,更新isClickShow
            currDControl    = dControl;
            currElement.Tag = currDControl;
            Button button = (Button)currElement;

            button.Width   = currDControl.width;
            button.Height  = currDControl.height;
            button.Margin  = new Thickness(currDControl.left, currDControl.top, 0, 0);
            button.Opacity = currDControl.opacity / 100.0;
            TransformGroup  group           = (TransformGroup)button.RenderTransform;
            RotateTransform rotateTransform = TransformGroupUtil.GetRotateTransform(group);

            rotateTransform.Angle = currDControl.rotateAngle;

            //2.修改8个点的位置 及宽高
            editing.updateEditingBorder(currDControl);


            Close();
        }
コード例 #3
0
        /*
         * 让当前控件获得焦点
         */
        private Border control_GetFocus(object sender, MouseButtonEventArgs e)
        {
            pageTemplate.container.Children.Remove(editingBorder);
            FrameworkElement control     = (FrameworkElement)sender;
            DControl         dControl    = (DControl)control.Tag;
            SolidColorBrush  borderColor = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF109CEC"));


            //point宽度的一般
            double bhalf = Math.Floor(pointWidth / 2);
            //point水平居中坐标
            double centerX = (control.Width - pointWidth) / 2;
            //point垂直居中坐标
            double centerY = (control.Height - pointWidth) / 2;


            //1左上角
            Border border1 = new Border();

            border1.Name   = "leftTopBorder";
            border1.Width  = pointWidth;
            border1.Height = pointWidth;
            // border1.Margin = new Thickness(-bhalf,-bhalf,0,0);
            border1.BorderThickness = new Thickness(1);
            border1.BorderBrush     = borderColor;
            border1.Background      = Brushes.White;
            border1.SetValue(Canvas.LeftProperty, -bhalf);
            border1.SetValue(Canvas.TopProperty, -bhalf);
            //2右上角
            Border border2 = new Border();

            border2.Name   = "rightTopBorder";
            border2.Width  = pointWidth;
            border2.Height = pointWidth;
            // border2.Margin = new Thickness(0, -bhalf, -bhalf, 0);
            border2.BorderThickness = new Thickness(1);
            border2.BorderBrush     = borderColor;
            border2.Background      = Brushes.White;
            border2.SetValue(Canvas.TopProperty, -bhalf);
            border2.SetValue(Canvas.RightProperty, -bhalf);

            //3右下角
            Border border3 = new Border();

            border3.Name   = "rightBottomBorder";
            border3.Width  = pointWidth;
            border3.Height = pointWidth;
            // border3.Margin = new Thickness(0, 0, -bhalf, -bhalf);
            border3.BorderThickness = new Thickness(1);
            border3.BorderBrush     = borderColor;
            border3.Background      = Brushes.White;
            border3.SetValue(Canvas.RightProperty, -bhalf);
            border3.SetValue(Canvas.BottomProperty, -bhalf);
            border3.MouseEnter       += border3_MouseEnter;
            border3.MouseLeave       += border3_MouseLeave;
            border3.PreviewMouseDown += border3_MouseDown;
            border3.PreviewMouseMove += border3_MouseMove;
            border3.PreviewMouseUp   += border3_MouseUp;

            //4左下角
            Border border4 = new Border();

            border4.Name   = "leftBottomBorder";
            border4.Width  = pointWidth;
            border4.Height = pointWidth;
            // border4.Margin = new Thickness(-bhalf, 0, 0, -bhalf);
            border4.BorderThickness = new Thickness(1);
            border4.BorderBrush     = borderColor;
            border4.Background      = Brushes.White;
            border4.SetValue(Canvas.LeftProperty, -bhalf);
            border4.SetValue(Canvas.BottomProperty, -bhalf);

            //5左中角
            Border border5 = new Border();

            border5.Name   = "leftCenterBorder";
            border5.Width  = pointWidth;
            border5.Height = pointWidth;
            // border5.Margin = new Thickness(-bhalf, centerY, 0, 0);
            border5.BorderThickness = new Thickness(1);
            border5.BorderBrush     = borderColor;
            border5.Background      = Brushes.White;
            border5.SetValue(Canvas.LeftProperty, -bhalf);
            border5.SetValue(Canvas.TopProperty, centerY);

            //6上中角
            Border border6 = new Border();

            border6.Name   = "topCenterBorder";
            border6.Width  = pointWidth;
            border6.Height = pointWidth;
            // border6.Margin = new Thickness(centerX, -bhalf, 0, 0);
            border6.BorderThickness = new Thickness(1);
            border6.BorderBrush     = borderColor;
            border6.Background      = Brushes.White;
            border6.SetValue(Canvas.LeftProperty, centerX);
            border6.SetValue(Canvas.TopProperty, -bhalf);

            //7右中角
            Border border7 = new Border();

            border7.Name   = "rightCenterBorder";
            border7.Width  = pointWidth;
            border7.Height = pointWidth;
            //   border7.Margin = new Thickness(0, centerY, -bhalf, 0);
            border7.BorderThickness = new Thickness(1);
            border7.BorderBrush     = borderColor;
            border7.Background      = Brushes.White;
            border7.SetValue(Canvas.RightProperty, -bhalf);
            border7.SetValue(Canvas.TopProperty, centerY);

            //8下中角
            Border border8 = new Border();

            border8.Name   = "bottomCenterBorder";
            border8.Width  = pointWidth;
            border8.Height = pointWidth;
            //  border8.Margin = new Thickness(centerX, 0, 0, -bhalf);
            border8.BorderThickness = new Thickness(1);
            border8.BorderBrush     = borderColor;
            border8.Background      = Brushes.White;
            border8.SetValue(Canvas.LeftProperty, centerX);
            border8.SetValue(Canvas.BottomProperty, -bhalf);


            Canvas editingCanvas = new Canvas();

            editingCanvas.Name                = "editingCanvas";
            editingCanvas.Width               = control.Width;
            editingCanvas.Height              = control.Height;
            editingCanvas.VerticalAlignment   = VerticalAlignment.Top;
            editingCanvas.HorizontalAlignment = HorizontalAlignment.Left;
            editingCanvas.Margin              = new Thickness(-1, -1, 0, 0);
            editingCanvas.Children.Add(border1);
            editingCanvas.Children.Add(border2);
            editingCanvas.Children.Add(border3);
            editingCanvas.Children.Add(border4);
            editingCanvas.Children.Add(border5);
            editingCanvas.Children.Add(border6);
            editingCanvas.Children.Add(border7);
            editingCanvas.Children.Add(border8);


            editingBorder                     = new Border();
            editingBorder.Name                = "editingBorder";
            editingBorder.Width               = control.Width;
            editingBorder.Height              = control.Height;
            editingBorder.Margin              = control.Margin;
            editingBorder.BorderThickness     = new Thickness(1);
            editingBorder.BorderBrush         = borderColor;
            editingBorder.Background          = Brushes.Transparent;
            editingBorder.VerticalAlignment   = VerticalAlignment.Top;
            editingBorder.HorizontalAlignment = HorizontalAlignment.Left;
            Grid.SetZIndex(editingBorder, 10001);
            editingBorder.Child = editingCanvas;
            editingBorder.Tag   = control;
            // control.Tag = editingBorder;
            TransformGroup  group           = new TransformGroup();
            RotateTransform rotateTransform = TransformGroupUtil.GetRotateTransform(group);

            rotateTransform.Angle               = dControl.rotateAngle;
            editingBorder.RenderTransform       = group;
            editingBorder.RenderTransformOrigin = new Point(0.5, 0.5);


            editingBorder.MouseLeftButtonDown += editingBorder_MouseDown;
            editingBorder.MouseMove           += editingBorder_MouseMove;
            editingBorder.MouseLeftButtonUp   += editingBorder_MouseUp;
            //editingBorder.PreviewTouchDown += editingBorder_PreviewTouchDown;
            //editingBorder.TouchMove += editingBorder_TouchMove;
            //editingBorder.PreviewTouchUp += editingBorder_PreviewTouchUp;
            //右击控件
            editingBorder.MouseRightButtonUp += control_MouseRightButtonUp;


            pageTemplate.container.Children.Add(editingBorder);
            return(editingBorder);
        }