private async void WatermarkTextBox_TextChanged(object sender, TextChangedEventArgs e)
        {
            if (string.IsNullOrEmpty(previousID))
                previousID = (sender as TextBox).Text;

            try
            {
                if ((sender as TextBox).IsFocused == true)
                {
                    bool result = true;
                    var doc = (DataContext as DocumentEditViewModel).Document;
                    doc.DocumentID = (sender as TextBox).Text;

                    try { result = await (DataContext as DocumentEditViewModel).ParentViewModel.ParentViewModel.Database.DocumentExists(doc); }
                    catch { }
                    if (result && (DataContext as DocumentEditViewModel).EditMode == true)
                    {
                        (sender as TextBox).BorderBrush = Brushes.Red;
                        (sender as TextBox).BorderThickness = new System.Windows.Thickness(2);
                    }
                    else
                    {
                        var converter = new System.Windows.Media.BrushConverter();
                        var brush = (Brush)converter.ConvertFromString("#FFABADB3");
                        (sender as TextBox).BorderBrush = brush;
                        (sender as TextBox).BorderThickness = new System.Windows.Thickness(1);
                    }
                    result = await (DataContext as DocumentEditViewModel).ParentViewModel.ParentViewModel.Database.UpdateTemporaryUsedDocumentID(previousID, (sender as TextBox).Text, doc.DocumentType);
                    previousID = (sender as TextBox).Text;
                }
            }
            catch { }
        }
 /// <summary>
 /// Checks if the entered <see cref="ArticleID"/> already exists or not.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private async void TextBox_TextChanged(object sender, TextChangedEventArgs e)
 {
     try
     {
         if ((sender as TextBox).IsFocused == true)
         {
             bool result = true;
             try { result = await (DataContext as ArticleEditViewModel).ParentViewModel.ParentViewModel.Database.ArticleExists((sender as TextBox).Text); }
             catch { }
             if (result && (DataContext as ArticleEditViewModel).EditMode == false)
             {
                 (sender as TextBox).BorderBrush = Brushes.Red;
                 (sender as TextBox).BorderThickness = new System.Windows.Thickness(2);
             }
             else
             {
                 var converter = new System.Windows.Media.BrushConverter();
                 var brush = (Brush)converter.ConvertFromString("#FFABADB3");
                 (sender as TextBox).BorderBrush = brush;
                 (sender as TextBox).BorderThickness = new System.Windows.Thickness(1);
             }
             result = await (DataContext as ArticleEditViewModel).ParentViewModel.ParentViewModel.Database.UpdateTemporaryUsedArticleID(previousID, (sender as TextBox).Text);
             previousID = (sender as TextBox).Text;
         }
     }
     catch { }
 }
예제 #3
0
        public ParamétreColor(SVC.ServiceCliniqueClient proxyrecu, SVC.Membership memberrecu, ICallback callbackrecu)
        {
            try
            {
                InitializeComponent();
                proxy      = proxyrecu;
                memberuser = memberrecu;
                callback   = callbackrecu;
                SalleAttenteGrid.DataContext = proxy.GetAllParamétre();
                proxy      = proxyrecu;
                memberuser = memberrecu;
                callback   = callbackrecu;
                callbackrecu.InsertParamCallbackEvent += new ICallback.CallbackEventHandler16(callbackrecu_Refresh);

                var converter = new System.Windows.Media.BrushConverter();
                EclipsePatientPrésent.Background    = (Brush)converter.ConvertFromString((proxy.GetAllParamétre()).RdvPresent);
                EclipsePatientNomPrésent.Background = (Brush)converter.ConvertFromString((proxy.GetAllParamétre()).RdvNoPresent);
                EclipsePatientSalle.Background      = (Brush)converter.ConvertFromString((proxy.GetAllParamétre()).SalleAttenteTjr);
                EclipsePatientNoSalle.Background    = (Brush)converter.ConvertFromString((proxy.GetAllParamétre()).SalleAttenteQuit);

                EclipsePatientMedecinSalle.Background   = (Brush)converter.ConvertFromString((proxy.GetAllParamétre()).MedecinSalleTjr);
                EclipsePatientNoSalleMedecin.Background = (Brush)converter.ConvertFromString((proxy.GetAllParamétre()).MedecinSalleNON);
                VisiteRéglé.Background    = (Brush)converter.ConvertFromString((proxy.GetAllParamétre()).VisteRéglé);
                VisiteNonRéglé.Background = (Brush)converter.ConvertFromString((proxy.GetAllParamétre()).VisteNonRéglé);


                proxy.InnerDuplexChannel.Faulted += new EventHandler(InnerDuplexChannel_Faulted);

                proxy.InnerDuplexChannel.Closed += new EventHandler(InnerDuplexChannel_Closed);
            }
            catch (Exception ex)
            {
                MessageBoxResult resultc10 = Xceed.Wpf.Toolkit.MessageBox.Show(ex.Message, Medicus.Properties.Resources.SiteWeb, MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
예제 #4
0
        void changeBackBorderColor()
        {
            var converter = new System.Windows.Media.BrushConverter();
            var brush     = (Brush)converter.ConvertFromString("#FFE3E9EF");

            tbTitle.BorderBrush = brush;
        }
예제 #5
0
        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);
            }
        }
