Click here to Skip to main content
15,042,814 members
Home / Discussions / C#
   

C#

 
GeneralRe: Code style Pin
Pete O'Hanlon28-Jun-11 0:30
mvePete O'Hanlon28-Jun-11 0:30 
GeneralRe: Code style Pin
Lutosław28-Jun-11 0:54
MemberLutosław28-Jun-11 0:54 
GeneralRe: Code style Pin
Pete O'Hanlon28-Jun-11 1:07
mvePete O'Hanlon28-Jun-11 1:07 
GeneralRe: Code style Pin
Lutosław28-Jun-11 1:17
MemberLutosław28-Jun-11 1:17 
GeneralRe: Code style Pin
BobJanova28-Jun-11 2:41
MemberBobJanova28-Jun-11 2:41 
AnswerRe: Code style Pin
BobJanova28-Jun-11 0:05
MemberBobJanova28-Jun-11 0:05 
GeneralRe: Code style Pin
Lutosław28-Jun-11 1:03
MemberLutosław28-Jun-11 1:03 
AnswerRe: Code style PinPopular
Keith Barrow28-Jun-11 0:23
professionalKeith Barrow28-Jun-11 0:23 
I'd personally go for option 1, I'm of the opinion that switches are evil, but everytime I express this view I get downvoted. Rather than explain why here, have a look at SwitchStatementsSmell[^].

If you can't alter your class design much, you could consider this option (removing duplication under the "DRY" principle) :

virtual void RenderHead(DrawingContext drawingContext, 
                             Brush brush = Brushes.Transparent, 
                             Pen pen = NoteBeamPen, 
                             decimal xScale =1, 
                             decimal yScale =1)
{
    double y = NoteVerticalPosition;
    double yRadius = HeadYRadius * yScale;
    double xRadius = HeadXRadius * xScale;
    drawingContext.DrawEllipse(brush, pen, new Point(xRadius / 2 + XOffset + 4.5, y), xRadius - 1, yRadius);
}
	
protected virtual void RenderHead(DrawingContext drawingContext, NoteHeadTypes type)
{
    if(type==NoteHeadTypes.Filled)
        RenderHead(drawingContext, Brushes.Black, NoteHeadPen, 1.2, 1.1);
    else if(type==NoteHeadTypes.Empty)
        RenderHead(drawingContext);
}


Note this code only works with .net 4 (for brevity), but the named arguments can easily be refactored back.

GeneralRe: Code style Pin
Pete O'Hanlon28-Jun-11 0:34
mvePete O'Hanlon28-Jun-11 0:34 
GeneralRe: Code style Pin
Lutosław28-Jun-11 0:45
MemberLutosław28-Jun-11 0:45 
GeneralRe: Code style Pin
Keith Barrow28-Jun-11 1:22
professionalKeith Barrow28-Jun-11 1:22 
GeneralRe: Code style Pin
Lutosław28-Jun-11 1:50
MemberLutosław28-Jun-11 1:50 
GeneralRe: Code style Pin
Keith Barrow28-Jun-11 1:57
professionalKeith Barrow28-Jun-11 1:57 
GeneralRe: Code style Pin
BobJanova28-Jun-11 3:45
MemberBobJanova28-Jun-11 3:45 
GeneralRe: Code style Pin
Keith Barrow28-Jun-11 7:32
professionalKeith Barrow28-Jun-11 7:32 
GeneralRe: Code style Pin
BobJanova28-Jun-11 7:42
MemberBobJanova28-Jun-11 7:42 
GeneralRe: Code style Pin
Pete O'Hanlon28-Jun-11 7:59
mvePete O'Hanlon28-Jun-11 7:59 
GeneralRe: Code style Pin
Lutosław28-Jun-11 8:08
MemberLutosław28-Jun-11 8:08 
NewsNOTE 3 ,4 Pin
Lutosław28-Jun-11 0:48
MemberLutosław28-Jun-11 0:48 
AnswerRe: Code style [modified] Pin
PIEBALDconsult28-Jun-11 3:09
professionalPIEBALDconsult28-Jun-11 3:09 
AnswerRe: Code style Pin
SledgeHammer0128-Jun-11 7:34
MemberSledgeHammer0128-Jun-11 7:34 
GeneralRe: Code style Pin
Lutosław28-Jun-11 8:04
MemberLutosław28-Jun-11 8:04 
GeneralRe: Code style Pin
SledgeHammer0128-Jun-11 8:51
MemberSledgeHammer0128-Jun-11 8:51 
GeneralRe: Code style Pin
Lutosław28-Jun-11 9:47
MemberLutosław28-Jun-11 9:47 
QuestionCreating a multidimensional array from class Pin
lada_vyvojar27-Jun-11 20:34
Memberlada_vyvojar27-Jun-11 20:34 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.