flash menu for windows form?? | Newbie | | Join Date: Sep 2009
Posts: 15
| | |
Hi,
I am working on this standalone application on C#.NET in which i dont want to use the basic UI that comes with .NET framework,i would like to use either flash menu or some other impressive menu like mac style menu or something.I am unable to find any such thing as "Fancy UI for winforms", please guide me menu stylings.
Regards,
Ankit Khare
| | Expert | | Join Date: Jun 2008 Location: Pretoria, South Africa
Posts: 410
| | | re: flash menu for windows form??
Have a look at WPF (Windows Presentation Foundation) MSDN Official WPF site
WPF exposes several classes which allow you to create fancy UIs and separate UI from logic code.
| | Newbie | | Join Date: Sep 2009
Posts: 15
| | | re: flash menu for windows form??
Unfortunately i am not supposed to use WPF right now,need to use only windows forms! :( any such thing for modifying UI?like i found one krytpton toolkit for improvising the various controls .NET has..
| | Expert | | Join Date: Jun 2008 Location: Pretoria, South Africa
Posts: 410
| | | re: flash menu for windows form??
Well you can create custom form shapes and themes, but Winforms does not offer the flexibility of flash/wpf unless you go and create a whole bunch of custom controls...
I have never worked with any tool which is specifically aimed at altering the look and feel of a winform app, so unfortunately I cannot point you to to any tools, I suppose Google/Bing will be your best bet to find a third party product which suits your needs.
|  | Moderator | | Join Date: Mar 2008 Location: Arizona, USA
Posts: 1,745
| | | re: flash menu for windows form??
Is this a homework project?
You could just make your fancy UI as images in photoshop, present them, and respond to click messages etc.
| | Newbie | | Join Date: Sep 2009
Posts: 15
| | | re: flash menu for windows form??
google bing...never heard of....will be learning about it today...Ya its a inhouse project..i can go for image editing but i wanted to give the carousel menu...something like this : http://www.shinedraw.com/animation-e...fish-eye-menu/ | | Expert | | Join Date: Jun 2008 Location: Pretoria, South Africa
Posts: 410
| | | re: flash menu for windows form?? Quote:
Originally Posted by ankitkhare google bing...never heard of....will be learning about it today...Ya its a inhouse project..i can go for image editing but i wanted to give the carousel menu...something like this : http://www.shinedraw.com/animation-e...fish-eye-menu/ Google Bing
That carousel menu can easily be created in winforms. Just take a careful look at whats happening there. It works with the MouseOver event.
There is a little bit of math involved in calculating the distance from the center of the image which affects the size of the image. (The image is largest when the mouse is in the x-axis center of the image).
An array (or list) of picture boxes and a few simple calculations are all you need to create that effect.
Spend a couple of hours and try to build it, it shouldn't take too long. Feel free to post if you are stuck on a specific aspect of the algorithm.
| | Newbie | | Join Date: Sep 2009
Posts: 15
| | | re: flash menu for windows form??
ya even i thought that it should'nt be tough,so i started working towards it,but was unable to map the exact behaviour.I was trying with a n nomber of buttons aligned in the same line,and on mouse hover on a button i was trying.. -
button.mouseover(){
-
for(;button[i].height<75,button[i].width<40;button.height++,button.width++)
-
{
-
if(button[i-1].height<60 && button[i+1].height<60)
-
{
-
button[i-1].height++;
-
button[i-1].width++;
-
-
button[i+1].height++;
-
button[i+1].width++;
-
delay(1);//some dealy i added so that it slowly expands
-
-
}
-
}
-
}
-
its just an idea what i was trying,not the exact code...but in carsouel manu,the image zooms in,not exactly when mouse comes exactly over the image,it zooms in when mouse moves near the image..also i wrote opposite for loop for mouse leave event,i am not very sure it will work or not,thats why i kept it on a hold for a while...
| | Newbie | | Join Date: Sep 2009
Posts: 15
| | | re: flash menu for windows form??
one more question,i wanted to start a separate thread for this,but as you seems to be online,i thought of asking here only...
What i want to do is that on click of any of these menu item,i want only one part of the same form to change,is itpossible?
for eg,in a single form suppose i have 3-4 panels,in the bottom most panel i have menu,in the left panel i have some tree structure or something and i want to change only the contents of the panel to change on menu click.Is it possible?throught xml ? any idea how?
Thanks,
Ankit
| | Expert | | Join Date: Jun 2008 Location: Pretoria, South Africa
Posts: 410
| | | re: flash menu for windows form?? Quote:
Originally Posted by ankitkhare one more question,i wanted to start a separate thread for this,but as you seems to be online,i thought of asking here only...
What i want to do is that on click of any of these menu item,i want only one part of the same form to change,is itpossible? Let's first get your menu working and then look at accessing parts of a form (which is indeed possible).
What I would suggest is that you first write the code to get just one image to change its size based on the mouse location. Once that is working we can look at getting the adjacent images to grow and shrink.
I would suggest that you create methods which will peek at the adjacent elements in the array/list and if an image exists, apply the sizing algorithm to it.
Instead of using for loops like you did, i would write a function to calculate what the image size should be based on the mouse position relative to the x-axis origin of the image.
So calcualte X-origin: - float xOrigin = pictureBox.width / 2;
You can then work out what size the image should be based on the distance the mouse is from xOrigin so if the picture is 200px wide, and the mouse is 40px from the origin, the image should be 60% of its "full size":
let dX be the distance from the origin (remember that distance should be an absolute value in this case)
dx/xOrigin*100 = % away from origin. We know that when %fromOrigin == 0 then image size = 100%
So 100 - percentageFromOrigin = percentageImageSize. So if the origin is at 50px and the mouse is at 85px then dX is 35px (remember distance is absolute)
percentageFromOrigin = dX/xOrigin*100 = 35/50*100 = 70%
thus,
ImageSizePercentage = 100 - 70 = 30%
Or something like that :) this is just a rough algorithm for calculating the size of the image, there are other ways to reach the correct value. Feel free to implement another method if you are more comfortable with it than with this one.
| | Newbie | | Join Date: Sep 2009
Posts: 15
| | | re: flash menu for windows form??
huff....lemme try that out! !
| | Newbie | | Join Date: Sep 2009
Posts: 15
| | | re: flash menu for windows form??
Hey thanks cloud255,it actually worked!! Fine tuning is left otherwise i have almost achieved the behaviour! I took n picture boxes dynamically created,and on mouse move even i have calculated the distance of the position of the cursor and center point of each picture, respectively i am zooming in and zooming out....how can i share the exe with you?
| | Newbie | | Join Date: Sep 2009
Posts: 15
| | | re: flash menu for windows form??
here's the code..i have used few things to get the things working so please suggest modifications: |  | Familiar Sight | | Join Date: Jul 2009 Location: Bangalore, INDIA
Posts: 251
| | | re: flash menu for windows form??
Pls use code tags... so its easy to experts to go through the code...
Regards
Dheeraj Joshi
| | Expert | | Join Date: Jun 2008 Location: Pretoria, South Africa
Posts: 410
| | | re: flash menu for windows form?? Quote:
Originally Posted by ankitkhare here's the code..i have used few things to get the things working so please suggest modifications: Hi,
At present I'm rather sick, I attempted to read through the code posted but its all a bit of blur right now. I promise I'll have a good look at it as soon as I'm better. My apologies.
|  | Moderator | | Join Date: Mar 2008 Location: Arizona, USA
Posts: 1,745
| | | re: flash menu for windows form?? TIP: When you are writing your question, there is a button on the tool bar that wraps the [code] tags around your copy/pasted code. It helps a bunch. Its the button with a '#' on it. More on tags. They're cool. Check'em out. | | Newbie | | Join Date: Sep 2009
Posts: 15
| | | re: flash menu for windows form??
thanks for the tip sir,I will take care of it from the next time!
@cloud255, no problem at all...i will be waiting !
| | Expert | | Join Date: Jun 2008 Location: Pretoria, South Africa
Posts: 410
| | | re: flash menu for windows form?? Quote:
Originally Posted by ankitkhare here's the code..i have used few things to get the things working so please suggest modifications: Hi
This seems to be ok, the only suggestion I would make is that you replace all those hard coded values with constants, this will help make re-factoring and maintenance easier.
| | Newbie | | Join Date: Sep 2009
Posts: 15
| | | re: flash menu for windows form??
hey,
Whatver i have done can also be achieved by another way,please correct me if i am wrong...
OnMouseHover over any picbox will start zooming the image inside it..wid a for loop i can do that...eg -
public void picbox_mousehover()
-
{
-
for(int temp=picbox.image.height;picbox.image.height<100;temp++)
-
{
-
picbox.image=new Bitmap(picbox.image,temp,temp);
-
MessageBox.show(temp.tostring());
-
}
-
-
}
-
It works,but the problem is that it first finishes execution of for loop then displays the image.Zooming effect is not visible...to cross check that i just inroduced message box inside the for and zooming effect is visible :(
I also tried thread.sleep() inside for loop,but that also didnt work the way i wanted it to work! Any idea?
|  | Moderator | | Join Date: Mar 2008 Location: Arizona, USA
Posts: 1,745
| | | re: flash menu for windows form??
inside your loop you need to refresh the picbox - picbox.refresh();
-
application.DoEvents();
Watch your memory as this happens tho...
Your new bitmap doesn't get disposed of inside that tight loop because garbage collection takes place when the app and OS feel its a good time to do so.
The old bitmap that you have no reference to is still taking up memory and you have no reference to it to call - oldbitmap.Dispose();
-
GC.Collect();
So if you make 100 1000x1000 bitmaps you are going to eat memory quickly.
Thread.sleep is something to avoid on your main (only) thread in my opinion. It does exactly what it says. It totally sleeps the current thread. That includes refreshes, repaints, events, responding to events, communication and any and all thinking being done on this thread. It exists to completely halt a thread of everything for the specified time. If you have an LED graphic on its own thread its great for the pause between blinking. 'on,' sleep(1000), "off", sleep(1000).
It should not be thought of as - Thread.KillTimeBeforeGoingToNextStepButStillProcessInBackground(1000);
| | Familiar Sight | | Join Date: Jul 2009 Location: Calgary, Alberta, Canada
Posts: 211
| | | re: flash menu for windows form?? Quote:
Originally Posted by tlhintoq Thread.sleep is something to avoid on your main (only) thread in my opinion. It does exactly what it says. It totally sleeps the current thread. That includes refreshes, repaints, events, responding to events, communication and any and all thinking being done on this thread. It exists to completely halt a thread of everything for the specified time. If you have an LED graphic on its own thread its great for the pause between blinking. 'on,' sleep(1000), "off", sleep(1000).
It should not be thought of as - Thread.KillTimeBeforeGoingToNextStepButStillProcessInBackground(1000);
Good point, though this brings to mind a question. Would a better approach be... - int DELAY = 1000;
-
...
-
-
DateTime initial = DateTime.Now;
-
while (1)
-
{
-
Application.DoEvents();
-
DateTime current = DateTime.Now;
-
TimeSpan elapsed = current - initial;
-
-
if (elapsed.TotalMilliseconds > DELAY) break;
-
}
There are better ways to implement this of course, but hopefully that rough bit of code demonstrates what I'm getting at.
|  | Moderator | | Join Date: Mar 2008 Location: Arizona, USA
Posts: 1,745
| | | re: flash menu for windows form?? -
namespace tlhintoq
-
{
-
public class Common
-
{
-
public static void Wait(int WaitSeconds)
-
{
-
DateTime timeout = DateTime.Now.AddSeconds(WaitSeconds);
-
while (DateTime.Now < timeout) { Application.DoEvents(); }
-
}
-
}
-
}
-
You could of course do this in milliseconds... or days.
This way I can call it whenever I need to wait a bit. -
private voide SomeMethod()
-
{
-
// Do something
-
// Something else
-
tlhintoq.Common.Wait(2); // Waits 2 seconds
-
// Carry on
-
// These aren't the droid you're looking for
-
// You don't need to see his papers
-
// Move along
-
}
-
|  | Similar C# / C Sharp bytes | | | /bytes/about
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 226,272 network members.
|