예제 #6
0
        private Brush ConvertHexIntoBrush(string hexCode)
        {
            var converter = new System.Windows.Media.BrushConverter();
            var brush     = (Brush)converter.ConvertFromString(hexCode);

            return(brush);
        }
        private Brush stringToBrush(string s)
        {
            var converter = new System.Windows.Media.BrushConverter();
            var brush     = (Brush)converter.ConvertFromString(s);

            return(brush);
        }
        /// <summary>
        /// Converts the name of a color to a <see cref="System.Windows.Media.Brush"/> object.
        /// </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 purpose = System.Convert.ToString(parameter);
            switch (purpose)
            {
                case AppConstants.CONVERT_ACCENT:
                    var aceentColorName = System.Convert.ToString(value);
                    var accent = ThemeManager.DefaultAccents.FirstOrDefault(a => string.CompareOrdinal(a.Name, aceentColorName) == 0);
                    if (null != accent)
                        return accent.Resources["AccentColorBrush"] as Brush;
                    break;
                case AppConstants.CONVERT_BASE:
                    var baseColorName = System.Convert.ToString(value);
                    var converter = new BrushConverter();
                    if (string.CompareOrdinal(baseColorName, AppConstants.LIGHT_BASE) == 0)
                    {
                        var brush = (Brush)converter.ConvertFromString("#FFFFFFFF");
                        return brush;
                    }
                    if (string.CompareOrdinal(baseColorName, AppConstants.DARK_BASE) == 0)
                    {
                        var brush = (Brush)converter.ConvertFromString("#FF000000");
                        return brush;
                    }

                    break;
            }
            return null;
        }
예제 #9
0
        public LoginWindow()
        {
            Logger.MonitoringLogger.Debug("Initializing LoginWindow");
            InitializeComponent();

            //Title Bar color change
            var converter = new System.Windows.Media.BrushConverter();
            var brush = (Brush)converter.ConvertFromString("#404040");
            this.TitleBarBackground = brush;

            this.DataContext = loginDataView;

            //Event handler
            this.Loaded += new RoutedEventHandler(LoadedEventHandler);
            this.Closing += new CancelEventHandler(ClosedEventHandler);
            loginDataView.ServersProfiles.CollectionChanged += new NotifyCollectionChangedEventHandler(CollectionChangedEventHandler);

            ResourceDictionary resourceDictionary = new ResourceDictionary()
            {
                Source = new Uri("/Framework.UI;component/Themes/ElysiumExtra/GeometryIcon.xaml", UriKind.RelativeOrAbsolute)
            };

            //BattlEyeLoginCredentials loginCredentials = new BattlEyeLoginCredentials();
            Logger.MonitoringLogger.Debug("Login Window Initialized");
        }
예제 #10
0
        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;
        }
예제 #11
0
        public object Convert(object value_to_test, Type type, object paramater, CultureInfo cultureInfo)
        {
            double tempvalue = (double)value_to_test;
            object tempBrushConverter = null;

            if (!ReverseOrder)
            {
                // Default Order
                if (tempvalue <= Bucket0)
                    tempBrushConverter = new BrushConverter().ConvertFromString("#7FFF0000");
                else if (tempvalue > Bucket0 && tempvalue <= Bucket1)
                    tempBrushConverter = new BrushConverter().ConvertFromString("#7FF9E719");
                else if (tempvalue > Bucket1)
                    tempBrushConverter = new BrushConverter().ConvertFromString("#7F00F500");
                else
                    tempBrushConverter = Brushes.White;
            }
            else
            {
                if (tempvalue <= Bucket0)
                    tempBrushConverter = new BrushConverter().ConvertFromString("#7F00F500");
                else if (tempvalue > Bucket0 && tempvalue <= Bucket1)
                    tempBrushConverter = new BrushConverter().ConvertFromString("#7FF9E719");
                else if (tempvalue > Bucket1)
                    tempBrushConverter = new BrushConverter().ConvertFromString("#7FFF0000");
                else
                    tempBrushConverter = Brushes.White;
            }

            return (tempBrushConverter as SolidColorBrush);
        }
예제 #12
0
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            Debug.Assert(value != null, "Value must not be null");

            Brush brush = null;
            if (value is Color)
            {
                brush = new SolidColorBrush((Color)value);
            }
            else if (value is string)
            {
                try
                {
                    BrushConverter converter = new BrushConverter();
                    brush = converter.ConvertFromString((string)value) as SolidColorBrush;
                }
                catch
                {
                    // We want to eat the exception
                }
            }

            if (brush == null)
            {
                Debug.Fail(string.Format("Unable to convert {0} to a Brush. Using a Colors.Black as a default.", value ?? "NULL"));
                brush = new SolidColorBrush(Colors.Black);
            }

            return brush;
        }
