Beispiel #1
0
 public ColorRgba(ColorInfo colorInfo)
 {
     R = colorInfo.Color.Red != null ? colorInfo.Color.Red.Value : 0;
     G = colorInfo.Color.Green != null ? colorInfo.Color.Green.Value : 0;
     B = colorInfo.Color.Blue != null ? colorInfo.Color.Blue.Value : 0;
     A = colorInfo.Color.Alpha != null ? colorInfo.Color.Alpha.Value : 0;
 }
Beispiel #2
0
    IEnumerator SpawnWave(Wave wave)
    {
        List <GameObject> enemies = wave.enemies;
        float             delay   = wave.delay;
        int enemyIndex            = 0;

        do
        {
            int spawnIndex = Random.Range(0, spawnPoints.Count);

            Vector2 spawnPoint = spawnPoints[spawnIndex];
            if (wave.isBoss)
            {
                spawnPoint = centrePos;
            }

            spawnDoors[spawnIndex].SetTrigger("Open");
            GameObject enemy = Instantiate(enemies[enemyIndex], spawnPoint, Quaternion.identity);
            waveHandler.AddEnemy(enemy);

            EnemyStats enemyScript = enemy.GetComponent <EnemyStats>();
            ColorInfo  color       = colorMats[Random.Range(0, colorMats.Length)];
            enemyScript.material = color.mat;
            enemyScript.tag      = color.color;
            enemyIndex++;
            yield return(new WaitForSeconds(delay / 2));

            spawnDoors[spawnIndex].SetTrigger("Close");

            yield return(new WaitForSeconds(delay - delay / 3));
        } while (enemyIndex < enemies.Count);
    }
Beispiel #3
0
    public void FinishTypewriter()
    {
        mTyping = false;
        colorList.Clear();
        int colorCount = 0;

        while (mText.Contains("{"))
        {
            int       index      = mText.IndexOf("{");
            ColorInfo aColorInfo = new ColorInfo();
            aColorInfo.startIndex = index + colorCount * 8;
            aColorInfo.color      = mText.Substring(index, 8);
            aColorInfo.color      = aColorInfo.color.Replace('{', '[');
            aColorInfo.color      = aColorInfo.color.Replace('}', ']');
            mText = mText.Remove(index, 8);
            colorList.Add(aColorInfo);
            colorCount++;
        }

        for (int i = 0; i < colorList.Count; i++)
        {
            mText = mText.Insert(colorList[i].startIndex, colorList[i].color);
        }

        mLabel.text = mText;


        if (TypeWriteStopEvent != null)
        {
            TypeWriteStopEvent();
            //TypeWriteStopEvent = null;
        }
    }
        static void writeColorConversionPath(ColorInfo c1, ColorInfo c2)
        {
            var path = ColorDepthConverter.GetPath(c1, c2);
            //var path = ColorDepthConverter.GetMostInexepnsiveConversionPath(c1, c2);
            Console.Write("{0} => {1}:  ", c1, c2);
            Console.CursorLeft = 40;

            //Console.Write("Cast: {0}", !ColorDepthConverter.ConversionPathCopiesData(path));
            Console.CursorLeft = 55;

            if (path.Count == 0)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("NO PATH");
                Console.ResetColor();
                return;
            }
            else if (path.CopiesData() == false)
            {
                Console.ForegroundColor = ConsoleColor.Blue;
                Console.WriteLine("cast");
                Console.ResetColor();
                return;
            }

            Console.ForegroundColor = ConsoleColor.Green;
            foreach (var stage in path)
            {
                Console.Write("=>  ({0} => {1})", stage.Source, stage.Destination);
            }
            Console.ResetColor();

            Console.WriteLine();
        }
        protected void SaveData()
        {
            try
            {
                if (vID != null)
                {
                    //Edit on the object.
                    int Id;
                    if (int.TryParse(vID.ToString(), out Id))
                    {
                        ColorInfo obj = ColorManager.Select(Id);
                        obj.Colorname = txtName.Text;
                        obj.Status    = int.Parse(txtOrder.Text);
                        ColorManager.Update(obj);
                    }
                }
                else
                {
                    //this is a new object.
                    ColorInfo obj = new ColorInfo();
                    obj.Colorname = txtName.Text;
                    obj.Status    = int.Parse(txtOrder.Text);
                    ColorManager.Insert(obj);
                }

                lblMessage.Text   = "Đã lưu dữ liệu thành công!";
                EditPanel.Enabled = false;
                BindData();
                vID = null;
            }
            catch (Exception ex)
            {
                lblMessage.Text = ex.Message;
            }
        }
