tutorials.de Buch-Aktion 05/2012
ERLEDIGT
NEIN
ANTWORTEN
0
ZUGRIFFE
194
EMPFEHLEN
  • An Twitter übertragen
  • An Facebook übertragen
AUF DIESES THEMA
ANTWORTEN
  1. #1
    C-H C-H ist offline Mitglied Brokat
    Registriert seit
    Jan 2005
    Beiträge
    256
    Hi!

    Ich bin gerade dabei einen customRenderer für das ToolStrip-Control zu schreiben, so dass es sich unter XP optisch genauso verhält wie unter Vista (z.B. wie die grüne Toolbar im Windows Explorer). Dazu habe ich 3 png Grafiken erstellt, jeweils für Links, Rechts und die Mitte. Mein Problem ist jetzt, dass sie nicht richtig gezeichnet werden. Soll heißen, wenn ich z.B. das linke Bild (4 Pixel breit) an Position X=2, Y=0 zeichne, sieht es so aus wie das (vergrößerte) Bild im Anhang.

    Es scheint so zu sein, dass der Ursprung der Textur immer gleich bleibt, auch wenn ich das zu zeichnende Rectangle in der Position verschiebe. Kann ich diesen Ursprung irgendwie beeinflussen? Oder kann ich mein Ziel anders erreichen?

    Hier noch mein Code:

    Code :
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    
    [SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]
    Protected[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Overrides[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] OnRenderButtonBackground([/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] e [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] System.Windows.Forms.ToolStripItemRenderEventArgs)
    [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] button [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] ToolStripButton = e.Item
    [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] button.Selected [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Then
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] b [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] Brush
    [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] bi [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] Image
    [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]' Left Image
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]bi = [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] System.Drawing.Bitmap([/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]My[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].Resources.toolstripbutton_overlay_hover_left)
    b = [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] TextureBrush(bi)
    e.Graphics.FillRectangle(b, 2, 0, 4, 21)
    [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]' Center Image
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]bi = [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] System.Drawing.Bitmap([/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]My[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].Resources.toolstripbutton_overlay_hover_center)
    b = [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] TextureBrush(bi)
    e.Graphics.FillRectangle(b, 0, 0, (e.Item.ContentRectangle.Width - 8), 21)
    [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]' Right Image
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]bi = [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] System.Drawing.Bitmap([/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]My[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].Resources.toolstripbutton_overlay_hover_right)
    b = [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] TextureBrush(bi)
    e.Graphics.FillRectangle(b, 0, 0, 4, 21)
    [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]If
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] button.Pressed [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]OrElse[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] button.Checked [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Then
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]e.Graphics.FillRectangle([/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] SolidBrush(Color.CornflowerBlue), e.Item.ContentRectangle)
    [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Else
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]e.Graphics.FillRectangle([/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] SolidBrush(Color.Transparent), e.Item.ContentRectangle)
    [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]If
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Sub
    [/COLOR][/SIZE][/COLOR][/SIZE]
    Angehängte Grafiken Angehängte Grafiken  
     

Ähnliche Themen

  1. c# zeichnen
    Von minfler im Forum .NET Grafik und Sound
    Antworten: 6
    Letzter Beitrag: 15.05.09, 11:46
  2. Zeichnen
    Von mal2000b im Forum Swing, Java2D/3D, SWT, JFace
    Antworten: 4
    Letzter Beitrag: 23.10.07, 20:10
  3. Zeichnen
    Von Ymaster im Forum Photoshop
    Antworten: 3
    Letzter Beitrag: 11.07.07, 22:33
  4. Säulen Zeichnen, Drachen zeichnen
    Von RudeJava im Forum Photoshop
    Antworten: 34
    Letzter Beitrag: 17.07.05, 09:34
  5. Pad zum Zeichnen?
    Von Carndret im Forum Photoshop
    Antworten: 2
    Letzter Beitrag: 22.10.02, 18:09