public void ShowPopup(string msg, bool isError = false)
        {
            var        popup = new TipPopup(App.Tools, msg);
            ColorNames color = isError ? ColorNames.ErrorColor : ColorNames.PrimaryColor;

            popup.Show(color);
        }
Example #2
0
    public static Color toColor(this ColorNames code, float alpha = 1.0f)
    {
        var result = (Color)code.toColor32();

        result.a = alpha;
        return(result);
    }
Example #3
0
        /// <summary>
        /// Resets layout of the widget
        /// </summary>
        protected void ResetLayout()
        {
            if (ResolveColorNames == false)
            {
                name.Text = colorName;
            }
            else
            {
                name.Text = ColorNames.GetName(Color);
            }
            if (SmallFonts == true)
            {
                name.Text = "<small>" + name.Text + "</small>";
            }
            double w, h;

            colorbox.Visible = true;
            name.Visible     = (NameVisible == true);
            MainBox.GetSize(out w, out h);
            if (Allocation.Width < w)
            {
                WidthRequest = System.Convert.ToInt32(w);
            }
            if (Allocation.Height < h)
            {
                HeightRequest = System.Convert.ToInt32(h);
            }
            CellsChanged();
        }
Example #4
0
        /// <summary>
        /// sets colors to a control and optional to it's subcontrols
        /// </summary>
        /// <param name="guiObject"></param>
        /// <param name="forecolorName"></param>
        /// <param name="backcolorName"></param>
        /// <param name="recursive"></param>
        internal void SetColorToObject(Control guiObject, ColorNames forecolorName, ColorNames backcolorName, bool recursive = true)
        {
            try
            {
                Color foreColor = GetColor(forecolorName);
                Color backColor = GetColor(backcolorName);

                Boolean guiReset = false;

                if ((!UseColors) && (forecolorName == ColorNames.Default_ForeColor) && (backcolorName == ColorNames.Default_BackColor))
                {
                    // reset to system colors
                    foreColor = Color.FromKnownColor(KnownColor.ControlText);
                    backColor = Color.FromKnownColor(KnownColor.Control);

                    guiReset = true;
                }

                SetColorToObjectExtracted(guiObject, foreColor, backColor, recursive, guiReset);
            }
            catch (Exception ex)
            {
                throw new Exception("Error while setting colors of a gui object", ex);
            }
        }
 public void ToggleObjectsColor(ColorNames color)
 {
     foreach (var sprite in sprites)
     {
         sprite.color = ColorList.colors[(int)color];
     }
 }
Example #6
0
 public AnyUiColor GetColor(ColorNames c)
 {
     if (AccentColors != null && AccentColors.ContainsKey(c))
     {
         return(AccentColors[c]);
     }
     return(AnyUiColors.Black);
 }
Example #7
0
    public static Color32 toColor32(this ColorNames code, byte alpha = 0xFF)
    {
        int  value = (int)code;
        byte r     = (byte)((value >> 16) & 0xFF);
        byte g     = (byte)((value >> 8) & 0xFF);
        byte b     = (byte)(value & 0xFF);

        return(new Color32(r, g, b, alpha));
    }
 public static bool TryParse(string name, out ChatColor?color)
 {
     color = null;
     if (ColorNames.ContainsKey(name))
     {
         color = new ChatColor(ColorNames[name]);
     }
     return(color != null);
 }
Example #9
0
 public void SetText()
 {
     if (ResolveColorNames == false)
     {
         name.Text = colorName;
     }
     else
     {
         name.Text = ColorNames.GetName(Color);
     }
 }
Example #10
0
        public void Update(Vehicle vehicle, DateTime now, decimal pricePerMinute)
        {
            TotalVehicles  += 1;
            TotalMembers   += 1;
            TotalWheels    += vehicle.NumberOfWheels;
            TotalCost      += (decimal)Math.Round((now - vehicle.CheckinTime).TotalMinutes) * pricePerMinute;
            TotalUnitsUsed += vehicle.Units;

            if (!ColorNames.ContainsKey(vehicle.VehicleColorId))
            {
                ColorNames[vehicle.VehicleColorId] = vehicle.Color.Name;
            }
            if (!TypeNames.ContainsKey(vehicle.VehicleTypeId))
            {
                TypeNames[vehicle.VehicleTypeId] = vehicle.Type.Type;
            }

            // Vehicle Color statistics
            if (!ColorStatistics.ContainsKey(vehicle.VehicleColorId))
            {
                ColorStatistics[vehicle.VehicleColorId] = 1;
            }
            else
            {
                ColorStatistics[vehicle.VehicleColorId] += 1;
            }

            // Vehicle Type statistics
            if (!TypeStatistics.ContainsKey(vehicle.VehicleTypeId))
            {
                TypeStatistics[vehicle.VehicleTypeId] = 1;
            }
            else
            {
                TypeStatistics[vehicle.VehicleTypeId] += 1;
            }

            // Vehicle Type & Color statistics
            if (!TypeColorStatistics.ContainsKey(vehicle.VehicleTypeId))
            {
                TypeColorStatistics[vehicle.VehicleTypeId] = new Dictionary <int, int>();
            }
            var tcs = TypeColorStatistics[vehicle.VehicleTypeId];

            if (!tcs.ContainsKey(vehicle.VehicleColorId))
            {
                tcs[vehicle.VehicleColorId] = 1;
            }
            else
            {
                tcs[vehicle.VehicleColorId] += 1;
            }
        }
