122 lines
3.7 KiB
C#
122 lines
3.7 KiB
C#
using System;
|
|
using System.Linq;
|
|
using System.Windows;
|
|
using DataFileAnalyzer.Properties;
|
|
using UAF.Application;
|
|
using UAF.Application.Modules;
|
|
using System.Xml.Linq;
|
|
using System.IO;
|
|
using System.ComponentModel.Composition;
|
|
using UAF.Interfaces.Composition.Units;
|
|
|
|
namespace DataFileAnalyzer
|
|
{
|
|
/// <summary>
|
|
/// MainWindow of the DataFileAnalyzer.
|
|
/// Displays the DataFileAnalyzerView
|
|
/// </summary>
|
|
public partial class DataFileAnalyzerWindow : MainframeWindow
|
|
{
|
|
private DataFileAnalyzerModel m_model = null;
|
|
|
|
public DataFileAnalyzerWindow()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
protected override MainframeBase GetMainframe()
|
|
{
|
|
return DataFileAnalyzerFrame;
|
|
}
|
|
|
|
protected override void InitializeWindowComponent()
|
|
{
|
|
InitializeComponent();
|
|
|
|
m_workspace.Behavior.BehaviorOnApplicationMinimize = BehaviorOnMinimize.ToTrayBar;
|
|
m_workspace.TaskBar.IconSourceUri = new Uri("pack://application:,,,/Icons/App.ico");
|
|
SetIconTemplate("Icon_Page_Search");
|
|
}
|
|
|
|
protected override void InitializeWorkspace()
|
|
{
|
|
base.InitializeWorkspace();
|
|
|
|
m_workspace.ApplicationName = "Data Files Analyzer";
|
|
m_workspace.ShowMenu = false;
|
|
m_workspace.UseTaskBar = true;
|
|
|
|
m_workspace.WorkspaceLayout.AutoLayoutLoadAtInit = true;
|
|
m_workspace.WorkspaceLayout.AutoLayoutSaveAtExit = true;
|
|
|
|
m_workspace.UseInputManager = true;
|
|
|
|
m_basicModel.ShowHelp = true;
|
|
}
|
|
|
|
protected override void AfterInitializeWindowComponent()
|
|
{
|
|
base.AfterInitializeWindowComponent();
|
|
|
|
m_model = new DataFileAnalyzerModel();
|
|
m_model.ReadCommandLine(Workspace.This.CommandLineInterpreter);
|
|
Workspace.This.AddModel(m_model);
|
|
|
|
if (!Workspace.This.Documents.Any())
|
|
Application.Current.Shutdown(-1);
|
|
}
|
|
|
|
protected void OnLoaded(object sender, RoutedEventArgs e)
|
|
{
|
|
if (m_model != null)
|
|
{
|
|
if (!UAF.WindowsUtils.CurrentUserIsAdmin())
|
|
{
|
|
System.Windows.MessageBox.Show("You're not running this program as administrator. It will be really slow!", "Warning!");
|
|
}
|
|
|
|
m_model.StartScaning();
|
|
}
|
|
}
|
|
|
|
protected void OnClosed(object sender, EventArgs e)
|
|
{
|
|
if (m_model != null)
|
|
{
|
|
m_model.Close();
|
|
}
|
|
}
|
|
}
|
|
|
|
[Export(typeof(IWorkspaceModule))]
|
|
public class DataFileAnalyzerLayoutModule : LayoutModule
|
|
{
|
|
private DataFileAnalyzerModel Model { get; set; }
|
|
|
|
public DataFileAnalyzerLayoutModule()
|
|
{
|
|
Model = Workspace.This.FirstDocument as DataFileAnalyzerModel;
|
|
Workspace.This.ActiveDocumentChanged += OnActiveDocumentChanged;
|
|
}
|
|
|
|
private void OnActiveDocumentChanged(object sender, UAF.Application.Events.ActiveDocumentChangedEventArgs e)
|
|
{
|
|
Model = e.NewActiveDocument as DataFileAnalyzerModel;
|
|
}
|
|
|
|
public override bool OnLayoutLoadingApplicationSettings(XElement _applicationSettingsRoot)
|
|
{
|
|
if (!base.OnLayoutLoadingApplicationSettings(_applicationSettingsRoot))
|
|
return false;
|
|
|
|
Model.OnLoadApplicationSettings(_applicationSettingsRoot);
|
|
return true;
|
|
}
|
|
|
|
public override void OnLayoutSavingApplicationSettings(XElement _applicationSettingsRoot)
|
|
{
|
|
base.OnLayoutSavingApplicationSettings(_applicationSettingsRoot);
|
|
Model.OnSaveApplicationSettings(_applicationSettingsRoot);
|
|
}
|
|
}
|
|
}
|