当前位置: 首页>>代码示例>>C#>>正文


C# Canvas.Refresh方法代码示例

本文整理汇总了C#中System.Windows.Controls.Canvas.Refresh方法的典型用法代码示例。如果您正苦于以下问题:C# Canvas.Refresh方法的具体用法?C# Canvas.Refresh怎么用?C# Canvas.Refresh使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Controls.Canvas的用法示例。


在下文中一共展示了Canvas.Refresh方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DrawException

        /// <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();
        }
开发者ID:sidhub1,项目名称:kinesis,代码行数:29,代码来源:CanvasUtil.cs

示例2: DrawProgress

        /// <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();
        }
开发者ID:sidhub1,项目名称:kinesis,代码行数:86,代码来源:CanvasUtil.cs


注:本文中的System.Windows.Controls.Canvas.Refresh方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。