private void Form_TextChanged(object sender, TextChangedEventArgs e) { var converter = new ColorTypeConverter(); LoginPassword.TextColor = (Color)converter.ConvertFromInvariantString("Color.Black"); LoginUsername.TextColor = (Color)converter.ConvertFromInvariantString("Color.Black"); }
void RefreshDayData(List <NFPData_1_1_0> dt) { var converter = new ColorTypeConverter(); cycle_day.Text = dt[0].DayID.ToString(); int_sel.SelectedIndex = dt[0].Intercourse; freq_sel.SelectedIndex = dt[0].Frequency; cycle_id.Text = dt[0].CycleID.ToString(); //var ci = CrossMultilingual.Current.CurrentCultureInfo; //var dateTime = DateTime.Parse(dt[0].Date); date_field.Text = dt[0].Date; men_sel.SelectedIndex = dt[0].Menstrual; ind1_sel.SelectedIndex = dt[0].Indicator_1; ind2_sel.SelectedIndex = dt[0].Indicator_2; ind3_sel.SelectedIndex = dt[0].Indicator_3; pk_sel.SelectedIndex = dt[0].Peak; dcnt_sel.SelectedIndex = dt[0].DayCount; note_edit.Text = dt[0].Notes; stampSelect = dt[0].StSelect; stampColor = dt[0].Color; img = dt[0].Image; stamp_view.BackgroundColor = (Color)converter.ConvertFromInvariantString(dt[0].Color); stamp_grid.BackgroundColor = (Color)converter.ConvertFromInvariantString(dt[0].Color); if (dt[0].Image == 1) { stamp_view.Source = "baby_small.png"; } else { stamp_view.Source = null; } }
protected override void OnAppearing() { var converter = new ColorTypeConverter(); try { cycle = App.Database.GetCurrentCycle(); var dayData = App.Database.GetDayData(cycle[0].CycleID, cycle[0].LastEdit); curday = cycle[0].LastEdit; RefreshDayData(dayData); swipe_layout.IsEnabled = true; } catch { swipe_layout.IsEnabled = false; curday = 1; stampSelect = 0; stampColor = "White"; img = 0; stamp_view.BackgroundColor = (Color)converter.ConvertFromInvariantString("White"); stamp_grid.BackgroundColor = (Color)converter.ConvertFromInvariantString("White"); cycle_day.Text = ""; int_sel.SelectedIndex = 0; freq_sel.SelectedIndex = 0; cycle_id.Text = ""; date_field.Text = ""; men_sel.SelectedIndex = 0; ind1_sel.SelectedIndex = 0; ind2_sel.SelectedIndex = 0; ind3_sel.SelectedIndex = 0; pk_sel.SelectedIndex = 0; dcnt_sel.SelectedIndex = 0; note_edit.Text = ""; } }
async void addToContacts(object sender, EventArgs e) { Label l = (Label)sender; string s = l.Text.ToString().ToUpper(); s = strip(s); if (!Recipients.Contains(s)) { Button newButton = new Button { Text = s, BackgroundColor = (Color)(converter.ConvertFromInvariantString("#003595")), WidthRequest = 100, HeightRequest = 30, TextColor = Color.White, FontSize = 12, Padding = 1, VerticalOptions = LayoutOptions.Center, }; newButton.Clicked += removeButton; recipientList.Children.Add(newButton); Recipients.Add(s); l.BackgroundColor = (Color)(converter.ConvertFromInvariantString(" #ff33b5e5")); } }
protected override void OnAppearing() { var converter = new ColorTypeConverter(); try { var dayData = App.Database.GetDayData(tid, tdy); RefreshDayData(dayData); } catch { stampSelect = 0; stampColor = "White"; stamp_view.BackgroundColor = (Color)converter.ConvertFromInvariantString(stampColor); stamp_grid.BackgroundColor = (Color)converter.ConvertFromInvariantString(stampColor); cycle_day.Text = ""; int_sel.SelectedIndex = 0; freq_sel.SelectedIndex = 0; cycle_id.Text = ""; date_field.Text = ""; men_sel.SelectedIndex = 0; ind1_sel.SelectedIndex = 0; ind2_sel.SelectedIndex = 0; ind3_sel.SelectedIndex = 0; pk_sel.SelectedIndex = 0; dcnt_sel.SelectedIndex = 0; note_edit.Text = ""; } }
// afiseaza un set de ingrediente per pagina void ShowPageData(int m_idStart, int m_pasId) { NextBtn.IsVisible = true; PrevBtn.IsVisible = true; //DisplayAlert("VERIF22", "X_idStart=" + m_idStart + "X_idMax =" + idMax, "Ok."); List <Ingrediente> eng_listaIngrediente = ApiProcessor.LoadSomeIngredients(m_listaIngrediente, m_idStart, m_pasId, idMax); listViewIngrediente.ItemsSource = ApiProcessor.LoadTranslationIngrediente(eng_listaIngrediente); var converter = new ColorTypeConverter(); // daca nu mai putem merge in una dintre directii, culoarea butonului va deveni roz // daca mai putem merge, culoarea se va transforma in verde if (m_idStart <= 0) { PrevBtn.BackgroundColor = (Color)converter.ConvertFromInvariantString("LightCoral"); } else { PrevBtn.BackgroundColor = (Color)converter.ConvertFromInvariantString("LightGreen"); } if (m_idStart + m_pasId >= idMax) { NextBtn.BackgroundColor = (Color)converter.ConvertFromInvariantString("LightCoral"); } else { NextBtn.BackgroundColor = (Color)converter.ConvertFromInvariantString("LightGreen"); } }
private void MasterServerConnection() { var converter = new ColorTypeConverter(); var ip = "localhost"; hubConnection = new HubConnectionBuilder().WithUrl($"http://24.35.25.72:80/scoreHub").Build(); hubConnection.HandshakeTimeout = TimeSpan.FromMinutes(10); hubConnection.KeepAliveInterval = TimeSpan.FromSeconds(5); hubConnection.Closed += (exception) => { if (exception == null) { DisplayAlert("OK", "Connection closed without error.", "OK"); Console.WriteLine($"Connection closed due to no error"); } else { DisplayAlert("OK", "Connection closed with error.", "OK"); Console.WriteLine($"Connection closed due to an error: {exception}"); } return(Task.CompletedTask); }; hubConnection.On <string, string>("authSucc", async(token, session) => { Analytics.TrackEvent("User " + LoginUsername.Text + " logged in to app. Token: " + token); await ProgressLogin.ProgressTo(0.85, 1000, Easing.SinOut); var TokenStorageItem = new TokenStorageMaster(); var returnValue = TokenStorageItem.StoreToken(token, session, 1); await ProgressLogin.ProgressTo(0.95, 1000, Easing.SinOut); Analytics.TrackEvent(returnValue); await ProgressLogin.ProgressTo(1, 1000, Easing.SinOut); await Navigation.PushAsync(new Home()); await hubConnection.StopAsync(); }); hubConnection.On("authFail", () => { LoginPassword.TextColor = (Color)converter.ConvertFromInvariantString("Color.Red"); LoginUsername.TextColor = (Color)converter.ConvertFromInvariantString("Color.Red"); }); hubConnection.On("authRoleFail", () => { LoginPassword.TextColor = (Color)converter.ConvertFromInvariantString("Color.Yellow"); LoginUsername.TextColor = (Color)converter.ConvertFromInvariantString("Color.Yellow"); }); hubConnection.On("authAccept", () => { ProgressLogin.ProgressTo(0.1, 1000, Easing.SinOut); LoginPending.IsVisible = false; LoginAccepted.IsVisible = true; }); hubConnection.On <int>("authProgress", (progress) => { ProgressLogin.ProgressTo(progress / 100, 1000, Easing.SinOut); }); }
/// <summary> /// Va changer les couleurs des labels et du nom du médicament en fonction de la couleur saisie dans la base de données XML. /// </summary> /// <param name="couleur">Correspond à la couleur saisie dans la base de données XML pour la substance correspondante.</param> private void SetColorLabel(string couleur) { if (string.IsNullOrEmpty(couleur)) { couleur = "Black"; } ColorTypeConverter c = new ColorTypeConverter(); c.ConvertFromInvariantString(couleur); entrySubstance.TextColor = (Color)c.ConvertFromInvariantString(couleur); labelTypeSolvant.TextColor = (Color)c.ConvertFromInvariantString(couleur); labelUniteProduit.TextColor = (Color)c.ConvertFromInvariantString(couleur); labelUniteSolution.TextColor = (Color)c.ConvertFromInvariantString(couleur); labelUniteSolvant.TextColor = (Color)c.ConvertFromInvariantString(couleur); labelQteSolvant.TextColor = (Color)c.ConvertFromInvariantString(couleur); labelQteProduit.TextColor = (Color)c.ConvertFromInvariantString(couleur); labelQteMelange.TextColor = (Color)c.ConvertFromInvariantString(couleur); if (programme.GetUniteSolvant().Equals("Non Injectable")) { labelUniteSolvant.TextColor = Color.Red; labelUniteSolvant.FontAttributes = FontAttributes.Bold; } }
public void ConvertFromInvariantStringTest3() { tlog.Debug(tag, $"ConvertFromInvariantStringTest3 START"); try { ColorTypeConverter t2 = new ColorTypeConverter(); Assert.IsNotNull(t2, "null ColorTypeConverter"); var b1 = t2.ConvertFromInvariantString("Color.Red"); Assert.IsNotNull(b1, "null Binding"); var b2 = t2.ConvertFromInvariantString("Color.White"); Assert.IsNotNull(b2, "null Binding"); var b3 = t2.ConvertFromInvariantString("Color.Green"); Assert.IsNotNull(b3, "null Binding"); var b4 = t2.ConvertFromInvariantString("Color.Blue"); Assert.IsNotNull(b4, "null Binding"); var b5 = t2.ConvertFromInvariantString("Color.Yellow"); Assert.IsNotNull(b5, "null Binding"); var b6 = t2.ConvertFromInvariantString("Color.Magenta"); Assert.IsNotNull(b6, "null Binding"); var b7 = t2.ConvertFromInvariantString("Color.Cyan"); Assert.IsNotNull(b7, "null Binding"); var b8 = t2.ConvertFromInvariantString("Color.Transparent"); Assert.IsNotNull(b8, "null Binding"); } catch (Exception e) { Assert.Fail("Caught Exception" + e.ToString()); } tlog.Debug(tag, $"ConvertFromInvariantStringTest3 END"); }
private void judgeKey_TextChanged(object sender, TextChangedEventArgs e) { var converter = new ColorTypeConverter(); if (judgeKey.Text.ToString() == "1234" && judgeInitials.Text != "" && studentInitials.Text != "") { judgeKey.TextColor = (Color)converter.ConvertFromInvariantString("Color.Green"); SubmitScores.IsEnabled = true; } else { judgeKey.TextColor = (Color)converter.ConvertFromInvariantString("Color.Red"); SubmitScores.IsEnabled = false; } }
public override object ConvertFromInvariantString(string value) { return(new SolidColorBrush() { Color = (Color)colorTypeConverter.ConvertFromInvariantString(value) }); }
private void Item_OnTabItemClicked(object sender, string e) { var senderObj = (TabItem)sender; foreach (var item in Container.Children) { (item.BindingContext as TabBarItemModel).IsSelected = false; item.Margin = new Thickness(0, 10, 0, 0); } (senderObj.BindingContext as TabBarItemModel).IsSelected = true; if ((senderObj.BindingContext as TabBarItemModel).IsSelected) { senderObj.Margin = new Thickness(0, 5, 0, 0); senderObj.Padding = new Thickness(0, 0, 0, -5); //senderObj.HeightRequest = 50; var converter = new ColorTypeConverter(); BottomColor.BackgroundColor = (Xamarin.Forms.Color)converter.ConvertFromInvariantString((senderObj.BindingContext as TabBarItemModel).ColorName); BottomColor.Margin = new Thickness(0, -2, 0, 2); } //scroll position bool animate = true; ScrollBar.ScrollToAsync(senderObj, ScrollToPosition.Center, animate); OnTabBarClicked?.Invoke(this, e); }
public async Task Init() { Room currentRoom = await App.DatabaseUtil.GetRoom(App.CurrentRoom); ColorTypeConverter converter = new ColorTypeConverter(); if (currentRoom.Players != null) { foreach (Player p in currentRoom.Players) { p.SelectedColor = (Color)converter.ConvertFromInvariantString(p.StringColor); Players.Add(p); } } FirebaseObject <Room> toUpdateRoom = (await databaseClient.Child("Rooms").OnceAsync <Room>()).Where(a => a.Object.IdRoom == App.CurrentRoom).FirstOrDefault(); eventNewPlayer = databaseClient.Child("Rooms").Child(toUpdateRoom.Key).Child("Players").AsObservable <Player>().Subscribe(onNext: (FirebaseEvent <Player> p) => { if (p.Object != null) { if (Players.Where(a => a.Name == p.Object.Name).FirstOrDefault() == null) { Players.Add(new Player() { Name = p.Object.Name }); } } }); }
public override object?ConvertFromInvariantString(string?value) { if (value == null) { return(null); } value = value?.Trim(); var parts = value?.Split(','); if (parts == null) { return(null); } var colors = new SKConfettiColorCollection(); var colConv = new ColorTypeConverter(); foreach (var part in parts) { var c = colConv.ConvertFromInvariantString(part); colors.Add((Color)c); } return(colors); }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { if (value == null) { return(Color.Default); } string valueAsString = value.ToString(); Debug.WriteLine(valueAsString); switch (valueAsString) { case (""): { return(Color.Default); } case ("Accent"): { return(Color.Accent); } default: { var converter = new ColorTypeConverter(); var result = converter.ConvertFromInvariantString(valueAsString); return(result); } } }
async void OnColorButtonClicked(object sender, EventArgs e) { if (sender is XButton button) { string[] buttons = { "Aqua", "Azure", "Beige", "Bisque", "Black", "Blue", "BlueViolet", "Brown", "Chocolate", "Coral", "Crimson", "Cyan", "DarkBlue", "DarkCyan", "DarkGoldenrod", "DarkGray", "DarkGreen", "DarkKhaki","DarkMagenta", "DarkOliveGreen", "DarkOrange", "DarkOrchid", "DarkRed", "DarkSalmon", "DarkSeaGreen", "DarkSlateBlue", "DarkSlateGray", "DarkTurquoise", "DarkViolet", "DeepPink", "DeepSkyBlue", "FloralWhite", "Fuchsia", "Gold", "Gray", "Green", "GreenYellow", "Honeydew", "HotPink", "IndianRed","Indigo", "Ivory", "Khaki", "Lavender", "LightBlue", "LightCoral", "LightPink", "LightSkyBlue", "Lime", "Magenta", "MidnightBlue", "Navy", "Olive", "Orange", "OrangeRed", "Orchid", "PaleGreen", "Pink", "Purple", "Red", "Silver", "SkyBlue", "Transparent", "Violet", "Wheat", "White", "Yellow", "YellowGreen" }; string ret = await Application.Current.MainPage.DisplayActionSheet("Choose Color", "Cancel", "Default", buttons); XColor color = (XColor)(_converter.ConvertFromInvariantString(ret)); if (color.IsDefault) { ApplyDefaultColor(button); } else { button.BackgroundColor = color; } } }
/// <summary> /// Makes CustomPins and Polylines for each location /// </summary> /// <param name="shipLocation"></param> private void RegisterLive(ShipLocation shipLocation) { ColorTypeConverter colorTypeConverter = new ColorTypeConverter(); Location lastLocation = shipLocation.LocationsRegistrations.ElementAt(0); Location firstLocation = shipLocation.LocationsRegistrations.ElementAt(shipLocation.LocationsRegistrations.Count - 1); if (shipLocation.LocationsRegistrations.Count != 0) { Polyline polyline = new Polyline { StrokeWidth = 8, StrokeColor = (Color)colorTypeConverter.ConvertFromInvariantString(shipLocation.Color) }; for (int i = 0; i < shipLocation.LocationsRegistrations.Count; i++) { Location currentLocationRegistration = shipLocation.LocationsRegistrations[i]; polyline.Geopath.Add(new Position(currentLocationRegistration.Latitude, currentLocationRegistration.Longtitude)); } sharedData.Direction = (float)CalculateDirection(firstLocation, lastLocation); CustomPin pin = new CustomPin { Type = PinType.Place, Position = new Position(polyline.Geopath.ElementAt(0).Latitude, polyline.Geopath.ElementAt(0).Longitude), Label = String.Empty, Address = "" + shipLocation.ShipId, Name = "Ship", ShipId = "" + shipLocation.ShipId, TeamName = shipLocation.TeamName }; mapView.LoadPoints(polyline, pin, shipLocation.ShipId); } }
private Brush GetColorFromShipRarity(string ShipRarity) { switch (ShipRarity) { case "Normal": return(new SolidColorBrush(Color.LightGray)); case "Rare": return(new SolidColorBrush((Color)colorConverter.ConvertFromInvariantString("#9fe8ff"))); case "Elite": return(new SolidColorBrush((Color)colorConverter.ConvertFromInvariantString("#c4adff"))); case "Super Rare": case "Priority": return(new SolidColorBrush((Color)colorConverter.ConvertFromInvariantString("#ee9"))); case "Ultra Rare": case "Decisive": var gradStopCollection = new GradientStopCollection(); Color tempColor = (Color)colorConverter.ConvertFromInvariantString("#fbffca"); gradStopCollection.Add(new GradientStop(tempColor, 0.0f)); tempColor = (Color)colorConverter.ConvertFromInvariantString("#baffbf"); gradStopCollection.Add(new GradientStop(tempColor, 0.33f)); tempColor = (Color)colorConverter.ConvertFromInvariantString("#a7efff"); gradStopCollection.Add(new GradientStop(tempColor, 0.66f)); tempColor = (Color)colorConverter.ConvertFromInvariantString("#ffabff"); gradStopCollection.Add(new GradientStop(tempColor, 1.0f)); return(new LinearGradientBrush(gradStopCollection, new Point(0, 0), new Point(1, 1))); default: return(null); } }
public MainPage() { InitializeComponent(); var cTc = new ColorTypeConverter(); var res = cTc.ConvertFromInvariantString("Blue"); LblSpace.BackgroundColor = Color.Yellow; }
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { try { var converter = new ColorTypeConverter(); return((Color)converter.ConvertFromInvariantString(value.ToString().Trim())); } catch (Exception) { return(Color.Transparent); } }
private void colorPicker_SelectedIndexChanged(object sender, EventArgs e) { // Color Converter // Class used to convert the String into Color object var colorConverter = new ColorTypeConverter(); Color c = (Color)colorConverter.ConvertFromInvariantString(colorPicker.SelectedItem.ToString()); lblDisplay.TextColor = c; }
public void ConvertFromInvariantStringTest5() { tlog.Debug(tag, $"ConvertFromInvariantStringTest5 START"); ColorTypeConverter t2 = new ColorTypeConverter(); Assert.Throws <InvalidOperationException>(() => t2.ConvertFromInvariantString("Color.Pink")); //Pink not exist tlog.Debug(tag, $"ConvertFromInvariantStringTest5 END"); }
public static Color StringToColor(string c) { if (!string.IsNullOrEmpty(c)) { ColorTypeConverter _colorTypeConverter = new ColorTypeConverter(); return((Color)_colorTypeConverter.ConvertFromInvariantString(c)); } return(Color.Black); }
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { if (!string.IsNullOrEmpty((string)value)) { ColorTypeConverter _colorTypeConverter = new ColorTypeConverter(); return((Color)_colorTypeConverter.ConvertFromInvariantString((string)value)); } return(Color.Default); }
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { if (value == null) { return(Color.Gray); } var converter = new ColorTypeConverter(); return(converter.ConvertFromInvariantString(value.ToString())); }
public override object ConvertFromInvariantString(string value) { if (value != null) { var colors = value.Split(','); var conv = new ColorTypeConverter(); return(new GradientColors(colors.Select(x => (Color)conv.ConvertFromInvariantString(x)))); } throw new InvalidOperationException($"Cannot convert \"{value}\" into {typeof(GradientColors)}"); }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { if (value is string) { var converter = new ColorTypeConverter(); return(converter.ConvertFromInvariantString((string)value)); } else { return(Color.Default); } }
public void ConvertFromInvariantStringTest2() { tlog.Debug(tag, $"ConvertFromInvariantStringTest2 START"); try { ColorTypeConverter t2 = new ColorTypeConverter(); Assert.IsNotNull(t2, "null ColorTypeConverter"); var b1 = t2.ConvertFromInvariantString("#FFF"); Assert.IsNotNull(b1, "null Binding"); var b2 = t2.ConvertFromInvariantString("#F"); Assert.IsNotNull(b2, "null Binding"); //var b3 = t2.ConvertFromInvariantString("FFF"); //Assert.IsNotNull(b3, "null Binding"); var b4 = t2.ConvertFromInvariantString("#FFF1"); Assert.IsNotNull(b4, "null Binding"); var b5 = t2.ConvertFromInvariantString("#F1F3F1"); Assert.IsNotNull(b5, "null Binding"); var b6 = t2.ConvertFromInvariantString("#F1F3F134"); Assert.IsNotNull(b6, "null Binding"); var b7 = t2.ConvertFromInvariantString("#ABG"); Assert.IsNotNull(b7, "null Binding"); } catch (Exception e) { Assert.Fail("Caught Exception" + e.ToString()); } tlog.Debug(tag, $"ConvertFromInvariantStringTest2 END"); }
private async void btnAdd_Clicked(object sender, EventArgs e) { try { var converter = new ColorTypeConverter(); var testColorIfValid = (Color)converter.ConvertFromInvariantString(entryBackColor.Text); App.Setting.SaveColorSetting(entryBackColor.Text); } catch (InvalidOperationException ex) { await DisplayAlert("Error", "The Color you selected is not a valid color", "OK"); } }
void GetColorList() { _colors = new List <string>(); var temp = new List <string>(); foreach (var field in typeof(Color).GetFields(BindingFlags.Static | BindingFlags.Public)) { if (field != null && !String.IsNullOrEmpty(field.Name) && !field.Name.Contains("White")) { temp.Add(field.Name); } } for (int i = 0; i < temp.Count; i++) { var ranColor = (Color)_colorConverter.ConvertFromInvariantString(temp[i]); var sum = (ranColor.R + ranColor.G + ranColor.B) * 255; if (sum < 382) { _colors.Add(temp[i]); } } }
public void TestColorTypeConverter () { var converter = new ColorTypeConverter (); Assert.True (converter.CanConvertFrom (typeof(string))); Assert.AreEqual (Color.Blue, converter.ConvertFromInvariantString ("Color.Blue")); Assert.AreEqual (Color.Blue, converter.ConvertFromInvariantString ("Blue")); Assert.AreEqual (Color.Blue, converter.ConvertFromInvariantString ("#0000ff")); Assert.AreEqual (Color.Default, converter.ConvertFromInvariantString ("Color.Default")); Assert.AreEqual (Color.Accent, converter.ConvertFromInvariantString ("Accent")); var hotpink = Color.FromHex ("#FF69B4"); Color.Accent = hotpink; Assert.AreEqual (Color.Accent, converter.ConvertFromInvariantString ("Accent")); Assert.Throws<InvalidOperationException> (() => converter.ConvertFromInvariantString ("")); }