예제 #13
0
 static BrushProvider()
 {
     var brushConverter = new BrushConverter();
     _brushes.Insert(0, brushConverter.ConvertFromString("#88FFB7A5") as SolidColorBrush);
     _brushes.Insert(0, brushConverter.ConvertFromString("#88BFE0FF") as SolidColorBrush);
     _brushes.Insert(0, brushConverter.ConvertFromString("#88D2FFB5") as SolidColorBrush);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="DiagramInheritanceConnector"/> class.
 /// </summary>
 /// <param name="startConnector">The start connector.</param>
 /// <param name="endConnector">The end connector.</param>
 /// <remarks>
 /// Consturctor that specifies the two nodes that are connected.
 /// </remarks>
 internal DiagramInheritanceConnector(DiagramConnectorNode startConnector, DiagramConnectorNode endConnector)
   : base(startConnector, endConnector)
 {
   BrushConverter bc = new BrushConverter();
   Brush brush = bc.ConvertFromString("#716F64") as Brush;
   this.ResourcePen = new Pen(brush != null ? brush : Brushes.DimGray, 1);
 }
예제 #15
0
        private void ApagarCor(object sender, MouseEventArgs e)
        {
            var converter = new System.Windows.Media.BrushConverter();
            var brush     = (Brush)converter.ConvertFromString("#000000");

            CadLabel1.Foreground = brush;
        }
예제 #16
0
        protected override void DrawCore(DrawingContext drawingContext, DrawingAttributes drawingAttributes)
        {
            if (drawingContext == null)
            {
                throw new ArgumentNullException("drawingContext");
            }
            if (null == drawingAttributes)
            {
                throw new ArgumentNullException("drawingAttributes");
            }
            Pen pen = new Pen
            {
                StartLineCap = PenLineCap.Round,
                EndLineCap = PenLineCap.Round,
                Brush = new SolidColorBrush(drawingAttributes.Color),
                Thickness = drawingAttributes.Width
            };

            BrushConverter bc = new BrushConverter();
            Brush BackGround = (Brush)bc.ConvertFromString(drawingAttributes.GetPropertyData(DrawAttributesGuid.BackgroundColor).ToString());
            GeometryConverter gc = new GeometryConverter();
            Geometry geometry = (Geometry)gc.ConvertFromString(string.Format("M {0},{1} {2},{3} {4},{5} Z", StylusPoints[0].X, StylusPoints[1].Y, (Math.Abs(StylusPoints[1].X - StylusPoints[0].X))/2 + StylusPoints[0].X, StylusPoints[0].Y, StylusPoints[1].X, StylusPoints[1].Y));
            GeometryDrawing gd = new GeometryDrawing(BackGround, pen, geometry);
            drawingContext.DrawDrawing(gd);
        }
예제 #17
0
        void create2_random(Canvas canvas, Brush color2)
        {
            Random          r         = new Random();
            var             converter = new System.Windows.Media.BrushConverter();
            Polygon         polygon   = new Polygon();
            Polygon         polygon2  = new Polygon();
            Polygon         polygon3  = new Polygon();
            PointCollection points1   = new PointCollection()
            {
                A, D, D1, A1
            };
            PointCollection points2 = new PointCollection()
            {
                A, B, C, D
            };
            PointCollection points3 = new PointCollection()
            {
                D, C, C1, D1
            };

            polygon.Points  = points1;
            polygon.Fill    = (Brush)converter.ConvertFromString($"#{r.Next(0, 9)}{r.Next(0, 9)}{r.Next(0, 9)}{r.Next(0, 9)}{r.Next(0, 9)}{r.Next(0, 9)}");
            polygon2.Points = points2;
            polygon2.Fill   = (Brush)converter.ConvertFromString($"#{r.Next(0, 9)}{r.Next(0, 9)}{r.Next(0, 9)}{r.Next(0, 9)}{r.Next(0, 9)}{r.Next(0, 9)}");
            polygon3.Points = points3;
            polygon3.Fill   = (Brush)converter.ConvertFromString($"#{r.Next(0, 9)}{r.Next(0, 9)}{r.Next(0, 9)}{r.Next(0, 9)}{r.Next(0, 9)}{r.Next(0, 9)}");
            canvas.Children.Add(polygon);
            canvas.Children.Add(polygon2);
            canvas.Children.Add(polygon3);
        }
예제 #18
0
        //Создание пустого поля для игры
        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);
            }
        }
예제 #19
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            //Progressbar Color Converter based on Progress Value

            double progress   = (double)value;
            var    param      = (string)parameter;
            var    converter  = new System.Windows.Media.BrushConverter();
            Brush  foreground = Brushes.DeepPink;

            if (param != null)
            {
                foreground = (Brush)converter.ConvertFromString(param);
            }
            else
            {
                foreground = (Brush)converter.ConvertFromString("#2196f3");
            }

            if (progress >= 100)
            {
                foreground = (Brush)converter.ConvertFromString("#c41c00");
            }
            else if (progress >= 80)
            {
                foreground = (Brush)converter.ConvertFromString("#ffeb3b");
            }

            return(foreground);
        }
예제 #20
0
 private void ChangeColor(object sender, SelectionChangedEventArgs args)
 {
     var li2 = ((sender as ListBox).SelectedItem as ListBoxItem);
     var myBrushConverter = new BrushConverter();
     border1.BorderBrush = (Brush) myBrushConverter.ConvertFromString((string) li2.Content);
     bColor.Text = "Border.Borderbrush =" + li2.Content;
 }
예제 #21
0
        private void searchUser(string user)
        {
            Console.WriteLine(user);

            var request = BackendConnect.server + "users/search/" + user.ToString();

            Console.WriteLine(request);
            var response = Backend.Get(request);

            if (response != null)
            {
                users.Items.Clear();

                for (int i = 0; i < response.Count; i++)
                {
                    var converter = new System.Windows.Media.BrushConverter();

                    Button Add_User = new Button
                    {
                        Content     = response[i].Username,
                        Background  = (Brush)converter.ConvertFromString("transparent"),
                        BorderBrush = (Brush)converter.ConvertFromString("transparent"),
                        Foreground  = (Brush)converter.ConvertFromString("black")
                    };
                    Add_User.Click += new RoutedEventHandler(Add_User_action);
                    Add_User.Tag    = response[i].Id;

                    users.Items.Add(Add_User);
                }
            }
        }
예제 #22
0
        public SelfmadeSVI(ProtoDefinition protoDefinition = null)
        {
            InitializeComponent();

            if (protoDefinition != null)
            {
                this.ProtoDefinition = protoDefinition;
            }

            //apply width and height
            this.MainCanvas.Width = this.ProtoDefinition.Width;
            this.MainCanvas.Height = this.ProtoDefinition.Height;

            // applying the color
            BrushConverter cConverter = new BrushConverter();
            this.OwnColoredRectangle.Fill = cConverter.ConvertFromString(this.ProtoDefinition.Color) as SolidColorBrush;

            //TODO: apply the given image

            // initial position
            MatrixTransform matrixTransform = this.RenderTransform as MatrixTransform;
            Matrix rectsMatrix = matrixTransform.Matrix;
            rectsMatrix.Translate(this.ProtoDefinition.X, this.ProtoDefinition.Y);
            this.RenderTransform = new MatrixTransform(rectsMatrix);
        }
예제 #23
0
 void clearFieldRefresh()
 {
     try
     {
         var converter = new System.Windows.Media.BrushConverter();
         changeBackBorderColor();
         tbFirstNameT.Clear();
         tbLastNameT.Clear();
         dateHireDate.SelectedDate = null;
         tbContact.Clear();
         tbEmail.Clear();
         tbNumber.Clear();
         tbStreet.Clear();
         tbCity.Clear();
         comboProvince.SelectedIndex = -1;
         btDelete.IsEnabled          = false;
         btUpdate.IsEnabled          = false;
         tbCodePostal.Clear();
         listTeacher            = (from t in Globals.ctx.Teachers orderby t.Id select t).ToList <Teacher>();
         lvTeachers.ItemsSource = listTeacher;
         Utils.AutoResizeColumns(lvTeachers);
     }
     catch (SystemException ex)
     {
         MessageBox.Show("Database Error! " + ex.Message);
         return;
     }
 }
