public void AddButton(String imageSrc, String path, FunctionsImplementations.Size size, Thickness margin) { Console.WriteLine(defaultMargin); Button b = new Button(); b.Style = Application.Current.Resources["ButtonRevealStyle"] as Style; if (imageSrc != null) { b.Content = new BitmapImage(new Uri(imageSrc)); } else { MessageBox.Show("No button icon, using default", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning); } b.Width = size.width; b.Height = size.height; b.Margin = FunctionsImplementations.AddMargin(margin, defaultMargin); b.Tag = path; // Throwing path into button properties for shortcut b.AddHandler(Button.ClickEvent, new RoutedEventHandler(b_Click)); grid.Children.Add(b); }
private void Button_Click(object sender, RoutedEventArgs e) { IntPtr TaskBar = FunctionsImplementations.FindWindow("Shell_TrayWnd", null); // Connect to taskbar if (TaskBar != (IntPtr)0) { hwndButton = FunctionsImplementations.FindWindowEx(TaskBar, IntPtr.Zero, "Start", null); // Connect to start menu tooltip if (hwndButton != (IntPtr)0) { FunctionsImplementations.EnableWindow(hwndButton, false); FunctionsImplementations.GetWindowRect(hwndButton, ref Hooks.buttonRect); hook.Hook(); } else { MessageBox.Show("Failed to connect to start menu", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } } else { MessageBox.Show("Failed to connect to taskbar", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } }
private void AcrylicWindow_Closing(object sender, CancelEventArgs e) { hook.UnHook(); // Unhook on window close FunctionsImplementations.EnableWindow(hwndButton, true); }