Disable cursor During Drag and Drop Operation - c#

I have implemented this WPF drag and drop framework by Jan Karger (2011) https://code.google.com/p/gong-wpf-dragdrop/
However, I cannot seem to change the default cursor which appears during a Drag and Drop operation:
I understand that the cursor is affected somehow by the DragDropEffects.Copy method, however I cannot seem to override or change it at all.
If anyone could shed some light on this problem, it would be greatly appreciated

The answer is right there on the main documentation page: if you follow the exact same model with ViewModels implementing the interfaces, then you need to have an IDropTarget. The drop target controls what icon is displayed, of course - different targets might have different effects.
So in the handler for DragOver, you receive a DropInfo - simply set its Effects property to the value you'd like.
I used that library once and I remember it being really neat - a simple wrapper that brought MVVM to drag/drop. I distinctly remember having different drag icons (and even more complicated stuff like semi-transparent overlay of the stuff being dragged) so I'm sure it's possible. If you're sure you're doing everything right and it still doesn't work, then much more detail will be needed...

Related

Xamarin Forms UI Animated Menu

I'm rather new to Xamarin Forms and I am finding some of the rigidness of the UI to be difficult to deal with and would like some expert input. Basically what i'm trying to make is a preferably sleek menu UI like Example Menu (crudely drawn in MS paint) that is nothing more than a list of menu options, and when you click one, the ones below it slide or move down a bit to make room for an area with additional descriptive text. Also, if the menu option opens up and the other options no longer fit on the screen, I would want them to remain out of scope in a ScrollView.
Now my issue is that I don't really know the best way to go about it. My thoughts:
I am currently attempting to nest a grid inside of a scroll view and formulate some kind of function that will add an empty row definition under the indexed menu option button, and populating the empty row. Basically using adding/removing grid rows to handle the 'expanding and contracting' of the menu option. I am struggling to get this function bug free right now but I am wondering if animating this action is possible with a smooth easing sliding motion or if I should explore better easier options. It seems silly to constantly clear the grid and re-add all of the update rowdefinitions each time.
I am curious if perhaps dynamically changing the specific buttons row height when clicked might be cleaner than adding/removing rows. Or using a listview and changing the listview cell's height when clicked. Or would a stacklayout work best in this case since it is technically a stack of buttons. Is it best to add/remove rows or are there easier/better ways to handle this?
Essentially, I am looking for some pointers on which direction I should take that makes the most convenient sense. I chose to start with a grid because it seemed easiest to work with in this case but when looking to animate the menu option and make a sleek smooth menu I am starting to have doubts.
Thanks!
p.s. If someone can also provide or link me a relevant example of how an animation in this case would go down it would be greatly appreciated

How to set Custom control as ToolTip for Button or Label?

I have created a custom control of my own and i am in a need of making this custom control as a ToolTip for the Labels or Buttons.
But i could not find a way to set the Custom control as ToolTip.
Anyone please help me on setting the Custom control as ToolTip.
Note:
I don't need solution with showing the Custom Control in mouse_hover events of controls.
Please suggest me ideas to make the custom control as default ToolTip in standard way.
Regards,
Amal Raj
I assume that you already know about overriding the paint event, so I won't go into that. If you want anything a bit more complicated, deriving from the ToolTip control to extend it for your purposes won't make much sense since you'll run into restrictions quite fast.
What you should do is implement your own ToolTip control by reusing some important bits from the original one. If you're feeling adventurous you could follow these steps to get started. I'm going to refer to your custom control as tooltip from now on:
If you want to show custom text or something else for each control that uses your tooltip, you need to implement IExtenderProvider in your class. Here's more about it.
You need to keep track of controls that are using your tooltip and the custom values you've set for them. Internally, Windows Forms tooltip uses a HashTable for that purpose. Key is the control showing your tooltip and value is the tooltip text (or something else you want to tie to your tooltip).
If you want to have more than just one string to show (title, description, image etc), you can have multiple HashTables.
When adding the tooltip to a control, subscribe to mouse events (enter, move, leave) to keep track of when to show the tooltip. If you want to have a delay before showing the control, you need to use an internal timer to keep track of time.
You'll most likely want the tooltip to extend outside the main form's boundaries. You could wrap your tooltip inside a headerless form or an alpha blended form to allow other shapes than rectangle.
Those are the very generalized first steps. In reality, there's quite a bit more to be done. It's been a few years since I implemented my custom ToolTip control so I might be forgetting something crucial. However, if you spend some time poking around the code of Windows Forms's ToolTip class, you'll get quite a good idea of what's going on behind the curtains.
I haven't reviewed the code myself but judging from the ratings, this article will give you a good starting point too: A ToolTip with Title, Multiline Contents, and Image. It's in VB.NET but you can easily convert it to C# by using Telerik's converter or any other.