예제 #24
0
 /// <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;
 }
        public void ImportPlaylist(object sender, RoutedEventArgs e)
        {
            loadingLabel.Visibility = Visibility.Visible;
            try
            {
                List <string> youtubeURLS = DownloadManager.RetrieveYouTubePlaylist(playlistURLTextBox.Text);

                if (linksTextBox.Text == "Enter YouTube Links Here (Separate Lines)")
                {
                    var converter = new System.Windows.Media.BrushConverter();
                    linksTextBox.Text       = "";
                    linksTextBox.Foreground = (Brush)converter.ConvertFromString("#FFFFFFFF");
                }
                else
                {
                    linksTextBox.AppendText("\n");
                }

                foreach (string youtubeURL in youtubeURLS)
                {
                    linksTextBox.AppendText(youtubeURL + "\n");
                }
            }
            catch
            {
                RaiseAnError("Please Enter a Valid YouTube Playlist URL");
            }

            playlistURLTextBox.Text = "";
            loadingLabel.Visibility = Visibility.Hidden;
        }
 private void cpColor_SelectedColorChanged(object sender, RoutedPropertyChangedEventArgs<Color> e)
 {
     Color selected = cpColor.SelectedColor;
     var bc = new BrushConverter();
     TheBackground = bc.ConvertFromString(selected.ToString()) as Brush;
     colorDisplay.Background = TheBackground;
 }
예제 #27
0
		public static Brush getBrush(Name name, int num = 4)
		{
			var converter = new System.Windows.Media.BrushConverter();

			switch(name)
			{
				case Name.Red:			return (Brush)converter.ConvertFromString(RED[num]);
				case Name.Pink:			return (Brush)converter.ConvertFromString(PINK[num]);
				case Name.Purple:		return (Brush)converter.ConvertFromString(PURPLE[num]);
				case Name.DeepPurple:	return (Brush)converter.ConvertFromString(DEEP_PURPLE[num]);
				case Name.Indigo:		return (Brush)converter.ConvertFromString(INDIGO[num]);
				case Name.Blue:			return (Brush)converter.ConvertFromString(BLUE[num]);
				case Name.LightBlue:	return (Brush)converter.ConvertFromString(LIGHT_BLUE[num]);
				case Name.Cyan:			return (Brush)converter.ConvertFromString(CYAN[num]);
				case Name.Teal:			return (Brush)converter.ConvertFromString(TEAL[num]);
				case Name.Green:		return (Brush)converter.ConvertFromString(GREEN[num]);
				case Name.LightGreen:	return (Brush)converter.ConvertFromString(LIGHT_GREEN[num]);
				case Name.Lime:			return (Brush)converter.ConvertFromString(LIME[num]);
				case Name.Yellow:		return (Brush)converter.ConvertFromString(YELLOW[num]);
				case Name.Amber:		return (Brush)converter.ConvertFromString(AMBER[num]);
				case Name.Orange:		return (Brush)converter.ConvertFromString(ORANGE[num]);
				case Name.DeepOrange:	return (Brush)converter.ConvertFromString(DEEP_ORANGE[num]);
				case Name.Brown:		return (Brush)converter.ConvertFromString(BROWN[num]);
				case Name.Grey:			return (Brush)converter.ConvertFromString(GREY[num]);
				case Name.BlueGrey:		return (Brush)converter.ConvertFromString(BLUE_GREY[num]);
				case Name.Black:		return (Brush)converter.ConvertFromString("#FF000000");
			}

			return (Brush)converter.ConvertFromString("#FFFFFFFF");
		}
예제 #28
0
        private void Button_MouseLeave(object sender, MouseEventArgs e)
        {
            var converter = new System.Windows.Media.BrushConverter();
            var brush     = (Brush)converter.ConvertFromString("#FFE8E8E8");

            (sender as Button).Foreground = brush;
        }
예제 #29
0
        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);
            }
        }
예제 #30
0
        private void SearchTextBox_TextChanged(object sender, RoutedEventArgs e)
        {
            TextBox TB = (TextBox)sender;

            foreach (DataGridColumn DGC in this.Columns)
            {
                for (int ind = 0; ind < this.Items.Count; ind++)
                {
                    FrameworkElement FE = DGC.GetCellContent(this.Items[ind]);
                    if (FE != null && FE.GetType().Name == "TextBlock")
                    {
                        TextBlock TX = (TextBlock)FE;
                        if (TX != null)
                        {
                            if (!string.IsNullOrEmpty(TB.Text) && TX.Text.ToUpper().Contains(TB.Text.ToUpper()))
                            {
                                System.Windows.Media.BrushConverter BC = new System.Windows.Media.BrushConverter();
                                TX.Background = this.SearchedValueBackGroundColor;
                                //TX.Background =  System.Windows.Media.Brushes.Orange;
                                TX.Foreground = System.Windows.Media.Brushes.YellowGreen;
                            }
                            else
                            {
                                TX.Background = System.Windows.Media.Brushes.White;
                                TX.Foreground = System.Windows.Media.Brushes.Black;
                            }
                        }
                    }
                }
            }
        }
예제 #31
0
        private static Brush ConvertToBrush(string Color)
        {
            var converter = new System.Windows.Media.BrushConverter();
            var brush     = (Brush)converter.ConvertFromString(Color);

            return(brush);
        }
예제 #32
0
        public static Brush Hex2Color(AppColors color)
        {
            string hexValue = "#FFFFFF";

            switch (color)
            {
            case AppColors.Teal:
                hexValue = "#FF30B89F";
                break;

            case AppColors.Magenta:
                hexValue = "#FFB83061";
                break;

            case AppColors.Peach:
                hexValue = "#FFDC7C1B";
                break;

            default:
                break;
            }
            var converter = new System.Windows.Media.BrushConverter();
            var brush     = (Brush)converter.ConvertFromString(hexValue);

            return(brush);
        }
