Skip to content

ScreenCapture控件建议 #68

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
chen2well opened this issue Oct 17, 2023 · 2 comments
Closed

ScreenCapture控件建议 #68

chen2well opened this issue Oct 17, 2023 · 2 comments
Assignees
Labels
enhancement New feature or request

Comments

@chen2well
Copy link

当加载资源字典无法写在App.xaml时,写在Window.Resources时 ScreenCapture及ScreenCut无法正常使用
<Window.Resources>

<ResourceDictionary.MergedDictionaries>

<wd:Resources Theme="Light"/>

</ResourceDictionary.MergedDictionaries>

</Window.Resources>

@yanjinhuagood yanjinhuagood self-assigned this Oct 20, 2023
@yanjinhuagood yanjinhuagood added the enhancement New feature or request label Oct 20, 2023
@yanjinhuagood
Copy link
Member

yanjinhuagood commented Dec 2, 2023

update in ScreenCapture
问题已再此提交修复。

@yanjinhuagood
Copy link
Member

yanjinhuagood commented Dec 2, 2023

1.引入WD的资源文件

<Window
    x:Class="WpfScreenCapture.ScreenCaptureWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:local="clr-namespace:WpfScreenCapture"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:wd="https://github.com/WPFDevelopersOrg/WPFDevelopers"
    Title="Window1"
    Width="800"
    Height="450"
    mc:Ignorable="d">
    
    <Window.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="pack://application:,,,/WPFDevelopers;component/Themes/Light.Blue.xaml" />
                <!-- 需要注意 wd:Resources 必须在配色主题后,Theme="Dark" 为黑色皮肤 -->
                <wd:Resources Theme="Light" />
                <ResourceDictionary Source="pack://application:,,,/WPFDevelopers;component/Themes/Theme.xaml" />
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Window.Resources>

    <Button
        Margin="0,10"
        HorizontalAlignment="Center"
        VerticalAlignment="Top"
        Click="Button_Click"
        Content="ScreenCapture" />
    
</Window>

2.在弹出截图控件时将资源传入

private void Button_Click(object sender, RoutedEventArgs e)
{
  Dispatcher.Invoke(new Action(delegate
  {
     ScreenCapture screenCapturer = new ScreenCapture(resources: this.Resources);
     screenCapturer.Capture();
  }));
}

或者用下面的方式

外部进程启动 ScreenCaptureExt

private void Button_Click(object sender, RoutedEventArgs e)
{
  ScreenCaptureExt screenCaptureExt = new ScreenCaptureExt();
  screenCaptureExt.SnapCanceled += ScreenCaptureExt_SnapCanceled;
  screenCaptureExt.SnapCompleted += ScreenCaptureExt_SnapCompleted;
}

yanjinhuagood added a commit that referenced this issue Dec 2, 2023
Supports incoming resource files
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants