예제 #1
0
        // ReSharper disable once SuggestBaseTypeForParameter
        private static PropertyKey <T> RegisterCommon <T>(DependencyPropertyKeyMetadata dependencyPropertyMetadata, string name, Type ownerType, T defaultValue, ValidateValueCallback <T> validateValueCallback, ObjectInvalidationCallback <T> invalidationCallback, params PropertyKeyMetadata[] otherMetadatas)
        {
            var metadataList = new List <PropertyKeyMetadata> {
                dependencyPropertyMetadata, DefaultValueMetadata.Static(defaultValue)
            };

            if (validateValueCallback != null)
            {
                metadataList.Add(ValidateValueMetadata.New(validateValueCallback));
            }
            if (invalidationCallback != null)
            {
                metadataList.Add(ObjectInvalidationMetadata.New(invalidationCallback));
            }
            metadataList.AddRange(otherMetadatas);

            return(new PropertyKey <T>(name, ownerType, metadataList.ToArray()));
        }
예제 #2
0
        protected override void LoadContent()
        {
            base.LoadContent();

            // create effect and geometric primitives
            Batch = new UIBatch(GraphicsDevice);

            // create depth stencil states
            var depthStencilDescription = new DepthStencilStateDescription(true, true)
            {
                StencilEnable = true,
                FrontFace     = new DepthStencilStencilOpDescription
                {
                    StencilDepthBufferFail = StencilOperation.Keep,
                    StencilFail            = StencilOperation.Keep,
                    StencilPass            = StencilOperation.Keep,
                    StencilFunction        = CompareFunction.Equal
                },
                BackFace = new DepthStencilStencilOpDescription
                {
                    StencilDepthBufferFail = StencilOperation.Keep,
                    StencilFail            = StencilOperation.Keep,
                    StencilPass            = StencilOperation.Keep,
                    StencilFunction        = CompareFunction.Equal
                },
            };

            KeepStencilValueState = DepthStencilState.New(GraphicsDevice, depthStencilDescription);

            depthStencilDescription.FrontFace.StencilPass = StencilOperation.Increment;
            depthStencilDescription.BackFace.StencilPass  = StencilOperation.Increment;
            IncreaseStencilValueState = DepthStencilState.New(GraphicsDevice, depthStencilDescription);

            depthStencilDescription.FrontFace.StencilPass = StencilOperation.Decrement;
            depthStencilDescription.BackFace.StencilPass  = StencilOperation.Decrement;
            DecreaseStencilValueState = DepthStencilState.New(GraphicsDevice, depthStencilDescription);

            // set the default design of the UI elements.
            var designsTexture = TextureExtensions.CreateTextureFromFileData(GraphicsDevice, DefaultDesigns.Designs);

            Button.PressedImagePropertyKey.DefaultValueMetadata = DefaultValueMetadata.Static(new UIImage("Default button pressed design", designsTexture)
            {
                Borders = 8 * Vector4.One, Region = new RectangleF(71, 3, 32, 32)
            });
            Button.NotPressedImagePropertyKey.DefaultValueMetadata = DefaultValueMetadata.Static(new UIImage("Default button not pressed design", designsTexture)
            {
                Borders = 8 * Vector4.One, Region = new RectangleF(3, 3, 32, 32)
            });
            Button.MouseOverImagePropertyKey.DefaultValueMetadata = DefaultValueMetadata.Static(new UIImage("Default button overred design", designsTexture)
            {
                Borders = 8 * Vector4.One, Region = new RectangleF(37, 3, 32, 32)
            });
            EditText.ActiveImagePropertyKey.DefaultValueMetadata = DefaultValueMetadata.Static(new UIImage("Default edit active design", designsTexture)
            {
                Borders = 12 * Vector4.One, Region = new RectangleF(105, 3, 32, 32)
            });
            EditText.InactiveImagePropertyKey.DefaultValueMetadata = DefaultValueMetadata.Static(new UIImage("Default edit inactive design", designsTexture)
            {
                Borders = 12 * Vector4.One, Region = new RectangleF(139, 3, 32, 32)
            });
            EditText.MouseOverImagePropertyKey.DefaultValueMetadata = DefaultValueMetadata.Static(new UIImage("Default edit overred design", designsTexture)
            {
                Borders = 12 * Vector4.One, Region = new RectangleF(173, 3, 32, 32)
            });
            ToggleButton.CheckedImagePropertyKey.DefaultValueMetadata = DefaultValueMetadata.Static(new UIImage("Default toggle button checked design", designsTexture)
            {
                Borders = 8 * Vector4.One, Region = new RectangleF(71, 3, 32, 32)
            });
            ToggleButton.UncheckedImagePropertyKey.DefaultValueMetadata = DefaultValueMetadata.Static(new UIImage("Default toggle button unchecked design", designsTexture)
            {
                Borders = 8 * Vector4.One, Region = new RectangleF(3, 3, 32, 32)
            });
            ToggleButton.IndeterminateImagePropertyKey.DefaultValueMetadata = DefaultValueMetadata.Static(new UIImage("Default toggle button indeterminate design", designsTexture)
            {
                Borders = 8 * Vector4.One, Region = new RectangleF(37, 3, 32, 32)
            });
            Slider.TrackBackgroundImagePropertyKey.DefaultValueMetadata = DefaultValueMetadata.Static(new UIImage("Default slider track background design", designsTexture)
            {
                Borders = 14 * Vector4.One, Region = new RectangleF(207, 3, 32, 32)
            });
            Slider.TrackForegroundImagePropertyKey.DefaultValueMetadata = DefaultValueMetadata.Static(new UIImage("Default slider track foreground design", designsTexture)
            {
                Borders = 0 * Vector4.One, Region = new RectangleF(3, 37, 32, 32)
            });
            Slider.ThumbImagePropertyKey.DefaultValueMetadata = DefaultValueMetadata.Static(new UIImage("Default slider thumb design", designsTexture)
            {
                Borders = 4 * Vector4.One, Region = new RectangleF(37, 37, 16, 32)
            });
            Slider.MouseOverThumbImagePropertyKey.DefaultValueMetadata = DefaultValueMetadata.Static(new UIImage("Default slider thumb overred design", designsTexture)
            {
                Borders = 4 * Vector4.One, Region = new RectangleF(71, 37, 16, 32)
            });
            Slider.TickImagePropertyKey.DefaultValueMetadata = DefaultValueMetadata.Static(new UIImage("Default slider track foreground design", designsTexture)
            {
                Region = new RectangleF(245, 3, 3, 6)
            });
            Slider.TickOffsetPropertyKey.DefaultValueMetadata            = DefaultValueMetadata.Static(13f);
            Slider.TrackStartingOffsetsrPropertyKey.DefaultValueMetadata = DefaultValueMetadata.Static(new Vector2(3));
        }