예제 #33
0
        protected override void DrawCore(DrawingContext drawingContext, DrawingAttributes drawingAttributes)
        {
            if (drawingContext == null)
            {
                throw new ArgumentNullException("drawingContext");
            }
            if (null == drawingAttributes)
            {
                throw new ArgumentNullException("drawingAttributes");
            }
            Pen pen = new Pen
            {
                StartLineCap = PenLineCap.Round,
                EndLineCap = PenLineCap.Round,
                Brush = new SolidColorBrush(drawingAttributes.Color),
                Thickness = drawingAttributes.Width
            };

            BrushConverter bc = new BrushConverter();
            Brush BackGround = (Brush)bc.ConvertFromString(drawingAttributes.GetPropertyData(DrawAttributesGuid.BackgroundColor).ToString());

            drawingContext.DrawRectangle(
                BackGround,
                pen,
                new Rect(new Point(StylusPoints[0].X, StylusPoints[0].Y),
                    new Point(StylusPoints[1].X, StylusPoints[1].Y)));
        }
예제 #34
0
        public StatusButton CreateNewButton(int PrintersID, int Submodel, string Name, int Row)
        {
            var          _converter = new System.Windows.Media.BrushConverter();
            var          _brushFore = (Brush)_converter.ConvertFromString("#FFFFFF");
            var          _brushBack = (Brush)_converter.ConvertFromString("#b9192c");
            StatusButton _btn       = new StatusButton()
            {
                Name       = "SUB" + Submodel.ToString(),
                Content    = Submodel.ToString() + " - " + Name,
                Height     = 80,
                Width      = 450,
                FontFamily = new FontFamily("Oxygen-Bold"),
                FontSize   = 30,
                Foreground = _brushFore,
                Background = _brushBack,
                Visibility = Visibility.Visible,
            };

            _btn.Click += new RoutedEventHandler(_btn_Click);
            Grid.SetColumn(_btn, 0);
            Grid.SetRow(_btn, Row);

            grdSubmodel.Children.Add(_btn);
            _btn.ID = PrintersID;
            return(_btn);
        }
예제 #35
0
 private void click(object sender, RoutedEventArgs e)
 {
     Button b = sender as Button;
     switch (b.Name)
     {
         case "activator":
             if (!CManager.Properties.Settings.Default.activator)
             {
                 this.activator.IsEnabled = false;
                 this.activator.BorderThickness = new Thickness(1);
                 BrushConverter c = new BrushConverter();
                 this.activator.BorderBrush = (Brush)c.ConvertFromString("#FF828282");
                 this.activator.ToolTip = "This options is avaible only in extended version of program";
                 ToolTipService.SetInitialShowDelay(this.activator, 1500);
                 ToolTipService.SetShowDuration(this.activator, 5000);
                 ToolTipService.SetShowOnDisabled(this.activator, true);
             }
             else
             {
                 sel(this, new program() { page = 2 });
             }
             break;
         case "manager":
             sel(this, new program() { page = 3 });
             break;
     }
 }
예제 #36
0
        public Control()
        {
            InitializeComponent();

            selectionContainer = new Microsoft.VisualStudio.Shell.SelectionContainer();

            nextGraph = null;
            hasNextGraph = false;
            VSGraphVizPackage.expressionGraph.graphUpdated += graphUpdatedHandler;

            bc = new BrushConverter();

            showCompleted = true;
            animationCounter = 0;
            animationLock = new object();

            cur_alg = 1;

            grap_layout_algo = new List<GraphLayout>();
            grap_layout_algo.Add(new FRLayout());
            grap_layout_algo.Add(new RadialLayout());
            grap_layout_algo.Add(new RightHeavyHVLayout());

            graph_layout_algo_name = new List<string>();
            graph_layout_algo_name.Add("Fruchterman-Reingold");
            graph_layout_algo_name.Add("Radial");
            graph_layout_algo_name.Add("Right-Heavy HV");

            gen_menu();
        }