Example #11
0
    public void SetRandom()
    {
        //ColorName = Util.RandomEnumValue<ColorNames>();

        var colorList = Enum.GetValues(typeof(ColorNames)).Cast <ColorNames>().ToList();

        ColorName = Util.randomProc(20) ?
                    ColorNames.White :
                    colorList[UnityEngine.Random.Range(0, colorList.Count)];

        //System.Random random = new System.Random();
        //ColorName = (ColorNames)values.GetValue(random.Next(values.Length));
    }
Example #12
0
        /// <summary>
        /// sets the color for a colorname
        /// </summary>
        /// <param name="currentColor"></param>
        /// <returns></returns>
        public void SetColor(ColorNames currentColor, Color colorValue)
        {
            try
            {
                Program.DBCon.setIniValue(DB_GROUPNAME, currentColor.ToString(), colorValue.ToArgb().ToString());

                m_DataCache.Remove(currentColor.ToString());
                m_DataCache.Add(currentColor.ToString(), colorValue, DateTimeOffset.Now.AddMinutes(10));
            }
            catch (Exception ex)
            {
                throw new Exception("Error while setting a GUI-color", ex);
            }
        }
    public static Color?GetColor(ColorNames colorName)
    {
        // Try to get the result in the static Dictionary
        Color result;

        if (colorDict.TryGetValue(colorName, out result))
        {
            return(result);
        }
        else
        {
            return(null);
        }
    }
Example #14
0
    private void LoadColors()
    {
        string response = Rest.GetColors();

        Debug.Log(response);
        List <CustomColor> customColors = JsonArrayHelper.getJsonList <CustomColor>(response);

        if (ColorNames == null || ColorNames.Count > 0)
        {
            ColorNames = new Dictionary <string, string>();
        }

        foreach (var customColor in customColors)
        {
            ColorNames.Add(customColor.color, customColor.name);
        }
    }
Example #15
0
        private void RefreshCanvas()
        {
            CurrentStones.Clear();
            HistStones.Clear();
            ColorNames.Clear();
            CurrentBlock.Children.RemoveRange(0, CurrentBlock.Children.Count);

            stoneWidth = (((int)CurrentBlock.Bounds.Width) - (2 * 2 * space) - ((BlockSize - 1) * space)) / BlockSize;

            int firstBlockStone = BlockSize * (SelectedBlock - 1);

            for (int i = 0; i < BlockSize; i++)
            {
                if (firstBlockStone + i < stonesPerLine)
                {
                    if (ShowHistory && SelectedRow - 2 >= 0)
                    {
                        int oldStoneIndex = intField[firstBlockStone + i, SelectedRow - 2];
                        if (oldStoneIndex >= 0 && fParameters.colors.Length > oldStoneIndex)
                        {
                            HistStones.Add(new SolidColorBrush(fParameters.colors[oldStoneIndex].mediaColor));
                        }
                    }

                    int stoneindex = intField[firstBlockStone + i, SelectedRow - 1];
                    if (stoneindex < 0)
                    {
                        continue;
                    }

                    CurrentStones.Add(new SolidColorBrush(fParameters.colors[stoneindex].mediaColor));

                    if (ColorNames.Count == 0 || !ColorNames.LastOrDefault().ColorName.Equals(fParameters.colors[stoneindex].name))
                    {
                        ColorNames.Add(new ColorAmount(fParameters.colors[stoneindex].name, 1));
                    }
                    else
                    {
                        ColorNames.LastOrDefault().Amount++;
                    }
                }
            }
        }
Example #16
0
    public void DrawWebColliders(int[] spriteIndexes, ColorNames name)
    {
        for (int i = 0; i < spriteIndexes.Length; i++)
        {
            sprites[spriteIndexes[i]].color = ColorList.colors[(int)name];

            sprites[spriteIndexes[i]].gameObject.AddComponent <PolygonCollider2D>().usedByEffector = true;
            PlatformEffector2D effector = sprites[spriteIndexes[i]].gameObject.AddComponent <PlatformEffector2D>();
            effector.rotationalOffset = offsetAngles[spriteIndexes[i]];
            effector.useColliderMask  = false;
            effector.useOneWay        = true;

            if (name == ColorNames.Red)
            {
                sprites[spriteIndexes[i]].gameObject.layer = layerWebRed;
            }

            if (name == ColorNames.Green)
            {
                sprites[spriteIndexes[i]].gameObject.layer = layerWebGreen;
            }
        }
    }
