private void SetListeners(UIElement element)
        {
            var renderer = element as ViewRenderer;

            if (renderer != null)
            {
                foreach (var child in renderer.Children)
                {
                    SetListeners(child);
                }
            }
            else
            {
                var property = new MouseDragElementBehavior()
                {
                    ConstrainToParentBounds = true
                };



                //element.MouseLeftButtonDown += DragContentViewRenderer_MouseLeftButtonDown;
                //element.MouseLeftButtonUp += DragContentViewRenderer_MouseLeftButtonUp;
                element.MouseMove += DragContentViewRenderer_MouseMove;
            }
        }
Example #2
0
 private void PerformSingleDrag(MouseDragElementBehavior behavior, Point from, Point to)
 {
     using (TestDragToken token = new TestDragToken(behavior, from))
     {
         token.PerformDrag(to);
     }
 }
Example #3
0
        void da_FtpMethodCompleted(object sender, FtpMethodCompletedEventArgs e)
        {
            if (e.Result == null || e.Result.Contains("@") == false)
            {
                MessageBox.Show("无法连接ftp://templete.ccflow.org,无法获取共享表单模板资源。");
                return;
            }

            string[] strs = e.Result.Split('@');
            int      idx  = 0;

            foreach (string s in strs)
            {
                BPDir img = new BPDir();

                img.Cursor = Cursors.Hand;
                img.SetValue(Canvas.LeftProperty, (double)30);
                img.SetValue(Canvas.TopProperty, (double)30);

                img.Width  = 32;
                img.Height = 32;

                MouseDragElementBehavior mdeImg = new MouseDragElementBehavior();
                Interaction.GetBehaviors(img).Add(mdeImg);
                this.canvas1.Children.Add(img);
                img.MouseLeftButtonDown  += new MouseButtonEventHandler(img_MouseLeftButtonDown);
                img.MouseRightButtonDown += new MouseButtonEventHandler(img_MouseLeftButtonDown);
            }
        }
Example #4
0
        public void IsConstrainedFalse_DragOutsideParentBounds_LeavesParentBounds()
        {
            Rectangle rect = CreateRectangleInGrid();
            MouseDragElementBehavior behavior = CreateAndAttachMouseDragElementBehavior(rect);

            this.PerformSingleDrag(behavior, new Point(5, 5), new Point(101, 101));
            this.VerifyOffset(rect.RenderTransform, 96, 96);
        }
Example #5
0
        /// <summary>
        /// 被拖动完成之后触发的事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void dragBehavior_DragFinished(object sender, MouseEventArgs e)
        {
            MouseDragElementBehavior dragBehavior = sender as MouseDragElementBehavior;

            this.Tag = dragBehavior.X + "|" + dragBehavior.Y; // this.Tag设置为相应的值

            //设置鼠标拖动本控件之后,在label1中显示当前控件的坐标位置
        }
Example #6
0
            public TestDragToken(MouseDragElementBehavior behavior, Point startPoint)
            {
                this.behavior       = behavior;
                this.draggedElement = (FrameworkElement)((IAttachedObject)behavior).AssociatedObject;;
                this.stubWindow     = new StubWindow(draggedElement.Parent);
                GeneralTransform rootToElement = this.stubWindow.TransformToVisual(draggedElement);

                behavior.StartDrag(rootToElement.Transform(startPoint));
            }
Example #7
0
        public void IsConstrainedTrue_DragOutsideVerticalBounds_DoesNotLeaveParent()
        {
            Rectangle rect = CreateRectangleInGrid();
            MouseDragElementBehavior behavior = CreateAndAttachMouseDragElementBehavior(rect);

            behavior.ConstrainToParentBounds = true;
            this.PerformSingleDrag(behavior, new Point(5, 5), new Point(5, 101));
            this.VerifyOffset(rect.RenderTransform, 0, 90);
        }
Example #8
0
        public void IsConstrainedTrue_NoMovement_DoesNotApplyTransform()
        {
            Rectangle rect = CreateRectangleInGrid();
            MouseDragElementBehavior behavior = CreateAndAttachMouseDragElementBehavior(rect);

            behavior.ConstrainToParentBounds = true;
            this.PerformSingleDrag(behavior, new Point(5, 5), new Point(5, 5));
            this.VerifyOffset(rect.RenderTransform, 0, 0);
        }
