Example #1
0
 /// <summary>
 /// Compose the out visual map.
 /// </summary>
 /// <since_tizen> 3 </since_tizen>
 protected override void ComposingPropertyMap()
 {
     if (_urls != null)
     {
         _outputVisualMap = new PropertyMap();
         PropertyValue temp = new PropertyValue((int)Visual.Type.AnimatedImage);
         _outputVisualMap.Add(Visual.Property.Type, temp);
         temp.Dispose();
         if (_urls.Count == 1)
         {
             temp = new PropertyValue(_urls[0]);
             _outputVisualMap.Add(ImageVisualProperty.URL, temp);
             temp.Dispose();
         }
         else
         {
             var urlArray = new PropertyArray();
             foreach (var url in _urls)
             {
                 urlArray.Add(new PropertyValue(url));
             }
             temp = new PropertyValue(urlArray);
             _outputVisualMap.Add(ImageVisualProperty.URL, temp);
             temp.Dispose();
             urlArray.Dispose();
         }
         if (_batchSize != null)
         {
             temp = new PropertyValue((int)_batchSize);
             _outputVisualMap.Add(ImageVisualProperty.BatchSize, temp);
             temp.Dispose();
         }
         if (_cacheSize != null)
         {
             temp = new PropertyValue((int)_cacheSize);
             _outputVisualMap.Add(ImageVisualProperty.CacheSize, temp);
             temp.Dispose();
         }
         if (_frameDelay != null)
         {
             temp = new PropertyValue((float)_frameDelay);
             _outputVisualMap.Add(ImageVisualProperty.FrameDelay, temp);
             temp.Dispose();
         }
         if (_loopCount != null)
         {
             temp = new PropertyValue((int)_loopCount);
             _outputVisualMap.Add(ImageVisualProperty.LoopCount, temp);
             temp.Dispose();
         }
         base.ComposingPropertyMap();
     }
 }
Example #2
0
        public void SetAvailableOrientations(List <GLWindow.GLWindowOrientation> orientations)
        {
            PropertyArray orientationArray = new PropertyArray();

            for (int i = 0; i < orientations.Count; i++)
            {
                PropertyValue val = new PropertyValue((int)orientations[i]);
                orientationArray.PushBack(val);
                val.Dispose();
            }

            Interop.GLWindow.GlWindow_SetAvailableOrientations(swigCPtr, PropertyArray.getCPtr(orientationArray), orientations.Count);
            orientationArray.Dispose();
            if (NDalicPINVOKE.SWIGPendingException.Pending)
            {
                throw NDalicPINVOKE.SWIGPendingException.Retrieve();
            }
        }
Example #3
0
        public int SetText(TextLabel label, string str)
        {
            if (label == null || str == null)
            {
                return(0);
            }

            // perform this operation to match the utf32 character used in native Dali.
            bool previousMarkup = label.EnableMarkup;

            label.EnableMarkup = false;
            label.Text         = str;
            pageString         = label.Text;
            label.EnableMarkup = previousMarkup;
            label.MultiLine    = true;
            label.Ellipsis     = false;

            int length       = pageString.Length;
            int remainLength = length;
            int offset       = 0;
            int cutOffIndex  = 0;

            // init
            totalPageCnt  = 0;
            pageList      = new List <PageData>();
            tagList       = new List <TagData>();
            characterList = new List <char>();

            stream = new StringReader(pageString);

            RendererParameters textParameters = new RendererParameters();

            textParameters.Text = pageString;
            textParameters.HorizontalAlignment = label.HorizontalAlignment;
            textParameters.VerticalAlignment   = label.VerticalAlignment;
            textParameters.FontFamily          = label.FontFamily;
            textParameters.FontWeight          = "";
            textParameters.FontWidth           = "";
            textParameters.FontSlant           = "";
            textParameters.Layout          = TextLayout.MultiLine;
            textParameters.TextColor       = Color.Black;
            textParameters.FontSize        = label.PointSize;
            textParameters.TextWidth       = (uint)label.Size.Width;
            textParameters.TextHeight      = (uint)label.Size.Height;
            textParameters.EllipsisEnabled = true;
            textParameters.MarkupEnabled   = previousMarkup;
            textParameters.MinLineSize     = label.MinLineSize;
            textParameters.Padding         = label.Padding;


            Tizen.NUI.PropertyArray cutOffIndexArray = TextUtils.GetLastCharacterIndex(textParameters);
            uint count = cutOffIndexArray.Count();

            for (uint i = 0; i < count; i++)
            {
                var temp = cutOffIndexArray.GetElementAt(i);
                temp.Get(out cutOffIndex); // Gets the last index of text shown on the actual screen.
                temp.Dispose();

                // If markup is enabled, It should parse markup
                if (label.EnableMarkup)
                {
                    int preOffset = offset;
                    offset        = MarkupProcess(offset, cutOffIndex - preOffset);
                    remainLength -= (offset - preOffset);
                }
                //If markup is not enabled, parsing is not required.
                else
                {
                    PageData pageData = new PageData();
                    pageData.StartOffset = offset;
                    int cnt = (cutOffIndex - offset) < remainLength ? (cutOffIndex - offset) : remainLength;
                    remainLength      -= cnt;
                    offset            += cnt;
                    pageData.EndOffset = offset;
                    pageList.Add(pageData);
                }
                totalPageCnt++;
                if (offset <= 0 || remainLength <= 0)
                {
                    break;
                }
            }

            textParameters.Dispose();
            cutOffIndexArray.Dispose();
            stream = null;
            return(totalPageCnt);
        }
