Ejemplo n.º 1
0
        public PreviewPane(Image severityIcon, string id, string title, string description, Uri helpLink, string helpLinkToolTipText,
                           object previewContent, bool logIdVerbatimInTelemetry)
        {
            InitializeComponent();

            _id = id;
            _logIdVerbatimInTelemetry = logIdVerbatimInTelemetry;

            // Initialize header portion.
            if ((severityIcon != null) && !string.IsNullOrWhiteSpace(id) && !string.IsNullOrWhiteSpace(title))
            {
                HeaderStackPanel.Visibility = Visibility.Visible;

                SeverityIconBorder.Child = severityIcon;

                // Set the initial title text to three lines worth so that we can measure the pixel height
                // that WPF requires to render three lines of text under the current font and DPI settings.
                TitleRun.Text = s_dummyThreeLineTitle;
                TitleTextBlock.Measure(availableSize: s_infiniteSize);
                _heightForThreeLineTitle = TitleTextBlock.DesiredSize.Height;

                // Now set the actual title text.
                TitleRun.Text = title;

                InitializeHyperlinks(helpLink, helpLinkToolTipText);

                if (!string.IsNullOrWhiteSpace(description))
                {
                    DescriptionParagraph.Inlines.Add(description);
                }
            }

            // Initialize preview (i.e. diff view) portion.
            InitializePreviewElement(previewContent);
        }
Ejemplo n.º 2
0
        // This method adjusts the width of the header section to match that of the preview content
        // thereby ensuring that the preview pane itself is never wider than the preview content.
        // This method also adjusts the height of the header section so that it displays only three lines
        // worth by default.
        private void AdjustWidthAndHeight(FrameworkElement previewElement)
        {
            PreviewDockPanel.Measure(availableSize: new Size(previewElement.Width, double.PositiveInfinity));
            var width = PreviewDockPanel.DesiredSize.Width;

            if (IsNormal(width))
            {
                HeaderStackPanel.Width = width;

                TitleTextBlock.Measure(availableSize: new Size(width, double.PositiveInfinity));
                var height = TitleTextBlock.DesiredSize.Height;

                // If the pixel height required to render the complete title in the
                // TextBlock is larger than that required to render three lines worth,
                // then trim the contents of the TextBlock with an ellipsis at the end and
                // display the expander button that will allow users to view the full text.
                if ((IsNormal(height) && (height > _heightForThreeLineTitle)) || HasDescription)
                {
                    TitleTextBlock.MaxHeight    = _heightForThreeLineTitle;
                    TitleTextBlock.TextTrimming = TextTrimming.CharacterEllipsis;

                    ExpanderToggleButton.Visibility = Visibility.Visible;

                    if (_isExpanded)
                    {
                        ExpanderToggleButton.IsChecked = true;
                    }
                }
            }
        }
Ejemplo n.º 3
0
 public PlaylistDetailPage()
 {
     this.InitializeComponent();
     _compositor               = ElementCompositionPreview.GetElementVisual(this).Compositor;
     _floatingVisual           = PlayerFloating.GetVisual();
     _playButtonVisual         = PlayButton.GetVisual();
     _addToButtonVisual        = AddToButton.GetVisual();
     _exitButtonVisual         = ExitButton.GetVisual();
     _musicListVisual          = list.GetVisual();
     _albumYearTextBlockVisual = AlbumYearTextBlock.GetVisual();
     _albumNameTextBlockVisual = AlbumNameTextBlock.GetVisual();
     _titleTextBlockVisual     = TitleTextBlock.GetVisual();
 }
Ejemplo n.º 4
0
        public PreviewPane(Image severityIcon, string id, string title, string helpMessage, string description, string helpLink,
                           bool telemetry, object previewContent, IServiceProvider serviceProvider)
        {
            InitializeComponent();

            InitializeHyperlinkStyles();

            if ((severityIcon != null) && !string.IsNullOrWhiteSpace(id) && !string.IsNullOrWhiteSpace(title))
            {
                HeaderStackPanel.Visibility = Visibility.Visible;

                SeverityIconBorder.Child = severityIcon;

                // Set the initial title text to three lines worth so that we can measure the pixel height
                // that WPF requires to render three lines of text under the current font and DPI settings.
                TitleRun.Text = s_dummyThreeLineTitle;
                TitleTextBlock.Measure(availableSize: s_infiniteSize);
                _heightForThreeLineTitle = TitleTextBlock.DesiredSize.Height;

                // Now set the actual title text.
                TitleRun.Text = title;

                Uri helpUri;
                if (BrowserHelper.TryGetUri(helpLink, out helpUri))
                {
                    InitializeDiagnosticIdHyperLink(id, helpUri, bingLink: false);
                }
                else
                {
                    InitializeDiagnosticIdHyperLink(id, BrowserHelper.CreateBingQueryUri(id, helpMessage), bingLink: true);
                }

                if (!string.IsNullOrWhiteSpace(description))
                {
                    DescriptionParagraph.Inlines.Add(description);
                }
            }

            InitializePreviewElement(previewContent);

            _serviceProvider = serviceProvider;
            _errorId         = id;

            // save permission whether we are allowed to save data as it is or not.
            _telemetry = telemetry;
        }
