Esempio n. 1
0
        /// <summary>
        /// The event will be triggered when fittingModeButton clicked
        /// FittingMode converts a scaling mode to the definition of which dimensions matter
        /// when box filtering as a part of that mode.
        //
        /// Shrink to fit attempts to make one or zero dimensions smaller than the
        /// desired dimensions and one or two dimensions exactly the same as the desired
        /// ones, so as long as one dimension is larger than the desired size, box
        /// filtering can continue even if the second dimension is smaller than the
        /// desired dimensions.!
        ///
        /// X Dimension is ignored by definition in FIT_HEIGHT mode
        ///
        /// Y dimension is irrelevant when downscaling in FIT_WIDTH mode
        ///
        /// Scale to fill mode keeps both dimensions at least as large as desired
        /// </summary>
        /// <param name="source">fittingModeButton.</param>
        /// <param name="e">event</param>
        /// <returns>the consume flag</returns>
        private bool FittingModeButtonClick(object source, EventArgs e)
        {
            switch (fittingMode)
            {
            case (int)FittingModeType.FitHeight:
                fittingMode = (int)FittingModeType.FitWidth;
                pngImageMap.Add(ImageVisualProperty.FittingMode, new PropertyValue((int)FittingModeType.FitWidth));
                fittingModeButton.Label = CreateText("FittingMode : FitWidth");
                break;

            case (int)FittingModeType.FitWidth:
                fittingMode = (int)FittingModeType.ScaleToFill;
                pngImageMap.Add(ImageVisualProperty.FittingMode, new PropertyValue((int)FittingModeType.ScaleToFill));
                fittingModeButton.Label = CreateText("FittingMode : ScaleToFill");
                break;

            case (int)FittingModeType.ScaleToFill:
                fittingMode = (int)FittingModeType.ShrinkToFit;
                pngImageMap.Add(ImageVisualProperty.FittingMode, new PropertyValue((int)FittingModeType.ShrinkToFit));
                fittingModeButton.Label = CreateText("FittingMode : ShrinkToFit");
                break;

            case (int)FittingModeType.ShrinkToFit:
                fittingMode = (int)FittingModeType.FitHeight;
                pngImageMap.Add(ImageVisualProperty.FittingMode, new PropertyValue((int)FittingModeType.FitHeight));
                fittingModeButton.Label = CreateText("FittingMode : FitHeight");
                break;
            }

            image.ImageMap = pngImageMap;

            return(true);
        }
Esempio n. 2
0
        public void BuilderGetConstants()
        {
            tlog.Debug(tag, $"BuilderGetConstants START");

            var testingTarget = new Builder();

            Assert.IsNotNull(testingTarget, "Should be not null!");
            Assert.IsInstanceOf <Builder>(testingTarget, "Should be an Instance of Builder!");

            using (PropertyMap map = new PropertyMap())
            {
                map.Add("Size", new PropertyValue(new Size(20, 30)));
                map.Add("Posision", new PropertyValue(new Position(100, 200)));

                testingTarget.AddConstants(map);

                var result = testingTarget.GetConstants();
                Assert.IsNotNull(result, "Should be not null!");
                Assert.IsInstanceOf <PropertyMap>(result, "Should be an Instance of PropertyMap!");
            }

            testingTarget.Dispose();
            testingTarget = null;
            tlog.Debug(tag, $"BuilderGetConstants END (OK)");
        }
Esempio n. 3
0
        public void TextMapHelperGetNullableFloatFromMap()
        {
            tlog.Debug(tag, $"TextMapHelperGetNullableFloatFromMap START");

            var   stringKey        = "width";
            var   stringInvalidKey = "invalidKey";
            var   intKey           = 1;
            var   intInvalidKey    = 10;
            float value            = 3.14f;
            float?result           = null;

            using (var map = new PropertyMap())
            {
                map.Add(stringKey, value);
                map.Add(intKey, value);

                result = TextMapHelper.GetNullableFloatFromMap(map, stringKey);
                Assert.AreEqual(value, result, "Should be equal!");

                result = TextMapHelper.GetNullableFloatFromMap(map, stringInvalidKey);
                Assert.AreEqual(null, result, "Should be equal!");

                result = TextMapHelper.GetNullableFloatFromMap(map, intKey);
                Assert.AreEqual(value, result, "Should be equal!");

                result = TextMapHelper.GetNullableFloatFromMap(map, intInvalidKey);
                Assert.AreEqual(null, result, "Should be equal!");
            }

            tlog.Debug(tag, $"TextMapHelperGetNullableFloatFromMap END (OK)");
        }
