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


C# Brush.Equals方法代碼示例

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


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

示例1: BrushToColor

 private Color BrushToColor(Brush brush)
 {
     if (brush.Equals(Brushes.Red))
         return Color.Red;
     if (brush.Equals(Brushes.Orange))
         return Color.Orange;
     if (brush.Equals(Brushes.Yellow))
         return Color.Yellow;
     if (brush.Equals(Brushes.Green))
         return Color.Green;
     if (brush.Equals(Brushes.Blue))
         return Color.Blue;
     return Color.Purple;
 }
開發者ID:glenwatson,項目名稱:Flood-It-Solver,代碼行數:14,代碼來源:BoardViewControl.xaml.cs

示例2: UpdateCircleColour

 private void UpdateCircleColour(Brush brush, Ellipse circle)
 {
     if (!brush.Equals(Gray) && !circle.Fill.Equals(Gray))
         circle.Fill = Violet;
     else
         circle.Fill = brush;
 }
開發者ID:kennedykinyanjui,項目名稱:Projects,代碼行數:7,代碼來源:MainWindow.xaml.cs

示例3: Equals

		public static bool Equals(Brush a, Brush b) {
			if (a == b)
				return true;
			if (a == null || b == null)
				return false;

			if (a.Opacity == 0 && b.Opacity == 0)
				return true;

			var sa = a as SolidColorBrush;
			var sb = b as SolidColorBrush;
			if (sa != null && sb != null) {
				if (sa.Color.A == 0 && sb.Color.A == 0)
					return true;
				return sa.Color.A == sb.Color.A && sa.Color.R == sb.Color.R && sa.Color.G == sb.Color.G && sa.Color.B == sb.Color.B;
			}

			return a.Equals(b);
		}
開發者ID:manojdjoshi,項目名稱:dnSpy,代碼行數:19,代碼來源:BrushComparer.cs

示例4: CreateTextMaterial

        /// <summary>
        /// Creates the text material.
        /// </summary>
        /// <param name="items">The items.</param>
        /// <param name="createElement">The create element.</param>
        /// <param name="background">The background.</param>
        /// <param name="elementMap">The element map.</param>
        /// <param name="elementPositions">The element positions.</param>
        /// <returns>A text material.</returns>
        public static Material CreateTextMaterial(
            IEnumerable<TextItem> items,
            Func<string, FrameworkElement> createElement,
            Brush background,
            out Dictionary<string, FrameworkElement> elementMap,
            out Dictionary<FrameworkElement, Rect> elementPositions)
        {
            var panel = new WrapPanel();
            elementMap = new Dictionary<string, FrameworkElement>();
            double maxWidth = 16;
            foreach (var item in items)
            {
                if (elementMap.ContainsKey(item.Text))
                {
                    continue;
                }

                var e = createElement(item.Text);
                e.Measure(new Size(2048, 2048));
                maxWidth = Math.Max(maxWidth, e.DesiredSize.Width);
                elementMap[item.Text] = e;
                panel.Children.Add(e);
            }

            var pw = (int)OptimizeSize(panel, maxWidth, 1024);
            var ph = (int)Math.Min(pw, panel.ActualHeight);

            elementPositions = new Dictionary<FrameworkElement, Rect>();
            foreach (FrameworkElement element in panel.Children)
            {
                var loc = element.TranslatePoint(new Point(0, 0), panel);
                double x = (int)Math.Floor(loc.X);
                double y = (int)Math.Floor(loc.Y);
                double x2 = (int)Math.Ceiling(loc.X + element.RenderSize.Width);
                double y2 = (int)Math.Ceiling(loc.Y + element.RenderSize.Height);
                elementPositions[element] = new Rect(x / pw, y / ph, (x2 - x) / pw, (y2 - y) / ph);
            }

            // Create the bitmap
            var rtb = new RenderTargetBitmap(pw, ph, 96, 96, PixelFormats.Pbgra32);
            rtb.Render(panel);
            rtb.Freeze();
            var ib = new ImageBrush(rtb)
                         {
                             Stretch = Stretch.Fill,
                             ViewboxUnits = BrushMappingMode.RelativeToBoundingBox,
                             Viewbox = new Rect(0, 0, 1, 1),
                             ViewportUnits = BrushMappingMode.Absolute,
                             Viewport = new Rect(0, 0, 1, 1),
                             TileMode = TileMode.None,
                             AlignmentX = AlignmentX.Left,
                             AlignmentY = AlignmentY.Top
                         };

            if (background != null && !background.Equals(Brushes.Transparent))
            {
                var mg = new MaterialGroup();
                mg.Children.Add(new DiffuseMaterial(Brushes.Black));
                mg.Children.Add(new EmissiveMaterial(ib));
                return mg;
            }

            return new DiffuseMaterial(ib) { Color = Colors.White };
        }
開發者ID:ondrej11,項目名稱:o106,代碼行數:73,代碼來源:TextGroupVisual3D.cs

示例5: Prompt

        /// <summary>
        /// Prompts with specified colors.
        /// </summary>
        /// <param name="background">The background.</param>
        /// <param name="foreground">The foreground.</param>
        /// <param name="prompt">The prompt text.</param>
        public void Prompt(Brush foreground, Brush background, string prompt)
        {
            TrimCurrentParagraph();

            //currentParagraph.ContentStart.GetOffsetToPosition(currentParagraph.ContentEnd) + PromptPadding.Length;
            Run prmt = new Run(prompt);
            if( !background.Equals( this.Background ) ) prmt.Background = background;
            prmt.Foreground = foreground;
            currentParagraph.Inlines.Add(prmt);

            SetPrompt();
            // toggle undo to prevent "undo"ing past this point.
            IsUndoEnabled = false;
            IsUndoEnabled = true;
            promptInlines = currentParagraph.Inlines.Count;
        }
開發者ID:ForNeVeR,項目名稱:PoshConsole,代碼行數:22,代碼來源:ConsoleTextBox.cs

示例6: Equals

		static bool Equals(Brush a, Brush b) {
			if (a == b)
				return true;
			if (a == null || b == null)
				return false;
			if (a.Opacity == 0 && b.Opacity == 0)
				return true;

			var sa = a as SolidColorBrush;
			var sb = b as SolidColorBrush;
			if (sa != null && sb != null) {
				var ca = sa.Color;
				var cb = sb.Color;
				return ca == cb || (ca.A == 0 && cb.A == 0);
			}

			return a.Equals(b);
		}
開發者ID:arkanoid1,項目名稱:dnSpy,代碼行數:18,代碼來源:HexTextRunProperties.cs

示例7: CompareBrushes

 private bool CompareBrushes(Brush brush1, Brush brush2)
 {
     return !brush1.Equals(brush2);
 }
開發者ID:fednep,項目名稱:UV-Outliner,代碼行數:4,代碼來源:FontProperties.cs

示例8: Equals

		private static bool Equals(Brush a, Brush b)
		{
			if (a == null)
				return b == null;
			return a.Equals(b);
		}
開發者ID:JeroenBos,項目名稱:ASDE,代碼行數:6,代碼來源:Markup.cs


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