myGully.com Boerse.SH - BOERSE.AM - BOERSE.IO - BOERSE.IM Boerse.BZ .TO Nachfolger
Zurück   myGully.com > Computer & Technik > Programmierung
Seite neu laden

c# - Canvas

Willkommen

myGully

Links

Forum

 
 
 
Themen-Optionen Ansicht
Prev Vorheriger Beitrag   Nächster Beitrag Next
Ungelesen 03.05.11, 12:11   #1
Dergecko911
Erfahrener Newbie
 
Registriert seit: Sep 2009
Beiträge: 95
Bedankt: 16
Dergecko911 ist noch neu hier! | 0 Respekt Punkte
Standard c# - Canvas

Servus,

hab ein kleines Problemchen mit einem Canvas in ner WPF.
Hab schonr elativ viel ausprobiert jedoch bekomm ichs nicht hin in ein Canvas zu zeichnen ohne direkt in der Main class zu sein.

ich poste einfach mal ein Beispiel

Lg DerGecko


in der main.xaml steht:
Code:
 Canvas Height="288" HorizontalAlignment="Left" Margin="0,23,0,0" Name="myCanvas" VerticalAlignment="Top" Width="501" /
In der main.cs
Code:
public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            test re = new test();
            re.paint(); <- geht nicht!
            paint(); <- geht!

        }
        public void paint()
        {
            PointCollection points = new PointCollection();
            points.Add(new Point(10, 0));
            points.Add(new Point(0, 10));
            points.Add(new Point(20, 10));

            LinearGradientBrush brush = new LinearGradientBrush();
            brush.StartPoint = new Point(0.5, 0);
            brush.EndPoint = new Point(0.5, 1);
            brush.GradientStops.Add(new GradientStop(Color.FromRgb(255, 0, 0), 0.0));
            brush.GradientStops.Add(new GradientStop(Color.FromRgb(0, 255, 0), 0.0));



            Polygon poly = new Polygon();
            poly.Fill = brush;
            poly.Points = points;
            //      startpos();
            //      Canvas.SetBottom(poly, pos_x);

            myCanvas.Children.Add(poly);
        }

    }

class test : MainWindow
{
    public test()
    { }

    public void paint()
    {
        PointCollection points = new PointCollection();
        points.Add(new Point(10, 0));
        points.Add(new Point(0, 10));
        points.Add(new Point(20, 10));

        LinearGradientBrush brush = new LinearGradientBrush();
        brush.StartPoint = new Point(0.5, 0);
        brush.EndPoint = new Point(0.5, 1);
        brush.GradientStops.Add(new GradientStop(Color.FromRgb(255, 0, 0), 0.0));
        brush.GradientStops.Add(new GradientStop(Color.FromRgb(0, 255, 0), 0.0));

        Polygon poly = new Polygon();
        poly.Fill = brush;
        poly.Points = points;
        myCanvas.Children.Add(poly);
    }
}
__________________
[ Link nur für registrierte Mitglieder sichtbar. Bitte einloggen oder neu registrieren ]
Dergecko911 ist offline   Mit Zitat antworten
 


Forumregeln
Du kannst keine neue Themen eröffnen
Du kannst keine Antworten verfassen
Du kannst keine Anhänge posten
Du kannst nicht deine Beiträge editieren

BB code is An
Smileys sind An.
[IMG] Code ist An.
HTML-Code ist Aus.

Gehe zu


Alle Zeitangaben in WEZ +1. Es ist jetzt 06:43 Uhr.


Sitemap

().