コード例 #1
0
        public static object SkinSetBool(params object[] args)
        {
            // args[0] - setting name
            // args[1] - (optional) new value
            bool newValue = true;

            if (args.Length == 2)
            {
                newValue = bool.Parse(args[1].ToString());
            }
            int condition = GUIInfoManager.TranslateSingleString("skin.setbool(" + args[0] + ")");

            GUIInfoManager.SetBool(condition, newValue, 0);
            return(newValue);
        }
コード例 #2
0
        private static bool GetConditionalVisibility(XmlNode element, GUIControl control, ref int condition,
                                                     ref bool allowHiddenFocus)
        {
            condition = GUIInfoManager.TranslateString(element.InnerText);

            // allowhiddenfocus (defaults to false)
            XmlNode nodeAttribute = element.Attributes.GetNamedItem("allowhiddenfocus");

            if (nodeAttribute != null)
            {
                string allow = nodeAttribute.Value;
                if (String.Compare(allow, "true") == 0)
                {
                    allowHiddenFocus = true;
                }
            }

            return(condition != 0);
        }
コード例 #3
0
ファイル: Functions.cs プロジェクト: c3333/MediaPortal-1
        public static object SkinSetString(params object[] args)
        {
            // args[0] - setting name
            // args[1] - (optional) new value
            // args[2] - (optional) keyboard prompt
            string newValue = "";

            // Set the setting to the specified string.  If no value is specified then present the keyboard to input the value.
            if (args.Length == 2)
            {
                int condition = GUIInfoManager.TranslateSingleString("skin.setstring(" + args[0] + ")");
                newValue = args[1].ToString();
                GUIInfoManager.SetString(condition, newValue, 0);
            }
            else
            {
                // No value was provided for the skin setting.  Display a keyboard and ask for a value.
                string prompt = "";
                if (args.Length >= 3)
                {
                    newValue = args[1].ToString();
                    prompt   = args[2].ToString();
                    GUILocalizeStrings.LocalizeLabel(ref prompt);
                }

                // Get the current value to initialize the keyboard.
                int    condition = GUIInfoManager.TranslateSingleString("skin.setstring(" + args[0] + "," + newValue + "," + prompt + ")");
                string userInput = GUIInfoManager.GetString(condition, 0);

                if (GetUserInputString(ref userInput, prompt))
                {
                    GUIInfoManager.SetString(condition, userInput, 0);
                }
                else
                {
                    // Keyboard cancelled; no value supplied and no input was entered into the keyboard.
                }
            }
            return(newValue);
        }
コード例 #4
0
        public void UpdateCondition()
        {
            bool condition = GUIInfoManager.GetBool(_condition, 0);

            if (condition && !_lastCondition)
            {
                ApplyAnimation();
                _queuedProcess = AnimationProcess.Normal;
            }
            else if (!condition && _lastCondition)
            {
                if (_isReversible)
                {
                    ApplyAnimation();
                    _queuedProcess = AnimationProcess.Reverse;
                }
                else
                {
                    ResetAnimation();
                }
            }
            _lastCondition = condition;
        }
コード例 #5
0
        /// <summary>
        /// Checks, if an update for the element is needed
        /// </summary>
        /// <returns>true, if an update is needed</returns>
        public bool CheckForUpdate()
        {
            _control.UpdateVisibility();
            _control.DoRender(GUIGraphicsContext.TimePassed, (uint)System.Windows.Media.Animation.AnimationTimer.TickCount);

            int  _visibleCondition = _control.GetVisibleCondition();
            bool newVisible        = _visibleCondition == 0 ? _control.Visible : GUIInfoManager.GetBool(_visibleCondition, _control.ParentID);

            if (newVisible == _wasVisible)
            {
                if (newVisible)
                {
                    return(CheckElementSpecificForUpdate());
                }
                return(false);
            }
            _wasVisible = newVisible;
            if (true)
            {
                CheckElementSpecificForUpdate();
            }
            return(true);
        }