Example #4
0
        /// <summary>
        /// Sets a property value on a view.
        /// </summary>
        private void SetPropertyValue(IntPtr refObjectPtr, string propertyName, IntPtr propertyValuePtr)
        {
            // Get the C# control that maps to the C++ control
            NUILog.Debug("SetPropertyValue   refObjectPtr = {0:X}" + refObjectPtr);

            PropertyValue propValue = new PropertyValue(propertyValuePtr, false);

            // Get the C# control that maps to the C++ control
            View view = Registry.GetManagedBaseHandleFromRefObject(refObjectPtr) as View;

            if (view != null)
            {
                System.Reflection.PropertyInfo propertyInfo = view.GetType().GetProperty(propertyName);
                // We know the property name, we know it's type, we just need to convert from a DALi property value to native C# type
                System.Type type = propertyInfo.PropertyType;
                bool        ok   = false;

                if (type.Equals(typeof(Int32)))
                {
                    int value = 0;
                    ok = propValue.Get(out value);
                    if (ok)
                    {
                        propertyInfo.SetValue(view, value);
                    }
                }
                else if (type.Equals(typeof(bool)))
                {
                    bool value = false;
                    ok = propValue.Get(out value);
                    if (ok)
                    {
                        propertyInfo.SetValue(view, value);
                    }
                }
                else if (type.Equals(typeof(float)))
                {
                    float value = 0;
                    ok = propValue.Get(out value);
                    if (ok)
                    {
                        propertyInfo.SetValue(view, value);
                    }
                }
                else if (type.Equals(typeof(string)))
                {
                    string value = "";
                    ok = propValue.Get(out value);
                    if (ok)
                    {
                        propertyInfo.SetValue(view, value);
                    }
                }
                else if (type.Equals(typeof(Vector2)))
                {
                    Vector2 value = new Vector2();
                    ok = propValue.Get(value);
                    if (ok)
                    {
                        propertyInfo.SetValue(view, value);
                    }
                    value.Dispose();
                }
                else if (type.Equals(typeof(Vector3)))
                {
                    Vector3 value = new Vector3();
                    ok = propValue.Get(value);
                    if (ok)
                    {
                        propertyInfo.SetValue(view, value);
                    }
                    value.Dispose();
                }
                else if (type.Equals(typeof(Vector4)))
                {
                    Vector4 value = new Vector4();
                    ok = propValue.Get(value);

                    if (ok)
                    {
                        propertyInfo.SetValue(view, value);
                    }
                    value.Dispose();
                }
                else if (type.Equals(typeof(Position)))
                {
                    Position value = new Position();
                    ok = propValue.Get(value);
                    if (ok)
                    {
                        propertyInfo.SetValue(view, value);
                    }
                    value.Dispose();
                }
                else if (type.Equals(typeof(Size)))
                {
                    Size value = new Size();
                    ok = propValue.Get(value);
                    if (ok)
                    {
                        Size sz = new Size(value.Width, value.Height, value.Depth);
                        propertyInfo.SetValue(view, sz);
                        sz.Dispose();
                    }
                    ;
                    value.Dispose();
                }
                else if (type.Equals(typeof(Color)))
                {
                    // Colors are stored as Vector4's in DALi
                    Color value = new Color();
                    ok = propValue.Get(value);
                    if (ok)
                    {
                        propertyInfo.SetValue(view, (Color)value);
                    }
                    ;
                    value.Dispose();
                }
                else if (type.Equals(typeof(PropertyMap)))
                {
                    PropertyMap map = new PropertyMap();
                    ok = propValue.Get(map);
                    if (ok)
                    {
                        propertyInfo.SetValue(view, map);
                    }
                    map.Dispose();
                }
                else if (type.Equals(typeof(PropertyArray)))
                {
                    PropertyArray array = new PropertyArray();
                    ok = propValue.Get(array);
                    if (ok)
                    {
                        propertyInfo.SetValue(view, array);
                    }
                    array.Dispose();
                }
                else
                {
                    throw new global::System.InvalidOperationException("SetPropertyValue Unimplemented type for Property Value for " + type.FullName);
                }
                if (!ok)
                {
                    throw new global::System.InvalidOperationException("SetPropertyValue propValue.Get failed");
                }
            }
            else
            {
                throw new global::System.InvalidOperationException("failed to find the control to write a property to: cptr = " + refObjectPtr);
            }
            propValue.Dispose();
        }