c# smartphone-like scrolling windows forms panel movement - c#

I will try to explain it: I'm making an touch app in windows forms. I have some panels with buttons inside. I would like to move ( right or left ) the panel when i click in any control inside the panel and move the mouse left or right. I would like to get the movement like smartphone scrolling.
I thought to make this with drag&drop and when I drag some control inside the panel, move the panel to right or left. But I don't know how to make this and I don't want to lose button's click because every button have their own functionality.
You have some idea?
Thanks a lot

Related

How do i make a ScrollViewer with buttons instead of scrollbar?

I'm making an online cinema UWP app and i need to implement horizontal "gallery" with movies. The app will be used on PC, Xbox and touch devices, so i need the scrolling to be working with mouse, arrow keys and touch scrolling with swipes.
Currently I'm using ListView with ScrollViewer, but it doesn't give me the intended result. I want mouse wheel to scroll vertically, but when pointer enters the area of ListView, it starts to scroll the View horizontally. Disabling horizontal scrolling, well, breaks everything, so this pure implementaion is not an option.
I like the way MS made horizontal gallery in Microsoft Store app. It's scrollable with touch swipes and keyboard, but mouse wheel does nothing. Instead, the view shows round arrow buttons on the sides of this horizontal list like this:
I want to make something like that, but can't find any tips for controlling the scroll manually. Maybe there's any similar controls I don't know about or docs for making such control?
It should not be a big deal.
Set the VerticalScrollMode="Disabled" , VerticalScrollBarVisibility="Disabled", HorizontalScrollMode="Auto" and HorizontalScrollBarVisibility="Auto". Then set those two buttons to left and right with vertically centered alignment.
Use the ChangeView Method in the Click event handler to programmatically scroll through the contents. That's it.

How to make items to resize automatically in windows forms when going on fullscreen

I have many buttons in winform. it's look like buttons in calculator.
When I open full screen, buttons stays on top left side (same size they were before) and on the right side there is empty background of form.
How can I make them get bigger and stay centered relatively when I open winform on full screen?
If you have 2 or less buttons per row/column, then you can use anchors.
However, if you have more than 2 buttons per row/column, you'll need to use a TableLayoutPanel (granted you don't have an external controls library like DevExpress or Telerik) which you can then dock/anchor accordingly.
You can dock your controls in the center. Try the following:
1) Select your controls through pressing right cursor of the mouse and hovering over your controls
2) Place your controls in the center
2) Go to 'Properties' panel and find 'Anchor' property
3) Deselect all the anchors (default anchors are top and right)
Try running and resizing your Windows Forms application.

How to scroll by touch custom control?

I have a custom control in a winforms C# application which looks like this:
PANEL
-label1
-label2
-label3
If I want to scroll with the mouse wheel, scrolls fine, even if I have the mouse over one of those labels. The problem comes when I want to scroll touching the screen.
If I touch the panel it scrolls just fine, but it doesn't if I touch over a label.
ps: actually labels are custom controls too.

Not allowing controls to overlap

I am have been trying all day to figure out how to not allow controls that I draw on event to check and see if there is another control there and if so to move it over so they do not overlap. I need them to be able to be overlapping if the user drags them there but on the creation of the control to check and move them if necessary. I am trying to create a card game and dont want controls to be hidden behind controls (cards) that the user has not yet moved manually. I am using picture boxes as my cards. Any help would greatly be appreciated. Here is a screen shot of my form. The darker panels are whats in the players hand. The panels that are a light grey are the playing field. Ideally, the user would play a card and it would try and place it in the top left of the panel. if there is a card that intersects then move it over until it doesn't touch a card. Basically find a open space to put the card.
Have you tried using the flow layout panel Class it's under the toolbox=> container with this control you can set how controls are added to it.

During drag drop, how to show a popup with text(or a cursor with text) that follows the mouse cursor in WPF

I need to show a popup to the user when he is dragging files or items onto my control. The popup basically informs him why dragging is disabled by giving him a message. I would like the popup to follow the mouse cursor whilst he is still in dragging mode.
OR is there a way to change the mouse cursor while dragging and displaying a text alongside the cursor?
If there are any other designs that you guys can suggest.. that would be nice too.
Thanks for your suggestions!
You might finde some suggestions on how to change the cursor here: Custom cursor in WPF?
One suggestion is to draw your popup on a canvas and move it as the cursor moves.

Categories