Skip to content

Commit

Permalink
Open files in command line arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
ReMinoer committed Jun 5, 2022
1 parent 50af743 commit 1500cba
Showing 1 changed file with 24 additions and 11 deletions.
35 changes: 24 additions & 11 deletions Calame/CalameBootstrapper.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.ComponentModel.Composition.Hosting;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Windows;
using System.Windows.Media.Imaging;
Expand Down Expand Up @@ -32,17 +35,6 @@ protected override void StartRuntime()
mainWindow.Icon = null;
}

protected override void OnStartup(object sender, StartupEventArgs e)
{
base.OnStartup(sender, e);

Window mainWindow = Application.MainWindow;
mainWindow.Top = 0;
mainWindow.Left = 0;
mainWindow.WindowState = WindowState.Maximized;
mainWindow.Icon = _icon;
}

protected override void BindServices(CompositionBatch batch)
{
base.BindServices(batch);
Expand All @@ -64,5 +56,26 @@ protected override void Configure()
}
}
#endif

protected override void OnStartup(object sender, StartupEventArgs e)
{
base.OnStartup(sender, e);

Window mainWindow = Application.MainWindow;
mainWindow.Top = 0;
mainWindow.Left = 0;
mainWindow.WindowState = WindowState.Maximized;
mainWindow.Icon = _icon;

foreach (string commandLineArgument in Environment.GetCommandLineArgs())
{
if (File.Exists(commandLineArgument))
{
var shell = (IShell)GetInstance(typeof(IShell), null);
IEnumerable<IEditorProvider> editorProviders = GetAllInstances(typeof(IEditorProvider)).Cast<IEditorProvider>();
shell.OpenFileAsync(commandLineArgument, editorProviders);
}
}
}
}
}

0 comments on commit 1500cba

Please sign in to comment.