Esempio n. 4
0
        public void TextMapHelperGetHiddenInputStruct()
        {
            tlog.Debug(tag, $"TextMapHelperGetHiddenInputStruct START");

            int mode = (int)HiddenInputModeType.ShowLastCharacter;
            int substituteCharacter       = Convert.ToInt32('★');
            int substituteCount           = 0;
            int showLastCharacterDuration = 1000;

            using (var map = new PropertyMap())
            {
                map.Add(0, mode);
                map.Add(1, substituteCharacter);
                map.Add(2, substituteCount);
                map.Add(3, showLastCharacterDuration);

                var hiddenInput = TextMapHelper.GetHiddenInputStruct(map);
                Assert.AreEqual(mode, (int)hiddenInput.Mode, "Should be equal!");
                Assert.AreEqual(substituteCharacter, Convert.ToInt32(hiddenInput.SubstituteCharacter), "Should be equal!");
                Assert.AreEqual(substituteCount, hiddenInput.SubstituteCount, "Should be equal!");
                Assert.AreEqual(showLastCharacterDuration, hiddenInput.ShowLastCharacterDuration, "Should be equal!");
            }

            tlog.Debug(tag, $"TextMapHelperGetHiddenInputStruct END (OK)");
        }
Esempio n. 5
0
        public void TextMapHelperGetStringFromMap()
        {
            tlog.Debug(tag, $"TextMapHelperGetStringFromMap START");

            var stringKey        = "width";
            var stringInvalidKey = "invalidKey";
            var intKey           = 1;
            var intInvalidKey    = 10;
            var value            = "expanded";
            var defaultValue     = "none";

            using (var map = new PropertyMap())
            {
                map.Add(stringKey, value);
                map.Add(intKey, value);

                var result = TextMapHelper.GetStringFromMap(map, stringKey, defaultValue);
                Assert.AreEqual(value, result, "Should be equal!");

                result = TextMapHelper.GetStringFromMap(map, stringInvalidKey, defaultValue);
                Assert.AreEqual(defaultValue, result, "Should be equal!");

                result = TextMapHelper.GetStringFromMap(map, intKey, defaultValue);
                Assert.AreEqual(value, result, "Should be equal!");

                result = TextMapHelper.GetStringFromMap(map, intInvalidKey, defaultValue);
                Assert.AreEqual(defaultValue, result, "Should be equal!");
            }

            tlog.Debug(tag, $"TextMapHelperGetStringFromMap END (OK)");
        }
Esempio n. 6
0
        public void TextMapHelperGetShadowStruct()
        {
            tlog.Debug(tag, $"TextMapHelperGetShadowStruct START");

            var   offset     = new Vector2(5, 5);
            var   color      = new Color("#F1C40F");
            float blurRadius = 5.0f;

            using (var map = new PropertyMap())
            {
                map.Add("offset", offset);
                map.Add("color", color);
                map.Add("blurRadius", (float)blurRadius);

                var shadow = TextMapHelper.GetShadowStruct(map);
                Assert.AreEqual(blurRadius, shadow.BlurRadius, "Should be equal!");
                Assert.AreEqual(true, CheckVector2(offset, shadow.Offset), "Should be true!");
                Assert.AreEqual(true, CheckColor(color, shadow.Color), "Should be true!");
            }

            offset.Dispose();
            color.Dispose();

            tlog.Debug(tag, $"TextMapHelperGetShadowStruct END (OK)");
        }
Esempio n. 7
0
        public void TextMapHelperGetTextFitStruct()
        {
            tlog.Debug(tag, $"TextMapHelperGetTextFitStruct START");

            bool  enable   = true;
            float minSize  = 10.0f;
            float maxSize  = 100.0f;
            float stepSize = 5.0f;

            using (var map = new PropertyMap())
            {
                map.Add("enable", enable);
                map.Add("minSize", (float)minSize);
                map.Add("maxSize", (float)maxSize);
                map.Add("stepSize", (float)stepSize);
                map.Add("fontSizeType", "pointSize");

                var textFit = TextMapHelper.GetTextFitStruct(map);
                Assert.AreEqual(enable, textFit.Enable, "Should be equal!");
                Assert.AreEqual(minSize, textFit.MinSize, "Should be equal!");
                Assert.AreEqual(maxSize, textFit.MaxSize, "Should be equal!");
                Assert.AreEqual(stepSize, textFit.StepSize, "Should be equal!");
                Assert.AreEqual(FontSizeType.PointSize, textFit.FontSizeType, "Should be equal!");
            }

            tlog.Debug(tag, $"TextMapHelperGetTextFitStruct END (OK)");
        }
