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


C# BrushConverter.IsValid方法代码示例

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


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

示例1: OnDrop

        protected override void OnDrop(DragEventArgs e)
        {
            base.OnDrop(e);

            if (e.Data.GetDataPresent(DataFormats.StringFormat))
            {
                string dataString = (string) e.Data.GetData(DataFormats.StringFormat);

                BrushConverter converter = new BrushConverter();
                if (converter.IsValid(dataString))
                {
                    Brush newFill = (Brush) converter.ConvertFromString(dataString);
                    circleUI.Fill = newFill;

                    if (e.KeyStates.HasFlag(DragDropKeyStates.ControlKey))
                    {
                        e.Effects = DragDropEffects.Copy;
                    }
                    else
                    {
                        e.Effects = DragDropEffects.Move;
                    }
                }
            }
            e.Handled = true;
        }
开发者ID:cgideon,项目名称:CSharpSandbox,代码行数:26,代码来源:Circle.xaml.cs

示例2: ConvertBrush

 public static Brush ConvertBrush(System.Drawing.Color color)
 {
     var b = new BrushConverter();
     if (b.IsValid(color.Name)) {
         return b.ConvertFromString(color.Name) as SolidColorBrush;
     }
     return b.ConvertFromString("Black") as SolidColorBrush;
 }
开发者ID:2594636985,项目名称:SharpDevelop,代码行数:8,代码来源:FixedDocumentCreator.cs

示例3: ellipse_DragOver

        private void ellipse_DragOver(object sender, DragEventArgs e)
        {
            e.Effects = DragDropEffects.None;

            // If the DataObject contains string data, extract it.
            if (e.Data.GetDataPresent(DataFormats.StringFormat))
            {
                string dataString = (string)e.Data.GetData(DataFormats.StringFormat);

                // If the string can be converted into a Brush, allow copying.
                BrushConverter converter = new BrushConverter();
                if (converter.IsValid(dataString))
                {
                    e.Effects = DragDropEffects.Copy | DragDropEffects.Move;
                }
            }
        }
开发者ID:fan123777,项目名称:WPF_Unleashed,代码行数:17,代码来源:Dragging.xaml.cs

示例4: ellipse_DragEnter

        private void ellipse_DragEnter(object sender, DragEventArgs e)
        {
            Ellipse ellipse = sender as Ellipse;
            if (ellipse != null)
            {
                // Save the current Fill brush so that you can revert back to this value in DragLeave.
                _previousFill = ellipse.Fill;

                // If the DataObject contains string data, extract it.
                if (e.Data.GetDataPresent(DataFormats.StringFormat))
                {
                    string dataString = (string)e.Data.GetData(DataFormats.StringFormat);

                    // If the string can be converted into a Brush, convert it.
                    BrushConverter converter = new BrushConverter();
                    if (converter.IsValid(dataString))
                    {
                        Brush newFill = (Brush)converter.ConvertFromString(dataString);
                        ellipse.Fill = newFill;
                    }
                }
            }
        }
开发者ID:fan123777,项目名称:WPF_Unleashed,代码行数:23,代码来源:Dragging.xaml.cs

示例5: OnDragOver

        protected override void OnDragOver(DragEventArgs e)
        {
            base.OnDragOver(e);
            e.Effects = DragDropEffects.None;

            if (e.Data.GetDataPresent(DataFormats.StringFormat))
            {
                string dataString = (string) e.Data.GetData(DataFormats.StringFormat);

                BrushConverter converter = new BrushConverter();
                if (converter.IsValid(dataString))
                {
                    if (e.KeyStates.HasFlag(DragDropKeyStates.ControlKey))
                    {
                        e.Effects = DragDropEffects.Copy;
                    }
                    else
                    {
                        e.Effects = DragDropEffects.Move;
                    }
                }
            }
            e.Handled = true;
        }
开发者ID:cgideon,项目名称:CSharpSandbox,代码行数:24,代码来源:Circle.xaml.cs

示例6: OnDragEnter

        protected override void OnDragEnter(DragEventArgs e)
        {
            base.OnDragEnter(e);
            _previousFill = circleUI.Fill;

            if (e.Data.GetDataPresent(DataFormats.StringFormat))
            {
                string dataString = (string) e.Data.GetData(DataFormats.StringFormat);

                BrushConverter converter = new BrushConverter();
                if (converter.IsValid(dataString))
                {
                    Brush newFill = (Brush) converter.ConvertFromString(dataString);
                    circleUI.Fill = newFill;
                }
            }
        }
开发者ID:cgideon,项目名称:CSharpSandbox,代码行数:17,代码来源:Circle.xaml.cs

示例7: ellipse_Drop

        private void ellipse_Drop(object sender, DragEventArgs e)
        {
            Ellipse ellipse = sender as Ellipse;
            if (ellipse != null)
            {
                // If the DataObject contains string data, extract it.
                if (e.Data.GetDataPresent(DataFormats.StringFormat))
                {
                    string dataString = (string)e.Data.GetData(DataFormats.StringFormat);

                    // If the string can be converted into a Brush, 
                    // convert it and apply it to the ellipse.
                    BrushConverter converter = new BrushConverter();
                    if (converter.IsValid(dataString))
                    {
                        Brush newFill = (Brush)converter.ConvertFromString(dataString);
                        ellipse.Fill = newFill;
                    }
                }
            }
        }
开发者ID:fan123777,项目名称:WPF_Unleashed,代码行数:21,代码来源:Dragging.xaml.cs


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