protected override void OnRefresh() { CustomGauge customGauge = Visual as CustomGauge; // ----------BG plate CustomNeedle customNeedle = Visual as CustomNeedle; // ----- needle if (customNeedle != null) // needle { _imageRect.X = customNeedle.Width * customGauge.Needle_PosX;; _imageRect.Y = customNeedle.Height * customGauge.Needle_PosY;; _image = ConfigManager.ImageManager.LoadImage(customNeedle.KnobImage); _imageRect.Height = customGauge.Height * customGauge.Needle_Scale; _imageRect.Width = (_image.Width * (customGauge.Height / _image.Height)) * customGauge.Needle_Scale; // uniform image based on Height _brush = new ImageBrush(_image); _center = new Point(customGauge.Width * customGauge.Needle_PivotX, customGauge.Height * customGauge.Needle_PivotY); // calculate rotation point _punto = new Point((customNeedle.Width * customGauge.Needle_PivotX) + 1, customNeedle.Height * customGauge.Needle_PivotY); } else { _image = null; _brush = null; } if (customGauge != null) // plate { _bgplate_imageRect.Width = customNeedle.Width; _bgplate_imageRect.Height = customNeedle.Height; _bgplate_image = ConfigManager.ImageManager.LoadImage(customGauge.BGPlateImage); } else { _bgplate_image = null; _brush = null; } }
private void MaxPosition_GotFocus(object sender, RoutedEventArgs e) { CustomGauge pot = Control as CustomGauge; if (pot != null) { pot.Value = pot.MaxValue; } }
protected override void OnRefresh() { _gauge = Visual as CustomGauge; if (_gauge == null) { _rotation = 0d; _image = null; _backgroundImage = null; return; } _imageRect.X = _gauge.Width * _gauge.NeedlePosX; _imageRect.Y = _gauge.Height * _gauge.NeedlePosY; _image = ConfigManager.ImageManager.LoadImage(_gauge.KnobImage) ?? ConfigManager.ImageManager.LoadImage("{Helios}/Images/General/missing_image.png"); // WARNING: needle scale applied to image but not rotation point _imageRect.Height = _gauge.Height * _gauge.NeedleScale; _imageRect.Width = _image.Width * (_imageRect.Height / _image.Height); // uniform image based on Height // calculate rotation point _center = new Point(_gauge.Width * _gauge.NeedlePivotX, _gauge.Height * _gauge.NeedlePivotY); _nextToCenter = new Point((_gauge.Width * _gauge.NeedlePivotX) + 1, _gauge.Height * _gauge.NeedlePivotY); // optional background plate image if (!string.IsNullOrWhiteSpace(_gauge.BgPlateImage)) { _backgroundRect.Width = _gauge.Width; _backgroundRect.Height = _gauge.Height; _backgroundImage = ConfigManager.ImageManager.LoadImage(_gauge.BgPlateImage); } else { _backgroundImage = null; } }