Esempio n. 8
0
        public void PropertyBufferSetData()
        {
            tlog.Debug(tag, $"PropertyBufferSetData START");

            PropertyMap buffer = new PropertyMap();

            Assert.IsNotNull(buffer, "should be not null");
            Assert.IsInstanceOf <PropertyMap>(buffer, "should be an instance of PropertyMap class!");
            buffer.Add("aIndex", new PropertyValue((int)PropertyType.Float));
            buffer.Add("aValue", new PropertyValue((int)PropertyType.Float));

            var testingTarget = new PropertyBuffer(buffer);

            Assert.IsNotNull(testingTarget, "should be not null");
            Assert.IsInstanceOf <PropertyBuffer>(testingTarget, "Should be an instance of PropertyBuffer class!");
            try
            {
                global::System.IntPtr data = new global::System.IntPtr();
                testingTarget.SetData(data, 0);
            }
            catch (Exception e)
            {
                LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "Caught Exception" + e.ToString());
                Assert.Fail("Caught Exception" + e.ToString());
            }
            Assert.AreEqual(0, testingTarget.GetSize(), "Should be Equal.");

            testingTarget.Dispose();
            buffer.Dispose();
            tlog.Debug(tag, $"PropertyBufferSetData END (OK)");
        }
Esempio n. 9
0
        public void BuilderAddConstants()
        {
            tlog.Debug(tag, $"BuilderAddConstants START");

            var testingTarget = new Builder();

            Assert.IsNotNull(testingTarget, "Should be not null!");
            Assert.IsInstanceOf <Builder>(testingTarget, "Should be an Instance of Builder!");

            using (PropertyMap map = new PropertyMap())
            {
                map.Add("Size", new PropertyValue(new Size(20, 30)));
                map.Add("Posision", new PropertyValue(new Position(100, 200)));

                try
                {
                    testingTarget.AddConstants(map);
                }
                catch (Exception e)
                {
                    tlog.Debug(tag, e.Message.ToString());
                    Assert.Fail("Caught Exception: Failed!");
                }
            }

            testingTarget.Dispose();
            testingTarget = null;
            tlog.Debug(tag, $"BuilderAddConstants END (OK)");
        }
Esempio n. 10
0
        /// <summary>
        /// Compose the out visual map.
        /// </summary>
        /// <since_tizen> 3 </since_tizen>
        protected override void ComposingPropertyMap()
        {
            if (color != null && size != null)
            {
                _outputVisualMap = new PropertyMap();
                PropertyValue temp = new PropertyValue((int)Visual.Type.Border);
                _outputVisualMap.Add(Visual.Property.Type, temp);
                temp.Dispose();

                temp = new PropertyValue((float)size);
                _outputVisualMap.Add(BorderVisualProperty.Size, temp);
                temp.Dispose();

                temp = new PropertyValue(color);
                _outputVisualMap.Add(BorderVisualProperty.Color, temp);
                temp.Dispose();

                if (antiAliasing != null)
                {
                    temp = new PropertyValue((bool)antiAliasing);
                    _outputVisualMap.Add(BorderVisualProperty.AntiAliasing, temp);
                    temp.Dispose();
                }
                base.ComposingPropertyMap();
            }
        }
Esempio n. 11
0
        // This is currently a static as it is a single method.
        // This could be incorporated into ImageView or View/Control as a property.
        /// <summary>
        /// Creates and initializes a new instance of ImageView class
        /// </summary>
        /// <param name="filename">file name</param>
        /// <returns>clipped view</returns>
        public static ImageView Create(String filename)
        {
            ImageView clipView = new ImageView();

            String fragmentShaderString = "#extension GL_OES_standard_derivatives : enable\n" +
                                          "varying mediump vec2 vTexCoord;" +
                                          "uniform sampler2D sTexture;" +
                                          "void main()" +
                                          "{" +
                                          "  if (texture2D(sTexture, vTexCoord).a > 0.4)" +
                                          "  {" +
                                          "    gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0);" +
                                          "  }" +
                                          "  else" +
                                          "  {" +
                                          "    discard;" +
                                          "  }" +
                                          "}";

            PropertyMap shaderMap = new PropertyMap();

            shaderMap.Add(Tizen.NUI.Visual.ShaderProperty.FragmentShader, new PropertyValue(fragmentShaderString));
            shaderMap.Add(Tizen.NUI.Visual.ShaderProperty.ShaderHints, new PropertyValue((int)Shader.Hint.Value.OUTPUT_IS_TRANSPARENT));

            PropertyMap imageMap = new PropertyMap();

            imageMap.Add(Tizen.NUI.ImageVisualProperty.URL, new PropertyValue(filename));
            imageMap.Add(Tizen.NUI.Visual.Property.Shader, new PropertyValue(shaderMap));

            clipView.ImageMap     = imageMap;
            clipView.ClippingMode = ClippingModeType.ClipChildren;
            return(clipView);
        }
Esempio n. 12
0
 protected void AddPropertiesToMap <PlayerType>(PropertyMap <PlayerType> map) where PlayerType : Player
 {
     map.Add(nameof(Zone), GetZone, null);
     map.Add(nameof(Interaction), GetInteraction, null);
     map.Add(nameof(Trainer.Inventory), GetInventory, null);
     map.Add(nameof(Name), GetName, SetName);
 }
