Improved and Recoded RibbonMenuButton - CodeP...
来源:百度文库 编辑:神马文学网 时间:2024/05/15 16:13:56
Comments and Discussions
FAQ New Message Msgs 1 to 25 of 77 (Total in Forum: 77) (Refresh) FirstPrevNext Download - Refactored w/ Lot's of Bug fixes and Performance Improvments Tom Guinther 12:25 26 Nov '10 It is really sad that this control is rated so highly (perception rules) as it was very poorly written and is barely usable within a real application. Still, the overall drawing concepts were reasonable so I decided to spend 4 hours or so trying to make it more reasonable. After the 4 hours I think most of the common problems are resolved but I stopped once the basic functionality was no longer complete junk. All in all, this control could have been written correctly in about 4 hours so I don't think there is any point in wasting more time on it, but if I fix any other bugs I will update my solution (but not this post.)The re-factoring will break existing code but most of the changes are relatively easy to fix.
The solution below is VS 2010. You can obviouly jack the code into the existing solution...but I leave that up to you.
https://sites.google.com/site/atomicdog63/home/RibbonMenuControlTest.zip?attredirects=0&d=1[^]
Tom Guinther
http://mothership.blogdns.net/cs/blog
Reply·Email·View Thread·PermaLink·Bookmark Rate this message: 1 2 3 4 5 Ribbon button Viktor_BVP 9:02 15 Nov '10 Fine, Excellent, Indispensable. Thank You.
Reply·Email·View Thread·PermaLink·Bookmark Rate this message: 1 2 3 4 5 My vote of 5 Viktor_BVP 9:00 15 Nov '10 Fine, Excellent, Indispensable. Thank You.
Reply·View Thread·PermaLink·Bookmark Rate this message: 1 2 3 4 5 My vote of 5 Heaven2020 16:12 3 Nov '10 excellent code
Reply·View Thread·PermaLink·Bookmark Rate this message: 1 2 3 4 5 Brilliant :) Ant2100 18:39 10 Sep '10 I really love this, thanks!
Check out my unit conversion software for Windows!
Reply·Email·View Thread·PermaLink·Bookmark Rate this message: 1 2 3 4 5 My vote of 5 Member 3288788 14:42 7 Aug '10 Great..
Reply·View Thread·PermaLink·Bookmark Rate this message: 1 2 3 4 5 My vote of 5 pebeeye 23:23 28 Jul '10 how excellent it's
i do like it!
Reply·View Thread·PermaLink·Bookmark Rate this message: 1 2 3 4 5 Text Aligned Don't work sepel 3:50 6 Apr '09 Hi.
When I set TextAlign to right or left It hasn't any effect.
sepel
Reply·Email·View Thread·PermaLink·Bookmark 2.67/5 (3 votes) Rate this message: 1 2 3 4 5 Extremely Awesome Work
Xmen
5:54 10 Mar '09 Thanks for the damn nice article...5 TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87??6?N8?BcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN%
Rs0~53%eYrd8?mt^7Z6]iTF+(EWfJ9zaK-i?TV.C\y
--------------------------------------------------------
128 bit encrypted signature, crack if you can
Reply·Email·View Thread·PermaLink·Bookmark Rate this message: 1 2 3 4 5
Reply·Email·View Thread·PermaLink·Bookmark 3.33/5 (8 votes) Rate this message: 1 2 3 4 5 Great! And how about glowing one? Hugo Tomas 5:36 24 Dec '08 Hi,
Great button! And how about glowing one? Like this:
http://www.codeproject.com/KB/GDI-plus/glowbutton.aspx[^]
Hugo Tomas
Reply·Email·View Thread·PermaLink·Bookmark 5.00/5 (1 vote) Rate this message: 1 2 3 4 5 Colors, ForeColor Infinity999 8:37 22 Dec '08 When I set ForeColor as Gray or tints of Gray Button text color become red or tints of red.
Help me please... Why gray became red?
Reply·Email·View Thread·PermaLink·Bookmark 2.00/5 (2 votes) Rate this message: 1 2 3 4 5 Thank you so much for your amazing posts - I have few questions Wael Salman 7:35 19 Dec '08 Hi,
Thank you again for your work , it is amazing
I will be so happy and thankful if you answer me about my questions.
I am not so proffesional in C# .Net , but I am trying to dive deeply into this amazing language, I am software engineer since 8 years , but working with C++, emebdded .
1. How can you create dll and then add it to the ToolBox in order to have new tools that we can drag it to our controls??
2. How can you create specific ICon Image and locate it in its place in teh control??
3. whic resources, articles, researches did you use in order to study all of this stuff??
I will be thankfull i fyou can provice me with all the needed in order to start develp things like this??
thank you
Wael
Wael...Where Imagination Is Touched...
Reply·Email·View Thread·PermaLink·Bookmark 2.00/5 (1 vote) Rate this message: 1 2 3 4 5 Some properties did not work :( [modified] Trung D 2:49 9 Aug '08 Hi Mr. Pablo,
First, I have to say that your library is pretty cool . I hope that you will keep it going better .
But, I do not know how to make Mnemonic to the button.
Example when I type 'E&xit' the button's text display is still 'E&xit' when it has to be 'Exit' with underline at 'x' character.
I cannot make tab order among those buttons.
I cannot create the AcceptButton or CancelButton on my form.
I was thrown an exception when set the Radius <= 1 and i had to go to the *.designer.cs to edit.
The Text Alignment does not work too .
And when i run my Test application, i pressed on the button and there were 3 sides of the bounding rectangle work. I think if 4 sides work together, your button will be more cooler
But did I do something wrong? Because your ribbon button extends the Button and so those properties above have to work.
I hope to see some good news from you. Have a nice day .
modified on Saturday, August 9, 2008 3:00 AM
Reply·Email·View Thread·PermaLink·Bookmark Rate this message: 1 2 3 4 5 Tab key press piyush7419820 2:21 6 May '08 I have placed two textbox and one this button.
Now when i move from one control to another by Tab key press the button don't get focus.
Whey you replace this button with normal button, the normal button get focus and it show this by border around button. But this button don't.
Can you help me ?
Reply·Email·View Thread·PermaLink·Bookmark 3.50/5 (3 votes) Rate this message: 1 2 3 4 5 strip menu does not work by me trupik 2:14 28 Feb '08 When I set ContextStripMenu to a Ribbon menu and click the button, the menu does not render itself correctly. It just is all black.
In design time, when I click the Type here area in the RibbonMenu to add a new menu item, the UI stucks in some kind of endless cycle.
Am I the only one having this trouble???
Reply·Email·View Thread·PermaLink·Bookmark 1.50/5 (2 votes) Rate this message: 1 2 3 4 5 Found a bug on right clicking a button... [modified] Octopod 11:50 10 Jan '08 Its easy to reproduce, simply right click in the right part (the contextual part with the arrow) of the button named "Paste History Menu".
Then try to click another button... it's now stuck.
The same bug occurs with all buttons that have same kind of contextuel part ("Write & Close" for example).
Anyway, pretty cool control, really good work.
Alexis.
modified on Monday, January 14, 2008 5:20:39 PM
Reply·Email·View Thread·PermaLink·Bookmark Rate this message: 1 2 3 4 5 so cool JackChen1987 4:11 8 Jan '08 Thank you I love you so much
Reply·Email·View Thread·PermaLink·Bookmark Rate this message: 1 2 3 4 5 I'm confused tcsoccerman 19:49 4 Dec '07 First i'd like to say that this is the control that many many many many many people are looking for. It includes may features of lots of seperate controls out there. Someone made a split button (a boring one too). someone made a glowing one. someone made a colorful one. You joined all that together. Now people like me can have a common button throughout their app and still have all the functions they need. Thank you.
Second, I can't quite figure out a few things. First of all, i can't seem to get the arrow to point right, even though that's what i set it as. Second, the color part is a little confusing, can you discribe that a little more? What does ispressed and keepressed mean and theres just a few things that don't seem to be working visually. The Grouppos for example.
Reply·Email·View Thread·PermaLink·Bookmark 1.67/5 (4 votes) Rate this message: 1 2 3 4 5 Another CPU bug Jordiproatec 8:30 29 Nov '07 When I click the ribbonmenubutton lots of OnPaint events was send by the "set" method in the ColorBase, ColorOn and ColorPress properties:
public Color ColorBase
{
get { return _baseColor; }
set
{
_baseColor = value;
R0 = _baseColor.R;
B0 = _baseColor.B;
G0 = _baseColor.G;
A0 = _baseColor.A;
RibbonColor hsb = new RibbonColor(_baseColor);
if (hsb.BC < 50)
{
hsb.SetBrightness(60);
}
else
{
hsb.SetBrightness(30);
}
if (_baseColor.A > 0)
_baseStroke = Color.FromArgb(100, hsb.GetColor());
else
_baseStroke = Color.FromArgb(0, hsb.GetColor());
here---> this.Invalidate();
}
}
I fix this executing the set code only when the property change:
public Color ColorBase
{
get { return _baseColor; }
set
{
if (_baseColor != value)
{
_baseColor = value;
R0 = _baseColor.R;
B0 = _baseColor.B;
G0 = _baseColor.G;
A0 = _baseColor.A;
RibbonColor hsb = new RibbonColor(_baseColor);
if (hsb.BC < 50)
{
hsb.SetBrightness(60);
}
else
{
hsb.SetBrightness(30);
}
if (_baseColor.A > 0)
_baseStroke = Color.FromArgb(100, hsb.GetColor());
else
_baseStroke = Color.FromArgb(0, hsb.GetColor());
this.Invalidate();
}
}
}
Thanks for reading and excuse my poor English
Reply·Email·View Thread·PermaLink·Bookmark 2.80/5 (3 votes) Rate this message: 1 2 3 4 5 3 bug fixes (includin CPU issues) gpgemini 17:01 13 Oct '07 Hi,
First of all - Jaun, I LOVE your control, it's probably one of the best in CodeProject.
But as soon as I started using it, i noticed it has CPU consumption issues (I always have SiMeter on, so noticing it was a breeze).
It has two CPU problems, first is that moving the mouse around the buttons causes major CPU usage, which probably happens due to over-painting the buttons (and should be fixed by optimizing the code), and second that it has bursts of massive CPU usage with no user/mouse interaction. The latter is obviously a bug.
all bugs/fixes here relate to the RibbonMenuButton.cs file.
(fixed file is linked at the end of the post)
Bug #1: when moving the mouse quickly over a split button, or two non-split buttons, the CPU usage jumps to 100% until the mouse is moved over the buttons again (do it too many times and you are stuck with 100%).
This is a major application killer, and obviously cannot be left unfixed.
To locate the CPU leakage, I went to the immediate suspect: OnPaint().
Added a WriteLine("Paint" + DateTime.Millisecond) to see each time a button is painted, and I saw it was bombarding with OnPaint() calls for no reason.
Add a breakpoint AFTER the bombardment has started and you find the perpetrator:
timer1_Tick() is being called, and executes the following in the "Leaving" region:
else
{
this.Refresh();
}
Obviously the timer went out of control, so I added a timer1.Stop() statement before this.Refresh():else
{
timer1.Stop();
this.Refresh();
}
And what do you know, the bug is gone.Hurray !
But obviously this timer is good for something ...
Since I only use non-fading buttons (I want maximum performance) I tried the fix on a fading button, and sadly it broke.
So I tested to see if the bug is unique to non-fading buttons, or affects all buttons, and turns out it only happens with non-fading buttons.
So I patched the fix to affect only non-fading buttons:
else
{
if (i_factor == 0)
timer1.Stop();
this.Refresh();
}
Bug #1 fixed.
Bug #2: When the mouse is hovering over a button, periodic OnPaint() calls are executed.
With the WriteLine() thing in OnPaint I was able to notice a weird behavior, that had little effect on CPU usage but was clearly a bug - a hovering non-moving mouse over a button was producing OnPaint() calls, slowly but constantly (around 2-10 per second), with varying effect on different buttons.
To catch this, I added a breakpoint in OnPaint that hit after 50 passes (to avoid regular OnPaint calls) and put the mouse over a button. After a few seconds I found the second perpetrator:
The overrriden OnMouseMove() method.
protected override void OnMouseMove(MouseEventArgs mevent) {
if (mouse & this.SplitButton == e_splitbutton.Yes) {
xmouse = PointToClient(Cursor.Position).X;
ymouse = PointToClient(Cursor.Position).Y;
this.Refresh();
}
base.OnMouseMove(mevent);
}
After taking a look at it, I found nothing wrong about it (except the really weird way to get xmouse and ymouse, why not use the mevent.X and mevent.Y values ?).The only suspicious thing was using this.Refresh() inside a OnMoueMove() event handler.
So I tested it in a small program outside, and indeed, calling this.Refresh() (or this.Invalidate()) inside a OnMouseMove() handler is a BAD idea - it causes the OnMouseMove() event to be called repeatedly and indefinitely.
It's probably some internal WinForms bug/feature (or maybe it's an abuse of the API), but either way I fixed it by checking that the mouse has ACTUALLY moved, before calling this.Refresh():
protected override void OnMouseMove(MouseEventArgs mevent)
{
if (mouse & this.SplitButton == e_splitbutton.Yes)
{
prev_xmouse = xmouse;
prev_ymouse = ymouse;
xmouse = PointToClient(Cursor.Position).X;
ymouse = PointToClient(Cursor.Position).Y;
if (prev_xmouse != xmouse || prev_ymouse != ymouse)
this.Refresh();
}
base.OnMouseMove(mevent);
}
Bug #2 fixed.
Bug #3: This one is a non-CPU related, when RIGHT-clicking the arrow of a split-button, AND then clicking outside the opened context menu, ALL the RibbonButtons stop reacting to mouse events (except click events) until the context menu is clicked properly.
This one was obviously related to mouseDown and mouseUp events, so I cheched them out.
I found that when clicking the button, there is a check in the MouseUp event if the click was inside the arrow area (hmmmm, suspicious already) and if so, the conetxt menu is opened under the button, if not, the event is passes to the base.
First attempt: lets pass the event to the base either way. Quickly enough it turned out to be a bad idea. But why ? Since this causes the context menu to open under the mouse, and then in a split of a second to move under the button. Taking another look at the problem I noticed that when right-clicking the button NOT in the arrow area, the context menu is opened under the mouse, and in the arrow area it is overridden and is opened under the button. But in the latter case, the base class event handler is never called. The mouseUp event never reaches the base class and the mouse state is messed up.
To fix this, I added a check in the MouseUp method, if the click is a RIGHT-click, pass the event to the base class and return, the effect of this is that the context menu is opened naturally and all is good, if the click is a LEFT-click the context menu is opened manually under the button, and all is good.
Bug #3 fixed.
Ce tout.
The fixed file is here:
http://gpgemini.googlepages.com/RibbonMenuButton.zip
Notice that these are plain patches to the found bugs, I hope Juan takes a look at them and fixes them properly in the next release.
Reply·Email·View Thread·PermaLink·Bookmark 2.52/5 (12 votes) Rate this message: 1 2 3 4 5 TextAlign requests are ignored GrantM 16:19 2 Oct '07 TextAlign requests are being ignored, even in the demo application. Any suggestions? They don't shift at all from their current locations.
Other than that, I love it!
Reply·Email·View Thread·PermaLink·Bookmark 3.29/5 (6 votes) Rate this message: 1 2 3 4 5 How to unable a RibbonMenuButton? ivanchain@hotmail.com 20:43 16 Sep '07 I want to do this:
Unable a button, that means, the button could not be clicked and the image on it is showed as grey-color.
I tried to set the RibbonMenuButton.enable to false, the result is: yes, the button could not be clicked, BUT, the image on it is still a colorful one, just looks like a common button.
So If I don't click it, I can't tell an enable button or an unable button from appearance. I thinks this is not good.
thanks!
123
Reply·Email·View Thread·PermaLink·Bookmark 1.00/5 (2 votes) Rate this message: 1 2 3 4 5 Hi, about the icons ivanchain@hotmail.com 9:44 11 Sep '07 Hi, I read your answers that you get the icons from the gnome.
Sorry for my stupid, I don't know how to download the icons there. Could you tell me?
For example, I found an icons set at:
http://art.gnome.org/themes/icon/1112
I tried to download it, but the .rar package could not be opened(report an error). and The context seem to be .tar file, not the icon file. How do you get the png out?
thanks.
123
Reply·Email·View Thread·PermaLink·Bookmark Rate this message: 1 2 3 4 5 Re: Hi, about the icons Alpha Nerd 13:32 24 May '08 Some are icons from the Tango theme. They have a normal RAR file, which I have decompressed with WinRAR suceesfully.
Reply·Email·View Thread·PermaLink·Bookmark 5.00/5 (1 vote) Rate this message: 1 2 3 4 5 Last Visit: 2:20 22 Dec '10 Last Update: 2:25 22 Dec '10 1234 Next »
General News Question Answer Joke Rant Admin
Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+PgUp/PgDown to switch pages.
PermaLink | Privacy | Terms of UseLast Updated: 5 Jun 2007
Copyright 2007 by Juan Pablo G.C.
Everything else Copyright © CodeProject, 1999-2010
Web22 | Advertise on the Code Project Spread for COM/ActiveX by GrapeCity
FarPoint Spread for COM/ActiveX by GrapeCity...
www.farpointspread.com ActiveReports by GrapeCity
ActiveReports by GrapeCity is the...
www.datadynamics.com BinaryVirtualizingWrapPanel .NET
BinaryVirtualizingWrapPanel .NET is a UI...
www.binarymission.co.uk See Also...Creating PDF Documents in ASP.NET
How to create PDF documents in ASP.NET.
A Fast CSV Reader
A reader that provides fast, non-cached,...
A Simplified SQL-CSV Import/Export Functionality
A simplified SQL-CSV import/export functionality.
Transferring Data Using SqlBulkCopy
An article on how to transfer data using...
Importing CSV Data and saving it in database
This article shows how to import CSV data and...
Announcements Mobile Virtual Tech Summit On Demand Got an Azure app? Win an Xbox & Kinect The Daily Insider30 free programming booksDaily News: Signup now.
Improved and Recoded RibbonMenuButton - CodeP...
Rich OutlookBar in XP and Vista style - CodeP...
Improved Balance Exercise
Improved calendar helper with ajax paging
Qt 4.6, now with improved DirectFB support!
Chinese people's livelihoods greatly improved
How Pain Treatment Has Improved in Recent Years
Building and Installing ACE and Its Auxiliary Libraries and Services
google and microsoft interview questions and solutions
Beijing and Havana: Political Fraternity and ...
java, unicode and xml
process control and management
process control and management1
unix and c
Faculty and Staff
CScanGenner Design And Implement
David and Google
MIT Policies and Procedures
Solidot - Rails and Django
Slate | Trial and Terror
Fire and Motion
Smoking and Fuming
AJAX Basics and Directions
Site Maps and SEO