FaNim
FaNim
CC#
Created by FaNim on 8/23/2024 in #help
[WPF] DragDrop problems
No description
5 replies
CC#
Created by FaNim on 2/20/2024 in #help
WPF custom resizable window
c#
#region ResizeWindows
private void Resize_Init(object sender, MouseButtonEventArgs e)
{
if (sender is not Rectangle senderRect) return;

ResizeInProcess = true;
senderRect.CaptureMouse();
}

private void Resize_End(object sender, MouseButtonEventArgs e)
{
if (sender is not Rectangle senderRect) return;

ResizeInProcess = false; ;
senderRect.ReleaseMouseCapture();
}

private void Resizeing_Form(object sender, MouseEventArgs e)
{
if (!ResizeInProcess) return;
if (sender is not Rectangle senderRect) return;

Window mainWindow = senderRect.Tag as Window;
double width = e.GetPosition(mainWindow).X;
double height = e.GetPosition(mainWindow).Y;
double temp = 0;
senderRect.CaptureMouse();

if (senderRect.Name.Contains("right", StringComparison.OrdinalIgnoreCase))
{
width += 5;
if (width > 0)
mainWindow.Width = width;
}
if (senderRect.Name.Contains("left", StringComparison.OrdinalIgnoreCase))
{
width -= 5;
temp = mainWindow.Width - width;
if ((temp > mainWindow.MinWidth) && (temp < mainWindow.MaxWidth))
{
mainWindow.Width = temp;
mainWindow.Left += width;
}
}
if (senderRect.Name.Contains("bottom", StringComparison.OrdinalIgnoreCase))
{
height += 5;
if (height > 0)
mainWindow.Height = height;
}
if (senderRect.Name.ToLower().Contains("top", StringComparison.OrdinalIgnoreCase))
{
height -= 5;
temp = mainWindow.Height - height;
if ((temp > mainWindow.MinHeight) && (temp < mainWindow.MaxHeight))
{
mainWindow.Height = temp;
mainWindow.Top += height;
}
}
}
#endregion
c#
#region ResizeWindows
private void Resize_Init(object sender, MouseButtonEventArgs e)
{
if (sender is not Rectangle senderRect) return;

ResizeInProcess = true;
senderRect.CaptureMouse();
}

private void Resize_End(object sender, MouseButtonEventArgs e)
{
if (sender is not Rectangle senderRect) return;

ResizeInProcess = false; ;
senderRect.ReleaseMouseCapture();
}

