Esempio n. 1
0
        void CreateRBGScrollBarAndSampleColorBox(
            int x, int y,
            out ScrollBar scBar,
            out SimpleBox sampleBox,
            SimpleAction <ScrollBar, SimpleBox> pairAction
            )
        {
            //horizontal scrollbar
            scBar = new LayoutFarm.CustomWidgets.ScrollBar(300, 15);

            //TODO: add mx with layout engine
            scBar.ScrollBarType = CustomWidgets.ScrollBarType.Horizontal;
            scBar.SetLocation(x, y);
            scBar.MinValue    = 0;
            scBar.MaxValue    = 255 * 10;
            scBar.SmallChange = 1;
            //
            scBar.ScrollValue = 0; //init
                                   //
            sampleBox = new SimpleBox(30, 30);
            sampleBox.SetLocation(x + 350, y);
            //
            var n_scBar     = scBar;
            var n_sampleBox = sampleBox;

            scBar.SliderBox.UserScroll += (s, e) => pairAction(n_scBar, n_sampleBox);

            pairAction(n_scBar, n_sampleBox);
        }
Esempio n. 2
0
 void CreateHsvVarBoxes(SampleViewport viewport, int x, int y)
 {
     hsv_varBoxes = new SimpleBox[9];
     for (int i = 0; i < 9; ++i)
     {
         SimpleBox hsv_varBox = new SimpleBox(40, 40);
         hsv_varBox.SetLocation(x + (i * 40), y);
         hsv_varBoxes[i] = hsv_varBox;
         viewport.AddContent(hsv_varBox);
     }
 }
Esempio n. 3
0
 void CreateSwatchBoxes(SampleViewport viewport, int x, int y)
 {
     swatch_Boxes = new SimpleBox[6];
     for (int i = 0; i < 6; ++i)
     {
         SimpleBox swatchBox = new SimpleBox(40, 40);
         swatchBox.SetLocation(x + (i * 40), y);
         swatch_Boxes[i] = swatchBox;
         viewport.AddContent(swatchBox);
     }
 }
Esempio n. 4
0
 void CreateRBGVarBoxes(SampleViewport viewport, int x, int y)
 {
     rgb_varBoxes = new SimpleBox[7];
     for (int i = 0; i < 7; ++i)
     {
         SimpleBox rgb_varBox = new SimpleBox(40, 40);
         rgb_varBox.SetLocation(x + (i * 40), y);
         rgb_varBoxes[i] = rgb_varBox;
         viewport.AddContent(rgb_varBox);
     }
 }
        void GenerateAnimation(PennerAnimationGeneratorDelegate pennerAnimator)
        {
            float startValue       = 0;
            float stopValue        = 300;
            float sec              = 0;
            float completeDuration = 10;

            animationBoard.ClearChildren();

            List <double> calculatedValues = new List <double>();

            while (sec < completeDuration)
            {
                double currentValue = pennerAnimator(sec, startValue, stopValue, completeDuration);
                //step 0.1 sec (100 ms), until complete at 5 sec
                sec += 0.1f;
                calculatedValues.Add(currentValue);
                //System.Console.WriteLine(currentValue.ToString());
            }

            //create image box that present the results
            int j = calculatedValues.Count;

            for (int i = 0; i < j; ++i)
            {
                SimpleBox box = new SimpleBox(5, 5);
                box.SetLocation(5 * i, (int)calculatedValues[i]);
                animationBoard.AddChild(box);
            }

            //-----
            //show animation

            SimpleBox sampleBox1 = new SimpleBox(600, 20);

            animationBoard.AddChild(sampleBox1);
            sampleBox1.BackColor = PixelFarm.Drawing.Color.Red;
            int step = 0;

            UIPlatform.RegisterTimerTask(10, tim =>
            {
                //animate the box
                sampleBox1.SetLocation(10, (int)calculatedValues[step]);
                if (step < j - 1)
                {
                    step++;
                }
                else
                {
                    //unregister and remove the task
                    tim.Remove();
                }
            });
        }
Esempio n. 6
0
        protected override void OnStartDemo(SampleViewport viewport)
        {
            colorMatch = new ColorMatch();
            colorMatch.VariationsRGB = new RGB[7];
            colorMatch.VariationsHSV = new RGB[9];
            blenderAlgo = colorMatch.Algorithms[0];
            //

            {
                lstvw_blendAlgo = new ListView(200, 400);
                lstvw_blendAlgo.SetLocation(500, 20);
                viewport.AddContent(lstvw_blendAlgo);
                lstvw_blendAlgo.ListItemMouseEvent += (s, e) =>
                {
                    if (lstvw_blendAlgo.SelectedIndex > -1)
                    {
                        blenderAlgo = colorMatch.Algorithms[lstvw_blendAlgo.SelectedIndex];
                        UpdateAllComponents();
                    }
                };

                //add item
                foreach (IAlgorithm algo in colorMatch.Algorithms)
                {
                    ListItem listItem = new ListItem(200, 20);
                    listItem.Text = algo.GetType().Name;
                    listItem.Tag  = algo;
                    lstvw_blendAlgo.AddItem(listItem);
                }
            }

            //start RGB value
            byte r_value = 200;
            byte g_value = 46;
            byte b_value = 49;


            CreateRBGVarBoxes(viewport, 20, 250);
            CreateHsvVarBoxes(viewport, 20, 300);
            CreateSwatchBoxes(viewport, 20, 350);

            {
                pure_rgbBox           = new SimpleBox(50, 50);
                pure_rgbBox.BackColor = new PixelFarm.Drawing.Color(
                    (byte)r_value,
                    (byte)b_value,
                    (byte)g_value);
                pure_rgbBox.SetLocation(0, 0);
                viewport.AddContent(pure_rgbBox);
            }

            //R
            {
                CreateRBGScrollBarAndSampleColorBox(80, 80, out r_sc, out r_sampleBox, (n_scrollBar, n_sampleBox) =>
                {
                    if (_component_ready)
                    {
                        n_sampleBox.BackColor = new PixelFarm.Drawing.Color((byte)(n_scrollBar.ScrollValue / 10), 0, 0);
                        UpdateAllComponents();
                    }
                });
                viewport.AddContent(r_sc);
                viewport.AddContent(r_sampleBox);
            }
            //G
            {
                CreateRBGScrollBarAndSampleColorBox(80, 120, out g_sc, out g_sampleBox, (n_scrollBar, n_sampleBox) =>
                {
                    if (_component_ready)
                    {
                        n_sampleBox.BackColor = new PixelFarm.Drawing.Color(0, (byte)(n_scrollBar.ScrollValue / 10), 0);
                        UpdateAllComponents();
                    }
                });
                viewport.AddContent(g_sc);
                viewport.AddContent(g_sampleBox);
            }
            //B
            {
                CreateRBGScrollBarAndSampleColorBox(80, 160, out b_sc, out b_sampleBox, (n_scrollBar, n_sampleBox) =>
                {
                    if (_component_ready)
                    {
                        n_sampleBox.BackColor = new PixelFarm.Drawing.Color(0, 0, (byte)(n_scrollBar.ScrollValue / 10));
                        UpdateAllComponents();
                    }
                });
                viewport.AddContent(b_sc);
                viewport.AddContent(b_sampleBox);
            }
            _component_ready = true;
        }