當前位置: 首頁>>代碼示例>>C#>>正文


C# Brush.CloneCurrentValue方法代碼示例

本文整理匯總了C#中System.Windows.Media.Brush.CloneCurrentValue方法的典型用法代碼示例。如果您正苦於以下問題:C# Brush.CloneCurrentValue方法的具體用法?C# Brush.CloneCurrentValue怎麽用?C# Brush.CloneCurrentValue使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Windows.Media.Brush的用法示例。


在下文中一共展示了Brush.CloneCurrentValue方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: UpdateNodeBrushes

        public void UpdateNodeBrushes(Brush brush, Dictionary<int, List<SankeyNode>> nodes)
        {
            if(diagram == null || brush == null || nodes == null || nodes.Count < 2)
            {
                return;
            }

            if(diagram.UsePallette == SankeyPalette.NodesLinks)
            {
                return;
            }

            ResetHighlight();

            foreach(var levelNodes in nodes.Values)
            {
                foreach(var node in levelNodes)
                {
                    node.Shape.Fill = brush.CloneCurrentValue();
                }
            }
        }
開發者ID:ZoeCheck,項目名稱:SankeyDiagram,代碼行數:22,代碼來源:SankeyStyleManager.cs

示例2: RandomizeBrush

        public static Brush RandomizeBrush(Brush brush)
        {
            if (brush is SolidColorBrush)
            {
                return new SolidColorBrush(GetRandomRainbowMediaColor());
            }

            if (brush is LinearGradientBrush)
            {
                var randomBrush = (LinearGradientBrush) brush.CloneCurrentValue();
                var rand = GetRandomRainbowMediaColor();
                foreach (var stop in randomBrush.GradientStops)
                    stop.Color = System.Windows.Media.Color.FromArgb(stop.Color.A, rand.R, rand.G, rand.B);

                return randomBrush;
            }

            if (brush is RadialGradientBrush)
            {
                var randomBrush = (RadialGradientBrush) brush.CloneCurrentValue();
                var rand = GetRandomRainbowMediaColor();
                foreach (var stop in randomBrush.GradientStops)
                    stop.Color = System.Windows.Media.Color.FromArgb(stop.Color.A, rand.R, rand.G, rand.B);

                return randomBrush;
            }

            return brush;
        }
開發者ID:SpoinkyNL,項目名稱:Artemis,代碼行數:29,代碼來源:ColorHelpers.cs

示例3: Initialize


