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


C# BrushConverter.ConvertFrom方法代码示例

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


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

示例1: WatchViewFullscreen

        public WatchViewFullscreen()
        {
            InitializeComponent();

            MouseLeftButtonDown += new System.Windows.Input.MouseButtonEventHandler(view_MouseButtonIgnore);
            MouseLeftButtonUp += new System.Windows.Input.MouseButtonEventHandler(view_MouseButtonIgnore);
            MouseRightButtonUp += new System.Windows.Input.MouseButtonEventHandler(view_MouseRightButtonUp);
            PreviewMouseRightButtonDown += new System.Windows.Input.MouseButtonEventHandler(view_PreviewMouseRightButtonDown);

            MenuItem mi = new MenuItem();
            mi.Header = "Zoom to Fit";
            mi.Click += new RoutedEventHandler(mi_Click);

            MainContextMenu.Items.Add(mi);

            System.Windows.Shapes.Rectangle backgroundRect = new System.Windows.Shapes.Rectangle();
            Canvas.SetZIndex(backgroundRect, -10);
            backgroundRect.IsHitTestVisible = false;
            BrushConverter bc = new BrushConverter();
            Brush strokeBrush = (Brush)bc.ConvertFrom("#313131");
            backgroundRect.Stroke = strokeBrush;
            backgroundRect.StrokeThickness = 1;
            SolidColorBrush backgroundBrush = new SolidColorBrush(System.Windows.Media.Color.FromRgb(250, 250, 216));
            backgroundRect.Fill = backgroundBrush;

            inputGrid.Children.Add(backgroundRect);
        }
开发者ID:romeo08437,项目名称:Dynamo,代码行数:27,代码来源:WatchViewFullscreen.xaml.cs

示例2: setUpMap

        private void setUpMap()
        {
            for (int i = 0; i < 20; i++)
            {
                RowDefinition rowDef = new RowDefinition();
                rowDef.Height = new GridLength(1, GridUnitType.Star);
                mapGrid.RowDefinitions.Add(rowDef);
            }

            for (int i = 0; i < 15; i++)
            {
                ColumnDefinition colDef = new ColumnDefinition();
                colDef.Width = new GridLength(1, GridUnitType.Star);
                mapGrid.ColumnDefinitions.Add(colDef);
            }
            var bc = new BrushConverter();
            mapGrid.ShowGridLines = true;
            for (int i = 0; i < 9; i++)
            {
                Label label = new Label();
                label.Background = (Brush)bc.ConvertFrom("#FF28701C");
                Grid.SetRow(label, 19 - i / 3);
                Grid.SetColumn(label, i % 3);
                mapGrid.Children.Add(label);
            }

            for (int i = 0; i < 9; i++)
            {
                Label label = new Label();
                label.Background = (Brush)bc.ConvertFrom("#FF28701C");
                Grid.SetRow(label, i / 3);
                Grid.SetColumn(label, 14 - i % 3);
                mapGrid.Children.Add(label);
            }
        }
开发者ID:yikolyk,项目名称:MDP-Jan-2015,代码行数:35,代码来源:MainPage.xaml.cs

示例3: PingElapsed

        internal void PingElapsed(object sender, ElapsedEventArgs e)
        {
            if (i++ < 10) //Ping every 10 seconds
                return;
            i = 0;
            if (!Client.IsOnPlayPage)
                return;
            double PingAverage = HighestPingTime(Client.Region.PingAddresses);
            Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() =>
            {
                PingLabel.Content = Math.Round(PingAverage).ToString() + "ms";
                if (PingAverage == 0)
                    PingLabel.Content = "Timeout";
                if (PingAverage == -1)
                    PingLabel.Content = "Ping not enabled for this region";

                BrushConverter bc = new BrushConverter();
                Brush brush = null;
                if (PingAverage > 999 || PingAverage < 1)
                    brush = (Brush)bc.ConvertFrom("#FFFF6767");
                else if (PingAverage > 110 && PingAverage < 999)
                    brush = (Brush)bc.ConvertFrom("#FFFFD667");
                else
                    brush = (Brush)bc.ConvertFrom("#FF67FF67");
                PingRectangle.Fill = brush;
            }));
        }
