Click here to Skip to main content
15,881,757 members
Home / Discussions / C#
   

C#

 
AnswerRe: Code style [modified] Pin
Pete O'Hanlon28-Jun-11 0:00
mvePete O'Hanlon28-Jun-11 0:00 
GeneralRe: Code style Pin
BobJanova28-Jun-11 0:06
BobJanova28-Jun-11 0:06 
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
Lutosł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
Lutosław28-Jun-11 1:17 
GeneralRe: Code style Pin
BobJanova28-Jun-11 2:41
BobJanova28-Jun-11 2:41 
AnswerRe: Code style Pin
BobJanova28-Jun-11 0:05
BobJanova28-Jun-11 0:05 
I prefer the second, but I'd take the ellipse drawing out of the switch, since the logic is (to me) 'set up parameters depending on head type, then draw it' and the last part is common. So I'd do:

protected virtual void RenderHead(DrawingContext drawingContext, NoteHeadTypes type)
{
    double y = NoteVerticalPosition;
    double xRadiusFactor, yRadiusFactor;
    Brush brush;
    Pen pen;

    switch (type)
    {
        case NoteHeadTypes.Filled:
            yRadiusFactor = 1.1;
            xRadiusFactor = 1.2;
            brush = Brushes.Black;
            pen = NoteHeadPen;
            break;
        case NoteHeadTypes.Empty:
            yRadiusFactor = xRadiusFactor = 1;
            brush = Brushes.Transparent;
            pen = NoteBeamPen;
            break;
        default:
            // I think you need this to stop it complaining about 
            // unassigned variables below
            throw new ArgumentException("Unknown head type");
    }

    double xRadius = HeadXRadius * xRadiusFactor,
           yRadius = HeadYRadius * yRadiusFactor;
    drawingContext.DrawEllipse(brush, pen, xRadius / 2 + XOffset + 4.5, y, xRadius - 1, yRadius);
}

GeneralRe: Code style Pin
Lutosław28-Jun-11 1:03
Lutosław28-Jun-11 1:03 
AnswerRe: Code style PinPopular
Keith Barrow28-Jun-11 0:23
professionalKeith Barrow28-Jun-11 0:23 
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
Lutosł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
Lutosł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
BobJanova28-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
BobJanova28-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
Lutosław28-Jun-11 8:08 
NewsNOTE 3 ,4 Pin
Lutosław28-Jun-11 0:48
Lutosław28-Jun-11 0:48 
AnswerRe: Code style [modified] Pin
PIEBALDconsult28-Jun-11 3:09
mvePIEBALDconsult28-Jun-11 3:09 
AnswerRe: Code style Pin
SledgeHammer0128-Jun-11 7:34
SledgeHammer0128-Jun-11 7:34 
GeneralRe: Code style Pin
Lutosław28-Jun-11 8:04
Lutosław28-Jun-11 8:04 
GeneralRe: Code style Pin
SledgeHammer0128-Jun-11 8:51
SledgeHammer0128-Jun-11 8:51 

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.