Esempio n. 1
0
        Path DrawWedge(double radius, double startAngle, out double endAngle, FixtureSummary fixtureSummary)
        {
            Path path = new Path();

            Canvas.SetLeft(path, radius);
            Canvas.SetTop(path, radius);

            path.Fill = TwBrushes.FrozenSolidColorBrush(fixtureSummary.FixtureClass);

            PathGeometry pathGeometry = new PathGeometry();
            PathFigure   pathFigure   = new PathFigure();

            pathFigure.StartPoint = new Point(0, 0);
            pathFigure.IsClosed   = true;

            Point       startArc    = new Point(Math.Cos(startAngle * Math.PI / 180) * radius, Math.Sin(startAngle * Math.PI / 180) * radius);
            LineSegment lineSegment = new LineSegment(startArc, true);

            ArcSegment arcSegment = new ArcSegment();
            double     percent    = ByInstances ? fixtureSummary.PercentCount : fixtureSummary.PercentVolume;

            double angle;

            if (fixtureSummary.PercentCount == 1)
            {
                angle = 359.99; // WPF won't draw a wedge from 0 to 360 degrees, so we fake it
            }
            else
            {
                angle = percent * 360;
            }

            arcSegment.IsLargeArc     = angle >= 180.0;
            arcSegment.Point          = new Point(Math.Cos((startAngle + angle) * Math.PI / 180) * radius, Math.Sin((startAngle + angle) * Math.PI / 180) * radius);
            arcSegment.Size           = new Size(radius, radius);
            arcSegment.SweepDirection = SweepDirection.Clockwise;

            pathFigure.Segments.Add(lineSegment);
            pathFigure.Segments.Add(arcSegment);

            pathGeometry.Figures.Add(pathFigure);
            path.Data = pathGeometry;

            endAngle = startAngle + angle;

            if (!IsEnlargeable)
            {
                if (ByInstances)
                {
                    path.ToolTip = new PieChartToolTip(fixtureSummary.FixtureClass, ByInstances, fixtureSummary.Count.ToString(), fixtureSummary.PercentCount);
                }
                else
                {
                    path.ToolTip = new PieChartToolTip(fixtureSummary.FixtureClass, ByInstances, fixtureSummary.Volume.ToString("0.0"), fixtureSummary.PercentVolume);
                }
            }
            ToolTipService.SetShowDuration(path, 60000);
            ToolTipService.SetInitialShowDelay(path, 500);

            return(path);
        }
Esempio n. 2
0
        public StyledFixtureLabel(FixtureClass fixtureClass, FontWeight fontWeight, bool showKey, bool manuallyClassified, bool firstCycle, bool firstCycleManuallyClassified, bool showFriendlyName, bool singleRow, bool showHasNotes)
        {
            this.Focusable = false;
            this.IsTabStop = false;

            this.InputBindings.Add(new MouseBinding(AnalysisPanel.BringSelectedEventIntoViewCommand, new MouseGesture(MouseAction.LeftDoubleClick, ModifierKeys.None)));

            FixtureClass = fixtureClass;

            Grid grid = new Grid();

            ColumnDefinition coldefText = new ColumnDefinition();

            coldefText.Width = GridLength.Auto;
            grid.ColumnDefinitions.Add(coldefText);

            ColumnDefinition coldefImage = new ColumnDefinition();

            coldefImage.Width = new GridLength(1, GridUnitType.Star);
            grid.ColumnDefinitions.Add(coldefImage);

            Image image = new Image();

            image.Style  = (Style)ResourceLocator.FindResource("ImageStyle");
            image.Source = TwGui.GetImage(fixtureClass.ImageFilename);

            Border border = new Border();

            border.Style             = (Style)ResourceLocator.FindResource("FixtureBorderStyle");
            border.Background        = TwBrushes.FrozenSolidColorBrush(fixtureClass.Color);
            border.VerticalAlignment = VerticalAlignment.Top;
            border.Child             = image;

            Grid.SetColumn(border, 0);
            grid.Children.Add(border);

            var stackPanel = new StackPanel();

            var label = new TextBlock();

            var name = showFriendlyName ? fixtureClass.FriendlyName : fixtureClass.ShortName;

            if (showKey)
            {
                label.Text = name + " (" + fixtureClass.Character + ")";
            }
            else
            {
                label.Text = name;
            }

            if (singleRow)
            {
                grid.ToolTip = "Selected Event is " + fixtureClass.FriendlyName;
            }

            if (manuallyClassified)
            {
                label.Text += "*";
                if (singleRow)
                {
                    grid.ToolTip += "\r\n* = Manually classified";
                }
            }

            label.Margin              = new Thickness(6, 0, 0, 0);
            label.FontWeight          = fontWeight;
            label.HorizontalAlignment = HorizontalAlignment.Left;
            label.VerticalAlignment   = VerticalAlignment.Center;

            stackPanel.Children.Add(label);

            if (firstCycle)
            {
                label                     = new TextBlock();
                label.Text                = "(1st Cycle)";
                label.Margin              = new Thickness(6, 0, 0, 0);
                label.FontWeight          = fontWeight;
                label.HorizontalAlignment = HorizontalAlignment.Left;
                label.VerticalAlignment   = VerticalAlignment.Center;
                stackPanel.Children.Add(label);

                if (singleRow)
                {
                    stackPanel.Orientation = Orientation.Horizontal;
                    label.Text             = "1";
                    if (singleRow)
                    {
                        grid.ToolTip += "\r\n1 = 1st Cycle";
                    }
                }

                if (firstCycleManuallyClassified)
                {
                    label.Text += "*";
                }
            }

            if (showHasNotes)
            {
                label                     = new TextBlock();
                label.Text                = "Notes";
                label.Margin              = new Thickness(6, 0, 0, 0);
                label.FontWeight          = fontWeight;
                label.HorizontalAlignment = HorizontalAlignment.Left;
                label.VerticalAlignment   = VerticalAlignment.Center;
                stackPanel.Children.Add(label);

                if (singleRow)
                {
                    stackPanel.Orientation = Orientation.Horizontal;
                    label.Text             = "N";
                    grid.ToolTip          += "\r\nN = Has User Notes";
                }
            }

            Grid.SetColumn(stackPanel, 1);
            grid.Children.Add(stackPanel);

            this.Content = grid;
        }
