当前位置: 首页>>代码示例>>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;未经允许,请勿转载。