public static AyText CreateWeekHeadLabel(string cnt)
        {
            AyText label = new AyText();

            label.HorizontalAlignment = HorizontalAlignment.Center;
            label.VerticalAlignment   = VerticalAlignment.Center;
            label.TextAlignment       = TextAlignment.Center;
            label.Width = UIGeneric.DayWidth.Value;
            label.Text  = cnt;
            return(label);
        }
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();
            bd = GetTemplateChild("SelectTen") as Border;


            ContentPresenter cp = GetTemplateChild("contentPresenter") as ContentPresenter;

            _EditContent = GetTemplateChild("contentPresenter1") as ContentPresenter;

            if (_column.IsNotNull() && _column.Formatter.IsNotNull())
            {
                var     _b      = BindingOperations.GetBinding(cp, ContentPresenter.ContentProperty);
                Binding newbind = new Binding {
                    Converter = _column.Formatter, Path = _b.Path, Mode = _b.Mode, RelativeSource = _b.RelativeSource
                };
                BindingOperations.ClearBinding(cp, ContentPresenter.ContentProperty);
                BindingOperations.SetBinding(cp, ContentPresenter.ContentProperty, newbind);
            }
            cp.ApplyTemplate();
            tb = WpfTreeHelper.FindChild <AyText>(cp);
            if (tb.IsNotNull())
            {
                tb.TextWrapping = CellTextWrapping;

                if (CellCharacterEllipsis == TextTrimming.CharacterEllipsis)
                {
                    ToolTip tt  = new System.Windows.Controls.ToolTip();
                    AyText  ttb = new AyText();
                    ttb.SetBinding(AyText.TextProperty, new Binding {
                        Source = cp.Content
                    });
                    tt.Content = ttb;
                    tb.ToolTip = tt;
                    if (dpd != null)
                    {
                        dpd.AddValueChanged(tb, ActualWidthPropertyChangedHandler);
                    }
                    if (tb.ActualWidth < tb.DesiredSize.Width)
                    {
                        tt.Visibility = Visibility.Visible;
                    }
                    else
                    {
                        tt.Visibility = Visibility.Collapsed;
                    }
                }
                tb.TextTrimming = CellCharacterEllipsis;
            }
        }
        public static Grid CreateWeekHeadLabel2(string cnt)
        {
            Grid g = new Grid();

            g.Height = 40;
            g.Width  = UIGeneric.DayWidth.Value;

            AyText label = new AyText();

            label.HorizontalAlignment = HorizontalAlignment.Center;
            label.VerticalAlignment   = VerticalAlignment.Center;
            label.Text = cnt;
            label.SetResourceReference(AyText.ForegroundProperty, "colorsuccess");
            g.Children.Add(label);
            return(g);
        }
        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();
            }
        }