Ejemplo n.º 1
0
 /// <summary>
 /// 设置按钮的文字
 /// </summary>
 /// <param name="text">按钮显示的文字</param>
 /// <param name="waiting">是否等待,设置为null时显示位原始状态</param>
 public void UpdateButton(string text, bool?waiting = null)
 {
     if (waiting.HasValue)
     {
         IsWaiting(waiting.Value);
     }
     else
     {
         IsWaiting(ButtonHelper.GetIsWaiting(LaunchButton));
     }
     void IsWaiting(bool w)
     {
         if (w)
         {
             Dispatcher.Invoke(() =>
             {
                 ButtonHelper.SetWaitingContent(LaunchButton, text);
                 ButtonHelper.SetIsWaiting(LaunchButton, true);
                 TabItemChangeButton.IsEnabled = false;
             });
         }
         else
         {
             Dispatcher.Invoke(() =>
             {
                 LaunchButton.Content = text;
                 ButtonHelper.SetIsWaiting(LaunchButton, false);
                 TabItemChangeButton.IsEnabled = true;
             });
         }
         isWaiting = waiting.Value;
     }
 }
Ejemplo n.º 2
0
        private void UpdateTemplate()
        {
            var color = Helper.GetColorByOffset(_linearGradientBrush.GradientStops, SldTheme.Value / 7);

            ButtonHelper.SetCornerRadius(BtnCustom, new CornerRadius(SldCornerRadius.Value));
            BtnCustom.Width = SldWidth.Value;

            if (BtnCustom.Width < 60)
            {
                BtnCustom.Content = "";
                ButtonHelper.SetWaitingContent(BtnCustom, null);
            }
            else
            {
                BtnCustom.Content = " Button";
                ButtonHelper.SetWaitingContent(BtnCustom, "Please wait...");
            }


            switch (ButtonHelper.GetButtonStyle(BtnCustom))
            {
            case ButtonStyle.Standard:
                BtnCustom.Foreground = Colors.White.ToBrush();
                BtnCustom.Background = new Color()
                {
                    A = 200, R = color.R, G = color.G, B = color.B
                }.ToBrush();
                ButtonHelper.SetHoverBrush(BtnCustom, color.ToBrush());
                break;

            case ButtonStyle.Hollow:
                BtnCustom.Background  = Colors.Transparent.ToBrush();
                BtnCustom.Foreground  = color.ToBrush();
                BtnCustom.BorderBrush = color.ToBrush();
                ButtonHelper.SetHoverBrush(BtnCustom, color.ToBrush());
                break;

            case ButtonStyle.Outline:
                BtnCustom.Background = Colors.Transparent.ToBrush();
                BtnCustom.Foreground = new Color()
                {
                    A = 150, R = color.R, G = color.G, B = color.B
                }.ToBrush();
                BtnCustom.BorderBrush = new Color()
                {
                    A = 150, R = color.R, G = color.G, B = color.B
                }.ToBrush();
                ButtonHelper.SetHoverBrush(BtnCustom, color.ToBrush());
                break;

            case ButtonStyle.Link:
                BtnCustom.Background = Colors.Transparent.ToBrush();
                BtnCustom.Foreground = new Color()
                {
                    A = 150, R = color.R, G = color.G, B = color.B
                }.ToBrush();
                ButtonHelper.SetHoverBrush(BtnCustom, color.ToBrush());
                break;
            }
        }