예제 #37
0
        void AyarDegistir()
        {
            Global.AraSuresi   = new TimeSpan(0, 0, 30);
            Global.BilgiAlani1 = "Bilgi Alanı 1";
            Global.BilgiAlani2 = "Bilgi Alanı 2";
            Global.BilgiAlani3 = "Bilgi Alanı 3";
            Global.BilgiAlani4 = "Bilgi Alanı 4";
            Global.ErkekBayan  = "EKREK/BAYAN";
            Global.MaviAd      = "Kişi 2";
            Global.KirmiziAd   = "Kişi 1";
            Global.KafaPuani   = 3;
            Global.VucutPuani  = 1;
            Global.KalanSure   = new TimeSpan();
            Global.Kg          = "";
            var converter = new System.Windows.Media.BrushConverter();
            var Kirmizi   = (Brush)converter.ConvertFromString("#FFB70A0A");
            var Mavi      = (Brush)converter.ConvertFromString("#FF0B189C");

            Global.KirmiziRenk      = Kirmizi;
            Global.MaviRenk         = Mavi;
            Global.MaviUlke         = "TR";
            Global.MaviUlkeBayrak   = "";
            Global.MaxPuan          = false;
            Global.MaxPuanSayi      = 12;
            Global.OnikiFarkPuani   = false;
            Global.RaundSayisi      = 2;
            Global.RaundSuresi      = new TimeSpan(0, 1, 30);
            Global.SureArtan        = false;
            Global.TimeOutSureArtan = false;
            Global.Yas = "";
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="DiagramAssociationConnector"/> class.
 /// </summary>
 /// <param name="startConnector">The start connector.</param>
 /// <param name="endConnector">The end connector.</param>
 /// <remarks>
 /// Consturctor that specifies the two nodes that are connected.
 /// </remarks>
 internal DiagramAssociationConnector(DiagramConnectorNode startConnector, DiagramConnectorNode endConnector)
   : base(startConnector, endConnector)
 {
   BrushConverter bc = new BrushConverter();
   Brush brush = bc.ConvertFromString("#B0764F") as Brush;
   this.ResourcePen = new Pen(brush != null ? brush : Brushes.Sienna, 1);
 }
예제 #39
0
        /// <summary>
        /// Fonction appelé afin de savoir si
        /// le Mode nuit a déjà été appelé par l'utilisateur depuis
        /// "DM_Btn" et changer les couleurs de certains éléments de la
        /// vue selon l'appel Dark Mode
        /// </summary>
        private void Dark_Mode()
        {
            var converter = new System.Windows.Media.BrushConverter();     //On créé une variable permettant de convertir un code couleur en teinte de couleur
            var brush     = (Brush)converter.ConvertFromString("#121211"); // On créé une teinte de coueleur avec les paramêtres hexa de la couleur
            var brush2    = (Brush)converter.ConvertFromString("white");   // On créé une teinte de coueleur avec le nom système de la couleur
            var brush3    = (Brush)converter.ConvertFromString("#ECE1DE");

            if ((Application.Current as App).ColorTestGlobal % 2 == 0) //Si le DarkMode est enclenché (car "ColorTestGlobal" dans App est pair lorsque le DarkMode est activé)
            {
                //Fixe chaque teinte de ces éléments de la vue sur le code couleur représentant
                GridTotal.Background = brush;
                Textpage.Foreground  = brush2;
                TirePage2.Foreground = brush2;
                TirePage3.Foreground = brush2;
                TirePage4.Foreground = brush2;
                DM_Btn.Background    = brush;
                DM_Btn.Foreground    = brush2;
                DM_Btn.BorderBrush   = brush2;
            }
            else //Si le DarkMode n'est pas enclenché (car "ColorTestGlobal" dans App est impair lorsque le DarkMode est désactivé)
            {
                GridTotal.Background = brush3;
                Textpage.Foreground  = brush;
                TirePage2.Foreground = brush;
                TirePage3.Foreground = brush;
                TirePage4.Foreground = brush;
                DM_Btn.Background    = brush2;
                DM_Btn.Foreground    = brush;
                DM_Btn.BorderBrush   = brush;
            }
        }
예제 #40
0
        protected override void OnDragOver(DragEventArgs e)
        {
            base.OnDragEnter(e);

            HitTestResult result = VisualTreeHelper.HitTest(this, e.GetPosition(this));

            if ((result.VisualHit as UIElement).IsDescendantOf(this))
            {
                UIElement            element    = (result.VisualHit as UIElement);
                DragDropTreeViewItem targetNode = GetNearestContainer(e.Source as UIElement);
                if (e.GetPosition(targetNode).Y < targetNode.ActualHeight * 0.2f)
                {
                    // meter em cima
                    //Console.WriteLine("cima");
                    DragDropHelper.insertionPlace = DragDropHelper.InsertionPlace.Top;
                    DragDropHelper.CreateInsertionAdorner(targetNode, true);
                }
                else if (e.GetPosition(targetNode).Y > targetNode.ActualHeight * 0.8f)
                {
                    //Console.WriteLine("baixo");
                    DragDropHelper.insertionPlace = DragDropHelper.InsertionPlace.Bottom;
                    DragDropHelper.CreateInsertionAdorner(targetNode, false);
                }
                else
                {
                    //Console.WriteLine("centro");
                    DragDropHelper.RemoveInsertionAdorner();
                    DragDropHelper.insertionPlace = DragDropHelper.InsertionPlace.Center;
                    var converter = new System.Windows.Media.BrushConverter();
                    Background = (Brush)converter.ConvertFromString("#555");
                }
            }
        }
 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);
 }
예제 #42
0
            /// <summary>
            /// Laver en farve fra hex til en brushes
            /// </summary>
            /// <param name="hexColor">#FFFFFFFF</param>
            /// <returns>Brushes</returns>
            public Brush ColorBrushHex(string hexColor)
            {
                var converter = new System.Windows.Media.BrushConverter();
                var brush     = (Brush)converter.ConvertFromString(hexColor);

                return(brush);
            }
예제 #43
0
        private void updatebutton_Click(object sender, RoutedEventArgs e)
        {
            //Same as editbutton_Click function
            var converter = new System.Windows.Media.BrushConverter();
            var brush     = (Brush)converter.ConvertFromString("#e1e4ed");

            UIDlatBox.Background  = brush;
            UIDlatBox.IsReadOnly  = true;
            UIDlongBox.Background = brush;
            UIDlongBox.IsReadOnly = true;


            double f;
            double g;

            if ((double.TryParse(UIDlatBox.Text, out f)) && (double.TryParse(UIDlongBox.Text, out g)))
            {
                if (f > 90 || f < -90 || g > 90 || g < -90)
                {
                    MessageBox.Show("Latitudes and Longitudes must be less than or equal to 90 or greater than or equal to -90");
                    UIDlatBox.Text  = "";
                    UIDlongBox.Text = "";
                }
                else
                {
                    UpdateCoordinates();
                }
            }
            else
            {
                MessageBox.Show("Please Enter Valid Coordinates");
                UIDlatBox.Text  = "";
                UIDlongBox.Text = "";
            }
        }