コード例 #6
0
        /// <summary>
        /// Draws the element on the given graphics
        /// </summary>
        /// <param name="graph">Graphics</param>
        public override void DrawElement(Graphics graph)
        {
            if (_wasVisible)
            {
                GUIControl.Alignment alignment = _label.TextAlignment;
                RectangleF           rectangle;
                String text  = GUIPropertyManager.Parse(_label.Label);
                SizeF  sizeF = graph.MeasureString(text, _font);

                int xFromAnim = 0;
                int yFromAnim = 0;
                foreach (VisualEffect effect in _label.Animations)
                {
                    if (effect.CurrentState != AnimationState.None && effect.Effect == EffectType.Slide && (effect.Condition == 0 || GUIInfoManager.GetBool(effect.Condition, 0)))
                    {
                        xFromAnim += (int)effect.EndX;
                        yFromAnim += (int)effect.EndY;
                    }
                }
                int x = _label.XPosition + xFromAnim;
                int y = _label.YPosition + yFromAnim;

                if (alignment == GUIControl.Alignment.ALIGN_LEFT)
                {
                    //rectangle = new RectangleF(_label.XPosition, _label.YPosition, _label._width, Math.Max(sizeF.Height, _label._height));
                    rectangle = new RectangleF(x, y, _label._width, Math.Max(sizeF.Height, _label._height));
                }
                else
                {
                    //rectangle = alignment == GUIControl.Alignment.ALIGN_RIGHT ? new RectangleF((float)_label.Location.X - sizeF.Width, (float)_label.Location.Y, _label.Width, Math.Max(sizeF.Height, _label.Height)) : new RectangleF((float)_label.Location.X - (sizeF.Width / 2), (float)_label.Location.Y - (sizeF.Height / 2), _label.Width, Math.Max(sizeF.Height, _label.Height));
                    rectangle = alignment == GUIControl.Alignment.ALIGN_RIGHT ? new RectangleF((float)x - sizeF.Width, (float)y, _label.Width, Math.Max(sizeF.Height, _label.Height)) : new RectangleF((float)x - (sizeF.Width / 2), (float)y - (sizeF.Height / 2), _label.Width, Math.Max(sizeF.Height, _label.Height));
                }
                graph.DrawString(text, _font, _brush, rectangle, StringFormat.GenericTypographic);
            }
        }
コード例 #7
0
        public override void UpdateVisibility()
        {
            base.UpdateVisibility();
            if (Children == null)
            {
                return;
            }
            if (_layout == null)
            {
                return;
            }

            if (_layout is StackLayout)
            {
                StackLayout layout = _layout as StackLayout;
                if (!layout.CollapseHiddenButtons)
                {
                    return;
                }
                if (_first)
                {
                    StoreButtonsPosition();
                }
                bool isVisible = IsVisible;
                int  visCon    = GetVisibleCondition();
                if (isVisible && visCon != 0)
                {
                    isVisible = GUIInfoManager.GetBool(visCon, ParentID);
                }

                if (!isVisible)
                {
                    RestoreButtonsPosition();
                    _first = true;
                    return;
                }

                if (!_first && CheckButtonsModifiedPosition())
                {
                    _first = true;
                }

                if (_first)
                {
                    StoreButtonsVisibilityState();
                }

                for (int i = 0; i < Children.Count; i++)
                {
                    Children[i].UpdateVisibility();

                    bool bWasVisible = _visibilityState[i];

                    int  bVisCon    = Children[i].GetVisibleCondition();
                    bool bIsVisible = Children[i].IsVisible;
                    if (bVisCon != 0)
                    {
                        bIsVisible = GUIInfoManager.GetBool(bVisCon, Children[i].ParentID);
                    }

                    if (_first && !bIsVisible)
                    {
                        if (layout.Orientation == System.Windows.Controls.Orientation.Vertical)
                        {
                            ShiftControlsUp(i);
                        }
                        else
                        {
                            ShiftControlsLeft(i);
                        }
                    }
                    if (!bWasVisible && bIsVisible)
                    {
                        _visibilityState[i] = true;

                        if (!_first)
                        {
                            if (layout.Orientation == System.Windows.Controls.Orientation.Vertical)
                            {
                                ShiftControlsDown(i);
                            }
                            else
                            {
                                ShiftControlsRight(i);
                            }
                        }
                    }
                    else if (bWasVisible && !bIsVisible)
                    {
                        if (Children[i].IsEffectAnimating(AnimationType.Hidden))
                        {
                            continue;
                        }
                        _visibilityState[i] = false;

                        if (!_first)
                        {
                            if (layout.Orientation == System.Windows.Controls.Orientation.Vertical)
                            {
                                ShiftControlsUp(i);
                            }
                            else
                            {
                                ShiftControlsLeft(i);
                            }
                        }
                    }
                }
                _first = false;
                StoreButtonsModifiedPosition();
            }
        }