开发者ID:Gratin,项目名称:LegendaryClient,代码行数:27,代码来源:PlayPage.xaml.cs

示例4: foregroundOverrideChangedCallback

 private static void foregroundOverrideChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
 {
     var bc = new BrushConverter();
     HyperLinkStandard input = (HyperLinkStandard)d;
     input.txtLink.Foreground = (Brush)bc.ConvertFrom(e.NewValue as string);
     input.Foreground = (Brush)bc.ConvertFrom(e.NewValue as string);
 }
开发者ID:ElementalCrisis,项目名称:jmmclient,代码行数:7,代码来源:HyperLinkStandard.xaml.cs

示例5: DeviceItem

        public DeviceItem(String username, String mac, String userimgurl, long lastupdated)
        {
            var bc = new BrushConverter();

            // IMAGE
            Image imgUser = new Image();
            imgUser.Source = new BitmapImage(new Uri(userimgurl));
            imgUser.Height = 44;
            imgUser.Width = 44;

            StackPanel spInnerImg = new StackPanel();
            spInnerImg.Orientation = System.Windows.Controls.Orientation.Vertical;
            spInnerImg.Height = 46;
            spInnerImg.Width = 44;
            spInnerImg.Children.Add(imgUser);

            Border borderInnerImg = new Border();
            borderInnerImg.Padding = new Thickness(2);
            borderInnerImg.Margin = new Thickness(0, 0, 5, 0);
            borderInnerImg.Background = (Brush)bc.ConvertFrom("#DDDDDD");
            borderInnerImg.Width = 46;
            borderInnerImg.Height = 48;
            borderInnerImg.Child = spInnerImg;

            // TEXT
            TextBlock tbUsername = new TextBlock(); tbUsername.Name = "username"; tbUsername.Text = username;
            TextBlock tbMac = new TextBlock(); tbMac.Name = "mac"; tbMac.Text = mac;
            TextBlock tbLastUpdated = new TextBlock(); tbLastUpdated.Name = "lastupdated";
            //DateTime date = new DateTime(lastupdated)
            DateTime dtDateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0);
            dtDateTime = dtDateTime.AddMilliseconds((double)lastupdated);
            tbLastUpdated.Text = dtDateTime.ToString("yyyy-MM-dd hh:mm:ss");
            //tbLastUpdated.Text = lastupdated.ToString();

            StackPanel spInnerText = new StackPanel();
            spInnerText.Orientation = System.Windows.Controls.Orientation.Vertical;
            spInnerText.Height = 48;
            spInnerText.Children.Add(tbUsername);
            spInnerText.Children.Add(tbMac);
            spInnerText.Children.Add(tbLastUpdated);

            // CONTAINER
            StackPanel spOuter = new StackPanel();
            spOuter.Orientation = System.Windows.Controls.Orientation.Horizontal;
            spOuter.Height = 48;
            spOuter.Children.Add(borderInnerImg);
            spOuter.Children.Add(spInnerText);

            Border borderOuter = new Border();
            borderOuter.Padding = new Thickness(2);
            borderOuter.Width = 198;
            borderOuter.Background = (Brush)bc.ConvertFrom("#BBBBBB");
            borderOuter.Child = spOuter;

            this.BorderThickness = new Thickness(0);
            this.Padding = new Thickness(0);
            this.Margin = new Thickness(0, 0, 0, 2);
            this.Content = borderOuter;
        }
开发者ID:nmplcpimenta,项目名称:scmu_project,代码行数:59,代码来源:DeviceItem.cs

