InkCanvas をバックグラウンドで動かしたい
アプリケーション(現在作りたいアプリケーション)が起動中は
他のアプリを操作中(ゲームやブラウザ)でもアプリケーションのウインドウに線を描き続けたいのですが、方法がわかりません
よろしくお願いいたします。
C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace mouz
{
/// <summary>
/// Mouz.xaml の相互作用ロジック
/// </summary>
public partial class Mouz : Window
{
public Mouz()
{
InitializeComponent();
}
private DrawingAttributes ink = new DrawingAttributes();
private IntPtr hHook;
private void left_mouz_down(object sender, MouseButtonEventArgs e)
{
changeColor(e);
}
private void left_mouz_up(object sender, MouseButtonEventArgs e)
{
mouzCanvas.Strokes.Clear();
}
private void mouz_move(object sender, MouseEventArgs e)
{
changeColor(e);
}
private void right_mouz_down(object sender, MouseEventArgs e)
{
mouzCanvas.Strokes.Clear();
}
private void MouzCanvas_Loaded(object sender, RoutedEventArgs e)
{
var mouse_capture = Mouse.Capture(this);
ink.Width = 10;
ink.Height = 10;
Color myColor = (Color)ColorConverter.ConvertFromString("#30FFFFFF");
ink.Color = myColor;
mouzCanvas.DefaultDrawingAttributes = ink;
_ = Mouse.Capture(this);
}
private void changeColor(MouseEventArgs e)
{
if (e.LeftButton == MouseButtonState.Pressed)
{
Color myColor = new Color();
myColor = (Color)ColorConverter.ConvertFromString("#30FF0000");
ink.Color = myColor;
mouzCanvas.DefaultDrawingAttributes = ink;
}
else
{
Color myColor = new Color();
myColor = (Color)ColorConverter.ConvertFromString("#30FFFFFF");
ink.Color = myColor;
mouzCanvas.DefaultDrawingAttributes = ink;
}
}
}
}
xaml
<Window x:Class="mouz.MainWindow"
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:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:mouz"
mc:Ignorable="d"
Title="MainWindow" Height="337.271" Width="206.435" Background="#FF000000" WindowStyle="SingleBorderWindow">
<Grid>
<Button Content="Start" HorizontalAlignment="Left" Margin="10,15,0,0" VerticalAlignment="Top" Width="175" Height="87" Click="Start_Button" FontSize="30"/>
<Button Content="Quit" HorizontalAlignment="Left" Margin="10,129,0,0" VerticalAlignment="Top" Width="175" Height="87" Click="Quit_Button" FontSize="30"/>
<Button Content="Quit" HorizontalAlignment="Left" Margin="10,226,0,0" VerticalAlignment="Top" Width="175" Height="87" Click="Button_Click" FontSize="30"/>
</Grid>
</Window>