Ejemplo n.º 5
0
        private void Update()
        {
            if (!IsChartInitialized)
            {
                return;
            }

            Func <double, string> defFormatter = x => x.ToString(CultureInfo.InvariantCulture);

            var completed = (Value - From) / (To - From);

            var t = 0d;

            if (double.IsNaN(completed) || double.IsInfinity(completed))
            {
                completed = 0;
            }

            completed = completed > 1 ? 1 : (completed < 0 ? 0 : completed);
            var angle = Uses360Mode ? 360 : 180;

            if (!Uses360Mode)
            {
                LeftLabel.Text  = (LabelFormatter ?? defFormatter)(From);
                RightLabel.Text = (LabelFormatter ?? defFormatter)(To);

                LeftLabel.UpdateLayout();
                RightLabel.UpdateLayout();

                LeftLabel.Visibility  = LabelsVisibility;
                RightLabel.Visibility = LabelsVisibility;

                t = LeftLabel.ActualHeight;
            }
            else
            {
                LeftLabel.Visibility  = Visibility.Hidden;
                RightLabel.Visibility = Visibility.Hidden;
            }

            double r, top;

            if (Uses360Mode)
            {
                r   = ActualWidth > ActualHeight ? ActualHeight : ActualWidth;
                r   = r / 2 - 2 * t;
                top = ActualHeight / 2;
            }
            else
            {
                r = ActualWidth;

                if (ActualWidth > ActualHeight * 2)
                {
                    r = ActualHeight * 2;
                }
                else
                {
                    t = 0;
                }

                r = r / 2 - 2 * t;

                top = ActualHeight / 2 + r / 2;
            }

            if (r < 0)
            {
                r = 1;
            }

            PieBack.Radius        = r;
            PieBack.InnerRadius   = InnerRadius ?? r * .6;
            PieBack.RotationAngle = 270;
            PieBack.WedgeAngle    = angle;

            Pie.Radius        = PieBack.Radius;
            Pie.InnerRadius   = PieBack.InnerRadius;
            Pie.RotationAngle = PieBack.RotationAngle;

            Canvas.SetLeft(PieBack, ActualWidth / 2);
            Canvas.SetTop(PieBack, top);
            Canvas.SetLeft(Pie, ActualWidth / 2);
            Canvas.SetTop(Pie, top);

            Canvas.SetTop(LeftLabel, top);
            Canvas.SetTop(RightLabel, top);
            Canvas.SetRight(LeftLabel, ActualWidth / 2 + (r + PieBack.InnerRadius) / 2 - LeftLabel.ActualWidth / 2);
            Canvas.SetRight(RightLabel, ActualWidth / 2 - (r + PieBack.InnerRadius) / 2 - RightLabel.ActualWidth / 2);

            MeasureTextBlock.FontSize = HighFontSize ?? Pie.InnerRadius * .4;
            MeasureTextBlock.Text     = (LabelFormatter ?? defFormatter)(Value);
            MeasureTextBlock.UpdateLayout();
            Canvas.SetTop(MeasureTextBlock, top - MeasureTextBlock.ActualHeight * (Uses360Mode ? .5 : 1));
            Canvas.SetLeft(MeasureTextBlock, ActualWidth / 2 - MeasureTextBlock.ActualWidth / 2);

            PercentTextBlock.FontSize = MeasureTextBlock.FontSize * .4;
            PercentTextBlock.Text     = "%";
            PercentTextBlock.UpdateLayout();
            Canvas.SetTop(PercentTextBlock, top - PercentTextBlock.ActualHeight * (Uses360Mode ? .5 : 1));
            Canvas.SetLeft(PercentTextBlock, r * 2 - PercentTextBlock.ActualWidth * 2);

            TitleTextBlock.FontSize = 14;
            TitleTextBlock.Text     = Title;
            TitleTextBlock.UpdateLayout();
            Canvas.SetTop(TitleTextBlock, r * 2 + TitleTextBlock.ActualHeight * (Uses360Mode ? .5 : 1));
            Canvas.SetLeft(TitleTextBlock, 0);


            var interpolatedColor = new Color
            {
                R = LinearInterpolation(FromColor.R, ToColor.R),
                G = LinearInterpolation(FromColor.G, ToColor.G),
                B = LinearInterpolation(FromColor.B, ToColor.B),
                A = LinearInterpolation(FromColor.A, ToColor.A)
            };

            if (IsNew)
            {
                Pie.Fill       = new SolidColorBrush(FromColor);
                Pie.WedgeAngle = 0;
            }

            if (DisableAnimations)
            {
                Pie.WedgeAngle = completed * angle;
            }
            else
            {
                Pie.BeginAnimation(PieSlice.WedgeAngleProperty, new DoubleAnimation(completed * angle, AnimationsSpeed));
            }

            if (GaugeActiveFill == null)
            {
                ((SolidColorBrush)Pie.Fill).BeginAnimation(SolidColorBrush.ColorProperty,
                                                           new ColorAnimation(interpolatedColor, AnimationsSpeed));
            }
            else
            {
                Pie.Fill = GaugeActiveFill;
            }

            IsNew = false;
        }
Ejemplo n.º 6
0
 private void TitleTextBlockFocus(object sender, RoutedEventArgs e)
 {
     TitleTextBlock.Clear();
 }
Ejemplo n.º 7
0
        public PreviewPane(Image severityIcon, string id, string title, string helpMessage, string description, string helpLink,
                           bool telemetry, object previewContent, IServiceProvider serviceProvider)
        {
            InitializeComponent();

            InitializeHyperlinkStyles();

            if ((severityIcon != null) && !string.IsNullOrWhiteSpace(id) && !string.IsNullOrWhiteSpace(title))
            {
                HeaderStackPanel.Visibility = Visibility.Visible;

                SeverityIconBorder.Child = severityIcon;

                // Set the initial title text to three lines worth so that we can measure the pixel height
                // that WPF requires to render three lines of text under the current font and DPI settings.
                TitleRun.Text = s_dummyThreeLineTitle;
                TitleTextBlock.Measure(availableSize: s_infiniteSize);
                _heightForThreeLineTitle = TitleTextBlock.DesiredSize.Height;

                // Now set the actual title text.
                TitleRun.Text = title;

                Uri helpUri;
                if (BrowserHelper.TryGetUri(helpLink, out helpUri))
                {
                    InitializeDiagnosticIdHyperLink(id, helpUri, bingLink: false);
                }
                else
                {
                    InitializeDiagnosticIdHyperLink(id, BrowserHelper.CreateBingQueryUri(id, helpMessage), bingLink: true);
                }

                if (!string.IsNullOrWhiteSpace(description))
                {
                    DescriptionParagraph.Inlines.Add(description);
                }
            }

            FrameworkElement previewElement = null;

            if (previewContent is IWpfDifferenceViewer)
            {
                _previewDiffViewer          = previewContent as IWpfDifferenceViewer;
                previewElement              = _previewDiffViewer.VisualElement;
                PreviewDockPanel.Background = _previewDiffViewer.InlineView.Background;
            }
            else if (previewContent is string)
            {
                previewElement = GetPreviewForString(previewContent as string);
            }
            else if (previewContent is FrameworkElement)
            {
                previewElement = previewContent as FrameworkElement;
            }
            else
            {
                // previewContent is either null or some type that we don't know how to display.
                previewElement = GetEmptyPreview();
            }

            PreviewScrollViewer.Content        = previewElement;
            previewElement.VerticalAlignment   = VerticalAlignment.Top;
            previewElement.HorizontalAlignment = HorizontalAlignment.Left;

            // 1. Width of the header section should not exceed the width of the preview content.
            // In other words, the text we put in the header at the top of the preview pane
            // should not cause the preview pane itself to grow wider than the width required to
            // display the preview content at the bottom of the pane.
            // 2. Adjust the height of the header section so that it displays only three lines worth
            // by default.
            AdjustWidthAndHeight(previewElement);

            _serviceProvider = serviceProvider;
            _errorId         = id;

            // save permission whether we are allowed to save data as it is or not.
            _telemetry = telemetry;
        }
 public PageHeader()
 {
     this.InitializeComponent();
     this.InitializeDropShadow(ShadowHost, TitleTextBlock.GetAlphaMask());
 }
