Exemplo n.º 1
0
        public void UpdateFromModel(GuildShieldInfo Model, bool RaiseChangedEvent)
        {
            if (RaiseChangedEvent)
            {
                GuildID   = Model.GuildID;
                GuildName = Model.GuildName;
                Color1    = Model.Color1;
                Color2    = Model.Color2;
                Design    = Model.Design;
            }
            else
            {
                guildID   = Model.GuildID;
                guildName = Model.GuildName;
                color1    = Model.Color1;
                color2    = Model.Color2;
                design    = Model.Design;

                // update examplemodel
                exampleModel.ColorTranslation = ColorTransformation.GetGuildShieldColor(color1, color2);

                if (design > 0 && shields != null && shields.Length > (design - 1))
                {
                    exampleModel.OverlayFileRID = shields[design - 1].Value;
                    exampleModel.OverlayFile    = shields[design - 1].Name;
                    exampleModel.Resource       = shields[design - 1].Resource;
                }
            }
        }
Exemplo n.º 2
0
        public ComboBoxPalette()
            : base()
        {
            DropDownStyle = ComboBoxStyle.DropDownList;

            string prefix;

            for (int i = 0; i < ColorTransformation.Palettes.Length; i++)
            {
                if (i < 10)
                {
                    prefix = "00";
                }
                else if (i < 100)
                {
                    prefix = "0";
                }
                else
                {
                    prefix = String.Empty;
                }

                Items.Add("(" + prefix + i.ToString() + ") - " + ColorTransformation.GetNameOfPalette((byte)i));
            }

            SelectedIndex = 0;
        }
Exemplo n.º 3
0
        public void Clear(bool RaiseChangedEvent)
        {
            if (RaiseChangedEvent)
            {
                GuildID   = new ObjectID();
                GuildName = DESIGNNOTAVAILABLE;
                Color1    = WHITECOLOR;
                Color2    = WHITECOLOR;
                Design    = 1;
            }
            else
            {
                guildID   = new ObjectID();
                guildName = DESIGNNOTAVAILABLE;
                color1    = WHITECOLOR;
                color2    = WHITECOLOR;
                design    = 1;

                // update examplemodel
                exampleModel.ColorTranslation = ColorTransformation.GetGuildShieldColor(color1, color2);

                if (design > 0 && shields != null && shields.Length > (design - 1))
                {
                    exampleModel.OverlayFileRID = shields[design - 1].Value;
                    exampleModel.OverlayFile    = shields[design - 1].Name;
                    exampleModel.Resource       = shields[design - 1].Resource;
                }
            }
        }
Exemplo n.º 4
0
        public void Should_not_break_for_invalid_input(string testCase)
        {
            var input = testCase switch
            {
                "wrong type" => new object(),
                "exception on decode" => "#kennadecode"
            };

            var source = Observable.Return(input);

            var transformation = new ColorTransformation(new ColorTransformationOptions());

            var scheduler = new TestScheduler();


            var actual = scheduler.Start(
                () => transformation.GetOperator()(source),
                created: 0,
                subscribed: 0,
                disposed: 100
                );


            var expected = new Recorded <Notification <Ref <Color> > >[] {
                OnCompleted <Ref <Color> >(1)
            };

            ReactiveAssert.AreElementsEqual(expected, actual.Messages);
        }
    }
Exemplo n.º 5
0
        public void Should_transform_color_using_given_channel_layout()
        {
            var black         = "#FF0000";
            var expectedColor = new Ref <Color>(Color.FromArgb(255, 0, 255, 0));
            var source        = Observable.Return(black);

            var transformation = new ColorTransformation(new ColorTransformationOptions()
            {
                ChannelLayout = "GRB"
            });

            var scheduler = new TestScheduler();


            var actual = scheduler.Start(
                () => transformation.GetOperator()(source),
                created: 0,
                subscribed: 10,
                disposed: 100
                );

            var expected = new Recorded <Notification <Ref <Color> > >[] {
                OnNext(10, expectedColor),
                OnCompleted <Ref <Color> >(10)
            };

            ReactiveAssert.AreElementsEqual(expected, actual.Messages);
        }
        public ComboBoxPalette()
            : base()
        {
            DropDownStyle = ComboBoxStyle.DropDownList;

            string prefix;

            for (int i = 0; i < ColorTransformation.Palettes.Length; i++)
            {
                if (i < 10)
                {
                    prefix = "00";
                }
                else if (i < 100)
                {
                    prefix = "0";
                }
                else
                {
                    prefix = String.Empty;
                }

                Items.Add("(" + prefix + i.ToString() + ") - " + ColorTransformation.GetNameOfPalette((byte)i));
            }

            // add the special legacy vale palette last
            Items.Add("(999) - VALE OF SORROW)");

            SelectedIndex = 0;
        }
Exemplo n.º 7
0
        /// <summary>
        /// Generic method that loops through an multidimensional array of a color format and
        /// applies a method to the function
        /// </summary>
        /// <param name="colorArray">Multi Dimensional array of color encodings</param>
        /// <param name="convertMethod">The method used to convert T into T2</param>
        /// <typeparam name="T">Input color encoding</typeparam>
        /// <typeparam name="T2">Output color enconding</typeparam>
        /// <returns>Multi dimensional array of color encodings</returns>
        private T[,] ExecuteColorSpaceTransformation <T, T2>(T2[,] colorArray, ColorTransformation <T, T2> transformation)
        {
            int width  = colorArray.GetLength(0);
            int height = colorArray.GetLength(1);

            T[,] convertedColours = new T[width, height];
            for (int x = 0; x < width; x++)
            {
                for (int y = 0; y < height; y++)
                {
                    convertedColours[x, y] = transformation(colorArray[x, y]);
                }
            }

            return(convertedColours);
        }
Exemplo n.º 8
0
        /// <summary>
        /// Hozzáad az összes mezõhöz egy random transzformált képpel rendelkezõ mezõt. A mezõ sor és oszlopadata a paraméterben meghatározott
        /// </summary>
        /// <param name="column"></param>
        /// <param name="row"></param>
        private void AddRandomFieldToAllFields(Difficulty difficulty, int column, int row)
        {
            int           randomImage = random.Next(imageList.Count);
            Transformator trf;

            switch (random.Next(5))
            {
            case (0): trf = new Rotate(difficulty, random.Next()); break;

            case (1): trf = new Mirror(difficulty, random.Next()); break;

#if WINDOWS
            case (2): trf = new Blur(difficulty, random.Next()); break;
#endif
            case (3): trf = new ColorTransformation(difficulty, random.Next()); break;

            default: trf = new Transformator(difficulty, random.Next()); break;
            }
            Field field = new Field(imageList[randomImage], randomImage, column, row, true, trf);
            AllFields.Add(field);
        }