public static Brush FreezeSolidBrush(string hex) { var _1 = SolidColorBrushConverter.From16JinZhi(hex); _1.Freeze(); return(_1); }
private void CreatePopupEx() { if (_apErrorToolTip.IsNull()) { _apErrorToolTip = new ToolTip(); _apErrorToolTip.BorderThickness = new Thickness(0); _apErrorToolTip.Background = new SolidColorBrush(Colors.Transparent); _apErrorToolTip.Padding = new Thickness(0); _apErrorToolTip.Placement = PlacementMode.Top; _apErrorToolTip.Padding = new Thickness(0, 0, 0, 10); _apErrorToolTip.HorizontalOffset = 0; _apErrorToolTip.VerticalOffset = 0; _apErrorToolTip.Opened += popup_Opened; _apErrorToolTip.PlacementTarget = this.AssociatedObject; _apErrorToolTip.VerticalContentAlignment = VerticalAlignment.Center; if (at.IsNull()) { at = new AyTooltip(); at.BorderBrush = SolidColorBrushConverter.From16JinZhi("#B2C9DE"); at.Foreground = SolidColorBrushConverter.From16JinZhi("#FF3737"); at.Background = SolidColorBrushConverter.From16JinZhi("#F3FAFD"); at.Placement = Dock.Bottom; _tb = new TextBlock(); _tb.TextWrapping = TextWrapping.Wrap; _tb.FontSize = 12; _tb.Foreground = at.Foreground; at.TooltipContent = _tb; _apErrorToolTip.Content = at; } } }
private void UserName_MouseLeave(object sender, MouseEventArgs e) { if (userB != null) { userB.Visibility = Visibility.Collapsed; cbo.BorderBrush = SolidColorBrushConverter.From16JinZhi("#ABADB3"); } }
protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); ContentManager.Instance.ApplySetting(); AyGlobalConfig.AYUI_ConfigFileNamePath = AyGlobalConfig.ReturnCurrentFolderCombinePath2("Content/application.xml"); _theme = new ElementBlueThemeResourceDictionary(); _theme.AccentBrush = SolidColorBrushConverter.From16JinZhi("#D80A0A"); _theme.AddTheme(this); //下次切换,应该从merge移除,重新add }
protected internal override void BeginTransition(TransitionPresenter transitionElement, ContentPresenter oldContent, ContentPresenter newContent) { LinearGradientBrush gb = new LinearGradientBrush(); GradientStop gs_gs1 = new GradientStop(SolidColorBrushConverter.ToColor("#FF000000"), 0); GradientStop gs_gs2 = new GradientStop(SolidColorBrushConverter.ToColor("#00000000"), 0); gb.GradientStops.Add(gs_gs1); gb.GradientStops.Add(gs_gs2); Point StartPoint = new Point(0, 0); Point EndPoint = new Point(0, 1); switch (Direction) { case AyTransitionDirection.down: StartPoint = new Point(0, 0); EndPoint = new Point(0, 1); break; case AyTransitionDirection.up: StartPoint = new Point(0, 1); EndPoint = new Point(0, 0); break; case AyTransitionDirection.left: StartPoint = new Point(0, 0); EndPoint = new Point(1, 0); break; case AyTransitionDirection.right: StartPoint = new Point(1, 0); EndPoint = new Point(0, 0); break; } gb.StartPoint = StartPoint; gb.EndPoint = EndPoint; oldContent.OpacityMask = gb; DoubleAnimation da1 = new DoubleAnimation(); da1.From = 0; da1.To = 1; da1.Duration = Duration; gs_gs1.BeginAnimation(GradientStop.OffsetProperty, da1); DoubleAnimation da2 = new DoubleAnimation(); da2.From = 0; da2.To = 1; da2.Duration = Duration; da2.BeginTime = TimeSpan.FromMilliseconds(50); gs_gs2.BeginAnimation(GradientStop.OffsetProperty, da2); }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { String _value = value.ToString(); if (StringUtil.isNotBlank(_value)) { if ("导入成功".Equals(_value)) { return(SolidColorBrushConverter.From16JinZhi("#FF0000")); } } return(SolidColorBrushConverter.From16JinZhi("#000000")); }
/// <summary> /// Participates in rendering operations that are directed by the layout system. /// </summary> /// <param name="drawingContext">The drawing instructions.</param> protected override void OnRender(DrawingContext drawingContext) { base.OnRender(drawingContext); if (this.IsEnabled) { // Make the lines snap to pixels (add half the pen width [0.5]) double[] x = { this.SelectionArea.Left + 0.5, this.SelectionArea.Right + 0.5 }; double[] y = { this.SelectionArea.Top + 0.5, this.SelectionArea.Bottom + 0.5 }; drawingContext.PushGuidelineSet(new GuidelineSet(x, y)); Brush fill = SolidColorBrushConverter.From16JinZhi(SelectionBrush); fill.Opacity = 0.4; drawingContext.DrawRectangle(fill, new Pen(fill, 1.0), this.SelectionArea); } }
private void ButtonBase_OnClick(object sender, RoutedEventArgs e) { var dd = new Demo1(); //dd.Width = 800; //dd.Height = 640; Console.WriteLine("开始触发"); //var vm = new MyLayerDemo1ViewModel(); //MyLayerServices.ShowDialog("这是MyLayerDemo1", dd, vm, onDialogCloseCallBack, null,vm.SetMessage); MyWPFUI.Controls.MyLayer.ShowDialog(null, dd, "弹窗DEMO1", new MyLayerOptions() { MaskBrush = SolidColorBrushConverter.From16JinZhi("#4F000000"), CanDrag = true, HasShadow = true, AnimationType = AnimationType.InFormDown }); }
private void btnshift_Unchecked(object sender, RoutedEventArgs e) { this.Resources["Foreground.Disabled"] = SolidColorBrushConverter.From16JinZhi("#888888"); this.Resources["Foreground.Enabled"] = SolidColorBrushConverter.From16JinZhi("#000000"); this.Resources["fontsize.Enabled"] = 12.0; this.Resources["fontsize.Disabled"] = 9.0; if (uppercase == 1) { ToUpperCase(); uppercase = 2; } else { ToLowCase(); uppercase = 1; } shiftIsChecked = false; }
private void ButtonBase2_OnClick(object sender, RoutedEventArgs e) { var dd = new Demo1(); dd.Width = 800; dd.Height = 640; //MyLayer.ShowDialog(null, dd, "弹窗DEMO1"); //var vm = new MyLayerDemo1ViewModel(); MyLayerServices.ShowDialog("这是MyLayerDemo2", dd, this, onDialogCloseCallBack, new MyLayerOptions() { MaskBrush = SolidColorBrushConverter.From16JinZhi("#4F000000"), CanDrag = true, HasShadow = true, AnimationType = AnimationType.InFormDown }, delegate { MessageBox.Show("渲染数据"); }, CloseRequest); }
private void CreatePopupEx() { if (_apUserToolTip.IsNull()) { _apUserToolTip = new ToolTip(); _apUserToolTip.BorderThickness = new Thickness(0); _apUserToolTip.Background = new SolidColorBrush(Colors.Transparent); _apUserToolTip.Padding = new Thickness(0); _apUserToolTip.Placement = PlacementMode.Left; _apUserToolTip.Padding = new Thickness(0, 0, 10, 0); _apUserToolTip.HorizontalOffset = 0; _apUserToolTip.VerticalOffset = 0; _apUserToolTip.Opened += popup_Opened; _apUserToolTip.PlacementTarget = this.AssociatedObject; _apUserToolTip.VerticalContentAlignment = VerticalAlignment.Center; if (at.IsNull()) { at = new AyTooltip(); at.RadiusX = 3; at.RadiusY = 3; at.BorderBrush = SolidColorBrushConverter.From16JinZhi("#333333"); at.MaxWidth = 150; at.Foreground = SolidColorBrushConverter.From16JinZhi("#333333"); at.Background = SolidColorBrushConverter.From16JinZhi("#FFFFFF"); at.Placement = Dock.Right; _tb = new TextBlock(); //_tb.Margin = new Thickness(2,2,0,2); _tb.TextWrapping = TextWrapping.Wrap; _tb.FontSize = 12; _tb.SetBinding(TextBlock.ForegroundProperty, new Binding { Path = new PropertyPath("Foreground"), Source = at, Mode = BindingMode.TwoWay }); _tb.SetBinding(TextBlock.TextProperty, new Binding { Path = new PropertyPath("Text"), Source = this, Mode = BindingMode.TwoWay }); at.TooltipContent = _tb; _apUserToolTip.Content = at; } } }
private void PropertyControl_OnDataContextChanged(FrameworkElement sender, DataContextChangedEventArgs args) { if (args.NewValue == _currentSample) { return; } _currentSample = DataContext as Sample; RootPanel.Children.Clear(); if (_currentSample != null) { var propertyDesc = _currentSample.PropertyDescriptor; if (propertyDesc == null) { return; } foreach (var option in propertyDesc.Options) { // Label var label = new TextBlock { Text = option.Label + ":", Foreground = new SolidColorBrush(Colors.Black) }; RootPanel.Children.Add(label); // Control Control controlToAdd; DependencyProperty dependencyProperty; IValueConverter converter = null; IDictionary <string, object> propertyDict = propertyDesc.Expando; switch (option.Kind) { case PropertyKind.Slider: case PropertyKind.DoubleSlider: var slider = new Slider(); var sliderOption = option as SliderPropertyOptions; if (sliderOption != null) { slider.Minimum = sliderOption.MinValue; slider.Maximum = sliderOption.MaxValue; slider.StepFrequency = sliderOption.Step; } if (option.Kind == PropertyKind.DoubleSlider) { slider.StepFrequency = 0.01; } if ((propertyDict[option.Name] as ValueHolder).Value is double value) { slider.Value = value; } controlToAdd = slider; dependencyProperty = RangeBase.ValueProperty; break; case PropertyKind.Enum: var enumType = option.DefaultValue.GetType(); var comboBox = new ComboBox { ItemsSource = Enum.GetNames(enumType), SelectedItem = (propertyDict[option.Name] as ValueHolder).Value.ToString() }; converter = new EnumConverter(enumType); controlToAdd = comboBox; dependencyProperty = Selector.SelectedItemProperty; break; case PropertyKind.Bool: var checkBox = new ToggleSwitch(); if ((propertyDict[option.Name] as ValueHolder).Value is bool isOn) { checkBox.IsOn = isOn; } controlToAdd = checkBox; dependencyProperty = ToggleSwitch.IsOnProperty; break; case PropertyKind.Brush: var colorComboBox = new ComboBox(); var dataSource = typeof(Colors).GetTypeInfo().DeclaredProperties.Select(p => p.Name).ToList(); colorComboBox.ItemsSource = dataSource; if ((propertyDict[option.Name] as ValueHolder).Value is SolidColorBrush brush && _colorNames.TryGetValue(brush.Color, out var color)) { colorComboBox.SelectedIndex = dataSource.IndexOf(color); } else { colorComboBox.SelectedIndex = dataSource.IndexOf(option.DefaultValue.ToString()); } converter = new SolidColorBrushConverter(); controlToAdd = colorComboBox; dependencyProperty = Selector.SelectedItemProperty; break;
private async void PropertyControl_OnDataContextChanged(FrameworkElement sender, DataContextChangedEventArgs args) { var sample = DataContext as Sample; RootPanel.Children.Clear(); if (sample != null) { var propertyDesc = await sample.GetPropertyDescriptorAsync(); if (propertyDesc == null) { return; } foreach (var option in propertyDesc.Options) { // Label var label = new TextBlock { Text = option.Name + ":", Foreground = new SolidColorBrush(Colors.Black) }; RootPanel.Children.Add(label); // Control Control controlToAdd; DependencyProperty dependencyProperty; IValueConverter converter = null; switch (option.Kind) { case PropertyKind.Slider: case PropertyKind.DoubleSlider: var slider = new Slider(); var sliderOption = option as SliderPropertyOptions; if (sliderOption != null) { slider.Minimum = sliderOption.MinValue; slider.Maximum = sliderOption.MaxValue; } if (option.Kind == PropertyKind.DoubleSlider) { slider.StepFrequency = 0.01; } controlToAdd = slider; dependencyProperty = RangeBase.ValueProperty; break; case PropertyKind.Enum: var comboBox = new ComboBox { ItemsSource = Enum.GetNames(option.DefaultValue.GetType()), SelectedItem = option.DefaultValue.ToString() }; controlToAdd = comboBox; dependencyProperty = Selector.SelectedItemProperty; break; case PropertyKind.Bool: var checkBox = new ToggleSwitch(); controlToAdd = checkBox; dependencyProperty = ToggleSwitch.IsOnProperty; break; case PropertyKind.Brush: var colorComboBox = new ComboBox(); var dataSource = typeof(Colors).GetTypeInfo().DeclaredProperties.Select(p => p.Name).ToList(); colorComboBox.ItemsSource = dataSource; colorComboBox.SelectedIndex = dataSource.IndexOf(option.DefaultValue.ToString()); converter = new SolidColorBrushConverter(); controlToAdd = colorComboBox; dependencyProperty = Selector.SelectedItemProperty; break; default: var textBox = new TextBox { Text = option.DefaultValue.ToString() }; controlToAdd = textBox; dependencyProperty = TextBox.TextProperty; break; } var binding = new Binding { Source = propertyDesc.Expando, Path = new PropertyPath(option.Name + ".Value"), Mode = BindingMode.TwoWay, Converter = converter }; controlToAdd.SetBinding(dependencyProperty, binding); controlToAdd.Margin = new Thickness(0, 5, 0, 20); RootPanel.Children.Add(controlToAdd); } } }
private void SetAyLayerBase(object owner, object content, string title, AyLayerOptions options, bool isDiaglog) { if (options == null) { options = AyLayerOptions.DefaultAyLayerOptions; } _options = options; //this.Topmost = true; //this.ShowInTaskbar = true; //if (owner != null) //{ // Owner = owner; //} if (owner == null) { if (Application.Current.MainWindow is AyWindow) { AyWindow mainWindow = Application.Current.MainWindow as AyWindow; Owner = mainWindow.ayLayerArea; } } else { var _Owner = owner as Grid; if (_Owner != null) { Owner = _Owner; } else { var _Wn = owner as AyWindow; if (_Wn.IsNotNull()) { Owner = _Wn.ayLayerArea; } } } userPresenter.Content = content; ItemContent = content; if (options.LayerId.IsNotNull()) { AYUI.Session[options.LayerId] = this; } if (options.Direction.HasValue) { switch (options.Direction.Value) { case AyLayerDockDirect.LT: body.HorizontalAlignment = HorizontalAlignment.Left; body.VerticalAlignment = VerticalAlignment.Top; break; case AyLayerDockDirect.CT: //中间位置计算 body.HorizontalAlignment = HorizontalAlignment.Center; body.VerticalAlignment = VerticalAlignment.Top; break; case AyLayerDockDirect.RT: //中间位置计算 body.HorizontalAlignment = HorizontalAlignment.Right; body.VerticalAlignment = VerticalAlignment.Top; break; case AyLayerDockDirect.LC: body.HorizontalAlignment = HorizontalAlignment.Left; body.VerticalAlignment = VerticalAlignment.Center; break; case AyLayerDockDirect.CC: body.HorizontalAlignment = HorizontalAlignment.Center; body.VerticalAlignment = VerticalAlignment.Center; break; case AyLayerDockDirect.RC: body.HorizontalAlignment = HorizontalAlignment.Right; body.VerticalAlignment = VerticalAlignment.Center; break; case AyLayerDockDirect.LB: body.HorizontalAlignment = HorizontalAlignment.Left; body.VerticalAlignment = VerticalAlignment.Bottom; break; case AyLayerDockDirect.CB: body.HorizontalAlignment = HorizontalAlignment.Center; body.VerticalAlignment = VerticalAlignment.Bottom; break; case AyLayerDockDirect.RB: body.HorizontalAlignment = HorizontalAlignment.Right; body.VerticalAlignment = VerticalAlignment.Bottom; break; default: break; } } if (options.IsContainsTitleBar) { d.Height = "40.00".ToGridLength(); Border b = new Border(); b.SetResourceReference(Border.BorderBrushProperty, "bordercolorlight"); b.BorderThickness = options.TitleBarBorderThickness; if (options.CanDrag) { SetDragMove(b); } if (options.LayerCornerRadius.HasValue) { b.CornerRadius = new CornerRadius(options.LayerCornerRadius.Value.TopLeft, options.LayerCornerRadius.Value.TopRight, 0, 0); } b.HorizontalAlignment = HorizontalAlignment.Stretch; b.VerticalAlignment = VerticalAlignment.Stretch; Grid g = new Grid(); if (!title.IsNullOrWhiteSpace()) { AyText tb = new AyText(); tb.Width = 200; tb.VerticalAlignment = VerticalAlignment.Center; tb.HorizontalAlignment = HorizontalAlignment.Left; tb.Margin = new Thickness(16, 0, 0, 0); tb.TextWrapping = TextWrapping.NoWrap; tb.SetResourceReference(AyText.FontSizeProperty, "WindowTitleFontSize"); tb.TextTrimming = TextTrimming.CharacterEllipsis; tb.Text = title; g.Children.Add(tb); } if (options.CanClose) { Button ab = new Button(); ab.SetResourceReference(Button.StyleProperty, "AYWin_CLOSE"); ab.Click += closewindow_Click; ab.VerticalAlignment = VerticalAlignment.Center; ab.HorizontalAlignment = HorizontalAlignment.Right; ab.Content = Langs.share_close.Lang(); ab.Width = 32; ab.Height = 32; ab.Margin = new Thickness(0, 0, 5, 0); g.Children.Add(ab); } b.Child = g; b.SetResourceReference(Border.BackgroundProperty, "colorwhite"); bodyConent.Children.Add(b); } else { if (options.TitleBar.IsNotNull() && options.CanDrag) { SetDragMove(options.TitleBar); } } if (options.MaskBrush.IsNotNull()) { layoutMain.Background = options.MaskBrush; } if (isDiaglog) { if (options.MaskBrush.IsNull()) { layoutMain.Background = SolidColorBrushConverter.From16JinZhi("#8C000000"); } if (options.WhenShowDialogNeedShake) { layoutMain.MouseLeftButtonDown += LayoutMain_MouseLeftButtonDown; } } if (options.IsShowLayerBorder) { body.SetResourceReference(Border.BorderBrushProperty, "bordercolorlight"); if (options.LayerBorderThickness.HasValue) { body.BorderThickness = options.LayerBorderThickness.Value; } else { body.BorderThickness = new Thickness(1); } } if (options.LayerCornerRadius.HasValue) { body.CornerRadius = options.LayerCornerRadius.Value; } options.LayerBackground.Freeze(); body.Background = options.LayerBackground; if (options.ShowAnimateIndex == 0) { body.Visibility = Visibility.Visible; if (options.Opened.IsNotNull()) { options.Opened(); } body.Loaded += Body_Loaded; DropShadowEffect de = new DropShadowEffect(); de.Color = options.ShadowColor; de.ShadowDepth = options.ShadowDepth; de.Opacity = 0.1; body.Effect = de; de.BlurRadius = options.ShadowRadius; SetRealPoint(options); } else if (options.ShowAnimateIndex == 1) { var sc = new AyAniScale(body, () => { ShowShadow(options); }); sc.AutoDestory = true; sc.AnimateSpeed = 450; sc.ScaleXFrom = 0; sc.ScaleYFrom = 0; sc.ScaleXTo = 1; sc.ScaleYTo = 1; sc.EasingFunction = new System.Windows.Media.Animation.CubicEase { EasingMode = EasingMode.EaseOut }; sc.Begin(); } else if (options.ShowAnimateIndex == 2) { var sc = new AyAniSlideInDown(body, () => { ShowShadow(options); }); sc.AutoDestory = true; sc.AnimateSpeed = 750; sc.FromDistance = -4000; sc.OpacityNeed = false; sc.EasingFunction = new System.Windows.Media.Animation.CubicEase { EasingMode = EasingMode.EaseOut }; sc.Begin(); } else if (options.ShowAnimateIndex == 3) { var sc = new AyAniSlideInUp(body, () => { ShowShadow(options); }); sc.AutoDestory = true; sc.AnimateSpeed = 750; sc.FromDistance = 4000; sc.OpacityNeed = false; sc.EasingFunction = new System.Windows.Media.Animation.CubicEase { EasingMode = EasingMode.EaseOut }; sc.Begin(); } else if (options.ShowAnimateIndex == 4) { var sc = new AyAniSlideInLeft(body, () => { ShowShadow(options); }); sc.AutoDestory = true; sc.AnimateSpeed = 750; sc.FromDistance = -4000; sc.OpacityNeed = false; sc.EasingFunction = new System.Windows.Media.Animation.CubicEase { EasingMode = EasingMode.EaseOut }; sc.Begin(); } else if (options.ShowAnimateIndex == 5) { var sc = new AyAniSlideInRight(body, () => { ShowShadow(options); }); sc.AutoDestory = true; sc.AnimateSpeed = 750; sc.FromDistance = 4000; sc.OpacityNeed = false; sc.EasingFunction = new System.Windows.Media.Animation.CubicEase { EasingMode = EasingMode.EaseOut }; sc.Begin(); } else if (options.ShowAnimateIndex == 6) { var sc = new AyAniBounceInDown(body, () => { ShowShadow(options); }); sc.AutoDestory = true; sc.Begin(); } else if (options.ShowAnimateIndex == 7) { var sc = new AyAniBounceInUp(body, () => { ShowShadow(options); }); sc.AutoDestory = true; sc.Begin(); } else if (options.ShowAnimateIndex == 8) { var sc = new AyAniBounceInLeft(body, () => { ShowShadow(options); }); sc.AutoDestory = true; sc.Begin(); } else if (options.ShowAnimateIndex == 9) { var sc = new AyAniBounceInRight(body, () => { ShowShadow(options); }); sc.AutoDestory = true; sc.Begin(); } else if (options.ShowAnimateIndex == 10) { var sc = new AyAniRotateIn(body, () => { ShowShadow(options); }); sc.AnimateSpeed = 750; sc.EasingFunction = new System.Windows.Media.Animation.CubicEase { EasingMode = EasingMode.EaseOut }; sc.Begin(); } else if (options.ShowAnimateIndex == 11) { var sc = new AyAniBounceIn(body, () => { ShowShadow(options); }); sc.AutoDestory = true; sc.AnimateSpeed = 750; sc.Begin(); } else if (options.ShowAnimateIndex == 12) { var sc = new AyAniBounceInLeft(body, () => { ShowShadow(options); }); sc.AutoDestory = true; sc.AnimateSpeed = 750; sc.Begin(); } else if (options.ShowAnimateIndex == 13) { var sc = new AyAniBounceInRight(body, () => { ShowShadow(options); }); sc.AutoDestory = true; sc.AnimateSpeed = 750; sc.Begin(); } else if (options.ShowAnimateIndex == 14) { var sc = new AyAniBounceInDown(body, () => { ShowShadow(options); }); sc.AutoDestory = true; sc.AnimateSpeed = 750; sc.Begin(); } else if (options.ShowAnimateIndex == 15) { var sc = new AyAniBounceInUp(body, () => { ShowShadow(options); }); sc.AutoDestory = true; sc.AnimateSpeed = 750; sc.Begin(); } }