예제 #1
0
        protected override void OnRender(DrawingContext drawingContext)
        {
            GuardedToggleSwitch toggleSwitch = Visual as GuardedToggleSwitch;

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

                case ToggleSwitchPosition.Two:
                    if (toggleSwitch.GuardPosition == GuardPosition.Up)
                    {
                        drawingContext.DrawImage(_imageTwoGuardUp, _imageRect);
                    }
                    else
                    {
                        drawingContext.DrawImage(_imageTwoGuardDown, _imageRect);
                    }
                    break;
                }
            }
        }
예제 #2
0
        protected override void OnRefresh()
        {
            GuardedToggleSwitch toggleSwitch = Visual as GuardedToggleSwitch;

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