Ejemplo n.º 9
0
        private void Update()
        {
            if (!IsChartInitialized)
            {
                return;
            }

            Func <double, string> defFormatter = x => x.ToString(CultureInfo.InvariantCulture);

            var completed = Value / (To - From);

            var t = 0d;

            completed = completed > 1 ? 1 : (completed < 0 ? 0 : completed);
            var angle = Uses360Mode ? 360 : 180;

            if (!string.IsNullOrWhiteSpace(Title))
            {
                TitleTextBlock.UpdateLayout();
                t = TitleTextBlock.ActualHeight;
                Canvas.SetLeft(TitleTextBlock, ActualWidth / 2 - TitleTextBlock.ActualWidth / 2);
            }

            if (!Uses360Mode)
            {
                LeftLabel.Text  = (LabelFormatter ?? defFormatter)(From);
                RightLabel.Text = (LabelFormatter ?? defFormatter)(To);

                LeftLabel.UpdateLayout();
                RightLabel.UpdateLayout();

                LeftLabel.Visibility  = Visibility.Visible;
                RightLabel.Visibility = Visibility.Visible;

                t = LeftLabel.ActualHeight;
            }
            else
            {
                LeftLabel.Visibility  = Visibility.Hidden;
                RightLabel.Visibility = Visibility.Hidden;
            }

            double r, top;

            if (Uses360Mode)
            {
                r   = ActualWidth > ActualHeight ? ActualHeight: ActualWidth;
                r   = r / 2 - 2 * t;
                top = ActualHeight / 2;
            }
            else
            {
                r = ActualWidth;

                if (ActualWidth > ActualHeight * 2)
                {
                    r = ActualHeight * 2;
                }

                r = r / 2 - 2 * t;

                top = ActualHeight / 2 + r / 2;
            }

            PieBack.Radius        = r;
            PieBack.InnerRadius   = InnerRadius ?? r * .6;
            PieBack.RotationAngle = 270;
            PieBack.WedgeAngle    = angle;

            Pie.Radius        = PieBack.Radius;
            Pie.InnerRadius   = PieBack.InnerRadius;
            Pie.RotationAngle = PieBack.RotationAngle;

            Canvas.SetLeft(PieBack, ActualWidth / 2);
            Canvas.SetTop(PieBack, top);
            Canvas.SetLeft(Pie, ActualWidth / 2);
            Canvas.SetTop(Pie, top);

            Canvas.SetTop(LeftLabel, top);
            Canvas.SetTop(RightLabel, top);
            Canvas.SetRight(LeftLabel, ActualWidth / 2 + (r + PieBack.InnerRadius) / 2 - LeftLabel.ActualWidth / 2);
            Canvas.SetRight(RightLabel, ActualWidth / 2 - (r + PieBack.InnerRadius) / 2 - RightLabel.ActualWidth / 2);

            MeasureTextBlock.FontSize = HighFontSize ?? Pie.InnerRadius * .4;
            MeasureTextBlock.Text     = (LabelFormatter ?? defFormatter)(Value);
            MeasureTextBlock.UpdateLayout();
            Canvas.SetTop(MeasureTextBlock, top - MeasureTextBlock.ActualHeight * (Uses360Mode ? .5 : 1));
            Canvas.SetLeft(MeasureTextBlock, ActualWidth / 2 - MeasureTextBlock.ActualWidth / 2);

            var interpolatedColor = new Color
            {
                R = LinearInterpolation(ToColor.R, FromColor.R),
                G = LinearInterpolation(ToColor.G, FromColor.G),
                B = LinearInterpolation(ToColor.B, FromColor.B),
                A = 255
            };

            if (IsNew)
            {
                Pie.Fill       = new SolidColorBrush(ToColor);
                Pie.WedgeAngle = 0;
            }

            Pie.BeginAnimation(PieSlice.WedgeAngleProperty, new DoubleAnimation(completed * angle, AnimationsSpeed));
            ((SolidColorBrush)Pie.Fill).BeginAnimation(SolidColorBrush.ColorProperty,
                                                       new ColorAnimation(interpolatedColor, AnimationsSpeed));

            IsNew = false;
        }
