Пример #1
0
        static void AssetAction(SaveItemInfo info, ToolboxItem item, double x, double y)
        {
            Canvas canvas = item.Parent as Canvas;

            if (canvas == null)
            {
                return;
            }
            if (item == null)
            {
                return;
            }

            switch (info.assetActionInfo.AssetAction)
            {
            case enumAssetAction.Fade:    //淡入淡出
                AssetActionFade(info.assetActionInfo, item, 0, 1);
                break;

            case enumAssetAction.Left:     //左侧飞入
                AssetActionMove(info.assetActionInfo, item, ((SaveItemInfo)item.DataContext).X, ((SaveItemInfo)item.DataContext).X + canvas.ActualWidth);
                break;

            case enumAssetAction.Right:    //右侧飞入
                AssetActionMove(info.assetActionInfo, item, ((SaveItemInfo)item.DataContext).X, ((SaveItemInfo)item.DataContext).X - canvas.ActualWidth);
                break;
            }
        }
Пример #2
0
        public void SetContent(int Column, int Row, SaveItemInfo children)
        {
            ToolboxItem toolBoxItem;

            UIElement txt = (from model in this.Children.OfType <UIElement>() where Grid.GetColumn(model) == Column && Grid.GetRow(model) == Row select model).FirstOrDefault();

            if (txt != null)
            {
                Children.Remove(txt);
            }
            if (IsEdit == true)
            {
                toolBoxItem = ToolboxItem.GetToolBoxItem(children);
            }
            else
            {
                toolBoxItem = ToolboxItem.GetGridChildrenPreview(children);
            }

            Grid.SetRow(toolBoxItem, Row);
            Grid.SetColumn(toolBoxItem, Column);
            Children.Add(toolBoxItem);
        }
Пример #3
0
        public static UIElement CreateElement(SaveItemInfo info)
        {
            Canvas      canvas;
            ToolboxItem item = null;

            double x, y;

            item = ToolboxItem.GetToolBoxItemPreview(info);

            if (item.Content is jg.Editor.Library.Control.ControlMediaElement)
            {
                ((jg.Editor.Library.Control.ControlMediaElement)item.Content).ScaleChanged += PageStage_ScaleChanged;
            }


            item.DataContext = info;
            x = Canvas.GetLeft(item);
            y = Canvas.GetTop(item);

            if (item.AssetType != AssetType.HTML5)
            {
                item.MouseEnter += (sender, e) =>
                {
                    item = sender as ToolboxItem;
                    if (item == null)
                    {
                        return;
                    }
                    canvas = item.Parent as Canvas;
                    if (canvas == null)
                    {
                        return;
                    }

                    if (info.assetActionInfo == null)
                    {
                        return;
                    }
                    if (string.IsNullOrEmpty(info.assetActionInfo.AssetName))
                    {
                        return;
                    }

                    var selectedItems = canvas.Children.OfType <ToolboxItem>().FirstOrDefault(model => model.ItemName == info.assetActionInfo.AssetName);
                    if (selectedItems == null)
                    {
                        return;
                    }
                    if (info.assetActionInfo.AssetEvent != enumAssetEvent.MouseEnter)
                    {
                        return;
                    }
                    AssetAction(info, selectedItems, x, y);
                };

                ShowMaxBox smb = item.Content as ShowMaxBox;

                if (smb != null)
                {
                    smb.eventShowAsset += item_showAsset;
                }


                item.MouseLeave += (sender, e) =>
                {
                    item = sender as ToolboxItem;
                    if (item == null)
                    {
                        return;
                    }

                    canvas = item.Parent as Canvas;
                    if (canvas == null)
                    {
                        return;
                    }
                    if (info.assetActionInfo == null)
                    {
                        return;
                    }
                    if (string.IsNullOrEmpty(info.assetActionInfo.AssetName))
                    {
                        return;
                    }
                    var selectedItems = canvas.Children.OfType <ToolboxItem>().FirstOrDefault(model => model.ItemName == info.assetActionInfo.AssetName);
                    if (selectedItems == null)
                    {
                        return;
                    }
                    if (info.assetActionInfo.AssetEvent != enumAssetEvent.MouseEnter)
                    {
                        return;
                    }
                    UnAssetAction(info, selectedItems, x, y);
                };

                item.MouseLeftButtonUp += (sender, e) =>
                {
                    try
                    {
                        item = sender as ToolboxItem;
                        if (item == null)
                        {
                            return;
                        }

                        canvas = item.Parent as Canvas;
                        if (canvas == null)
                        {
                            return;
                        }

                        if (string.IsNullOrEmpty(info.assetActionInfo.AssetName))
                        {
                            return;
                        }
                        switch (info.assetActionInfo.AssetAction)
                        {
                        case enumAssetAction.PageJump:
                            PageChanged(item, new RoutedPropertyChangedEventArgs <Guid>(info.ItemId, Guid.Parse(info.assetActionInfo.AssetName)));
                            break;

                        default:
                            var selectedItems = canvas.Children.OfType <ToolboxItem>().FirstOrDefault(model => model.ItemName == info.assetActionInfo.AssetName);
                            if (selectedItems == null)
                            {
                                return;
                            }
                            if (info.assetActionInfo.AssetEvent != enumAssetEvent.MouseClick)
                            {
                                return;
                            }
                            if (SelItemId == item.ItemId)
                            {
                                UnAssetAction(info, selectedItems, x, y);
                                SelItemId = Guid.NewGuid();
                            }
                            else
                            {
                                AssetAction(info, selectedItems, x, y);
                                SelItemId = item.ItemId;
                            }
                            break;
                        }
                    }
                    catch (Exception ex)
                    {
                        System.Windows.MessageBox.Show(ex.Message);
                    }
                };
            }

            return(item);
        }
