private Grid CreateRoundButton(string Text, int Order) { Grid button = new Grid(); button.Width = 20; button.Height = 20; TextBlock tb = new TextBlock(); Panel.SetZIndex(tb, 20); tb.Text = Text; tb.FontFamily = new System.Windows.Media.FontFamily("Segoe MDL2 Assets"); tb.TextAlignment = TextAlignment.Center; tb.VerticalAlignment = VerticalAlignment.Center; Ellipse DelButton = LayoutObjects.CreateEllipse(); button.MouseEnter += (sender, e) => Button_MouseEnter(DelButton); button.MouseLeave += (sender, e) => Button_MouseLeave(DelButton); button.Children.Add(DelButton); button.Children.Add(tb); SetTop(button, DelButton.Height * -1); SetLeft(button, TheItemHolder.Width - button.Width * Order - 2 * Order); Panel.SetZIndex(button, 10); return(button); }
private void ChangeIcon_Click(object sender, RoutedEventArgs e) { MenuItem mnu = sender as MenuItem; StackPanel mystp = null; if (mnu != null) { ContextMenu MyContextMenu = (ContextMenu)mnu.Parent; mystp = MyContextMenu.PlacementTarget as StackPanel; } Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog(); dlg.DefaultExt = ".jpg"; dlg.Filter = SupportedIconExtensions; bool?result = dlg.ShowDialog(); if (result == true) { IconSourceLocation = dlg.FileName; if (Path.GetExtension(dlg.FileName).ToUpper() == ".ICO" || Path.GetExtension(dlg.FileName).ToUpper() == ".EXE") { ChangeImage(LayoutObjects.GetIcon(dlg.FileName)); } else { ChangeImage(LayoutObjects.GetImageSource(dlg.FileName)); } } Data.SaveIcons(HomePage.AppsList); }
private void EditBackgroundButton_g_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) { Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog(); dlg.DefaultExt = ".jpg"; dlg.Filter = SupportedIconExtensions; bool?result = dlg.ShowDialog(); if (result == true) { IconSourceLocation = dlg.FileName; if (System.IO.Path.GetExtension(dlg.FileName).ToUpper() == ".ICO" || System.IO.Path.GetExtension(dlg.FileName).ToUpper() == ".EXE") { ChangeImage(LayoutObjects.GetIcon(dlg.FileName)); } else { ChangeImage(LayoutObjects.GetImageSource(dlg.FileName)); } //Remove the Text Before Replacing it with an Image foreach (object child in TheEventsHolder.Children) { if (child is Viewbox) { TheEventsHolder.Children.Remove(child as UIElement); break; } } Data.SaveShortcuts(Shortcuts.ShortcutItems); } }
private void LoadDefaultIcon(string Location) { Image img = LayoutObjects.CreateImage(); img.Source = LayoutObjects.GetIcon(Location); TheEventsHolder.Children.Add(img); }
private void Groups_tb_LostFocus(object sender, RoutedEventArgs e) { LayoutObjects.SealTextBox(sender as TextBox); List <TextBox> GroupNames = new List <TextBox>(); GroupNames.Add(Group1_tb); GroupNames.Add(Group2_tb); GroupNames.Add(Group3_tb); Data.SaveGroupNames(GroupNames); }
private static void SetImageAsBackground(string location) { Image img = new Image(); img.Source = LayoutObjects.GetImageSource(location); img.Width = ParentCanvas.Width; img.Height = ParentCanvas.Height; img.Stretch = Stretch.Fill; ParentCanvas.Children.Add(img); }
//Load The Image which The User Have Choosen private void LoadCustomDesign(string ImageLocation) { if (System.IO.Path.GetExtension(ImageLocation).ToUpper() == ".ICO" || System.IO.Path.GetExtension(ImageLocation).ToUpper() == ".EXE") { ChangeImage(LayoutObjects.GetIcon(ImageLocation)); } else { ChangeImage(LayoutObjects.GetImageSource(ImageLocation)); } }
public AppInfo(string file, string IconSource = "Default") : this() { //To get the original exe file instead of shortcut ShortCutLocation = Path.GetExtension(file).ToLower() == ".lnk" ? LayoutObjects.GetOriginalFileURL(file) : file; FileName = LayoutObjects.CreateTextBlock(System.IO.Path.GetFileName(ShortCutLocation)); //Check if a directory try { if (((FileAttributes)System.IO.File.GetAttributes(file)).HasFlag(FileAttributes.Directory)) { CreateIconFromImage("pack://application:,,,/Resources/Folder_Icon.png"); } else { //check If Icon is new created or loaded file = IconSource == "Default" ? file : IconSource; //if loaded the Icon will Be change IconSourceLocation = GetExtensionIconUrl(file); if (!Object.ReferenceEquals(IconSourceLocation, null)) { IconSourceLocation = IconSourceLocation != "" ? IconSourceLocation : file; CreateIconFromImage(IconSourceLocation != "" ? IconSourceLocation : file); } else { IconSourceLocation = ShortCutLocation; CreateIconFromexe(ShortCutLocation); } } AddElements(); } catch (FileNotFoundException) { MessageBox.Show("A file is missing\nCan't find " + file); IsThereisErrors = true; } catch (DirectoryNotFoundException) { MessageBox.Show("Directory is missing\n Cant find " + file); IsThereisErrors = true; } catch (Exception e) { MessageBox.Show("Error happened while adding " + file + " \nMay save File corrupted or no permission to access this file\ndeleted shortcut from DM\nerror: " + e.Message); IsThereisErrors = true; } return; }
private void LoadDefaultDesign() { IconSourceLocation = "Default"; //add them to the holder Viewbox viewbox = new Viewbox(); TextBlock tb = LayoutObjects.CreateTextBlock(System.IO.Path.GetFileNameWithoutExtension(ShortCutLocation)); tb.Foreground = new SolidColorBrush((System.Windows.Media.Color) System.Windows.Media.ColorConverter.ConvertFromString (AppTheme.Foreground)); viewbox.Child = tb; TheEventsHolder.Children.Add(viewbox); }
public ShortcutItem(string file, string IconSource = "Default") : this() { ShortCutLocation = System.IO.Path.GetExtension(file).ToLower() == ".lnk" ? LayoutObjects.GetOriginalFileURL(file) : file; // FileName = LayoutObjects.CreateTextBlock(System.IO.Path.GetFileNameWithoutExtension(ShortCutLocation)); FileName_beta = CreateTextBox(System.IO.Path.GetFileNameWithoutExtension(ShortCutLocation)); LoadGeneralDesign(); //Check if a directory try { //set the default folder Image if (((FileAttributes)System.IO.File.GetAttributes(file)).HasFlag(FileAttributes.Directory)) { //CreateIconFromImage("pack://application:,,,/Resources/Folder_Icon.png"); ShortcutIcon.Source = LayoutObjects.GetImageSource("pack://application:,,,/Resources/Folder_Icon.png"); LoadFolderDesign(); } //else set the the Default Design else { if (IconSource == "Default") { //LoadDefaultDesign(); LoadDefaultIcon(ShortCutLocation); } else { LoadCustomDesign(IconSource); } //to save Icons location when its loaded IconSourceLocation = IconSource; } } catch (FileNotFoundException) { MessageBox.Show("A file is missing\nCan't find " + file); IsThereisErrors = true; } catch (DirectoryNotFoundException) { MessageBox.Show("Directory is missing\n Cant find " + file); IsThereisErrors = true; } catch (Exception e) { MessageBox.Show("Error happened while adding " + file + " \nMay save File corrupted or no permission to access this file\ndeleted shortcut from DM\nerror: " + e.Message); IsThereisErrors = true; } SizeChanged += ShortcutItem_SizeChanged; return; }
private void Groups_tb_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { LayoutObjects.UnSealTextBox(sender as TextBox); }
public void CreateIconFromexe(string Location) { System.Windows.Controls.Image img = LayoutObjects.CreateImage(); img.Source = LayoutObjects.GetIcon(Location); ShortcutIcon = img; }
private void EditTextButton_g_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) { LayoutObjects.UnSealTextBox(FileName_beta); }
private void TextBox_LostFocus(object sender, RoutedEventArgs e) { LayoutObjects.SealTextBox(sender as TextBox); }