Example #1
0
        private void Move_Click(object sender, RoutedEventArgs e)
        {
            TreeViewItem parentWorldItem = (TreeViewItem)((TreeViewItem)WorldTree.SelectedItem).Parent;
            TreeViewItem parentLevelItem = (TreeViewItem)((TreeViewItem)WorldTree.SelectedItem).Parent;

            LevelInfo levelInfo       = (LevelInfo)((TreeViewItem)WorldTree.SelectedItem).DataContext;
            IInfo     parentInfo      = (IInfo)parentLevelItem.DataContext;
            LevelInfo parentLevelInfo = parentLevelItem.DataContext is LevelInfo ? (LevelInfo)parentLevelItem.DataContext : null;

            while (parentWorldItem.Parent is TreeViewItem)
            {
                parentWorldItem = (TreeViewItem)parentWorldItem.Parent;
            }

            WorldInfo hostWorldInfo = (WorldInfo)parentWorldItem.DataContext;

            MoveLevelResult result = MoveLevelWindow.Show(_levelService, _worldService, hostWorldInfo, parentLevelInfo);

            if (result != null)
            {
                parentInfo.SublevelsInfo.Remove(levelInfo);
                if (result.InfoNode.SublevelsInfo == null)
                {
                    result.InfoNode.SublevelsInfo = new List <LevelInfo>();
                }

                result.InfoNode.SublevelsInfo.Add(levelInfo);

                BuildTree();
                LevelTreeUpdated();
                SetSelectedItem(levelInfo);
            }
        }
Example #2
0
        public static MoveLevelResult Show(LevelService levelService, WorldService worldService, WorldInfo hostWorld, LevelInfo parentLevel)
        {
            MoveLevelResult moveLevelResult = null;

            MoveLevelWindow window = new MoveLevelWindow(levelService, worldService, hostWorld, parentLevel);

            window.WindowStartupLocation = WindowStartupLocation.CenterOwner;
            window.ShowDialog();


            if (window.DialogResult == true)
            {
                moveLevelResult = new MoveLevelResult();
                if (window.ParentLevel != null)
                {
                    moveLevelResult.InfoNode = window.ParentLevel;
                }
                else
                {
                    moveLevelResult.InfoNode = window.HostWorld;
                }

                return(moveLevelResult);
            }

            return(moveLevelResult);
        }