コード例 #8
0
        private static void UpdateControlWithXmlData(GUIControl control, Type controlType, XmlNode pControlNode,
                                                     IDictionary <string, string> defines, string filename)
        {
            List <int> vecInfo = new List <int>();
            IDictionary <XMLSkinAttribute, MemberInfo> attributesThatCanBeUpdates = GetAttributesToUpdate(controlType);

            if (attributesThatCanBeUpdates != null)
            {
                var nodeDic = getNodes(pControlNode);
                foreach (KeyValuePair <XMLSkinAttribute, MemberInfo> en in attributesThatCanBeUpdates)
                {
                    XMLSkinAttribute xmlAttr = (XMLSkinAttribute)en.Key;
                    MemberInfo       correspondingMemberAttr = en.Value as MemberInfo;
                    //XmlNode elementNode = pControlNode.SelectSingleNode(xmlAttr.XmlElementName);
                    //XmlNode elementNode = pControlNode.SelectSingleNodeFast(xmlAttr.XmlElementName);
                    XmlNode elementNode;
                    //if (elementNode != null)
                    if (nodeDic.TryGetValue(xmlAttr.XmlElementName, out elementNode))
                    {
                        XmlNode attribNode = elementNode.Attributes.GetNamedItem(xmlAttr.XmlAttributeName);
                        if (attribNode != null)
                        {
                            if (correspondingMemberAttr != null)
                            {
                                string text = attribNode.Value;

                                // Window defines (passed in) override references defines (cached).
                                if (text.Length > 0 && text[0] == '#')
                                {
                                    string foundDefine = null;
                                    if (defines.TryGetValue(text, out foundDefine))
                                    {
                                        text = foundDefine;
                                    }
                                    else
                                    {
                                        if (_cachedDefines.TryGetValue(text, out foundDefine))
                                        {
                                            text = foundDefine;
                                        }
                                    }
                                }

                                object newValue = null;

                                if (correspondingMemberAttr.MemberType == MemberTypes.Field)
                                {
                                    newValue = ConvertXmlStringToObject(xmlAttr.XmlAttributeName, text,
                                                                        ((FieldInfo)correspondingMemberAttr).FieldType);
                                }
                                else if (correspondingMemberAttr.MemberType == MemberTypes.Property)
                                {
                                    newValue = ConvertXmlStringToObject(xmlAttr.XmlAttributeName, text,
                                                                        ((PropertyInfo)correspondingMemberAttr).PropertyType);
                                }

                                try
                                {
                                    if (correspondingMemberAttr.MemberType == MemberTypes.Field)
                                    {
                                        ((FieldInfo)correspondingMemberAttr).SetValue(control, newValue);
                                    }
                                    else if (correspondingMemberAttr.MemberType == MemberTypes.Property)
                                    {
                                        ((PropertyInfo)correspondingMemberAttr).SetValue(control, newValue, null);
                                    }
                                }
                                catch (Exception e)
                                {
                                    Log.Info("Couldn't place {0}, which is {1} in {2}. Exception:{3}",
                                             newValue, newValue.GetType(), correspondingMemberAttr, e);
                                }
                            }
                            else
                            {
                                if (char.IsUpper(xmlAttr.XmlAttributeName[0]))
                                {
                                    PropertyInfo propertyInfo;

                                    if (xmlAttr.XmlAttributeName.IndexOf('.') != -1)
                                    {
                                        propertyInfo = controlType.GetProperty(xmlAttr.XmlAttributeName.Split('.')[1]);
                                    }
                                    else
                                    {
                                        propertyInfo = controlType.GetProperty(xmlAttr.XmlAttributeName);
                                    }

                                    if (propertyInfo == null)
                                    {
                                        Log.Info(
                                            "GUIControlFactory.UpdateControlWithXmlData: '{0}' does not contain a definition for '{1}'",
                                            controlType, xmlAttr.XmlAttributeName);
                                        return;
                                    }
                                }
                            }
                        }
                    }
                }
            }
            IDictionary <string, MemberInfo> membersThatCanBeUpdated = GetMembersToUpdate(controlType);
            List <VisualEffect> animations      = new List <VisualEffect>();
            List <VisualEffect> thumbAnimations = new List <VisualEffect>();
            XmlNodeList         childNodes      = pControlNode.ChildNodes;
            bool hasVisiblecondition            = false;

            foreach (XmlNode element in childNodes)
            {
                if (element.Name == "visible")
                {
                    if (element.InnerText != null)
                    {
                        hasVisiblecondition = true;
                        if (element.InnerText != "yes" && element.InnerText != "no")
                        {
                            if (element.InnerText.Length != 0)
                            {
                                int  iVisibleCondition = 0;
                                bool allowHiddenFocus  = false;
                                //Add parent's visible condition in addition to ours
                                XmlNode parentNode = pControlNode.ParentNode;
                                if (IsGroupControl(parentNode))
                                {
                                    string parentVisiblecondition = GetVisibleConditionXML(parentNode);
                                    if (!string.IsNullOrEmpty(parentVisiblecondition) && parentVisiblecondition != "yes" &&
                                        parentVisiblecondition != "no")
                                    {
                                        element.InnerText += "+[" + parentVisiblecondition + "]";
                                    }
                                }
                                GetConditionalVisibility(element, control, ref iVisibleCondition, ref allowHiddenFocus);
                                control.SetVisibleCondition(iVisibleCondition, allowHiddenFocus);
                                continue;
                            }
                        }
                    }
                }
                if (element.Name == "animation")
                {
                    VisualEffect effect = new VisualEffect();
                    if (effect.Create(element))
                    {
                        if (effect.AnimationType == AnimationType.VisibleChange)
                        {
                            effect.AnimationType = AnimationType.Visible;
                            //if (effect.IsReversible)
                            {
                                VisualEffect effect2 = (VisualEffect)effect.CloneReverse();
                                effect2.AnimationType = AnimationType.Hidden;
                                //animations.Add(effect);
                                animations.Add(effect2);
                                //continue;
                            }
                        }
                        animations.Add(effect);
                        continue;
                    }
                }
                if (element.Name == "thumbAnimation")
                {
                    VisualEffect effect = new VisualEffect();
                    if (effect.Create(element))
                    {
                        thumbAnimations.Add(effect);
                        continue;
                    }
                }
                if (element.Name == "info")
                {
                    List <string> infoList = new List <string>();
                    if (GetMultipleString(element, "info", ref infoList))
                    {
                        vecInfo.Clear();
                        for (int i = 0; i < infoList.Count; i++)
                        {
                            int infoId = GUIInfoManager.TranslateString(infoList[i]);
                            if (infoId != 0)
                            {
                                vecInfo.Add(infoId);
                            }
                        }
                    }
                    control.Info = vecInfo;
                }
                MemberInfo correspondingMember = null;
                membersThatCanBeUpdated.TryGetValue(element.Name, out correspondingMember);

                if (correspondingMember != null)
                {
                    string text = element.InnerText;

                    // Window defines (passed in) override references defines (cached).
                    if (text.Length > 0 && text[0] == '#')
                    {
                        string foundDefine = null;

                        if (defines.TryGetValue(text, out foundDefine))
                        {
                            text = foundDefine;
                        }
                        else
                        {
                            if (_cachedDefines.TryGetValue(text, out foundDefine))
                            {
                                text = foundDefine;
                            }
                        }
                    }

                    object newValue = null;

                    if (correspondingMember.MemberType == MemberTypes.Field)
                    {
                        newValue = ConvertXmlStringToObject(element.Name, text, ((FieldInfo)correspondingMember).FieldType);
                    }
                    else if (correspondingMember.MemberType == MemberTypes.Property)
                    {
                        newValue = ConvertXmlStringToObject(element.Name, text, ((PropertyInfo)correspondingMember).PropertyType);
                    }

                    try
                    {
                        if (correspondingMember.MemberType == MemberTypes.Field)
                        {
                            ((FieldInfo)correspondingMember).SetValue(control, newValue);
                        }
                        else if (correspondingMember.MemberType == MemberTypes.Property)
                        {
                            ((PropertyInfo)correspondingMember).SetValue(control, newValue, null);
                        }
                    }
                    catch (Exception e)
                    {
                        Log.Info("Couldn't place {0}, which is {1} in {2}. Exception:{3}",
                                 newValue, newValue.GetType(), correspondingMember, e);
                    }
                }
                else
                {
                    if (char.IsUpper(element.Name[0]))
                    {
                        PropertyInfo propertyInfo;

                        if (element.Name.IndexOf('.') != -1)
                        {
                            propertyInfo = controlType.GetProperty(element.Name.Split('.')[1]);
                        }
                        else
                        {
                            propertyInfo = controlType.GetProperty(element.Name);
                        }

                        if (propertyInfo == null)
                        {
                            Log.Info("GUIControlFactory.UpdateControlWithXmlData: '{0}' does not contain a definition for '{1}'",
                                     controlType, element.Name);
                            return;
                        }

                        string xml = element.OuterXml;

                        if (xml.IndexOf("Button.") != -1)
                        {
                            xml = xml.Replace("Button.", "GUIControl.");
                        }
                        else if (xml.IndexOf("Window.") != -1)
                        {
                            xml = xml.Replace("Window.", "GUIWindow.");
                        }

                        XamlParser.LoadXml(xml, XmlNodeType.Element, control, filename);
                    }
                }
            }

            //Set parent control's visible condition as ours wn if we're children of a group
            if (!hasVisiblecondition)
            {
                XmlNode parentNode = pControlNode.ParentNode;
                if (IsGroupControl(parentNode))
                {
                    XmlDocument tempDoc                = new XmlDocument();
                    XmlNode     elem                   = tempDoc.CreateElement("visible");
                    int         iVisibleCondition      = 0;
                    bool        allowHiddenFocus       = true;
                    string      parentVisiblecondition = GetVisibleConditionXML(parentNode);
                    if (!string.IsNullOrEmpty(parentVisiblecondition) && parentVisiblecondition != "yes" &&
                        parentVisiblecondition != "no")
                    {
                        elem.InnerText = parentVisiblecondition;
                        XmlNode visibleNode = pControlNode.OwnerDocument.ImportNode(elem, true);
                        pControlNode.AppendChild(visibleNode);
                        GetConditionalVisibility(visibleNode, control, ref iVisibleCondition, ref allowHiddenFocus);
                        control.SetVisibleCondition(iVisibleCondition, allowHiddenFocus);
                    }
                }
            }
            if (animations.Count > 0)
            {
                control.SetAnimations(animations);
            }
            if (thumbAnimations.Count > 0)
            {
                control.SetThumbAnimations(thumbAnimations);
            }
        }
