v13可以正常用,v17无法正常打开窗口

使用问题 · 88 次浏览
用户1626159636... 创建于 4天10小时前

v13可以正常用,v17无法正常打开窗口


回复内容
困困君 4天10小时前
#1

v13和v17啥意思?

困困君 最后更新于 4天10小时前
用户1626159636... 4天9小时前 :


用户1626159636... 回复 困困君 4天9小时前 :

最新的17版,不能打开,前一个版本v13是可以正常使用的

困困君 回复 用户1626159636... 4天9小时前 :

你调试一下,看看有无错误信息

困困君 回复 用户1626159636... 4天9小时前 :

我这边一切都是正常的

困困君 回复 用户1626159636... 4天9小时前 :

我想到可能时调用媒体的线程没有没释放。没重要工作的话可以关机重启该动作。

用户1626159636... 回复 困困君 4天7小时前 :

之前在Win11的资源管理器和Total commander第三方文件管理器,都是可以使用的,但是新版不行了,调试运行的代码部分贴在下面了。如果需要全部的,可以留言。

通过按钮点击动作,或快捷键执行,都不能正常使用

用户1626159636... 最后更新于 3天18小时前
用户1626159636... 4天7小时前
#2
33获取选择的文件(夹)/选择特定文件获取选择的文件 -
[in]失败后中止动作【值/表达式】False
[in]操作类型【值/表达式】getSelection
[in]等待剪贴板时间【值/表达式】200
[in]排序文件列表【值/表达式】Default
通过Win32接口获取选中的文件失败:不是资源管理器窗口
用户1626159636... 4天7小时前
#3
2384.2.0自定义窗口显示窗口
[in]失败后停止【值/表达式】False
[in]操作类型【值/表达式】Show
[in]窗口标识【变量 windowId】
[in]窗口XAML代码【值/表达式】<hc:Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"\r\n xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"\r\n xmlns:hc="https://handyorg.github.io/handycontrol"\r\n xmlns:qk="https://getquicker.net"\r\n Height="600" Width="1200" Topmost="True">\r\n \t<hc:Window.NonClientAreaContent>\r\n <qk:WindowToolsControl />\r\n </hc:Window.NonClientAreaContent>\r\n <Window.Resources>\r\n <!-- 定义 DataTemplate 作为静态资源 -->\r\n <DataTemplate x:Key="FileSystemItemTemplate">\r\n <StackPanel Orientation="Horizontal" ToolTip="{Binding Path}">\r\n <qk:IconControl Width="20" Height="20" Icon="{Binding Icon}" Margin="2,0" />\r\n <TextBlock Text="{Binding Name}" VerticalAlignment="Center" />\r\n </StackPanel>\r\n </DataTemplate>\r\n </Window.Resources>\r\n <Grid>\r\n <!-- 行列定义 -->\r\n <Grid.RowDefinitions>\r\n <RowDefinition Height="Auto"/>\r\n <RowDefinition Height="*"/>\r\n </Grid.RowDefinitions>\r\n <Grid.ColumnDefinitions>\r\n \t<ColumnDefinition Width="150"/> <!-- 侧边栏 -->\r\n <ColumnDefinition Width="3*"/>\r\n <ColumnDefinition Width="2*"/>\r\n </Grid.ColumnDefinitions>\r\n \r\n <!-- 顶部按钮栏 -->\r\n <StackPanel Grid.Row="0" Grid.ColumnSpan="2" Orientation="Horizontal" Background="#EEE" Margin="5">\r\n <Button x:Name="返回" Content="返回" Width="60" Margin="5"/>\r\n <Button Content="剪切" Width="60" Margin="5" IsEnabled="False"/>\r\n <Button Content="复制" Width="60" Margin="5" IsEnabled="False"/>\r\n <Button Content="粘贴" Width="60" Margin="5" IsEnabled="False"/>\r\n <Button Content="重命名" Width="60" Margin="5" IsEnabled="False"/>\r\n <Button Content="删除" Width="60" Margin="5" IsEnabled="False"/>\r\n </StackPanel>\r\n \r\n \t\t<!-- 侧边栏(快速访问路径) -->\r\n <ListBox x:Name="QuickAccessList" Grid.Row="1" Grid.Column="0" ItemTemplate="{StaticResource FileSystemItemTemplate}" />\r\n \t\t\r\n <!-- 左侧文件列表 -->\r\n <ListView x:Name="FileListView" Grid.Row="1" Grid.Column="1">\r\n <ListView.View>\r\n <GridView>\r\n <GridViewColumn Header="名称" Width="250" CellTemplate="{StaticResource FileSystemItemTemplate}" />\r\n <GridViewColumn Header="修改日期" DisplayMemberBinding="{Binding Modified}" Width="120"/>\r\n <GridViewColumn Header="类型" DisplayMemberBinding="{Binding Type}" Width="80"/>\r\n <GridViewColumn Header="大小" DisplayMemberBinding="{Binding Size}" Width="80"/>\r\n </GridView>\r\n </ListView.View>\r\n </ListView>\r\n \r\n <!-- 右侧文件预览区域 -->\r\n <Border Grid.Row="1" Grid.Column="2" BorderThickness="1" BorderBrush="Gray">\r\n <ContentControl x:Name="PreviewContainer" VerticalAlignment="Stretch" HorizontalAlignment="Stretch"/>\r\n </Border>\r\n </Grid>\r\n </hc:Window>\r\n
[in]窗口位置【值/表达式】CenterScreen
[in]数据映射【值/表达式】initialPath:{initialPath}\r\n showInTaskbar:{showInTaskbar}
[in]辅助C#代码【值/表达式】//css_reference F:\Game\HDT\SharpCompress.dll\r\n using System.Windows;\r\n using System.Collections.Generic;\r\n using Quicker.Public;\r\n \r\n using System.IO;\r\n using System.Windows.Controls;\r\n using System.Windows.Media;\r\n using System.Windows.Media.Imaging;\r\n using System.Windows.Documents;\r\n using System.Diagnostics;\r\n using Quicker.Utilities;\r\n using System.Collections.ObjectModel; // ObservableCollection\r\n using System.Windows.Input; // KeyEventArgs\r\n using System.Windows.Threading; // DispatcherTimer\r\n using System.Windows.Controls.Primitives; // DragStartedEventHandler\r\n using System.Threading.Tasks; // Task\r\n using System.Windows.Data; // Binding\r\n using System.IO.Compression; // ZipArchive\r\n using SharpCompress.Archives;\r\n \r\n \r\n \r\n public static Window win;\r\n public static ICustomWindowContext winContext;\r\n \r\n public static ListBox QuickAccessList;\r\n public static ListView FileListView;\r\n public static ContentControl PreviewContainer;\r\n \r\n public static string currentFolder; // 当前文件夹\r\n public static ObservableCollection<FileItem> quickAccessList;\r\n \r\n // 定义菜单项配置\r\n \r\n public static readonly List<menuItem> _menuConfigs = new List<menuItem>\r\n {\r\n new menuItem\r\n {\r\n Header = "复制文件地址",\r\n Icon = "fa:Regular_Copy:#3FB582",\r\n Action = (FileItem fileItem) => Clipboard.SetText(fileItem.Path)\r\n }\r\n };\r\n \r\n public class FileItem\r\n {\r\n public string Name { get; set; }\r\n public string Path { get; set; }\r\n public string Type { get; set; }\r\n public string Size { get; set; }\r\n public string Modified { get; set; }\r\n public string Icon { get; set; }\r\n }\r\n // 定义Zip文件结构\r\n public class ZipFileItem\r\n {\r\n public string FileName { get; set; }\r\n public string FileSize { get; set; }\r\n public string LastModified { get; set; }\r\n }\r\n \r\n public class menuItem\r\n {\r\n public string Header { get; set; }\r\n public string Icon { get; set; }\r\n public Action<FileItem> Action { get; set; }\r\n }\r\n \r\n public static void OnWindowCreated(Window _win, IDictionary<string, object> dataContext, ICustomWindowContext _winContext){\r\n \r\n \twin=_win;\r\n \twinContext=_winContext;\r\n \t\r\n \twin.ShowInTaskbar=(bool)dataContext["showInTaskbar"];\r\n \t\r\n \tQuickAccessList=win.FindName("QuickAccessList") as ListBox ;\r\n \tQuickAccessList.SelectionChanged += OnQuickAccessSelected;\r\n \t\r\n \tFileListView=win.FindName("FileListView") as ListView;\r\n \tFileListView.SelectionChanged += OnFileSelected;\r\n \tFileListView.MouseDoubleClick += OnFileDoubleClicked;\r\n \t\r\n \tFileListView.ItemContainerGenerator.StatusChanged += ItemContainerGenerator_StatusChanged;\r\n \tFileListView.KeyDown += OnFileListKeyDown;\r\n \t\r\n \tPreviewContainer=win.FindName("PreviewContainer") as ContentControl;\r\n \t\r\n \t// 快速访问\r\n \tInitializeQuickAccess();\r\n \t\r\n \tstring initialPath=dataContext["initialPath"].ToString();\r\n \t\r\n \tInitializeFileList(initialPath);\r\n \t\r\n \twin.PreviewKeyDown += Window_PreviewKeyDown;\r\n \t\r\n \twin.Closing += (sender, e) =>\r\n \t{\r\n \r\n \t};\r\n \t\r\n }\r\n \r\n private static void ItemContainerGenerator_StatusChanged(object sender, EventArgs e)\r\n {\r\n \tif (FileListView.ItemContainerGenerator.Status == GeneratorStatus.ContainersGenerated)\r\n \t{\r\n \t\tUpdateContextMenus();\r\n \t}\r\n }\r\n \r\n private static void UpdateContextMenus()\r\n {\r\n \tforeach (var item in FileListView.Items)\r\n \t{\r\n \t\tListViewItem listViewItem = FileListView.ItemContainerGenerator.ContainerFromItem(item) as ListViewItem;\r\n \t\tif (listViewItem != null && listViewItem.ContextMenu == null)\r\n \t\t{\r\n \t\t\tlistViewItem.ContextMenu = CreateContextMenu(listViewItem);\r\n \t\t}\r\n \t}\r\n }\r\n \r\n private static ContextMenu CreateContextMenu(ListViewItem item)\r\n {\r\n \tContextMenu contextMenu = new ContextMenu();\r\n \tFileItem selectedPerson = item.DataContext as FileItem;\r\n \r\n \t// 动态生成菜单项\r\n \tforeach (var config in _menuConfigs)\r\n \t{\r\n \t\tMenuItem menuItem = new MenuItem\r\n \t\t{\r\n \t\t\tHeader = config.Header,\r\n \t\t\tIcon = new Quicker.View.Controls.IconControl(){ Icon = config.Icon, Width = 16,Height=16}\r\n \t\t};\r\n \t\tmenuItem.Click += (s, args) => config.Action(selectedPerson);\r\n \t\tcontextMenu.Items.Add(menuItem);\r\n \t}\r\n \treturn contextMenu;\r\n }\r\n \r\n public static void OnWindowLoaded(Window win, IDictionary<string, object> dataContext,ICustomWindowContext winContext){\r\n \tFileListView.Focus();\r\n }\r\n \r\n public static bool OnButtonClicked(string controlName, object controlTag, Window win,IDictionary<string, object> dataContext,ICustomWindowContext winContext){\r\n \t\r\n \tswitch (controlName)\r\n \t{\r\n \t\tcase "返回": ReturnFolder(); break;\r\n \t\tdefault: break;\r\n \t}\r\n \treturn false;\r\n }\r\n \r\n public static void ReturnFolder()\r\n {\r\n \tvar selectFolder=currentFolder;\r\n \t\r\n \tDirectoryInfo parentDir = Directory.GetParent(currentFolder);\r\n \tif (parentDir != null)\r\n \t{\r\n \t\tstring parentPath = parentDir.FullName;\r\n \t\tLoadFiles(parentPath);\r\n \t\tSelectFileInList(selectFolder);\r\n \t\tFileListView.Focus();\r\n \t}\r\n }\r\n \r\n public static void InitializeQuickAccess()\r\n {\r\n \tList<FileItem> quickAccessItems = new List<FileItem>();\r\n \tforeach (var drive in DriveInfo.GetDrives())\r\n \t{\r\n \t\tquickAccessItems.Add(new FileItem\r\n \t\t{\r\n \t\t\tName = drive.Name,\r\n \t\t\tPath = drive.Name,\r\n \t\t\tIcon = "icon:"+drive.Name\r\n \t\t});\r\n \t}\r\n \tQuickAccessList.ItemsSource = quickAccessItems;\r\n }\r\n \r\n public static void OnQuickAccessSelected(object sender, SelectionChangedEventArgs e)\r\n {\r\n \tif (QuickAccessList.SelectedItem is FileItem)\r\n \t{\r\n \t\tvar selectedItem = QuickAccessList.SelectedItem as FileItem;\r\n \t\r\n \t\tLoadFiles(selectedItem.Path);\r\n \t}\r\n }\r\n \r\n public static void InitializeFileList(string path)\r\n {\r\n \tif (File.Exists(path))\r\n \t{\r\n \t\tstring folderPath = Path.GetDirectoryName(path);\r\n \t\tLoadFiles(folderPath);\r\n \t\tSelectFileInList(path);\r\n \t\tPreviewFile(path);\r\n \t}\r\n \telse if (Directory.Exists(path))\r\n \t{\r\n \t\tLoadFiles(path);\r\n \t}\r\n }\r\n \r\n public static void LoadFiles(string folderPath)\r\n {\t\r\n \tcurrentFolder = folderPath;\r\n \twin.Title="文件预览器:"+currentFolder;\r\n \tList<FileItem> files = new List<FileItem>();\r\n \tDirectoryInfo dirInfo = new DirectoryInfo(folderPath);\r\n \t\r\n \tforeach (var file in dirInfo.GetDirectories())\r\n \t{\r\n \t\tif ((file.Attributes & FileAttributes.Hidden) == FileAttributes.Hidden)\r\n \tcontinue; // 如果是隐藏文件夹,跳过\r\n \r\n \t\tfiles.Add(new FileItem\r\n \t\t{\r\n \t\t\tName = file.Name,\r\n \t\t\tPath = file.FullName,\r\n \t\t\tType = "文件夹",\r\n \t\t\tModified = file.LastWriteTime.ToString("yyyy-MM-dd HH:mm"),\r\n \t\t\tIcon = "icon:"+file.FullName\r\n \t\t});\r\n \t}\r\n \t\r\n \tforeach (var file in dirInfo.GetFiles())\r\n \t{\r\n \t\tif ((file.Attributes & FileAttributes.Hidden) == FileAttributes.Hidden)\r\n \tcontinue; // 如果是隐藏文件,跳过\r\n \r\n \t\tfiles.Add(new FileItem\r\n \t\t{\r\n \t\t\tName = file.Name,\r\n \t\t\tPath = file.FullName,\r\n \t\t\tType = file.Extension,\r\n \t\t\tSize = (file.Length / 1024).ToString() + " KB",\r\n \t\t\tModified = file.LastWriteTime.ToString("yyyy-MM-dd HH:mm"),\r\n \t\t\tIcon = "icon:"+file.FullName\r\n \t\t});\r\n \t}\r\n \t\r\n \tFileListView.ItemsSource = files;\r\n \t\r\n \tPreviewContainer.Content = null; // 刷新预览\r\n }\r\n \r\n public static void SelectFileInList(string filePath)\r\n {\r\n \tforeach (FileItem item in FileListView.Items)\r\n \t{\r\n \t\tif (item.Path == filePath)\r\n \t\t{\r\n \t\t\tFileListView.SelectedItem = item;\r\n \t\t\tbreak;\r\n \t\t}\r\n \t}\r\n }\r\n \r\n public static void OnFileSelected(object sender, SelectionChangedEventArgs e)\r\n {\r\n \tif (FileListView.SelectedItem is FileItem)\r\n \t{\r\n \t\tvar selectedFile = FileListView.SelectedItem as FileItem;\r\n \t\r\n \t\tPreviewFile(selectedFile.Path);\r\n \t}\r\n }\r\n \r\n public static void OnFileDoubleClicked(object sender, System.Windows.Input.MouseButtonEventArgs e)\r\n {\r\n \tif (FileListView.SelectedItem is FileItem)\r\n \t{\r\n \t\tvar selectedFile = FileListView.SelectedItem as FileItem;\r\n \t\t\r\n \t\tif (Directory.Exists(selectedFile.Path))\r\n \t\t{\r\n \t\t\tLoadFiles(selectedFile.Path);\r\n \t\t}\r\n \t\telse if (File.Exists(selectedFile.Path))\r\n \t\t{\r\n \t\t\tProcess.Start(new ProcessStartInfo(selectedFile.Path) { UseShellExecute = true });\r\n \t\t}\r\n \t}\r\n }\r\n \r\n private static void OnFileListKeyDown(object sender, KeyEventArgs e)\r\n {\r\n \t// 有焦点后,↑↓键切换选中有默认事件\r\n \tif (e.Key == Key.Enter)\r\n \t{\r\n \t\tOnFileDoubleClicked(sender, null);\r\n \t}\r\n }\r\n \r\n private static void Window_PreviewKeyDown(object sender, KeyEventArgs e)\r\n {\r\n if (e.Key == Key.Space || e.Key == Key.Escape)\r\n {\r\n \twin.Close();\r\n }else if (e.Key == Key.Back)\r\n \t{\r\n \t\tReturnFolder();\r\n \t\te.Handled = true; // 可选:标记事件已处理\r\n \t}\r\n }\r\n \r\n public static void PreviewFile(string filePath)\r\n {\r\n \tif (Directory.Exists(filePath))\r\n \t{\r\n \t\tListBox folderPreview = new ListBox();\r\n \t\tDataTemplate itemTemplate = (DataTemplate)win.FindResource("FileSystemItemTemplate"); // 从资源中获取 DataTemplate\r\n \t\tfolderPreview.ItemTemplate = itemTemplate;\r\n \t\t\r\n \t\tList<FileItem> items = new List<FileItem>();\r\n \t\tDirectoryInfo dirInfo = new DirectoryInfo(filePath);\r\n \r\n \t\tforeach (var dir in dirInfo.GetDirectories())\r\n \t\t{\r\n \t\t\tif ((dir.Attributes & FileAttributes.Hidden) == FileAttributes.Hidden)\r\n \t\tcontinue; // 如果是隐藏文件夹,跳过\r\n \t\t\r\n \t\t\titems.Add(new FileItem\r\n \t\t\t{\r\n \t\t\t\tName = dir.Name,\r\n \t\t\t\tIcon = "icon:"+dir.FullName,\r\n \t\t\t\tPath = dir.FullName\r\n \t\t\t});\r\n \t\t}\r\n \t\t\r\n \t\tforeach (var file in dirInfo.GetFiles())\r\n \t\t{\r\n \t\t\tif ((file.Attributes & FileAttributes.Hidden) == FileAttributes.Hidden)\r\n \t\tcontinue; // 如果是隐藏文件夹,跳过\r\n \t\t\r\n \t\t\titems.Add(new FileItem\r\n \t\t\t{\r\n \t\t\t\tName = file.Name,\r\n \t\t\t\tIcon = "icon:"+file.FullName,\r\n \t\t\t\tPath = file.FullName\r\n \t\t\t});\r\n \t\t}\r\n \t\t\r\n \t\tfolderPreview.ItemsSource = items; // // 设置 ItemsSource\r\n \t\tPreviewContainer.Content = folderPreview;\r\n \t\treturn;\r\n \t}\r\n \r\n \r\n string extension = Path.GetExtension(filePath).ToLower();\r\n \r\n if (extension == ".jpg" || extension == ".png" || extension == ".bmp" || extension == ".gif")\r\n {\r\n Image previewImage = new Image\r\n {\r\n Source = new BitmapImage(new Uri(filePath)),\r\n Stretch = Stretch.Uniform\r\n };\r\n PreviewContainer.Content = previewImage;\r\n }\r\n else if (extension == ".txt" || extension == ".log" || extension == ".ini" || extension == ".md")\r\n {\r\n TextBox previewText = new TextBox\r\n {\r\n Text = File.ReadAllText(filePath),\r\n IsReadOnly = true,\r\n TextWrapping = TextWrapping.Wrap,\r\n VerticalScrollBarVisibility = ScrollBarVisibility.Auto,\r\n VerticalAlignment = VerticalAlignment.Top,\r\n HorizontalAlignment = HorizontalAlignment.Left,\r\n BorderThickness = new Thickness(0)\r\n };\r\n PreviewContainer.Content = previewText;\r\n }\r\n else if (extension == ".pdf")\r\n {\r\n // WebBrowser webViewer = new WebBrowser();\r\n // webViewer.Navigate(new Uri(filePath).AbsoluteUri);\r\n // PreviewContainer.Content = webViewer;\r\n }\r\n else if (extension == ".doc" || extension == ".docx")\r\n {\r\n // Process.Start(new ProcessStartInfo(filePath) { UseShellExecute = true });\r\n }\r\n else if (extension == ".mp3" || extension == ".wav" || extension == ".flac" || extension == ".mp4" || extension == ".mkv" || extension == ".avi")\r\n {\r\n \tbool isPlaying = true; // 跟踪播放状态\r\n \tbool isDragging = false; // 标记是否正在拖动进度条\r\n \t\r\n \t// 音视频\r\n MediaElement mediaPlayer = new MediaElement\r\n {\r\n Source = new Uri(filePath), // 替换为实际文件路径\r\n LoadedBehavior = MediaState.Manual, // 允许手动控制播放/暂停\r\n UnloadedBehavior = MediaState.Close, // 在 MediaElement 控件从 UI 中卸载时自动关闭媒体。\r\n Stretch = Stretch.Uniform // 均匀缩放\r\n };\r\n Slider progressSlider = new Slider { Minimum = 0, Width = double.NaN };\r\n TextBlock timeDisplay = new TextBlock\r\n \t\t {\r\n \t\t Text = "00:00 / 00:00",\r\n \t\t FontSize = 14,\r\n \t\t Margin = new Thickness(5),\r\n \t\t TextAlignment = TextAlignment.Center\r\n \t\t };\r\n Button playPauseButton = new Button { Content = "暂停", Width = 60, Margin = new Thickness(5) };\r\n mediaPlayer.MediaOpened += (s, e) =>\r\n \t\t {\r\n \t\t if (mediaPlayer.NaturalDuration.HasTimeSpan)\r\n \t\t {\r\n \t\t progressSlider.Maximum = mediaPlayer.NaturalDuration.TimeSpan.TotalSeconds; // 初始化进度条最大值\r\n \t\t timeDisplay.Text = string.Format("00:00 / {0:D2}:{1:D2}", \r\n \t\t mediaPlayer.NaturalDuration.TimeSpan.Minutes, \r\n \t\t mediaPlayer.NaturalDuration.TimeSpan.Seconds);\r\n \t\t }\r\n \t\t };\r\n \t\t \r\n \t\t // mkv视频在调整position时容易播放失败\r\n \t\t mediaPlayer.MediaFailed += (s, e) =>\r\n \t\t {\r\n \t\t AppHelper.ShowInformation(e.ErrorException.Message);\r\n \t\t };\r\n \t\t \r\n \t\t DispatcherTimer timer = new DispatcherTimer { Interval = TimeSpan.FromMilliseconds(500) }; // 监听播放进度,更新进度条,但在拖动时不更新\r\n \t\t \r\n \t\t timer.Tick += (s, e) =>\r\n \t\t {\r\n \t\t if (!isDragging && mediaPlayer.NaturalDuration.HasTimeSpan)\r\n \t\t {\r\n \t\t progressSlider.Value = mediaPlayer.Position.TotalSeconds;\r\n \t\t timeDisplay.Text = string.Format("{0:D2}:{1:D2} / {2:D2}:{3:D2}", \r\n \t\t mediaPlayer.Position.Minutes, mediaPlayer.Position.Seconds, \r\n \t\t mediaPlayer.NaturalDuration.TimeSpan.Minutes, \r\n \t\t mediaPlayer.NaturalDuration.TimeSpan.Seconds);\r\n \t\t\t\t\t\r\n \t\t }\r\n \t\t };\r\n \t\t timer.Start();\r\n \r\n \r\n progressSlider.PreviewMouseDown += (s, e) => \r\n {\r\n \tisDragging = true;\r\n };\r\n \t\t progressSlider.PreviewMouseUp += (s, e) =>\r\n \t\t {\r\n \t\t isDragging = false;\r\n \t\t mediaPlayer.Position = TimeSpan.FromSeconds(progressSlider.Value); // 在暂停状态(Pause)下不会主动更新视频帧的显示\r\n \t\t\t};\r\n playPauseButton.Click += (s, e) =>\r\n \t\t\t{\r\n \t\t\t\r\n \t\t\t if (isPlaying) { mediaPlayer.Pause(); playPauseButton.Content = "播放"; isPlaying = false; }\r\n else { mediaPlayer.Play(); playPauseButton.Content = "暂停"; isPlaying = true; }\r\n \t\t\t};\r\n \t\t\t\r\n \t\t\tmediaPlayer.Play(); // 播放视频\r\n \r\n StackPanel mediaPreviewPanel = new StackPanel\r\n \t\t {\r\n \t\t HorizontalAlignment = HorizontalAlignment.Center,\r\n \t\t VerticalAlignment = VerticalAlignment.Center\r\n \t\t };\r\n \t\t \r\n \t\t mediaPreviewPanel.Children.Add(mediaPlayer);\r\n \t\t mediaPreviewPanel.Children.Add(progressSlider);\r\n \t\t mediaPreviewPanel.Children.Add(timeDisplay);\r\n \t\t mediaPreviewPanel.Children.Add(playPauseButton);\r\n \t\t \r\n \t\t PreviewContainer.Content = mediaPreviewPanel;\r\n }\r\n else if (extension == ".zip")\r\n {\r\n ListView zipListView = new ListView();\r\n \r\n GridView gridView = new GridView();\r\n gridView.Columns.Add(new GridViewColumn { Header = "文件名", DisplayMemberBinding = new Binding("FileName"), Width = 250 });\r\n gridView.Columns.Add(new GridViewColumn { Header = "大小", DisplayMemberBinding = new Binding("FileSize"), Width = 100 });\r\n zipListView.View = gridView;\r\n \r\n List<ZipFileItem> zipItems = new List<ZipFileItem>();\r\n \r\n using (FileStream zipToOpen = new FileStream(filePath, FileMode.Open, FileAccess.Read))\r\n using (ZipArchive archive = new ZipArchive(zipToOpen, ZipArchiveMode.Read))\r\n {\r\n foreach (ZipArchiveEntry entry in archive.Entries)\r\n {\r\n zipItems.Add(new ZipFileItem\r\n {\r\n FileName = entry.FullName,\r\n FileSize = entry.Length > 0 ? (entry.Length / 1024).ToString() + " KB" : ""\r\n });\r\n }\r\n }\r\n \r\n zipListView.ItemsSource = zipItems;\r\n \r\n zipListView.MouseDoubleClick += (s, e) =>\r\n {\r\n if (zipListView.SelectedItem is ZipFileItem)\r\n {\r\n \tvar selectedItem = zipListView.SelectedItem as ZipFileItem;\r\n string tempDir = Path.Combine(Path.GetTempPath(), "ZipPreview");\r\n Directory.CreateDirectory(tempDir);\r\n string tempFilePath = Path.Combine(tempDir, selectedItem.FileName);\r\n \r\n using (FileStream zipToOpen = new FileStream(filePath, FileMode.Open, FileAccess.Read))\r\n using (ZipArchive archive = new ZipArchive(zipToOpen, ZipArchiveMode.Read))\r\n {\r\n foreach (ZipArchiveEntry entry in archive.Entries)\r\n {\r\n if (entry.FullName == selectedItem.FileName)\r\n {\r\n using (var entryStream = entry.Open())\r\n using (var fileStream = new FileStream(tempFilePath, FileMode.Create, FileAccess.Write))\r\n {\r\n entryStream.CopyTo(fileStream);\r\n }\r\n System.Diagnostics.Process.Start(tempFilePath); // 打开文件\r\n break;\r\n }\r\n }\r\n }\r\n }\r\n };\r\n \r\n PreviewContainer.Content = zipListView;\r\n }\r\n else\r\n {\r\n TextBlock unsupportedText = new TextBlock\r\n {\r\n Text = "无法预览此文件类型",\r\n FontSize = 14,\r\n Foreground = Brushes.Gray,\r\n TextAlignment = TextAlignment.Center\r\n };\r\n PreviewContainer.Content = unsupportedText;\r\n }\r\n }
[in]窗口尺寸/位置【值/表达式】
[in]激活模式【值/表达式】AutoActivate
[in]事件【值/表达式】
[in]自动关闭时间(S)【值/表达式】0
[in]失去焦点后关闭窗口【值/表达式】False
异常:z:\TEMP\CSSCRIPT\dynamic\11840.42f4d6bd-2555-4bd3-b5c1-c3965c5407a1.tmp(22,7): error CS0246: 未能找到类型或命名空间名称“SharpCompress”(是否缺少 using 指令或程序集引用?)
在 csscript.CSExecutor.ProcessCompilingResult(CompilerResults results, CompilerParameters compilerParams, ScriptParser parser, String scriptFileName, String assemblyFileName, String[] additionalDependencies) 在 csscript.CSExecutor.Compile(String scriptFileName) 在 CSScriptLibrary.CSScript.LoadWithConfig(String scriptFile, String assemblyFile, Boolean debugBuild, Settings scriptSettings, String compilerOptions, String[] refAssemblies) 在 CSScriptLibrary.CSScript.LoadCode(String scriptText, String tempFileExtension, String assemblyFile, Boolean debugBuild, String[] refAssemblies) 在 CSScriptLibrary.CodeDomEvaluator.CompileCode(String scriptText) 在 yXe4B8rq7T5hHcWFdu3.CDQNterg8BsbsbYPQXU.VyCZMQUQy55(String , String , Boolean , ActionExecuteContext ) 在 Ea5hmBrZQPxg0hkvIdK.TNqtN0rlxvqSd0yGVO1.<>c__DisplayClass61_0.IPJ97UiHHSs() 在 Quicker.Domain.Actions.X.XActionHelper.ExecuteCommonAction(ActionExecuteContext context, ActionStep step, XAction action, Func`1 actionFunc, Action successAction, Action failAction, StepInParamDef stopIfErrorParam, StepOutParamDef isSuccessOutputParam)
步骤(sys:customwindow)执行失败,原因:z:\TEMP\CSSCRIPT\dynamic\11840.42f4d6bd-2555-4bd3-b5c1-c3965c5407a1.tmp(22,7): error CS0246: 未能找到类型或命名空间名称“SharpCompress”(是否缺少 using 指令或程序集引用?)
困困君 4天7小时前
#4

解决了。这个需要等我解决下载dll的问题。以便支持更多压缩文件的预览。暂时屏蔽了。

回复主贴