private void Resizeing_Form(object sender, MouseEventArgs e)
{
if (!ResizeInProcess) return;
if (sender is not Rectangle senderRect) return;

Window mainWindow = senderRect.Tag as Window;
double width = e.GetPosition(mainWindow).X;
double height = e.GetPosition(mainWindow).Y;
double temp = 0;
senderRect.CaptureMouse();

if (senderRect.Name.Contains("right", StringComparison.OrdinalIgnoreCase))
{
width += 5;
if (width > 0)
mainWindow.Width = width;
}
if (senderRect.Name.Contains("left", StringComparison.OrdinalIgnoreCase))
{
width -= 5;
temp = mainWindow.Width - width;
if ((temp > mainWindow.MinWidth) && (temp < mainWindow.MaxWidth))
{
mainWindow.Width = temp;
mainWindow.Left += width;
}
}
if (senderRect.Name.Contains("bottom", StringComparison.OrdinalIgnoreCase))
{
height += 5;
if (height > 0)
mainWindow.Height = height;
}
if (senderRect.Name.ToLower().Contains("top", StringComparison.OrdinalIgnoreCase))
{
height -= 5;
temp = mainWindow.Height - height;
if ((temp > mainWindow.MinHeight) && (temp < mainWindow.MaxHeight))
{
mainWindow.Height = temp;
mainWindow.Top += height;
}
}
}
#endregion
hello is there a better way to make custom resizeable window because it cause more memory use and its not smooth at all?
3 replies
CC#
Created by FaNim on 1/21/2024 in #help
MAUI how to make ContentPage and FlyoutPage as one page?
<?xml version="1.0" encoding="utf-8" ?> <FlyoutPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="InzynieriaAplikacja.Controls.Flyout" Title="Flyout" FlyoutLayoutBehavior="Popover"> <FlyoutPage.Flyout> <ContentPage Title="Flyout"> <Label Text="Flyout" HorizontalTextAlignment="Center" VerticalTextAlignment="Center"/> </ContentPage> </FlyoutPage.Flyout> <FlyoutPage.Detail> <ContentPage> <Label Text="Flyout Detail" HorizontalTextAlignment="Center" VerticalTextAlignment="Center"/> </ContentPage> </FlyoutPage.Detail> </FlyoutPage> here is my flyout page but i have not idea how to add here as theoretically detail my grid and whole content from like my mainview page? and do i need to make my mainview as flyout page do display it maybe? i don't how to deal with it
1 replies
CC#
Created by FaNim on 1/20/2024 in #help
Atlas MongoDB with .net maui Realm
Hello, I am trying to create an Android app that includes both administrator and user functionalities. The administrator should be able to add training data to the database, and users should be able to retrieve that data. However, I am having difficulty finding tutorials that cover these specific aspects. Can you please help me?
6 replies
CC#
Created by FaNim on 9/27/2023 in #help
❔ [WPF] Changing TextBlock text like renaming files in windows eplorer
Hello iam looking for how to implement renaming my ui elements that have textblock in grid same way as explorer doing this. I am using MVVM and i already have context menu implementation for that but i want to have option when i click to rename it will trigger command in my viewmodel that will trigger that renaming funcionality but i have no idea how to deal with edtiting that text and with losing focus, pressing enter to accept that rename etc etc
2 replies
CC#
Created by FaNim on 8/25/2023 in #help
✅ Prevent WPF applications from being detected as a virus
Hi, is there any way or technique to prevent .exe files downloaded from my repository from being detected by an antivirus? I want to build auto download in my app but when i download the .exe from my app to replace it, it is detected as a trojan and defender deletes it so i can make for user easy update system etc etc.
13 replies
CC#
Created by FaNim on 8/24/2023 in #help
✅ Problem with downloading .exe file from assets int Github releases
Hello iam trying to create auto-download function for my wpf application but when i download my .exe file from assets windows defender detects it as trojan and iam clueless with how can i bypass that Here's the code: https://pastebin.com/5CpRf75M
6 replies
CC#
Created by FaNim on 3/29/2023 in #help
❔ How to work with Hwnd in c#
I want to open programs using Process.Start but all those programs have empty MainWindowHandle and MainWindowHandle do i need after it opens search again for all processes using EnumWindows or smth like that to refresh datas in this opened processes to have control or is there any better solution to search for hwnd and title data or just get it after Process.Start. And is it all safe?
5 replies
CC#
Created by FaNim on 3/28/2023 in #help
❔ How to wait for process to complete
i want to make program opens async but instead of giving 'hard coded' delays but i don't know how to use Process to wait for it to complete opening
32 replies
CC#
Created by FaNim on 3/4/2023 in #help
How to save and restore window position in wpf c#
Hello iam using .NET 7.0 and Properties doesnt work for me via code
13 replies
CC#
Created by FaNim on 3/4/2023 in #help
How to make TextBox numeric and set min and max value to it
private void InstanceNumberValidationTextBox(object sender, TextCompositionEventArgs e)
{
e.Handled = !IsValid(((TextBox)sender).Text + e.Text);
}

public static bool IsValid(string str)
{
return int.TryParse(str, out int i) && i >= 1 && i <= 32;
}
private void InstanceNumberValidationTextBox(object sender, TextCompositionEventArgs e)
{
e.Handled = !IsValid(((TextBox)sender).Text + e.Text);
}

public static bool IsValid(string str)
{
return int.TryParse(str, out int i) && i >= 1 && i <= 32;
}
I've tried something like that but it gives problems
19 replies
CC#
Created by FaNim on 3/3/2023 in #help
How to get and set position of an ui element via code wpf c#
Hello i want to create TextBoxes via code and set their position but i can't found how to even get the position or set what should i reference to?
13 replies
CC#
Created by FaNim on 2/25/2023 in #help
✅ How can i save Ui content when switching between views in MVVM wpf
when i switching between views everytime what i my textboxes are cleared only listview items are saved but i have main list in MainWindow what can i do?
97 replies
CC#
Created by FaNim on 2/22/2023 in #help
❔ binding Command in user control button problem
25 replies