Docking buttons in the wpf panels

How can it be done? If there are, for example, four groups of buttons in menu-like panel. How would you dock them to their initial location if the window is resized?
I am trying this using DockPanel and HorizontalAlign, but it seems to only be work for the last button on the right when the window is resized. But how do you dock(anchor) a group of buttons? Maybe put them in border object and use HorizontalAlign for it? Is there more elegant way to do this?
To summarize the comments: I don't know your background but it seems you are used to another way of UI design where you do not explicitely have to specify grouping etc in code. While that might seem more elegant, it is not: the designer generated code is awful and the whole system is not as flexible nor srtaightforward as what WPF gives you..
With WPF you get a clear one-to-one relationship between your intent (treating buttons as a group within a layout) and the actual code (put the buttons in a stackpanel/grid/...). Or draw a border around buttons and organize them vertically within the border vs in xaml use a border with a stackpanel inside. It won't get any more elegant than that.
Read up on WPF layouts and once you'll get a grip of it you will quickly see that it is rather powerful and beatiful at the same time. I found this tutorial pretty helpful when just starting with layouts. And google provides lots and lots and lots more information, as usual.
Like stijn said, put the buttons in a Grid or a Stackpanel and you'll be fine.
You may not think it's beautifull, but it's the best solution for your problem.

Manually Activate/Deactivate SnapLines For Custom Controls

At this point, I almost never want to design a control with rich design-time support again. That said...
I am already overriding the SnapLines property in my ControlDesigner-derived class to manually forward out various snaplines from the child controls of my control -- the text baseline (pink) snap from the labels and comboboxes; the text inset snap from the labels; the top, bottom, left and right snaplines from the comboboxes. Those snaplines activate when the control itself is moved around on the form and when other controls are moved around it.
What I need is the ability to tell the designer to activate the snaplines and then deactivate them while I'm doing an internal move or resize of the underlying controls.
My comboboxes are resizable through overrides of OnMouseDragBegin, OnMouseDragMove, and OnMouseDragEnd in my control designer. The magic bullet I'm looking for is something I can call in Begin to tell the designer to show the snaplines and something in End to tell it to stop.
Allowing people to resize and move the internal controls at design time is kind of useless if they don't show snaplines for each other or for external controls.
As with stuff like this, it's incredibly hard to search for. I've found one post on a forum where someone asked this exact question that had (of course) no responses. That's about it.
Obviously the issue of actually snapping to the snaplines when/if they're shown remains. Just being able to see them would be a nice start.
Any ideas?
The best way to do what you want todo is to create a Design Surface MSDN Reference
I've used this to create my own design surface for my application so that the clients can customize the forms.
Hope this helps,
Johan J v Rensburg

I would like to learn about creating graphic objects at Runtime in c#

I would like to learn about creating a program that I could draw simple shapes and be able to select them for editing - like resizing, order of display, color change. Is there an online resource that someone knows of that would help me reach my goals.
thanks
"GDI+" is what you are looking for. You can start here: http://msdn.microsoft.com/en-us/library/da0f23z7.aspx
A sneaky way I used to do it was to create a custom control, remove the background from it and paint my shapes and sizes on it. Then, you can easily implement selection (override OnClick), dragging and resizing (OnMouseDown, OnMouseMove, OnMouseUp). You can then implement options like color, etc. by means of a property (see Browsable attribute and property get/setters) and a PropertyGrid control.
Anything beyond that, though - Bezier curves and such - would need something a tad more advanced, though.
The alternative is to only use such controls for the sizing handles, and do all the drawing on one central canvas - the only drawback then is figuring out how to select a shape on the canvas.

Categories

Resources