-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathRevitSectionsConstructorCommand.cs
More file actions
80 lines (64 loc) · 2.61 KB
/
Copy pathRevitSectionsConstructorCommand.cs
File metadata and controls
80 lines (64 loc) · 2.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
using System;
using System.Globalization;
using System.Reflection;
using Autodesk.Revit.Attributes;
using Autodesk.Revit.UI;
using dosymep.Bim4Everyone;
using dosymep.Bim4Everyone.SimpleServices;
using dosymep.SimpleServices;
using dosymep.WpfCore.Ninject;
using dosymep.WpfUI.Core.Ninject;
using dosymep.Xpf.Core.Ninject;
using Ninject;
using RevitSectionsConstructor.Models;
using RevitSectionsConstructor.Services;
using RevitSectionsConstructor.ViewModels;
using RevitSectionsConstructor.Views;
namespace RevitSectionsConstructor;
[Transaction(TransactionMode.Manual)]
public class RevitSectionsConstructorCommand : BasePluginCommand {
public RevitSectionsConstructorCommand() {
PluginName = "Конструктор секций";
}
protected override void Execute(UIApplication uiApplication) {
using var kernel = uiApplication.CreatePlatformServices();
kernel.Bind<RevitRepository>()
.ToSelf()
.InSingletonScope();
kernel.Bind<GroupsHandler>()
.ToSelf()
.InSingletonScope();
kernel.Bind<DocumentSaver>()
.ToSelf()
.InSingletonScope();
kernel.BindMainWindow<MainViewModel, MainWindow>();
kernel.UseWpfUIMessageBox<MainViewModel>();
kernel.UseWpfUIThemeUpdater();
string assemblyName = Assembly.GetExecutingAssembly().GetName().Name;
kernel.UseWpfLocalization(
$"/{assemblyName};component/assets/Localization/Language.xaml",
CultureInfo.GetCultureInfo("ru-RU"));
var localization = kernel.Get<ILocalizationService>();
kernel.UseXtraSaveFileDialog<MainViewModel>(
title: localization.GetLocalizedString("SaveFileDialog.Title"),
addExtension: true,
filter: "Revit projects |*.rvt",
defaultExt: "rvt");
CheckViews(kernel.Get<RevitRepository>(), kernel.Get<IMessageBoxService>(), localization);
Notification(kernel.Get<MainWindow>());
}
private void CheckViews(
RevitRepository revitRepository,
IMessageBoxService messageBoxService,
ILocalizationService localization) {
if(!revitRepository.ActiveDocOnEmptySheet()) {
var result = messageBoxService.Show(localization.GetLocalizedString("ViewsWarning"),
localization.GetLocalizedString("MainWindow.Title"),
System.Windows.MessageBoxButton.YesNo,
System.Windows.MessageBoxImage.Warning);
if(result != System.Windows.MessageBoxResult.Yes) {
throw new OperationCanceledException();
}
}
}
}