Пример #1
0
 public MyLayer()
 {
     InitializeComponent();
     MyTime.SetInterval(1000, () =>
     {
         this.WindowState = WindowState.Maximized;
     });
 }
Пример #2
0
        public static void End(this MyAnimateBase ani)
        {
            MyTime.SetTimeout(((int)ani.AnimateSpeed + 1000), () =>
            {
                var d = ani as MyAnimateTypeBase;
                if (d != null)
                {
                    d.RaiseStoryComplete();
                }
                ani.Stop();
                ani.Destroy();
                ani.Completed = null;

                GC.SuppressFinalize(ani);
                ani = null;
            });
        }
Пример #3
0
 private void SearchText_PreviewMouseLeftButtonDown(object sender, RoutedEventArgs e)
 {
     MyTime.SetTimeout(10, () =>
     {
         ICollectionView view = CollectionViewSource.GetDefaultView(this.ItemsSource);
         if (view.Filter != null)
         {
             view.Filter -= Filter;
         }
         view.Filter += (obj) =>
         {
             return(true);
         };
         if (SourceListBox.Items.Count == 0)
         {
             InternalClosePopup();
         }
         else
         {
             InternalOpenPopup();
         }
     });
 }
Пример #4
0
        private void SetMyLayerBase(Window owner, object content, string title, MyLayerOptions options, bool isDiaglog, Action action)
        {
            if (options == null)
            {
                options = MYUI.DefaultAyLayerOptions;
            }
            _options   = options;
            this.Title = title ?? "";
            //this.Topmost = true;
            //this.ShowInTaskbar = true;
            //if (owner != null)
            //{
            //    Owner = owner;
            //}
            Owner = owner ?? Application.Current.MainWindow;
            //userPresenter.Content = content;
            var fram = content as FrameworkElement;

            if (fram != null)
            {
                userPresenter.Width  = fram.Width;
                userPresenter.Height = fram.Height;
            }
            if (options.CanDrag)
            {
                MouseDragElementBehavior m = new MouseDragElementBehavior();
                m.Attach(body);
                //body.MouseMove += new MouseEventHandler(Element_MouseMove);
                //body.MouseLeftButtonDown += new MouseButtonEventHandler(Element_MouseLeftButtonDown);
                //body.MouseLeftButtonUp += new MouseButtonEventHandler(Element_MouseLeftButtonUp);
            }
            if (options.IsContainsTitleBar)
            {
                d.Height = Extensiones.ToGridLength("42.00");
                Border b = new Border();
                if (options.LayerCornerRadius.HasValue)
                {
                    b.Margin       = new Thickness(-1, -1, -1, 0);
                    b.CornerRadius = new CornerRadius(options.LayerCornerRadius.Value.TopLeft, options.LayerCornerRadius.Value.TopRight, 0, 0);
                }

                b.HorizontalAlignment = HorizontalAlignment.Stretch;
                b.VerticalAlignment   = VerticalAlignment.Stretch;
                //b.SetResourceReference(Border.BackgroundProperty, Colors.CadetBlue);
                b.Background = SolidColorBrushConverter.From16JinZhi("#F0F1F2");
                Grid g = new Grid();
                if (!string.IsNullOrWhiteSpace(title))
                {
                    TextBlock tb = new TextBlock();
                    tb.Width               = 200;
                    tb.VerticalAlignment   = VerticalAlignment.Center;
                    tb.HorizontalAlignment = HorizontalAlignment.Left;
                    tb.Margin              = new Thickness(10, 0, 0, 0);
                    tb.TextWrapping        = TextWrapping.NoWrap;
                    tb.FontSize            = 14;
                    tb.TextTrimming        = TextTrimming.CharacterEllipsis;
                    //tb.Foreground = SolidColorBrushConverter.From16JinZhi("#99FFFFFF");
                    Binding binding = new Binding {
                        Path = new PropertyPath("Title"), Source = this, Mode = BindingMode.TwoWay
                    };
                    tb.SetBinding(TextBlock.TextProperty, binding);
                    g.Children.Add(tb);
                }
                MyImageButton ab = new MyImageButton();
                ab.RenderMode          = MyImageButtonMode.HorizonFour;
                ab.SnapsToDevicePixels = true;
                ab.Margin              = new Thickness(0, 0, 10, 0);
                ab.Height              = ab.Width = 26;
                ab.VerticalAlignment   = VerticalAlignment.Center;
                ab.HorizontalAlignment = HorizontalAlignment.Right;
                ab.Padding             = new Thickness(0);
                ab.Icon   = new BitmapImage(new Uri("pack://application:,,,/MyWPFUI;component/Resources/Images/closebtn.png"));
                ab.Click += closewindow_Click;
                ab.VerticalContentAlignment   = VerticalAlignment.Center;
                ab.HorizontalContentAlignment = HorizontalAlignment.Center;
                //ab.Foreground = SolidColorBrushConverter.From16JinZhi("#99FFFFFF");
                //ab.Content = "关闭";
                g.Children.Add(ab);
                b.Child = g;
                bodyConent.Children.Add(b);
            }
            Console.WriteLine("开始触发options.MaskBrush");
            if (options.MaskBrush.IsNotNull())
            {
                layoutMain.Background = options.MaskBrush;
            }
            if (isDiaglog)
            {
                if (options.MaskBrush.IsNull())
                {
                    layoutMain.Background = SolidColorBrushConverter.From16JinZhi("#05FFFFFF");
                }
                layoutMain.MouseLeftButtonDown += LayoutMain_MouseLeftButtonDown;
            }
            Console.WriteLine("开始触发options.IsShowLayerBorder");


            if (options.IsShowLayerBorder)
            {
                body.SetResourceReference(Border.BorderBrushProperty, "Ay.Brush14");

                if (options.LayerBorderThickness.HasValue)
                {
                    body.BorderThickness = options.LayerBorderThickness.Value;
                }
                else
                {
                    body.BorderThickness = new Thickness(1);
                }
            }
            Console.WriteLine("开始触发options.LayerCornerRadius");
            if (options.LayerCornerRadius.HasValue)
            {
                body.CornerRadius = options.LayerCornerRadius.Value;
            }
            options.LayerBackground.Freeze();
            body.Background = options.LayerBackground;
            Console.WriteLine("开始触发options.ShowAnimateIndex");
            if (options.ShowAnimateIndex == 0)
            {
                ShowShadow(options);
                body.Visibility = Visibility.Visible;

                this.ContentRendered += (e, f) =>
                {
                    userPresenter.Content = content;
                    if (action != null)
                    {
                        MyTime.SetTimeout(20, action);
                    }
                };
            }
            else if (options.ShowAnimateIndex == 1)
            {
                var sc = new MyAniScale(body, () =>
                {
                    ShowShadow(options);
                });
                sc.AnimateSpeed   = 750;
                sc.ScaleXFrom     = 0;
                sc.ScaleYFrom     = 0;
                sc.ScaleXTo       = 1;
                sc.ScaleYTo       = 1;
                sc.EasingFunction = new System.Windows.Media.Animation.CubicEase {
                    EasingMode = EasingMode.EaseOut
                };
                sc.Animate().End();
                sc.story.Completed += (c, d) =>
                {
                    userPresenter.Content = content;
                    if (action != null)
                    {
                        MyTime.SetTimeout(20, action);
                    }
                };
            }
            else if (options.ShowAnimateIndex == 2)
            {
                var sc = new MyAniSlideInDown(body, () =>
                {
                    ShowShadow(options);
                });
                sc.AnimateSpeed   = 750;
                sc.FromDistance   = -4000;
                sc.OpacityNeed    = false;
                sc.EasingFunction = new System.Windows.Media.Animation.CubicEase {
                    EasingMode = EasingMode.EaseOut
                };
                sc.Animate().End();
                sc.story.Completed += (c, d) =>
                {
                    userPresenter.Content = content;
                    if (action != null)
                    {
                        MyTime.SetTimeout(20, action);
                    }
                };
            }
            else if (options.ShowAnimateIndex == 3)
            {
                var sc = new MyAniSlideInUp(body, () =>
                {
                    ShowShadow(options);
                });
                sc.AnimateSpeed   = 750;
                sc.FromDistance   = 4000;
                sc.OpacityNeed    = false;
                sc.EasingFunction = new System.Windows.Media.Animation.CubicEase {
                    EasingMode = EasingMode.EaseOut
                };
                sc.Animate().End();

                sc.story.Completed += (c, d) =>
                {
                    userPresenter.Content = content;
                    if (action != null)
                    {
                        MyTime.SetTimeout(20, action);
                    }
                };
            }
            else if (options.ShowAnimateIndex == 4)
            {
                var sc = new MyAniSlideInLeft(body, () =>
                {
                    ShowShadow(options);
                });
                sc.AnimateSpeed   = 750;
                sc.FromDistance   = -4000;
                sc.OpacityNeed    = false;
                sc.EasingFunction = new System.Windows.Media.Animation.CubicEase {
                    EasingMode = EasingMode.EaseOut
                };
                sc.Animate().End();

                sc.story.Completed += (c, d) =>
                {
                    userPresenter.Content = content;
                    if (action != null)
                    {
                        MyTime.SetTimeout(20, action);
                    }
                };
            }
            else if (options.ShowAnimateIndex == 5)
            {
                var sc = new MyAniSlideInRight(body, () =>
                {
                    ShowShadow(options);
                });
                sc.AnimateSpeed   = 750;
                sc.FromDistance   = 4000;
                sc.OpacityNeed    = false;
                sc.EasingFunction = new System.Windows.Media.Animation.CubicEase {
                    EasingMode = EasingMode.EaseOut
                };
                sc.Animate().End();

                sc.story.Completed += (c, d) =>
                {
                    userPresenter.Content = content;
                    if (action != null)
                    {
                        MyTime.SetTimeout(20, action);
                    }
                };
            }
            else if (options.ShowAnimateIndex == 6)
            {
                var sc = new MyAniBounceInDown(body, () =>
                {
                    ShowShadow(options);
                });
                sc.Animate().End();

                sc.story.Completed += (c, d) =>
                {
                    userPresenter.Content = content;
                    if (action != null)
                    {
                        MyTime.SetTimeout(20, action);
                    }
                };
            }
            else if (options.ShowAnimateIndex == 7)
            {
                var sc = new MyAniBounceInUp(body, () =>
                {
                    ShowShadow(options);
                });
                sc.Animate().End();

                sc.story.Completed += (c, d) =>
                {
                    userPresenter.Content = content;
                    if (action != null)
                    {
                        MyTime.SetTimeout(20, action);
                    }
                };
            }
            else if (options.ShowAnimateIndex == 8)
            {
                var sc = new MyAniBounceInLeft(body, () =>
                {
                    ShowShadow(options);
                });
                sc.Animate().End();

                sc.story.Completed += (c, d) =>
                {
                    userPresenter.Content = content;
                    if (action != null)
                    {
                        MyTime.SetTimeout(20, action);
                    }
                };
            }
            else if (options.ShowAnimateIndex == 9)
            {
                var sc = new MyAniBounceInRight(body, () =>
                {
                    ShowShadow(options);
                });
                sc.Animate().End();

                sc.story.Completed += (c, d) =>
                {
                    userPresenter.Content = content;
                    if (action != null)
                    {
                        MyTime.SetTimeout(20, action);
                    }
                };
            }
            else if (options.ShowAnimateIndex == 10)
            {
                var sc = new MyAniRotateIn(body, () =>
                {
                    ShowShadow(options);
                });
                sc.AnimateSpeed   = 750;
                sc.EasingFunction = new System.Windows.Media.Animation.CubicEase {
                    EasingMode = EasingMode.EaseOut
                };
                sc.Animate().End();

                sc.story.Completed += (c, d) =>
                {
                    userPresenter.Content = content;
                    if (action != null)
                    {
                        MyTime.SetTimeout(20, action);
                    }
                };
            }
            else if (options.ShowAnimateIndex == 11)
            {
                var sc = new MyAniBounceIn(body, () =>
                {
                    ShowShadow(options);
                });
                sc.AnimateSpeed = 750;
                sc.Animate().End();

                sc.story.Completed += (c, d) =>
                {
                    userPresenter.Content = content;
                    if (action != null)
                    {
                        MyTime.SetTimeout(20, action);
                    }
                };
            }
            //else if (options.ShowAnimateIndex == 12)
            //{
            //    var sc = new MyAniSlideOutDown(body, () =>
            //    {
            //        ShowShadow(options);
            //    });
            //    sc.AnimateSpeed = 750;
            //    sc.Animate().End();

            //    sc.story.Completed += (c, d) =>
            //    {
            //        userPresenter.Content = content;
            //        if (action != null)
            //            MyTime.SetTimeout(20, action);
            //    };
            //}
            //else if (options.ShowAnimateIndex == 13)
            //{
            //    var sc = new MyAniSlideOutRight(body, () =>
            //    {
            //        ShowShadow(options);
            //    });
            //    sc.AnimateSpeed = 750;
            //    sc.Animate().End();

            //    sc.story.Completed += (c, d) =>
            //    {
            //        userPresenter.Content = content;
            //        if (action != null)
            //            MyTime.SetTimeout(20, action);
            //    };
            //}
            //else if (options.ShowAnimateIndex == 14)
            //{
            //    var sc = new MyAniSlideOutUp(body, () =>
            //    {
            //        ShowShadow(options);
            //    });
            //    sc.AnimateSpeed = 750;
            //    sc.Animate().End();

            //    sc.story.Completed += (c, d) =>
            //    {
            //        userPresenter.Content = content;
            //        if (action != null)
            //            MyTime.SetTimeout(20, action);
            //    };
            //}
            //else if (options.ShowAnimateIndex == 15)
            //{
            //    var sc = new MyAniSlideOutLeft(body, () =>
            //    {
            //        ShowShadow(options);
            //    });
            //    sc.AnimateSpeed = 750;
            //    sc.Animate().End();

            //    sc.story.Completed += (c, d) =>
            //    {
            //        userPresenter.Content = content;
            //        if (action != null)
            //            MyTime.SetTimeout(20, action);
            //    };
            //}
        }