예제 #44
0
        /// <summary>
        /// Initialise la grille level1.
        /// </summary>
        protected void initializeCellsGrid()
        {
            cellsGrid = new BrowserGrid();
            cellsGrid.hideContextMenu();
            var          gridFactory = new FrameworkElementFactory(typeof(Grid));
            DataTemplate template    = new DataTemplate();

            template.VisualTree         = gridFactory;
            cellsGrid.RowHeaderTemplate = template;

            var brushConverter = new System.Windows.Media.BrushConverter();

            System.Windows.Media.Brush bruch = (System.Windows.Media.Brush)brushConverter.ConvertFrom(System.Windows.Media.Brushes.LightBlue.Color.ToString());
            cellsGrid.AlternatingRowBackground         = bruch;
            cellsGrid.AlternatingRowBackground.Opacity = 0.3;

            for (int i = 0; i < getColumnCount(); i++)
            {
                DataGridColumn column = getColumnAt(i);
                column.Header = getColumnHeaderAt(i);
                column.Width  = getColumnWidthAt(i);
                if (column is DataGridBoundColumn)
                {
                    ((DataGridBoundColumn)column).Binding = getBindingAt(i);
                }
                cellsGrid.Columns.Add(column);
            }

            this.GridScrollPanel1.Content = cellsGrid;

            cellsGrid.SelectionChanged += OnSelectionChange;
        }
        public static Brush mColor(string code)
        {
            var converter = new System.Windows.Media.BrushConverter();
            var brush     = (Brush)converter.ConvertFromString(code);

            return(brush);
        }
예제 #46
0
        public Change(string name, Threat threat)

        {
            Name          = name;
            ChangedThreat = threat;
            var converter = new System.Windows.Media.BrushConverter();

            switch (name)
            {
            case "Удалено":
                Color     = (Brush)converter.ConvertFromString("#C72C41");
                FillColor = (Brush)converter.ConvertFromString("#FF7673");
                break;

            case "Изменено":
                Color     = (Brush)converter.ConvertFromString("#FFD500");
                FillColor = (Brush)converter.ConvertFromString("#FFF3A7");
                break;

            case "Добавлено":
                Color     = (Brush)converter.ConvertFromString("#00BB3F");
                FillColor = (Brush)converter.ConvertFromString("#97E293");
                break;
            }
        }
예제 #47
0
        private void ResultsReceived(Object data)
        {
            var writer = new StringWriter();
            var dumper = new ObjectTextDumper(writer);

            dumper.Dump(data);

            Paragraph paragraph = new Paragraph();
            Bold      recv      = new Bold();
            var       converter = new System.Windows.Media.BrushConverter();

            recv.Foreground = (Brush)converter.ConvertFromString("#FF8ACCCF");
            recv.FontSize   = 14.0;
            recv.Inlines.Add("Event Received :" + Environment.NewLine);
            paragraph.Inlines.Add(recv);

            Span text = new Span();

            text.Foreground = (Brush)converter.ConvertFromString("#FFDFDFBF");
            text.Inlines.Add(writer.GetStringBuilder().ToString());
            paragraph.Inlines.Add(text);

            View.console.Document.Blocks.Add(paragraph);
            View.scroller.ScrollToBottom();
        }
예제 #48
0
        private static void OnColorChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            BrushPicker brush = d as BrushPicker;

            if ((brush.Brush as SolidColorBrush).Color != brush.Color)
            {
                //DiagramVM diagram = (brush.Tag as DiagramBuilderVM).SelectedDiagram as DiagramVM;
                //GroupTransactions group = new GroupTransactions();
                //group.ContinuousUndoRedo = ContinuousUndoRedo.Start;
                //diagram.HistoryManager.BeginComposite(diagram.HistoryManager, group);
                brush.Brush = new SolidColorBrush(brush.Color);

                var converter = new System.Windows.Media.BrushConverter();

                Brush brushS = (Brush)converter.ConvertFromString(e.NewValue.ToString());
                if ((brush.DataContext as DiagramButtonViewModel).Label == "Label")
                {
                    ((brush.Tag as DiagramBuilderVM).SelectedDiagram.SelectedItems as SelectorVM).LabelForeground = (brushS as SolidColorBrush);
                }
                else if ((brush.DataContext as DiagramButtonViewModel).Label == "Fill")
                {
                    ((brush.Tag as DiagramBuilderVM).SelectedDiagram.SelectedItems as SelectorVM).Fill = (brushS as SolidColorBrush);
                }
                else if ((brush.DataContext as DiagramButtonViewModel).Label == "Stroke")
                {
                    ((brush.Tag as DiagramBuilderVM).SelectedDiagram.SelectedItems as SelectorVM).Stroke = (brushS as SolidColorBrush);
                }

                brush.PickerTemp.IsDropDownOpen = false;
                //GroupTransactions group1 = new GroupTransactions();
                //group1.ContinuousUndoRedo = ContinuousUndoRedo.End;
                //diagram.HistoryManager.EndComposite(diagram.HistoryManager, group1);
            }
        }
예제 #49
0
        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;
            }));
        }
예제 #50
0
        /// <summary>
        /// Edition de l'event "Click" du
        /// bouton "DM_Btn". Il met à jour la
        /// variable permettant de reconnaître l'activation
        /// du DarkMode et actualise en même les couleurs au même
        /// titre que la fonction DarkMode() plus haut
        /// </summary>
        private void Dark_ModeBtn(object sender, RoutedEventArgs e)
        {
            var converter = new System.Windows.Media.BrushConverter();
            var brush     = (Brush)converter.ConvertFromString("#121211");
            var brush2    = (Brush)converter.ConvertFromString("white");
            var brush3    = (Brush)converter.ConvertFromString("#ECE1DE");

            if ((Application.Current as App).ColorTestGlobal % 2 == 1)  //Si le DarkMode n'est pas enclenché (car "ColorTestGlobal" dans App est impair lorsque le DarkMode est désactivé) alors on l'enclenche
            //c'est l'inverse des opérations de la "fonction Dark_Mode()"
            {
                Fenetre.Background   = brush;
                GridTotal.Background = brush;
                Textpage.Foreground  = brush2;
                TirePage2.Foreground = brush2;
                TirePage3.Foreground = brush2;
                TirePage4.Foreground = brush2;
                DM_Btn.Background    = brush;
                DM_Btn.Foreground    = brush2;
                DM_Btn.BorderBrush   = brush2;
                (Application.Current as App).ColorTestGlobal++; //Incrémente de 1 la valeur de 'ColorTestGlobal' dans App afin de donner l'information aux autres fenêtres de l'activation
            }
            else
            {
                Fenetre.Background   = brush3;
                GridTotal.Background = brush3;
                Textpage.Foreground  = brush;
                TirePage2.Foreground = brush;
                TirePage3.Foreground = brush;
                TirePage4.Foreground = brush;
                DM_Btn.Background    = brush3;
                DM_Btn.Foreground    = brush;
                DM_Btn.BorderBrush   = brush;
                (Application.Current as App).ColorTestGlobal++; //On incrémente de 1 aussi
            }
        }
