protected override void OnRefresh() { GuardedThreeWayToggle toggleSwitch = Visual as GuardedThreeWayToggle; 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); _imageThreeGuardUp = ConfigManager.ImageManager.LoadImage(toggleSwitch.PositionThreeGuardUpImage); _imageThreeGuardDown = ConfigManager.ImageManager.LoadImage(toggleSwitch.PositionThreeGuardDownImage); } else { _imageOneGuardUp = null; _imageOneGuardDown = null; _imageTwoGuardUp = null; _imageTwoGuardDown = null; _imageThreeGuardUp = null; _imageThreeGuardDown = null; } }
protected override void OnRender(DrawingContext drawingContext) { GuardedThreeWayToggle toggleSwitch = Visual as GuardedThreeWayToggle; if (toggleSwitch != null) { switch (toggleSwitch.SwitchPosition) { case ThreeWayToggleSwitchPosition.One: if (toggleSwitch.GuardPosition == GuardPosition.Up) { drawingContext.DrawImage(_imageOneGuardUp, _imageRect); } else { drawingContext.DrawImage(_imageOneGuardDown, _imageRect); } break; case ThreeWayToggleSwitchPosition.Two: if (toggleSwitch.GuardPosition == GuardPosition.Up) { drawingContext.DrawImage(_imageTwoGuardUp, _imageRect); } else { drawingContext.DrawImage(_imageTwoGuardDown, _imageRect); } break; case ThreeWayToggleSwitchPosition.Three: if (toggleSwitch.GuardPosition == GuardPosition.Up) { drawingContext.DrawImage(_imageThreeGuardUp, _imageRect); } else { drawingContext.DrawImage(_imageThreeGuardDown, _imageRect); } break; } } }