Пример #1
0
        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);
        }
Пример #2
0
        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);
            }
        }
Пример #3
0
        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);
        }
Пример #4
0
 //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));
     }
 }
Пример #5
0
 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;
 }
Пример #6
0
 public void CreateIconFromImage(string Location)
 {
     System.Windows.Controls.Image img = LayoutObjects.CreateImage();
     img.Source   = LayoutObjects.GetImageSource(Location);
     ShortcutIcon = img;
 }