Esempio n. 13
0
        /// <summary>
        /// Creates a tile for the main menu.
        /// </summary>
        /// <param name="name">The unique name for this Tile</param>
        /// <param name="title"> The text caption that appears on the Tile</param>
        /// <param name="sizeMultiplier">ile's parent size.</param>
        /// <param name="position">The tiles relative position within a page</param>
        /// <returns>
        /// The view for the created tile.
        /// </returns>
        View CreateTile(string name, string title, Vector3 sizeMultiplier, Vector2 position)
        {
            View focusableTile = new View();

            focusableTile.StyleName          = "DemoTile";
            focusableTile.HeightResizePolicy = ResizePolicyType.SizeRelativeToParent;
            focusableTile.WidthResizePolicy  = ResizePolicyType.SizeRelativeToParent;
            focusableTile.SizeModeFactor     = sizeMultiplier;
            focusableTile.Name = name;

            // Set the tile to be keyboard focusable
            focusableTile.Focusable = true;

            PropertyMap normalMap = new PropertyMap();

            normalMap.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.Image));
            normalMap.Add(ImageVisualProperty.URL, new PropertyValue(resource + "/images/demo-tile-texture.9.png"));
            normalMap.Add(Visual.Property.Shader, new PropertyValue(Visual.ShaderProperty.FragmentShader));
            normalMap.Add(Visual.Property.MixColor, new PropertyValue(new Vector4(0.4f, 0.6f, 0.9f, 0.6f)));
            PropertyMap fragmentShaderMap = new PropertyMap();

            fragmentShaderMap.Add(Visual.ShaderProperty.FragmentShader, new PropertyValue(fragmentShader));
            normalMap.Add(Visual.Property.Shader, new PropertyValue(fragmentShaderMap));
            focusableTile.Background = normalMap;

            // Create an ImageView for the 9-patch border around the tile.
            ImageView borderImage = new ImageView();

            borderImage.StyleName = "DemoTileBorder";
            borderImage.PositionUsesPivotPoint = true;
            borderImage.PivotPoint             = PivotPoint.Center;
            borderImage.ParentOrigin           = ParentOrigin.Center;
            borderImage.HeightResizePolicy     = ResizePolicyType.FillToParent;
            borderImage.WidthResizePolicy      = ResizePolicyType.FillToParent;
            borderImage.Opacity = 0.8f;
            focusableTile.Add(borderImage);

            TextLabel label = new TextLabel();

            label.PositionUsesPivotPoint = true;
            label.PivotPoint             = PivotPoint.Center;
            label.ParentOrigin           = ParentOrigin.Center;
            label.StyleName           = "LauncherLabel";
            label.MultiLine           = true;
            label.Text                = title;
            label.PointSize           = 5.0f;
            label.HorizontalAlignment = HorizontalAlignment.Center;
            label.VerticalAlignment   = VerticalAlignment.Center;
            label.HeightResizePolicy  = ResizePolicyType.FillToParent;
            label.WidthResizePolicy   = ResizePolicyType.FillToParent;
            // Pad around the label as its size is the same as the 9-patch border.
            // It will overlap it without padding.
            label.Padding = new Vector4(8.0f, 8.0f, 8.0f, 8.0f);
            focusableTile.Add(label);

            focusableTile.KeyEvent += DoTilePress;

            return(focusableTile);
        }
Esempio n. 14
0
        /// <summary>
        /// StateChanged event handling of CheckBox
        /// </summary>
        /// <param name="source">CheckBoxButton</param>
        /// <param name="e">event</param>
        /// <returns>The consume flag</returns>
        private void OnCheckBoxChanged(object source, EventArgs e)
        {
            // Get the source who trigger this event.
            CheckBox checkBoxButton = source as CheckBox;

            // Change the shadow state of TextLabel
            if (checkBoxButton.Text == "Shadow")
            {
                // Make a shadow for the TextLabel
                // Shadow offset is 3.0f
                // Shadow color is Black
                if (checkBoxButton.IsSelected)
                {
                    mtextLabelCheckBox.Position = new Position(3.0f, 3.0f);
                    mtextLabelCheckBox.Color    = Color.Black;
                }
                else
                {
                    // Delete the shadow of the TextLabel
                    mtextLabelCheckBox.Position = new Position(0, 0);
                }
            }
            // Change the color of the TextLabel
            else if (checkBoxButton.Text == "Color")
            {
                // Set the color of the TextLabel to Red
                if (checkBoxButton.IsSelected)
                {
                    mtextLabelCheckBox.TextColor = Color.Red;
                }
                // Set the color of the TextLabel to Black
                else
                {
                    mtextLabelCheckBox.TextColor = Color.Black;
                }
            }
            // Change the Underline state of the TextLabel
            else if (checkBoxButton.Text == "Underline")
            {
                // Create a PropertyMap to change the underline status
                PropertyMap underlineMapSet = new PropertyMap();
                // Make a underline propertymap.
                if (checkBoxButton.IsSelected)
                {
                    // Underline color is black.
                    // Underline height is 3.0
                    underlineMapSet.Add("enable", new PropertyValue("true"));
                    underlineMapSet.Add("color", new PropertyValue("black"));
                    underlineMapSet.Add("height", new PropertyValue("3.0f"));
                }
                // Delete UnderLine property
                else
                {
                    underlineMapSet.Add("enable", new PropertyValue("false"));
                }

                mtextLabelCheckBox.Underline = underlineMapSet;
            }
        }
