public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { var converter = new ColorTypeConverter(); if ((value is Boolean && (Boolean)value == true) || (value is Boolean? && (Boolean?)value == true)) { return(Xamarin.Forms.Color.Orange); } return(Xamarin.Forms.Color.White); }
public void ExtendedColorTypeConverterParsesColors(string input) { ColorTypeConverter converter = new ColorTypeConverter(); object convertFrom = converter.ConvertFrom(null, input, typeof(Color)); if (convertFrom != null) { Color color = (Color)convertFrom; Assert.AreEqual(Color.Blue.ToArgb(), color.ToArgb()); } }
public void GetStandardValuesSupported_Always_ReturnFalse() { // Setup var converter = new ColorTypeConverter(); // Call bool standardValuesSupported = converter.GetStandardValuesSupported(null); // Assert Assert.IsFalse(standardValuesSupported); }
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 void ConvertToStringTest1() { tlog.Debug(tag, $"ConvertToStringTest1 START"); ColorTypeConverter t2 = new ColorTypeConverter(); Color red = Color.Red; string r = t2.ConvertToString(red); Assert.IsNotNull(r, "Should not be null"); tlog.Debug(tag, $"ConvertToStringTest1 END"); }
void Start() { ColorTypeConverter colCon = new ColorTypeConverter(); string color = PlayerPrefs.GetString("savecolor"); ColorTypeConverter col = new ColorTypeConverter(); ParticleSystem ps = GetComponent <ParticleSystem>(); var main = ps.main; main.startColor = col.GetColorFromString(color); }
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); } }
async void ShowPageData(int m_idStartCache, int m_pasId) { //System.Diagnostics.Debug.WriteLine(">>>>>>IDSTARTC:" + idStartCache + " IDLASTC:" + idLastCache); // vom afisa lista din cache tradusa List <Dictionary <string, string> > someReteteCache_eng = ApiProcessor.LoadSomeRecipes(m_listaReteteCache, m_idStartCache, m_pasId, idLastCache); List <Dictionary <string, string> > someReteteCache_ro = ApiProcessor.LoadTranslationRetete(someReteteCache_eng); listViewRetete.ItemsSource = someReteteCache_ro; var converter = new ColorTypeConverter(); // daca nu am gasit retete, ii spunem utilizatorului & facem bg pt listview invisibil if (someReteteCache_ro.Count == 0) { listViewRetete.BackgroundColor = (Color)converter.ConvertFromInvariantString("#00FBC1BC"); lblMesajReteteFail.IsVisible = true; lblMesajReteteFail.Text = await ApiProcessor.LoadTranslation("No recipes found."); } else { lblMesajReteteFail.IsVisible = false; listViewRetete.BackgroundColor = (Color)converter.ConvertFromInvariantString("White"); } // daca nu mai putem merge in una dintre directii, culoarea butonului va deveni roz // daca mai putem merge, culoarea se va transforma in verde // in acest caz suntem la inceputul listei if (m_idStartCache <= 0) { BackBtn.BackgroundColor = (Color)converter.ConvertFromInvariantString("LightCoral"); } else { BackBtn.BackgroundColor = (Color)converter.ConvertFromInvariantString("LightGreen"); } // in acest caz, suntem la finalul listei daca idStart plus pasul trece de last // id cache si daca am terminat de cautat prin api if (FinishedSearchApi && m_idStartCache + m_pasId >= idLastCache) { NextBtn.BackgroundColor = (Color)converter.ConvertFromInvariantString("LightCoral"); } else { NextBtn.BackgroundColor = (Color)converter.ConvertFromInvariantString("LightGreen"); } }
public override void Initialize(INavigationParameters parameters) { base.Initialize(parameters); RoleList = new List <string> { "Select Role" }; _colorConverter = new ColorTypeConverter(); _random = new Random(); GetColorList(); ChangeBackgroundColor(); Captcha = GetUniqueKey(6); }
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"); } }
public App() { Syncfusion.Licensing.SyncfusionLicenseProvider.RegisterLicense("MTU4MzE3QDMxMzcyZTMzMmUzMGtxYThmb2NzaGxuMWJhZy9Eemk5WUhnMmZ2S3N3ZUZNU2VTdTdvWjRWaDg9"); InitializeComponent(); ColorTypeConverter color = new ColorTypeConverter(); Color.FromHex("ADC698"); MainPage = new NavigationPage(new WelcomePage()) { //#CBDFBD //#437C90 BarBackgroundColor = Color.FromHex("#CBDFBD"), }; }
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 Items(string _name, ItemTypes _itemType, int _amount) { name = _name; itemType = _itemType; amount = _amount; pendingAmount = amount; System.Random rand = new System.Random(name.GetHashCode()); float a = rand.Next(1000) / 1000f; float b = rand.Next(1000) / 1000f; float c = rand.Next(1000) / 1000f; color = new Color(a, b, c); coloredName = "<color=" + ColorTypeConverter.ToRGBHex(color) + ">" + name + "</color>"; }
public static bool TryParse(string value, out Brush brush) { try { var colorConverter = new ColorTypeConverter(); var color = (Color)colorConverter.ConvertFromInvariantString(value); brush = new SolidColorBrush(color); return(true); } catch { brush = null; return(false); } }
// Enabled btn public void GetMaterialGround(CustomColor c) { ground.GetComponent <SpriteRenderer>().color = new Color32( c.GetComponent <CustomColor>().color.r, c.GetComponent <CustomColor>().color.g, c.GetComponent <CustomColor>().color.b, 255); ColorTypeConverter col = new ColorTypeConverter(); string colorSaved = col.ToRGBHex(ground.GetComponent <SpriteRenderer>().color); // Save record PlayerPrefs.SetString("savecolorground", colorSaved); PlayerPrefs.Save(); }
public void Init() { //CurrentRoom = await App.DatabaseUtil.GetRoom(App.CurrentRoom); Player player1 = new Player() { Name = "Player1", Score = 0, StringColor = "Red" }; Player player2 = new Player() { Name = "Player2", Score = 0, StringColor = "Blue" }; Player player3 = new Player() { Name = "Player3", Score = 0, StringColor = "Yellow" }; Player player4 = new Player() { Name = "Player4", Score = 0, StringColor = "Green" }; Player player5 = new Player() { Name = "Player5", Score = 0, StringColor = "Purple" }; List <Player> players = new List <Player>() { player1, player2, player3, player4, player5 }; CurrentRoom = new Room() { IdRoom = "Demo", Players = players, CurrentRound = 1 }; Players = new ObservableCollection <Player>(); ColorTypeConverter converter = new ColorTypeConverter(); foreach (Player p in CurrentRoom.Players) { Players.Add(new Player() { Name = p.Name, Score = p.Score, UpCommand = new Command(async(player) => await UpAction(player)), DownCommand = new Command(async(player) => await DownAction(player)), SelectedColor = (Color)converter.ConvertFromInvariantString(p.StringColor) }); } RoundLabel = String.Concat("Round N°", CurrentRoom.CurrentRound); }
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("")); }
public void ConvertFromInvariantStringTest1() { tlog.Debug(tag, $"ConvertFromInvariantStringTest1 START"); try { ColorTypeConverter t2 = new ColorTypeConverter(); Assert.IsNotNull(t2, "null ColorTypeConverter"); var b = t2.ConvertFromInvariantString("Black"); Assert.IsNotNull(b, "null Binding"); } catch (Exception e) { Assert.Fail("Caught Exception" + e.ToString()); } tlog.Debug(tag, $"ConvertFromInvariantStringTest1 END"); }
public static string ColorToString(Color c) { string result = "Black"; ColorTypeConverter _colorTypeConverter = new ColorTypeConverter(); foreach (string tmpC in GetColorList()) { if ((Color)_colorTypeConverter.ConvertFromInvariantString(tmpC) == c) { return(tmpC); } } return(result); }
private void MasterServerConnection() { var converter = new ColorTypeConverter(); var ip = "localhost"; if (hubConnection == null || hubConnection.State != HubConnectionState.Connected) { hubConnection = new HubConnectionBuilder().WithUrl($"http://24.35.25.72:80/scoreHub").Build(); hubConnection.ServerTimeout = TimeSpan.FromMinutes(30); } hubConnection.On <List <StaticField> >("teamsUpNow", (fields) => { SetUpNowTeams(fields); }); }
// dekorator void Handle_SelectedIndexChanged(object sender, EventArgs e) { var todoItem = (TodoItem)BindingContext; if (colorPicker.SelectedIndex == -1) { colorBoxView.Color = Color.Default; todoItem.Color = "Default"; } else { ColorTypeConverter colortype = new ColorTypeConverter(); string colorName = colorPicker.Items[colorPicker.SelectedIndex]; todoItem.Color = colorName; colorBoxView.Color = (Color)colortype.ConvertFromInvariantString(colorName); } }
public IEnumerable <Instruction> ConvertFromString(string value, ILContext context, BaseNode node) { var module = context.Body.Method.Module; if (!string.IsNullOrEmpty(value)) { value = value.Trim(); if (value.StartsWith("#", StringComparison.Ordinal)) { var colorConverter = new ColorTypeConverter(); foreach (var instruction in colorConverter.ConvertFromString(value, context, node)) { yield return(instruction); } yield return(Instruction.Create(OpCodes.Newobj, module.ImportCtorReference(("Microsoft.Maui.Controls", "Microsoft.Maui.Controls", "SolidColorBrush"), parameterTypes: new[] {
public string StationStats() { string stats = "\nTotal Stations: " + data.stations.Count + "\n"; List <StationModel> sortedStations = new List <StationModel>(); foreach (StationModel station in data.stations) { sortedStations.Add(station); } sortedStations.Sort(delegate(StationModel c1, StationModel c2) { return(c2.money.CompareTo(c1.money)); }); for (int i = 0; i < sortedStations.Count; i++) { stats += string.Format("\n{0}. {1} - {2} | {3}/{4}", i + 1, "<color=" + ColorTypeConverter.ToRGBHex(sortedStations[i].color) + ">" + sortedStations[i].name + "</color>", sortedStations[i].money.ToString("0.00"), sortedStations[i].factory.productionTime.ToString("0.00"), sortedStations[i].factory.unitTime.ToString("0.00")); } return(stats); }
/// <summary> /// Makes CustomPins and Polylines for each location /// </summary> /// <param name="shipLocation">The ShipLocation object that will be made CustomPins and Polylines according to</param> /// <param name="currentIndex">The current number of locations already gone through</param> /// <param name="amount">The amount of locations to go through</param> private void RegisterReplay(ShipLocation shipLocation, int currentIndex, int amount) { if (amount > 0) { ColorTypeConverter colorTypeConverter = new ColorTypeConverter(); int lastIndex = currentIndex + amount - 1; Location lastLocation = shipLocation.LocationsRegistrations.ElementAt(lastIndex); Location firstLocation = shipLocation.LocationsRegistrations.ElementAt(currentIndex); if (shipLocation.LocationsRegistrations.Count != 0) { Polyline polyline = new Polyline { StrokeWidth = 8, StrokeColor = (Color)colorTypeConverter.ConvertFromInvariantString(shipLocation.Color) }; for (int i = currentIndex; i < currentIndex + amount; i++) { Location currentLocationRegistration = shipLocation.LocationsRegistrations[i]; polyline.Geopath.Add(new Position(currentLocationRegistration.Latitude, currentLocationRegistration.Longtitude)); ShipLocation sortedLocation = sortedLocations.Where(l => l.ShipId == shipLocation.ShipId).FirstOrDefault(); sortedLocation.LocationsRegistrations.Add(currentLocationRegistration); sortedLocation.Color = shipLocation.Color; } sharedData.Direction = (float)CalculateDirection(firstLocation, lastLocation); CustomPin pin = new CustomPin { Type = PinType.Place, Position = new Position(polyline.Geopath.ElementAt(amount - 1).Latitude, polyline.Geopath.ElementAt(amount - 1).Longitude), Label = String.Empty, Address = "" + shipLocation.ShipId, Name = "Ship", ShipId = "" + shipLocation.ShipId, TeamName = shipLocation.TeamName }; mapView.LoadPoints(polyline, pin, shipLocation.ShipId); } } }
void BackwardClicked(object sender, EventArgs e) { Update_Clicked(sender, e); var converter = new ColorTypeConverter(); curday -= 1; if (curday == 0) { curday = cycle[0].NumDays; } var dayData = App.Database.GetDayData(cycle[0].CycleID, curday); RefreshDayData(dayData); if (scroll_view.ScrollY > 0) { scroll_view.ScrollToAsync(0, 0, false); } }
void OnSwiped(object sender, SwipedEventArgs e) { Update_Clicked(sender, e); var converter = new ColorTypeConverter(); switch (e.Direction) { case SwipeDirection.Left: // Handle the swipe curday += 1; if (curday > cycle[0].NumDays) { curday = 1; } var dayData = App.Database.GetDayData(cycle[0].CycleID, curday); RefreshDayData(dayData); if (scroll_view.ScrollY > 0) { scroll_view.ScrollToAsync(0, 0, false); } break; case SwipeDirection.Right: // Handle the swipe curday -= 1; if (curday == 0) { curday = cycle[0].NumDays; } dayData = App.Database.GetDayData(cycle[0].CycleID, curday); RefreshDayData(dayData); if (scroll_view.ScrollY > 0) { scroll_view.ScrollToAsync(0, 0, false); } break; } }
Color GetRandomColor() { var colors = new List <string>(); foreach (var field in typeof(Color).GetFields(BindingFlags.Static | BindingFlags.Public)) { if (field != null && !string.IsNullOrEmpty(field.Name)) { colors.Add(field.Name); } } Random random = new Random(); var randomColorName = colors[random.Next(colors.Count)]; var colorConverter = new ColorTypeConverter(); var result = colorConverter.ConvertFromInvariantString(randomColorName); return((Color)result); }
// ADS void Start() { Advertisement.Initialize(store_id); // ADS record = PlayerPrefs.GetInt("savescore"); bestScore.text = "Best: " + record.ToString(); string s = PlayerPrefs.GetString("savecolorground"); ColorTypeConverter col = new ColorTypeConverter(); if (s != "") { ground.GetComponent <SpriteRenderer>().color = col.GetColorFromString(s); } else { ground.GetComponent <SpriteRenderer>().color = col.GetColorFromString("FFFFFF"); } }
private void ChangeRound(object sender, EventArgs e) { var converter = new ColorTypeConverter(); if (sender == r1select) { Round = 1; r1select.BackgroundColor = (Color)converter.ConvertFromInvariantString("#0a6cf5"); r2select.BackgroundColor = (Color)converter.ConvertFromInvariantString("#ffffff"); r1select.TextColor = (Color)converter.ConvertFromInvariantString("#ffffff"); r2select.TextColor = (Color)converter.ConvertFromInvariantString("#0a6cf5"); } else { Round = 2; r2select.BackgroundColor = (Color)converter.ConvertFromInvariantString("#0a6cf5"); r1select.BackgroundColor = (Color)converter.ConvertFromInvariantString("#ffffff"); r2select.TextColor = (Color)converter.ConvertFromInvariantString("#ffffff"); r1select.TextColor = (Color)converter.ConvertFromInvariantString("#0a6cf5"); } }
async void ShowPageData(int m_idStart, int m_pasId) { List <Ingrediente> eng_listaIngrediente = ApiProcessor.LoadSomeIngredientsReverse(App.listaIngredienteFrigider, m_idStart, m_pasId, idMax); listViewIngrediente.ItemsSource = ApiProcessor.LoadTranslationIngrediente(eng_listaIngrediente); var converter = new ColorTypeConverter(); // daca nu avem ingrediente, ii spunem utilizatorului si facem bg de la listview invisibil if (eng_listaIngrediente.Count == 0) { listViewIngrediente.BackgroundColor = (Color)converter.ConvertFromInvariantString("#00FBC1BC"); lblMsg.Text = await ApiProcessor.LoadTranslation("You do not have any ingredients. Click the plus button to add some."); } else { listViewIngrediente.BackgroundColor = (Color)converter.ConvertFromInvariantString("White"); lblMsg.Text = await ApiProcessor.LoadTranslation("To remove an ingredient, press click on it."); } // 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) { BackBtn.BackgroundColor = (Color)converter.ConvertFromInvariantString("LightCoral"); } else { BackBtn.BackgroundColor = (Color)converter.ConvertFromInvariantString("LightGreen"); } if (m_idStart + m_pasId >= idMax) { NextBtn.BackgroundColor = (Color)converter.ConvertFromInvariantString("LightCoral"); } else { NextBtn.BackgroundColor = (Color)converter.ConvertFromInvariantString("LightGreen"); } }
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 ("")); }