コード例 #9
0
        public bool Create(XmlNode node)
        {
            string animType = node.InnerText.ToLowerInvariant();

            if (String.Compare(animType, "visible", true) == 0)
            {
                _type = AnimationType.Visible;
            }

            else if (String.Compare(animType, "visiblechange", true) == 0)
            {
                _type = AnimationType.VisibleChange;
            }
            else if (String.Compare(animType, "hidden", true) == 0)
            {
                _type = AnimationType.Hidden;
            }
            else if (String.Compare(animType, "focus", true) == 0)
            {
                _type = AnimationType.Focus;
            }
            else if (String.Compare(animType, "unfocus", true) == 0)
            {
                _type = AnimationType.Unfocus;
            }
            else if (String.Compare(animType, "windowopen", true) == 0)
            {
                _type = AnimationType.WindowOpen;
            }
            else if (String.Compare(animType, "windowclose", true) == 0)
            {
                _type = AnimationType.WindowClose;
            }
            else if (String.Compare(animType, "conditional", true) == 0)
            {
                _type = AnimationType.Conditional;
                SetInitialCondition();
            }
            if (_type == AnimationType.None)
            {
                Log.Error(String.Format("Control has invalid animation type [{0} on {1}]", animType, node.Name));
                return(false);
            }
            XmlNode nodeAttribute = node.Attributes.GetNamedItem("condition");

            if (nodeAttribute != null)
            {
                string conditionString = nodeAttribute.Value;
                _condition = GUIInfoManager.TranslateString(conditionString);
            }
            nodeAttribute = node.Attributes.GetNamedItem("effect");
            if (nodeAttribute == null)
            {
                return(false);
            }
            string effectType = nodeAttribute.Value;

            // effect type
            if (String.Compare(effectType, "fade", true) == 0)
            {
                _effect = EffectType.Fade;
            }
            else if (String.Compare(effectType, "slide", true) == 0)
            {
                _effect = EffectType.Slide;
            }
            else if (String.Compare(effectType, "rotate", true) == 0)
            {
                _effect = EffectType.RotateZ;
            }
            else if (String.Compare(effectType, "rotatey", true) == 0)
            {
                _effect = EffectType.RotateY;
            }
            else if (String.Compare(effectType, "rotatex", true) == 0)
            {
                _effect = EffectType.RotateX;
            }
            else if (String.Compare(effectType, "zoom", true) == 0)
            {
                _effect = EffectType.Zoom;
            }
            if (_effect == EffectType.None)
            {
                Log.Error(String.Format("Control has invalid effect type [{0} on {1}]", effectType, node.Name));
                return(false);
            }
            // time and delay
            nodeAttribute = node.Attributes.GetNamedItem("time");
            UInt32.TryParse(nodeAttribute.Value.ToString(), out _length);

            nodeAttribute = node.Attributes.GetNamedItem("delay");
            if (nodeAttribute != null)
            {
                UInt32.TryParse(nodeAttribute.Value.ToString(), out _delay);
            }

            //_length = (uint)(_length * g_SkinInfo.GetEffectsSlowdown());
            //_delay = (uint)(_delay * g_SkinInfo.GetEffectsSlowdown());

            _tweener      = null;
            nodeAttribute = node.Attributes.GetNamedItem("tween");
            if (nodeAttribute != null)
            {
                string tweenMode = nodeAttribute.Value;
                if (tweenMode == "linear")
                {
                    _tweener = new LinearTweener();
                }
                else if (tweenMode == "quadratic")
                {
                    _tweener = new QuadTweener();
                }
                else if (tweenMode == "cubic")
                {
                    _tweener = new CubicTweener();
                }
                else if (tweenMode == "sine")
                {
                    _tweener = new SineTweener();
                }
                else if (tweenMode == "back")
                {
                    _tweener = new BackTweener();
                }
                else if (tweenMode == "circle")
                {
                    _tweener = new CircleTweener();
                }
                else if (tweenMode == "bounce")
                {
                    _tweener = new BounceTweener();
                }
                else if (tweenMode == "elastic")
                {
                    _tweener = new ElasticTweener();
                }
                nodeAttribute = node.Attributes.GetNamedItem("easing");
                if (nodeAttribute != null && _tweener != null)
                {
                    string easing = nodeAttribute.Value;
                    if (easing == "in")
                    {
                        _tweener.Easing = TweenerType.EASE_IN;
                    }
                    else if (easing == "out")
                    {
                        _tweener.Easing = TweenerType.EASE_OUT;
                    }
                    else if (easing == "inout")
                    {
                        _tweener.Easing = TweenerType.EASE_INOUT;
                    }
                }
            }

            // acceleration of effect
            //float accel;
            nodeAttribute = node.Attributes.GetNamedItem("acceleration");
            if (nodeAttribute != null)
            {
                float acceleration = GetFloat(nodeAttribute.Value.ToString());
                if (_tweener == null)
                {
                    if (acceleration != 0.0f)
                    {
                        _tweener        = new QuadTweener(acceleration);
                        _tweener.Easing = TweenerType.EASE_IN;
                    }
                    else
                    {
                        _tweener = new LinearTweener();
                    }
                }
            }


            // reversible (defaults to true)
            nodeAttribute = node.Attributes.GetNamedItem("reversible");
            if (nodeAttribute != null)
            {
                string reverse = nodeAttribute.Value;
                if (String.Compare(reverse, "false") == 0)
                {
                    _isReversible = false;
                }
            }

            // conditional parameters
            if (_type == AnimationType.Conditional)
            {
                nodeAttribute = node.Attributes.GetNamedItem("pulse");
                if (nodeAttribute != null)
                {
                    string reverse = nodeAttribute.Value;
                    if (String.Compare(reverse, "true") == 0)
                    {
                        _repeatAnim = AnimationRepeat.Pulse;
                    }
                }
                nodeAttribute = node.Attributes.GetNamedItem("loop");
                if (nodeAttribute != null)
                {
                    string reverse = nodeAttribute.Value;
                    if (String.Compare(reverse, "true") == 0)
                    {
                        _repeatAnim = AnimationRepeat.Loop;
                    }
                }

                // Analog Clock animation
                nodeAttribute = node.Attributes.GetNamedItem("clockhandle");
                if (nodeAttribute != null)
                {
                    string clockType = nodeAttribute.Value;
                    if (String.Compare(clockType, "second") == 0)
                    {
                        _clockHandle = ClockHandleType.Second;
                    }
                    else if (String.Compare(clockType, "minute") == 0)
                    {
                        _clockHandle = ClockHandleType.Minute;
                    }
                    else if (String.Compare(clockType, "hour") == 0)
                    {
                        _clockHandle = ClockHandleType.Hour;
                    }
                    else
                    {
                        _clockHandle = ClockHandleType.None;
                    }
                }
            }

            // slide parameters
            if (_effect == EffectType.Slide)
            {
                nodeAttribute = node.Attributes.GetNamedItem("start");
                if (nodeAttribute != null)
                {
                    string startPos = nodeAttribute.Value;
                    GetPosition(startPos, ref _startX, ref _startY);
                }
                nodeAttribute = node.Attributes.GetNamedItem("end");
                if (nodeAttribute != null)
                {
                    string endPos = nodeAttribute.Value;
                    GetPosition(endPos, ref _endX, ref _endY);
                }
                // scale our parameters
                GUIGraphicsContext.ScaleHorizontal(ref _startX);
                GUIGraphicsContext.ScaleVertical(ref _startY);
                GUIGraphicsContext.ScaleHorizontal(ref _endX);
                GUIGraphicsContext.ScaleVertical(ref _endY);
            }
            else if (_effect == EffectType.Fade)
            {
                // alpha parameters
                if (_type < 0)
                {
                    // out effect defaults
                    _startAlpha = 100;
                    _endAlpha   = 0;
                }
                else
                {
                    // in effect defaults
                    _startAlpha = 0;
                    _endAlpha   = 100;
                }
                nodeAttribute = node.Attributes.GetNamedItem("start");
                if (nodeAttribute != null)
                {
                    _startAlpha = Int32.Parse(nodeAttribute.Value.ToString());
                }
                nodeAttribute = node.Attributes.GetNamedItem("end");
                if (nodeAttribute != null)
                {
                    _endAlpha = Int32.Parse(nodeAttribute.Value.ToString());
                }

                if (_startAlpha > 100)
                {
                    _startAlpha = 100;
                }
                if (_endAlpha > 100)
                {
                    _endAlpha = 100;
                }
                if (_startAlpha < 0)
                {
                    _startAlpha = 0;
                }
                if (_endAlpha < 0)
                {
                    _endAlpha = 0;
                }
            }
            else if (_effect == EffectType.RotateZ || _effect == EffectType.RotateX || _effect == EffectType.RotateY)
            {
                nodeAttribute = node.Attributes.GetNamedItem("start");
                if (nodeAttribute != null)
                {
                    _startX = float.Parse(nodeAttribute.Value);
                }
                nodeAttribute = node.Attributes.GetNamedItem("end");
                if (nodeAttribute != null)
                {
                    _endX = float.Parse(nodeAttribute.Value);
                }

                // convert to a negative to account for our reversed vertical axis
                _startX *= -1;
                _endX   *= -1;


                nodeAttribute = node.Attributes.GetNamedItem("center");
                if (nodeAttribute != null)
                {
                    string centerPos = nodeAttribute.Value;
                    GetPosition(centerPos, ref _centerX, ref _centerY);
                    GUIGraphicsContext.ScaleHorizontal(ref _centerX);
                    GUIGraphicsContext.ScaleVertical(ref _centerY);
                }
            }
            else // if (effect == EffectType.Zoom)
            {
                // effect defaults
                _startX = _startY = 100;
                _endX   = _endY = 100;

                nodeAttribute = node.Attributes.GetNamedItem("start");
                if (nodeAttribute != null)
                {
                    string start = nodeAttribute.Value;
                    GetPosition(start, ref _startX, ref _startY);
                    if (_startX == 0)
                    {
                        _startX = 100;
                    }
                    if (_startY == 0)
                    {
                        _startY = 100;
                    }
                }
                nodeAttribute = node.Attributes.GetNamedItem("end");
                if (nodeAttribute != null)
                {
                    string endLine = nodeAttribute.Value;
                    GetPosition(endLine, ref _endX, ref _endY);
                    if (_endX == 0)
                    {
                        _endX = 100;
                    }
                    if (_endY == 0)
                    {
                        _endY = 100;
                    }
                }
                nodeAttribute = node.Attributes.GetNamedItem("center");
                if (nodeAttribute != null)
                {
                    string center = nodeAttribute.Value;
                    GetPosition(center, ref _centerX, ref _centerY);
                    GUIGraphicsContext.ScaleHorizontal(ref _centerX);
                    GUIGraphicsContext.ScaleVertical(ref _centerY);
                }
                else
                {
                    /*
                     * // no center specified
                     * // calculate the center position...
                     * if (_startX != 0)
                     * {
                     * float scale = _endX / _startX;
                     * if (scale != 1)
                     *  _centerX = (_endPosX - scale * _startPosX) / (1 - scale);
                     * }
                     * if (_startY != 0)
                     * {
                     * float scale = _endY / _startY;
                     * if (scale != 1)
                     *  _centerY = (_endPosY - scale * _startPosY) / (1 - scale);
                     * }*/
                }
            }
            return(true);
        }
