Example #1
0
        protected void ShowAboutWindow()
        {
            var textPanelList = new List <Tuple <FrameworkElement, FrameworkElement> >();

            textPanelList.Add(WpfHelper.CreateTuple("Version", AppVersion));
            textPanelList.Add(WpfHelper.CreateTuple("Developer", "myT"));
            var textPanel = WpfHelper.CreateDualColumnPanel(textPanelList, 100, 1);

            var image = new System.Windows.Controls.Image();

            image.HorizontalAlignment = HorizontalAlignment.Right;
            image.VerticalAlignment   = VerticalAlignment.Top;
            image.Margin  = new Thickness(5);
            image.Stretch = Stretch.None;
            image.Source  = AboutIcon.ToImageSource();

            var rootPanel = new StackPanel();

            rootPanel.HorizontalAlignment = HorizontalAlignment.Stretch;
            rootPanel.VerticalAlignment   = VerticalAlignment.Stretch;
            rootPanel.Margin      = new Thickness(5);
            rootPanel.Orientation = Orientation.Horizontal;
            rootPanel.Children.Add(textPanel);
            rootPanel.Children.Add(image);

            var window = new Window();

            window.WindowStyle   = WindowStyle.ToolWindow;
            window.ResizeMode    = ResizeMode.NoResize;
            window.Background    = new SolidColorBrush(System.Windows.SystemColors.ControlColor);
            window.ShowInTaskbar = false;
            window.Title         = "About UberMmeMuxer";
            window.Content       = rootPanel;
            window.Width         = 240;
            window.Height        = 100;
            window.Left          = MainWindow.Left + (MainWindow.Width - window.Width) / 2;
            window.Top           = MainWindow.Top + (MainWindow.Height - window.Height) / 2;
            window.Icon          = AboutIcon.ToImageSource();
            window.ShowDialog();
        }
Example #2
0
        public static ImageSource LoadSmallIcon(string processFilePath)
        {
            var shinfo = new Shell32.SHFILEINFO();

            IntPtr hBitmap = Shell32.SHGetFileInfo(processFilePath, 0, ref shinfo, Marshal.SizeOf(shinfo), Shell32.SHGFI_ICON | Shell32.SHGFI_SMALLICON);

            if (hBitmap == (IntPtr)0)
            {
                return(null);
            }

            System.Drawing.Icon ico = System.Drawing.Icon.FromHandle(shinfo.hIcon);
            var source = ico.ToImageSource();

            return(source);
        }
Example #3
0
        internal void GetChildren()
        {
            Children.Clear();

            try
            {
                foreach (DirectoryInfo dir in new DirectoryInfo(FullName).GetDirectories().OrderBy(x => x.Name).ToArray())
                {
                    ShellObject  shellFolder = ShellObject.FromParsingName(dir.FullName.ToString());
                    BitmapSource shellThumb  = shellFolder.Thumbnail.SmallBitmapSource;

                    Folder newItem = new Folder
                    {
                        Name     = dir.ToString(),
                        Icon     = shellThumb,
                        FullName = dir.FullName,
                    };


                    try
                    {
                        newItem.CountOfFolders = new DirectoryInfo(dir.FullName).GetDirectories().Length.ToString();
                    }
                    catch (UnauthorizedAccessException ex)
                    {
                        newItem.CountOfFolders = "Отказано в доступе";
                    }

                    try
                    {
                        newItem.CountOfFiles = new DirectoryInfo(dir.FullName).GetFiles().Length.ToString();
                    }
                    catch (UnauthorizedAccessException ex)
                    {
                        newItem.CountOfFiles = "Отказано в доступе";
                    }

                    try
                    {
                        newItem.CreationTime = dir.CreationTime.ToString(CultureInfo.InvariantCulture);
                    }
                    catch (UnauthorizedAccessException ex)
                    {
                    }


                    newItem.Children.Add(new Element
                    {
                        Name     = "*",
                        Icon     = null,
                        FullName = dir.FullName
                    });

                    Children.Add(newItem);
                }

                foreach (FileInfo file in new DirectoryInfo(FullName).GetFiles().OrderBy(x => x.Name).ToArray())
                {
                    System.Drawing.Icon icon = (System.Drawing.Icon)System.Drawing.Icon.ExtractAssociatedIcon(file.FullName.ToString());


                    if (file.Extension.ToLower() == ".jpg" || file.Extension.ToLower() == ".jpeg" || file.Extension.ToLower() == ".bmp" || file.Extension.ToLower() == ".png")
                    {
                        Children.Add(new CustomImage
                        {
                            Name         = file.ToString(),
                            Icon         = icon.ToImageSource(),
                            FullName     = file.FullName.ToString(),
                            Size         = ByteSize.FromBytes(file.Length).ToString(),
                            CreationTime = file.CreationTime.ToString(CultureInfo.InvariantCulture)
                        });
                    }
                    else
                    {
                        Children.Add(new CustomFile
                        {
                            Name         = file.ToString(),
                            Icon         = icon.ToImageSource(),
                            FullName     = file.FullName,
                            Size         = ByteSize.FromBytes(file.Length).ToString(),
                            CreationTime = file.CreationTime.ToString(CultureInfo.InvariantCulture)
                        });
                    }
                }
            }
            catch (UnauthorizedAccessException ex)
            {
                Folder newIFolder = new Folder()
                {
                    Name = "Отказано в доступе"
                };
                Children.Add(newIFolder);
            }
        }