示例6: Initialize

        private void Initialize()
        {
            _bc = new BrushConverter();
            _click = (Brush)_bc.ConvertFrom("#007acc");
            _hover = (Brush)_bc.ConvertFrom("#fcfcfc");
            _leave = Brushes.Transparent;

            ControlMin.Source = ImageEditing.GenerateImage(_minIconPath);
            ControlMax.Source = ImageEditing.GenerateImage(_maxIconPath);
            ControlClose.Source = ImageEditing.GenerateImage(_closeIcon);
        }
开发者ID:bedashii,项目名称:ReturnMedz,代码行数:11,代码来源:WUIControlBox.xaml.cs

示例7: StatusWindow

        public StatusWindow(ServerWindow mainWindow)
        {
            InitializeComponent();
            this.mainWindow = mainWindow;
            var bc = new BrushConverter();
            green = (Brush)bc.ConvertFrom("#FF76FF03");
            yellow = (Brush)bc.ConvertFrom("#FFFFFF00");
            red = (Brush)bc.ConvertFrom("#FFF44336");
            Background = red;
            Deactivated += StatusWindow_Deactivated;

        }
开发者ID:giu-fio,项目名称:remote-control-server,代码行数:12,代码来源:StatusWindow.xaml.cs

示例8: changeColor

 internal void changeColor()
 {
     Brush tmp = null;
     var bc = new BrushConverter();
     switch (col)
     {
         case 0: tmp = (Brush)bc.ConvertFrom("#FFF8b8"); break;
         case 1: tmp = (Brush)bc.ConvertFrom("#C4F5BF"); break;
         case 2: tmp = (Brush)bc.ConvertFrom("#FF9AA4"); break;
         case 3: tmp = (Brush)bc.ConvertFrom("#CBE9F8"); break;
     }
     this.Background = tmp;
     text.Background = tmp;
 }
开发者ID:marce155,项目名称:MyNotes,代码行数:14,代码来源:NoteWindow.xaml.cs

示例9: Convert

 /// <summary>
 /// </summary>
 /// <param name="value"> </param>
 /// <param name="targetType"> </param>
 /// <param name="parameter"> </param>
 /// <param name="culture"> </param>
 /// <returns> </returns>
 public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
 {
     var brushConverter = new BrushConverter();
     value = (value.ToString()
                   .StartsWith("#")) ? value : "#" + value;
     var result = (Brush) brushConverter.ConvertFrom("#FFFFFFFF");
     try
     {
         result = (Brush) brushConverter.ConvertFrom(value);
     }
     catch (Exception ex)
     {
     }
     return result;
 }
开发者ID:Yaguar666,项目名称:ffxivapp-common,代码行数:22,代码来源:StringToBrushConverter.cs

示例10: Convert

 /// <summary>
 /// </summary>
 /// <param name="value"> </param>
 /// <returns> </returns>
 public object Convert(object value)
 {
     var brushConverter = new BrushConverter();
     value = (value.ToString()
                   .Substring(0, 1) == "#") ? value : "#" + value;
     var result = (Brush) brushConverter.ConvertFrom("#FFFFFFFF");
     try
     {
         result = (Brush) brushConverter.ConvertFrom(value);
     }
     catch (Exception ex)
     {
     }
     return result;
 }
开发者ID:Icehunter,项目名称:ffxivapp-chatlog-importer,代码行数:19,代码来源:StringToBrushConverter.cs

示例11: OverButtonLeft_MouseEnter

 /// <summary>
 /// Highlights UnderButtons
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void OverButtonLeft_MouseEnter(object sender, MouseEventArgs e)
 {
     BrushConverter bc = new BrushConverter();
     Brush brush = (Brush)bc.ConvertFrom("#41B1E1");
     UnderButtonLeft.Foreground = brush;
     UnderButtonLeft.Background = brush;
 }
开发者ID:GodLesZ,项目名称:LegendaryClient,代码行数:12,代码来源:PatcherPage.xaml.cs

