Пример #1
0
        /*
         * protected helper methods
         */

        protected static Image GetImage(FileSystemInfo file, ConfigureWpfFiler config)
        {
            System.Drawing.Icon ico;
            Image img = new Image();

            if ((file.Attributes & FileAttributes.Directory) == FileAttributes.Directory)
            {
                ico = config.DefaultFolderIcon;
            }
            else
            {
                ico = config.DefaultFileIcon;
            }

            BitmapSource bmp = Imaging.CreateBitmapSourceFromHIcon(
                ico.Handle, Int32Rect.Empty,
                BitmapSizeOptions.FromEmptyOptions()
                );

            ico.Dispose();
            img.Source = bmp;
            img.Width  = config.IconSize;
            img.Height = config.IconSize;
            img.HorizontalAlignment = HorizontalAlignment.Center;
            img.VerticalAlignment   = VerticalAlignment.Center;
            return(img);
        }
Пример #2
0
        // Aliases file
        // Does not modify config
        public FileButton(FileSystemInfo file, ConfigureWpfFiler config)
        {
            Margin          = new Thickness(4);
            BorderThickness = new Thickness(0);
            Background      = config.BackgroundBrush;
            info            = file;

            textBlock = new TextBlock
            {
                TextAlignment     = TextAlignment.Center,
                TextWrapping      = TextWrapping.Wrap,
                VerticalAlignment = VerticalAlignment.Bottom,
                Text = info.Name
            };

            panel = new StackPanel
            {
                Orientation = Orientation.Vertical,
                Width       = config.IconSize
            };

            Image img = GetImage(info, config);

            panel.Children.Add(img);
            panel.Children.Add(textBlock);

            AddChild(panel);
        }
 public MainWindow()
 {
     InitializeComponent();
     config = new ConfigureWpfFiler();
     config.LoadConfiguration();
     DriveInfo[] drives = DriveInfo.GetDrives();
     foreach (DriveInfo d in drives)
     {
         Tree.Items.Add(CreateTreeViewItem(d));
     }
     Tabs.Items.Add(new CloseableTab());
 }