Example #1
0
        // Draws the display on the window
        private void DrawScreen(List <Pipeline> pipelines)
        {
            _canvas.Children.Clear();
            if (Pipelines.Any())
            {
                CalculateMaximums();
                var pipelineArray = pipelines.ToArray();
                var counter       = 0;
                for (var i = 0; i < Columns; i++)
                {
                    for (var j = 0; j < Rows; j++)
                    {
                        try
                        {
                            DrawPipelineSegment(i, j, (Pipeline)pipelineArray.GetValue(counter));
                            counter++;
                        }
                        catch (Exception)
                        {
                            Console.WriteLine("Do nothing");
                        }
                    }
                }
            }
            else
            {
                var viewBox = new Viewbox
                {
                    MaxWidth  = (ActualWidth / 100) * 80,
                    MaxHeight = ActualHeight / 2
                };
                Canvas.SetLeft(viewBox, (ActualWidth / 100) * 10);
                Canvas.SetTop(viewBox, (ActualHeight / 3));

                var textBlock = new TextBlock // Contains the name of the Pipeline to display
                {
                    Text                = "There is nothing to parse at the given URL\nDouble check URL setting",
                    Foreground          = new SolidColorBrush(Colors.White),
                    HorizontalAlignment = HorizontalAlignment.Center,
                    TextAlignment       = TextAlignment.Center,
                    TextWrapping        = TextWrapping.Wrap
                };

                viewBox.Child = textBlock;
                _canvas.Children.Add(viewBox);
            }
            Content = _canvas; // Add this segment to the screens content
            GC.Collect();
            GC.WaitForPendingFinalizers();
            GC.Collect();
        }
Example #2
0
        // Draws a single segment
        private void DrawPipelineSegment(int column, int row, Pipeline pipeline)
        {
            var rectangle = new Rectangle // The background rectangle
            {
                Name            = "Rectangle" + column + "" + row,
                Width           = (ActualWidth - 16) / Columns,
                Height          = (ActualHeight - 39) / Rows,
                Stroke          = new SolidColorBrush(Colors.Black),
                StrokeThickness = 1,
                Fill            = new SolidColorBrush(ColorForPipeline(pipeline))
            };

            Canvas.SetLeft(rectangle, column * rectangle.Width);
            Canvas.SetTop(rectangle, row * rectangle.Height);
            _canvas.Children.Add(rectangle);

            var textBlock = new TextBlock // Contains the name of the Pipeline to display
            {
                Text       = pipeline.Name,
                Foreground = new SolidColorBrush(Colors.Black)
            };

            var viewBox = new Viewbox // Scales the containing elements
            {
                MaxWidth  = (rectangle.Width / 100) * 80,
                MinHeight = (rectangle.Height / 100) * 90,
                MaxHeight = (rectangle.Height / 100) * 90
            };

            Canvas.SetLeft(viewBox, (column * rectangle.Width) + ((rectangle.Width / 100) * 10));
            Canvas.SetTop(viewBox, (row * rectangle.Height));

            if (pipeline.IsBrokenProject)
            {
                textBlock.TextAlignment = TextAlignment.Left;
                textBlock.Text          = "    " + textBlock.Text;
            }

            viewBox.Child = textBlock;
            _canvas.Children.Add(viewBox);
        }
Example #3
0
        private void DrawErrorScreen(Error error)
        {
            _canvas.Children.Clear();
            switch (error)
            {
            case Error.ErrorWebException:
                var errorViewBox = new Viewbox
                {
                    MaxWidth  = (ActualWidth / 100) * 80,
                    MaxHeight = ActualHeight / 2
                };
                Canvas.SetLeft(errorViewBox, (ActualWidth / 100) * 10);

                var errorTextBlock = new TextBlock     // Contains the name of the Pipeline to display
                {
                    Text                = "Network Error",
                    Foreground          = new SolidColorBrush(Colors.White),
                    HorizontalAlignment = HorizontalAlignment.Center,
                };

                var timerViewBox = new Viewbox
                {
                    MaxWidth  = (ActualWidth / 100) * 50,
                    MaxHeight = ActualHeight / 2
                };
                Canvas.SetTop(timerViewBox, (ActualHeight / 2) + 10);
                Canvas.SetLeft(timerViewBox, (ActualWidth / 100) * 25);

                var timerTextBlock = new TextBlock
                {
                    Foreground          = new SolidColorBrush(Colors.White),
                    HorizontalAlignment = HorizontalAlignment.Center
                };

                var time  = TimeSpan.FromSeconds(Config.Default.PollSpeed - 1);
                var timer = new DispatcherTimer();
                timer = new DispatcherTimer(new TimeSpan(0, 0, 1), DispatcherPriority.Normal, delegate
                {
                    timerTextBlock.Text = time.ToString("c");
                    if (time == TimeSpan.Zero)
                    {
                        timer.Stop();
                    }
                    time = time.Add(TimeSpan.FromSeconds(-1));
                }, Application.Current.Dispatcher);

                timer.Start();

                timerViewBox.Child = timerTextBlock;
                errorViewBox.Child = errorTextBlock;
                _canvas.Children.Add(timerViewBox);
                _canvas.Children.Add(errorViewBox);
                break;

            case Error.ErrorInvalidUrl:
                var viewBox = new Viewbox
                {
                    MaxWidth  = (ActualWidth / 100) * 80,
                    MaxHeight = ActualHeight / 2
                };
                Canvas.SetLeft(viewBox, (ActualWidth / 100) * 10);

                var textBlock = new TextBlock     // Contains the name of the Pipeline to display
                {
                    Text                = "Network Error",
                    Foreground          = new SolidColorBrush(Colors.White),
                    HorizontalAlignment = HorizontalAlignment.Center,
                };

                var box = new Viewbox
                {
                    MaxWidth  = (ActualWidth / 100) * 50,
                    MaxHeight = ActualHeight / 2
                };
                Canvas.SetTop(box, (ActualHeight / 2) + 10);
                Canvas.SetLeft(box, (ActualWidth / 100) * 25);

                var block = new TextBlock
                {
                    Foreground          = new SolidColorBrush(Colors.White),
                    HorizontalAlignment = HorizontalAlignment.Center
                };

                var span            = TimeSpan.FromSeconds(Config.Default.PollSpeed - 1);
                var dispatcherTimer = new DispatcherTimer();
                dispatcherTimer = new DispatcherTimer(new TimeSpan(0, 0, 1), DispatcherPriority.Normal, delegate
                {
                    block.Text = span.ToString("c");
                    if (span == TimeSpan.Zero)
                    {
                        dispatcherTimer.Stop();
                    }
                    span = span.Add(TimeSpan.FromSeconds(-1));
                }, Application.Current.Dispatcher);

                dispatcherTimer.Start();

                box.Child     = block;
                viewBox.Child = textBlock;
                _canvas.Children.Add(box);
                _canvas.Children.Add(viewBox);
                break;
            }
        }