|
I assume this is a Windows Forms project with: on the same Form:
1. a Panel named 'panel1 200x200 in size
2. a Label named 'label1
3. you define the Panel's 'MouseMove EventHandler:
private void panel1_MouseMove(object sender, MouseEventArgs e)
{
if (e.X < 5 || e.X > 195)
{
label1.Text = e.Location.ToString();
}
else
{
label1.Text = "";
}
} The label will be updated with the current mouse position in 'panel1 co-ordinates every time it is moved within 5 points of the right and left side.
Consider another simple solution:
1. a Panel, 'panel1 200x200
2. a Panel, 'panel2 190x200
3. a Label, 'label1
by placing 'panel2 inside 'panel1 (adding 'panel2 to panel1's ControlCollection), and writing this MouseMove EventHandler for 'panel1:
private void panel1_MouseMove(object sender, MouseEventArgs e)
{
label1.Text = e.Location.ToString();
} The mouse-move will be detected only when the mouse is over the area not covered by 'panel2: which would be an area of the two horizontal sides of 'panel1 5 points in width.
« I had therefore to remove knowledge, in order to make room for belief » Immanuel Kant
|
|
|
|
|
here is your code.
private void panel1_MouseMove(object sender, MouseEventArgs e)
{
if (e.X < 5 || e.X > 195)
{
label1.Text = e.Location.ToString();
}
else
{
label1.Text = "";
}
}
here you hard code 5 & 195. in my case value can be different. so how do i know what i should use to test this. let me know. thanks
tbhattacharjee
|
|
|
|
|
You should be able to easily figure out how to make those hard-coded numbers in my example calculated in your code by looking at the width of the Panel, and the value of your own variable that holds the width of the two areas you wish to be "mouse-sensitive."
I'm here to help you learn how to learn, any time
cheers, Bill
« I had therefore to remove knowledge, in order to make room for belief » Immanuel Kant
|
|
|
|
|
i have one panel and i put a flow layout panel in the main panel and flow layout panel has many images. my UI looks like this http://i.stack.imgur.com/14eJG.png[^]
now i got a code which scroll the container in the panel. i mean the flow layout will scroll in main panel when i will place my mouse at the left or right most area on the main panel. their code is working i checked but when i place their code in my project then that is not working, i means scrolling is not working when i place my mouse at the left or right most area on the main panel.
here i am attaching main code which causes to scroll the flow layout panel inside in main panel
protected override CreateParams CreateParams
{
get
{
CreateParams cp = base.CreateParams;
cp.ExStyle |= 0x02000000; // Turn on WS_EX_COMPOSITED
return cp;
}
}
int _myval = 5;
protected override void OnMouseMove(MouseEventArgs e)
{
base.OnMouseMove(e);
if (e.Y < metroPanel1.Top || e.Y > metroPanel1.Top + metroPanel1.Height) return;
if (e.X <= metroPanel1.Left && e.X >= metroPanel1.Left - 40)
{
if (metroPanel1.HorizontalScroll.Value <= _myval)
{
metroPanel1.HorizontalScroll.Value = _myval;
}
else
{
metroPanel1.HorizontalScroll.Value -= _myval;
}
}
if (e.X <= (metroPanel1.Left + metroPanel1.Width + 40) && e.X >= (metroPanel1.Left + metroPanel1.Width))
{
metroPanel1.HorizontalScroll.Value += _myval;
}
}
i just do not understand this value 40 used here if (e.X <= metroPanel1.Left && e.X >= metroPanel1.Left - 40)
i guess i need to use different value rather than 40 but i used 10 & 20 but did not work. here is my full project link from where anyone can download and see what is wrong in my routine which prevent the scrolling. here is the link https://onedrive.live.com/embed?cid=C4A6F16F34D7540A&resid=C4A6F16F34D7540A%21134&authkey=AM5Fq2gcFLtcw_A
so it is my request that please some one see my code and guide me what i need to change in code and why. thanks
tbhattacharjee
|
|
|
|
|
Come on! You've been here long enough to know that code snippets should always be pasted inside PRE tags. Not doing so make you're code very difficult to read.
|
|
|
|
|
The problem with Windows ContainerControls and trying to create your own alternative for "seamless" AutoScrolling is that setting 'AutoScroll to 'true means Scrollbars will be shown.
But, the bigger problem is that Win Forms is not designed for smooth animation ... at least not from programming regular C# with no API calls ... If you have a FlowLayoutPanel with lots of fancy Controls in it, moving it yourself within its ContainerControl will probably lead to a "herky-jerky" kind of effect. And, what the user sees is probably going to be influenced by the power of their CPU, GPU, etc.
To do animation of Controls, Windows, etc., why not consider WPF rather than WinForms: it's designed to support such advanced graphic features.
Please, as Dave suggested, format your code example.
Try and state your goal here very clearly: is it to make a FlowLayoutTable Control inside a Panel automatically move right or left ... an animation ... when the mouse is within certain areas ?
The solution I would use would not involve using 'AutoScroll at all: I'd use a 'Timer, and two Panels outside the Panel that contains the FlowLayoutTable.
Be happy to help you discover how to achieve this, but I want to see more work on your part, first, and I strongly suggest you think about whether a lot of work here might lead to a disappointing visual result.
« I had therefore to remove knowledge, in order to make room for belief » Immanuel Kant
modified 18-Sep-14 13:40pm.
|
|
|
|
|
thanks for giving time.
here i am providing a link from where you can download win apps not wpf where people did the nice scroll with panel and flow layout panel. the link as follow https://onedrive.live.com/embed?cid=C4A6F16F34D7540A&resid=C4A6F16F34D7540A%21133&authkey=AC-BXcngO7n2g9Q[^]
the UI link as follows http://i.imgur.com/ZYzVMuV.gif[^]
the above UI is designed in winform.
i just copied and follow their code to implement same in winform but mine is not working. i guess i am missing or making a small mistake for which my scrolling is not working.
so please first see image preview link and if u have trust then download the apps from one drive and run at your end.
you will see writing a very minimum line of code how a nice automatic scrolling can be done. looking for your help. if possible please investigate my code and tell me what mine is not scrolling. thanks
tbhattacharjee
|
|
|
|
|
I've looked at your sample, run the code, and I do not call what it produces "smooth animation" at all.
You are using Sven Walter's Metro FrameWork for WinForms; it's always good to reveal things like that in your first post.
You can easily produce the quality of animation shown in Sven's code if you take the ideas I've given you, and start to work.
I'll be happy to help you learn to how to build your own animation function for WinForms, but you have to take the first steps. Helping you fix some problem with code copied from Sven is not going to teach you anything.
Please, come back with your own code, and specific questions.
cheers, Bill
« I had therefore to remove knowledge, in order to make room for belief » Immanuel Kant
|
|
|
|
|
He wrote this code to scroll his panel
protected override CreateParams CreateParams
{
get
{
CreateParams cp = base.CreateParams;
cp.ExStyle |= 0x02000000;
return cp;
}
}
int _myval = 5;
protected override void OnMouseMove(MouseEventArgs e)
{
base.OnMouseMove(e);
if (e.Y < metroPanel1.Top || e.Y > metroPanel1.Top + metroPanel1.Height) return;
if (e.X <= metroPanel1.Left && e.X >= metroPanel1.Left - 40)
{
if (metroPanel1.HorizontalScroll.Value <= _myval)
{
metroPanel1.HorizontalScroll.Value = _myval;
}
else
{
metroPanel1.HorizontalScroll.Value -= _myval;
}
}
if (e.X <= (metroPanel1.Left + metroPanel1.Width + 40) && e.X >= (metroPanel1.Left + metroPanel1.Width))
{
metroPanel1.HorizontalScroll.Value += _myval;
}
}
and i follow the same but mine is not working. i am not trying to do any animation rather i want when i will place my mouse/left at the right most area of the panel then panel controls should start scroll. trying to simulate win8 start screen where lots of tiles are there and when people place his mouse at right/left most area then everything start scrolling.
please help. if u can help with code then answer.
thanks
tbhattacharjee
|
|
|
|
|
If you use your version of Sven's code, you need to use Visual Studio's debugging capabilities ... set break-points, single-step, etc. ... and isolate the problem in your code. Since you have Sven's code, which is working, you have something to compare directly with.
I am interested in helping people who develop their own solutions because that, I think, results in the maximum contribution of value to both the individual learning C# and writing code, and to CodeProject as a whole. Debugging/fixing a copy of another person's obscure undocumented code is not an activity that contributes to CodeProject, or you.
I repeat my assertion that you can achieve better looking, smoother scrolling, animation, than what Sven's code does.
You'll learn a lot writing your own version !
cheers, Bill
« I had therefore to remove knowledge, in order to make room for belief » Immanuel Kant
|
|
|
|
|
how do i delete my visual stuio project
|
|
|
|
|
Try this[^].
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
|
Hi,
I am writing an application with Windows forms which has to enable user to select a webcam connected to his computer via USB and print the video stream in the window. I need to get some of the frames (let say every 5th frame, but it depends on fps I get) and search it for an graphic object that was defined earlier by the user.
As I am new to c# and Visual Studio I was searching for an example of an application similar to what I want to do. I found a few examples on AForgery, but I would like to print original video with just added a few markers on it and AForgery gives me processed frames. Also, when I aded simple processing in the receving new frame event, the performace was pretty bad. I tried the WIA and what I get is an error when I try to call device selection dialog.
Device dev = dialog.ShowSelectDevice(WiaDeviceType.CameraDeviceType,true,false);
What I get is HRESULT exception with error code 0x80210015. I am not sure if WIA is exactly what I need, but because of this error I can't check it.
I need help with selecting the best video stream fiting that kind of application and the more I search, the more I am confused. I do not need to send video over IP or save it. I just need to present the video stream from the camera and sometimes get a frame (the best would be RGB) for processing. I would appreciate any suggestions on stream selecting or linking documentations/examples.
|
|
|
|
|
You may want to check out this[^] article.
admbrt wrote: AForgery I think you meant AForge.
/ravi
|
|
|
|
|
Thanks, I think this will do it.
And of course i meant AForge
|
|
|
|
|
|
Thanks, while working on this project I came across OpenCV and I think that is exactly what I need as in the future there will be some imageprocessing in my project. So I guess I'll use OpenCV to do all the work with Webcam.
|
|
|
|
|
Hi,
I am wondering when I can get the finger print attendance device without any finger print system.
I want to use it for testing finger attendance system in C#
I tried searching the net for it but I couldn't find it and I am not sure what do you call the device?
Thanks,
Jassim
Technology News @ www.JassimRahma.com
|
|
|
|
|
This[^] vendor seems to sell inexpensive devices and SDKs.
/ravi
|
|
|
|
|
How to use entity frame work in MVC web Application to fetch bulk records from database by joining multiple tables in MVC Web Application.
|
|
|
|
|
See this[^] tutorial.
/ravi
|
|
|
|
|
Seriously? There are entire BOOKS written on that very subject. You want someone to copy and paste and entire book into a forum post??
|
|
|
|
|
|
How to get the screen shots of dynamic display chart for a list of values?
In a loop need to change the line graph for each iteration and have to get the screenshot for the same.
|
|
|
|