Esempio n. 15
0
        /// <summary>
        /// Create selected background
        /// </summary>
        /// <returns>
        /// The PropertyMap which define the selected background.
        /// </returns>
        private PropertyMap CreateSelectedBG()
        {
            PropertyMap map = new PropertyMap();

            map.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.Image));
            map.Add(ImageVisualProperty.URL, new PropertyValue(handleSelectedVisual));
            return(map);
        }
Esempio n. 16
0
 protected void AddPropertiesToMap <ZoneDataType>(PropertyMap <ZoneDataType> map) where ZoneDataType : ZoneData
 {
     map.Add(nameof(World), GetWorld, null);
     map.Add(nameof(Player), GetPlayer, null);
     map.Add(nameof(Zone.Name), GetName, null);
     map.Add(nameof(State), GetState, null);
     map.Add(nameof(IsActive), GetIsActive, null);
 }
        /// <summary>
        /// Create an Image visual.
        /// </summary>
        /// <param name="imagePath">The url of the image</param>
        /// <returns>return thr radioButton instance</returns>
        private PropertyMap CreateImageVisual(string imagePath)
        {
            PropertyMap map = new PropertyMap();

            map.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.Image));
            map.Add(ImageVisualProperty.URL, new PropertyValue(imagePath));
            return(map);
        }
        /// <summary>
        /// Create an Color visual.
        /// </summary>
        /// <param name="color">The color value of the visual</param>
        /// <returns>return a map which contain the properties of the color</returns>
        private PropertyMap CreateColorVisual(Vector4 color)
        {
            PropertyMap map = new PropertyMap();

            map.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.Color));
            map.Add(ColorVisualProperty.MixColor, new PropertyValue(color));
            return(map);
        }
        /// <summary>
        /// StateChanged event handling of CheckBox
        /// </summary>
        /// <param name="source">CheckBoxButton</param>
        /// <param name="e">event</param>
        /// <returns>The consume flag</returns>
        private void OnCheckBoxChanged(object source, EventArgs e)
        {
            // Get the source who trigger this event.
            CheckBox checkBoxButton = source as CheckBox;

            // Change the shadow state of TextLabel
            if (checkBoxButton.Text == "Background")
            {
                // Set the background-color of the TextLabel to Bluish
                if (checkBoxButton.IsSelected)
                {
                    mTitleLabelCheckBox.BackgroundColor = new Color(0.05f, 0.63f, 0.9f, 1);
                }
                // Set the background color of the TextLabel to White
                else
                {
                    mTitleLabelCheckBox.BackgroundColor = Color.White;
                }
            }
            // Change the color of the TextLabel
            else if (checkBoxButton.Text == "Color")
            {
                // Set the color of the TextLabel to Red
                if (checkBoxButton.IsSelected)
                {
                    mTitleLabelCheckBox.TextColor = Color.Red;
                }
                // Set the color of the TextLabel to Black
                else
                {
                    mTitleLabelCheckBox.TextColor = Color.Black;
                }
            }
            // Change the Underline state of the TextLabel
            else if (checkBoxButton.Text == "Underline")
            {
                // Create a PropertyMap to change the underline status
                PropertyMap underlineMapSet = new PropertyMap();
                // Make a underline propertymap.
                if (checkBoxButton.IsSelected)
                {
                    // Underline color is black.
                    // Underline height is 3.0
                    underlineMapSet.Add("enable", new PropertyValue("true"));
                    underlineMapSet.Add("color", new PropertyValue("black"));
                    underlineMapSet.Add("height", new PropertyValue("3.0f"));
                }
                // Delete UnderLine property
                else
                {
                    underlineMapSet.Add("enable", new PropertyValue("false"));
                }

                mTitleLabelCheckBox.Underline = underlineMapSet;
            }
        }
Esempio n. 20
0
 /// <summary>
 /// Compose the out visual map.
 /// </summary>
 /// <since_tizen> 3 </since_tizen>
 protected override void ComposingPropertyMap()
 {
     if (_url != null)
     {
         _outputVisualMap = new PropertyMap();
         _outputVisualMap.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.SVG));
         _outputVisualMap.Add(ImageVisualProperty.URL, new PropertyValue(_url));
         base.ComposingPropertyMap();
     }
 }
