コード例 #1
0
ファイル: MainWindow.xaml.cs プロジェクト: rebootus/Esthar
        private void TryCreateButtonForFileSystemItem(string path)
        {
            bool   isDirectory = Directory.Exists(path);
            string extension   = Path.GetExtension(path);

            if (!isDirectory && !String.Equals(extension, ".exe", StringComparison.OrdinalIgnoreCase))
            {
                return;
            }

            BitmapSource imageSource = ShellHelper.ExtractAssociatedIcon(path);
            Image        image       = new Image {
                Source = imageSource
            };
            Button button = new Button {
                Content = image, Tag = path, ToolTip = path, Style = (Style)Application.Current.Resources["XamlIconStyle"]
            };

            if (isDirectory)
            {
                button.Click += OnDirectoryButtonClick;
            }
            else
            {
                button.Click += OnExecutableButtonClick;
            }

            BottomPanel.Children.Add(button);
        }