private static void ShowContextDetails() { var hitTestResult = Api.Client.UI.GetVisualInPointedPosition(); if (hitTestResult == null) { return; } if (VisualTreeHelperExtension.FindParentOfType( hitTestResult, typeof(ItemSlotControl)) is ItemSlotControl itemSlotControl) { if (itemSlotControl.Item != null) { WindowCNEIdetails.Open( EntityViewModelsManager.GetEntityViewModel(itemSlotControl.Item.ProtoItem)); } return; } if (VisualTreeHelperExtension.FindParentOfType( hitTestResult, typeof(RequiredItemControl)) is RequiredItemControl requiredItemControl) { if (requiredItemControl.ProtoItemWithCount != null) { WindowCNEIdetails.Open( EntityViewModelsManager.GetEntityViewModel(requiredItemControl.ProtoItemWithCount.ProtoItem)); } return; } if (VisualTreeHelperExtension.FindParentOfType( hitTestResult, typeof(EntitySlotControl)) is EntitySlotControl entitySlotControl) { if (entitySlotControl.DataContext is ProtoEntityViewModel entityViewModel) { WindowCNEIdetails.Open(entityViewModel); } else { Api.Logger.Error("CNEI: Wrong view model for details window " + entitySlotControl.DataContext); } } }
private static void ResetHandler() { WindowCNEIdetails.Close(); CreativePanelManager.Reset(); hudButton?.Dispose(); hudButton = null; if (hudLayoutControl != null) { hudLayoutControl.Loaded -= LayoutControl_Loaded; hudLayoutControl = null; } gameplayInputContext?.Stop(); gameplayInputContext = null; }