コード例 #1
0
ファイル: ChartItem.cs プロジェクト: Planshit/ProjectEye
        /// <summary>
        /// 填充颜色
        /// </summary>
        private void FillColor()
        {
            if (ValueControl != null)
            {
                LinearGradientBrush brush = new LinearGradientBrush();

                brush.StartPoint = new Point(0.5, 0);
                brush.EndPoint   = new Point(0.5, 1);
                brush.GradientStops.Add(new GradientStop()
                {
                    Color  = Project1UIColor.BrushToColor(ItemColor, .5),
                    Offset = 0
                });

                brush.GradientStops.Add(new GradientStop()
                {
                    Color  = Project1UIColor.BrushToColor(ItemColor, 1),
                    Offset = 1,
                });
                ValueControl.Fill = brush;
            }
        }
コード例 #2
0
        private void CreateAttrWindow()
        {
            attrPopup           = new Popup();
            attrPopup.StaysOpen = false;
            attrPopup.SetValue(ZIndexProperty, 999);
            attrPopup.DataContext        = containerModel;
            attrPopup.Placement          = PlacementMode.MousePoint;
            attrPopup.Width              = 259;
            attrPopup.Height             = Double.NaN;
            attrPopup.AllowsTransparency = true;
            var border = new Border();

            border.Margin          = new Thickness(5);
            border.BorderThickness = new Thickness(1);
            border.BorderBrush     = Project1UIColor.Get("#ccc");
            border.Background      = Project1UIColor.Get("#ffffff");
            border.Effect          = new DropShadowEffect()
            {
                BlurRadius  = 5,
                Opacity     = .3,
                ShadowDepth = 0
            };
            var grid = new Grid();

            grid.Margin = new Thickness(10, 5, 10, 10);
            grid.RowDefinitions.Add(new RowDefinition()
            {
                Height = new GridLength(30)
            });
            grid.RowDefinitions.Add(new RowDefinition()
            {
                Height = GridLength.Auto
            });
            grid.Children.Add(new TextBlock()
            {
                Text              = "窗口属性编辑面板",
                FontWeight        = FontWeights.Bold,
                VerticalAlignment = VerticalAlignment.Center
            });
            var stackpanel = new StackPanel();

            stackpanel.SetValue(Grid.RowProperty, 1);
            var stackPanelGrid = new Grid();

            stackPanelGrid.ColumnDefinitions.Add(new ColumnDefinition()
            {
                Width = new GridLength(80)
            });
            stackPanelGrid.ColumnDefinitions.Add(new ColumnDefinition()
            {
                Width = new GridLength(1, GridUnitType.Star)
            });
            stackPanelGrid.RowDefinitions.Add(new RowDefinition()
            {
                Height = GridLength.Auto
            });
            stackPanelGrid.RowDefinitions.Add(new RowDefinition()
            {
                Height = GridLength.Auto
            });
            //添加透明度属性
            var opacityName = new TextBlock();

            opacityName.Text = "透明度";
            opacityName.VerticalAlignment = VerticalAlignment.Center;
            var opacityTextBox = new Project1UIInput();

            opacityTextBox.Height            = 25;
            opacityTextBox.Width             = Double.NaN;
            opacityTextBox.Type              = Project1UIInputType.Number;
            opacityTextBox.Minimum           = 0;
            opacityTextBox.Maximum           = 1;
            opacityTextBox.VerticalAlignment = VerticalAlignment.Center;
            opacityTextBox.SetValue(Grid.ColumnProperty, 1);
            BindingOperations.SetBinding(opacityTextBox, Project1UIInput.TextProperty, new Binding()
            {
                Path = new PropertyPath("Opacity"),
                Mode = BindingMode.TwoWay,
                UpdateSourceTrigger = UpdateSourceTrigger.Default
            });
            stackPanelGrid.Children.Add(opacityName);
            stackPanelGrid.Children.Add(opacityTextBox);
            //添加背景颜色属性
            var backgroundName = new TextBlock();

            backgroundName.Text              = "背景颜色";
            backgroundName.Margin            = new Thickness(0, 10, 0, 0);
            backgroundName.VerticalAlignment = VerticalAlignment.Center;
            backgroundName.SetValue(Grid.RowProperty, 1);
            var backgroundSelect = new Project1UIColorSelect();

            backgroundSelect.Width  = 20;
            backgroundSelect.Height = 20;
            backgroundSelect.Margin = new Thickness(0, 10, 0, 0);

            backgroundSelect.HorizontalAlignment = HorizontalAlignment.Left;
            backgroundSelect.VerticalAlignment   = VerticalAlignment.Center;
            backgroundSelect.SetValue(Grid.ColumnProperty, 1);
            backgroundSelect.SetValue(Grid.RowProperty, 1);

            BindingOperations.SetBinding(backgroundSelect, Project1UIColorSelect.ColorProperty, new Binding()
            {
                Path = new PropertyPath("Background"),
                Mode = BindingMode.TwoWay,
                UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
            });
            stackPanelGrid.Children.Add(backgroundName);
            stackPanelGrid.Children.Add(backgroundSelect);

            stackpanel.Children.Add(stackPanelGrid);
            grid.Children.Add(stackpanel);
            border.Child    = grid;
            attrPopup.Child = border;
        }