Example #9
0
        public void IsConstrainedFalse_ParentIsRotated_ElementIsPositionedCorrectly()
        {
            Rectangle rect = CreateRectangleInGrid();
            MouseDragElementBehavior behavior  = CreateAndAttachMouseDragElementBehavior(rect);
            RotateTransform          transform = new RotateTransform(30);

            ((Grid)rect.Parent).RenderTransform = transform;
            Point startPoint = transform.Transform(new Point(5, 5));
            Point dragPoint  = transform.Transform(new Point(50, 50));

            this.PerformSingleDrag(behavior, startPoint, dragPoint);
            this.VerifyOffset(rect.RenderTransform, 45.0d, 45.0d);
        }
Example #10
0
        public void IsConstrainedTrue_DragDownSide_MovesAlongUnboundedAxis()
        {
            Rectangle rect = CreateRectangleInGrid();
            MouseDragElementBehavior behavior = CreateAndAttachMouseDragElementBehavior(rect);

            behavior.ConstrainToParentBounds = true;

            using (TestDragToken token = new TestDragToken(behavior, new Point(5, 5)))
            {
                token.PerformDrag(new Point(-5, 25));
                this.VerifyOffset(rect.RenderTransform, 0, 20);
                token.PerformDrag(new Point(-5, 120));
                this.VerifyOffset(rect.RenderTransform, 0, 90);
            }
        }
Example #11
0
        public PuzzlePiece(int row, int column)
        {
            Matched = false;
            _dragTranslation = new TranslateTransform();

            Element = new Image();
            Element = StyleOrb(Element);
            Element = AddTouchEvents(Element);
            SetPosition(row, column);
            _dragTranslation.Y -= AppGlobals.PuzzleGridActualHeight;

            BehaviorCollection behaviors = Interaction.GetBehaviors(Element);
            var mouseDragBehavior = new MouseDragElementBehavior();
            mouseDragBehavior.ConstrainToParentBounds = true;
            behaviors.Add(mouseDragBehavior);
        }
Example #12
0
        public void addToDragList()
        {
            MouseDragElementBehavior dragBehavior = new MouseDragElementBehavior();

            dragBehavior.Attach(this);
            dragBehavior.Dragging += dragBehavior_Dragging;

            MouseDragElementBehavior dragBehaviorConnectorFront = new MouseDragElementBehavior();

            dragBehaviorConnectorFront.Attach(FrontConnector);
            dragBehaviorConnectorFront.Dragging += dragBehaviorConnectorFront_Dragging;

            MouseDragElementBehavior dragBehaviorConnectorTail = new MouseDragElementBehavior();

            dragBehaviorConnectorTail.Attach(TailConnector);
            dragBehaviorConnectorTail.Dragging += dragBehaviorConnectorTail_Dragging;
        }
Example #13
0
        private void addToDragList(Shape renderShape, Point pt)
        {
            MouseDragElementBehavior dragBehaviorEllipse = new MouseDragElementBehavior();

            dragBehaviorEllipse.Attach(renderShape);

            //TextBlock lable = new TextBlock { Text = "X = " + pt.X + ", Y = " + pt.Y };
            //lable.RenderTransform = new TranslateTransform();

            //Canvas.SetLeft(lable, pt.X + NODE_DIMENSION + 3);
            //Canvas.SetTop(lable, pt.Y + (NODE_DIMENSION / 2 - 5));

            //DisplayArea.Children.Add(lable);
            //renderShape.Tag = lable; // attach to Ellipse

            _label.Text = getLabelText(pt);
            dragBehaviorEllipse.Dragging += dragBehaviorEllipse_Dragging;

            dragBehaviorEllipse.DragFinished += dragBehaviorEllipse_DragFinished;;
        }