Пример #4
0
        public static UIElement CreateElement(SaveItemInfo info)
        {
            Canvas      canvas;
            ToolboxItem item = null;
            double      x, y;

            item             = ToolboxItem.GetToolBoxItemPreview(info);
            item.DataContext = info;
            x = Canvas.GetLeft(item);
            y = Canvas.GetTop(item);

            item.MouseEnter += (sender, e) =>
            {
                item = sender as ToolboxItem;
                if (item == null)
                {
                    return;
                }
                canvas = item.Parent as Canvas;
                if (canvas == null)
                {
                    return;
                }

                if (info.assetActionInfo == null)
                {
                    return;
                }
                if (string.IsNullOrEmpty(info.assetActionInfo.AssetName))
                {
                    return;
                }

                var selectedItems = canvas.Children.OfType <ToolboxItem>().FirstOrDefault(model => model.ItemName == info.assetActionInfo.AssetName);
                if (selectedItems == null)
                {
                    return;
                }
                if (info.assetActionInfo.AssetEvent != enumAssetEvent.MouseEnter)
                {
                    return;
                }
                AssetAction(info, selectedItems, x, y);
            };
            item.MouseDoubleClick += (sender, e) =>
            {
            };
            item.MouseLeave += (sender, e) =>
            {
                item = sender as ToolboxItem;
                if (item == null)
                {
                    return;
                }

                canvas = item.Parent as Canvas;
                if (canvas == null)
                {
                    return;
                }
                if (info.assetActionInfo == null)
                {
                    return;
                }
                if (string.IsNullOrEmpty(info.assetActionInfo.AssetName))
                {
                    return;
                }
                var selectedItems = canvas.Children.OfType <ToolboxItem>().FirstOrDefault(model => model.ItemName == info.assetActionInfo.AssetName);
                if (selectedItems == null)
                {
                    return;
                }
                if (info.assetActionInfo.AssetEvent != enumAssetEvent.MouseEnter)
                {
                    return;
                }
                UnAssetAction(info, selectedItems, x, y);
            };
            item.MouseLeftButtonUp += (sender, e) =>
            {
                item = sender as ToolboxItem;
                if (item == null)
                {
                    return;
                }

                canvas = item.Parent as Canvas;
                if (canvas == null)
                {
                    return;
                }
                if (info.assetActionInfo == null)
                {
                    return;
                }
                if (string.IsNullOrEmpty(info.assetActionInfo.AssetName))
                {
                    return;
                }
                var selectedItems = canvas.Children.OfType <ToolboxItem>().FirstOrDefault(model => model.ItemName == info.assetActionInfo.AssetName);
                if (selectedItems == null)
                {
                    return;
                }
                if (info.assetActionInfo.AssetEvent != enumAssetEvent.MouseClick)
                {
                    return;
                }

                if (SelItemId == item.ItemId)
                {
                    UnAssetAction(info, selectedItems, x, y);
                    SelItemId = Guid.NewGuid();
                }
                else
                {
                    AssetAction(info, selectedItems, x, y);
                    SelItemId = item.ItemId;
                }
            };
            return(item);
        }