2008-07-01から1ヶ月間の記事一覧

《参考文献》

C# Design Patterns 31. The Visitor Pattern.

Boss.cs

class Boss(Employee): # Visitor::ConcreteElement def __init__(self, name, salary, vdays, sdays, bonusDays=None): Employee.__init__(self, name, salary, vdays, sdays) self.bonusDays = bonusDays def accept(self, v): source = "v.visit_%s(self)…

Employee.cs

class Employee: # Visitor::ConcreteElement def __init__(self, name, salary, vDays, sDays): self.name = name self.salary = salary self.sickDays = sDays self.vacDays = vDays def accept(self, v): source = "v.visit_%s(self)"%self.__class__.__n…

Visitor_WPF.py

WPF アプリケーションとして、IronPython で実現した事例を紹介します。 # -*- coding: utf-8 -*- #=============================================================================== # Copyright (C) 2000-2008, 小泉ひよ子とタマゴ倶楽部 # # History: D…

__main__

if __name__ == "__main__": print __file__,"ver.1.1" win = Visitor_WPF() win.Title = win.__class__.__name__ # .Text Application().Run(win) Text に代えて、Title に値を設定しています。

Form1.cs

class Visitor_WPF(Window): # Form # Visitor::ObjectStructure Form に代えて、Window を拡張しています。 def __init__(self, **args): self.InitializeComponent() self.init() def init(self): self.empls = # Employee for e in [ Employee("Susan Bea…

bVacationVisitor.cs

class bVacationVisitor(Visitor): # Visitor::ConcreteVisitor def __init__(self): self.totalDays = 0 def visit_Employee(self, emp): # visit(Employee emp) self.totalDays += emp.vacDays def visit_Boss(self, bos): # visit(Boss bos) self.totalDa…

VacationVisitor.cs

class VacationVisitor(Visitor): # Visitor::ConcreteVisitor def __init__(self): self.totalDays = 0 def visit_Employee(self, emp): # visit(Employee emp) self.totalDays += emp.vacDays def visit_Boss(self, bos): # visit(Boss bos) self.totalDay…

Visitor.cs

class Visitor: # abstract # Visitor::Visitor def visit_Employee(self, emp): raise NotImplementedError("%s.visit_Employee" %self.__class__.__name__) def visit_Boss(self, bos): raise NotImplementedError("%s.visit_Boss" %self.__class__.__name…

C#.use(better, IronPython=”GoF”) # Visitor〈WPF〉

C#.use(better, IronPython="GoF") 《記事一覧》 Visitor〈WPF〉Visitor -- pay a tribute to "C# Design Patterns" by James William Cooper 《著》小粒ちゃん《監修》小泉ひよ子とタマゴ倶楽部第2版♪2008/03/21 ● 改訂♪2008/10/25

__main__

if __name__ == "__main__": win = ButtonMenu_WPF() win.Title = win.__class__.__name__ # .Text Application().Run(win) Text に代えて、Title に値を設定しています。

Form1.cs

class ButtonMenu_WPF(Window): # Form Form に代えて、Window を拡張しています。 def __init__(self, **args): self.InitializeComponent() self.init() def init(self): evh = self.commandClick self.btRed.Click += evh file = MenuItem(Header="File")…

FileOpen.cs

class FileOpen(MenuItem, Command): def __init__(self): self.Header = "Open" # .Text System.Windows.Forms.MenuItem に代えて、System.Windows.Controls.MenuItem を拡張しています。 Text に代えて、Header に値を設定しています。 def Execute(self):…

Command.cs

class Command: # interface Command def Execute(self): raise NotImplementedError("Execute") interface に代えて、例外 NotImplementedError を生成しています。

ButtonMenu_WPF.py

WPF アプリケーションとして、IronPython で実現した事例を紹介します。 # -*- coding: utf-8 -*- #=============================================================================== # Copyright (C) 2000-2008, 小泉ひよ子とタマゴ倶楽部 # # History: D…

《こちらに移動中です》