Ejemplo n.º 10
0
        //update title text block's text than save
        public void Update_Title()
        {
            TitleTextBlock.SetBinding(TextBlock.TextProperty, "Title");

            Update?.Invoke(this, EventArgs.Empty);
        }
Ejemplo n.º 11
0
        private void UpdateOrientation()
        {
            grid.ColumnDefinitions.Clear();
            grid.RowDefinitions.Clear();

            if (Orientation == Orientation.Horizontal)
            {
                grid.ColumnDefinitions.Add(new ColumnDefinition());
                grid.RowDefinitions.Add(new RowDefinition());
                grid.RowDefinitions.Add(new RowDefinition());

                grid.SetCurrentValue(FrameworkElement.MinWidthProperty, 100.0);
                grid.SetCurrentValue(FrameworkElement.MaxWidthProperty, 100.0);
                grid.SetCurrentValue(FrameworkElement.MarginProperty, new Thickness()
                {
                    Bottom = 8
                });

                TitleTextBlock.SetCurrentValue(Grid.ColumnProperty, 0);
                TitleTextBlock.SetCurrentValue(FrameworkElement.HorizontalAlignmentProperty, HorizontalAlignment.Center);

                pathlineCanvas.SetCurrentValue(Grid.ColumnProperty, 1);
                pathlineCanvas.SetCurrentValue(FrameworkElement.MarginProperty, new Thickness(5));
                pathlineCanvas.SetCurrentValue(FrameworkElement.HorizontalAlignmentProperty, HorizontalAlignment.Center);
                pathline.SetCurrentValue(FrameworkElement.WidthProperty, 48.0);
                pathline.SetCurrentValue(FrameworkElement.HeightProperty, 2.0);
                pathline.SetCurrentValue(Canvas.TopProperty, 13.0);
                pathline.SetCurrentValue(Canvas.LeftProperty, 24.0);

                ellipseVisited.Parent.SetCurrentValue(FrameworkElement.MarginProperty, new Thickness(5));
                ellipseCurrent.Parent.SetCurrentValue(FrameworkElement.MarginProperty, new Thickness(5));
                ellipseToVisit.Parent.SetCurrentValue(FrameworkElement.MarginProperty, new Thickness(5));
            }
            else
            {
                grid.ColumnDefinitions.Add(new ColumnDefinition()
                {
                    Width = GridLength.Auto
                });
                grid.ColumnDefinitions.Add(new ColumnDefinition());
                grid.RowDefinitions.Add(new RowDefinition());

                grid.SetCurrentValue(FrameworkElement.MinWidthProperty, 240.0);
                grid.SetCurrentValue(FrameworkElement.MaxWidthProperty, 240.0);
                grid.SetCurrentValue(FrameworkElement.MarginProperty, new Thickness()
                {
                    Bottom = 56
                });

                TitleTextBlock.SetCurrentValue(Grid.ColumnProperty, 1);
                TitleTextBlock.SetCurrentValue(FrameworkElement.HorizontalAlignmentProperty, HorizontalAlignment.Left);

                pathlineCanvas.SetCurrentValue(Grid.ColumnProperty, 0);
                pathlineCanvas.SetCurrentValue(FrameworkElement.MarginProperty, new Thickness(2));
                pathlineCanvas.SetCurrentValue(FrameworkElement.HorizontalAlignmentProperty, HorizontalAlignment.Left);
                pathline.SetCurrentValue(FrameworkElement.WidthProperty, 2.0);
                pathline.SetCurrentValue(FrameworkElement.HeightProperty, 48.0);
                pathline.SetCurrentValue(Canvas.TopProperty, 35.0);
                pathline.SetCurrentValue(Canvas.LeftProperty, 24.0);

                ellipseVisited.Parent.SetCurrentValue(FrameworkElement.MarginProperty, new Thickness()
                {
                    Left = 15, Top = 5, Right = 25, Bottom = 5
                });
                ellipseCurrent.Parent.SetCurrentValue(FrameworkElement.MarginProperty, new Thickness()
                {
                    Left = 15, Top = 5, Right = 25, Bottom = 5
                });
                ellipseToVisit.Parent.SetCurrentValue(FrameworkElement.MarginProperty, new Thickness()
                {
                    Left = 15, Top = 5, Right = 25, Bottom = 5
                });
            }
        }