Esempio n. 1
0
        private void CreateNodeClick(object sender, RoutedEventArgs e)
        {
            if (tvUISTree.SelectedItem is TreeViewItem tvi &&
                tvi.Header is UISObject obj &&
                obj is UISList lst)
            {
                Type listType = lst.GetListType();
                if (listType == typeof(UISObject))
                {
                    AllowTag = new ObjectTag[] { ObjectTag.AnimationDefine, ObjectTag.Comment, ObjectTag.Predefined, ObjectTag.Functional, ObjectTag.Custom, ObjectTag.List };
                }
                else if (listType == typeof(UISProperty))
                {
                    AllowTag = Enum.GetValues(typeof(Property));
                }
                else if (listType == typeof(UISAnimation))
                {
                    AllowTag = Enum.GetValues(typeof(AnimationName));
                }
                else if (listType == typeof(UISFunctionalElement))
                {
                    AllowTag = Enum.GetValues(typeof(FunctionElementType));
                }
                else
                {
                    ObjectTag tag = PropertyConstraint.GetPropertyConstraint <ObjectTag>(lst.GetListType());
                    AllowTag = new ObjectTag[] { tag };
                }

                ShowModalDialog(true);
                this.PopupContent.LoadDialog(Dialog.CreateNode);
            }
        }
Esempio n. 2
0
        private static UISAnimation Animation()
        {
            Word aniName;

            aniName = look as Word;
            ExpectGrammar(Tag.IDENTITY);
            if (aniName.Lexeme != "name")
            {
                ThrowError(new UISAnimationNameMissingException(aniName.Lexeme));
            }
            ExpectGrammar(Tag.Equal);
            aniName = look as Word;
            string animation_name = string.Empty;

            if (aniName.Lexeme.Length <= 2)
            {
                animation_name = PropertyConstraint.GetPropertyConstraint <string>(aniName.Lexeme);
            }
            else
            {
                animation_name = aniName.Lexeme;
            }
            ExpectGrammar(Tag.IDENTITY);

            Func <UISValue> readFunc;

            if (Enum.TryParse(animation_name, true, out AnimationName TargetAnimate))
            {
                readFunc = PropertyConstraint.GetPropertyConstraint <Func <UISValue> >(TargetAnimate);
            }
            else
            {
                readFunc = null;
                ThrowError(new UISUnsupportAnimationException(aniName.Lexeme));
            }

            ExpectGrammar(Tag.Split);

            Word         kw;
            UISAnimation ani = new UISAnimation(TargetAnimate);

            do
            {
                kw = look as Word;
                if (kw == null)
                {
                    break;
                }
                ExpectGrammar(Tag.IDENTITY);
                switch (kw.Lexeme.ToLower())
                {
                case "from":
                    ExpectGrammar(Tag.Equal);
                    ani.AddAnimationProperty(new UISAnimationProperty(AnimationType.FROM, readFunc() as UISLiteralValue));
                    Expect(Tag.Split);
                    break;

                case "to":
                    ExpectGrammar(Tag.Equal);
                    ani.AddAnimationProperty(new UISAnimationProperty(AnimationType.TO, readFunc() as UISLiteralValue));
                    Expect(Tag.Split);
                    break;

                case "time":
                    ExpectGrammar(Tag.Equal);
                    ani.AddAnimationProperty(new UISAnimationProperty(AnimationType.TIME, AnimationTime()));
                    Expect(Tag.Split);
                    break;

                case "atime":
                    ExpectGrammar(Tag.Equal);
                    ani.AddAnimationProperty(new UISAnimationProperty(AnimationType.ATIME, AnimationTime()));
                    Expect(Tag.Split);
                    break;

                case "repeat":
                    ExpectGrammar(Tag.Equal);
                    ani.AddAnimationProperty(new UISAnimationProperty(AnimationType.REPEAT, AnimationRepeat()));
                    Expect(Tag.Split);
                    break;

                case "trans":
                    ExpectGrammar(Tag.Equal);
                    ani.AddAnimationProperty(new UISAnimationProperty(AnimationType.TRANS, new UISAnimationCurve(ReadCurve())));
                    Expect(Tag.Split);
                    break;

                default:
                    ThrowError(new UISUnsupportAnimationControllerException(kw.Lexeme));
                    break;
                }
            } while (!Test(Tag.LINE_END));

            return(ani);
        }
Esempio n. 3
0
 /// <summary>
 /// Read value by constrainted <see cref="Func{UISValue}"/>
 /// </summary>
 /// <returns></returns>
 private static UISValue Value()
 {
     return(PropertyConstraint.GetPropertyConstraint <Func <UISValue> >(CURRENT_PROPERTY)());
 }
Esempio n. 4
0
 public static string GetRelativeUri(Dialog dialog)
 {
     return($"pack://application:,,,/UISEditor;component/{PropertyConstraint.GetPropertyConstraint<string>(dialog)}");
 }