How to make a movable control in c#?
Two circles with a line joining b/w them.
if we move one circle in any direction the other circle remains fixed but the line changes its position according to the first circle.
i want the idea .....pls help me if u have?
You are not telling us if this is a Winform application, WPF or Silverlight.
To me it sounds like WPF could be the right technology for this.
You could use the shape objects to draw circles and lines.
Link to MSDN documentation
Related
I have a WPF application where I used DevExpress charts to display some data. I want to get rid of them and use LiveCharts, but I want to display a circle in the chart point closest to the mouse cursor when it is inside the chart. I have tried sections and I can show lines that cross in the point, but I can't mark that point as it automatically does when you hover over it. Is there a way to do this without changing the source code?
I think you can get your answer from this example.
By calculating the closest point to your mouse (like in the example, you can then change the style of your chart point. In the example, the x-axis lable at the specific point gets highlighted.
I am trying to figure out how to add a full shadow around a borderless form, using WinForms. I am looking at adding a shadow around all four sides of the form.
I have tried using the DropShadow class, although it only adds the shadow to the bottom and right side corners.
I have seen this question asked many times before in my searches but nothing I cam upon had an answer for all four sides.
I am using both C# and VB.net languages in my solution so any help regarding either language would be a big help.
You are going to have to manually draw this. I have done something similar before with a splash screen, I think. You need to decide the offset of the shadow from the client area of the form and either create a container (easier layout wise) to host its constituent controls or redefine its client rectangle programmatically if you need dynamic shadow size, and then draw your border. If memory serves, you will get the best results using alpha blending + lineargradientbrush to fade the shadow transparency out to the edges.
I am developing an application in C# .NET using WPF. I want the users to be able to draw shapes on a draw area. The shapes are zigzag lines and polygons. The end points of line segments should be small squares as shown in the image below. In some cases, I need arrows in the middle of line segments as shown in the image below.
I have partially implemented the drawing by adding lines to a canvas and resizing the lines on mouse events. However, I have not been able to implement creation of small squares on the end points of line segments and arrows.
Is there any package or tool that provides the functionality of drawing such shapes?
Thank you for any help which you can provide.
A common way to approach this is to use Adorners. Basically, there is a virtual layer rendered for adorners. You can use these to drag / resize (among other things) visual elements on the screen with a little bit of glue code.
Here is a page from Microsoft on the subject:
http://msdn.microsoft.com/en-us/library/ms743737.aspx?ppud=4
I have two inkCanvas elements in WPF displayed side by side. I want to be able to draw lines seamlessly from one inkCanvas to the next. Right now the stroke gets clipped at the boundary and you have to release the mouse and press it again on the next canvas to continue the line.
I also read that inkCanvas wasn't really the way to go for drawing. It was more for simple things like signatures. What are you supposed to use instead?
First try with one inkcancas:
add tiles by replacing the current inkcanvas with a bigger one and copying the strokes
it might work
if it doesn't you will know what you need more
Yes inkcanvas is for simple things but before you start coding a lot try to specify what you need.
I am using NPlot charting library to draw several plots illustrating signal fluctuations. The plots are inserted one beneath the other in a flowlayoutpanel1.
The x axis is the time. The y is the value of the signal.
I've added a trackbar at the bottom, along the x axis. When the user moves the trackbar, the value of each signal is displayed somewhere (in relation to the trackbar's position).
All of this is already functional.
I've been asked to add some visual way to illustrate the precise time where the trackbar is. They want some sort of vertical line that would move with the trackbar, over all the Nplots. However they are open to alternatives.
I have tried drawing the line but it's difficult to draw in relation to the trackbar's position. Also it ends up being drawn BEHIND the Nplots.
I've also tried drawing a static grid on the flowpanel but the Nplots are not transparent, and my boss doesn't like each plot having a individual grid for aesthetic purposes.
At this point i'm open to any "out-of-the-box" suggestions, or corrections on my implementation. I'm self taught in C# so i haven't done anything like this before.
Please help!
EDIT: I have gotten something slightly better by using a label with a border, stretching it to be tall and having width of 1. This creates a Line that goes over all other control. Now my biggest challenge is calculating the position of the trackbar pointer to make the line match it...
After a lot of fiddling, i found that the only way to have a line drawn over all other controls was NOT to use the Graphics drawline, as the controls placed on top were not transparent and i could not access their graphics component (was a imported control not a .NET class).
I ended up going with the EDIT solution, took a label with a border and put the width to 1, creating a simple line instead of a box.
The position formula took a lot of fine tuning, the way to go was to calculate (estimate) the width between two trackbar ticks an add a tiny offset for the control itself. Using the traback's pointer Value property, i could calculate the position of the label/line so that it would follow the trackbar pointer. There is a minuscule offset sometimes formed but not well seen to the naked eye.