Esempio n. 21
0
        public static PropertyMap GetFontStyleMap(FontStyle fontStyle)
        {
            var map = new PropertyMap();

            map.Add("width", GetFontWidthString(fontStyle.Width));
            map.Add("weight", GetFontWeightString(fontStyle.Weight));
            map.Add("slant", GetFontSlantString(fontStyle.Slant));

            return(map);
        }
        /// <summary>
        /// Create an Color visual.
        /// </summary>
        /// <param name="color">The color value of the visual</param>
        /// <returns>return a map which contain the properties of the color</returns>
        private PropertyMap CreateColorVisual(Vector4 color)
        {
            // Create a Property map for ColorVisual
            PropertyMap map = new PropertyMap();

            // Set each property of ColorVisual
            map.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.Color));
            map.Add(ColorVisualProperty.MixColor, new PropertyValue(color));
            return(map);
        }
Esempio n. 23
0
 /// <summary>
 /// Compose the out visual map.
 /// </summary>
 /// <since_tizen> 3 </since_tizen>
 protected override void ComposingPropertyMap()
 {
     if (_color != null && _size != null)
     {
         _outputVisualMap = new PropertyMap();
         _outputVisualMap.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.Border));
         _outputVisualMap.Add(BorderVisualProperty.Size, new PropertyValue((float)_size));
         _outputVisualMap.Add(BorderVisualProperty.Color, new PropertyValue(_color));
         if (_antiAliasing != null)
         {
             _outputVisualMap.Add(BorderVisualProperty.AntiAliasing, new PropertyValue((bool)_antiAliasing));
         }
         if (_shader != null)
         {
             _outputVisualMap.Add((int)Visual.Property.Shader, new PropertyValue(_shader));
         }
         if (_premultipliedAlpha != null)
         {
             _outputVisualMap.Add((int)Visual.Property.PremultipliedAlpha, new PropertyValue((bool)_premultipliedAlpha));
         }
         if (_mixColor != null)
         {
             _outputVisualMap.Add((int)Visual.Property.MixColor, new PropertyValue(_mixColor));
         }
         if (_opacity != null)
         {
             _outputVisualMap.Add((int)Visual.Property.Opacity, new PropertyValue((float)_opacity));
         }
         if (_visualFittingMode != null)
         {
             _outputVisualMap.Add((int)Visual.Property.VisualFittingMode, new PropertyValue((int)_visualFittingMode));
         }
     }
 }
Esempio n. 24
0
        private bool Timer_Tick(object source, Timer.TickEventArgs e)
        {
            Tizen.Log.Fatal(TAG, $"#3 imageView.LoadingStatus={imageView?.LoadingStatus}");
            Tizen.Log.Fatal(TAG, $"###3 imageView2.LoadingStatus={imageView2?.LoadingStatus}");
            Tizen.Log.Fatal(TAG, $"Timer_Tick() comes!");

            if (cnt++ % 2 == 0)
            {
                map.Clear();
                customShader.Clear();
                map.Add("shader", new PropertyValue(customShader));
                imageView.Image = map;
            }
            else
            {
                map.Clear();
                customShader.Clear();
                customShader.Add("vertexShader", new PropertyValue(vertexShaderSource));
                customShader.Add("fragmentShader", new PropertyValue(fragmentShaderSource));
                map.Add("shader", new PropertyValue(customShader));
                imageView.Image = map;
            }

            Tizen.Log.Fatal(TAG, $"#4 imageView.LoadingStatus={imageView.LoadingStatus}");

            if (cnt % 3 == 0)
            {
                window.SetTransparency(false);
                Random rand  = new Random();
                float  value = rand.Next(0, 255) / 255.0f;
                window.BackgroundColor = new Color(value, value, 1 - value, 1.0f);
            }
            else
            {
                window.SetTransparency(true);
                window.BackgroundColor = new Color(0, 0, 0, 0);
            }

            string url1 = resourcePath + "/images/image-" + (cnt % 3 + 1) + ".jpg";

            Tizen.Log.Fatal(TAG, $"url1={url1}");
            imageView2?.Dispose();
            imageView2 = null;
            imageView2 = new ImageView(url1);
            imageView2.PositionUsesPivotPoint = true;
            imageView2.PivotPoint             = PivotPoint.BottomCenter;
            imageView2.ParentOrigin           = ParentOrigin.BottomCenter;
            imageView2.Size2D = new Size2D(300, 300);
            Tizen.Log.Fatal(TAG, $"###4 imageView2.LoadingStatus={imageView2.LoadingStatus}");
            window.Add(imageView2);

            Tizen.Log.Fatal(TAG, $"#5 imageView.LoadingStatus={imageView.LoadingStatus}");
            Tizen.Log.Fatal(TAG, $"###5 imageView2.LoadingStatus={imageView2.LoadingStatus}");
            return(true);
        }
