private void UpdateTemplate()
        {
            var color = Helper.GetColorByOffset(_linearGradientBrush.GradientStops, SldTheme.Value / 7);

            RadioButtonHelper.SetCornerRadius(RdbCustom1, SldCornerRadius.Value);
            RadioButtonHelper.SetCornerRadius(RdbCustom2, SldCornerRadius.Value);



            switch (RadioButtonHelper.GetRadioButtonStyle(RdbCustom1))
            {
            case RadioButtonStyle.Standard:
                RdbCustom1.Background = new Color()
                {
                    A = 50, R = color.R, G = color.G, B = color.B
                }.ToBrush();
                RdbCustom2.Background = new Color()
                {
                    A = 50, R = color.R, G = color.G, B = color.B
                }.ToBrush();
                RadioButtonHelper.SetCheckedGlyphBrush(RdbCustom1, Colors.White.ToBrush());
                RadioButtonHelper.SetCheckedGlyphBrush(RdbCustom2, Colors.White.ToBrush());
                RadioButtonHelper.SetCheckedBackground(RdbCustom1, color.ToBrush());
                RadioButtonHelper.SetCheckedBackground(RdbCustom2, color.ToBrush());
                RadioButtonHelper.SetBoxHeight(RdbCustom1, SldSize.Value);
                RadioButtonHelper.SetBoxHeight(RdbCustom2, SldSize.Value);
                RadioButtonHelper.SetBoxWidth(RdbCustom1, SldSize.Value);
                RadioButtonHelper.SetBoxWidth(RdbCustom2, SldSize.Value);
                break;

            case RadioButtonStyle.Switch:
                RdbCustom1.Background = Colors.White.ToBrush();
                RdbCustom2.Background = Colors.White.ToBrush();
                RadioButtonHelper.SetCheckedGlyphBrush(RdbCustom1, Colors.Transparent.ToBrush());
                RadioButtonHelper.SetCheckedGlyphBrush(RdbCustom2, Colors.Transparent.ToBrush());
                RadioButtonHelper.SetCheckedBackground(RdbCustom1, color.ToBrush());
                RadioButtonHelper.SetCheckedBackground(RdbCustom2, color.ToBrush());
                RadioButtonHelper.SetBoxHeight(RdbCustom1, SldSize.Value);
                RadioButtonHelper.SetBoxHeight(RdbCustom2, SldSize.Value);
                RadioButtonHelper.SetBoxWidth(RdbCustom1, SldSize.Value * 1.5);
                RadioButtonHelper.SetBoxWidth(RdbCustom2, SldSize.Value * 1.5);
                break;

            case RadioButtonStyle.Button:
                RdbCustom1.Background = Colors.White.ToBrush();
                RdbCustom2.Background = Colors.White.ToBrush();
                RadioButtonHelper.SetCheckedGlyphBrush(RdbCustom1, Colors.White.ToBrush());
                RadioButtonHelper.SetCheckedGlyphBrush(RdbCustom2, Colors.White.ToBrush());
                RadioButtonHelper.SetCheckedBackground(RdbCustom1, color.ToBrush());
                RadioButtonHelper.SetCheckedBackground(RdbCustom2, color.ToBrush());
                break;
            }
        }
Пример #2
0
        private void UpdateCode()
        {
            var radioButtonStyle = RadioButtonHelper.GetRadioButtonStyle(RdbCustom1);
            var cornerRadius     = SldCornerRadius.Value;
            var checkedContent   = RadioButtonHelper.GetCheckedContent(RdbCustom1);

            TbCode.Text = "<RadioButton  Height=\"30\"" +
                          $"\nContent=\"{RdbCustom1.Content}\"" +
                          (radioButtonStyle == RadioButtonStyle.Standard ? "" : $"\npu:RadioButtonHelper.RadioButtonStyle=\"{radioButtonStyle}\"") +
                          (radioButtonStyle == RadioButtonStyle.Standard ? $"\nBackground=\"{RdbCustom1.Background.ToColor().ToHexString(true)}\"" : "") +
                          (radioButtonStyle == RadioButtonStyle.Button ? "" : $"\npu:RadioButtonHelper.BoxHeight=\"{RadioButtonHelper.GetBoxHeight(RdbCustom1)}\"") +
                          (radioButtonStyle == RadioButtonStyle.Button ? "" : $"\npu:RadioButtonHelper.BoxWidth=\"{RadioButtonHelper.GetBoxWidth(RdbCustom1)}\"") +
                          $"\npu:RadioButtonHelper.CheckedBackground=\"{RadioButtonHelper.GetCheckedBackground(RdbCustom1).ToColor().ToHexString(false)}\"" +
                          (cornerRadius == 2 ? "" : $"\npu:RadioButtonHelper.CornerRadius=\"{cornerRadius}\"") +
                          (checkedContent == null ? "" : $"\npu:RadioButtonHelper.CheckedContent=\"{checkedContent}\"") +
                          " />";
        }