Beispiel #6
0
        public override void Execute(object parameter)
        {
            if (parameter == null)
            {
                return;
            }

            var color = (Color)parameter;

            ColorInfo colorInfo = null;

            if (color.A == 0 && color != Colors.Transparent)
            {
                return;
            }

            if (color == Colors.Transparent)
            {
                colorInfo = ColorInfo.Automatic;
            }
            else
            {
                colorInfo = new ColorInfo(color);
            }

            var editor    = this.Adapter.Editor;
            var selection = editor.Selection;

            if (selection != null)
            {
                selection.ApplyTextForecolor(colorInfo);
            }
        }
Beispiel #7
0
        public static SolidColorBrush GetBrush(this Color color, RenderTarget renderTarget)
        {
            var ci = color.Tag as ColorInfo;

            if (ci != null)
            {
                if (ci.Target != renderTarget)
                {
                    ci = null;
                }
            }

            if (ci == null)
            {
                ci = new ColorInfo {
                    Target = renderTarget,
                    Brush  = new SolidColorBrush(
                        renderTarget,
                        new Color4(color.RedValue, color.GreenValue, color.BlueValue, color.AlphaValue)),
                };
                color.Tag = ci;
            }

            return(ci.Brush);
        }
Beispiel #8
0
 public DefaultOptionPage()
 {
     foreach (var colorKey in ColorKeyList)
     {
         _colorMap[colorKey] = new ColorInfo(colorKey, Color.Black);
     }
 }
        private PointF GetLocationInCanvas(Canvas canvas, ColorInfo colorInfo)
        {
            var left  = _canvasScreenWidthRatio * colorInfo.Point.X;
            var right = _canvasScreenHeightRatio * colorInfo.Point.Y;

            return(new PointF(left, right));
        }
Beispiel #10
0
        public static void OnGridPresetsClick(ItemGrid sender, ItemGridCellClickEvent itemClicked)
        {
            try
            {
                CASMakeup ths = CASMakeup.gSingleton;
                if (ths == null)
                {
                    return;
                }

                ths.UpdatePresetState();
                if (itemClicked.mTag is ResourceKey)
                {
                    ResourceKey mTag = (ResourceKey)itemClicked.mTag;
                    ColorInfo   info = ColorInfo.FromResourceKey(mTag);

                    CASPart part = (CASPart)ths.mGridMakeupParts.SelectedTag;

                    ths.SetMakeupColors(part, info.Colors, true, false);
                    Audio.StartSound("ui_tertiary_button");

                    ths.mCurrentPreset = new CASPartPreset(part, null);
                }
            }
            catch (Exception e)
            {
                Common.Exception("OnGridPresetsClick", e);
            }
        }
        private static void addGenericConversions()
        {
            var colors = graph.GetVertices <ColorInfo, ConversionData <ColorInfo> >().ToList();

            foreach (var genericColor in genericColors)
            {
                foreach (var color in colors)
                {
                    var genericColorInfo = ColorInfo.GetInfo(genericColor.GetType(), color.ChannelType);

                    if (color.NumberOfChannels != genericColorInfo.NumberOfChannels)
                    {
                        continue;
                    }

                    Add(ConversionData <ColorInfo> .AsCast
                        (
                            source: genericColorInfo,
                            destination: color
                        ));

                    Add(ConversionData <ColorInfo> .AsCast
                        (
                            source: color,
                            destination: genericColorInfo
                        ));
                }
            }
        }
 public SeriesModel()
 {
     id         = 0;
     seriesName = "Series Name";
     colorInfo  = new ColorInfo();
     colorInfo.SetColorInfo("Red", Colors.Red);
 }
        static void writeColorConversionPath(ColorInfo c1, ColorInfo c2)
        {
            var path = ColorDepthConverter.GetPath(c1, c2);

            //var path = ColorDepthConverter.GetMostInexepnsiveConversionPath(c1, c2);
            Console.Write("{0} => {1}:  ", c1, c2);
            Console.CursorLeft = 40;

            //Console.Write("Cast: {0}", !ColorDepthConverter.ConversionPathCopiesData(path));
            Console.CursorLeft = 55;

            if (path.Count == 0)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("NO PATH");
                Console.ResetColor();
                return;
            }
            else if (path.CopiesData() == false)
            {
                Console.ForegroundColor = ConsoleColor.Blue;
                Console.WriteLine("cast");
                Console.ResetColor();
                return;
            }

            Console.ForegroundColor = ConsoleColor.Green;
            foreach (var stage in path)
            {
                Console.Write("=>  ({0} => {1})", stage.Source, stage.Destination);
            }
            Console.ResetColor();

            Console.WriteLine();
        }
