Exemplo n.º 1
0
        private CtlTreeView GetShowingTreeview(TabControl tc = null)
        {
            CtlTreeView ctv = null;

            try
            {
                if (this.grdSearch.IsVisible)
                {
                    ctv = this.GetShowingSearchTreeview();
                }
                else
                {
                    tc = (tc ?? this.tabMain);
                    TabItem tabItem = tc.SelectedItem as TabItem;
                    if (tabItem != null)
                    {
                        if (tabItem.Content is TabControl)
                        {
                            ctv = this.GetShowingTreeview(tabItem.Content as TabControl);
                        }
                        else
                        {
                            Util.Assert(tabItem.Content is CtlTreeView);
                            ctv = (tabItem.Content as CtlTreeView);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Log.Exception(e);
            }
            return(ctv);
        }
Exemplo n.º 2
0
        private void ReloadTabItemData(TabItem tabItem, string targetNodeId = null)
        {
            TabItemTag tag   = this.GetTag(tabItem);
            var        catEt = tag.CatEntity;

            if (catEt != null)
            {
                var ctv = new CtlTreeView();
                ctv.CollapseSearch();
                if (tag.IsShopShortcut)
                {
                    TreeNode showFrom = catEt;
                    var      entityId = catEt.EntityId;
                    ctv.Init(_pubTvController, null, null, false, entityId == ((_pubTvController != null) ? _pubTvController.DbAccessor.Root.EntityId : null), targetNodeId, showFrom, this.CanEditShortCut);
                }
                else
                {
                    var showFrom = catEt;
                    var entityId = catEt.EntityId;
                    ctv.Init(_prvTvController, null, null, false, entityId == ((_prvTvController != null) ? _prvTvController.DbAccessor.Root.EntityId : null), targetNodeId, showFrom, this.CanEditShortCut);
                }
                this.BindEvent(ctv, true);
                this.SetTooltip(ctv);
                tabItem.Content = ctv;
            }
        }
Exemplo n.º 3
0
        private TabItemTag FindRootTabItemTag(CtlTreeView ctv)
        {
            TabItemTag tag = null;

            if (ctv != null)
            {
                tag = (ctv.xFindAncestor <TabItem>().Tag as TabItemTag);
            }
            return(tag);
        }
Exemplo n.º 4
0
        private ShortcutEntity GetSelectedShortcut()
        {
            ShortcutEntity sc = null;
            CtlTreeView    showingTreeview = this.GetShowingTreeview(null);
            TreeNode       n = showingTreeview.ReadNodeFromSelectedItem();

            if (n is ShortcutEntity)
            {
                sc = (n as ShortcutEntity);
            }
            return(sc);
        }
Exemplo n.º 5
0
 private void BindEvent(CtlTreeView treeview, bool useDrop)
 {
     if (useDrop)
     {
         treeview.EvDrop -= this.OnEvDrop;
         treeview.EvDrop += this.OnEvDrop;;
     }
     treeview.tvMain.MouseDoubleClick  -= this.OnTreeviewDoubleClick;
     treeview.tvMain.MouseDoubleClick  += this.OnTreeviewDoubleClick;
     treeview.tvMain.MouseLeftButtonUp -= this.OnMouseLeftButtonUp;
     treeview.tvMain.MouseLeftButtonUp += this.OnMouseLeftButtonUp;
     treeview.tvMain.ContextMenu        = this.MenuShortcut;
 }
Exemplo n.º 6
0
        private void InitTabData(string rootId, string subRootId, string targetNodeId)
        {
            if (string.IsNullOrEmpty(rootId))
            {
                return;
            }

            TabItem mainTabItem = this.FindCatalogTabItemById(this.tabMain, rootId);

            if (mainTabItem == null)
            {
                return;
            }
            if (!string.IsNullOrEmpty(subRootId))
            {
                TabControl tabControl = mainTabItem.Content as TabControl;
                if (tabControl != null)
                {
                    TabItem tabItem = this.FindCatalogTabItemById(tabControl, subRootId);
                    if (tabItem != null)
                    {
                        if (targetNodeId != null)
                        {
                            CtlTreeView ctv = tabItem.Content as CtlTreeView;
                            if (ctv != null)
                            {
                                ctv.ReloadTreeViewData(subRootId);
                            }
                            else
                            {
                                this.ReloadTabItemData(tabItem, targetNodeId);
                            }
                        }
                        tabControl.SelectedItem = tabItem;
                    }
                }
            }
            else if (!string.IsNullOrEmpty(targetNodeId))
            {
                var ctv = mainTabItem.Content as CtlTreeView;
                if (ctv != null)
                {
                    ctv.ReloadTreeViewData(subRootId);
                }
                else
                {
                    ReloadTabItemData(mainTabItem, targetNodeId);
                }
            }
            this.tabMain.SelectedItem = mainTabItem;
        }
Exemplo n.º 7
0
 public void LoadDatas(CtlTreeView ctv = null, string targetNodeId = null)
 {
     if (this.grdSearch.IsVisible)
     {
         this.InitTvController();
         this.InitTabControl(null, null, null);
     }
     else
     {
         string parentId = null;
         string rootId   = this.GetCtvRoot(ctv, targetNodeId, out parentId);
         this.InitTabControl(rootId, parentId, targetNodeId);
     }
 }
Exemplo n.º 8
0
        private bool IsInsidePrvTabItem(CtlTreeView ctv)
        {
            bool rt;

            if (this.grdSearch.IsVisible)
            {
                rt = (this._prvSearchMouseDownTime > this._pubSearchMouseDownTime);
            }
            else
            {
                TabItemTag tag = this.FindRootTabItemTag(ctv);
                rt = !tag.IsShopShortcut;
            }
            return(rt);
        }
Exemplo n.º 9
0
        private string GetCtvRoot(CtlTreeView ctv, string targetNodeId, out string parentId)
        {
            string rootId = null;

            parentId = null;
            ctv      = (ctv ?? this.GetShowingTreeview(null));
            if (ctv != null && ctv != this.tvPrvSearch && ctv != this.tvPubSearch)
            {
                var rootTag = this.FindRootTabItemTag(ctv);
                if (rootTag != null)
                {
                    rootId = this.FindParentNode(this.GetShortcutTreeviewController(rootTag), rootTag.CatEntity, out parentId);
                }
            }
            return(rootId);
        }
Exemplo n.º 10
0
        private void ClearTreeViewExcept(CtlTreeView tv)
        {
            TabItem    tabItem    = tv.xFindAncestor <TabItem>();
            TabControl tabControl = tabItem.xFindAncestor <TabControl>();

            if (tabControl != null)
            {
                Util.Assert(tabControl.SelectedItem == tabItem);
                this.ClearTreeViewExcept(tabControl, tabItem);
            }
            if (tabControl != this.tabMain)
            {
                TabItem tabItem_ = this.tabMain.SelectedItem as TabItem;
                this.ClearTreeViewExcept(this.tabMain, tabItem_);
            }
            this._needInitTvSearch = true;
        }
Exemplo n.º 11
0
 private void SetTooltip(CtlTreeView ctv)
 {
     ctv.tvMain.xTraverse((it) =>
     {
         var ctlLeaf = it.Header as CtlLeaf;
         if (ctlLeaf == null)
         {
             return;
         }
         var shortcut = ctv.ReadNode(it) as ShortcutEntity;
         var text     = shortcut.Text.xLimitCharCountPerLine(70);
         it.ToolTip   = text;
         if (text.Length > 50)
         {
             it.SetValue(ToolTipService.ShowDurationProperty, text);
         }
     });
 }
Exemplo n.º 12
0
        private void Delete()
        {
            CtlTreeView ctv = this.GetShowingTreeview(null);

            if (this.CanEdit(ctv))
            {
                var tn = ctv.Delete();
                if (tn != null)
                {
                    this.LoadDatas(ctv, null);
                    if (!ctv.IsCatalogType(tn))
                    {
                        var shortcut = tn as ShortcutEntity;
                        if (shortcut != null && !string.IsNullOrEmpty(shortcut.ImageName))
                        {
                            ShortcutImageHelper.DeleteImage(shortcut.ImageName);
                        }
                    }
                }
            }
        }
Exemplo n.º 13
0
        private void OnTreeviewDoubleClick(object sender, MouseButtonEventArgs e)
        {
            this._isDoubleClick   = true;
            this._doubleClickTime = DateTime.Now;
            TreeView    tv  = sender as TreeView;
            CtlTreeView ctv = tv.xFindAncestor <CtlTreeView>();
            bool        isCatalog;

            if (ctv.IsPointInsideItem(false, out isCatalog))
            {
                if (!isCatalog)
                {
                    ShortcutEntity shortcut = ctv.ReadNodeFromSelectedItem() as ShortcutEntity;
                    this.SetOrSendShortcut(shortcut, true);
                    e.Handled = true;
                }
                else
                {
                    Util.Assert(false, "节点为空");
                }
            }
        }
Exemplo n.º 14
0
        private CtlTreeView GetShowingSearchTreeview()
        {
            Params.Shortcut.ShowType showType = Params.Shortcut.GetShowType(this._seller);
            CtlTreeView ctv = null;

            if (showType != Params.Shortcut.ShowType.ShopOnly)
            {
                if (showType != Params.Shortcut.ShowType.SelfOnly)
                {
                    ctv = ((this._pubSearchMouseDownTime > this._prvSearchMouseDownTime) ? this.tvPubSearch : this.tvPrvSearch);
                }
                else
                {
                    ctv = this.tvPrvSearch;
                }
            }
            else
            {
                ctv = this.tvPubSearch;
            }
            return(ctv);
        }
Exemplo n.º 15
0
 private void OnMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
 {
     if ((DateTime.Now - this._doubleClickTime).TotalMilliseconds > 500.0)
     {
         this._isDoubleClick   = false;
         this._doubleClickTime = DateTime.Now;
         TreeView    tv  = sender as TreeView;
         CtlTreeView ctv = tv.xFindAncestor <CtlTreeView>();
         bool        isCatalog;
         if (ctv.IsPointInsideItem(false, out isCatalog))
         {
             if (!isCatalog)
             {
                 DelayCaller.CallAfterDelayInUIThread(() =>
                 {
                     var shortcut = ctv.ReadNodeFromSelectedItem() as ShortcutEntity;
                     this.SetOrSendShortcut(shortcut, false);
                 }, 80);
             }
         }
     }
 }
Exemplo n.º 16
0
        private TreeNode ReadSelectedNode()
        {
            CtlTreeView showingTreeview = this.GetShowingTreeview(null);

            return((showingTreeview != null) ? showingTreeview.ReadNodeFromSelectedItem() : null);
        }
Exemplo n.º 17
0
 private bool CanEdit(CtlTreeView ctv)
 {
     return(this.IsInsidePrvTabItem(ctv) || QnHelper.Auth.CanEditShortCut(this._seller, "编辑话术"));;
 }