Pandetthe
Pandetthe
CC#
Created by Pandetthe on 7/30/2024 in #help
Read-only question
Today visual studio 2022 suggested IDE0251 on property getter, it's suggestion that element can be readonly. What's the difference between a normal getter and a readonly one?
18 replies
CC#
Created by Pandetthe on 7/27/2024 in #help
Positioning window in per monitor aware v2
Hi! I am trying to position the wpf window perfectly within the selected screen. When I am using the unaware option everything works fine, but in per monitor aware v2 it's a little bit complicated. I have information about screen scalling and bounds. Firstly I thought that I can just multiplicate scalling and bounds to get the correct position. I was wrong. When the selected screen is under the primary screen, then the top/y position should not be scaled, but when is above it should. What would happen if there were three monitors in the row, primary first, then some monitor with weird scaling and then selected screen? Is there some option to easily get these bounds? I want to make this clean, because now I have a temporary solution. When creating a new window I am changing dpi aware to unaware.
80 replies
CC#
Created by Pandetthe on 3/26/2024 in #help
WFP InkCanvas hit test
Hi! I found a problem that my inkcanvas sometime is not being hit by VisualTreeHelper.Hittest on specific point.
10 replies
CC#
Created by Pandetthe on 3/25/2024 in #help
WPF inkcanvas input simulation
Hi!, I am trying to add my own input for Wpf inkcanvas. I have now working code for adding new points and creating from them strokes. This solution works perfectly for drawing, but not for erasing. Is there any option for simulating your own input for inkcanvas or something similar?
2 replies
CC#
Created by Pandetthe on 3/21/2024 in #help
Wpf combobox
Hi! I am doing some app with Wintab api in WPF. I am trying to "extend" combobox control that it will be possible for me to programaticly interact with control on specific window coordinates, for example click. I know how to open and close combobox (using togglebutton), how to interact with popup window, how to interact with scrollviewer, but I couldnt find how to interact and select specific item. Is this interaction logic in combobox or comboboxitem or somewhere else. I know I can change selection index in combobox item, but I wouldn't get all default visuals.
1 replies
CC#
Created by Pandetthe on 3/20/2024 in #help
Find popup window in Wpf
Hi, I want to get all opened popups in a specific window in Wpf, but I couldn't find a solution to solve it.
6 replies
CC#
Created by Pandetthe on 3/5/2024 in #help
Wpf custom button template proble
Hi! I am trying to create custom button control, but I have a problem with a content property. Button is displaying properly if the content is set in it's code, but when I am trying to do this in some view, only it's content is visible without border etc.
<UserControl x:Class="Wacom.TabletApp.Controls.ExtendedButton"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Wacom.TabletApp.Controls"
mc:Ignorable="d"
d:DataContext="{Binding RelativeSource={RelativeSource Self}}"
d:DesignHeight="450" d:DesignWidth="800">
<UserControl.Resources>
<SolidColorBrush x:Key="Button.MouseOver.Background" Color="#FFBEE6FD"/>
<SolidColorBrush x:Key="Button.MouseOver.Border" Color="#FF3C7FB1"/>
<SolidColorBrush x:Key="Button.Pressed.Background" Color="#FFC4E5F6"/>
<SolidColorBrush x:Key="Button.Pressed.Border" Color="#FF2C628B"/>
<SolidColorBrush x:Key="Button.Disabled.Background" Color="#FFF4F4F4"/>
<SolidColorBrush x:Key="Button.Disabled.Border" Color="#FFADB2B5"/>
<SolidColorBrush x:Key="Button.Disabled.Foreground" Color="#FF838383"/>
<ControlTemplate x:Key="ButtonTemplate" TargetType="{x:Type ButtonBase}">
<UserControl x:Class="Wacom.TabletApp.Controls.ExtendedButton"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Wacom.TabletApp.Controls"
mc:Ignorable="d"
d:DataContext="{Binding RelativeSource={RelativeSource Self}}"
d:DesignHeight="450" d:DesignWidth="800">
<UserControl.Resources>
<SolidColorBrush x:Key="Button.MouseOver.Background" Color="#FFBEE6FD"/>
<SolidColorBrush x:Key="Button.MouseOver.Border" Color="#FF3C7FB1"/>
<SolidColorBrush x:Key="Button.Pressed.Background" Color="#FFC4E5F6"/>
<SolidColorBrush x:Key="Button.Pressed.Border" Color="#FF2C628B"/>
<SolidColorBrush x:Key="Button.Disabled.Background" Color="#FFF4F4F4"/>
<SolidColorBrush x:Key="Button.Disabled.Border" Color="#FFADB2B5"/>
<SolidColorBrush x:Key="Button.Disabled.Foreground" Color="#FF838383"/>
<ControlTemplate x:Key="ButtonTemplate" TargetType="{x:Type ButtonBase}">
3 replies
CC#
Created by Pandetthe on 3/3/2024 in #help
✅ Wndproc is not receiving any messages when window is not focused
HI! I am trying to handle messages in WPF using WndProc like this:
_messageWindowHandle = new WindowInteropHelper(window).EnsureHandle();
HwndSource.FromHwnd(_messageWindowHandle).AddHook(WndProc);
_messageWindowHandle = new WindowInteropHelper(window).EnsureHandle();
HwndSource.FromHwnd(_messageWindowHandle).AddHook(WndProc);
When window is focused everything is working fine, but when I select another window, wndproc stop receiving any messages. How can I fix it?
22 replies
CC#
Created by Pandetthe on 2/28/2024 in #help
WPF custom click event
Hi, I am wondering if it is possible to create similar event to mouse click, that will be called only for controls that are at the specific coordinates of window.
2 replies
CC#
Created by Pandetthe on 2/24/2024 in #help
Wpf combobox problem
Hi! I came across an interesting problem today and I don't know how to overcome it. I have ObservableCollection<CustomWindow> where CustomWindow is including Window class and has public string property Example. I am using it as an ItemSource for combobox with DisplayNamePath="Example". Dropdown list is being displayed correctly but after selecting any option from it, selection box is still empty and I get System.Windows.Data Error: 40 : BindingExpression path error: 'Example' property not found on 'object' ''Frame' (Name='ViewControl')'. BindingExpression:Path=Example; DataItem='Frame' (Name='ViewControl'); target element is 'TextBlock' (Example=''); target property is 'Text' (type 'String')
2 replies
CC#
Created by Pandetthe on 12/10/2023 in #help
PDF modify lib
Hi, what lib would you recommend for modifying existing pdf files, best option would be without any license. I was using previously QuestPDF, but it's only for creating new documents.
4 replies
CC#
Created by Pandetthe on 11/23/2023 in #help
WPF, "emulate" mouse click
Hi. I am working with WPF and I am adding Wintab API(tablet API). I want to "emulate" mouse click event on specific coordinates to avoid creating own buttons and other controls that will have this compatibility. Is there any option to call some kind of event or easily create own?
12 replies
CC#
Created by Pandetthe on 11/20/2023 in #help
Struct with explicit layout
Hi, I am using Wintab and I am trying to make packet struct, but I have some problem. In some situations field x is uint but in others it's a int. Is there any option to determine if it's now uint or int or I need to have two fields - uint and int at the same offset
13 replies
CC#
Created by Pandetthe on 10/26/2023 in #help
❔ WPF app with rest API
Hi, I am trying to create WPF app with opened rest API for communication. I want to have swagger included to test API, is there option to combine it under one exe?
5 replies
CC#
Created by Pandetthe on 9/29/2023 in #help
❔ Best duplex communication protocol
Hi! What do you guys think that will be the best way to have communication between 2 apps (one in .net c# and one in other language, so technology cannot be only for .net). It's needed to be possible in two directions and easy to send files and some other text data.
26 replies
CC#
Created by Pandetthe on 9/4/2023 in #help
❔ How to disable automatic time sync?
Hi! I am trying to add to my app manual time setting using SetSystemTime from kernel32.dll, but I couldnt find how to disable/enable automatic time sync with ntp server. I found that it can be done by setting [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\Parameters] "Type"="NoSync", but it changes back occasionally
3 replies
CC#
Created by Pandetthe on 8/31/2023 in #help
❔ Tablet API
Hey, I am trying to implement a Wacom tablet to my WPF app. What is better to do, use Wintab or Windows Ink and does Windows Ink have an option to receive pen data without moving a cursor?
23 replies
CC#
Created by Pandetthe on 8/22/2023 in #help
❔ Restricting mouse movement
Hi!, I am trying to restrict mouse movement on the area of the whole screen. I am using SetWindowsHookEx for LowLevelMouseProc. For checking monitor area I am using GetMonitorInfo, and here is my problem. When all screens have the same dpi, everything is fine, if primary screen have scaling 125%, and screen where I want to restrict movement 100%, everything is fine but if primary has 100% and second has 125%, boundaries of the screen are wrong.
7 replies
CC#
Created by Pandetthe on 6/21/2023 in #help
❔ Task scheduling
Hi,I have a question about the example of code in .net docs for asp.net core 6.0. Is this code good about maintaining high accuracy per minute for a long time?
namespace TimedBackgroundTasks;

public class TimedHostedService : BackgroundService
{
private readonly ILogger<TimedHostedService> _logger;
private int _executionCount;

public TimedHostedService(ILogger<TimedHostedService> logger)
{
_logger = logger;
}

protected override async Task ExecuteAsync(CancellationToken stoppingToken)
{
_logger.LogInformation("Timed Hosted Service running.");

// When the timer should have no due-time, then do the work once now.
DoWork();

using PeriodicTimer timer = new(TimeSpan.FromSeconds(1));

try
{
while (await timer.WaitForNextTickAsync(stoppingToken))
{
DoWork();
}
}
catch (OperationCanceledException)
{
_logger.LogInformation("Timed Hosted Service is stopping.");
}
}

// Could also be a async method, that can be awaited in ExecuteAsync above
private void DoWork()
{
int count = Interlocked.Increment(ref _executionCount);

_logger.LogInformation("Timed Hosted Service is working. Count: {Count}", count);
}
}
namespace TimedBackgroundTasks;

public class TimedHostedService : BackgroundService
{
private readonly ILogger<TimedHostedService> _logger;
private int _executionCount;

public TimedHostedService(ILogger<TimedHostedService> logger)
{
_logger = logger;
}

protected override async Task ExecuteAsync(CancellationToken stoppingToken)
{
_logger.LogInformation("Timed Hosted Service running.");

// When the timer should have no due-time, then do the work once now.
DoWork();

using PeriodicTimer timer = new(TimeSpan.FromSeconds(1));

try
{
while (await timer.WaitForNextTickAsync(stoppingToken))
{
DoWork();
}
}
catch (OperationCanceledException)
{
_logger.LogInformation("Timed Hosted Service is stopping.");
}
}

// Could also be a async method, that can be awaited in ExecuteAsync above
private void DoWork()
{
int count = Interlocked.Increment(ref _executionCount);

_logger.LogInformation("Timed Hosted Service is working. Count: {Count}", count);
}
}
10 replies
CC#
Created by Pandetthe on 6/15/2023 in #help
❔ Cannot run python process
3 replies