《ここに引越中》2008年5月12日(月)
C#.use(better, IronPython=”WPF”) 《記事一覧》
TabControl
《著》本間りす《監修》小泉ひよ子とタマゴ倶楽部
《付録》exBrush.py
# -*- coding: utf-8 -*- #=============================================================================== # Copyright (C) 2000-2008, 小泉ひよ子とタマゴ倶楽部 # # History: WPF examples # 2008/01/25, IronPython 1.1.1 (download) # 2008/08/22, IronPython 1.1.2 (download) # 2008/03/16, ver.2.0, WPF # 2008/00/00, ver.2.1, IronPython 1.1.2 #=============================================================================== from _ant import * from System import * from System.Windows import * from System.Windows.Media import * from System.Windows.Media.Imaging import * from System.Windows.Shapes import * ## -------------------- class ExWindow(Window): def __init__(self, Content=None, **args): self.InitializeComponent(Content) self.init() def InitializeComponent(self, Content): self.Content = LoadXaml(Content) def init(self): target = ( "solidColorBrush", "linearGradientBrush", "radialGradientBrush", "imageBrush", "drawingBrush", "visualBrush", ) self._Controls(target) def _Controls(self, target): controls = xaml_controls(self) for e in target: setattr(self, e, controls[e]) for e in target: items = getattr(self, e) for shape in self.newEllipse(), self.newPolygon(): shape.Fill = getattr(self, "_%s"%e)() items.Children.Add(shape) def _solidColorBrush(self): return Brushes.Yellow def newEllipse(self): return Ellipse( Stroke=Brushes.Blue, StrokeThickness=2, Width=100, Height=50, ) def newPolygon(self): points = PointCollection() vertices = "0,28 80,28 12,80 40,0 68,80" for e in vertices.split(" "): x, y = eval(e) points.Add(Point(x, y)) return Polygon( Stroke=Brushes.Blue, StrokeThickness=2, Points=points, ) ## -------------------- if __name__ == "__main__": xaml = __file__.replace(".py",".xaml") win = ExWindow( Title=xaml, Width=400, Height=200, Content=xaml, ) Application().Run(win) ## --------------------
《付録》exBrush.xaml
<!-- # Copyright (C) 2000-2008, (^.^) piyo-piyo Tamago-Club # # History: WPF examples # 2008/01/25, IronPython 1.1.1 (download) # 2008/08/22, IronPython 1.1.2 (download) # 2008/03/16, ver.2.0, WPF # 2008/00/00, ver.2.1, IronPython 1.1.2
-
- >