Exemple #1
0
        private void ExecutedRemoveBlueprint(object sender, RoutedEventArgs e)
        {
            // Check if an item is selected.
            BlueprintViewModel selectedItem = this.SelectedItem;

            if (selectedItem == null)
            {
                return;
            }

            // Select other blueprint.
            var node = (TreeViewItem)this.TvTree.ItemContainerGenerator.ContainerFromIndex(0);

            node.IsSelected = true;

            // Delete current selected blueprint.
            try
            {
                ((BlueprintManagerViewModel)this.DataContext).RemoveBlueprint(selectedItem.BlueprintId);
            }
            catch (InvalidOperationException exception)
            {
                EditorDialog.Error("Unable to delete blueprint", exception.Message);
            }
        }
Exemple #2
0
 private void ExecutedCreateNewBlueprint(object sender, ExecutedRoutedEventArgs e)
 {
     try
     {
         BlueprintManagerViewModel viewModel = this.DataContext as BlueprintManagerViewModel;
         if (viewModel != null)
         {
             viewModel.CreateNewBlueprint();
         }
     }
     catch (ArgumentException ex)
     {
         EditorDialog.Error("Unable to add blueprint", ex.Message);
     }
 }
        private void AddAssembly_OnClick(object sender, RoutedEventArgs e)
        {
            // Configure open file dialog box.
            OpenFileDialog dlg = new OpenFileDialog {
                DefaultExt = ".dll", Filter = "Assemblies (.dll)|*.dll"
            };

            // Show open file dialog box.
            bool?result = dlg.ShowDialog();

            // Process open file dialog box results
            if (result != true)
            {
                return;
            }

            // Add assembly to project.
            ProjectSettings projectSettings = (ProjectSettings)this.DataContext;
            Assembly        assembly        = Assembly.LoadFile(dlg.FileName);

            try
            {
                projectSettings.AddAssembly(assembly);

                // Refresh list.
                this.AssembliesList.Items.Refresh();
            }
            catch (ReflectionTypeLoadException ex)
            {
                EditorDialog.Error(
                    "Error adding assembly",
                    string.Format(
                        "An error has occurred adding assembly {0}: {1}", dlg.FileName, ex.LoaderExceptions[0]));

                // TODO(np): Beautifully handle the error and prevent the crash.
                projectSettings.RemoveAssembly(assembly);
            }
        }