Esempio n. 25
0
        /// <summary>
        /// Creates an animation to animate the mixColor of the named visual.
        /// </summary>
        /// <since_tizen> 3 </since_tizen>
        public Animation AnimateColor(string targetVisual, object destinationColor, int startTime, int endTime, AlphaFunction.BuiltinFunctions?alphaFunction = null, object initialColor = null)
        {
            Animation animation = null;

            using (PropertyMap animator = new PropertyMap())
                using (PropertyMap timePeriod = new PropertyMap())
                    using (PropertyValue pvDuration = new PropertyValue((endTime - startTime) / 1000.0f))
                        using (PropertyValue pvDelay = new PropertyValue(startTime / 1000.0f))
                            using (PropertyMap transition = new PropertyMap())
                                using (PropertyValue pvTarget = new PropertyValue(targetVisual))
                                    using (PropertyValue pvProperty = new PropertyValue("mixColor"))
                                        using (PropertyValue destValue = PropertyValue.CreateFromObject(destinationColor))
                                        {
                                            if (alphaFunction != null)
                                            {
                                                using (PropertyValue pvAlpha = new PropertyValue(AlphaFunction.BuiltinToPropertyKey(alphaFunction)))
                                                {
                                                    animator.Add("alphaFunction", pvAlpha);
                                                }
                                            }

                                            timePeriod.Add("duration", pvDuration);
                                            timePeriod.Add("delay", pvDelay);
                                            using (PropertyValue pvTimePeriod = new PropertyValue(timePeriod))
                                            {
                                                animator.Add("timePeriod", pvTimePeriod);
                                            }
                                            using (PropertyValue pvAnimator = new PropertyValue(animator))
                                            {
                                                transition.Add("animator", pvAnimator);
                                            }
                                            transition.Add("target", pvTarget);
                                            transition.Add("property", pvProperty);

                                            if (initialColor != null)
                                            {
                                                using (PropertyValue initValue = PropertyValue.CreateFromObject(initialColor))
                                                {
                                                    transition.Add("initialValue", initValue);
                                                }
                                            }

                                            transition.Add("targetValue", destValue);
                                            using (TransitionData transitionData = new TransitionData(transition))
                                            {
                                                animation = new Animation(Interop.View.CreateTransition(SwigCPtr, TransitionData.getCPtr(transitionData)), true);
                                            }
                                            if (NDalicPINVOKE.SWIGPendingException.Pending)
                                            {
                                                throw NDalicPINVOKE.SWIGPendingException.Retrieve();
                                            }
                                        }
            return(animation);
        }
Esempio n. 26
0
        private PropertyMap CreateTextVisual(string text, Color color)
        {
            PropertyMap map = new PropertyMap();

            map.Add(TextVisualProperty.Text, new PropertyValue(text));
            map.Add(TextVisualProperty.TextColor, new PropertyValue(color));
            map.Add(TextVisualProperty.PointSize, new PropertyValue(30.0f));
            map.Add(TextVisualProperty.HorizontalAlignment, new PropertyValue("CENTER"));
            map.Add(TextVisualProperty.VerticalAlignment, new PropertyValue("CENTER"));
            return(map);
        }
        /// <summary>
        /// Create a PropertyMap which be used to set _checkboxbutton.Label
        /// </summary>
        /// <param name="text">text</param>
        /// <returns>
        /// the created PropertyMap
        /// </returns>
        private PropertyMap CreateLabel(string text, Color color)
        {
            PropertyMap textVisual = new PropertyMap();

            textVisual.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.Text));
            textVisual.Add(TextVisualProperty.Text, new PropertyValue(text));
            textVisual.Add(TextVisualProperty.TextColor, new PropertyValue(color));
            textVisual.Add(TextVisualProperty.PointSize, new PropertyValue(8.0f));
            textVisual.Add(TextVisualProperty.VerticalAlignment, new PropertyValue("TOP"));
            return(textVisual);
        }