Example #14
0
        public void IsConstrainedTrue_DragOutAndBackIn_DoesNotMoveUntilBackAtStartPoint()
        {
            Rectangle rect = CreateRectangleInGrid();
            MouseDragElementBehavior behavior = CreateAndAttachMouseDragElementBehavior(rect);

            behavior.ConstrainToParentBounds = true;

            using (TestDragToken token = new TestDragToken(behavior, new Point(5, 5)))
            {
                token.PerformDrag(new Point(-50, 5));
                this.VerifyOffset(rect.RenderTransform, 0, 0);
                token.PerformDrag(new Point(-25, 5));
                this.VerifyOffset(rect.RenderTransform, 0, 0);
                token.PerformDrag(new Point(-1, 5));
                this.VerifyOffset(rect.RenderTransform, 0, 0);
                token.PerformDrag(new Point(4, 5));
                this.VerifyOffset(rect.RenderTransform, 0, 0);
                token.PerformDrag(new Point(6, 5));
                this.VerifyOffset(rect.RenderTransform, 1, 0);
            }
        }
        void da_Fls_FtpMethodCompleted(object sender, FtpMethodCompletedEventArgs e)
        {
            this.loadingWindow.Close();
            if (e.Result == null || e.Result.Contains("Err") == true)
            {
                MessageBox.Show(e.Result, "连接到网络错误", MessageBoxButton.OK);
                return;
            }

            this.OKButton.Visibility = System.Windows.Visibility.Visible;
            this.canvas1.Children.Clear();

            string[] strs   = e.Result.Split('@');
            int      colIdx = 0;
            int      rowIdx = 0;

            foreach (string s in strs)
            {
                if (string.IsNullOrEmpty(s))
                {
                    continue;
                }

                colIdx++;
                if (colIdx == 5)
                {
                    rowIdx++;
                    colIdx = 0;
                }
                TempleteFile tempFile = new TempleteFile();
                tempFile.BindText(s);
                tempFile.SetValue(Canvas.LeftProperty, (double)100 * colIdx);
                tempFile.SetValue(Canvas.TopProperty, (double)100 * rowIdx);
                tempFile.Tag = s;
                MouseDragElementBehavior mdeImg = new MouseDragElementBehavior();
                Interaction.GetBehaviors(tempFile).Add(mdeImg);
                this.canvas1.Children.Add(tempFile);
                tempFile.MouseLeftButtonDown += new MouseButtonEventHandler(tempFile_MouseLeftButtonDown);
            }
        }
Example #16
0
        private async void InitMainMenu()
        {
            #region 初始化属性
            var mainMenuInfo = _userConfigution.ImageSetting.MainMenuInfo;

            var animatedGif = await GetMainMenuIcon();

            _mainMenu = new UserControl
            {
                Content = animatedGif,
                Width   = mainMenuInfo.Width,
                Height  = mainMenuInfo.Height,
                ToolTip = "EasyImage主菜单",
                Cursor  = Cursors.SizeAll,
            };

            var transformGroup = new TransformGroup();
            transformGroup.Children.Add(new ScaleTransform(1, 1));
            transformGroup.Children.Add(new RotateTransform(0));
            transformGroup.Children.Add(new TranslateTransform(mainMenuInfo.TranslateX, mainMenuInfo.TranslateY));
            _mainMenu.RenderTransform = transformGroup;

            var dragBehavior = new MouseDragElementBehavior <UserControl>
            {
                MoveableRange = new Rect(0, 0, SystemParameters.VirtualScreenWidth, SystemParameters.VirtualScreenHeight),
            };
            dragBehavior.Attach(_mainMenu);

            _autoHideBehavior = new AutoHideElementBehavior
            {
                AutoHideFactor = _userConfigution.WindowState.ImageWindowState.AutoHideFactor,
            };
            _autoHideBehavior.Attach(_mainMenu);

            #endregion

            #region 添加上下文菜单
            var contextMenu = new ContextMenu();
            var item        = new MenuItem {
                Header = "新建", Tag = "New"
            };

            #region 二级菜单
            var subItem = new MenuItem
            {
                Header = "矩形",
                Tag    = "Square"
            };
            subItem.Click += AddImageFromInternal;
            item.Items.Add(subItem);

            subItem = new MenuItem
            {
                Header = "圆形",
                Tag    = "Circle"
            };
            subItem.Click += AddImageFromInternal;
            item.Items.Add(subItem);

            subItem = new MenuItem
            {
                Header = "三角形",
                Tag    = "Triangle"
            };
            subItem.Click += AddImageFromInternal;
            item.Items.Add(subItem);

            subItem = new MenuItem
            {
                Header = "五角星",
                Tag    = "FiveStar"
            };
            subItem.Click += AddImageFromInternal;
            item.Items.Add(subItem);

            subItem = new MenuItem
            {
                Header = "圆环",
                Tag    = "Torus"
            };
            subItem.Click += AddImageFromInternal;
            item.Items.Add(subItem);

            #endregion

            contextMenu.Items.Add(item);

            item = new MenuItem {
                Header = "打开", Tag = "Open"
            };
            item.Click += LoadEasyImageFromFile;
            contextMenu.Items.Add(item);

            item = new MenuItem {
                Header = "添加", Tag = "Add"
            };
            item.Click += AddImagesFromFile;
            contextMenu.Items.Add(item);

            item = new MenuItem {
                Header = "保存", Tag = "Save"
            };
            item.Click += SaveEasyImageToFile;
            contextMenu.Items.Add(item);

            item = new MenuItem {
                Header = "另保存", Tag = "SaveAs"
            };
            item.Click += SaveAsEasyImageToFile;
            contextMenu.Items.Add(item);

            item = new MenuItem {
                Header = "粘贴", Tag = "Paste"
            };
            item.Click += PasteImagesFromClipboard;
            contextMenu.Items.Add(item);

            item = new MenuItem {
                Header = "设置", Tag = "Setting"
            };
            item.Click += SettingWindow;
            contextMenu.Items.Add(item);

            item = new MenuItem {
                Header = "收藏夹", Tag = "Favorites"
            };
            item.Click += (sender, e) =>
            {
                _imageFavoritesWindow.ShowWindow();
            };
            contextMenu.Items.Add(item);

            contextMenu.Items.Add(new Separator());//分割线

            item = new MenuItem {
                Header = "退出", Tag = "Exit"
            };
            item.Click += (sender, args) =>
            {
                Close();
            };
            contextMenu.Items.Add(item);

            _mainMenu.ContextMenu = contextMenu;
            #endregion

            #region 添加事件
            _mainMenu.MouseDown          += MainMenu_MouseDown;
            _mainMenu.ContextMenuOpening += MainMenu_ContextMenuOpening;

            #endregion

            MainCanvas.Children.Add(_mainMenu);
        }
