Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion AtlasToolbox/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public partial class App : Application
public static Window f_window;
public static XamlRoot XamlRoot { get; set; }
public static string CurrentCategory { get; set; }
public static string SearchHighlightItemKey { get; set; }
private static Dictionary<string, string> StringList = new Dictionary<string, string>();
public static List<IConfigurationItem> RootList = new List<IConfigurationItem>();
private static Mutex _mutex = new(true, "{AtlasToolbox}");
Expand Down Expand Up @@ -252,7 +253,7 @@ public static string GetValueFromItemList(string key, bool desc = false)
string toReturn = "";
if (!desc) toReturn = StringList.Where(item => item.Key == key).Select(item => item.Value).FirstOrDefault();
else toReturn = StringList.Where(item => item.Key == key + "Description").Select(item => item.Value).FirstOrDefault();
if (toReturn == "" && toReturn != null) return "To be translated";
if (toReturn == "" || toReturn == null) return StringList.Where(item => item.Key == "ToBeTranslated").Select(item => item.Value).FirstOrDefault();
else return toReturn;
}
catch
Expand Down
25 changes: 16 additions & 9 deletions AtlasToolbox/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,7 @@ public MainWindow()

public void LoadExperiments()
{
// Search Experiment
if (RegistryHelper.IsMatch("HKLM\\SOFTWARE\\AtlasOS\\Toolbox\\Experiments\\Search", "enabled", 0) || !RegistryHelper.KeyExists("HKLM\\SOFTWARE\\AtlasOS\\Toolbox\\Experiments\\Search"))
{
SearchBox.Visibility = Visibility.Collapsed;
}

}

public bool IsFullscreen()
Expand Down Expand Up @@ -389,6 +385,8 @@ private void AtlasButton_Click(object sender, RoutedEventArgs e)
private void AutoSuggestBox_SuggestionChosen(AutoSuggestBox sender, AutoSuggestBoxSuggestionChosenEventArgs args)
{
var configItem = RootList.Where(item => item.Name == args.SelectedItem.ToString()).FirstOrDefault();
if (configItem is null) return;

string type = configItem.Type.ToString();
if (configItem is not null)
{
Expand Down Expand Up @@ -420,10 +418,13 @@ private void AutoSuggestBox_SuggestionChosen(AutoSuggestBox sender, AutoSuggestB
type = itemViewModelType;
}
}
//folders.Remove(folders.First());
ContentFrame.Navigate(typeof(SubSection), new Tuple<ConfigurationSubMenuViewModel, DataTemplate, object>
(rootItemViewModel, template, new ObservableCollection<Folder>(folders.Reverse())), new SlideNavigationTransitionInfo()
{ Effect = SlideNavigationTransitionEffect.FromRight });
//folders.Remove(folders.First());
// Set the item key to highlight after navigation
App.SearchHighlightItemKey = configItem.Key;

ContentFrame.Navigate(typeof(SubSection), new Tuple<ConfigurationSubMenuViewModel, DataTemplate, object>
(rootItemViewModel, template, new ObservableCollection<Folder>(folders.Reverse())), new SlideNavigationTransitionInfo()
{ Effect = SlideNavigationTransitionEffect.FromRight });
}
catch (Exception ex)
{
Expand All @@ -432,13 +433,19 @@ private void AutoSuggestBox_SuggestionChosen(AutoSuggestBox sender, AutoSuggestB
}
else
{
// Set the item key to highlight after navigation
App.SearchHighlightItemKey = configItem.Key;

NavigationViewControl.SelectedItem = NavigationViewControl.MenuItems
.OfType<NavigationViewItem>()
.First(n => n.Tag.Equals(configItem.Type.ToString()));
App.CurrentCategory = configItem.Type.ToString();
Navigate(typeof(Views.ConfigPage));
}
}

// Clear the search box after selection
sender.Text = string.Empty;
}

