private void treeViewMaterials_Selected(object sender, RoutedEventArgs e) { const string iconsMaterialDirectory = @"Icons\IconsMaterialCategory"; if (selectedItemType == LastSelectedItemType.CategoryMaterial || selectedItemType == LastSelectedItemType.Material) { lastSelectedTreeViewItem = selectedTreeViewItem; lastSelectedItemType = selectedItemType; } selectedTreeViewItem = e.OriginalSource as TreeViewItem; if (selectedTreeViewItem.Tag is Category <Material> ) { selectedItemType = LastSelectedItemType.CategoryMaterial; Category <Material> currentCategory = selectedTreeViewItem.Tag as Category <Material>; AddMaterialCategory addCategory = new AddMaterialCategory(currentCategory.Name, currentCategory, true, false, System.IO.Path.GetFullPath(System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"..\..\", iconsMaterialDirectory))); Grid grid = new Grid(); grid.Children.Add(addCategory); groupBoxPreviewMaterial.Content = grid; } else { if (selectedTreeViewItem.Tag is Material) { selectedItemType = LastSelectedItemType.Material; Material material = selectedTreeViewItem.Tag as Material; ImportMaterial importMaterial = new ImportMaterial("Material", material, true, false, false); importMaterial.StatusUpdated += importMaterial_StatusUpdated; Grid grid = new Grid(); grid.Children.Add(importMaterial); groupBoxPreviewMaterial.Content = grid; } } }
private void treeViewCategories_Selected(object sender, RoutedEventArgs e) { const string iconsCategoryDirectory = @"Icons\IconsCategory"; lastSelectedTreeViewItem = selectedTreeViewItem; lastSelectedItemType = selectedItemType; selectedTreeViewItem = e.OriginalSource as TreeViewItem; if (selectedTreeViewItem.Tag is Category <FurnitureObject> ) { selectedItemType = LastSelectedItemType.Category; Category <FurnitureObject> currentCategory = selectedTreeViewItem.Tag as Category <FurnitureObject>; AddCategory addCategory = new AddCategory(currentCategory.Name, currentCategory, true, false, System.IO.Path.GetFullPath(System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"..\..\", iconsCategoryDirectory))); Grid grid = new Grid(); grid.Children.Add(addCategory); groupBoxRightSide.Content = grid; } else { if (selectedTreeViewItem.Tag is FurnitureObject) { selectedItemType = LastSelectedItemType.FurnitureObject; FurnitureObject currentObject = selectedTreeViewItem.Tag as FurnitureObject; double tradeAllowance = ((selectedTreeViewItem.Parent as TreeViewItem).Tag as Category <FurnitureObject>).TradeAllowance; ImportObject importObject = new ImportObject("Object", currentObject, configuration.Materials, true, false, tradeAllowance); importObject.StatusUpdated += importObject_StatusUpdated; Grid grid = new Grid(); grid.Children.Add(importObject); groupBoxRightSide.Content = grid; } } }