Skip to content

Commit

Permalink
Add more open file options.
Browse files Browse the repository at this point in the history
  • Loading branch information
cfrpg committed May 18, 2021
1 parent f24bccc commit 0b3974d
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 18 deletions.
5 changes: 3 additions & 2 deletions src/SharpBladeFlightAnalyzer/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ namespace SharpBladeFlightAnalyzer
/// App.xaml 的交互逻辑
/// </summary>
public partial class App : Application
{
}
{

}
}
2 changes: 1 addition & 1 deletion src/SharpBladeFlightAnalyzer/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
xmlns:local="clr-namespace:SharpBladeFlightAnalyzer"
xmlns:d3="clr-namespace:InteractiveDataDisplay.WPF;assembly=InteractiveDataDisplay.WPF"
mc:Ignorable="d"
Title="SharpBladeFlightAnalyzer - cfrpg" Height="700" Width="1000" MinHeight="700" MinWidth="1000" Closing="Window_Closing">
Title="SharpBladeFlightAnalyzer - cfrpg" Height="700" Width="1000" MinHeight="700" MinWidth="1000" Closing="Window_Closing" Drop="Window_Drop" AllowDrop="True">
<Window.Resources>
<Style x:Key="FocusVisual">
<Setter Property="Control.Template">
Expand Down
50 changes: 35 additions & 15 deletions src/SharpBladeFlightAnalyzer/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ public MainWindow()
}
sr.Close();
}
string[] args = Environment.GetCommandLineArgs();
if(args.Length>1)
{
loadFile(args[1]);
}

//ULogFile f = new ULogFile();
//f.Load("D:\\temp\\log.ulg");
Expand Down Expand Up @@ -172,21 +177,7 @@ private void Button_Click(object sender, RoutedEventArgs e)
System.Windows.Forms.OpenFileDialog ofd = new System.Windows.Forms.OpenFileDialog();
if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
string path = ofd.FileName;
ULogFile f = new ULogFile();
if (f.Load(path,fieldConfigs))
{
LogPageControl lpc = new LogPageControl(f, this);
lpc.addFieldBtn.Click += AddFieldBtn_Click;
TabPage page = new TabPage();
page.Header = f.File.Name;

page.Content = lpc;
page.DisposableContent = f;
mainTabControl.Items.Insert(mainTabControl.Items.Count - 1, page);
mainTabControl.SelectedIndex = mainTabControl.Items.Count - 2;
currentPage = lpc;
}
loadFile(ofd.FileName);
}
}

Expand All @@ -209,5 +200,34 @@ private void ShowMessageBox(string str)
{
MessageBox.Show(str, "SharpBladeFlightAnalyzer");
}

private void Window_Drop(object sender, DragEventArgs e)
{
if(e.Data.GetDataPresent(DataFormats.FileDrop))
{
string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);

loadFile(files[0]);

}
}

private void loadFile(string path)
{
ULogFile f = new ULogFile();
if (f.Load(path, fieldConfigs))
{
LogPageControl lpc = new LogPageControl(f, this);
lpc.addFieldBtn.Click += AddFieldBtn_Click;
TabPage page = new TabPage();
page.Header = f.File.Name;

page.Content = lpc;
page.DisposableContent = f;
mainTabControl.Items.Insert(mainTabControl.Items.Count - 1, page);
mainTabControl.SelectedIndex = mainTabControl.Items.Count - 2;
currentPage = lpc;
}
}
}
}

0 comments on commit 0b3974d

Please sign in to comment.