Пример #1
0
        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);
        }
Пример #2
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);
        }
Пример #3
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);
            }
        }
Пример #4
0
        private void LoadDefaultIcon(string Location)
        {
            Image img = LayoutObjects.CreateImage();

            img.Source = LayoutObjects.GetIcon(Location);
            TheEventsHolder.Children.Add(img);
        }
Пример #5
0
        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);
        }
Пример #6
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);
        }
Пример #7
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));
     }
 }
Пример #8
0
        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;
        }
Пример #9
0
        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);
        }
Пример #10
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;
 }
Пример #11
0
 private void Groups_tb_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
 {
     LayoutObjects.UnSealTextBox(sender as TextBox);
 }
Пример #12
0
 public void CreateIconFromexe(string Location)
 {
     System.Windows.Controls.Image img = LayoutObjects.CreateImage();
     img.Source   = LayoutObjects.GetIcon(Location);
     ShortcutIcon = img;
 }
Пример #13
0
 private void EditTextButton_g_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
 {
     LayoutObjects.UnSealTextBox(FileName_beta);
 }
Пример #14
0
 private void TextBox_LostFocus(object sender, RoutedEventArgs e)
 {
     LayoutObjects.SealTextBox(sender as TextBox);
 }