private void dragShortCut_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) { isDrag = false; dragShortCut.ReleaseMouseCapture(); dragShortCut.Visibility = System.Windows.Visibility.Collapsed; Debug.WriteLine("dragShortCut_MouseLeftButtonUp__false"); if (isDelete) { isDelete = false; #region 检测删除面板 var startMenuS = from element in VisualTreeHelper.FindElementsInHostCoordinates(e.GetPosition(null), gridBottom) where element is SMT.SAAS.Platform.Xamls.MainPagePart.Start select element; if (startMenuS.Count() >= 1) { SMT.SAAS.Platform.Xamls.MainPagePart.Start start = startMenuS.FirstOrDefault() as SMT.SAAS.Platform.Xamls.MainPagePart.Start; if (start != null) { ViewModel.MainPage.ShortCutViewModel shortcutVM = (dragShortCut.DataContext as ViewModel.MainPage.ShortCutViewModel); shortCutManager.RemoveItem(shortcutVM.ShortCutID); } } #endregion } else { #region 检测添加面板 var ShortCutManagers = from element in VisualTreeHelper.FindElementsInHostCoordinates(e.GetPosition(null), grdShortCut) where element is SMT.SAAS.Platform.Xamls.MainPagePart.ShortCutManager select element; if (ShortCutManagers.Count() >= 1) { SMT.SAAS.Platform.Xamls.MainPagePart.ShortCutManager customMenus = ShortCutManagers.FirstOrDefault() as SMT.SAAS.Platform.Xamls.MainPagePart.ShortCutManager; if (customMenus != null) { ViewModel.Menu.MenuViewModel menuvm = (dragShortCut.DataContext as ViewModel.Menu.MenuViewModel); ViewModel.MainPage.ShortCutViewModel vm = new ViewModel.MainPage.ShortCutViewModel() { AssemplyName = menuvm.Content.ModuleType == null ? "NULL" : menuvm.Content.ModuleType, FullName = menuvm.Content.ModuleType == null ? "NULL" : menuvm.Content.ModuleType, Titel = menuvm.MenuName, IconPath = menuvm.MenuIconPath, ModuleID = menuvm.MenuID, ShortCutID = menuvm.MenuID, IsSysNeed = "0", ModuleName = menuvm.Content.ModuleName, UserState = "1" }; customMenus.AddItem(vm); } } #endregion } }
private void dragShortCut_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) { isDrag = false; dragShortCut.ReleaseMouseCapture(); dragShortCut.Visibility = System.Windows.Visibility.Collapsed; Debug.WriteLine("dragShortCut_MouseLeftButtonUp__false"); if (isDelete) { isDelete = false; #region 检测删除面板 var startMenuS = from element in VisualTreeHelper.FindElementsInHostCoordinates(e.GetPosition(null), gridBottom) where element is SMT.SAAS.Platform.Xamls.MainPagePart.Start select element; if (startMenuS.Count() >= 1) { SMT.SAAS.Platform.Xamls.MainPagePart.Start start = startMenuS.FirstOrDefault() as SMT.SAAS.Platform.Xamls.MainPagePart.Start; if (start != null) { ViewModel.MainPage.ShortCutViewModel shortcutVM = (dragShortCut.DataContext as ViewModel.MainPage.ShortCutViewModel); shortCutManager.RemoveItem(shortcutVM.ShortCutID); } } #endregion } else { #region 检测添加面板 var ShortCutManagers = from element in VisualTreeHelper.FindElementsInHostCoordinates(e.GetPosition(null), grdShortCut) where element is SMT.SAAS.Platform.Xamls.MainPagePart.ShortCutManager select element; if (ShortCutManagers.Count() >= 1) { SMT.SAAS.Platform.Xamls.MainPagePart.ShortCutManager customMenus = ShortCutManagers.FirstOrDefault() as SMT.SAAS.Platform.Xamls.MainPagePart.ShortCutManager; if (customMenus != null) { ViewModel.Menu.MenuViewModel menuvm = (dragShortCut.DataContext as ViewModel.Menu.MenuViewModel); ViewModel.MainPage.ShortCutViewModel vm = new ViewModel.MainPage.ShortCutViewModel() { AssemplyName = menuvm.Content.ModuleType == null ? "NULL" : menuvm.Content.ModuleType, FullName = menuvm.Content.ModuleType == null ? "NULL" : menuvm.Content.ModuleType, Titel = menuvm.MenuName, IconPath = menuvm.MenuIconPath, ModuleID = menuvm.MenuID, ShortCutID = menuvm.MenuID, IsSysNeed = "0", ModuleName = menuvm.Content.ModuleName, UserState = "1" }; customMenus.AddItem(vm); } } #endregion } }