Click or drag to resize

Tray Constructor (EngineWindows, DictionaryString, String)

IT Hit User File System
Initializes a new instance of the Tray class.

Namespace:  ITHit.FileSystem.Windows.WinUI
Assembly:  ITHit.FileSystem.Windows.WinUI (in ITHit.FileSystem.Windows.WinUI.dll) Version: 9.0.29481.0-Beta
Syntax
public Tray(
	EngineWindows engine,
	Dictionary<string, string> compareSettings
)

Parameters

engine
Type: ITHit.FileSystem.WindowsEngineWindows
to assign to the window.
compareSettings
Type: System.Collections.GenericDictionaryString, String
Compare setting dictionary of the engine.
Examples

The code below is part of 'WebDAVDrive' C# sample provided with the SDK.

C#
// Create Tray window.
Tray trayWindow = new Tray(engine);                  

//Set header text, mount, unmount, start/stop sync handlers here - as Tray does not access to sample related things
trayWindow.DriveNameText = engine.RemoteStorageRootPath;
trayWindow.NotifyIconText = $"{ServiceProvider.GetService<AppSettings>().ProductName}\n{engine.RemoteStorageRootPath}";
trayWindow.Header = ServiceProvider.GetService<AppSettings>().ProductName;
trayWindow.ShowSettingsMenu.Click += (sender, e) => ShowSettingsMenuClick(engine);
trayWindow.MountNewDriveMenu.Click += TrayMountNewDriveClick;
trayWindow.UnmountMenu.Click += (sender, e) => TrayUnmountClick(engine, engineKey);
trayWindow.ShowFeedbackMenu.Click += async (sender, e) => await Commands.OpenSupportPortalAsync();
trayWindow.OpenFolderButton.Click += (sender, e) => engine.Commands.TryOpen(engine.Path);
trayWindow.ViewOnlineButton.Click += (sender, e) => ViewOnlineClicked(engine);
trayWindow.ViewItemOnlineClick += (viewModel) => ViewItemOnlineClick(viewModel, engine);
trayWindow.ErrorDescriptionClick += (viewModel) => ErrorDescriptionClick(viewModel, engine, LogFormatter);
trayWindow.ResolveConflictClick += (viewModel) => ResolveConflictClick(viewModel, engine);

#if DEBUG
MenuFlyoutItem hideShowConsole = new MenuFlyoutItem { Text = resourceLoader.GetString("HideLog") };
hideShowConsole.Click += (_, _) => HideShowConsoleClicked(hideShowConsole);
trayWindow.DebugMenu.Items.Add(hideShowConsole);
#endif
MenuFlyoutItem enableDisableDebugLoggingMenu = new MenuFlyoutItem
{
    Text = LogFormatter.DebugLoggingEnabled ? resourceLoader.GetString("DisableDebugLogging")
    : resourceLoader.GetString("EnableDebugLogging")
};
enableDisableDebugLoggingMenu.Click += (sender, e) => EnableDisableDebugLoggingClicked(enableDisableDebugLoggingMenu);
MenuFlyoutItem openLogFile = new MenuFlyoutItem { Text = resourceLoader.GetString("OpenLogFile/Text") };
openLogFile.Click += (_, _) => Commands.TryOpen(LogFormatter.LogFilePath);

trayWindow.DebugMenu.Items.Add(enableDisableDebugLoggingMenu);
trayWindow.DebugMenu.Items.Add(openLogFile);

The code below is part of 'WebDAVDrive' C# sample provided with the SDK.

C#
private void ViewItemOnlineClick(FileEventViewModel fileEvent, VirtualEngine engine)
{
    string url = engine.Mapping.MapPath(fileEvent.Path);
    Commands.Open(url);
}

private void ErrorDescriptionClick(FileEventViewModel fileEvent, VirtualEngine engine, LogFormatter logFormatter)
{
    new ErrorDetails(fileEvent, engine, logFormatter).Show();
}

private void ResolveConflictClick(FileEventViewModel fileEvent, VirtualEngine engine)
{
    ServiceProvider.DispatcherQueue.TryEnqueue(() => new Compare(fileEvent.Path, engine).Show());
}

private async void TrayUnmountClick(VirtualEngine engine, Guid engineKey)
{
    await engine.Commands.StopEngineAsync();
    await UnMountAsync(engineKey, engine.RemoteStorageRootPath);
}

private void TrayMountNewDriveClick(object sender, Microsoft.UI.Xaml.RoutedEventArgs e)
{
    new MountNewDrive().Show();
}

private void EnableDisableDebugLoggingClicked(MenuFlyoutItem menuItem)
{
    LogFormatter.DebugLoggingEnabled = !LogFormatter.DebugLoggingEnabled;
    ResourceLoader resourceLoader = ResourceLoader.GetForViewIndependentUse();
    menuItem.Text = resourceLoader.GetString(LogFormatter.DebugLoggingEnabled ? "DisableDebugLogging" : "EnableDebugLogging");
}

private void HideShowConsoleClicked(MenuFlyoutItem menuItem)
{
    WindowManager.SetConsoleWindowVisibility(!WindowManager.ConsoleVisible);
    ResourceLoader resourceLoader = ResourceLoader.GetForViewIndependentUse();
    menuItem.Text = WindowManager.ConsoleVisible ? resourceLoader.GetString("HideLog") : resourceLoader.GetString("ShowLog");
}

private void ViewOnlineClicked(VirtualEngine engine)
{
    Commands.Open(engine.RemoteStorageRootPath);
}
See Also