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); }
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; } }
private TabItemTag FindRootTabItemTag(CtlTreeView ctv) { TabItemTag tag = null; if (ctv != null) { tag = (ctv.xFindAncestor <TabItem>().Tag as TabItemTag); } return(tag); }
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); }
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; }
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; }
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); } }
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); }
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); }
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; }
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); } }); }
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); } } } } }
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, "节点为空"); } } }
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); }
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); } } } }
private TreeNode ReadSelectedNode() { CtlTreeView showingTreeview = this.GetShowingTreeview(null); return((showingTreeview != null) ? showingTreeview.ReadNodeFromSelectedItem() : null); }
private bool CanEdit(CtlTreeView ctv) { return(this.IsInsidePrvTabItem(ctv) || QnHelper.Auth.CanEditShortCut(this._seller, "编辑话术"));; }