//.........這裏部分代碼省略.........

            Window_TitleGrid.ClipToBounds = true;
            Window_TitleGrid.Height = TITLE_BAR_HEIGHT;
            Window_TitleGrid.VerticalAlignment = System.Windows.VerticalAlignment.Top;
            Window_TitleGrid.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
            Window_TitleGrid.Children.Add(TitleIcon);
            Window_TitleGrid.Children.Add(Window_TitleLabel);
            Window_TitleGrid.Children.Add(Window_Button_Close);
            Window_TitleGrid.Children.Add(Window_Button_Maximize);
            Window_TitleGrid.Children.Add(Window_Button_Minimize);

            Window_TitleLabel.VerticalAlignment = System.Windows.VerticalAlignment.Top;
            Window_TitleLabel.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
            Window_TitleLabel.Height = TITLE_BAR_HEIGHT - 2;
            Window_TitleLabel.VerticalContentAlignment = System.Windows.VerticalAlignment.Center;
            Window_TitleLabel.Margin = new Thickness(30, 0, 140, 0);
            Window_TitleLabel.Foreground = Brushes.White;

            Window_Button_Close.MouseEnter += Window_Button_MouseEnter;
            Window_Button_Close.MouseLeave += Window_Button_MouseLeave;
            Window_Button_Close.Click += Window_Close;
            Window_Button_Close.Content = 'r';
            Window_Button_Close.FontFamily = new System.Windows.Media.FontFamily("Webdings");
            Window_Button_Close.FontSize = 11;
            Window_Button_Close.Height = 19;
            Window_Button_Close.HorizontalAlignment = System.Windows.HorizontalAlignment.Right;
            Window_Button_Close.VerticalAlignment = System.Windows.VerticalAlignment.Top;
            Window_Button_Close.Padding = new Thickness(0, -CHROME_BUTTON_TOP_MARGIN - 1, 0, 0);
            Window_Button_Close.Foreground = Brushes.Black;
            Window_Button_Close.BorderThickness = new Thickness(1);
            Window_Button_Close.FontWeight = FontWeights.Bold;
            Window_Button_Close.Width = X_BUTTON_NORMAL_WIDTH;
            Window_Button_Close.Margin = new Thickness(0, CHROME_BUTTON_TOP_MARGIN, 5, 0);
            Window_Button_Close.Focusable = false;
            WindowChrome.SetIsHitTestVisibleInChrome(Window_Button_Close, true);

            Window_Button_Maximize.MouseEnter += Window_Button_MouseEnter;
            Window_Button_Maximize.MouseLeave += Window_Button_MouseLeave;
            Window_Button_Maximize.Click += Window_MaximizeRestore;
            Window_Button_Maximize.Content = '1';
            Window_Button_Maximize.FontFamily = new System.Windows.Media.FontFamily("Webdings");
            Window_Button_Maximize.FontSize = 11;
            Window_Button_Maximize.Height = 19;
            Window_Button_Maximize.HorizontalAlignment = System.Windows.HorizontalAlignment.Right;
            Window_Button_Maximize.VerticalAlignment = System.Windows.VerticalAlignment.Top;
            Window_Button_Maximize.Padding = new Thickness(0, -CHROME_BUTTON_TOP_MARGIN - 1, 0, 0);
            Window_Button_Maximize.Foreground = Brushes.Black;
            Window_Button_Maximize.BorderThickness = new Thickness(1);
            Window_Button_Maximize.FontWeight = FontWeights.Bold;
            Window_Button_Maximize.Width = 30;
            Window_Button_Maximize.Margin = new Thickness(0, CHROME_BUTTON_TOP_MARGIN, 52, 0);
            Window_Button_Maximize.Focusable = false;
            WindowChrome.SetIsHitTestVisibleInChrome(Window_Button_Maximize, true);

            Window_Button_Minimize.MouseEnter += Window_Button_MouseEnter;
            Window_Button_Minimize.MouseLeave += Window_Button_MouseLeave;
            Window_Button_Minimize.Click += Window_Minimize;
            Window_Button_Minimize.Content = '0';
            Window_Button_Minimize.FontFamily = new System.Windows.Media.FontFamily("Webdings");
            Window_Button_Minimize.FontSize = 11;
            Window_Button_Minimize.Height = 19;
            Window_Button_Minimize.HorizontalAlignment = System.Windows.HorizontalAlignment.Right;
            Window_Button_Minimize.VerticalAlignment = System.Windows.VerticalAlignment.Top;
            Window_Button_Minimize.Padding = new Thickness(0, -CHROME_BUTTON_TOP_MARGIN - 1, 0, 0);
            Window_Button_Minimize.Foreground = Brushes.Black;
            Window_Button_Minimize.BorderThickness = new Thickness(1);
            Window_Button_Minimize.FontWeight = FontWeights.Bold;
            Window_Button_Minimize.Width = 30;
            Window_Button_Minimize.Margin = new Thickness(0, CHROME_BUTTON_TOP_MARGIN, 81, 0);
            Window_Button_Minimize.Focusable = false;
            WindowChrome.SetIsHitTestVisibleInChrome(Window_Button_Minimize, true);

            #endregion

            #region COLOR_PICKER
            foreach (ThemeColors t in AvailableThemeColors)
            {
                MenuItem NewItem = new MenuItem();
                NewItem.Header = t;
                NewItem.Click += (o, e) =>
                {
                    ThemeColor = (ThemeColors)((MenuItem)e.Source).Header;
                };
                ColorPicker.Items.Add(NewItem);
            }
            //Window_TitleGrid.ContextMenu = ColorPicker;
            #endregion

            Window_Button_Close.Style = (Style)this.FindResource("Window_Button_Close");
            Window_Button_Maximize.Style = (Style)this.FindResource("Window_Button_Maximize");
            Window_Button_Minimize.Style = (Style)this.FindResource("Window_Button_Minimize");
            Window_TitleGrid.Style = (Style)this.FindResource("Window_Frame_Title_Bar");
            Window_Border.Style = (Style)this.FindResource("Window_Frame_Border");

            TitleEnabledBackground = Window_TitleGrid.Background.CloneCurrentValue();
            TitleDisabledBackground = TitleEnabledBackground.CloneCurrentValue();
            TitleDisabledBackground.Opacity = 0.4;
            TitleEnabledBackground.Freeze();
            TitleDisabledBackground.Freeze();
        }
開發者ID:kazelone,項目名稱:ExpressionWindow,代碼行數:101,代碼來源:ExpressionWindow.cs


注:本文中的System.Windows.Media.Brush.CloneCurrentValue方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。