├── OpenStartScreen ├── Down.png ├── Up.png ├── TileInteraction.cs ├── App.xaml.cs ├── App.xaml ├── ProgramCategory.cs ├── ShortcutResolver.cs ├── AssemblyInfo.cs ├── IconExtractor.cs ├── OpenStartScreen.csproj ├── tile.xaml ├── MainWindow.xaml ├── tile.xaml.cs ├── UserCard.cs ├── TileManager.cs ├── AppsScreen.cs ├── GridManager.cs └── MainWindow.xaml.cs ├── README.md ├── OpenStartScreen.sln ├── .gitattributes └── .gitignore /OpenStartScreen/Down.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kolejker/OpenStartScreen/HEAD/OpenStartScreen/Down.png -------------------------------------------------------------------------------- /OpenStartScreen/Up.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kolejker/OpenStartScreen/HEAD/OpenStartScreen/Up.png -------------------------------------------------------------------------------- /OpenStartScreen/TileInteraction.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace OpenStartScreen 8 | { 9 | internal class TileInteraction 10 | { 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /OpenStartScreen/App.xaml.cs: -------------------------------------------------------------------------------- 1 | using System.Configuration; 2 | using System.Data; 3 | using System.Windows; 4 | 5 | namespace WpfApp3 6 | { 7 | /// 8 | /// Interaction logic for App.xaml 9 | /// 10 | public partial class App : Application 11 | { 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /OpenStartScreen/App.xaml: -------------------------------------------------------------------------------- 1 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /OpenStartScreen/ProgramCategory.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace OpenStartScreen 4 | { 5 | public class ProgramCategory 6 | { 7 | public string Name { get; set; } 8 | public List Items { get; set; } 9 | 10 | public ProgramCategory(string name) 11 | { 12 | Name = name; 13 | Items = new List(); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /OpenStartScreen/ShortcutResolver.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.InteropServices; 3 | using IWshRuntimeLibrary; 4 | 5 | public class ShortcutResolver 6 | { 7 | public static string Resolve(string shortcutPath) 8 | { 9 | if (System.IO.File.Exists(shortcutPath)) 10 | { 11 | WshShell shell = new WshShell(); 12 | IWshShortcut link = (IWshShortcut)shell.CreateShortcut(shortcutPath); 13 | return link.TargetPath; 14 | } 15 | return null; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /OpenStartScreen/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | 3 | [assembly: ThemeInfo( 4 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located 5 | //(used if a resource is not found in the page, 6 | // or application resource dictionaries) 7 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located 8 | //(used if a resource is not found in the page, 9 | // app, or any theme specific resource dictionaries) 10 | )] 11 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ### OBSELETE, GO USE [THIS](https://github.com/valinet/ExplorerPatcher/wiki/ExplorerPatcher%27s-taskbar-implementation) INSTEAD, ITS THE REAL AND FULL START SCREEN FOR WINDOWS 8 2 | 3 | # OpenStartScreen 4 | 5 | **OpenStartScreen** is an open-source, WPF-based project built with .NET 8.0 that brings back the Windows 8/8.1 Start Screen to Windows 10 and 11. 6 | 7 | 8 | 9 | ## Features to add 10 | 11 | - **MAKE IT REPLACE THE NORMAL START MENU** 12 | - Allow more customizable tile placement 13 | - Live Tiles implementation (either custom or imported from uwp app) 14 | - Smoother animations 15 | - Save tile placement data 16 | - Actual windows 8 menus for tile and app management (on long press) 17 | - Free order of tiles 18 | - Add background and parallax effect 19 | - Add swipe features 20 | 21 | 22 | -------------------------------------------------------------------------------- /OpenStartScreen.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.10.35027.167 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenStartScreen", "OpenStartScreen\OpenStartScreen.csproj", "{53CD9673-0CBC-4922-8873-469C6E5AE25C}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {53CD9673-0CBC-4922-8873-469C6E5AE25C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {53CD9673-0CBC-4922-8873-469C6E5AE25C}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {53CD9673-0CBC-4922-8873-469C6E5AE25C}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {53CD9673-0CBC-4922-8873-469C6E5AE25C}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {087440F4-5BA3-4A97-9857-240A3039A2E2} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /OpenStartScreen/IconExtractor.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Drawing; 3 | using System.Runtime.InteropServices; 4 | using System.Windows.Media.Imaging; 5 | 6 | public class IconExtractor 7 | { 8 | [DllImport("shell32.dll", CharSet = CharSet.Auto)] 9 | public static extern IntPtr ExtractIcon(IntPtr hInst, string lpszExeFileName, int nIconIndex); 10 | 11 | public static Icon Extract(string filePath, int iconIndex) 12 | { 13 | IntPtr hIcon = ExtractIcon(IntPtr.Zero, filePath, iconIndex); 14 | if (hIcon != IntPtr.Zero) 15 | { 16 | return Icon.FromHandle(hIcon); 17 | } 18 | return null; 19 | } 20 | 21 | public static BitmapSource ToBitmapSource(Icon icon) 22 | { 23 | using (var bmp = icon.ToBitmap()) 24 | { 25 | var hBitmap = bmp.GetHbitmap(); 26 | 27 | try 28 | { 29 | var bitmapSource = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap( 30 | hBitmap, 31 | IntPtr.Zero, 32 | System.Windows.Int32Rect.Empty, 33 | BitmapSizeOptions.FromEmptyOptions()); 34 | 35 | return bitmapSource; 36 | } 37 | finally 38 | { 39 | DeleteObject(hBitmap); 40 | } 41 | } 42 | } 43 | 44 | [DllImport("gdi32.dll")] 45 | [return: MarshalAs(UnmanagedType.Bool)] 46 | private static extern bool DeleteObject(IntPtr hObject); 47 | } 48 | -------------------------------------------------------------------------------- /OpenStartScreen/OpenStartScreen.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | WinExe 5 | net8.0-windows 6 | enable 7 | enable 8 | true 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | tlbimp 19 | 0 20 | 1 21 | f935dc20-1cf0-11d0-adb9-00c04fd58a0b 22 | 0 23 | false 24 | true 25 | 26 | 27 | tlbimp 28 | 0 29 | 1 30 | 50a7e9b0-70ef-11d1-b75a-00a0c90564fe 31 | 0 32 | false 33 | true 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /OpenStartScreen/tile.xaml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 29 | 30 | 31 | 32 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /OpenStartScreen/MainWindow.xaml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 31 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 61 | 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /OpenStartScreen/tile.xaml.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | using System.Windows.Controls; 3 | using System.Windows.Input; 4 | using System.Windows.Media; 5 | using System.Windows.Media.Imaging; 6 | 7 | namespace OpenStartScreen 8 | { 9 | public partial class Tile : UserControl 10 | { 11 | public static readonly DependencyProperty TileNameProperty = 12 | DependencyProperty.Register("TileName", typeof(string), typeof(Tile), new PropertyMetadata(string.Empty)); 13 | 14 | public static readonly DependencyProperty TileImageProperty = 15 | DependencyProperty.Register("TileImage", typeof(ImageSource), typeof(Tile), new PropertyMetadata(null)); 16 | 17 | public static readonly DependencyProperty TileBackgroundProperty = 18 | DependencyProperty.Register("TileBackground", typeof(ImageSource), typeof(Tile), new PropertyMetadata(null)); 19 | 20 | public static readonly DependencyProperty TileSizeProperty = 21 | DependencyProperty.Register("TileSize", typeof(TileSize), typeof(Tile), new PropertyMetadata(TileSize.Default)); 22 | 23 | public Tile() 24 | { 25 | InitializeComponent(); 26 | UpdateGradientBrush(); 27 | 28 | this.MouseMove += Tile_MouseMove; 29 | } 30 | 31 | private void Tile_MouseMove(object sender, MouseEventArgs e) 32 | { 33 | if (e.LeftButton == MouseButtonState.Pressed) 34 | { 35 | DragDrop.DoDragDrop(this, this, DragDropEffects.Move); 36 | } 37 | } 38 | 39 | private void UpdateGradientBrush() 40 | { 41 | SolidColorBrush accentBrush = SystemParameters.WindowGlassBrush as SolidColorBrush; 42 | if (accentBrush != null) 43 | { 44 | Color baseColor = accentBrush.Color; 45 | Color darkerColor = DarkenColor(baseColor, 0.1); 46 | 47 | var gradientBrush = (LinearGradientBrush)FindResource("TileGradientBrush"); 48 | if (gradientBrush != null) 49 | { 50 | gradientBrush.GradientStops[1].Color = baseColor; 51 | gradientBrush.GradientStops[0].Color = darkerColor; 52 | } 53 | } 54 | } 55 | 56 | private Color DarkenColor(Color color, double factor) 57 | { 58 | byte r = (byte)(color.R * (1 - factor)); 59 | byte g = (byte)(color.G * (1 - factor)); 60 | byte b = (byte)(color.B * (1 - factor)); 61 | return Color.FromRgb(r, g, b); 62 | } 63 | 64 | public string TileName 65 | { 66 | get => (string)GetValue(TileNameProperty); 67 | set => SetValue(TileNameProperty, value); 68 | } 69 | 70 | public ImageSource TileImage 71 | { 72 | get => (ImageSource)GetValue(TileImageProperty); 73 | set => SetValue(TileImageProperty, value); 74 | } 75 | 76 | public ImageSource TileBackground 77 | { 78 | get => (ImageSource)GetValue(TileBackgroundProperty); 79 | set => SetValue(TileBackgroundProperty, value); 80 | } 81 | 82 | public TileSize TileSize 83 | { 84 | get => (TileSize)GetValue(TileSizeProperty); 85 | set => SetValue(TileSizeProperty, value); 86 | } 87 | 88 | public double ImageSize => TileSize == TileSize.Large ? 72 : 44; 89 | 90 | private static void OnTileSizeChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) 91 | { 92 | if (d is Tile tile) 93 | { 94 | tile.UpdateSize(); 95 | } 96 | } 97 | 98 | private void UpdateSize() 99 | { 100 | UpdateGradientBrush(); 101 | switch (TileSize) 102 | { 103 | case TileSize.Default: 104 | Width = 124; 105 | Height = 124; 106 | break; 107 | case TileSize.Wide: 108 | Width = 248; 109 | Height = 124; 110 | break; 111 | case TileSize.Large: 112 | Width = 248; 113 | Height = 248; 114 | break; 115 | } 116 | } 117 | } 118 | 119 | 120 | 121 | public enum TileSize 122 | { 123 | Default, 124 | Wide, 125 | Large 126 | } 127 | } -------------------------------------------------------------------------------- /OpenStartScreen/UserCard.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel; 2 | using System.Diagnostics; 3 | using System.IO; 4 | using System.Runtime.InteropServices; 5 | using System.Security.Principal; 6 | using System.Windows.Controls; 7 | using System.Windows.Input; 8 | using System.Windows.Media.Imaging; 9 | 10 | public class UserCard : INotifyPropertyChanged 11 | { 12 | private string _username; 13 | private BitmapImage _userProfileImage; 14 | 15 | public string Username 16 | { 17 | get { return _username; } 18 | set 19 | { 20 | _username = value; 21 | OnPropertyChanged(nameof(Username)); 22 | } 23 | } 24 | 25 | public BitmapImage UserProfileImage 26 | { 27 | get { return _userProfileImage; } 28 | set 29 | { 30 | _userProfileImage = value; 31 | OnPropertyChanged(nameof(UserProfileImage)); 32 | } 33 | } 34 | 35 | public ICommand OpenContextMenuCommand { get; } 36 | public ICommand ChangeAccountPictureCommand { get; } 37 | public ICommand LockCommand { get; } 38 | public ICommand SignOutCommand { get; } 39 | 40 | public UserCard() 41 | { 42 | Username = GetUsername(); 43 | UserProfileImage = GetUserProfileImage(); 44 | 45 | OpenContextMenuCommand = new RelayCommand(OpenContextMenu); 46 | ChangeAccountPictureCommand = new RelayCommand(ChangeAccountPicture); 47 | LockCommand = new RelayCommand(Lock); 48 | SignOutCommand = new RelayCommand(SignOut); 49 | } 50 | 51 | private string GetUsername() 52 | { 53 | return WindowsIdentity.GetCurrent().Name.Split('\\')[1]; 54 | } 55 | 56 | private BitmapImage GetUserProfileImage() 57 | { 58 | string userImagePath = GetUserProfilePicturePath(); 59 | if (File.Exists(userImagePath)) 60 | { 61 | return LoadImage(userImagePath); 62 | } 63 | else 64 | { 65 | string defaultImagePath = @"C:\ProgramData\Microsoft\User Account Pictures\user-192.png"; 66 | if (File.Exists(defaultImagePath)) 67 | { 68 | return LoadImage(defaultImagePath); 69 | } 70 | } 71 | return null; 72 | } 73 | 74 | private BitmapImage LoadImage(string imagePath) 75 | { 76 | BitmapImage bitmap = new BitmapImage(); 77 | bitmap.BeginInit(); 78 | bitmap.UriSource = new Uri(imagePath); 79 | bitmap.CacheOption = BitmapCacheOption.OnLoad; 80 | bitmap.EndInit(); 81 | return bitmap; 82 | } 83 | 84 | private string GetUserProfilePicturePath() 85 | { 86 | string profilePath = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile); 87 | string imagePath = Path.Combine(profilePath, "AppData", "Roaming", "Microsoft", "Windows", "AccountPictures"); 88 | if (Directory.Exists(imagePath)) 89 | { 90 | var files = Directory.GetFiles(imagePath, "*.jpg"); 91 | if (files.Length > 0) 92 | { 93 | return files[0]; 94 | } 95 | } 96 | return null; 97 | } 98 | 99 | private void OpenContextMenu(object parameter) 100 | { 101 | if (parameter is Button button) 102 | { 103 | button.ContextMenu.PlacementTarget = button; 104 | button.ContextMenu.Placement = System.Windows.Controls.Primitives.PlacementMode.Bottom; 105 | button.ContextMenu.IsOpen = true; 106 | } 107 | } 108 | 109 | [DllImport("user32.dll")] 110 | private static extern bool LockWorkStation(); 111 | 112 | private void Lock(object parameter) 113 | { 114 | LockWorkStation(); 115 | } 116 | 117 | [DllImport("user32.dll", SetLastError = true)] 118 | private static extern bool ExitWindowsEx(uint uFlags, uint dwReason); 119 | 120 | private const uint EWX_LOGOFF = 0x00000000; 121 | 122 | private void SignOut(object parameter) 123 | { 124 | ExitWindowsEx(EWX_LOGOFF, 0); 125 | } 126 | 127 | private void ChangeAccountPicture(object parameter) 128 | { 129 | Process.Start(new ProcessStartInfo("ms-settings:yourinfo") { UseShellExecute = true }); 130 | } 131 | 132 | public event PropertyChangedEventHandler PropertyChanged; 133 | 134 | protected void OnPropertyChanged(string propertyName) 135 | { 136 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); 137 | } 138 | } 139 | 140 | public class RelayCommand : ICommand 141 | { 142 | private readonly Action _execute; 143 | private readonly Func _canExecute; 144 | 145 | public RelayCommand(Action execute, Func canExecute = null) 146 | { 147 | _execute = execute ?? throw new ArgumentNullException(nameof(execute)); 148 | _canExecute = canExecute; 149 | } 150 | 151 | public bool CanExecute(object parameter) 152 | { 153 | return _canExecute == null || _canExecute(parameter); 154 | } 155 | 156 | public void Execute(object parameter) 157 | { 158 | _execute(parameter); 159 | } 160 | 161 | public event EventHandler CanExecuteChanged 162 | { 163 | add { CommandManager.RequerySuggested += value; } 164 | remove { CommandManager.RequerySuggested -= value; } 165 | } 166 | } 167 | -------------------------------------------------------------------------------- /OpenStartScreen/TileManager.cs: -------------------------------------------------------------------------------- 1 | using System.Diagnostics; 2 | using System.IO; 3 | using System.Windows; 4 | using System.Windows.Controls; 5 | using System.Windows.Input; 6 | using System.Windows.Media; 7 | using System.Windows.Media.Imaging; 8 | 9 | namespace OpenStartScreen; 10 | 11 | public partial class MainWindow 12 | { 13 | private Tile CreateTile(TileInfo tileInfo) 14 | { 15 | var tile = new Tile 16 | { 17 | TileName = tileInfo.Name, 18 | TileImage = tileInfo.Image, 19 | TileBackground = tileInfo.Background, 20 | TileSize = tileInfo.Size 21 | }; 22 | 23 | tile.MouseRightButtonUp += (s, e) => ShowTileContextMenu(tile, tileInfo.FilePath); 24 | tile.MouseLeftButtonUp += (s, e) => LaunchProgram(tileInfo.FilePath); 25 | 26 | 27 | tile.MouseMove += (s, e) => 28 | { 29 | if (e.LeftButton == MouseButtonState.Pressed) 30 | { 31 | DragDrop.DoDragDrop(tile, tile, DragDropEffects.Move); 32 | } 33 | }; 34 | 35 | return tile; 36 | } 37 | 38 | private TileInfo CreateDesktopTileInfo() 39 | { 40 | return new TileInfo 41 | { 42 | Name = "Desktop", 43 | Image = null, 44 | Background = new BitmapImage(new Uri(GetWallpaperPath())), 45 | FilePath = "explorer.exe", 46 | Size = TileSize.Default 47 | }; 48 | } 49 | 50 | private TileInfo CreatePinnedProgramTileInfo(string file) 51 | { 52 | string targetPath = ShortcutResolver.Resolve(file); 53 | if (string.IsNullOrEmpty(targetPath) || !File.Exists(targetPath)) 54 | return null; 55 | 56 | var icon = IconExtractor.Extract(targetPath, 0); 57 | var bitmapImage = icon != null ? IconExtractor.ToBitmapSource(icon) : null; 58 | 59 | return new TileInfo 60 | { 61 | Name = Path.GetFileNameWithoutExtension(file), 62 | Image = bitmapImage, 63 | Background = null, 64 | FilePath = file, 65 | Size = TileSize.Default 66 | }; 67 | } 68 | 69 | private void MoveTile(Tile sourceTile, Tile targetTile) 70 | { 71 | var sourceTileInfo = _allTiles.FirstOrDefault(t => t.Name == sourceTile.TileName); 72 | var targetTileInfo = _allTiles.FirstOrDefault(t => t.Name == targetTile.TileName); 73 | 74 | if (sourceTileInfo != null && targetTileInfo != null) 75 | { 76 | int sourceIndex = _allTiles.IndexOf(sourceTileInfo); 77 | int targetIndex = _allTiles.IndexOf(targetTileInfo); 78 | 79 | _allTiles.RemoveAt(sourceIndex); 80 | _allTiles.Insert(targetIndex, sourceTileInfo); 81 | 82 | ReorganizeTiles(); 83 | } 84 | } 85 | 86 | private Tile CreateDesktopTile() 87 | { 88 | var desktopTile = new Tile 89 | { 90 | TileName = "Desktop", 91 | TileImage = null, 92 | TileBackground = new BitmapImage(new Uri(GetWallpaperPath())) 93 | }; 94 | 95 | desktopTile.MouseLeftButtonUp += (s, e) => LaunchDesktop(); 96 | return desktopTile; 97 | } 98 | 99 | private void LaunchDesktop() 100 | { 101 | try 102 | { 103 | Process.Start(new ProcessStartInfo 104 | { 105 | FileName = "explorer.exe", 106 | Arguments = "shell:::{3080F90D-D7AD-11D9-BD98-0000947B0257}", 107 | UseShellExecute = true 108 | }); 109 | } 110 | catch (Exception ex) 111 | { 112 | MessageBox.Show($"Failed to launch desktop: {ex.Message}"); 113 | } 114 | } 115 | 116 | private Tile CreatePinnedProgramTile(string file) 117 | { 118 | string targetPath = ShortcutResolver.Resolve(file); 119 | if (string.IsNullOrEmpty(targetPath) || !File.Exists(targetPath)) 120 | return null; 121 | 122 | var icon = IconExtractor.Extract(targetPath, 0); 123 | var bitmapImage = icon != null ? IconExtractor.ToBitmapSource(icon) : null; 124 | 125 | var tile = new Tile 126 | { 127 | TileName = Path.GetFileNameWithoutExtension(file), 128 | TileImage = bitmapImage, 129 | TileBackground = null 130 | }; 131 | 132 | tile.MouseRightButtonUp += (s, e) => ShowTileContextMenu(tile, file); 133 | tile.MouseLeftButtonUp += (s, e) => LaunchProgram(file); 134 | 135 | return tile; 136 | } 137 | 138 | private void ShowTileContextMenu(Tile tile, string filePath) 139 | { 140 | var contextMenu = new ContextMenu(); 141 | 142 | var unpinMenuItem = new MenuItem { Header = "Unpin from Start" }; 143 | unpinMenuItem.Click += (s, e) => UnpinFromStartMenu(filePath); 144 | contextMenu.Items.Add(unpinMenuItem); 145 | 146 | var sizeMenu = new MenuItem { Header = "Resize" }; 147 | sizeMenu.Items.Add(CreateSizeMenuItem("Small", TileSize.Default, tile, filePath)); 148 | sizeMenu.Items.Add(CreateSizeMenuItem("Wide", TileSize.Wide, tile, filePath)); 149 | sizeMenu.Items.Add(CreateSizeMenuItem("Large", TileSize.Large, tile, filePath)); 150 | contextMenu.Items.Add(sizeMenu); 151 | 152 | contextMenu.IsOpen = true; 153 | } 154 | 155 | private void UnpinFromStartMenu(string filePath) 156 | { 157 | try 158 | { 159 | var pinnedFilePath = Path.Combine(PinnedStartMenuPath, Path.GetFileName(filePath)); 160 | if (File.Exists(pinnedFilePath)) 161 | { 162 | File.Delete(pinnedFilePath); 163 | } 164 | 165 | LoadPinnedItems(); 166 | } 167 | catch (Exception ex) 168 | { 169 | MessageBox.Show($"Failed to unpin from Start Menu: {ex.Message}"); 170 | } 171 | } 172 | 173 | public class TileInfo 174 | { 175 | public string Name { get; set; } 176 | public ImageSource Image { get; set; } 177 | public ImageSource Background { get; set; } 178 | public string FilePath { get; set; } 179 | public TileSize Size { get; set; } 180 | public Tile Tile { get; set; } 181 | } 182 | } -------------------------------------------------------------------------------- /OpenStartScreen/AppsScreen.cs: -------------------------------------------------------------------------------- 1 | using System.Diagnostics; 2 | using System.IO; 3 | using System.Windows; 4 | using System.Windows.Controls; 5 | using System.Windows.Media; 6 | 7 | namespace OpenStartScreen; 8 | 9 | public partial class MainWindow 10 | { 11 | private void DisplayCategories(Dictionary categories) 12 | { 13 | bool isFirstCategory = true; 14 | 15 | foreach (var category in categories.Values) 16 | { 17 | var wrapPanel = new WrapPanel 18 | { 19 | Orientation = Orientation.Vertical, 20 | MaxHeight = 500, 21 | Margin = new Thickness(10, 0, 0, 0) 22 | }; 23 | 24 | if (category.Name != "Other Programs") 25 | { 26 | if (!isFirstCategory) 27 | { 28 | var separator = CreateSeparator(); 29 | CategoriesPanel.Children.Add(separator); 30 | } 31 | 32 | var titleButton = CreateCategoryButton(category.Name); 33 | wrapPanel.Children.Add(titleButton); 34 | } 35 | 36 | foreach (var file in category.Items) 37 | { 38 | var button = CreateProgramButton(file); 39 | if (button != null) 40 | { 41 | wrapPanel.Children.Add(button); 42 | } 43 | } 44 | 45 | var border = new Border 46 | { 47 | Padding = new Thickness(10), 48 | Child = wrapPanel 49 | }; 50 | 51 | CategoriesPanel.Children.Add(border); 52 | isFirstCategory = false; 53 | } 54 | } 55 | 56 | private Button CreateCategoryButton(string categoryName) 57 | { 58 | var stackPanel = new StackPanel { Orientation = Orientation.Horizontal }; 59 | 60 | var textBlock = new TextBlock 61 | { 62 | Text = categoryName, 63 | Foreground = Brushes.White, 64 | VerticalAlignment = VerticalAlignment.Center, 65 | TextAlignment = TextAlignment.Left, 66 | FontSize = 16, 67 | Opacity = 0.25, 68 | }; 69 | stackPanel.Children.Add(textBlock); 70 | 71 | var button = new Button 72 | { 73 | Content = stackPanel, 74 | Margin = new Thickness(5), 75 | Foreground = Brushes.White, 76 | Padding = new Thickness(10), 77 | Background = Brushes.Transparent, 78 | BorderBrush = Brushes.Transparent, 79 | BorderThickness = new Thickness(1) 80 | }; 81 | 82 | return button; 83 | } 84 | 85 | private UIElement CreateSeparator() 86 | { 87 | return new Border 88 | { 89 | Width = 50, 90 | Margin = new Thickness(0, 100, 0, 100), 91 | Background = Brushes.Transparent 92 | }; 93 | } 94 | 95 | private Button CreateProgramButton(string file) 96 | { 97 | string targetPath = ShortcutResolver.Resolve(file); 98 | if (string.IsNullOrEmpty(targetPath) || !File.Exists(targetPath)) 99 | return null; 100 | 101 | var icon = IconExtractor.Extract(targetPath, 0); 102 | var bitmapImage = icon != null ? IconExtractor.ToBitmapSource(icon) : null; 103 | 104 | var grid = new Grid 105 | { 106 | Margin = new Thickness(5), 107 | VerticalAlignment = VerticalAlignment.Center, 108 | HorizontalAlignment = HorizontalAlignment.Left 109 | }; 110 | 111 | grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(40) }); 112 | grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(150) }); 113 | 114 | var iconGrid = new Grid 115 | { 116 | Width = 40, 117 | Height = 40, 118 | Background = new SolidColorBrush(Color.FromRgb(0, 120, 215)), 119 | VerticalAlignment = VerticalAlignment.Center, 120 | HorizontalAlignment = HorizontalAlignment.Left 121 | }; 122 | 123 | if (bitmapImage != null) 124 | { 125 | var image = new Image 126 | { 127 | Source = bitmapImage, 128 | Width = 32, 129 | Height = 32, 130 | HorizontalAlignment = HorizontalAlignment.Center, 131 | VerticalAlignment = VerticalAlignment.Center 132 | }; 133 | iconGrid.Children.Add(image); 134 | } 135 | 136 | var textBlock = new TextBlock 137 | { 138 | Text = Path.GetFileNameWithoutExtension(file), 139 | Foreground = Brushes.White, 140 | FontSize = 14, 141 | TextWrapping = TextWrapping.Wrap, 142 | VerticalAlignment = VerticalAlignment.Top, 143 | HorizontalAlignment = HorizontalAlignment.Left, 144 | Margin = new Thickness(10, 0, 0, 0) 145 | }; 146 | 147 | Grid.SetColumn(iconGrid, 0); 148 | Grid.SetColumn(textBlock, 1); 149 | 150 | grid.Children.Add(iconGrid); 151 | grid.Children.Add(textBlock); 152 | 153 | var button = new Button 154 | { 155 | Content = grid, 156 | Tag = file, 157 | BorderThickness = new Thickness(0), 158 | Background = Brushes.Transparent, 159 | HorizontalAlignment = HorizontalAlignment.Left, 160 | BorderBrush = Brushes.Transparent, 161 | VerticalAlignment = VerticalAlignment.Top 162 | }; 163 | button.Click += ProgramButton_Click; 164 | 165 | var contextMenu = new ContextMenu(); 166 | var pinMenuItem = new MenuItem { Header = "Pin to Start" }; 167 | pinMenuItem.Click += (s, e) => PinToStartMenu(file); 168 | contextMenu.Items.Add(pinMenuItem); 169 | button.ContextMenu = contextMenu; 170 | 171 | return button; 172 | } 173 | 174 | private void LaunchProgram(string filePath) 175 | { 176 | try 177 | { 178 | Process.Start(new ProcessStartInfo(filePath) { UseShellExecute = true }); 179 | } 180 | catch (Exception ex) 181 | { 182 | MessageBox.Show($"Failed to start program: {ex.Message}"); 183 | } 184 | } 185 | 186 | private void PinToStartMenu(string filePath) 187 | { 188 | try 189 | { 190 | var pinnedFilePath = Path.Combine(PinnedStartMenuPath, Path.GetFileName(filePath)); 191 | File.Copy(filePath, pinnedFilePath, true); 192 | LoadPinnedItems(); 193 | } 194 | catch (Exception ex) 195 | { 196 | MessageBox.Show($"Failed to pin to Start Menu: {ex.Message}"); 197 | } 198 | } 199 | 200 | private void ProgramButton_Click(object sender, RoutedEventArgs e) 201 | { 202 | if (sender is Button button && button.Tag is string filePath) 203 | { 204 | try 205 | { 206 | Process.Start(new ProcessStartInfo(filePath) { UseShellExecute = true }); 207 | } 208 | catch (Exception ex) 209 | { 210 | MessageBox.Show($"Failed to start program: {ex.Message}"); 211 | } 212 | } 213 | } 214 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.rsuser 8 | *.suo 9 | *.user 10 | *.userosscache 11 | *.sln.docstates 12 | 13 | # User-specific files (MonoDevelop/Xamarin Studio) 14 | *.userprefs 15 | 16 | # Mono auto generated files 17 | mono_crash.* 18 | 19 | # Build results 20 | [Dd]ebug/ 21 | [Dd]ebugPublic/ 22 | [Rr]elease/ 23 | [Rr]eleases/ 24 | x64/ 25 | x86/ 26 | [Ww][Ii][Nn]32/ 27 | [Aa][Rr][Mm]/ 28 | [Aa][Rr][Mm]64/ 29 | bld/ 30 | [Bb]in/ 31 | [Oo]bj/ 32 | [Oo]ut/ 33 | [Ll]og/ 34 | [Ll]ogs/ 35 | 36 | # Visual Studio 2015/2017 cache/options directory 37 | .vs/ 38 | # Uncomment if you have tasks that create the project's static files in wwwroot 39 | #wwwroot/ 40 | 41 | # Visual Studio 2017 auto generated files 42 | Generated\ Files/ 43 | 44 | # MSTest test Results 45 | [Tt]est[Rr]esult*/ 46 | [Bb]uild[Ll]og.* 47 | 48 | # NUnit 49 | *.VisualState.xml 50 | TestResult.xml 51 | nunit-*.xml 52 | 53 | # Build Results of an ATL Project 54 | [Dd]ebugPS/ 55 | [Rr]eleasePS/ 56 | dlldata.c 57 | 58 | # Benchmark Results 59 | BenchmarkDotNet.Artifacts/ 60 | 61 | # .NET Core 62 | project.lock.json 63 | project.fragment.lock.json 64 | artifacts/ 65 | 66 | # ASP.NET Scaffolding 67 | ScaffoldingReadMe.txt 68 | 69 | # StyleCop 70 | StyleCopReport.xml 71 | 72 | # Files built by Visual Studio 73 | *_i.c 74 | *_p.c 75 | *_h.h 76 | *.ilk 77 | *.meta 78 | *.obj 79 | *.iobj 80 | *.pch 81 | *.pdb 82 | *.ipdb 83 | *.pgc 84 | *.pgd 85 | *.rsp 86 | *.sbr 87 | *.tlb 88 | *.tli 89 | *.tlh 90 | *.tmp 91 | *.tmp_proj 92 | *_wpftmp.csproj 93 | *.log 94 | *.vspscc 95 | *.vssscc 96 | .builds 97 | *.pidb 98 | *.svclog 99 | *.scc 100 | 101 | # Chutzpah Test files 102 | _Chutzpah* 103 | 104 | # Visual C++ cache files 105 | ipch/ 106 | *.aps 107 | *.ncb 108 | *.opendb 109 | *.opensdf 110 | *.sdf 111 | *.cachefile 112 | *.VC.db 113 | *.VC.VC.opendb 114 | 115 | # Visual Studio profiler 116 | *.psess 117 | *.vsp 118 | *.vspx 119 | *.sap 120 | 121 | # Visual Studio Trace Files 122 | *.e2e 123 | 124 | # TFS 2012 Local Workspace 125 | $tf/ 126 | 127 | # Guidance Automation Toolkit 128 | *.gpState 129 | 130 | # ReSharper is a .NET coding add-in 131 | _ReSharper*/ 132 | *.[Rr]e[Ss]harper 133 | *.DotSettings.user 134 | 135 | # TeamCity is a build add-in 136 | _TeamCity* 137 | 138 | # DotCover is a Code Coverage Tool 139 | *.dotCover 140 | 141 | # AxoCover is a Code Coverage Tool 142 | .axoCover/* 143 | !.axoCover/settings.json 144 | 145 | # Coverlet is a free, cross platform Code Coverage Tool 146 | coverage*.json 147 | coverage*.xml 148 | coverage*.info 149 | 150 | # Visual Studio code coverage results 151 | *.coverage 152 | *.coveragexml 153 | 154 | # NCrunch 155 | _NCrunch_* 156 | .*crunch*.local.xml 157 | nCrunchTemp_* 158 | 159 | # MightyMoose 160 | *.mm.* 161 | AutoTest.Net/ 162 | 163 | # Web workbench (sass) 164 | .sass-cache/ 165 | 166 | # Installshield output folder 167 | [Ee]xpress/ 168 | 169 | # DocProject is a documentation generator add-in 170 | DocProject/buildhelp/ 171 | DocProject/Help/*.HxT 172 | DocProject/Help/*.HxC 173 | DocProject/Help/*.hhc 174 | DocProject/Help/*.hhk 175 | DocProject/Help/*.hhp 176 | DocProject/Help/Html2 177 | DocProject/Help/html 178 | 179 | # Click-Once directory 180 | publish/ 181 | 182 | # Publish Web Output 183 | *.[Pp]ublish.xml 184 | *.azurePubxml 185 | # Note: Comment the next line if you want to checkin your web deploy settings, 186 | # but database connection strings (with potential passwords) will be unencrypted 187 | *.pubxml 188 | *.publishproj 189 | 190 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 191 | # checkin your Azure Web App publish settings, but sensitive information contained 192 | # in these scripts will be unencrypted 193 | PublishScripts/ 194 | 195 | # NuGet Packages 196 | *.nupkg 197 | # NuGet Symbol Packages 198 | *.snupkg 199 | # The packages folder can be ignored because of Package Restore 200 | **/[Pp]ackages/* 201 | # except build/, which is used as an MSBuild target. 202 | !**/[Pp]ackages/build/ 203 | # Uncomment if necessary however generally it will be regenerated when needed 204 | #!**/[Pp]ackages/repositories.config 205 | # NuGet v3's project.json files produces more ignorable files 206 | *.nuget.props 207 | *.nuget.targets 208 | 209 | # Microsoft Azure Build Output 210 | csx/ 211 | *.build.csdef 212 | 213 | # Microsoft Azure Emulator 214 | ecf/ 215 | rcf/ 216 | 217 | # Windows Store app package directories and files 218 | AppPackages/ 219 | BundleArtifacts/ 220 | Package.StoreAssociation.xml 221 | _pkginfo.txt 222 | *.appx 223 | *.appxbundle 224 | *.appxupload 225 | 226 | # Visual Studio cache files 227 | # files ending in .cache can be ignored 228 | *.[Cc]ache 229 | # but keep track of directories ending in .cache 230 | !?*.[Cc]ache/ 231 | 232 | # Others 233 | ClientBin/ 234 | ~$* 235 | *~ 236 | *.dbmdl 237 | *.dbproj.schemaview 238 | *.jfm 239 | *.pfx 240 | *.publishsettings 241 | orleans.codegen.cs 242 | 243 | # Including strong name files can present a security risk 244 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 245 | #*.snk 246 | 247 | # Since there are multiple workflows, uncomment next line to ignore bower_components 248 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 249 | #bower_components/ 250 | 251 | # RIA/Silverlight projects 252 | Generated_Code/ 253 | 254 | # Backup & report files from converting an old project file 255 | # to a newer Visual Studio version. Backup files are not needed, 256 | # because we have git ;-) 257 | _UpgradeReport_Files/ 258 | Backup*/ 259 | UpgradeLog*.XML 260 | UpgradeLog*.htm 261 | ServiceFabricBackup/ 262 | *.rptproj.bak 263 | 264 | # SQL Server files 265 | *.mdf 266 | *.ldf 267 | *.ndf 268 | 269 | # Business Intelligence projects 270 | *.rdl.data 271 | *.bim.layout 272 | *.bim_*.settings 273 | *.rptproj.rsuser 274 | *- [Bb]ackup.rdl 275 | *- [Bb]ackup ([0-9]).rdl 276 | *- [Bb]ackup ([0-9][0-9]).rdl 277 | 278 | # Microsoft Fakes 279 | FakesAssemblies/ 280 | 281 | # GhostDoc plugin setting file 282 | *.GhostDoc.xml 283 | 284 | # Node.js Tools for Visual Studio 285 | .ntvs_analysis.dat 286 | node_modules/ 287 | 288 | # Visual Studio 6 build log 289 | *.plg 290 | 291 | # Visual Studio 6 workspace options file 292 | *.opt 293 | 294 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 295 | *.vbw 296 | 297 | # Visual Studio LightSwitch build output 298 | **/*.HTMLClient/GeneratedArtifacts 299 | **/*.DesktopClient/GeneratedArtifacts 300 | **/*.DesktopClient/ModelManifest.xml 301 | **/*.Server/GeneratedArtifacts 302 | **/*.Server/ModelManifest.xml 303 | _Pvt_Extensions 304 | 305 | # Paket dependency manager 306 | .paket/paket.exe 307 | paket-files/ 308 | 309 | # FAKE - F# Make 310 | .fake/ 311 | 312 | # CodeRush personal settings 313 | .cr/personal 314 | 315 | # Python Tools for Visual Studio (PTVS) 316 | __pycache__/ 317 | *.pyc 318 | 319 | # Cake - Uncomment if you are using it 320 | # tools/** 321 | # !tools/packages.config 322 | 323 | # Tabs Studio 324 | *.tss 325 | 326 | # Telerik's JustMock configuration file 327 | *.jmconfig 328 | 329 | # BizTalk build output 330 | *.btp.cs 331 | *.btm.cs 332 | *.odx.cs 333 | *.xsd.cs 334 | 335 | # OpenCover UI analysis results 336 | OpenCover/ 337 | 338 | # Azure Stream Analytics local run output 339 | ASALocalRun/ 340 | 341 | # MSBuild Binary and Structured Log 342 | *.binlog 343 | 344 | # NVidia Nsight GPU debugger configuration file 345 | *.nvuser 346 | 347 | # MFractors (Xamarin productivity tool) working folder 348 | .mfractor/ 349 | 350 | # Local History for Visual Studio 351 | .localhistory/ 352 | 353 | # BeatPulse healthcheck temp database 354 | healthchecksdb 355 | 356 | # Backup folder for Package Reference Convert tool in Visual Studio 2017 357 | MigrationBackup/ 358 | 359 | # Ionide (cross platform F# VS Code tools) working folder 360 | .ionide/ 361 | 362 | # Fody - auto-generated XML schema 363 | FodyWeavers.xsd -------------------------------------------------------------------------------- /OpenStartScreen/GridManager.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | using System.Windows.Controls; 3 | using System.Windows.Controls.Primitives; 4 | using System.Windows.Media; 5 | 6 | namespace OpenStartScreen; 7 | 8 | public partial class MainWindow 9 | { 10 | private void GridsPanel_Drop(object sender, DragEventArgs e) 11 | { 12 | if (e.Data.GetDataPresent(typeof(Tile))) 13 | { 14 | Tile droppedTile = e.Data.GetData(typeof(Tile)) as Tile; 15 | if (droppedTile != null) 16 | { 17 | Point dropPosition = e.GetPosition(GridsPanel); 18 | HitTestResult hitTestResult = VisualTreeHelper.HitTest(GridsPanel, dropPosition); 19 | if (hitTestResult != null) 20 | { 21 | Tile targetTile = FindParent(hitTestResult.VisualHit); 22 | if (targetTile != null && !ReferenceEquals(droppedTile, targetTile)) 23 | { 24 | MoveTile(droppedTile, targetTile); 25 | } 26 | } 27 | } 28 | } 29 | } 30 | 31 | private void GridsPanel_DragOver(object sender, DragEventArgs e) 32 | { 33 | if (e.Data.GetDataPresent(typeof(Tile))) 34 | { 35 | e.Effects = DragDropEffects.Move; 36 | } 37 | else 38 | { 39 | e.Effects = DragDropEffects.None; 40 | } 41 | 42 | e.Handled = true; 43 | } 44 | 45 | private MenuItem CreateSizeMenuItem(string header, TileSize size, Tile tile, string filePath) 46 | { 47 | var menuItem = new MenuItem { Header = header }; 48 | menuItem.Click += (s, e) => 49 | { 50 | var tileInfo = _allTiles.FirstOrDefault(t => t.FilePath == filePath); 51 | if (tileInfo != null) 52 | { 53 | tileInfo.Size = size; 54 | tile.TileSize = size; 55 | ReorganizeTiles(); 56 | } 57 | }; 58 | return menuItem; 59 | } 60 | 61 | private void ReorganizeTiles() 62 | { 63 | GridsPanel.Children.Clear(); 64 | 65 | var stackPanel = new StackPanel 66 | { 67 | Orientation = Orientation.Horizontal 68 | }; 69 | 70 | var currentGrid = CreateNewGrid(); 71 | var occupiedCells = new List> { new List { false, false, false, false } }; 72 | 73 | foreach (var tileInfo in _allTiles) 74 | { 75 | var tile = CreateTile(tileInfo); 76 | 77 | int columnSpan = 1; 78 | int rowSpan = 1; 79 | 80 | switch (tile.TileSize) 81 | { 82 | case TileSize.Default: 83 | tile.Width = 124; 84 | tile.Height = 124; 85 | break; 86 | case TileSize.Wide: 87 | tile.Width = 248; 88 | tile.Height = 124; 89 | columnSpan = 2; 90 | break; 91 | case TileSize.Large: 92 | tile.Width = 248; 93 | tile.Height = 248; 94 | columnSpan = 2; 95 | rowSpan = 2; 96 | break; 97 | } 98 | 99 | int row = 0; 100 | int col = -1; 101 | 102 | while (col == -1) 103 | { 104 | col = FindNextAvailableColumn(occupiedCells, row, columnSpan, rowSpan); 105 | if (col == -1) 106 | { 107 | row++; 108 | if (row >= occupiedCells.Count) 109 | { 110 | occupiedCells.Add(new List { false, false, false, false }); 111 | currentGrid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(124) }); 112 | } 113 | } 114 | } 115 | 116 | if (row >= 4) 117 | { 118 | stackPanel.Children.Add(currentGrid); 119 | currentGrid = CreateNewGrid(); 120 | occupiedCells = new List> { new List { false, false, false, false } }; 121 | row = 0; 122 | col = 0; 123 | } 124 | 125 | Grid.SetRow(tile, row); 126 | Grid.SetColumn(tile, col); 127 | Grid.SetColumnSpan(tile, columnSpan); 128 | Grid.SetRowSpan(tile, rowSpan); 129 | 130 | for (int r = 0; r < rowSpan; r++) 131 | { 132 | while (row + r >= occupiedCells.Count) 133 | { 134 | occupiedCells.Add(new List { false, false, false, false }); 135 | currentGrid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(124) }); 136 | } 137 | 138 | for (int c = 0; c < columnSpan; c++) 139 | { 140 | occupiedCells[row + r][col + c] = true; 141 | } 142 | } 143 | 144 | currentGrid.Children.Add(tile); 145 | } 146 | 147 | stackPanel.Children.Add(currentGrid); 148 | 149 | var scrollViewer = new ScrollViewer 150 | { 151 | HorizontalScrollBarVisibility = ScrollBarVisibility.Auto, 152 | VerticalScrollBarVisibility = ScrollBarVisibility.Disabled, 153 | Content = stackPanel, 154 | MaxHeight = 500 155 | }; 156 | 157 | scrollViewer.HorizontalAlignment = HorizontalAlignment.Left; 158 | 159 | var scrollViewerContainer = new Grid 160 | { 161 | HorizontalAlignment = HorizontalAlignment.Stretch 162 | }; 163 | scrollViewerContainer.Children.Add(scrollViewer); 164 | 165 | GridsPanel.Children.Add(scrollViewerContainer); 166 | 167 | GridsPanel.HorizontalAlignment = HorizontalAlignment.Stretch; 168 | } 169 | 170 | private Grid CreateNewGrid() 171 | { 172 | var grid = new Grid(); 173 | for (int i = 0; i < 4; i++) 174 | { 175 | grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(124) }); 176 | grid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(124) }); 177 | } 178 | 179 | return grid; 180 | } 181 | 182 | private int FindNextAvailableColumn(List> occupiedCells, int row, int columnSpan, int rowSpan) 183 | { 184 | for (int col = 0; col <= 4 - columnSpan; col++) 185 | { 186 | bool isAvailable = true; 187 | for (int r = 0; r < rowSpan; r++) 188 | { 189 | if (row + r >= occupiedCells.Count) 190 | { 191 | continue; 192 | } 193 | 194 | for (int c = 0; c < columnSpan; c++) 195 | { 196 | if (occupiedCells[row + r][col + c]) 197 | { 198 | isAvailable = false; 199 | break; 200 | } 201 | } 202 | 203 | if (!isAvailable) break; 204 | } 205 | 206 | if (isAvailable) return col; 207 | } 208 | 209 | return -1; 210 | } 211 | 212 | private List _allTiles = new List(); 213 | 214 | private void AddTileToGrid(Tile tile) 215 | { 216 | UniformGrid lastGrid = GridsPanel.Children.OfType().LastOrDefault(); 217 | if (lastGrid == null || !CanFitTile(lastGrid, tile)) 218 | { 219 | lastGrid = new UniformGrid { Columns = 2, Rows = 4 }; 220 | lastGrid.Margin = new Thickness(10); 221 | GridsPanel.Children.Add(lastGrid); 222 | } 223 | 224 | lastGrid.Children.Add(tile); 225 | } 226 | 227 | private bool CanFitTile(UniformGrid grid, Tile tile) 228 | { 229 | int occupiedCells = grid.Children.Cast().Sum(t => GetTileOccupiedCells(t)); 230 | int newTileCells = GetTileOccupiedCells(tile); 231 | return occupiedCells + newTileCells <= grid.Columns * grid.Rows; 232 | } 233 | 234 | private int GetTileOccupiedCells(Tile tile) 235 | { 236 | switch (tile.TileSize) 237 | { 238 | case TileSize.Default: 239 | return 1; 240 | case TileSize.Wide: 241 | return 2; 242 | case TileSize.Large: 243 | return 4; 244 | default: 245 | return 1; 246 | } 247 | } 248 | } -------------------------------------------------------------------------------- /OpenStartScreen/MainWindow.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | using System.IO; 4 | using System.Windows; 5 | using System.Windows.Controls; 6 | using System.Windows.Controls.Primitives; 7 | using System.Windows.Media; 8 | using System.Windows.Media.Animation; 9 | using System.Windows.Threading; 10 | using System.Linq; 11 | using System.Windows.Input; 12 | using System.Windows.Media.Imaging; 13 | using System.Security.Principal; 14 | using System.Runtime.InteropServices; 15 | using System.Text; 16 | using System.Windows.Media.Media3D; 17 | 18 | 19 | namespace OpenStartScreen 20 | { 21 | public partial class MainWindow : Window 22 | { 23 | private bool isZoomedOut = false; 24 | private ScaleTransform scaleTransform; 25 | private double targetVerticalOffset; 26 | private DateTime animationStartTime; 27 | private TimeSpan animationDuration; 28 | [DllImport("user32.dll", CharSet = CharSet.Auto)] 29 | private static extern int SystemParametersInfo(int uAction, int uParam, StringBuilder lpvParam, int fuWinIni); 30 | 31 | public MainWindow() 32 | { 33 | InitializeComponent(); 34 | LoadStartMenuItems(); 35 | LoadPinnedItems(); 36 | this.WindowState = WindowState.Maximized; 37 | GridsPanel.AllowDrop = true; 38 | DataContext = new UserCard(); 39 | 40 | scaleTransform = new ScaleTransform(1.0, 1.0); 41 | var translateTransform = new TranslateTransform(); 42 | var transformGroup = new TransformGroup(); 43 | transformGroup.Children.Add(scaleTransform); 44 | transformGroup.Children.Add(translateTransform); 45 | 46 | GridsPanel.LayoutTransform = transformGroup; 47 | this.KeyDown += MainWindow_KeyDown; 48 | 49 | GridsPanel.Drop += GridsPanel_Drop; 50 | GridsPanel.DragOver += GridsPanel_DragOver; 51 | } 52 | 53 | 54 | 55 | private void MainWindow_KeyDown(object sender, KeyEventArgs e) 56 | { 57 | if (e.Key == Key.Z) 58 | { 59 | ToggleZoom(); 60 | } 61 | } 62 | 63 | private void ToggleZoom() 64 | { 65 | double newScale = isZoomedOut ? 1.0 : 0.3; 66 | var transformGroup = (TransformGroup)GridsPanel.LayoutTransform; 67 | var scaleTransform = (ScaleTransform)transformGroup.Children[0]; 68 | var translateTransform = (TranslateTransform)transformGroup.Children[1]; 69 | 70 | DoubleAnimation scaleXAnimation = new DoubleAnimation 71 | { 72 | To = newScale, 73 | Duration = TimeSpan.FromSeconds(0.2), 74 | EasingFunction = new CubicEase { EasingMode = EasingMode.EaseInOut } 75 | }; 76 | 77 | DoubleAnimation scaleYAnimation = new DoubleAnimation 78 | { 79 | To = newScale, 80 | Duration = TimeSpan.FromSeconds(0.2), 81 | EasingFunction = new CubicEase { EasingMode = EasingMode.EaseInOut } 82 | }; 83 | 84 | scaleTransform.BeginAnimation(ScaleTransform.ScaleXProperty, scaleXAnimation); 85 | scaleTransform.BeginAnimation(ScaleTransform.ScaleYProperty, scaleYAnimation); 86 | 87 | double translateX = isZoomedOut ? 0 : (GridsPanel.ActualWidth * (1 - newScale)) / 2; 88 | double translateY = isZoomedOut ? 0 : (GridsPanel.ActualHeight * (1 - newScale)) / 2; 89 | 90 | DoubleAnimation translateXAnimation = new DoubleAnimation 91 | { 92 | To = translateX, 93 | Duration = TimeSpan.FromSeconds(0.2), 94 | EasingFunction = new CubicEase { EasingMode = EasingMode.EaseInOut } 95 | }; 96 | 97 | DoubleAnimation translateYAnimation = new DoubleAnimation 98 | { 99 | To = translateY, 100 | Duration = TimeSpan.FromSeconds(0.2), 101 | EasingFunction = new CubicEase { EasingMode = EasingMode.EaseInOut } 102 | }; 103 | 104 | translateTransform.BeginAnimation(TranslateTransform.XProperty, translateXAnimation); 105 | translateTransform.BeginAnimation(TranslateTransform.YProperty, translateYAnimation); 106 | 107 | isZoomedOut = !isZoomedOut; 108 | } 109 | 110 | 111 | private const int SPI_GETDESKWALLPAPER = 0x0073; 112 | private const int MAX_PATH = 260; 113 | 114 | private string GetWallpaperPath() 115 | { 116 | var wallpaperPath = new StringBuilder(MAX_PATH); 117 | SystemParametersInfo(SPI_GETDESKWALLPAPER, MAX_PATH, wallpaperPath, 0); 118 | return wallpaperPath.ToString(); 119 | } 120 | 121 | private void GoToApps_Click(object sender, RoutedEventArgs e) 122 | { 123 | double newOffset = scrollViewer.VerticalOffset + scrollViewer.ViewportHeight; 124 | AnimateScrollViewer(scrollViewer, newOffset, TimeSpan.FromSeconds(1)); 125 | } 126 | 127 | private void GoToStart_Click(object sender, RoutedEventArgs e) 128 | { 129 | double newOffset = scrollViewer.VerticalOffset - scrollViewer.ViewportHeight; 130 | AnimateScrollViewer(scrollViewer, newOffset, TimeSpan.FromSeconds(1)); 131 | } 132 | 133 | private void AnimateScrollViewer(ScrollViewer scrollViewer, double toValue, TimeSpan duration) 134 | { 135 | targetVerticalOffset = toValue; 136 | animationDuration = duration; 137 | animationStartTime = DateTime.Now; 138 | 139 | CompositionTarget.Rendering += OnCompositionTargetRendering; 140 | } 141 | 142 | private void OnCompositionTargetRendering(object sender, EventArgs e) 143 | { 144 | var elapsed = DateTime.Now - animationStartTime; 145 | if (elapsed >= animationDuration) 146 | { 147 | scrollViewer.ScrollToVerticalOffset(targetVerticalOffset); 148 | CompositionTarget.Rendering -= OnCompositionTargetRendering; 149 | } 150 | else 151 | { 152 | double progress = elapsed.TotalMilliseconds / animationDuration.TotalMilliseconds; 153 | double currentOffset = scrollViewer.VerticalOffset; 154 | double newOffset = currentOffset + (targetVerticalOffset - currentOffset) * progress; 155 | scrollViewer.ScrollToVerticalOffset(newOffset); 156 | } 157 | } 158 | private const string StartMenuPath = @"C:\ProgramData\Microsoft\Windows\Start Menu\Programs"; 159 | private static string PinnedStartMenuPath = Environment.ExpandEnvironmentVariables(@"%AppData%\Microsoft\Internet Explorer\Quick Launch\User Pinned\StartMenu"); 160 | 161 | 162 | 163 | 164 | private T FindParent(DependencyObject child) where T : DependencyObject 165 | { 166 | DependencyObject parentObject = VisualTreeHelper.GetParent(child); 167 | if (parentObject == null) 168 | return null; 169 | 170 | if (parentObject is T parent) 171 | return parent; 172 | else 173 | return FindParent(parentObject); 174 | } 175 | 176 | private bool isFirstGridAdded = false; 177 | 178 | 179 | 180 | private void LoadStartMenuItems() 181 | { 182 | var programFiles = Directory.EnumerateFiles(StartMenuPath, "*.lnk", SearchOption.AllDirectories); 183 | var rootCategory = new ProgramCategory("Other Programs"); 184 | 185 | var categories = new Dictionary 186 | { 187 | { "Other Programs", rootCategory } 188 | }; 189 | 190 | foreach (var file in programFiles) 191 | { 192 | string targetPath = ShortcutResolver.Resolve(file); 193 | if (!string.IsNullOrEmpty(targetPath) && File.Exists(targetPath)) 194 | { 195 | var relativePath = Path.GetRelativePath(StartMenuPath, file); 196 | var directory = Path.GetDirectoryName(relativePath); 197 | 198 | if (string.IsNullOrEmpty(directory) || directory == ".") 199 | { 200 | rootCategory.Items.Add(file); 201 | } 202 | else 203 | { 204 | if (!categories.ContainsKey(directory)) 205 | { 206 | categories[directory] = new ProgramCategory(directory); 207 | } 208 | categories[directory].Items.Add(file); 209 | } 210 | } 211 | } 212 | 213 | DisplayCategories(categories); 214 | } 215 | 216 | private void LoadPinnedItems() 217 | { 218 | GridsPanel.Children.Clear(); 219 | _allTiles.Clear(); 220 | 221 | var desktopTileInfo = CreateDesktopTileInfo(); 222 | if (desktopTileInfo != null) 223 | { 224 | desktopTileInfo.Tile = CreateTile(desktopTileInfo); 225 | _allTiles.Add(desktopTileInfo); 226 | } 227 | 228 | var pinnedFiles = Directory.EnumerateFiles(PinnedStartMenuPath, "*.lnk", SearchOption.TopDirectoryOnly); 229 | foreach (var file in pinnedFiles) 230 | { 231 | var tileInfo = CreatePinnedProgramTileInfo(file); 232 | if (tileInfo != null) 233 | { 234 | tileInfo.Tile = CreateTile(tileInfo); 235 | _allTiles.Add(tileInfo); 236 | } 237 | } 238 | 239 | ReorganizeTiles(); 240 | } 241 | 242 | 243 | private void MinimizeButton_Click(object sender, RoutedEventArgs e) 244 | { 245 | this.WindowState = WindowState.Minimized; 246 | } 247 | } 248 | } --------------------------------------------------------------------------------