Esempio n. 3
0
 public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
 {
     return(TwBrushes.FrozenSolidColorBrush(((FixtureClass)value).Color));
 }
Esempio n. 4
0
        public StyledFixtureLabel(Event @event, bool showFriendlyName, bool activateCommand)
        {
            this.Focusable = false;
            this.IsTabStop = false;

            if (activateCommand)
            {
                this.InputBindings.Add(new MouseBinding(AnalysisPanel.BringSelectedEventIntoViewCommand, new MouseGesture(MouseAction.LeftDoubleClick, ModifierKeys.None)));
            }

            FixtureClass = @event.FixtureClass;

            this.ToolTip = BuildToolTip(@event);

            var panel = new StackPanel();

            panel.Orientation = Orientation.Horizontal;


            var panelTicks = new StackPanel();

            {
                var tick = new ClassificationTick();
                tick.Padding           = new Thickness(0, 1, 4, 1);
                tick.VerticalAlignment = VerticalAlignment.Center;

                if (@event.ManuallyClassified)
                {
                    tick.TickClassifiedUsingFixtureList.Visibility     = Visibility.Collapsed;
                    tick.TickClassifiedUsingMachineLearning.Visibility = Visibility.Collapsed;
                }
                else if (@event.ClassifiedUsingFixtureList)
                {
                    tick.TickManuallyClassified.Visibility             = Visibility.Collapsed;
                    tick.TickClassifiedUsingMachineLearning.Visibility = Visibility.Collapsed;
                }
                else
                {
                    tick.TickManuallyClassified.Visibility         = Visibility.Collapsed;
                    tick.TickClassifiedUsingFixtureList.Visibility = Visibility.Collapsed;
                }
                panelTicks.Children.Add(tick);
            }

            if (@event.ManuallyApproved)
            {
                var tick = new ApprovalTick();
                tick.Padding           = new Thickness(0, 1, 4, 1);
                tick.VerticalAlignment = VerticalAlignment.Center;
                panelTicks.Children.Add(tick);
            }

            panel.Children.Add(panelTicks);

            Image image = new Image();

            image.Style  = (Style)ResourceLocator.FindResource("ImageStyle");
            image.Source = TwGui.GetImage(@event.FixtureClass.ImageFilename);

            Border border = new Border();

            border.Margin            = new Thickness(3, 0, 0, 0);
            border.Style             = (Style)ResourceLocator.FindResource("FixtureBorderStyle");
            border.Background        = TwBrushes.FrozenSolidColorBrush(@event.FixtureClass.Color);
            border.VerticalAlignment = VerticalAlignment.Top;
            border.Child             = image;
            panel.Children.Add(border);

            var label = new TextBlock();

            label.Text    = showFriendlyName ? @event.FixtureClass.FriendlyName : @event.FixtureClass.ShortName;
            label.Padding = new Thickness(3, 0, 0, 0);
            panel.Children.Add(label);

            if (@event.FirstCycle)
            {
                label                = new TextBlock();
                label.FontSize       = 8;
                label.BaselineOffset = 10;
                label.Text           = "1";
                if ([email protected])
                {
                    label.FontStyle = FontStyles.Italic;
                }
                label.Padding = new Thickness(3, 0, 0, 0);
                panel.Children.Add(label);
            }
            else if (@event.ManuallyClassifiedFirstCycle)
            {
                label                = new TextBlock();
                label.FontSize       = 8;
                label.BaselineOffset = 10;
                label.Text           = "0";
                label.Padding        = new Thickness(3, 0, 0, 0);
                panel.Children.Add(label);
            }

            //if (!string.IsNullOrEmpty(@event.UserNotes)) {
            //    label = new TextBlock();
            //    label.Padding = new Thickness(3, 0, 0, 0);
            //    label.Text = "N";
            //    panel.Children.Add(label);
            //}

            this.Content = panel;
        }