コード例 #10
0
ファイル: Functions.cs プロジェクト: c3333/MediaPortal-1
        public static object SkinHasSetting(string setting)
        {
            int condition = GUIInfoManager.TranslateString("skin.hassetting(" + setting + ")");

            return(GUIInfoManager.GetBool(condition, 0));
        }
コード例 #11
0
ファイル: Functions.cs プロジェクト: c3333/MediaPortal-1
        public static bool PluginIsEnabled(string name)
        {
            int condition = GUIInfoManager.TranslateString("plugin.isenabled(" + name + ")");

            return(GUIInfoManager.GetBool(condition, 0));
        }
コード例 #12
0
ファイル: Functions.cs プロジェクト: c3333/MediaPortal-1
        public static object SkinHasTheme(string theme)
        {
            int condition = GUIInfoManager.TranslateSingleString("skin.hastheme(" + theme + ")");

            return(GUIInfoManager.GetBool(condition, 0));
        }
コード例 #13
0
ファイル: ImageElement.cs プロジェクト: MisterD81/MyMPlayer
        /// <summary>
        /// Gets the rectangle of the image
        /// </summary>
        /// <returns>Rectangle of the image</returns>
        public RectangleF GetImageRectangle()
        {
            if (_image.rect.IsEmpty)
            {
                _image.Refresh();
            }

            int xFromAnim = 0;
            int yFromAnim = 0;

            foreach (VisualEffect effect in _image.Animations)
            {
                if (effect.CurrentState != AnimationState.None && effect.Effect == EffectType.Slide && (effect.Condition == 0 || GUIInfoManager.GetBool(effect.Condition, 0)))
                {
                    xFromAnim += (int)effect.EndX;
                    yFromAnim += (int)effect.EndY;
                }
            }

            return(new RectangleF(_image._positionX + xFromAnim, _image._positionY + yFromAnim, _image.RenderWidth, _image.RenderHeight));
        }
コード例 #14
0
        /// <summary>
        /// Draws the element for additional osd informations
        /// </summary>
        /// <param name="graph">Graphics</param>
        /// <param name="label">Label content</param>
        /// <param name="strikeout">Strikeout the label, when true</param>
        /// <param name="rectangle">Rectangle for the label</param>
        public void DrawElementAlternative(Graphics graph, String label, bool strikeout, RectangleF rectangle)
        {
            Font temp = _font;

            if (strikeout)
            {
                FontStyle style = _font.Style | FontStyle.Strikeout;
                temp = new Font(_font.FontFamily.Name, _font.Size, style);
            }

            int xFromAnim = 0;
            int yFromAnim = 0;

            foreach (VisualEffect effect in _label.Animations)
            {
                if (effect.CurrentState != AnimationState.None && effect.Effect == EffectType.Slide && (effect.Condition == 0 || GUIInfoManager.GetBool(effect.Condition, 0)))
                {
                    xFromAnim += (int)effect.EndX;
                    yFromAnim += (int)effect.EndY;
                }
            }
            rectangle.X += xFromAnim; rectangle.Y += yFromAnim;

            graph.DrawString(label, temp, _brush, rectangle, StringFormat.GenericTypographic);
        }