protected override void ProcessStrokes(List <Stroke> strokes)
        {
            // clear all previous strokes
            foreach (UIElement p in TableGrid.Children)
            {
                if (p is Grid && p != NetOutStrokesContainerGrid)
                {
                    (p as Grid).Children.Clear();
                }
            }

            NetOutStrokesContainerGrid.Visibility = Visibility.Collapsed;
            NetOutStrokesGrid.Children.Clear();
            NetOutStrokesGrid.RowDefinitions.Clear();

            StrokeShapes.Clear();
            SelectedStroke = null;

            // add new lists of shapes for each stroke and also the strokes themselves
            // (at this point the actual size of this view should be set)
            foreach (Stroke s in strokes)
            {
                StrokeShapes[s] = new List <Shape>();

                if (s.EnumCourse == Models.Util.Enums.Stroke.Course.NetOut)
                {
                    AddNetOutShape(s);
                    NetOutStrokesContainerGrid.Visibility = Visibility.Visible;
                }
                else if (!PlacementValuesValid(s.Placement))
                {
                    continue;
                }
                else
                {
                    AddServiceStrokesSpinShapes(s);
                    AddStrokesDirectionShapes(s);
                    AddInterceptArrows(s);
                    AddStrokesArrowtips(s);
                }

                foreach (Shape shape in StrokeShapes[s])
                {
                    ToolTip tt = new ToolTip();
                    tt.Background = (Brush)matchPlayerToBrushConverter.Convert(s.Rally.Winner, typeof(Brush), 1, System.Globalization.CultureInfo.CurrentCulture);
                    tt.Content    = "#" + s.Rally.Number + " " +
                                    scoreToStringConverter.Convert(new object[] { s.Rally.CurrentRallyScore, s.Rally.CurrentSetScore }, typeof(string), false, System.Globalization.CultureInfo.CurrentCulture);
                    shape.ToolTip = tt;
                }
            }

            foreach (Stroke stroke in strokes)
            {
                if (ActiveRally != null && stroke.Rally.Number == ActiveRally.Number)
                {
                    SelectStroke(stroke);
                }
            }
        }
Example #2
0
        protected override void ProcessStrokes(List <Stroke> strokes)
        {
            // clear all previous strokes
            foreach (UIElement p in TableGrid.Children)
            {
                if (p is Grid && p != NetOutStrokesContainerGrid)
                {
                    (p as Grid).Children.Clear();
                }
            }

            NetOutStrokesContainerGrid.Visibility = Visibility.Collapsed;
            NetOutStrokesGrid.Children.Clear();
            NetOutStrokesGrid.RowDefinitions.Clear();

            StrokeShapes.Clear();
            SelectedStroke = null;

            // add new lists of shapes for each stroke and also the strokes themselves
            // (at this point the actual size of this view should be set)
            foreach (Stroke s in strokes)
            {
                StrokeShapes[s] = new List <Shape>();

                if (s.EnumCourse == Models.Util.Enums.Stroke.Course.NetOut)
                {
                    AddNetOutShape(s);
                    NetOutStrokesContainerGrid.Visibility = Visibility.Visible;
                }
                else if (!PlacementValuesValid(s.Placement))
                {
                    continue;
                }
                else
                {
                    AddServiceStrokesSpinShapes(s);
                    AddStrokesDirectionShapes(s);
                    AddInterceptArrows(s);
                    AddStrokesArrowtips(s);
                }
            }
        }
        protected override void ProcessStrokes(List <Stroke> strokes)
        {
            // clear all previous strokes
            foreach (UIElement p in TableGrid.Children)
            {
                if (p is Grid)
                {
                    (p as Grid).Children.Clear();
                }
            }
            StrokeShapes.Clear();

            // add new lists of shapes for each stroke - up to MaxDisplayedStrokes many for small table!
            int maxStrokeDisplayCounter = 0;

            foreach (Stroke s in strokes)
            {
                thisRally = s.Rally;

                maxStrokeDisplayCounter++;
                if (maxStrokeDisplayCounter > MaxDisplayedStrokes)
                {
                    break;
                }
                StrokeShapes[s]   = new List <Shape>();
                StrokeElements[s] = new List <FrameworkElement>();
            }

            // once size of this view changed, we know it's been fully added: add the actual stroke shapes (they need the actual size)
            new Thread(new ThreadStart(() =>
            {
                sizeChangedWaitEvent.WaitOne();

                Dispatcher.Invoke(() =>
                {
                    StrokeShapes.Keys.Apply(s => AddStroke(s));
                });
            })).Start();
        }