Beispiel #14
0
 protected override Person Create(Type objectType, JObject jObject)
 {
     if (FieldExists("favoriteColor ", jObject))
     {
         return new Person() { favoriteColor = new ColorInfo() { Color = "Red" };
     }
 }
Beispiel #15
0
        public void OnProtoSerialize(ProtobufSerializer serializer)
        {
            PrefabIdentifier prefabIdentifier = GetComponentInParent <PrefabIdentifier>();

            if ((prefabIdentifier ??= GetComponent <PrefabIdentifier>()) is null)
            {
                return; // return if we couldn't find a PrefabIdentifier component anywhere.
            }
            string saveFolder = Main.GetSaveFolderPath();

            if (!Directory.Exists(saveFolder))
            {
                Directory.CreateDirectory(saveFolder);
            }


            Light light = this.gameObject.GetComponentInChildren <Light>();

            ColorInfo colorInfo = new ColorInfo()
            {
                RedLevel   = light.color.r,
                GreenLevel = light.color.g,
                BlueLevel  = light.color.b,
            };

            if (light != null)
            {
                string filePath = Main.Combine(saveFolder, prefabIdentifier.Id + ".json");
                using (StreamWriter writer = new StreamWriter(filePath))
                {
                    writer.Write(JsonConvert.SerializeObject(colorInfo, Formatting.Indented));
                }
                _savedColor = new Color(colorInfo.RedLevel, colorInfo.GreenLevel, colorInfo.BlueLevel);
            }
        }
Beispiel #16
0
        public EnergyDataMod(EnergyDefinition def, AssetProvider assetProvider)
            : base(def.id, false)
        {
            BurstSprites  = def.burstSprites?.Select(x => new SpriteInfo(x, assetProvider)).ToList();
            TrailSprites  = def.trailSprites?.Select(x => new SpriteInfo(x, assetProvider)).ToList();
            SplashSprites = def.splashSprites?.Select(x => new SpriteInfo(x, assetProvider)).ToList();
            SurgeSprites  = def.surgeSprites?.Select(x => new SpriteInfo(x, assetProvider)).ToList();
            assetProvider.NameAndAddAsset(ref TextMaterialName, def.textMaterial);
            SurgeExpression     = def.surgeExpression;
            SurgeEyesClosed     = def.surgeEyesClosed;
            NegSurgeExpression  = def.negSurgeExpression;
            NegSurgeEyesClosed  = def.negSurgeEyesClosed;
            BossSurgeExpression = def.bossSurgeExpression;
            BossSurgeEyesClosed = def.bossSurgeEyesClosed;

            if (def.textColor != null)
            {
                TextColorInfo = new ColorInfo(def.textColor);
            }
            if (def.outlineColor != null)
            {
                OutlineColorInfo = new ColorInfo(def.outlineColor);
            }
            if (def.shadowColor != null)
            {
                ShadowColorInfo = new ColorInfo(def.shadowColor);
            }
            if (def.surgeColor != null)
            {
                SurgeColorInfo = new ColorInfo(def.surgeColor);
            }
        }
Beispiel #17
0
 public EnergyDataMod(int id,
                      List <SpriteInfo> burstSprites,
                      List <SpriteInfo> trailSprites,
                      List <SpriteInfo> splashSprites,
                      List <SpriteInfo> surgeSprites,
                      string textMaterialName,
                      ColorInfo textColorInfo,
                      ColorInfo outlineColorInfo,
                      ColorInfo shadowColorInfo,
                      ColorInfo surgeColorInfo,
                      GirlExpressionType?surgeExpression,
                      bool?surgeEyesClosed,
                      GirlExpressionType?negSurgeExpression,
                      bool?negSurgeEyesClosed,
                      GirlExpressionType?bossSurgeExpression,
                      bool?bossSurgeEyesClosed,
                      bool isAdditive = false)
     : base(id, isAdditive)
 {
     BurstSprites        = burstSprites;
     TrailSprites        = trailSprites;
     SplashSprites       = splashSprites;
     SurgeSprites        = surgeSprites;
     TextMaterialName    = textMaterialName;
     TextColorInfo       = textColorInfo;
     OutlineColorInfo    = outlineColorInfo;
     ShadowColorInfo     = shadowColorInfo;
     SurgeColorInfo      = surgeColorInfo;
     SurgeExpression     = surgeExpression;
     SurgeEyesClosed     = surgeEyesClosed;
     NegSurgeExpression  = negSurgeExpression;
     NegSurgeEyesClosed  = negSurgeEyesClosed;
     BossSurgeExpression = bossSurgeExpression;
     BossSurgeEyesClosed = bossSurgeEyesClosed;
 }
Beispiel #18
0
    private void Awake()
    {
        ColorInfo color = EnemyHandler.instance.colorInfo;

        GetComponent <EnemyStats>().material = color.mat;
        gameObject.tag = color.color;
    }
        private void PerformClassification(List <Bitmap> circles, List <Bitmap> triangles, List <Bitmap> rectangles, ImageViewModel viewModel)
        {
            var signData = new Dictionary <Bitmap, Sign>();

            foreach (var circle in circles)
            {
                var colorInfo = ColorInfo.Extract(circle);
                signData.Add(circle, new Sign(100, colorInfo[0], colorInfo[1], colorInfo[2], colorInfo[3]));
            }
            foreach (var triangle in triangles)
            {
                var colorInfo = ColorInfo.Extract(triangle);
                signData.Add(triangle, new Sign(50, colorInfo[0], colorInfo[1], colorInfo[2], colorInfo[3]));
            }
            foreach (var rectangle in rectangles)
            {
                var colorInfo = ColorInfo.Extract(rectangle);
                signData.Add(rectangle, new Sign(150, colorInfo[0], colorInfo[1], colorInfo[2], colorInfo[3]));
            }

            var containers = new[]
            {
                null, viewModel.WarningSigns, viewModel.ProhibitingSigns, viewModel.RegulatorySigns, viewModel.InformationSigns,
                viewModel.TemporarySigns
            };

            var tc = new PrebuildSignsClassifier();

            tc.Teach();
            foreach (var sign in signData)
            {
                var classIndex = tc.FindClass(sign.Value);
                containers[classIndex].Add(new ImageModel(BitmapConverter.GetBitmapSource(sign.Key)));
            }
        }
Beispiel #20
0
    public static void SaveColors(ColorInfo info)
    {
        BinaryFormatter bf   = new BinaryFormatter();
        FileStream      file = File.Create(Application.persistentDataPath + colorInfoFileName);

        bf.Serialize(file, ConvertColorInfoToColorData(info));
        file.Close();
    }
        /// <summary>
        /// Gets the conversion path.
        /// <para>If the conversion is not allowed or does not exist an empty list is returned.</para>
        /// </summary>
        /// <param name="src">Source color.</param>
        /// <param name="dst">Destination color.</param>
        /// <returns>Conversion path.</returns>
        public static List <ConversionData <ColorInfo> > GetPath(this ColorInfo src, ColorInfo dst)
        {
            List <ConversionData <ColorInfo> > path;

            shorthestPaths.TryGetValue(src, dst, out path);

            return(path ?? new List <ConversionData <ColorInfo> >());
        }
Beispiel #22
0
 public static ColorInfo FromXml(System.Xml.Linq.XElement el)
 {
     var c = new ColorInfo();
     c.Category = el.Attribute("Category").Value;
     c.Name= el.Attribute("Name").Value;
     c.rgb = int.Parse(el.Attribute("RGB").Value.Substring(1),System.Globalization.NumberStyles.HexNumber);
     return c;
 }
 public VisibleContainer(int id, ColorInfo color)
 {
     AddChild(new Rectangle {
         RelativeSizeAxes = Axes.Both, Color = color
     });
     AddChild(spriteText = new SpriteText {
         RelativeSizeAxes = Axes.Both, Offset = new(10)
     });
 /// <summary>
 /// Returns conversion data when source image has to be returned.
 /// </summary>
 /// <param name="source">Source's image color info.</param>
 /// <returns>Conversion info.</returns>
 public static ConversionData <ColorInfo> AsReturnSource(ColorInfo source)
 {
     return(new ConversionData <ColorInfo>(source,
                                           source,
                                           (srcImg, dstImg) => { }, true,
                                           (srcImg, destColor) => srcImg,
                                           ConversionCost.ReturnSource));
 }
        private void CopyCommandHandler(ColorInfo colorInfo)
        {
            var str =
                $"await WindowsApi.ScreenApi.WaitColorAt({colorInfo.Point.X}, {colorInfo.Point.Y}, Color.FromArgb({colorInfo.Color.R}, {colorInfo.Color.G}, {colorInfo.Color.B}));";

            Clipboard.SetDataObject(str);
            PromptHelper.Instance.Prompt = str;
        }
 public TaskViewModel(string name, ColorInfo colorInfo, TimeInfoViewModel originalTime)
 {
     this.name         = name;
     this.colorInfo    = colorInfo;
     this.originalTime = originalTime;
     this.elapsedTime.PropertyChanged  += ElapsedTime_PropertyChanged;
     this.originalTime.PropertyChanged += OriginalTime_PropertyChanged;
 }
        private void CopyColumnCommandHandler(ColorInfo colorInfo)
        {
            var str =
                $"await WindowsApi.ScreenApi.WaitScanColorLocation(Color.FromArgb({colorInfo.Color.R}, {colorInfo.Color.G}, {colorInfo.Color.B}), WindowsApi.ScreenApi.AllScreens[{SelectedScreenInfo.Index}], WindowsApi.ScreenApi.AllScreens[{SelectedScreenInfo.Index}].GetScreenColumn({colorInfo.Point.X - Buffer / 2}, {Buffer}));";

            Clipboard.SetDataObject(str);
            PromptHelper.Instance.Prompt = str;
        }
        public SyntaxHighlighter(ExpressionTextBox textbox)
        {
            m_TextBox = textbox;

            m_TextBox.AfterUndo += m_TextBox_AfterUndo;
            m_TextBox.AfterRedo += m_TextBox_AfterRedo;
            m_TextBox.UndoEntryAdded += m_TextBox_UndoEntryAdded;

            m_ColorInfo = new ColorInfo(m_TextBox.BackColor);
        }
 // ------------------------------------------------------------------
 // Desc:
 // ------------------------------------------------------------------
 public void RegisterAllChildren()
 {
     colorInfos.Clear();
     exSpriteBase[] sprites = GetComponentsInChildren<exSpriteBase>();
     for ( int i = 0; i < sprites.Length; ++i ) {
         ColorInfo colorInfo = new ColorInfo();
         exSpriteBase sprite = sprites[i];
         colorInfo.sprite = sprite;
         colorInfo.color = sprite.color;
         colorInfos.Add(colorInfo);
     }
 }
		private void InitFonts() {

			Colors = new ColorInfo();

			if (VisualStyleRenderer.IsSupported) {
				VisualStyleRenderer contentLink = VisualStyles.ControlPanel.GetRenderer(VisualStyles.ControlPanel.ControlPanelPart.ContentLink, (int)VisualStyles.ControlPanel.ContentLinkState.Normal, true);

				using (Graphics g = Graphics.FromHwnd(IntPtr.Zero)) {
					Colors.ContentLinkNormal = contentLink.GetColor(ColorProperty.TextColor);

					contentLink = VisualStyles.ControlPanel.GetRenderer(VisualStyles.ControlPanel.ControlPanelPart.ContentLink, (int)VisualStyles.ControlPanel.ContentLinkState.Hot, true);

					Colors.ContentLinkHot = contentLink.GetColor(ColorProperty.TextColor);
				}
			}

		}
 public PatternFill(PatternType pattern, ColorInfo bgColor, ColorInfo fgColor)
 {
     Pattern = pattern;
     BgColor = bgColor;
     FgColor = fgColor;
 }
Beispiel #32
0
        public void SetSize(Size size)
        {
            Size = size;

            Text = new char[Height, Width];
            Colors = new ColorInfo[Height, Width];
            Cursor = new Point(0, 0);
        }
Beispiel #33
0
 public TextBuffer(Size size)
 {
     SetSize(size);
     CurrentColor = new ColorInfo(ConsoleColor.DarkRed, ConsoleColor.White);
 }
 public BorderLine(LineStyle style, ColorInfo color)
 {
     Style = style;
     Color = color;
 }
 public GradientStop(double position, ColorInfo color)
 {
     Position = position;
     Color = color;
 }
    public void RegisterColor( exSpriteBase _sprite )
    {
        bool founded = false;
        for ( int i = 0; i < colorInfos.Count; ++i ) {
            ColorInfo colorInfo = colorInfos[i];
            if ( colorInfo.sprite == _sprite ) {
                colorInfo.color = _sprite.color;
                founded = true;
            }
        }

        if ( founded == false ) {
            ColorInfo colorInfo = new ColorInfo();
            colorInfo.sprite = _sprite;
            colorInfo.color = _sprite.color;
            colorInfos.Add(colorInfo);
        }
    }
Beispiel #37
0
 public void OnHairPresetAppliedProxy(BodyTypes bodyType, ColorInfo hairColors)
 {
     try
     {
         if (OnHairPresetApplied != null)
         {
             OnHairPresetApplied(bodyType, hairColors);
         }
     }
     catch (Exception e)
     {
         Common.Exception("OnHairPresetAppliedProxy", e);
     }
 }
Beispiel #38
0
        /// <summary>
        /// Populate control with standard <see cref="Color"/>s.
        /// </summary>
        public void AddStandardColors(ColorInfo customColor = null)
        {
            Items.Clear();

              Items.Add(ColorInfo.FromColor(Color.Black));
              Items.Add(ColorInfo.FromColor(Color.Blue));
              Items.Add(ColorInfo.FromColor(Color.Lime));
              Items.Add(ColorInfo.FromColor(Color.Cyan));
              Items.Add(ColorInfo.FromColor(Color.Red));
              Items.Add(ColorInfo.FromColor(Color.Fuchsia));
              Items.Add(ColorInfo.FromColor(Color.Yellow));
              Items.Add(ColorInfo.FromColor(Color.White));
              Items.Add(ColorInfo.FromColor(Color.Navy));
              Items.Add(ColorInfo.FromColor(Color.Green));
              Items.Add(ColorInfo.FromColor(Color.Teal));
              Items.Add(ColorInfo.FromColor(Color.Maroon));
              Items.Add(ColorInfo.FromColor(Color.Purple));
              Items.Add(ColorInfo.FromColor(Color.Olive));
              Items.Add(ColorInfo.FromColor(Color.Gray));

              if (customColor != null)
              {
            Items.Add(customColor);
              }
        }
Beispiel #39
0
        private void LoadColorsCore(IVsFontAndColorStorage vsStorage)
        {
            foreach (var colorKey in ColorKeyList)
            {
                ColorInfo colorInfo;
                try
                {
                    var color = LoadColor(vsStorage, colorKey);
                    colorInfo = new ColorInfo(colorKey, color);
                }
                catch (Exception ex)
                {
                    VimTrace.TraceError(ex);
                    colorInfo = new ColorInfo(colorKey, Color.Black, isValid: false);
                }

                _colorMap[colorKey] = colorInfo;
            }
        }
Beispiel #40
0
        private static void OnColorsSaved(Color[] colors)
        {
            try
            {
                CASMakeup ths = CASMakeup.gSingleton;
                if (ths == null) return;

                bool flag = false;
                bool flag2 = false;
                if (CASMakeup.sCategory != BodyTypes.CostumeMakeup)
                {
                    foreach (ItemGridCellItem item in ths.mGridMakeupPresets.Items)
                    {
                        flag2 = true;
                        ResourceKey mTag = (ResourceKey)item.mTag;
                        ColorInfo info = ColorInfo.FromResourceKey(mTag);
                        for (int i = 0x0; i < info.Colors.Length; i++)
                        {
                            Vector3 vector = CompositorUtil.ColorToVector3(colors[i]);
                            Vector3 v = CompositorUtil.ColorToVector3(info.Colors[i]);
                            if (!vector.IsSimilarTo(v))
                            {
                                flag2 = false;
                                break;
                            }
                        }
                        if (flag2)
                        {
                            break;
                        }
                    }

                    if (!flag2)
                    {
                        ColorInfo info2 = new ColorInfo();
                        info2.Usage = ColorInfo.PreferredUse.Makeup;
                        switch (CASMakeup.sCategory)
                        {
                            case BodyTypes.FirstFace:
                                info2.UsageSubCategory = ColorInfo.eUsageSubCategory.MakeupLipstick;
                                break;

                            case BodyTypes.EyeShadow:
                                info2.UsageSubCategory = ColorInfo.eUsageSubCategory.MakeupEyeshadow;
                                break;

                            case BodyTypes.EyeLiner:
                                info2.UsageSubCategory = ColorInfo.eUsageSubCategory.MakeupEyeliner;
                                break;

                            case BodyTypes.Blush:
                                info2.UsageSubCategory = ColorInfo.eUsageSubCategory.MakeupBlush;
                                break;
                        }
                        info2.Colors = colors;
                        flag = info2.SaveMakeupPreset(info2.UsageSubCategory) != ResourceKey.kInvalidResourceKey;
                        ths.PopulatePresetsGrid(CASMakeup.sCategory, ths.mCurrentPreset.mPart, ths.mButtonFilter.Selected);
                    }
                }
                else
                {
                    CASPart wornPart = ths.mCurrentPreset.mPart;

                    ObjectDesigner.SetCASPart(wornPart.Key);
                    Vector3[] makeupVectorColors = ths.GetMakeupVectorColors(wornPart);
                    uint num = CASUtils.PartDataNumPresets(wornPart.Key);
                    for (uint j = 0x0; j < num; j++)
                    {
                        KeyValuePair<string, Dictionary<string, Complate>> presetEntryFromPresetString = (KeyValuePair<string, Dictionary<string, Complate>>)SimBuilder.GetPresetEntryFromPresetString(CASUtils.PartDataGetPreset(wornPart.Key, j));
                        Vector3[] vectorArray2 = ths.GetMakeupVectorColors(presetEntryFromPresetString);
                        flag2 = true;
                        for (uint k = 0x0; k < vectorArray2.Length; k++)
                        {
                            if (!makeupVectorColors[k].IsSimilarTo(vectorArray2[k]))
                            {
                                flag2 = false;
                                break;
                            }
                        }
                        if (flag2)
                        {
                            break;
                        }
                    }

                    if (!flag2)
                    {
                        uint index = ObjectDesigner.AddDesignPreset(Responder.Instance.CASModel.GetDesignPreset(wornPart));
                        flag = index != uint.MaxValue;
                        CASClothingRow row = ths.FindRow(wornPart);
                        if (row != null)
                        {
                            row.CreateGridItems(true);
                            row.PopulateGrid(true);
                        }
                        ths.mButtonCostumeFilter.Tag = true;
                        ths.mContentTypeFilter.UpdateFilterButtonState();
                        ThumbnailKey key = new ThumbnailKey(wornPart.Key, (int)CASUtils.PartDataGetPresetId(wornPart.Key, index), (uint)wornPart.BodyType, (uint)wornPart.AgeGenderSpecies, ThumbnailSize.Large);
                        ThumbnailManager.InvalidateThumbnail(key);
                    }
                }

                if (flag)
                {
                    CASController.Singleton.ErrorMsg(CASErrorCode.SaveSuccess);
                }
                else if (flag2)
                {
                    Simulator.AddObject(new OneShotFunctionTask(delegate
                    {
                        string messageText = Responder.Instance.LocalizationModel.LocalizeString("Ui/Caption/CAS/Hair:SaveDuplicate", new object[0x0]);
                        SimpleMessageDialog.Show(null, messageText, ModalDialog.PauseMode.PauseTask, new Vector2(-1f, -1f), "ui_error", "ui_hardwindow_close");
                    }));
                }
                else
                {
                    CASController.Singleton.ErrorMsg(CASErrorCode.SaveFailed);
                }
            }
            catch (Exception e)
            {
                Common.Exception("OnColorsSaved", e);
            }
        }