Example #17
0
        /// <summary>
        /// gets the color for a colorname
        /// </summary>
        /// <param name="currentColor"></param>
        /// <returns></returns>
        public Color GetColor(ColorNames currentColor)
        {
            try
            {
                Color retValue;

                if (m_DataCache.Get(currentColor.ToString()) == null)
                {
                    retValue = Color.FromArgb(Program.DBCon.getIniValue <int>(DB_GROUPNAME, currentColor.ToString(), ((Color)(usedPresets[currentColor])).ToArgb().ToString()));
                    m_DataCache.Add(currentColor.ToString(), retValue, DateTimeOffset.Now.AddMinutes(10));
                }
                else
                {
                    retValue = (Color)m_DataCache.Get(currentColor.ToString());
                }

                return(retValue);
            }
            catch (Exception ex)
            {
                throw new Exception("Error while getting a GUI-color", ex);
            }
        }
Example #18
0
 public NamedColor(ColorNames colorName, uint color)
 {
     ColorName = colorName;
     Color     = color;
 }
Example #19
0
 public static Color32 ColorValue(ColorNames color)
 {
     return((Color32)ColorValues [color]);
 }
Example #20
0
        /// <summary>
        /// sets colors to a control and optional to it's subcontrols
        /// </summary>
        /// <param name="guiObject"></param>
        /// <param name="forecolorName"></param>
        /// <param name="backcolorName"></param>
        /// <param name="recursive"></param>
        internal void SetColorToObject(Control guiObject, ColorNames forecolorName, ColorNames backcolorName, bool recursive = true)
        {
            try
            {
                Color foreColor = GetColor(forecolorName);
                Color backColor = GetColor(backcolorName);

                Boolean guiReset = false;

                if ((!UseColors) && (forecolorName == ColorNames.Default_ForeColor) && (backcolorName == ColorNames.Default_BackColor))
                {
                    // reset to system colors
                    foreColor = Color.FromKnownColor(KnownColor.ControlText);
                    backColor = Color.FromKnownColor(KnownColor.Control);

                    guiReset = true;
                }

                SetColorToObjectExtracted(guiObject, foreColor, backColor, recursive, guiReset);
            }
            catch (Exception ex)
            {
                throw new Exception("Error while setting colors of a gui object", ex);
            }
        }
Example #21
0
        /// <summary>
        /// sets the color for a colorname
        /// </summary>
        /// <param name="currentColor"></param>
        /// <returns></returns>
        public void SetColor(ColorNames currentColor, Color colorValue)
	    {
            try
            {
                Program.DBCon.setIniValue(DB_GROUPNAME, currentColor.ToString(), colorValue.ToArgb().ToString());
                
                m_DataCache.Remove(currentColor.ToString());
                m_DataCache.Add(currentColor.ToString(), colorValue, DateTimeOffset.Now.AddMinutes(10));
                           
            }
            catch (Exception ex)
            {
                throw new Exception("Error while setting a GUI-color", ex);
            }
	    }
Example #22
0
        /// <summary>
        /// gets the color for a colorname
        /// </summary>
        /// <param name="currentColor"></param>
        /// <returns></returns>
        public Color GetColor(ColorNames currentColor)
	    {
            try
            {
                Color retValue;

                if(m_DataCache.Get(currentColor.ToString()) == null)
                { 
                    retValue = Color.FromArgb(Program.DBCon.getIniValue<int>(DB_GROUPNAME, currentColor.ToString(), ((Color)(usedPresets[currentColor])).ToArgb().ToString()));
                    m_DataCache.Add(currentColor.ToString(), retValue, DateTimeOffset.Now.AddMinutes(10));
                }
                else
                {
                    retValue = (Color)m_DataCache.Get(currentColor.ToString());
                }

                return retValue;

            }
            catch (Exception ex)
            {
                throw new Exception("Error while getting a GUI-color", ex);
            }
	    }
Example #23
0
 public static Color32 GetColorValue(ColorNames name)
 {
     return((Color32)colorValues[name]);
 }
Example #24
0
 /// <summary>
 /// Gets a color by enumeration.
 /// </summary>
 /// <param name="color">The color to get.</param>
 /// <returns>A color.</returns>
 public Color FromColorName(ColorNames color) => color switch
 {
Example #25
0
 public void TestColorName()
 {
     Assert.AreEqual(true, ColorNames.IsNameAvailable("maroon"));
     Assert.AreEqual(false, ColorNames.IsNameAvailable("wizcas"));
 }
Example #26
0
        public static Color ToColor(this ColorNames name)
        {
            var entity = ColorEntity.m_Entities[name];

            return(ToColor(entity.Hex.SanitizeHex()));
        }
Example #27
0
 public NamedColor(ColorNames colorName, _Color color)
 {
     ColorName = colorName;
     Color     = ColorToUInt(color);
 }
Example #28
0
        public ViewResult Index()
        {
            ColorNames model = new ColorNames();

            return(View(model));
        }