예제 #3
0
        protected override async Task LoadContent()
        {
            await base.LoadContent();

            // Set dependency properties test values.
            TextBlock.TextColorPropertyKey.DefaultValueMetadata     = DefaultValueMetadata.Static(Color.LightGray);
            EditText.TextColorPropertyKey.DefaultValueMetadata      = DefaultValueMetadata.Static(Color.LightGray);
            EditText.SelectionColorPropertyKey.DefaultValueMetadata = DefaultValueMetadata.Static(Color.FromAbgr(0x623574FF));
            EditText.CaretColorPropertyKey.DefaultValueMetadata     = DefaultValueMetadata.Static(Color.FromAbgr(0xF0F0F0FF));
            var buttonPressedTexture    = TextureExtensions.FromFileData(GraphicsDevice, ElementTestDesigns.ButtonPressed);
            var buttonNotPressedTexture = TextureExtensions.FromFileData(GraphicsDevice, ElementTestDesigns.ButtonNotPressed);
            var buttonOverredTexture    = TextureExtensions.FromFileData(GraphicsDevice, ElementTestDesigns.ButtonOverred);

            Button.PressedImagePropertyKey.DefaultValueMetadata = DefaultValueMetadata.Static(new Sprite("Test button pressed design", buttonPressedTexture)
            {
                Borders = 8 * Vector4.One
            });
            Button.NotPressedImagePropertyKey.DefaultValueMetadata = DefaultValueMetadata.Static(new Sprite("Test button not pressed design", buttonNotPressedTexture)
            {
                Borders = 8 * Vector4.One
            });
            Button.MouseOverImagePropertyKey.DefaultValueMetadata = DefaultValueMetadata.Static(new Sprite("Test button overred design", buttonOverredTexture)
            {
                Borders = 8 * Vector4.One
            });
            var editActiveTexture   = TextureExtensions.FromFileData(GraphicsDevice, ElementTestDesigns.EditTextActive);
            var editInactiveTexture = TextureExtensions.FromFileData(GraphicsDevice, ElementTestDesigns.EditTextInactive);
            var editOverredTexture  = TextureExtensions.FromFileData(GraphicsDevice, ElementTestDesigns.EditTextOverred);

            EditText.ActiveImagePropertyKey.DefaultValueMetadata = DefaultValueMetadata.Static(new Sprite("Test edit active design", editActiveTexture)
            {
                Borders = 12 * Vector4.One
            });
            EditText.InactiveImagePropertyKey.DefaultValueMetadata = DefaultValueMetadata.Static(new Sprite("Test edit inactive design", editInactiveTexture)
            {
                Borders = 12 * Vector4.One
            });
            EditText.MouseOverImagePropertyKey.DefaultValueMetadata = DefaultValueMetadata.Static(new Sprite("Test edit overred design", editOverredTexture)
            {
                Borders = 12 * Vector4.One
            });
            var toggleButtonChecked       = TextureExtensions.FromFileData(GraphicsDevice, ElementTestDesigns.ToggleButtonChecked);
            var toggleButtonUnchecked     = TextureExtensions.FromFileData(GraphicsDevice, ElementTestDesigns.ToggleButtonUnchecked);
            var toggleButtonIndeterminate = TextureExtensions.FromFileData(GraphicsDevice, ElementTestDesigns.ToggleButtonIndeterminate);

            ToggleButton.CheckedImagePropertyKey.DefaultValueMetadata = DefaultValueMetadata.Static(new Sprite("Test toggle button checked design", toggleButtonChecked)
            {
                Borders = 8 * Vector4.One
            });
            ToggleButton.UncheckedImagePropertyKey.DefaultValueMetadata = DefaultValueMetadata.Static(new Sprite("Test toggle button unchecked design", toggleButtonUnchecked)
            {
                Borders = 8 * Vector4.One
            });
            ToggleButton.IndeterminateImagePropertyKey.DefaultValueMetadata = DefaultValueMetadata.Static(new Sprite("Test toggle button indeterminate design", toggleButtonIndeterminate)
            {
                Borders = 8 * Vector4.One
            });

            Window.IsMouseVisible = true;

            SceneSystem.SceneInstance = new SceneInstance(Services, Scene);
        }