コード例 #3
0
        private Border CreateControlPoint(ControlPoint controlPoint)
        {
            var point = new Border();

            point.MouseDown += (s, e) =>
            {
                point.CaptureMouse();
                ControlPointMouseDown?.Invoke(this, controlPoint);
            };

            point.MouseLeave += (s, e) =>
            {
                if (e.LeftButton == MouseButtonState.Released)
                {
                    point.ReleaseMouseCapture();
                    ControlPointMouseUp?.Invoke(this, controlPoint);
                }
            };
            Binding binding = new Binding()
            {
                //Source = designItemModel,
                Path = new PropertyPath("ControlPointVisibility"),
                Mode = BindingMode.TwoWay,
                UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
            };

            BindingOperations.SetBinding(point, VisibilityProperty, binding);
            point.Width        = 10;
            point.Height       = 10;
            point.CornerRadius = new System.Windows.CornerRadius()
            {
                TopLeft     = 10,
                TopRight    = 10,
                BottomLeft  = 10,
                BottomRight = 10
            };
            point.SetCurrentValue(Panel.ZIndexProperty, 2);
            point.Background = Project1UIColor.Get("#6495ED");

            var cursorEnter = Cursors.Hand;

            switch (controlPoint)
            {
            case ControlPoint.LeftTop:
                cursorEnter               = Cursors.SizeNWSE;
                point.VerticalAlignment   = System.Windows.VerticalAlignment.Top;
                point.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
                point.Margin              = new System.Windows.Thickness(-5, -5, 0, 0);
                break;

            case ControlPoint.RightTop:
                cursorEnter               = Cursors.SizeNESW;
                point.VerticalAlignment   = System.Windows.VerticalAlignment.Top;
                point.HorizontalAlignment = System.Windows.HorizontalAlignment.Right;
                point.Margin              = new System.Windows.Thickness(0, -5, -5, 0);
                break;

            case ControlPoint.LeftBottom:
                cursorEnter = Cursors.SizeNESW;

                point.VerticalAlignment   = System.Windows.VerticalAlignment.Bottom;
                point.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
                point.Margin = new System.Windows.Thickness(-5, 0, 0, -5);
                break;

            case ControlPoint.RightBottom:
                cursorEnter = Cursors.SizeNWSE;

                point.VerticalAlignment   = System.Windows.VerticalAlignment.Bottom;
                point.HorizontalAlignment = System.Windows.HorizontalAlignment.Right;
                point.Margin = new System.Windows.Thickness(0, 0, -5, -5);
                break;
            }
            point.Cursor = cursorEnter;

            return(point);
        }