示例12: listRooms_SelectionChanged

        /// <remarks>
        /// Handles UI events for room row selection from list
        /// </remarks>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void listRooms_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            RoomBO selectedRoom = (RoomBO)listRooms.SelectedItem;

            // if on plan drawing there is matching room name, paint the room green
            BrushConverter bc = new BrushConverter();
            foreach (Button button in _planButtons)
            {
                if (button.Content.ToString() == selectedRoom.Name)
                {
                    
                    button.Background = (Brush)bc.ConvertFrom("#FF7DBA1D");
                }
                else button.Background = (Brush)bc.ConvertFrom("#FFFFFFFF");
            }
        }
开发者ID:mainrid,项目名称:Csharp_team_project_Conferece_Centrer_booking_sys,代码行数:21,代码来源:RoomsV.xaml.cs

示例13: WinColor

        public WinColor(MainWindow in_main)
        {
            InitializeComponent();

            Config = new IniFile("./boby_add_file.ini");

            tb_red.Text = Config.IniReadValue("boby", "red");
            tb_green.Text = Config.IniReadValue("boby", "green");
            tb_blue.Text = Config.IniReadValue("boby", "blue");

            if (tb_red.Text == "")
                tb_red.Text = "255";
            if (tb_green.Text == "")
                tb_green.Text = "0";
            if (tb_blue.Text == "")
                tb_blue.Text = "0";
            if (Convert.ToInt32(tb_red.Text.Trim()) > 255)
                tb_red.Text = "255";
            if (Convert.ToInt32(tb_green.Text.Trim()) > 255)
                tb_green.Text = "255";
            if (Convert.ToInt32(tb_blue.Text.Trim()) > 255)
                tb_blue.Text = "255";

            var bc = new BrushConverter();
            rt_color.Fill = (Brush)bc.ConvertFrom("#FF" + Convert.ToInt32(tb_red.Text.Trim()).ToString("X2") + Convert.ToInt32(tb_green.Text.Trim()).ToString("X2") + Convert.ToInt32(tb_blue.Text.Trim()).ToString("X2"));
            in_main_win = in_main;
        }
开发者ID:bobytools,项目名称:boby_add_files,代码行数:27,代码来源:WinColor.xaml.cs

示例14: CreateField

        //Создание пустого поля для игры
        private void CreateField(int[] matr)
        {
            int side = (int)(237 / Math.Sqrt(matr.Length));

            for (int i = 0; i < matr.Length; i++)
            {
                int leftPlace = (((int)(i % Math.Sqrt(matr.Length)))*side);
                int topPlace = ((i / (int)(Math.Sqrt(matr.Length)))*side);
                TextBox textBox = new TextBox();
                textBox.FontSize = 50;
                textBox.TextAlignment = TextAlignment.Center;

                var bc = new BrushConverter();
                textBox.Background = (Brush)bc.ConvertFrom("#FFD6D6D6");

                if (matr[i] != 0)
                    textBox.Text = Convert.ToString(matr[i]);

                textBox.Width = side - 1;
                textBox.Height = side - 1;

                Canvas.SetLeft(textBox, leftPlace);
                Canvas.SetTop(textBox, topPlace);

                Field.Children.Add(textBox);
            }
        }
开发者ID:Drumofrain,项目名称:netservices,代码行数:28,代码来源:MainWindow.xaml.cs

示例15: startClient

        private async void startClient()
        {
            try
            {
                BrushConverter bc = new BrushConverter();
                Brush brush = (Brush)bc.ConvertFrom(strColor);
                
                udpClient.Client.Bind(new IPEndPoint(IPAddress.Any, 0));
                udpClient.BeginReceive(dataReceived, udpClient);

                gridHeader.Background = brush;
                border.BorderBrush = brush;

                sendInformation(1, strName, string.Empty);
                while (true)
                {
                    sendInformation(3, strName, string.Empty);
                    await Task.Delay(100);
                }
            }
            catch (Exception) 
            {
                MessageBox.Show("Failed to connect to master server!");
                Environment.Exit(0);
            }
        }
开发者ID:vldr,项目名称:TLDRChat,代码行数:26,代码来源:MainWindow.xaml.cs


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