Skip to content

Commit

Permalink
Merge pull request #32 from nkasco/feature-UITweaks
Browse files Browse the repository at this point in the history
Feature UI tweaks
  • Loading branch information
nkasco authored Jan 16, 2023
2 parents 2818386 + 02cacf7 commit a3aa39f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
6 changes: 5 additions & 1 deletion MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,11 @@
<SymbolIcon Name="PingSymbol" Visibility="Collapsed" Symbol="Target" />
<!--<ComboBox IsEditable="True" Width="200" PlaceholderText="Machine" HorizontalAlignment="Right" Margin="5" Name="MachineComboBox" SelectionChanged="MachineComboBox_SelectionChanged" />-->
<TextBox Name="MachineComboBox" Margin="5" PlaceholderText="Machine" HorizontalAlignment="Right" Width="200" TextChanged="MachineComboBox_TextChangedAsync" IsSpellCheckEnabled="False" />
<TeachingTip x:Name="MachineInputTeachingTip" Title="Important" Subtitle="The selected script requires machine input, please provide a target then try again.">
<TeachingTip.IconSource>
<SymbolIconSource Symbol="Download" />
</TeachingTip.IconSource>
</TeachingTip>
<TextBox Name="MultipleMachineInput" Width="200" Height="175" HorizontalAlignment="Right" Margin="5" Visibility="Collapsed" PlaceholderText="Machines (1 per line)" IsSpellCheckEnabled="False" TextWrapping="Wrap" AcceptsReturn="True" ScrollViewer.VerticalScrollBarVisibility="Auto" ScrollViewer.VerticalScrollMode="Auto" TextChanged="MultipleMachineInput_TextChanged" />
<StackPanel Orientation="Horizontal" VerticalAlignment="Top">
<StackPanel>
Expand All @@ -142,7 +147,6 @@

</StackPanel>
</StackPanel>
<!-- TODO: Fix scrollbar issue to prevent slight cutting off of content -->
<ScrollViewer Grid.Row="1" x:Name="ContentFrameScrollViewer" ScrollViewer.VerticalScrollBarVisibility="Auto" ScrollViewer.VerticalScrollMode="Auto" ZoomMode="Enabled" >
<Frame x:Name="contentFrame" ScrollViewer.VerticalScrollBarVisibility="Auto" ScrollViewer.VerticalScrollMode="Auto" Grid.Row="1" />
</ScrollViewer>
Expand Down
19 changes: 14 additions & 5 deletions MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ public partial class MainWindow : Window

private static string SingleOrMulti = "Single";

public Collection <Page> Pages = new Collection <Page> ();

private static void LaunchScript(object sender, EventArgs e, string scriptPath, string args, string type, string inputType, string wait, string elevate, string hide)
{
string EXEPath;
Expand Down Expand Up @@ -231,6 +233,7 @@ public static void LaunchExplorer(string path)
public static Page GenerateCategoryPageFromXML(string name)
{
Page page = new Page();
page.Name = name;
//ResourceDictionary myResourceDictionary = new ResourceDictionary();
//myResourceDictionary.Source = new Uri("ResourceDictionary.xaml", UriKind.RelativeOrAbsolute);
////page.Resources.MergedDictionaries.Add(myResourceDictionary);
Expand Down Expand Up @@ -550,7 +553,7 @@ public void EnsureWindowsSystemDispatcherQueueController()
}
}

private void Window_Activated(object sender, WindowActivatedEventArgs args)
private void Window_Activated(object sender, Microsoft.UI.Xaml.WindowActivatedEventArgs args)
{
m_configurationSource.IsInputActive = args.WindowActivationState != WindowActivationState.Deactivated;
}
Expand Down Expand Up @@ -623,10 +626,12 @@ public MainWindow()
guiConfig = XDocument.Load(@"XML\Scripts.xml");
foreach (XElement item in from y in categoryConfig.Descendants("Item") select y)
{
Pages.Add(GenerateCategoryPageFromXML(item.Attribute("category").Value)); //Add the page to a collection for later use
MainNav.MenuItems.Add(GenerateCategoryNavigationViewItemFromXML(item.Attribute("category").Value, item.Attribute("icon").Value, item.Attribute("foreground").Value));
}

//Select the first navigation item
//TODO: This will need to be adjusted once Dashboard and All Scripts are available, should this be a setting?
MainNav.SelectedItem = MainNav.MenuItems[1]; //Index 1 because 0 is the "Categories" text header

//We've got to check for updates in the main window due to a WinUI limitation that currently exists
Expand Down Expand Up @@ -662,7 +667,7 @@ private async void CheckForUpdates()
LoadingText.Text = "Downloading update...";
string scriptName = "Updater.ps1";
string scriptPath = Environment.CurrentDirectory + "\\" + scriptName;
LaunchScript(scriptPath, " -InstallPath \"" + Environment.CurrentDirectory + "\" -DownloadURL \"" + updateXMLData.Attribute("link").Value + "\"", "PS5", "None", "false", "true", "true"); //TODO: Should this be moved to run with the integrated host? Probably can't until elevation support is added to Windows App SDK with v1.1
LaunchScript(scriptPath, " -InstallPath \"" + Environment.CurrentDirectory + "\" -DownloadURL \"" + updateXMLData.Attribute("link").Value + "\"", "PS5", "None", "false", "true", "true");
await Task.Run(() => Task.Delay(1000000)); //TODO: This needs fixed, for some reason WaitForExit() isn't working
//TODO: Run LoadingPhrase() on a loop
}
Expand Down Expand Up @@ -727,7 +732,6 @@ private void MainNav_SelectionChanged(NavigationView sender, NavigationViewSelec
Type _page = null;
_page = typeof(Settings);
contentFrame.Navigate(_page);
//TODO: Should we hide the machine input, terminal, and machine info pane here? If so ensure we show it once we navigate away below
ContentSplitView.IsPaneOpen = false;
MachineDetailsToggleButton.IsChecked = false;
MachineInputs.Visibility = Visibility.Collapsed;
Expand All @@ -748,9 +752,14 @@ private void MainNav_SelectionChanged(NavigationView sender, NavigationViewSelec
}
else
{
Page _page = GenerateCategoryPageFromXML(args.SelectedItemContainer.Content.ToString());
//Page _page = GenerateCategoryPageFromXML(args.SelectedItemContainer.Content.ToString());
string PageName = args.SelectedItemContainer.Content.ToString();
var _page = from Page in Pages
where Page.Name == PageName
select Page;

//MainNav.Header = args.SelectedItemContainer.Content.ToString();
contentFrame.Content = _page; //TODO: This probably doesn't need to generate each time you click
contentFrame.Content = _page.FirstOrDefault();
MachineInputs.Visibility = Visibility.Visible;
}
}
Expand Down

0 comments on commit a3aa39f

Please sign in to comment.