using JD.Application.View.Misc; using JD.Application.View.Utilities; using JD.Bloomberg; using JD.Core; using JD.Core.ProjectManaging; using System.Collections.Generic; using JD.Application.View.Actions; using System.IO; using JD.Kernel.StaticHelpers; using JD.Reflection.Attributes; using JD.TeaBoxAddinSystem.Addins.MEF; using JD.TeaBoxAddinSystem.Bootstrap; using TeaBox; using TeaBox.Bootstrap; using TeaBox.Gui; using TeaBox.ObjectModel; using Ubisoft; namespace JD.Application.Program { /// /// Controls the startup and initialization of the editor (updates the UI after it has been created). /// public class ProgramInitializer : IBootstrapCommand { [ImportMany] private List _extensions = null; public void Execute() { if (Runtime.CommandLineMode) { return; } global::TeaBox.ObjectModel.Application.Main.TitleBarButtons.Add(new TitleBarButton { ToolTip = "Give Feedback", Command = new RelayCommand(OpenFeedbackWindowOperation), Icon = @"/JD.Application;component/Resources/Icons_16x16_Feedback.png" }); WorkbenchSingleton.Workbench.Icon = ProgramIdentity.Instance.Icon.ToImageSource(); WorkbenchSingleton.Workbench.Title = ProgramIdentity.Instance.Name; ExecuteExtensions(); foreach (var argument in Runtime.Arguments.AllArguments) { if (FileUtility.IsValidPath(argument.Name) && File.Exists(argument.Name)) { global::TeaBox.ObjectModel.Application.Main.Open.FromFile(argument.Name, DocumentOpeningOptions.Default); } } var checkoutActionHandler = new CheckoutActionHandler(); DefaultSaveActionHandler.Saving += (sender, context) => checkoutActionHandler.Execute(context); UpdateApplicationTitle(); } private void OpenFeedbackWindowOperation() { new FeedbackBox().ShowDialog(); } private void UpdateApplicationTitle() { global::TeaBox.ObjectModel.Application.Main.Title = $"{ProgramIdentity.Instance.Name} - {ProjectManager.Instance.GetCurrentProjectId()} - {DataRoot.Value}"; if (!string.IsNullOrEmpty(JdBloombergLegacy.Instance.GetCurrentVersion())) { global::TeaBox.ObjectModel.Application.Main.Title += $" - Build {JdBloombergLegacy.Instance.GetCurrentVersion()}"; } } private void ExecuteExtensions() { AddinService.Compose(this); foreach (var bootstrapCommand in _extensions) { bootstrapCommand.Execute(); } } } }