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; } } }
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; } }