private void AutoSuggestBox_TextChanged(AutoSuggestBox sender, AutoSuggestBoxTextChangedEventArgs args)
Expand Down
78 changes: 78 additions & 0 deletions AtlasToolbox/Models/CustomViewsModel/ContextMenuEntry.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
锘縰sing System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtlasToolbox.Models.CustomViewsModel
{
public enum ContextMenuType
{
All, // Main location file entries: HKEY_CLASSES_ROOT\*\shell
Directory, // Folder: HKEY_CLASSES_ROOT\Directory\shell
DirectoryBackground, // Desktop background: HKEY_CLASSES_ROOT\Directory\Background\shell
Drive, // HKEY_CLASSES_ROOT\Drive\shell
Program, // HKEY_CLASSES_ROOT\{program_name}\shell OR HKEY_CLASSES_ROOT\program name\shellex\ContextMenuHandlers
CustomCommandStore, // HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell

}
public class ContextMenuEntry
{
public string ParentRegKey { get; set; }
public string Name { get; set; }
public string ContextMenuType { get; set; }
public KeyValuePair<string, string> Icon { get; set; }
public string Command { get; set; }
public List<KeyValuePair<string, string>> Parameters { get; set; }

/// <summary>
/// Simple context menu entry
/// </summary>
/// <param name="parentRegKey"></param>
/// <param name="name"></param>
/// <param name="contextMenuType"></param>
/// <param name="icon"></param>
/// <param name="command"></param>
public ContextMenuEntry(string parentRegKey, string name, string contextMenuType, KeyValuePair<string, string> icon, string command)
{
ParentRegKey = parentRegKey;
Name = name;
ContextMenuType = contextMenuType;
Icon = icon;
Command = command;
}

/// <summary>
/// Complex context menu entry with more parameters to use
/// </summary>
/// <param name="parentRegKey"></param>
/// <param name="name"></param>
/// <param name="contextMenuType"></param>
/// <param name="icon"></param>
/// <param name="command"></param>
/// <param name="parameters"></param>
public ContextMenuEntry(string parentRegKey, string name, string contextMenuType, KeyValuePair<string, string> icon, string command, List<KeyValuePair<string, string>> parameters)
{
ParentRegKey = parentRegKey;
Name = name;
ContextMenuType = contextMenuType;
Icon = icon;
Command = command;
Parameters = parameters;
}

/// <summary>
/// Add many parameters at once
/// </summary>
/// <param name="toAdd"></param>
public void AddParameter(List<KeyValuePair<string, string>> toAdd)
=> this.Parameters.AddRange(toAdd);

/// <summary>
/// Add a single parameter
/// </summary>
/// <param name="toAdd"></param>
public void AddParameter(KeyValuePair<string, string> toAdd)
=> this.Parameters.Add(toAdd);
}
}
16 changes: 10 additions & 6 deletions AtlasToolbox/Utils/ToolboxUpdateHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,31 @@ namespace AtlasToolbox.Utils
{
public class ToolboxUpdateHelper
{
const string RELEASE_URL = "https://api.github.com/repos/atlas-os/atlas-toolbox/releases/latest";
const string RELEASE_URL = "https://data.jsdelivr.com/v1/packages/gh/atlas-os/atlas-toolbox";
const string DOWNLOAD_URL = $"https://cdn.jsdelivr.net/atlas/toolbox/";
public static string commandUpdate;
public static JsonDocument result;
public static string version = "";
public static bool CheckUpdates()
{
try
{
// get the api result
string htmlContent = CommandPromptHelper.ReturnRunCommand("curl " + RELEASE_URL);
result = JsonDocument.Parse(htmlContent);
string tagName = result.RootElement.GetProperty("tag_name").GetString();
JsonElement versions = result.RootElement.GetProperty("versions");
version = versions[0].GetProperty("version").ToString();

// Format everything to compare
int version = int.Parse(RegistryHelper.GetValue($@"HKLM\SOFTWARE\AtlasOS\Toolbox", "Version").ToString().Replace(".", ""));
int currentVersion = int.Parse(RegistryHelper.GetValue($@"HKLM\SOFTWARE\AtlasOS\Toolbox", "Version").ToString().Replace(".", ""));

if (int.Parse(tagName.Replace(".", "").Replace("v", "")) > version)
if (int.Parse(version.Replace(".", "").Replace("v", "")) > currentVersion)
{
return true;
}
}catch
}catch (Exception e)
{
App.logger.Error(e, "Failed to check for updates");
return false;
}
return false;
Expand All @@ -38,7 +42,7 @@ public static void InstallUpdate()
{
// Call the installer and close Toolbox
// get the download link and create a temporary directory
string downloadUrl = result.RootElement.GetProperty("assets")[0].GetProperty("browser_download_url").GetString();
string downloadUrl = DOWNLOAD_URL + version + "/AtlasToolbox-Setup.exe";
string tempDirectory = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());
Directory.CreateDirectory(tempDirectory);

Expand Down
12 changes: 12 additions & 0 deletions AtlasToolbox/ViewModels/CustomViews/ContextMenuEditorViewModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
锘縰sing System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtlasToolbox.ViewModels.CustomViews
{
internal class ContextMenuEditorViewModel
{
}
}
4 changes: 2 additions & 2 deletions AtlasToolbox/ViewModels/LinksViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ namespace AtlasToolbox.ViewModels
public class LinksViewModel : IConfigurationItem
{
private Links link { get; set; }
public string Name => link.name;
public string Name => link.name ?? "N/A";
public string Link => link.link;
public string FontIcon => link.Icon;
public string Key => link.name.ToLower().Replace(" ", "");
public string Key => link.name.ToLower().Replace(" ", "") ?? "N/A";
public ConfigurationType Type => link.configurationType;

public LinksViewModel(Links link)
Expand Down
4 changes: 2 additions & 2 deletions AtlasToolbox/Views/ConfigPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,9 @@
</DataTemplate>
</BreadcrumbBar.ItemTemplate>
</BreadcrumbBar>
<ScrollViewer Grid.Row="1">
<ScrollViewer x:Name="ConfigScrollViewer" Grid.Row="1">
<StackPanel>
<ItemsControl ItemTemplateSelector="{StaticResource DataTemplateSelector}" ItemsSource="{Binding ConfigurationItems}" />
<ItemsControl x:Name="ConfigItemsControl" ItemTemplateSelector="{StaticResource DataTemplateSelector}" ItemsSource="{Binding ConfigurationItems}" />
</StackPanel>
</ScrollViewer>
</Grid>
Expand Down
92 changes: 92 additions & 0 deletions AtlasToolbox/Views/ConfigPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,98 @@ public ConfigPage()
new Folder {Name = type.GetDescription()}
};
BreadcrumbBar.ItemClicked += BreadcrumbBar_ItemClicked;

this.Loaded += ConfigPage_Loaded;
}

private async void ConfigPage_Loaded(object sender, RoutedEventArgs e)
{
// Check if there's an item to highlight from search
if (!string.IsNullOrEmpty(App.SearchHighlightItemKey))
{
string targetKey = App.SearchHighlightItemKey;
App.SearchHighlightItemKey = null;

await System.Threading.Tasks.Task.Delay(100);

ScrollToAndHighlightItem(targetKey);
}
}

private void ScrollToAndHighlightItem(string itemKey)
{
// Find the index of the item in the vm
int index = -1;
for (int i = 0; i < _viewModel.ConfigurationItems.Count; i++)
{
if (_viewModel.ConfigurationItems[i].Key == itemKey)
{
index = i;
break;
}
}

if (index < 0) return;

// Get the item SettingsCard
var container = ConfigItemsControl.ContainerFromIndex(index) as ContentPresenter;
if (container == null) return;

var settingsCard = FindDescendant<SettingsCard>(container);
if (settingsCard == null) return;

// Scroll to the item
var transform = settingsCard.TransformToVisual(ConfigScrollViewer);
var position = transform.TransformPoint(new Windows.Foundation.Point(0, 0));

double scrollPosition = ConfigScrollViewer.VerticalOffset + position.Y - (ConfigScrollViewer.ActualHeight / 2) + (settingsCard.ActualHeight / 2);
ConfigScrollViewer.ChangeView(null, Math.Max(0, scrollPosition), null);

HighlightSettingsCard(settingsCard);
}

private void HighlightSettingsCard(SettingsCard settingsCard)
{
var originalBrush = settingsCard.BorderBrush;
var originalThickness = settingsCard.BorderThickness;

var highlightBrush = new SolidColorBrush(Microsoft.UI.Colors.Gold);
highlightBrush.Opacity = 0.3;
settingsCard.BorderBrush = highlightBrush;
settingsCard.BorderThickness = new Thickness(3);

// Create a timer to fade out the highlight
var timer = new DispatcherTimer();
timer.Interval = TimeSpan.FromMilliseconds(1500);
timer.Tick += (s, e) =>
{
timer.Stop();
settingsCard.BorderBrush = originalBrush;
settingsCard.BorderThickness = originalThickness;
};
timer.Start();
}

private T FindDescendant<T>(DependencyObject parent) where T : DependencyObject
{
if (parent == null) return null;

int childCount = VisualTreeHelper.GetChildrenCount(parent);
for (int i = 0; i < childCount; i++)
{
var child = VisualTreeHelper.GetChild(parent, i);
if (child is T typedChild)
{
return typedChild;
}

var descendant = FindDescendant<T>(child);
if (descendant != null)
{
return descendant;
}
}
return null;
}

private void BreadcrumbBar_ItemClicked(BreadcrumbBar sender, BreadcrumbBarItemClickedEventArgs args)
Expand Down
2 changes: 1 addition & 1 deletion AtlasToolbox/Views/IncompatibleVersionWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@
</Window.SystemBackdrop>
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">
<TextBlock x:Name="IncompatibleVer" FontSize="20" />
<HyperlinkButton HorizontalAlignment="Center" FontSize="20">https://docs.atlasos.net/getting-started/installation</HyperlinkButton>
<HyperlinkButton HorizontalAlignment="Center" FontSize="20">https://docs.atlasos.net/getting-started/</HyperlinkButton>
</StackPanel>
</Window>
11 changes: 1 addition & 10 deletions AtlasToolbox/Views/SettingsPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
</controls:SettingsCard>
</StackPanel>
<!-- Experiments -->
<StackPanel>
<StackPanel Visibility="Collapsed">
<TextBlock x:Name="ExperimentalHeader" Style="{StaticResource CategoryTitle}" />
<controls:SettingsExpander
x:Name="ExperimentsExpander"
Expand All @@ -86,15 +86,6 @@
<FontIcon Glyph="&#xF196;" />
</controls:SettingsExpander.HeaderIcon>
<controls:SettingsExpander.Items>
<!-- Search experiment -->
<controls:SettingsCard x:Name="SearchExpCard" Tag="Search">
<controls:SettingsCard.HeaderIcon>
<FontIcon Glyph="&#xE71E;" />
</controls:SettingsCard.HeaderIcon>
<ToggleSwitch
Loaded="IsExperimentEnabled"
Tag="Search"/>
</controls:SettingsCard>
</controls:SettingsExpander.Items>
</controls:SettingsExpander>
</StackPanel>
Expand Down
8 changes: 4 additions & 4 deletions AtlasToolbox/Views/SettingsPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ public void LoadText()
ExperimentsExpander.Header = App.GetValueFromItemList("ExperimentsCardHeader");
ExperimentsExpander.Description = App.GetValueFromItemList("ExperimentsCardDescription");

/// Search Experiment
SearchExpCard.Header = App.GetValueFromItemList("SearchExperiment");
SearchExpCard.Description = App.GetValueFromItemList("SearchExperimentDescription");
///// Search Experiment
//SearchExpCard.Header = App.GetValueFromItemList("SearchExperiment");
//SearchExpCard.Description = App.GetValueFromItemList("SearchExperimentDescription");
}

private void KeepBackground_Toggled(object sender, RoutedEventArgs e)
Expand All @@ -82,7 +82,7 @@ private void toCloneRepoCard_Click(object sender, RoutedEventArgs e)

private async void bugRequestCard_Click(object sender, RoutedEventArgs e)
{
await Launcher.LaunchUriAsync(new Uri("https://github.com/Atlas-OS/atlas-toolbox/issues/new"));
await Launcher.LaunchUriAsync(new Uri("https://github.com/Atlas-OS/atlas-toolbox/issues/new?template=bug-report.md"));
}

private void ConfigSwitch_SelectionChanged(object sender, SelectionChangedEventArgs e)
Expand Down
Loading
Loading