コード例 #4
0
        private UIDesignModel GetDefaultUI()
        {
            //创建默认布局
            var data = new UIDesignModel();

            data.ContainerAttr = new ContainerModel()
            {
                Background = Brushes.White,
                Opacity    = .98
            };
            var elements = new List <ElementModel>();
            var tipimage = new ElementModel();

            tipimage.Type    = Project1.UI.Controls.Enums.DesignItemType.Image;
            tipimage.Width   = 272;
            tipimage.Opacity = 1;
            tipimage.Height  = 187;
            tipimage.Image   = $"pack://application:,,,/ProjectEye;component/Resources/Themes/{config.options.Style.Theme.ThemeName}/Images/tipImage.png";
            tipimage.X       = WindowInstance.Width / 2 - tipimage.Width / 2;
            tipimage.Y       = WindowInstance.Height * .24;

            var tipText = new ElementModel();

            tipText.Type      = Project1.UI.Controls.Enums.DesignItemType.Text;
            tipText.Text      = "您已持续用眼{t}分钟,休息一会吧!请将注意力集中在至少6米远的地方20秒!";
            tipText.Opacity   = 1;
            tipText.TextColor = Project1UIColor.Get("#45435b");
            tipText.Width     = 400;
            tipText.Height    = 50;
            tipText.X         = WindowInstance.Width / 2 - tipText.Width / 2;
            tipText.Y         = tipimage.Y + tipimage.Height + tipText.Height + 10;
            tipText.FontSize  = 20;

            var restBtn = new ElementModel();

            restBtn.Type     = Project1.UI.Controls.Enums.DesignItemType.Button;
            restBtn.Width    = 110;
            restBtn.Height   = 45;
            restBtn.FontSize = 14;
            restBtn.Text     = "好的";
            restBtn.Opacity  = 1;
            restBtn.Command  = "rest";

            restBtn.X = WindowInstance.Width / 2 - (restBtn.Width * 2 + 10) / 2;
            restBtn.Y = tipText.Y + tipText.Height + 20;

            var breakBtn = new ElementModel();

            breakBtn.Type     = Project1.UI.Controls.Enums.DesignItemType.Button;
            breakBtn.Width    = 110;
            breakBtn.Height   = 45;
            breakBtn.FontSize = 14;
            breakBtn.Text     = "暂时不";
            breakBtn.Style    = "basic";
            breakBtn.Command  = "break";
            breakBtn.Opacity  = 1;
            breakBtn.X        = WindowInstance.Width / 2 - (restBtn.Width * 2 + 10) / 2 + (restBtn.Width + 10);
            breakBtn.Y        = tipText.Y + tipText.Height + 20;

            var countDownText = new ElementModel();

            countDownText.Text       = "{countdown}";
            countDownText.FontSize   = 50;
            countDownText.IsTextBold = true;
            countDownText.Type       = Project1.UI.Controls.Enums.DesignItemType.Text;
            countDownText.TextColor  = Brushes.Black;
            countDownText.Opacity    = 1;
            countDownText.Width      = 100;
            countDownText.Height     = 60;
            countDownText.X          = WindowInstance.Width / 2 - countDownText.Width / 2;
            countDownText.Y          = restBtn.Y + restBtn.Height;
            elements.Add(tipimage);
            elements.Add(tipText);
            elements.Add(restBtn);
            elements.Add(breakBtn);
            elements.Add(countDownText);


            data.Elements = elements;

            return(data);
        }