예제 #4
0
        protected override Task LoadContent()
        {
            // Set dependency properties test values.
            TextBlock.TextColorPropertyKey.DefaultValueMetadata     = DefaultValueMetadata.Static(Color.LightGray);
            EditText.TextColorPropertyKey.DefaultValueMetadata      = DefaultValueMetadata.Static(Color.LightGray);
            EditText.SelectionColorPropertyKey.DefaultValueMetadata = DefaultValueMetadata.Static(Color.FromAbgr(0x623574FF));
            EditText.CaretColorPropertyKey.DefaultValueMetadata     = DefaultValueMetadata.Static(Color.FromAbgr(0xF0F0F0FF));
            var buttonPressedTexture    = TextureExtensions.CreateTextureFromFileData(GraphicsDevice, ElementTestDesigns.ButtonPressed);
            var buttonNotPressedTexture = TextureExtensions.CreateTextureFromFileData(GraphicsDevice, ElementTestDesigns.ButtonNotPressed);
            var buttonOverredTexture    = TextureExtensions.CreateTextureFromFileData(GraphicsDevice, ElementTestDesigns.ButtonOverred);

            Button.PressedImagePropertyKey.DefaultValueMetadata = DefaultValueMetadata.Static(new UIImage("Test button pressed design", buttonPressedTexture)
            {
                Borders = 8 * Vector4.One
            });
            Button.NotPressedImagePropertyKey.DefaultValueMetadata = DefaultValueMetadata.Static(new UIImage("Test button not pressed design", buttonNotPressedTexture)
            {
                Borders = 8 * Vector4.One
            });
            Button.MouseOverImagePropertyKey.DefaultValueMetadata = DefaultValueMetadata.Static(new UIImage("Test button overred design", buttonOverredTexture)
            {
                Borders = 8 * Vector4.One
            });
            var editActiveTexture   = TextureExtensions.CreateTextureFromFileData(GraphicsDevice, ElementTestDesigns.EditTextActive);
            var editInactiveTexture = TextureExtensions.CreateTextureFromFileData(GraphicsDevice, ElementTestDesigns.EditTextInactive);
            var editOverredTexture  = TextureExtensions.CreateTextureFromFileData(GraphicsDevice, ElementTestDesigns.EditTextOverred);

            EditText.ActiveImagePropertyKey.DefaultValueMetadata = DefaultValueMetadata.Static(new UIImage("Test edit active design", editActiveTexture)
            {
                Borders = 12 * Vector4.One
            });
            EditText.InactiveImagePropertyKey.DefaultValueMetadata = DefaultValueMetadata.Static(new UIImage("Test edit inactive design", editInactiveTexture)
            {
                Borders = 12 * Vector4.One
            });
            EditText.MouseOverImagePropertyKey.DefaultValueMetadata = DefaultValueMetadata.Static(new UIImage("Test edit overred design", editOverredTexture)
            {
                Borders = 12 * Vector4.One
            });
            var toggleButtonChecked       = TextureExtensions.CreateTextureFromFileData(GraphicsDevice, ElementTestDesigns.ToggleButtonChecked);
            var toggleButtonUnchecked     = TextureExtensions.CreateTextureFromFileData(GraphicsDevice, ElementTestDesigns.ToggleButtonUnchecked);
            var toggleButtonIndeterminate = TextureExtensions.CreateTextureFromFileData(GraphicsDevice, ElementTestDesigns.ToggleButtonIndeterminate);

            ToggleButton.CheckedImagePropertyKey.DefaultValueMetadata = DefaultValueMetadata.Static(new UIImage("Test toggle button checked design", toggleButtonChecked)
            {
                Borders = 8 * Vector4.One
            });
            ToggleButton.UncheckedImagePropertyKey.DefaultValueMetadata = DefaultValueMetadata.Static(new UIImage("Test toggle button unchecked design", toggleButtonUnchecked)
            {
                Borders = 8 * Vector4.One
            });
            ToggleButton.IndeterminateImagePropertyKey.DefaultValueMetadata = DefaultValueMetadata.Static(new UIImage("Test toggle button indeterminate design", toggleButtonIndeterminate)
            {
                Borders = 8 * Vector4.One
            });

            Window.IsMouseVisible = true;
            UI.VirtualResolution  = new Vector3(1000, 500, 500);

            CreatePipeline();

            return(base.LoadContent());
        }