Esempio n. 1
0
        protected override void OnRender(DrawingContext drawingContext)
        {
            GuardedSwitch toggleSwitch = Visual as GuardedSwitch;

            if (toggleSwitch != null)
            {
                switch (toggleSwitch.SwitchPosition)
                {
                case ToggleSwitchPosition.One:
                    if (toggleSwitch.GuardPosition == GuardPosition.Up)
                    {
                        drawingContext.DrawImage(_imageOneGuardUp, _imageRect);
                    }
                    else
                    {
                        drawingContext.DrawImage(_imageTwoGuardDown, _imageRect);
                    }
                    break;

                case ToggleSwitchPosition.Two:
                    if (toggleSwitch.GuardPosition == GuardPosition.Up)
                    {
                        drawingContext.DrawImage(_imageOneGuardUp, _imageRect);
                    }
                    else
                    {
                        drawingContext.DrawImage(_imageTwoGuardDown, _imageRect);
                    }
                    break;
                }
            }
        }
Esempio n. 2
0
        protected override void OnRefresh()
        {
            GuardedSwitch toggleSwitch = Visual as GuardedSwitch;

            if (toggleSwitch != null)
            {
                _imageRect.Width   = toggleSwitch.Width;
                _imageRect.Height  = toggleSwitch.Height;
                _imageOneGuardUp   = ConfigManager.ImageManager.LoadImage(toggleSwitch.PositionOneGuardUpImage);
                _imageTwoGuardDown = ConfigManager.ImageManager.LoadImage(toggleSwitch.PositionTwoGuardDownImage);
            }
            else
            {
                _imageOneGuardUp   = null;
                _imageTwoGuardDown = null;
            }
        }