• Save
Wpf Workgroup 3
Upcoming SlideShare
Loading in...5
×

Like this? Share it with your network

Share

Wpf Workgroup 3

  • 3,729 views
Uploaded on

The third WPF workgroup at FCS, UAIC

The third WPF workgroup at FCS, UAIC

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
3,729
On Slideshare
3,725
From Embeds
4
Number of Embeds
2

Actions

Shares
Downloads
0
Comments
0
Likes
0

Embeds 4

http://www.slideshare.net 3
https://www.linkedin.com 1

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. Andrei Iacob Microsoft Student Partners
  • 2. Agenda
    • Intro
    • 2D - Clasa Shape - Linii - alte forme primitive geometrice - Brushes & pens - Path , “geometrii” şi mini-limbajul său - Transform ări
    • XAML exploitation
  • 3. Intro
    • XAMLPad
    • Cuvinte cheie: SVG, Media Integration Layer, FrameworkElement (UIElement), GDI+
  • 4. Ierarhia
    • UIElement - FrameworkElement - Shape (abstract) - Ellipse - Line - Path - Polygon - Polyline - Rectangle
  • 5. Lin e
    • Propriet ăţi: - X1, Y1, X2, Y2 – Double
    • - Stroke - Brush
  • 6. Rectangle
    • Proprietăţi - Width, Height – Double - Fill, Stroke – Brush - RadiusX, RadiusY – Double
  • 7. Ellipse
    • Proprietăţi - Width, Height – Double - Fill, Stroke – Brush
  • 8. Polyline
    • Proprietăţi - Points – PointCollection - Stroke, Fill – Brush
    • Exemplu:
    • <Polyline Stroke=&quot;Blue” Points=&quot;0,80 60,80 65,50 68,110 73,80 85,80 90,50 93,110 98,80 210,80&quot; />
  • 9. Polyline
    • O spiral ă poly=new Polyline(); poly.Stroke = SystemColors.WindowTextBrush;
    • Panza.Children.Add(poly);
    • Point[] pts=new Point[numpts];
    • for (int i=0;i<numpts;i++)
    • {
    • double angle = i * 2 * Math.PI / (numpts/revs);
    • double scale = 250 * ( 1 - (double)i/numpts);
    • pts[i].X = scale * Math.Cos(angle);
    • pts[i].Y = scale * Math.Sin(angle);
    • }
    • poly.Points = new PointCollection(pts);
  • 10. Polygon
    • Proprietăţi - Points – PointCollection - Stroke, Fill – Brush
    • Exemplu:
    • <Poly gon Stroke=&quot;Blue” Points=&quot;0,80 60,80 65,50 68,110 73,80 85,80 90,50 93,110 98,80 210,80&quot; />
  • 11. Brush
    • Culori în WPF - 4 canale: Red, Green, Blue, Alpha - 16 biţi /culoare
    • SolidColorBrush
  • 12. Brush
    • LinearGradientBrush
    • <Rectangle Width=&quot;80&quot; Height=&quot;60&quot;> <Rectangle.Fill> <LinearGradientBrush StartPoint=&quot;0,0&quot; EndPoint=&quot;1,1&quot;> <LinearGradientBrush.GradientStops> <GradientStop Color=&quot;Black&quot; Offset=&quot;0&quot; /> <GradientStop Color=&quot;White&quot; Offset=&quot;1&quot; /> </LinearGradientBrush.GradientStops> </LinearGradientBrush> </Rectangle.Fill> </Rectangle>
    0,1 0,0 1,0 1,1
  • 13. Brush
    • RadialGradientBrush
    • <Rectangle Width=&quot;200&quot; Height=&quot;150&quot;>
    • <Rectangle.Fill>
    • <RadialGradientBrush Center=&quot;0.5,0.4&quot; RadiusX=&quot;0.3” RadiusY=&quot;0.5” GradientOrigin=&quot;0.25,0.4&quot;>
    • <RadialGradientBrush.GradientStops>
    • <GradientStop Color=&quot;White&quot; Offset=&quot;0&quot; />
    • <GradientStop Color=&quot;DarkBlue&quot; Offset=&quot;1&quot; />
    • </RadialGradientBrush.GradientStops>
    • </RadialGradientBrush>
    • </Rectangle.Fill>
    • </Rectangle>
  • 14. Brush
    • Alte brush-uri: - ImageBrush - DrawingBrush - VisualBrush
  • 15. Pens
    • StrokeThickness
    • StrokeDashArray
  • 16. Path
    • Cel mai puternic element grafic din WPF
    • Proprietăţi: Stroke, Fill, Data (conţinutul)
    • Are ca şi conţinut o “Geometrie”
  • 17. Path
    • Geometrii: - LineGeometry - RectangleGeometry - EllipseGeometry - GeometryGroup - CombinedGeometry - PathGeometry - StreamGeometry
  • 18. Geometrii
    • LineGeometry <Path Stroke=&quot;Black&quot;> <Path.Data>
    • <LineGeometry StartPoint=&quot;10 10&quot; EndPoint=&quot;10 100&quot; /> </Path.Data> </Path>
    • RectangleGeometry <Path Fill=&quot;Blue&quot;> <Path.Data> <RectangleGeometry Rect=&quot;0, 0, 40, 80&quot; /> </Path.Data> </Path>
  • 19. Geometrii
    • EllipseGeometry <Path Stroke=&quot;Black&quot;>
    • <Path.Data>
    • <EllipseGeometry Center=&quot;20, 40&quot; RadiusX=&quot;10&quot; RadiusY=&quot;30&quot; />
    • </Path.Data>
    • </Path>
    • GeometryGroup <Path Fill=&quot;Cyan&quot; Stroke=&quot;Black&quot;> <Path.Data> <GeometryGroup> <EllipseGeometry Center=&quot;20, 40&quot; RadiusX=&quot;20&quot; RadiusY=&quot;40&quot; /> <EllipseGeometry Center=&quot;20, 40&quot; RadiusX=&quot;10&quot; RadiusY=&quot;30&quot; /> </GeometryGroup> </Path.Data> </Path>
  • 20. Geometrii
    • PathGeometry <Path Fill=&quot;Cyan&quot; Stroke=&quot;Black&quot;> <Path.Data> <PathGeometry> <PathGeometry.Figures> <PathFigure> <PathFigure.Segments> <StartSegment Point=&quot;0,0&quot; /> <LineSegment Point=&quot;50,0&quot; /> <LineSegment Point=&quot;50,50&quot; /> <LineSegment Point=&quot;0,50&quot; /> <CloseSegment /> </PathFigure.Segments> </PathFigure> </PathGeometry.Figures> </PathGeometry> </Path.Data> </Path>
  • 21. Geometrii
    • StreamGeometry <Path Fill=&quot;Cyan&quot; Stroke=&quot;Black&quot; Data=&quot;M 0,0 L 50,0 50,50 0,50 Z&quot; />
  • 22. Geometrii
    • StreamGeometry
    M x y Move Moveto x y L x y Line H x Horizontal line V y Vertical line A xr yr a i j x y Arc Arc pana la x y din elipsa xr yr cu a grade i:1 LargeArc j:1 Clockwise C x1 y1 x2 y2 x3 y3 Cubic Bezier Bezier pana la x3 y3, cu x1 y1 x2 y2 ca puncte de control S x2 y2 x3 y3 Smooth Bezier Q x1 y1 x2 y2 Quadratic Bezier Z Close
  • 23. Transformări
    • RenderTransform
    • LayoutTransform
    • Tipuri de transformări: - TranslateTransform - ScaleTransform - SkewTransform - RotateTransform - MatrixTransform - TransformGroup
  • 24. XAML Exploitation
    • StringReader reader = new StringReader( this.DocumentRoot.TextBox. Text);    XmlReader xmlReader = XmlReader.Create( reader);           try    {     Control dynamicControl = (Control)XamlReader .Load(xmlReader) ;     this.DocumentRoot. Grid.Children. Add(dynamicContr ol);    }    catch (Exception ex)    {     MessageBox.Show( ex.Message) ;    }
  • 25. XAML Exploitation
    • string StrXaml=“<Rectangle Width=‘100’ Height=‘100’ Stroke=‘Blue’>”; StringReader strreader = new StringReader(StrXaml); XmlTextReader xmlreader = new XmlTextReader(strreader); object obj = XamlReader.Load(xmlreader);
    • Uri uri = new Uri(“pack://application:,,,/LoadXaml.xml”); Stream stream = Application.GetResourceStream(uri).Stream; FrameworkElement el = XamlReader.Load(stream) as FrameworkElement; Button btn = el.FindName(“Buton”) as Button