Example #17
0
        void AddControl(UIControl control)
        {
            if (control.ImageIndex >= images.Count)
            {
                return;
            }

            var imagebit = images[control.ImageIndex];
            var texture  = textures[(int)imagebit.TextureIndex];
            var text     = (control.TextIndex < texts.Count) ? texts[control.TextIndex] : null;

            control.Content = text;
            var image = new Image();

            image.Stretch = Stretch.Fill;
            image.SetBinding(Image.WidthProperty, CreateTwoWayBinding("Width", control));
            image.SetBinding(Image.HeightProperty, CreateTwoWayBinding("Height", control));

            var matrix = image.RenderTransform.Value;

            switch (control.Dock)
            {
            // TBD

            /*case DockingMode.CenterCenter:
             *      matrix.OffsetX = (canvas.ActualWidth - image.Width) / 2;
             *      matrix.OffsetY = (canvas.ActualHeight - image.Height) / 2;
             *      break;*/

            default:
                matrix.OffsetX = control.Rectangle.Left;
                matrix.OffsetY = control.Rectangle.Top;
                break;
            }

            image.SetBinding(Image.RenderTransformProperty, CreateTwoWayBinding("Rectangle", control, new RectConverter()));

            if (control.ImageState != State.Hidden)
            {
                /*var bitmap = new BitmapImage();
                 * bitmap.BeginInit();
                 * bitmap.UriSource = new Uri(dir + '\\' + texture.Name);
                 * bitmap.DecodePixelWidth = (int)texture.Width;
                 * bitmap.DecodePixelHeight = (int)texture.Height;
                 * bitmap.EndInit();*/

                var bitmap = (BitmapSource)DDSConverter.Convert(dir + '\\' + texture.Name);

                var rect = new Int32Rect(imagebit.TopLeft.X, imagebit.TopLeft.Y, imagebit.Width, imagebit.Height);

                if (rect.X + rect.Width > texture.Width)
                {
                    rect.Width = (int)texture.Width - rect.X;
                }
                if (rect.Y + rect.Height > texture.Height)
                {
                    rect.Height = (int)texture.Height - rect.Y;
                }

                image.Source = new CroppedBitmap(bitmap, rect);

                bitmap = null;

                #region Memory Leak!

                /*var write = new WriteableBitmap(bitmap);
                 *
                 * write.Lock();
                 *
                 * if (rect.Height != 0 && rect.Width != 0)
                 * {
                 *      if (rect.X + rect.Width > write.PixelWidth)
                 *      {
                 *              var pixels = new byte[write.PixelHeight * write.PixelWidth * write.Format.BitsPerPixel];
                 *
                 *              write.CopyPixels(pixels, write.BackBufferStride, 0);
                 *              write = new WriteableBitmap(write.PixelWidth * 2, write.PixelHeight, write.DpiX, write.DpiY, write.Format, write.Palette);
                 *              write.WritePixels(new Int32Rect(0, 0, write.PixelWidth, write.PixelHeight), pixels, write.BackBufferStride, 0);
                 *              write.WritePixels(new Int32Rect(write.PixelWidth, 0, write.PixelWidth, write.PixelHeight), pixels, write.BackBufferStride, 0);
                 *
                 *              pixels = null;
                 *      }
                 *
                 *      if (rect.Y + rect.Height > write.PixelHeight)
                 *      {
                 *              var pixels = new byte[write.PixelHeight * write.PixelWidth * write.Format.BitsPerPixel];
                 *
                 *              var blah = new BitmapImage();
                 *
                 *              write.CopyPixels(pixels, write.BackBufferStride, 0);
                 *              write = new WriteableBitmap(write.PixelWidth, write.PixelHeight * 2, write.DpiX, write.DpiY, write.Format, write.Palette);
                 *              write.WritePixels(new Int32Rect(0, 0, write.PixelWidth, write.PixelHeight / 2), pixels, write.BackBufferStride, 0);
                 *              write.WritePixels(new Int32Rect(0, write.PixelHeight / 2, write.PixelWidth, write.PixelHeight / 2), pixels, write.BackBufferStride, 0);
                 *
                 *              pixels = null;
                 *      }
                 *
                 *      image.Source = new CroppedBitmap(write, rect);
                 * }
                 *
                 * write.Unlock();
                 *
                 * bitmap = null;
                 * write = null;
                 *
                 * GC.Collect();
                 * GC.WaitForPendingFinalizers();*/

                #endregion
            }

            var behaviours = Interaction.GetBehaviors(image);

            var resize = new ResizeBehavior();
            resize.MaxWidth              = 1024;
            resize.MaxHeight             = 768;
            resize.MinWidth              = 2;
            resize.MinHeight             = 2;
            resize.StayInParent          = true;
            resize.DragSpace             = 4;
            resize.DragIndicatorsOpacity = 0.75;
            resize.DragIndicatorsFill    = Brushes.White;
            behaviours.Add(resize);

            var drag = new MouseDragElementBehavior();
            drag.ConstrainToParentBounds = true;
            behaviours.Add(drag);

            image.MouseDown += control_MouseDown;

            image.Tag = control;

            canvas.Children.Add(image);

            if (text == null || text.DTSIndex == -1 || control.TextLines == 0)
            {
                return;
            }

            var stack = new StackPanel();
            stack.SetBinding(StackPanel.RenderTransformProperty, CreateTwoWayBinding("Location", text, new PointConverter()));

            var lineWidthBinding  = CreateTwoWayBinding("Width", text);
            var lineHeightBinding = CreateTwoWayBinding("LineHeight", text);
            var hAlignBinding     = CreateTwoWayBinding("HAlign", text);
            var vAlignBinding     = CreateTwoWayBinding("VAlign", text);

            var brush = new SolidColorBrush();
            BindingOperations.SetBinding(brush, SolidColorBrush.ColorProperty, CreateTwoWayBinding("NormalColour", text, new ColourConverter()));

            for (int i = 0; i < control.TextLines; i++)
            {
                var label = new Label();

                var contentBinding = new Binding();
                contentBinding.Source = dts[text.DTSIndex + i];
                contentBinding.Mode   = BindingMode.OneWay;
                contentBinding.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;

                label.SetBinding(Label.ContentProperty, contentBinding);

                label.Foreground = brush;

                label.SetBinding(Label.WidthProperty, lineWidthBinding);
                label.SetBinding(Label.HeightProperty, lineHeightBinding);

                label.SetBinding(Label.HorizontalContentAlignmentProperty, hAlignBinding);
                label.SetBinding(Label.VerticalContentAlignmentProperty, vAlignBinding);

                label.IsHitTestVisible = false;
                label.FontFamily       = new FontFamily("Tahoma");
                label.FontSize         = 11.0d;
                label.Padding          = new Thickness(0);

                label.Tag = image;

                stack.Children.Add(label);
            }

            canvas.Children.Add(stack);
        }
Example #18
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);
            //    };
            //}
        }