コード例 #5
0
        /// <summary>
        /// 创建默认的提示界面布局UI
        /// </summary>
        /// <param name="themeName">主题名</param>
        /// <param name="screenName">屏幕名称</param>
        /// <returns></returns>
        public UIDesignModel GetCreateDefaultTipWindowUI(
            string themeName,
            string screenName)
        {
            screenName = screenName.Replace("\\", "");

            var screen = System.Windows.Forms.Screen.PrimaryScreen;

            if (screenName != string.Empty)
            {
                foreach (var item in System.Windows.Forms.Screen.AllScreens)
                {
                    string itemScreenName = item.DeviceName.Replace("\\", "");
                    if (itemScreenName == screenName)
                    {
                        screen = item;
                        break;
                    }
                }
            }

            var screenSize = WindowManager.GetSize(screen);

            //创建默认布局
            var data = new UIDesignModel();

            data.ContainerAttr = new ContainerModel()
            {
                Background = Brushes.White,
                Opacity    = .98
            };

            var elements = new List <ElementModel>();
            var tipimage = new ElementModel();

            tipimage.Type    = Project1.UI.Controls.Enums.DesignItemType.Image;
            tipimage.Width   = 272;
            tipimage.Opacity = 1;
            tipimage.Height  = 187;
            tipimage.Image   = $"pack://application:,,,/ProjectEye;component/Resources/Themes/{themeName}/Images/tipImage.png";
            tipimage.X       = screenSize.Width / 2 - tipimage.Width / 2;
            tipimage.Y       = screenSize.Height * .24;

            var tipText = new ElementModel();

            tipText.Type      = Project1.UI.Controls.Enums.DesignItemType.Text;
            tipText.Text      = "您已持续用眼{t}分钟,休息一会吧!请将注意力集中在至少6米远的地方20秒!";
            tipText.Opacity   = 1;
            tipText.TextColor = Project1UIColor.Get("#45435b");
            tipText.Width     = 400;
            tipText.Height    = 50;
            tipText.X         = screenSize.Width / 2 - tipText.Width / 2;
            tipText.Y         = tipimage.Y + tipimage.Height + tipText.Height + 10;
            tipText.FontSize  = 20;

            var restBtn = new ElementModel();

            restBtn.Type     = Project1.UI.Controls.Enums.DesignItemType.Button;
            restBtn.Width    = 110;
            restBtn.Height   = 45;
            restBtn.FontSize = 14;
            restBtn.Text     = "好的";
            restBtn.Opacity  = 1;
            restBtn.Command  = "rest";

            restBtn.X = screenSize.Width / 2 - (restBtn.Width * 2 + 10) / 2;
            restBtn.Y = tipText.Y + tipText.Height + 20;

            var breakBtn = new ElementModel();

            breakBtn.Type     = Project1.UI.Controls.Enums.DesignItemType.Button;
            breakBtn.Width    = 110;
            breakBtn.Height   = 45;
            breakBtn.FontSize = 14;
            breakBtn.Text     = "暂时不";
            breakBtn.Style    = "basic";
            breakBtn.Command  = "break";
            breakBtn.Opacity  = 1;
            breakBtn.X        = screenSize.Width / 2 - (restBtn.Width * 2 + 10) / 2 + (restBtn.Width + 10);
            breakBtn.Y        = tipText.Y + tipText.Height + 20;

            var countDownText = new ElementModel();

            countDownText.Text       = "{countdown}";
            countDownText.FontSize   = 50;
            countDownText.IsTextBold = true;
            countDownText.Type       = Project1.UI.Controls.Enums.DesignItemType.Text;
            countDownText.TextColor  = Brushes.Black;
            countDownText.Opacity    = 1;
            countDownText.Width      = 100;
            countDownText.Height     = 60;
            countDownText.X          = screenSize.Width / 2 - countDownText.Width / 2;
            countDownText.Y          = restBtn.Y + restBtn.Height;



            if (themeName == "Dark")
            {
                //深色主题的样式

                data.ContainerAttr.Background = Project1UIColor.Get("#1A1B1C");
                tipText.TextColor             = Project1UIColor.Get("#D9D9D9");
                countDownText.TextColor       = Project1UIColor.Get("#D9D9D9");
            }
            elements.Add(tipimage);
            elements.Add(tipText);
            elements.Add(restBtn);
            elements.Add(breakBtn);
            elements.Add(countDownText);


            data.Elements = elements;

            return(data);
        }