C#.use(better, IronPython="GoF") 《記事一覧》 Strategy〈WPF〉Strategy -- pay a tribute to "C# Design Patterns" by James William Cooper 《著》小粒ちゃん《監修》小泉ひよ子とタマゴ倶楽部第2版♪2008/03/21 ● 改訂♪2008/10/06

《参考文献》

C# Design Patterns 29. The Strategy Pattern.

RedButton.cs

class RedButton(Button, Command): def Execute(self): c = self.Parent c.Background = Brushes.Red # .BackColor = Color self.Background = Brushes.Yellow # .BackColor = Color System.Windows.Forms.Button に代えて、System.Windows.Controls.Button…

FileExit.cs

class FileExit(MenuItem, Command): def __init__(self, frm): self.Header = "Exit" # .Text self.form = frm System.Windows.Forms.MenuItem に代えて、System.Windows.Controls.MenuItem を拡張しています。 Text に代えて、Header に値を設定しています…

移動中

要求仕様の変更:オセロゲーム〈3人〉trinity 1/5

要求仕様の変更:オセロゲーム〈3人〉trinity 1/5

Shall_we_Agile = Java.use(better, Python) # 《記事一覧》 要求仕様の変更:trinity 《著》伊藤うさぎ、森こねこ《監修》小泉ひよ子とタマゴ倶楽部初出♪2003/12/23

Oh 脳《70》カレーライスとメジャーリーグ中継

Oh 脳: after ZERO 《記事一覧》《其之漆拾》カレーライスとメジャーリーグ中継 受講者のみなさんに、よくこんな質問をします。実際に作れるかどうかは別として、誰かに自慢できる料理のメニューを挙げてください。すると、いろんなメニューが返ってきます。…

Oh 脳《069》NIH シンドロームを知っていますか

‖記事一覧‖Oh 脳: after ZERO《其之陸拾玖》 NIH シンドロームを知っていますか 《監修》小泉ひよ子とタマゴ倶楽部第0版♪1988/03/30 ♪セミナーの枕で紹介した小ネタ集です。息抜きや話題作りにどうぞ (^.^) 「NIH シンドロームを知っていますか」こんな話も…

マークアップと分離コード

マークアップと同様の結果が得られる、分離コードについて解説します。 GeometryGroup オブジェクトは、複数の Geometry オブジェクトで構成され、これらをプロパティー .Children で管理します。# Path1.py def shapes(self): s = Path( HorizontalAlignmen…

GeometryGroup

GeometryGroup は、複数の図形をまとめてグループ化するのに便利です。 このアプリケーションを起動すると、ウィンドウが現れます。1)図形をクリックすると、2)その図形に関する情報が表示されます。ここでは、表示された図形が Path であり、3つの LineG…

Path

複雑な図形を表現する方法を紹介します。それには、クラス Path を利用すると便利です。Geometry の傘下には、単純な図形を扱う LineGeometry/RectangleGeometry/EllipseGeometry や、複雑な図形を扱う PathGeometry などがあります。これらの図形を組み合わ…

第4章 グラフィックス 5/5, Path

《Previous|5/5|Next》 C#.use(better, IronPython=”WPF”) 《記事一覧》

マークアップと分離コード

マークアップと同様の結果が得られる、分離コードについて解説します。 Polyline Name="shape" Stroke="Blue" StrokeThickness="2" Fill="Yellow" Points="0,28 80,28 12,80 40,0 68,80" />マークアップでは、Polyline ... に続いて、さまざまなプロパティー…

Polyline

折れ線を表現する方法を紹介します。 >ipy.exe Polyline.pyこのアプリケーションを起動すると、ウィンドウが現れます。1)図形をクリックすると、2)その図形に関する情報が表示されます。ここでは、表示された図形が折れ線 Polyline であり、5つの頂点 0,2…

第4章 グラフィックス 4/5, Polyline

《Previous|4/5|Next》 C#.use(better, IronPython=”WPF”) 《記事一覧》