예제 #51
0
        /// <summary>
        /// initialisation grille report level2
        /// </summary>
        private void initializeReportItemsGrid()
        {
            reportOriginalCellsGrid = new BrowserGrid();
            var          gridFactory = new FrameworkElementFactory(typeof(Grid));
            DataTemplate template    = new DataTemplate();

            template.VisualTree = gridFactory;
            reportOriginalCellsGrid.RowHeaderTemplate = template;

            var brushConverter = new System.Windows.Media.BrushConverter();

            System.Windows.Media.Brush bruch = (System.Windows.Media.Brush)brushConverter.ConvertFrom(System.Windows.Media.Brushes.LightBlue.Color.ToString());
            reportOriginalCellsGrid.AlternatingRowBackground         = bruch;
            reportOriginalCellsGrid.AlternatingRowBackground.Opacity = 0.3;

            for (int i = 0; i < 11; i++)
            {
                DataGridColumn column = getColumnAt(i);
                column.Header = getColumnHeader3At(i);
                column.Width  = getColumnWidthAt(i);
                if (column is DataGridBoundColumn)
                {
                    ((DataGridBoundColumn)column).Binding = getBinding3At(i);
                }
                reportOriginalCellsGrid.Columns.Add(column);
            }

            this.GridScrollPanel2.Content = reportOriginalCellsGrid;
        }
예제 #52
0
        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;
        }
예제 #53
0
        private void ButtonColorSets_Click(object sender, RoutedEventArgs e)
        {
            colorDialog = new System.Windows.Forms.ColorDialog();
            colorDialog.AllowFullOpen  = true;
            colorDialog.AnyColor       = true;
            colorDialog.SolidColorOnly = false;
            // colorDialog.ShowDialog();

            if (colorDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                //lineColor = colorDialog.Color.GetHashCode();
                //string color = lineColor.ToString();
                var conv = new System.Windows.Media.BrushConverter();
                var a    = colorDialog.Color.A;
                var r    = colorDialog.Color.R;
                var g    = colorDialog.Color.G;
                var b    = colorDialog.Color.B;

                Color color = new Color();
                color = Color.FromRgb(r, g, b);
                Brush brush = new SolidColorBrush(color);

                lineColor = brush;
                Console.WriteLine(color.R);
                rectInfo.Fill = brush;
            }
        }
예제 #54
0
        private static Inline BuildFont(ElementToken token, Hint hint)
        {
            var span = new Span();

            string size;
            if (token.Attributes.TryGetValue("size", out size))
            {
                var fc = new FontSizeConverter();
                var sz = (double)fc.ConvertFromString(size);
                span.FontSize = sz;
            }

            string face;
            if (token.Attributes.TryGetValue("face", out face))
            {
                span.FontFamily = new FontFamily(face);
            }

            string color;
            if (token.Attributes.TryGetValue("color", out color))
            {
                var bc = new BrushConverter();
                var br = (Brush)bc.ConvertFromString(color);
                span.Foreground = br;
            }
            return span.Fill(token, hint);
        }
예제 #55
0
        private static Brush GetBrushColorFromHex(String hexCode)
        {
            var converter = new System.Windows.Media.BrushConverter();
            var brush     = (Brush)converter.ConvertFromString(hexCode);

            return(brush);
        }
예제 #56
0
        // TODO: Find out to properly handle themes.
        private void SetHighlightColor()
        {
            var bconv   = new System.Windows.Media.BrushConverter();
            var selbrsh = (System.Windows.Media.Brush)bconv.ConvertFromString("#1D98EB");

            //yucky
            switch (App.AssemblyStorage.AssemblySettings.ApplicationAccent)
            {
            case Settings.Accents.Blue:
                selbrsh = (System.Windows.Media.Brush)bconv.ConvertFromString("#1D98EB");
                break;

            case Settings.Accents.Green:
                selbrsh = (System.Windows.Media.Brush)bconv.ConvertFromString("#98e062");
                break;

            case Settings.Accents.Orange:
                selbrsh = (System.Windows.Media.Brush)bconv.ConvertFromString("#D66F2B");
                break;

            case Settings.Accents.Purple:
                selbrsh = (System.Windows.Media.Brush)bconv.ConvertFromString("#9C40B4");
                break;
            }
            txtScript.TextArea.SelectionBorder = new System.Windows.Media.Pen(selbrsh, 1);
            selbrsh.Opacity = 0.3;
            txtScript.TextArea.SelectionBrush = selbrsh;
        }
        object IValueConverter.ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            try
            {
                // get brush from runtime property info
                if (value is PropertyInfo)
                {
                    // create converter
                    BrushConverter converter = new BrushConverter();

                    // convert neme to brush
                    Brush selectedBrush = (Brush)converter.ConvertFromString(((PropertyInfo)value).Name.ToString());

                    // get brush
                    return selectedBrush;
                }
                else
                {
                    // return black
                    return Brushes.Black;
                }
            }
            catch (Exception e)
            {
                // display
                Console.WriteLine("Exception caught converting property info: {0}", e.Message);

                // return black
                return Brushes.Black;
            }
        }
예제 #58
0
        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;
        }
 private void DisplayUi(CustomerViewModel o)
 {
     lblCustomerName.Content = o.txtCustomerName;
     lblSalesAmount.Content = o.txtAmount;
     BrushConverter brushconv = new BrushConverter();
     lblHabits.Background = brushconv.ConvertFromString(o.lblAmountColor) as SolidColorBrush;
     chkMarried.IsChecked = o.IsMarried;
 }
예제 #60
-3
        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);
        }