예제 #1
0
 public MainWindow()
 {
     InitializeComponent();
     DataContext = new VMViewModel();
 }
예제 #2
0
        static void Main(string[] args)
        {
            VMViewModel viewModel = new VMViewModel();

            viewModel.OpenButton.Execute(null);

            Stack <TreeViewItem> stack   = new Stack <TreeViewItem>();
            TreeViewItem         current = viewModel.HierarchicalAreas[0];

            current.IsExpanded = true;

            string command;
            string errorMessage = null;
            bool   showHelp     = true;

            while (true)
            {
                SetUpConsole(current.Name, stack.Count, showHelp, errorMessage);
                errorMessage = null;
                foreach (TreeViewItem item in current.Children)
                {
                    Console.WriteLine("\t" + item);
                }
                Console.Write("\n:: TYPE COMMAND ::\n:> ");

                command = Console.ReadLine();

                switch (command)
                {
                case "back":
                    if (stack.Count == 0)
                    {
                        errorMessage = "You are on root!";
                    }
                    else
                    {
                        current = stack.Pop();
                    }
                    break;

                case "exit":
                    return;

                case "help":
                    showHelp = !showHelp;
                    break;

                case "load":
                    viewModel.OpenButton.Execute(null);
                    break;

                case "save":
                    viewModel.SaveButton.Execute(null);
                    break;

                default:
                    stack.Push(current);
                    try
                    {
                        current = current.Children.First(i => i.Name.Equals(command));
                    }
                    catch (InvalidOperationException)
                    { errorMessage = "There is no such type!"; }
                    break;
                }

                current.IsExpanded = true;
            }
        }