Esempio n. 1
0
        /// <summary>
        /// draw an exception
        /// </summary>
        /// <param name="canvas"></param>
        /// <param name="exception"></param>
        public static void DrawException(Canvas canvas, String exception)
        {
            canvas.Background = ProfileManager.ActiveProfile.BackgroundColor;

            double sixth = canvas.Height / 6;
            double tenth = canvas.Width / 10;

            canvas.Children.Clear();

            TextBlock overallOperationTextBlock = new TextBlock();
            overallOperationTextBlock.Text = exception;
            overallOperationTextBlock.Foreground = ProfileManager.ActiveProfile.PrimaryColor;
            overallOperationTextBlock.FontSize = sixth / 1.5;
            overallOperationTextBlock.Width = canvas.Width;
            overallOperationTextBlock.Margin = new Thickness(0, 3 * sixth, 0, 0);
            overallOperationTextBlock.FontFamily = new System.Windows.Media.FontFamily("Century Gothic");

            overallOperationTextBlock.TextAlignment = TextAlignment.Center;

            canvas.Children.Add(overallOperationTextBlock);
            canvas.UpdateLayout();

            canvas.Refresh();
        }
Esempio n. 2
0
        /// <summary>
        /// Draw processing progress
        /// </summary>
        /// <param name="canvas">canvas where the progress will be drawn</param>
        /// <param name="pp">active processing progress</param>
        public static void DrawProgress(Canvas canvas, ProcessingProgress pp)
        {
            canvas.Background = ProfileManager.MinimalView ? System.Windows.Media.Brushes.Transparent : ProfileManager.ActiveProfile.BackgroundColor;

            String currentOperationName = pp.CurrentOperationName;
            Double currentOperation = ((Double)pp.CurrentOperationElement * 100 / (Double)pp.CurrentOperationTotalElements);
            String currentOperationProgress = String.Format("{0:00.00}", currentOperation) + " %";

            String overallOperationName = pp.OverallOperationName;
            Double overallOperation = ((Double)pp.OverallOperationElement * 100 / (Double)pp.OverallOperationTotalElements);
            String overallOperationProgress = String.Format("{0:00.00}", overallOperation) + " %";

            canvas.Children.Clear();

            double sixth = canvas.Height / 6;
            double tenth = canvas.Width / 10;

            //current
            System.Windows.Shapes.Rectangle currentOperationOuterRect = new System.Windows.Shapes.Rectangle();
            currentOperationOuterRect.Width = canvas.Width - tenth;
            currentOperationOuterRect.Height = sixth;
            currentOperationOuterRect.Stroke = ProfileManager.ActiveProfile.SecondaryColor;
            currentOperationOuterRect.StrokeThickness = 2;
            currentOperationOuterRect.Fill = ProfileManager.ActiveProfile.BackgroundColor;
            currentOperationOuterRect.Margin = new Thickness(tenth / 2, sixth, 0, 0);

            System.Windows.Shapes.Rectangle currentOperationInnerRect = new System.Windows.Shapes.Rectangle();
            currentOperationInnerRect.Width = ((canvas.Width - tenth - 6) * currentOperation) / 100;
            currentOperationInnerRect.Height = sixth - 6;
            currentOperationInnerRect.Stroke = ProfileManager.ActiveProfile.BackgroundColor;
            currentOperationInnerRect.StrokeThickness = 2;
            currentOperationInnerRect.Fill = ProfileManager.ActiveProfile.SecondaryColor;
            currentOperationInnerRect.Margin = new Thickness((tenth + 6) / 2, sixth + 3, 0, 0);

            TextBlock currentOperationTextBlock = new TextBlock();
            currentOperationTextBlock.Text = currentOperationName + "  [ " + currentOperationProgress + " ]";
            currentOperationTextBlock.Foreground = ProfileManager.ActiveProfile.SecondaryColor;
            currentOperationTextBlock.FontSize = sixth / 1.5;
            currentOperationTextBlock.Width = canvas.Width;
            currentOperationTextBlock.FontFamily = new System.Windows.Media.FontFamily("Century Gothic");

            currentOperationTextBlock.TextAlignment = TextAlignment.Center;

            //overall
            System.Windows.Shapes.Rectangle overallOperationOuterRect = new System.Windows.Shapes.Rectangle();
            overallOperationOuterRect.Width = canvas.Width - tenth;
            overallOperationOuterRect.Height = sixth;
            overallOperationOuterRect.Stroke = ProfileManager.ActiveProfile.PrimaryColor;
            overallOperationOuterRect.StrokeThickness = 2;
            overallOperationOuterRect.Fill = ProfileManager.ActiveProfile.BackgroundColor;
            overallOperationOuterRect.Margin = new Thickness(tenth / 2, 4 * sixth, 0, 0);

            System.Windows.Shapes.Rectangle overallOperationInnerRect = new System.Windows.Shapes.Rectangle();
            overallOperationInnerRect.Width = ProfileManager.MinimalView ? ((canvas.Width - tenth) * overallOperation) / 100 : ((canvas.Width - tenth - 6) * overallOperation) / 100;
            overallOperationInnerRect.Height = ProfileManager.MinimalView ? sixth - 2 : sixth - 6;
            overallOperationInnerRect.Stroke = ProfileManager.ActiveProfile.BackgroundColor;
            overallOperationInnerRect.StrokeThickness = ProfileManager.MinimalView ? 0 : 2;
            overallOperationInnerRect.Fill = ProfileManager.ActiveProfile.PrimaryColor;
            overallOperationInnerRect.Margin = ProfileManager.MinimalView ? new Thickness(tenth / 2 + 1, 4 * sixth + 1, 0, 0) : new Thickness((tenth + 6) / 2, 4 * sixth + 3, 0, 0);

            TextBlock overallOperationTextBlock = new TextBlock();
            overallOperationTextBlock.Text = overallOperationName + "  [ " + overallOperationProgress + " ]";
            overallOperationTextBlock.Foreground = ProfileManager.ActiveProfile.PrimaryColor;
            overallOperationTextBlock.FontSize = sixth / 1.5;
            overallOperationTextBlock.Width = canvas.Width;
            overallOperationTextBlock.Margin = new Thickness(0, 3 * sixth, 0, 0);
            overallOperationTextBlock.FontFamily = new System.Windows.Media.FontFamily("Century Gothic");

            overallOperationTextBlock.TextAlignment = TextAlignment.Center;

            if (!ProfileManager.MinimalView) canvas.Children.Add(currentOperationTextBlock);
            if (!ProfileManager.MinimalView) canvas.Children.Add(currentOperationOuterRect);
            if (!ProfileManager.MinimalView) canvas.Children.Add(currentOperationInnerRect);

            if (!ProfileManager.MinimalView) canvas.Children.Add(overallOperationTextBlock);
            canvas.Children.Add(overallOperationOuterRect);
            canvas.Children.Add(overallOperationInnerRect);
            canvas.UpdateLayout();

            canvas.Refresh();
        }