private void Initialize(StreamingContext context)
        {
            _type        = LayerType.Image;
            _brush       = Window.Current.Compositor.CreateSurfaceBrush();
            _nineGrid    = Window.Current.Compositor.CreateNineGridBrush();
            _inputEffect = new BorderEffect()
            {
                Name   = _id,
                Source = new CompositionEffectSourceParameter(_id + "Image"),
            };

            _properties = new List <LayerProperty>();
            _properties.Add(new LayerProperty("Offset", _brush));
            _properties.Add(new LayerProperty("Scale", _brush));
            _properties.Add(new LayerProperty("RotationAngleInDegrees", _brush));
            _properties.Add(new LayerProperty("AnchorPoint", _brush));
            _properties.Add(new LayerProperty("Stretch", _brush));
            _properties.Add(new LayerProperty("HorizontalAlignmentRatio", _brush));
            _properties.Add(new LayerProperty("VerticalAlignmentRatio", _brush));
            _properties.Add(new LayerProperty("ExtendX", _inputEffect));
            _properties.Add(new LayerProperty("ExtendY", _inputEffect));
            _properties.Add(new LayerProperty("LeftInset", _nineGrid));
            _properties.Add(new LayerProperty("TopInset", _nineGrid));
            _properties.Add(new LayerProperty("RightInset", _nineGrid));
            _properties.Add(new LayerProperty("BottomInset", _nineGrid));
            _properties.Add(new LayerProperty("LeftInsetScale", _nineGrid));
            _properties.Add(new LayerProperty("TopInsetScale", _nineGrid));
            _properties.Add(new LayerProperty("RightInsetScale", _nineGrid));
            _properties.Add(new LayerProperty("BottomInsetScale", _nineGrid));
            _properties.Add(new LayerProperty("IsCenterHollow", _nineGrid));
        }
示例#2
0
        public SurfaceNineGridScenario(Compositor compositor, CompositionSurfaceBrush surfaceBrush, string text)
        {
            _nineGridBrush        = compositor.CreateNineGridBrush();
            _nineGridBrush.Source = surfaceBrush;
            _nineGridBrush.SetInsets(60.0f);

            _text = text;
        }
示例#3
0
        public ColorNineGridScenario(Compositor compositor, string text)
        {
            _nineGridBrush        = compositor.CreateNineGridBrush();
            _nineGridBrush.Source = compositor.CreateColorBrush(Colors.Black);
            _nineGridBrush.SetInsets(10.0f);
            _nineGridBrush.IsCenterHollow = true;

            _text = text;
        }
示例#4
0
        public MaskNineGridScenario(Compositor compositor, CompositionSurfaceBrush surfaceBrush, string text)
        {
            CompositionNineGridBrush brush = compositor.CreateNineGridBrush();

            brush.Source = surfaceBrush;
            brush.SetInsets(60.0f);
            brush.IsCenterHollow = true;

            _nineGridMaskBrush        = compositor.CreateMaskBrush();
            _nineGridMaskBrush.Mask   = brush;
            _nineGridMaskBrush.Source = compositor.CreateColorBrush(Colors.Black);

            _text = text;
        }
示例#5
0
        public EffectNineGridScenario(Compositor compositor, CompositionNineGridBrush sourceNineGridBrush, string text)
        {
            var saturationEffect = new SaturationEffect
            {
                Saturation = 0f,
                Source     = new CompositionEffectSourceParameter("sourceNineGridBrush"),
            };
            var saturationFactory = compositor.CreateEffectFactory(saturationEffect);

            _nineGridEffectBrush = saturationFactory.CreateBrush();
            _nineGridEffectBrush.SetSourceParameter("sourceNineGridBrush", sourceNineGridBrush); //takes a ninegrid source as input

            _text = text;
        }
        public BorderNineGridScenario(Compositor compositor, CompositionSurfaceBrush surfaceBrush, Vector2 hostVisualSize, string text)
        {
            _nineGridBrush        = compositor.CreateNineGridBrush();
            _nineGridBrush.Source = compositor.CreateColorBrush(Colors.Black);
            _nineGridBrush.SetInsets(10.0f);
            _nineGridBrush.IsCenterHollow = true;

            _borderedContent        = compositor.CreateSpriteVisual();
            _borderedContent.Size   = hostVisualSize - new Vector2(2 * 10.0f);
            _borderedContent.Offset = new Vector3(10.0f, 10.0f, 0);
            _borderedContent.Brush  = surfaceBrush;

            _compositor = compositor;
            _text       = text;
        }
示例#7
0
        public NineGridResizing()
        {
            this.InitializeComponent();

            _compositor = ElementCompositionPreview.GetElementVisual(this).Compositor;

            // Add page loaded event listener
            this.Loaded += NineGridResizing_Loaded;

            // Set data context for data binding
            DataContext = this;

            // Sprite visual to be painted
            _ninegridVisual = _compositor.CreateSpriteVisual();

            // Create ninegridbrush and paint on visual;
            _ninegridBrush        = _compositor.CreateNineGridBrush();
            _ninegridVisual.Brush = _ninegridBrush;
            _ninegridSurface      = ImageLoader.Instance.LoadFromUri(new Uri("ms-appx:///Samples/SDK 14393/NineGridResizing/RoundedRect.png"));

            // Clip compgrid
            var compGrid = ElementCompositionPreview.GetElementVisual(CompGrid);

            compGrid.Clip = _compositor.CreateInsetClip();

            // Scene container to be scaled
            _backgroundContainer = ElementCompositionPreview.GetElementVisual(bkgHost);

            // Insert Composition island
            ElementCompositionPreview.SetElementChildVisual(ngHost, _ninegridVisual);

            // Instatiate brush scenario list and fill with created brush scenarios
            _nineGridBrushScenarios = new ObservableCollection <INineGridScenario>(CreateBrushes(_compositor, _ninegridSurface, _ninegridVisual.Size));

            // Set default combo box selection to first item
            BrushScenarioSelected = _nineGridBrushScenarios.FirstOrDefault();

            // Value timer initialization for sliders
            _valueTimerXSlider = new ValueTimer <float>();
            _valueTimerXSlider.ValueChanged += OnXSliderValueChanged;

            _valueTimerYSlider = new ValueTimer <float>();
            _valueTimerYSlider.ValueChanged += OnYSliderValueChanged;

            _valueTimerScaleSlider = new ValueTimer <float>();
            _valueTimerScaleSlider.ValueChanged += OnScaleSliderValueChanged;
        }
 /// <summary>
 /// Create an ExpressionNode reference to this CompositionObject.
 /// </summary>
 /// <param name="compObj">The comp object.</param>
 /// <returns>NineGridBrushReferenceNode.</returns>
 public static NineGridBrushReferenceNode GetReference(this CompositionNineGridBrush compObj)
 {
     return(new NineGridBrushReferenceNode(null, compObj));
 }
示例#9
0
 internal NineGridBrushReferenceNode(string paramName, CompositionNineGridBrush brush = null) : base(paramName, brush)
 {
 }