protected override void OnRender(DrawingContext drawingContext)
        {
            ThreeWayToggleSwitch toggleSwitch = Visual as ThreeWayToggleSwitch;

            if (toggleSwitch != null)
            {
                switch (toggleSwitch.SwitchPosition)
                {
                case ThreeWayToggleSwitchPosition.One:
                    if (toggleSwitch.HasIndicator && toggleSwitch.IndicatorOn && _imageOneIndicatorOn != null)
                    {
                        drawingContext.DrawImage(_imageOneIndicatorOn, _imageRect);
                    }
                    else
                    {
                        drawingContext.DrawImage(_imageOne, _imageRect);
                    }
                    break;

                case ThreeWayToggleSwitchPosition.Two:
                    if (toggleSwitch.HasIndicator && toggleSwitch.IndicatorOn && _imageTwoIndicatorOn != null)
                    {
                        drawingContext.DrawImage(_imageTwoIndicatorOn, _imageRect);
                    }
                    else
                    {
                        drawingContext.DrawImage(_imageTwo, _imageRect);
                    }
                    break;

                case ThreeWayToggleSwitchPosition.Three:
                    if (toggleSwitch.HasIndicator && toggleSwitch.IndicatorOn && _imageThreeIndicatorOn != null)
                    {
                        drawingContext.DrawImage(_imageThreeIndicatorOn, _imageRect);
                    }
                    else
                    {
                        drawingContext.DrawImage(_imageThree, _imageRect);
                    }
                    break;
                }
            }
        }
Esempio n. 2
0
        private void AddRocker(string name, string imagePrefix, double x, double y, bool horizontal)
        {
            ThreeWayToggleSwitch rocker = new ThreeWayToggleSwitch();

            rocker.Name             = name;
            rocker.SwitchType       = ThreeWayToggleSwitchType.MomOnMom;
            rocker.ClickType        = ClickType.Touch;
            rocker.PositionTwoImage = "{Helios}/Images/F-16/" + imagePrefix + "-middle.png";

            rocker.Top  = y;
            rocker.Left = x;
            if (horizontal)
            {
                rocker.Orientation        = ToggleSwitchOrientation.Horizontal;
                rocker.PositionOneImage   = "{Helios}/Images/F-16/" + imagePrefix + "-left.png";
                rocker.PositionThreeImage = "{Helios}/Images/F-16/" + imagePrefix + "-right.png";
                rocker.Width  = 56;
                rocker.Height = 32;
            }
            else
            {
                rocker.Orientation        = ToggleSwitchOrientation.Vertical;
                rocker.PositionOneImage   = "{Helios}/Images/F-16/" + imagePrefix + "-up.png";
                rocker.PositionThreeImage = "{Helios}/Images/F-16/" + imagePrefix + "-down.png";
                rocker.Width  = 32;
                rocker.Height = 56;
            }

            Children.Add(rocker);

            foreach (IBindingTrigger trigger in rocker.Triggers)
            {
                AddTrigger(trigger, name);
            }

            AddAction(rocker.Actions["set.position"], name);
        }
        protected override void OnRefresh()
        {
            ThreeWayToggleSwitch toggleSwitch = Visual as ThreeWayToggleSwitch;

            if (toggleSwitch != null)
            {
                _imageRect.Width     = toggleSwitch.Width;
                _imageRect.Height    = toggleSwitch.Height;
                _imageOne            = ConfigManager.ImageManager.LoadImage(toggleSwitch.PositionOneImage);
                _imageOneIndicatorOn = ConfigManager.ImageManager.LoadImage(toggleSwitch.PositionOneIndicatorOnImage);

                _imageTwo            = ConfigManager.ImageManager.LoadImage(toggleSwitch.PositionTwoImage);
                _imageTwoIndicatorOn = ConfigManager.ImageManager.LoadImage(toggleSwitch.PositionTwoIndicatorOnImage);

                _imageThree            = ConfigManager.ImageManager.LoadImage(toggleSwitch.PositionThreeImage);
                _imageThreeIndicatorOn = ConfigManager.ImageManager.LoadImage(toggleSwitch.PositionThreeIndicatorOnImage);
            }
            else
            {
                _imageOne   = null;
                _imageTwo   = null;
                _imageThree = null;
            }
        }
Esempio n. 4
0
        private void AddRocker(string name, string imagePrefix, double x, double y, bool horizontal)
        {
            ThreeWayToggleSwitch rocker = new ThreeWayToggleSwitch();
            rocker.Name = name;
            rocker.SwitchType = ThreeWayToggleSwitchType.MomOnMom;
            rocker.ClickType = ClickType.Touch;
            rocker.PositionTwoImage = "{Helios}/Images/F-16/" + imagePrefix + "-middle.png";

            rocker.Top = y;
            rocker.Left = x;
            if (horizontal)
            {
                rocker.Orientation = ToggleSwitchOrientation.Horizontal;
                rocker.PositionOneImage = "{Helios}/Images/F-16/" + imagePrefix + "-left.png";
                rocker.PositionThreeImage = "{Helios}/Images/F-16/" + imagePrefix + "-right.png";
                rocker.Width = 56;
                rocker.Height = 32;
            }
            else
            {
                rocker.Orientation = ToggleSwitchOrientation.Vertical;
                rocker.PositionOneImage = "{Helios}/Images/F-16/" + imagePrefix + "-up.png";
                rocker.PositionThreeImage = "{Helios}/Images/F-16/" + imagePrefix + "-down.png";
                rocker.Width = 32;
                rocker.Height = 56;
            }

            Children.Add(rocker);

            foreach (IBindingTrigger trigger in rocker.Triggers)
            {
                AddTrigger(trigger, name);
            }

            AddAction(rocker.Actions["set.position"], name);
        }