コード例 #1
0
ファイル: MediaElementModel.cs プロジェクト: Gigas002/Jaml
        /// <inheritdoc />
        public new void BindProperties(T element, ICommandProvider commandProvider = null,
                                       IList <StyleModel> styleModels = null)
        {
            if (element is null)
            {
                throw new UIException(nameof(element));
            }

            element.Balance        = Balance;
            element.Clock          = Clock;
            element.IsMuted        = IsMuted;
            element.LoadedBehavior = LoadedBehavior;

            bool isParsed = TimeSpan.TryParse(Position, out TimeSpan positionTimeSpan);

            element.Position = isParsed ? positionTimeSpan : default;

            element.ScrubbingEnabled = ScrubbingEnabled;

            if (!string.IsNullOrWhiteSpace(Source))
            {
                element.Source = PathsHelper.GetUriFromRelativePath(Source);
            }

            element.SpeedRatio       = SpeedRatio;
            element.Stretch          = Stretch;
            element.StretchDirection = StretchDirection;
            element.UnloadedBehavior = UnloadedBehavior;
            element.Volume           = Volume;
        }
コード例 #2
0
        /// <inheritdoc />
        public new void BindProperties(T element, ICommandProvider commandProvider = null,
                                       IList <StyleModel> styleModels = null)
        {
            if (element is null)
            {
                throw new UIException(nameof(element));
            }

            if (!string.IsNullOrWhiteSpace(Source))
            {
                element.Source = new BitmapImage(PathsHelper.GetUriFromRelativePath(Source));
            }
        }
コード例 #3
0
ファイル: StyleModel.cs プロジェクト: Gigas002/Jaml
        /// <inheritdoc />
        public T ToStyle <T>() where T : Style, new()
        {
            //todo improve this ugly code?
            T style = new T();

            FontWeight fontWeight      = PropertyParser.ParseFontWeight(FontWeight);
            FontStyle  fontStyle       = PropertyParser.ParseFontStyle(FontStyle);
            Brush      foreground      = PropertyParser.ConvertArgbToBrush(Foreground);
            Brush      background      = PropertyParser.ParseBackground(Background);
            Thickness  borderThickness = new Thickness(BorderThickness);
            bool       isParsed        = Enum.TryParse(Visibility, out Visibility visibility);

            visibility = isParsed ? visibility : default;

            style.Setters.Add(new Setter {
                Property = Control.FontWeightProperty, Value = fontWeight
            });
            style.Setters.Add(new Setter {
                Property = Control.FontStyleProperty, Value = fontStyle
            });
            style.Setters.Add(new Setter {
                Property = Control.FontSizeProperty, Value = FontSize
            });
            style.Setters.Add(new Setter {
                Property = Control.ForegroundProperty, Value = foreground
            });
            style.Setters.Add(new Setter {
                Property = Control.BackgroundProperty, Value = background
            });
            style.Setters.Add(new Setter {
                Property = Control.BorderThicknessProperty, Value = borderThickness
            });
            style.Setters.Add(new Setter {
                Property = UIElement.VisibilityProperty, Value = visibility
            });

            if (string.IsNullOrWhiteSpace(FontFamily))
            {
                return(style);
            }

            style.Setters.Add(new Setter
            {
                Property = Control.FontFamilyProperty,
                Value    = new FontFamily(PathsHelper.GetUriFromRelativePath(FontFamily), string.Empty)
            });

            return(style);
        }