Esempio n. 28
0
        public void TestMap()
        {
            var map = new PropertyMap {
                { "bool", true },
                { "byte", (byte)128 },
                { "short", (short)32000 },
                { "int", 1337 },
                { "long", 0xD34DB33FC4FE },
                { "float", 3.14F },
                { "double", 0.000002 },
                { "string", "gosh" },

                { "primitive list", new PropertyList {
                      "a", "b", "c"
                  } },
                { "byte array", Property.Of(new byte[] { 1, 2, 3 }) },
                { "float array", Property.Of(new [] { 1.0F, 2.0F, 3.0F }) },

                { "map list", new PropertyList {
                      new PropertyMap {
                          { "type", "zombie" }, { "health", 20 }
                      },
                      new PropertyMap {
                          { "type", "skeleton" }, { "health", 15 }
                      },
                      new PropertyMap {
                          { "type", "creeper" }, { "health", 10 }
                      },
                  } },
            };

            Assert.Equal(map["bool"].As <bool>(), true);
            Assert.Equal(map["byte"].As <byte>(), (byte)128);
            Assert.Equal(map["short"].As <short>(), (short)32000);
            Assert.Equal(map["int"].As <int>(), 1337);
            Assert.Equal(map["long"].As <long>(), 0xD34DB33FC4FE);
            Assert.Equal(map["float"].As <float>(), 3.14F);
            Assert.Equal(map["double"].As <double>(), 0.000002);
            Assert.Equal(map["string"].As <string>(), "gosh");

            Assert.Equal(map["unknown"], null);
            Assert.Throws <ArgumentNullException>(() => map[null]);

            Assert.Equal(map["map list"].As <PropertyList>().Count, 3);
            Assert.Equal(map["map list"][1]["type"].As <string>(), "skeleton");
            Assert.Equal(map["map list"][2]["health"].As <int>(), 10);

            map.Add("new", "Hi I'm new!");
            Assert.NotNull(map["new"]);
            Assert.Throws <ArgumentException>(() => map.Add("new", "Hello new, I'm dad!"));
            map.Remove("new");
            Assert.Null(map["new"]);
        }
Esempio n. 29
0
        /// <summary>
        /// Create a PropertyMap which be used to set _checkboxbutton.Label
        /// </summary>
        /// <param name="text">text</param>
        /// <returns>
        /// the created PropertyMap
        /// </returns>
        private PropertyMap CreateLabel(string text)
        {
            PropertyMap textVisual = new PropertyMap();

            textVisual.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.Text));
            textVisual.Add(TextVisualProperty.Text, new PropertyValue(text));
            textVisual.Add(TextVisualProperty.TextColor, new PropertyValue(Color.White));
            //textVisual.Add(TextVisualProperty.PointSize, new PropertyValue(8.0f));
            textVisual.Add(TextVisualProperty.PointSize, new PropertyValue(DeviceCheck.PointSize8));
            textVisual.Add(TextVisualProperty.VerticalAlignment, new PropertyValue("TOP"));
            return(textVisual);
        }
Esempio n. 30
0
        /// <summary>
        /// RadioButton initialisation.
        /// </summary>
        /// <param name="text">text</param>
        private void OnIntialize(string text)
        {
            _radiobutton              = new RadioButton();
            _radiobutton.Label        = CreateLabel(text);
            _radiobutton.LabelPadding = new Vector4(20, 12, 0, 0);
            _radiobutton.Size2D       = new Size2D(300, 48);
            _radiobutton.Focusable    = true;
            _radiobutton.ParentOrigin = ParentOrigin.TopLeft;
            _radiobutton.PivotPoint   = PivotPoint.TopLeft;

            // Create unfocused and unselected visual.
            PropertyMap unselectedMap = new PropertyMap();

            unselectedMap.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.Image));
            unselectedMap.Add(ImageVisualProperty.URL, new PropertyValue(normalImagePath));

            // Create focused and unselected visual.
            PropertyMap focusUnselectedMap = new PropertyMap();

            focusUnselectedMap.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.Image));
            focusUnselectedMap.Add(ImageVisualProperty.URL, new PropertyValue(focusedImagePath));

            // Create focused and selected visual.
            PropertyMap focusSelectedMap = new PropertyMap();

            focusSelectedMap.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.Image));
            focusSelectedMap.Add(ImageVisualProperty.URL, new PropertyValue(focusedSelectImagePath));

            // Create unfocused and selected visual.
            PropertyMap selectedMap = new PropertyMap();

            selectedMap.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.Image));
            selectedMap.Add(ImageVisualProperty.URL, new PropertyValue(selectImagePath));

            // Set the original visual.
            _radiobutton.SelectedVisual   = selectedMap;
            _radiobutton.UnselectedVisual = unselectedMap;

            // Change the image when focus changed.
            _radiobutton.FocusGained += (obj, e) =>
            {
                _radiobutton.UnselectedVisual = focusUnselectedMap;
                _radiobutton.SelectedVisual   = focusSelectedMap;
            };

            // Change the image when focus changed.
            _radiobutton.FocusLost += (obj, e) =>
            {
                _radiobutton.UnselectedVisual = unselectedMap;
                _radiobutton.SelectedVisual   = selectedMap;
            };
        }
 public PropertyMap getProperties()
 {
     PropertyMap map = new PropertyMap();
        Dictionary<string, string>.Enumerator enumer = propertyMap.GetEnumerator();
        while(enumer.MoveNext()){
        map.Add(enumer.Current.Key, enumer.Current.Value);
        }
        return map;
 }