
普通の Tcl/Tk 8.5 の入門書といった内容で丁寧に解説されており、Tcl、Tk の入門的内容から、Tcl_Obj (C API) や TEA に基づいた拡張パッケージの作成までカバーされています。700 頁を越える量ですが、わかりやすくまとめられている良書だと思います。製本はペーパーバック(並製本)で、背に頁を糊付けしただけのものです。そのため、永く使い込めば、背が折れて頁が剥がれることになり、もう一冊購入なんてことになりそうです。
すぐりふひとのプログラミングメモ
Name | Summary |
---|---|
Boost 1.44 | Update Boost to the upstream 1.44 release |
D Programming | Add a D compiler (LDC) and D standard runtime library (Tango) |
EC2 | We will provide a concurrent release of Fedora 14 and above on the Amazon EC2 cloud |
Eclipse Helios | Update Fedora's Eclipse stack to Helios releases |
Erlang R14 | Update Erlang to the upstream R14 release |
Gdb Index | This project will remove the useless indices from the .debug files, and will replace them with an index that greatly speeds up gdb |
GNUstep | GNUstep development environment for Fedora |
ipmiutil | An easy-to-use fully-featured IPMI server management utility |
libjpeg-turbo | libjpeg-turbo is fork of the original libjpeg project. It contains numerous performance related enhancements and is at least twice faster in JPEG compression/decompression than original libjpeg on platforms with MMX/SSE instruction set. |
KDE 4.5 | Rebase to KDE Plasma Desktop 4.5 |
Memory Debugging Tools | The gdb debugger has been extended with new commands that make it easier to track down and fix excessive memory usage within programs and libraries |
NetBeans 6.9 | Re-base to the NetBeans 6.9 |
Open SCAP | Provide open-source Security Content Automation Protocol (SCAP) framework, basic set of applications and OVAL/XCCDF security content |
Perl 5.12 | Update to Perl 5.12 |
Python 2.7 | Update Python to the upstream 2.7 release |
Rakudo Star | The Rakudo Star releases includes the Rakudo compiler, modules, Blizkost and documentation. Rakudo is an implementation of the Perl 6 specification for the Parrot virtual machine. |
Spice | Spice aims to provide a complete open source solution for interaction with virtualized desktops |
Sugar 0.90 | Provide the latest Sugar Learning Environment (0.90), including an enhanced activity set to provide an stable demo environment for Sugar as well as an environment for developers |
Ruby 1.8.7 | Update Ruby to the upstream 1.8.7 release |
$ tar zxvf rbc0.1.src.tar.gz $ cd rbc $ CFLAGS="-DUSE_INTERP_RESULT" \ > ./configure --prefix=$HOME --with-tcl=../tcl/unix --with-tk=../tk/unix $ make $ make installコンパイルフラグ USE_INTERP_RESULT は、Tcl 8.6 ではレガシーな (Tcl_Interp) interp->result にアクセスする際に必要になります[3]。
#!/bin/sh # the next line restarts using wish \ exec wish8.6 "$0" "$@" package require rbc proc init_x {} { set xList {} for {set i 0} {$i <= 200} {incr i} { lappend xList [expr $i / 5.] } return $xList } proc init_y {xList} { set yList {} foreach x $xList { lappend yList [expr sqrt($x) * sin($x)] } return $yList } # ---------------------------------------------------------------------------- # メイン # ---------------------------------------------------------------------------- wm title . "rbc::graph" set grp ".grp" rbc::graph $grp \ -title "Sample Graph" \ -font "helvetica 16" \ -rightmargin 15 \ -plotbackground "light cyan" \ -plotpadx 0 \ -plotpady 0 \ -plotborderwidth 0 pack .grp # ズームスタックを有効にする #Blt_ZoomStack $grp # X と Y 軸 $grp axis configure x \ -subdivisions 10 \ -tickfont "courier 8" \ -title "X Axis" \ -titlefont "helvetica 12" $grp axis configure y \ -subdivisions 10 \ -tickfont "courier 8" \ -title "Y Axis" \ -titlefont "helvetica 12" # グリッド $grp grid configure \ -color "turquoise" \ -mapx x \ -mapy y $grp grid on # 凡例 $grp legend configure \ -font "helvetica 10" \ -ipadx 10 \ -position bottom \ -relief ridge # データ set xList [init_x] set yList [init_y $xList] $grp element create func \ -label "sqrt(x) * sin(x)" \ -xdata $xList \ -ydata $yList \ -smooth quadratic \ -linewidth 1 \ -color blue \ -symbol circle \ -pixels 0.0625i \ -scalesymbols yes \ -outline red \ -fill green # --- # sample_graph.tcl実行例を以下に示しました。日本語フォントが表示できないし、 BLT のすべての機能が使えるわけでもなく制限はありますが、Tcl/Tk 8.6 の環境で手軽に(そこそこの)グラフを作成できそうです。
#!/bin/sh # the next line restarts using tclsh \ exec tclsh8.6 "$0" "$@" # 分散分析 # $Id: anova_1way.tcl,v 1.6 2010/10/10 05:15:34 bitwalk Exp bitwalk $ # サンプルデータ1 set a [list {3.42 3.84 3.96 3.76}] set b [list {3.17 3.63 3.47 3.44 3.39}] set c [list {3.64 3.72 3.91}] # サンプルデータ2 #set a [list {25 30 20 32}] #set b [list {30 33 29 40 36}] #set c [list {32 39 35 41 44}] # データ set data [list $a $b $c] # ----------------------------------------------------------------------------- # クラス anova # ----------------------------------------------------------------------------- oo::class create anova { constructor {a} { my variable x way # データリスト set x $a # 分散分析の対象フラグのリセット set way "" } # ------------------------------------------------------------------------- # 一元配置 # ------------------------------------------------------------------------- method oneway {} { my variable x way my variable n k my variable SSb SSw SSt my variable df_b df_w df_t my variable MSb MSw my variable F p # Sum of Squared Deviations # SSt (TOTAL) set x_simple [my list_simple $x] set n [llength $x_simple] set x_mean [my mean $x_simple $n] set SSt [my var $x_simple $x_mean] # SSb (BETWEEN GROUPS) set k [llength $x] set SSb 0 for {set i 0} {$i < $k} {incr i} { set x_b($i) [my list_simple [lindex $x $i]] set n_b($i) [llength $x_b($i)] set x_mean_b($i) [my mean $x_b($i) $n_b($i)] set SSb [expr $SSb + $n_b($i) \ * ($x_mean_b($i) - $x_mean) \ * ($x_mean_b($i) - $x_mean)] } # SSw (WITHIN GROUPS) # set SSw [expr $SSt - $SSb] set SSw 0 for {set i 0} {$i < $k} {incr i} { set x_w($i) [my list_simple [lindex $x $i]] set n_w($i) [llength $x_w($i)] set x_mean_w($i) [my mean $x_w($i) $n_w($i)] set SSw [expr $SSw + [my var $x_w($i) $x_mean_w($i)]] } # Degree of Freedom set df_b [expr $k - 1] set df_w [expr $n - $k] set df_t [expr $n - 1] # Mean Square set MSb [expr $SSb / $df_b] set MSw [expr $SSw / $df_w] # F value, the ratio of the two variance estimates set F [expr $MSb / $MSw] set p [my f_pval $F $df_b $df_w] # flag set way "One Way" return 1 } # ------------------------------------------------------------------------- # result # 結果の表示 # ------------------------------------------------------------------------- method result {} { my variable way switch $way { "One Way" { my result_1way } default { puts "No result yet!" } } } # ------------------------------------------------------------------------- # result_1way # 結果の表示(一元配置) # ------------------------------------------------------------------------- method result_1way {} { my variable x my variable n k my variable SSb SSw SSt my variable df_b df_w df_t my variable MSb MSw my variable F p puts "ANOVA (1way)" puts "Source SS df MS F val P Val" puts -nonewline "Between" puts -nonewline [format " %8.3f" $SSb] puts -nonewline [format " %8d" $df_b] puts -nonewline [format " %8.3f" $MSb] puts -nonewline [format " %8.3f" $F] puts -nonewline [format " %8.6f" $p] if {$p < 0.001} { puts " ***" } elseif {$p < 0.01} { puts " **" } elseif {$p < 0.05} { puts " *" } else { puts "" } puts -nonewline "Within " puts -nonewline [format " %8.3f" $SSw] puts -nonewline [format " %8d" $df_w] puts -nonewline [format " %8.3f" $MSw] puts "" puts -nonewline "Total " puts -nonewline [format " %8.3f" $SSt] puts -nonewline [format " %8d" $df_t] puts "" } # ------------------------------------------------------------------------- # mean # 平均値の計算 # ------------------------------------------------------------------------- method mean {xList num} { set sum [my sum $xList] return [expr $sum / $num] } # ------------------------------------------------------------------------- # sum # 合計の計算 # ------------------------------------------------------------------------- method sum {xList} { set total 0.0 foreach x $xList { set total [expr $total + $x] } return $total } # ------------------------------------------------------------------------- # var # 分散の計算 # ------------------------------------------------------------------------- method var {xList xMean} { set var 0.0 foreach x $xList { set var [expr $var + ($x - $xMean) * ($x - $xMean)] } return $var } # ------------------------------------------------------------------------- # f_pval # P値(F分布の上側確率の算出) # ------------------------------------------------------------------------- method f_pval {f df1 df2} { set m2pi 0.636619772367581343076 set m_pi 3.14159265358979323846 set i1 [expr 2 - ($df1%2)] set i2 [expr 2 - ($df2%2)] set w [expr $df2/($df2 + $df1*$f)] set y [expr 1.0 - $w] set p [expr sqrt($w)] set s [expr sqrt($y)] if {[expr 2*$i1 - $i2] == 0} { set p [expr 1.0 - $s] set c [$s*$w/2.0] } elseif {[expr 2*$i1 - $i2] == 1} { set c [expr $s*$p/$m_pi] set p [expr 1.0 - atan2($s, $p) * $m2pi] } elseif {[expr 2*$i1 - $i2] == 2} { set p $w set c [expr $w*$y] } else { set c [expr $y*$p/2.0] } for {set i2 $i2} {$df2 > $i2} {incr i2 2} { set p [expr $p - 2.0/$i2*$c] set c [expr $c*$w*($i1 + $i2)/$i2] } for {set i1 $i1} {$df1 > $i1} {incr i1 2} { set p [expr $p + 2.0/$i1*$c] set c [expr $c*$y*($i1 + $i2)/$i1] } return [expr ($p < 0.0 && abs($p) < 1e-10) ? 0.0 : $p] } # ------------------------------------------------------------------------- # list_simple # 入れ子になっているリストをシンプルなリストに変換 # ------------------------------------------------------------------------- method list_simple {xList} { regsub -all {[\{\}]} $xList {} foo regsub -all {\s{2,}} $foo { } baa return $baa } } # ----------------------------------------------------------------------------- # メイン # ----------------------------------------------------------------------------- set obj [anova new $data] if {[$obj oneway]} { $obj result } else { puts "failed" } # --- # END PROGRAM実行例を以下に示しました。
$ ./anova_1way.tcl ANOVA (1way) Source SS df MS F val P Val Between 0.318 2 0.159 4.615 0.041749 * Within 0.310 9 0.034 Total 0.628 11
# ------------------------------------------------------------------------- # f_pval # P値(F分布の上側確率の算出) # ------------------------------------------------------------------------- method f_pval {f df1 df2} { set x [expr $df1 * $f / ($df2 + $df1*$f)] return [expr 1 - betai($df1/2.0, $df2/2.0, $x)] }実行例を以下に示しましたが、上記と同じ結果が得られています。
$ ./anova_1way.tcl ANOVA (1way) Source SS df MS F val P Val Between 0.318 2 0.159 4.615 0.041749 * Within 0.310 9 0.034 Total 0.628 11
double gsl_sf_beta_inc (double a, double b, double x)以下のようなルーチンを使って Tcl の拡張パッケージを作成しています。
/***************************************************************************** * int func_betai * 規格化された不完全ベータ関数の処理部 * * Tcl 側のコマンド * expr betai($a, $b, $x) *****************************************************************************/ int func_betai (ClientData clientData, Tcl_Interp * interp, Tcl_Value * args, Tcl_Value * resultPtr) { double a, b, x; a = args->doubleValue; args++; b = args->doubleValue; args++; x = args->doubleValue; /* 計算結果 */ resultPtr->type = TCL_DOUBLE; resultPtr->doubleValue = gsl_sf_beta_inc (a, b, x); return TCL_OK; }ただ、GSL の配布ライセンスは GPLv3 (GNU General Public License) に従っているので、扱い難いと感じています。計算方法の検証ができたので、他に BSD などの配布ライセンスで良いライブラリがあれば乗り換えようと思っています。オープンソースを推進したい者としては矛盾した考えですが、しかたがありません。
#!/bin/sh # the next line restarts using tclsh \ exec tclsh8.6 "$0" "$@" # 分散分析 # $Id: anova_1way.tcl,v 1.4 2010/10/02 15:00:00 bitwalk Exp bitwalk $ # サンプルデータ1 set a [list {3.42 3.84 3.96 3.76}] set b [list {3.17 3.63 3.47 3.44 3.39}] set c [list {3.64 3.72 3.91}] # サンプルデータ2 #set a [list {25 30 20 32}] #set b [list {30 33 29 40 36}] #set c [list {32 39 35 41 44}] # データ set data [list $a $b $c] # ----------------------------------------------------------------------------- # クラス anova # ----------------------------------------------------------------------------- oo::class create anova { constructor {a} { my variable x way # データリスト set x $a # 分散分析の対象フラグのリセット set way "" } # ------------------------------------------------------------------------- # 一元配置 # ------------------------------------------------------------------------- method oneway {} { my variable x way my variable n k my variable SSb SSw SSt my variable df_b df_w df_t my variable MSb MSw my variable F # Sum of Squared Deviations # SSt (TOTAL) set x_simple [my list_simple $x] set n [llength $x_simple] set x_mean [my mean $x_simple $n] set SSt [my var $x_simple $x_mean] # SSb (BETWEEN GROUPS) set k [llength $x] set SSb 0 for {set i 0} {$i < $k} {incr i} { set x_b($i) [my list_simple [lindex $x $i]] set n_b($i) [llength $x_b($i)] set x_mean_b($i) [my mean $x_b($i) $n_b($i)] set SSb [expr $SSb + $n_b($i) \ * ($x_mean_b($i) - $x_mean) \ * ($x_mean_b($i) - $x_mean)] } # SSw (WITHIN GROUPS) # set SSw [expr $SSt - $SSb] set SSw 0 for {set i 0} {$i < $k} {incr i} { set x_w($i) [my list_simple [lindex $x $i]] set n_w($i) [llength $x_w($i)] set x_mean_w($i) [my mean $x_w($i) $n_w($i)] set SSw [expr $SSw + [my var $x_w($i) $x_mean_w($i)]] } # Degree of Freedom set df_b [expr $k - 1] set df_w [expr $n - $k] set df_t [expr $n - 1] # Mean Square set MSb [expr $SSb / $df_b] set MSw [expr $SSw / $df_w] # F value, the ratio of the two variance estimates set F [expr $MSb / $MSw] # flag set way "One Way" return 1 } # ------------------------------------------------------------------------- # result # 結果の表示 # ------------------------------------------------------------------------- method result {} { my variable way switch $way { "One Way" { my result_1way } default { puts "No result yet!" } } } # ------------------------------------------------------------------------- # result_1way # 結果の表示(一元配置) # ------------------------------------------------------------------------- method result_1way {} { my variable x my variable n k my variable SSb SSw SSt my variable df_b df_w df_t my variable MSb MSw my variable F puts "ANOVA (1way)" puts "Source SS df MS F val" puts -nonewline "Between" puts -nonewline [format " %8.3f" $SSb] puts -nonewline [format " %8d" $df_b] puts -nonewline [format " %8.3f" $MSb] puts -nonewline [format " %8.3f" $F] puts "" puts -nonewline "Within " puts -nonewline [format " %8.3f" $SSw] puts -nonewline [format " %8d" $df_w] puts -nonewline [format " %8.3f" $MSw] puts "" puts -nonewline "Total " puts -nonewline [format " %8.3f" $SSt] puts -nonewline [format " %8d" $df_t] puts "" } # ------------------------------------------------------------------------- # mean # 平均値の計算 # ------------------------------------------------------------------------- method mean {xList num} { set sum [my sum $xList] return [expr $sum / $num] } # ------------------------------------------------------------------------- # sum # 合計の計算 # ------------------------------------------------------------------------- method sum {xList} { set total 0.0 foreach x $xList { set total [expr $total + $x] } return $total } # ------------------------------------------------------------------------- # var # 分散の計算 # ------------------------------------------------------------------------- method var {xList xMean} { set var 0.0 foreach x $xList { set var [expr $var + ($x - $xMean) * ($x - $xMean)] } return $var } # ------------------------------------------------------------------------- # list_simple # 入れ子になっているリストをシンプルなリストに変換 # ------------------------------------------------------------------------- method list_simple {xList} { regsub -all {[\{\}]} $xList {} foo regsub -all {\s{2,}} $foo { } baa return $baa } } # ----------------------------------------------------------------------------- # メイン # ----------------------------------------------------------------------------- set obj [anova new $data] if {[$obj oneway]} { $obj result } else { puts "failed" } # --- # END PROGRAM実行例を以下に示しました。
$ ./anova_1way.tcl ANOVA (1way) Source SS df MS F val Between 0.318 2 0.159 4.615 Within 0.310 9 0.034 Total 0.628 11まだ、p値の計算はできていません。この部分は C で Tcl のライブラリを作成する予定です。あとは、すこしずつ GUI を作りながら、二元配置、直交表の分散分析にも対応させていく予定です。
Date: Wed, 08 Sep 2010 16:42:34 -0400 From: Donald G Porter <donald.porter at nist.gov> To: Tcl List Core <tcl-core at lists.sourceforge.net> Subject: [TCLCORE] Tcl/Tk 8.5.9 RELEASED Tcl/Tk 8.5.9 Release Announcement September 8, 2010 The Tcl Core Team is pleased to announce the 8.5.9 releases of the Tcl dynamic language and the Tk toolkit. This is the ninth patch release of Tcl/Tk 8.5. More details can be found below. We would like to express our gratitude to all those who submit bug reports and patches. This information is invaluable in enabling us to identify and eliminate problems in the core. Where to get the new releases: ------------------------------ Tcl/Tk 8.5.9 sources are freely available as open source from the Tcl Developer Xchange web site at: http://www.tcl.tk/software/tcltk/8.5.html This web page also contains additional information about the releases, including new features and notes about installing and compiling the releases. Sources are always available from the Tcl SourceForge project's file distribution area: http://sourceforge.net/project/showfiles.php?group_id=10894 Binaries for most major platforms are available from: http://www.activestate.com/Tcl For additional information: --------------------------- Please visit the Tcl Developer Xchange web site: http://www.tcl.tk/ This site contains a variety of information about Tcl/Tk in general, the core Tcl and Tk distributions, Tcl development tools, and much more. Summary of Changes since Tcl/Tk 8.5.8: -------------------------------------- The following were the main changes in Tcl/Tk 8.5.9. A complete list can be found in the changes file at the root of the source tree. The more complete ChangeLog is also included with each source release. This is a patch release, so it primarily includes bug fixes and corrections to erratic behavior. Below are only the most notable changes. * TIP 359: new X11 option: [wm attributes -type] - stops inappropriate Compiz animation of Tk menu & combobox. * TIP 360: modernize menus on X11. * New widget [ttk::spinbox]. * [lappend arr(elem)] no longer fires read traces as it inconsistently has in some situations, but not in others. *** POTENTIAL INCOMPATIBILITY *** * [tk_getOpenFile] on Windows: unlimited multiple-file selection. * [load] uses LOAD_WITH_ALTERED_SEARCH_PATH for fewer surprises when bringing in DLLs via dependencies on Windows. *** POTENTIAL INCOMPATIBILITY *** * Updated [send] security rules to current Ubuntu/Fedora conventions. * Fixed [wm iconphoto] on LP64 unix systems. * [chan copy] of more than 2**31 bytes is now possible. * min() and max() functions now work in safe interps. * [$menu delete $tooBig end] now properly a no-op. * canvas items now properly updated when canvas state changes. * Revised [ttk::sizegrip] to accommodate Compiz. * Revised default Text bindings forand to account for insertion point relationship to the selection. * Corrected result of [tcl::mathfunc::abs 0.0]. * New version 1.432 of msgcat package. * New version 1.0.9 of platform package. * New version 0.8.6 of tile package. * Changes to support building with MSVC++ 2010. * Prevent race condition in some XIM implementations. * Fixed bad results from [file rootname]. * Prevent consumption of all memory when [chan copy] copies to slow channel. * [wm transient] now works even with withdrawn windows. * $DISPLAY can now contain "::". * Restored compatibility of [entry] validation with Itcl variable scope. * Fixed line-sensitive matching by [regexp]. * Fixed memory corruption in complex canvas tag searches. * Fixed crash in encoding finalization. * Fixed crashes in widget destruction. * Fixed crash in GetFontFamilyName(). * Fixed crash in menu deletion. * Fixed crash in peer text dump. * Fixed crash when bind scripts are empty. * Fixed crash in unset traces during [array unset]. * Fixed crash deleting vars during callframe pop. * Fixed crash in [open |noSuchFile rb]. * Fixed crash in [chan postevent]. * Fixed programming error in [clock format] in he_IL locale. * Safe Base and Safe Tk rewrites -- Tcl Core Team and Maintainers Don Porter, Tcl Core Release Manager -- | Don Porter Mathematical and Computational Sciences Division | | donald.porter at nist.gov Information Technology Laboratory | | http://math.nist.gov/~DPorter/ NIST | |______________________________________________________________________| ------------------------------------------------------------------------------ This SF.net Dev2Dev email is sponsored by: Show off your parallel programming skills. Enter the Intel(R) Threading Challenge 2010. http://p.sf.net/sfu/intel-thread-sfd _______________________________________________ Tcl-Core mailing list Tcl-Core at lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/tcl-core
using System;
using System.Reflection;
using System.Runtime.InteropServices;
namespace bitWalk
{
class VerTest
{
public static void Main (string[] args)
{
string clrVersionBuildtime = Assembly.GetExecutingAssembly ().ImageRuntimeVersion;
Console.WriteLine ("built CLR version: " + clrVersionBuildtime);
string clrVersionRuntime = RuntimeEnvironment.GetSystemVersion();
Console.WriteLine ("runtime CLR version: " + clrVersionRuntime);
}
}
}
using System;
using System.Windows.Forms;
namespace Sample
{
class Program
{
static void Main ()
{
Application.Run (new FormTimer ());
}
}
}
$ gmcs -pkg:dotnet -target:winexe -out:FormTimer.exe FormTimer.Designer.cs FormT
imer.Main.cs FormTimer.cs
$ mono FormTimer.exe &
///////////////////////////////////////////////////////////////////////////////
// DataGridViewTest.cs - DataGridView コントロールを使ったサンプル
//
// 参考/引用:
// Koders Code Search: Test.cs - C#
// modified by Fuhito Suguri, 7-Aug-2010
///////////////////////////////////////////////////////////////////////////////
using System;
using System.Windows.Forms;
using System.Drawing;
//
namespace bitWalk
{
public class Program
{
public static void Main (string[] args) {
DataGridViewTest p = new DataGridViewTest();
p.SampleDataShow();
Application.Run(p);
}
}
//
public class DataGridViewTest : Form {
DataGridView myDataGridView;
/////////////////////////////////////////////////////////////////////////////
// DataGridViewTest constructor
public DataGridViewTest () {
this.Width = 400;
this.Height = 200;
this.Text = "DataGridViewTest";
//
this.Closed += OnClosed;
//
myDataGridView = new DataGridView();
myDataGridView.ColumnCount = 5;
//
DataGridViewCellStyle style1 = myDataGridView.ColumnHeadersDefaultCellStyle;
style1.BackColor = Color.Navy;
style1.ForeColor = Color.White;
style1.Font = new Font(myDataGridView.Font, FontStyle.Bold);
//
DataGridViewCellStyle style2 = new DataGridViewCellStyle();
style2.BackColor = Color.Beige;
style2.ForeColor = Color.Brown;
style2.Font = new Font("Arial", 8);
myDataGridView.AlternatingRowsDefaultCellStyle = style2;
//
myDataGridView.EditMode = DataGridViewEditMode.EditOnEnter;
myDataGridView.Name = "myDataGridView";
myDataGridView.AutoSizeRowsMode =
DataGridViewAutoSizeRowsMode.DisplayedCellsExceptHeaders;
myDataGridView.ColumnHeadersBorderStyle =
DataGridViewHeaderBorderStyle.Raised;
myDataGridView.CellBorderStyle = DataGridViewCellBorderStyle.Single;
myDataGridView.GridColor = SystemColors.ActiveBorder;
myDataGridView.Columns[0].Name = "リリース日";
myDataGridView.Columns[1].Name = "トラック";
myDataGridView.Columns[1].DefaultCellStyle.Alignment =
DataGridViewContentAlignment.MiddleCenter;
myDataGridView.Columns[2].Name = "タイトル";
myDataGridView.Columns[3].Name = "アーティスト";
myDataGridView.Columns[4].Name = "アルバム";
myDataGridView.Columns[4].DefaultCellStyle.Font =
new Font(DataGridView.DefaultFont, FontStyle.Italic);
myDataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
myDataGridView.MultiSelect = false;
myDataGridView.BackgroundColor = Color.Honeydew;
myDataGridView.Dock = DockStyle.Fill;
myDataGridView.CellFormatting +=
new DataGridViewCellFormattingEventHandler(MyDataGridViewCellFormatting);
myDataGridView.CellParsing +=
new DataGridViewCellParsingEventHandler(MyDataGridViewCellParsing);
myDataGridView.CellValidating +=
new DataGridViewCellValidatingEventHandler(MyDataGridViewCellValidating);
this.Controls.Add(myDataGridView);
//
DataGridViewColumnCollection columns = this.myDataGridView.Columns;
columns[0].DisplayIndex = 3;
columns[1].DisplayIndex = 4;
columns[2].DisplayIndex = 0;
columns[3].DisplayIndex = 1;
columns[4].DisplayIndex = 2;
}
// Populating the DataGrid
public void SampleDataShow () {
DataGridViewRowCollection rows = this.myDataGridView.Rows;
rows.Add(new string[] {"11/22/1968", "29", "Revolution 9", "Beatles", "The Beatles [White Album]"});
rows.Add(new string[] {"4/4/1960", "6", "Fools Rush In", "Frank Sinatra", "Nice 'N' Easy"});
rows.Add(new string[] {"11/11/1971", "1", "One of These Days", "Pink Floyd", "Meddle"});
rows.Add(new string[] {"4/4/1988", "7", "Where Is MY Mind?", "Pixies", "Surfer Rosa"});
rows.Add(new string[] {"5/1981", "9", "Can't Find My Mind", "Cramps", "Psychedelic Jungle"});
rows.Add(new string[] {"6/10/2003", "13", "Scatterbrain. (As Dead As Leaves.)", "Radiohead", "Hail to the Thief"});
rows.Add(new string[] {"6/30/1992", "3", "Dress", "P J Harvey", "Dry"});
}
//
void MyDataGridViewCellValidating (object sender, EventArgs args) {
}
//
void MyDataGridViewCellParsing (object sender, EventArgs args) {
}
//
void MyDataGridViewCellFormatting (object sender, EventArgs args) {
}
//
void OnClosed (object o, EventArgs e) {
Console.WriteLine("Closed!");
Application.Exit();
}
}
}
// END PROGRAM
$ gmcs -pkg:dotnet -target:winexe DataGridViewTest.cs
$ mono DataGridViewTest.exe &
///////////////////////////////////////////////////////////////////////////////
// dentaku.cs - 電卓プログラム
//
// created by Fuhito Suguri, 31-Jul-2010
///////////////////////////////////////////////////////////////////////////////
using System;
using System.Drawing;
using System.Windows.Forms;
//
namespace bitWalk
{
class Program
{
static void Main()
{
Application.Run(new Dentaku());
}
}
/////////////////////////////////////////////////////////////////////////////
// class Dentaku
/////////////////////////////////////////////////////////////////////////////
class Dentaku : Form
{
// DISPLAY
private Label lab_0;
// KEY
private Button but_dot;
private Button but_equal;
private Button but_plus;
private Button but_minus;
private Button but_mul;
private Button but_div;
private Button but_mrc;
private Button but_mminus;
private Button but_mplus;
private Button but_clear;
private Button but_sign;
private Button but_percent;
private Button but_root;
private Button but_00;
private Button but_0;
private Button but_1;
private Button but_2;
private Button but_3;
private Button but_4;
private Button but_5;
private Button but_6;
private Button but_7;
private Button but_8;
private Button but_9;
// background color of KEY
private Color bgcolor_Disp = Color.PaleGreen;
private Color bgcolor_Num = Color.LightCyan;
private Color bgcolor_Dot = Color.PowderBlue;
private Color bgcolor_Op = Color.Lavender;
private Color bgcolor_Eq = Color.LavenderBlush;
private Color bgcolor_Func = Color.LemonChiffon;
private Color bgcolor_Memo = Color.LightPink;
private Color bgcolor_Cls = Color.HotPink;
// KEY size
private Size key_Size = new Size(50, 30);
private Size key_Size2 = new Size(50, 60);
// layout
private int[] row = {10, 60, 90, 120, 150, 180};
private int[] col = {10, 60, 110, 160, 210};
// for dentaku calculation
private bool entry_started = false;
private bool entry_dot = false;
private decimal entry_result = 0;
private decimal entry_memory = 0;
private string entry_operation = null;
/////////////////////////////////////////////////////////////////////////////
// Dentaku constructor
public Dentaku()
{
this.Width = 280;
this.Height = 250;
this.Text = "電卓";
this.FormBorderStyle
= System.Windows.Forms.FormBorderStyle.FixedDialog;
// DISPLAY
this.lab_0 = new Label();
this.lab_0.Font = new Font("MS UI Gothic", 14);
this.lab_0.BackColor = bgcolor_Disp;
this.lab_0.BorderStyle = BorderStyle.FixedSingle;
this.lab_0.Location = new Point(col[0], row[0]);
this.lab_0.Name = "lab0";
this.lab_0.Size = new Size(250, 40);
this.lab_0.Padding = new Padding(5);
this.lab_0.Text = "0";
this.lab_0.TextAlign = ContentAlignment.MiddleRight;
this.Controls.Add(this.lab_0);
// KEY √
this.but_root = new Button();
this.but_root.BackColor = bgcolor_Func;
this.but_root.Location = new Point(col[0], row[1]);
this.but_root.Size = key_Size;
this.but_root.Text = "√";
this.but_root.Click += new EventHandler(but_func_Click);
this.Controls.Add(this.but_root);
// KEY MRC
this.but_mrc = new Button();
this.but_mrc.BackColor = bgcolor_Memo;
this.but_mrc.Location = new Point(col[1], row[1]);
this.but_mrc.Size = key_Size;
this.but_mrc.Text = "MRC";
this.but_mrc.Click += new EventHandler(but_memo_Click);
this.Controls.Add(this.but_mrc);
// KEY M-
this.but_mminus = new Button();
this.but_mminus.BackColor = bgcolor_Memo;
this.but_mminus.Location = new Point(col[2], row[1]);
this.but_mminus.Size = key_Size;
this.but_mminus.Text = "M-";
this.but_mminus.Click += new EventHandler(but_memo_Click);
this.Controls.Add(but_mminus);
// KEY M+
this.but_mplus = new Button();
this.but_mplus.BackColor = bgcolor_Memo;
this.but_mplus.Location = new Point(col[3], row[1]);
this.but_mplus.Size = key_Size;
this.but_mplus.Text = "M+";
this.but_mplus.Click += new EventHandler(but_memo_Click);
this.Controls.Add(this.but_mplus);
// KEY ÷
this.but_div = new Button();
this.but_div.BackColor = bgcolor_Op;
this.but_div.Location = new Point(col[4], row[1]);
this.but_div.Size = key_Size;
this.but_div.Text = "÷";
this.but_div.Click += new EventHandler(but_ope_Click);
this.Controls.Add(this.but_div);
// KEY %
this.but_percent = new Button();
this.but_percent.BackColor = bgcolor_Func;
this.but_percent.Location = new Point(col[0], row[2]);
this.but_percent.Size = key_Size;
this.but_percent.Text = "%";
this.but_percent.Click += new EventHandler(this.but_func_Click);
this.Controls.Add(this.but_percent);
// KEY 7
this.but_7 = new Button();
this.but_7.BackColor = bgcolor_Num;
this.but_7.Location = new Point(col[1], row[2]);
this.but_7.Size = key_Size;
this.but_7.Text = "7";
this.but_7.Click += new EventHandler(but_num_Click);
this.Controls.Add(this.but_7);
// KEY 8
this.but_8 = new Button();
this.but_8.BackColor = bgcolor_Num;
this.but_8.Location = new Point(col[2], row[2]);
this.but_8.Size = key_Size;
this.but_8.Text = "8";
this.but_8.Click += new EventHandler(but_num_Click);
this.Controls.Add(this.but_8);
// KEY 9
this.but_9 = new Button();
this.but_9.BackColor = bgcolor_Num;
this.but_9.Location = new Point(col[3], row[2]);
this.but_9.Size = key_Size;
this.but_9.Text = "9";
this.but_9.Click += new EventHandler(but_num_Click);
this.Controls.Add(this.but_9);
// KEY ×
this.but_mul = new Button();
this.but_mul.BackColor = this.bgcolor_Op;
this.but_mul.Location = new Point(this.col[4], this.row[2]);
this.but_mul.Size = this.key_Size;
this.but_mul.Text = "×";
this.but_mul.Click += new EventHandler(this.but_ope_Click);
this.Controls.Add(this.but_mul);
// KEY ±
this.but_sign = new Button();
this.but_sign.BackColor = bgcolor_Func;
this.but_sign.Location = new Point(col[0], row[3]);
this.but_sign.Size = key_Size;
this.but_sign.Text = "±";
this.but_sign.Click += new EventHandler(but_func_Click);
this.Controls.Add(this.but_sign);
// KEY 4
this.but_4 = new Button();
this.but_4.BackColor = bgcolor_Num;
this.but_4.Location = new Point(col[1], row[3]);
this.but_4.Size = key_Size;
this.but_4.Text = "4";
this.but_4.Click += new EventHandler(but_num_Click);
this.Controls.Add(this.but_4);
// KEY 5
this.but_5 = new Button();
this.but_5.BackColor = bgcolor_Num;
this.but_5.Location = new Point(col[2], row[3]);
this.but_5.Size = key_Size;
this.but_5.Text = "5";
this.but_5.Click += new EventHandler(but_num_Click);
this.Controls.Add(this.but_5);
// KEY 6
this.but_6 = new Button();
this.but_6.BackColor = bgcolor_Num;
this.but_6.Location = new Point(col[3], row[3]);
this.but_6.Size = key_Size;
this.but_6.Text = "6";
this.but_6.Click += new EventHandler(but_num_Click);
this.Controls.Add(this.but_6);
// KEY −
this.but_minus = new Button();
this.but_minus.BackColor = bgcolor_Op;
this.but_minus.Location = new Point(col[4], row[3]);
this.but_minus.Size = key_Size;
this.but_minus.Text = "−";
this.but_minus.Click += new EventHandler(but_ope_Click);
this.Controls.Add(this.but_minus);
// KEY C
this.but_clear = new Button();
this.but_clear.BackColor = bgcolor_Cls;
this.but_clear.Location = new Point(col[0], row[4]);
this.but_clear.Size = key_Size;
this.but_clear.Text = "C";
this.but_clear.Click += new EventHandler(but_clear_Click);
this.Controls.Add(this.but_clear);
// KEY 1
this.but_1 = new Button();
this.but_1.BackColor = bgcolor_Num;
this.but_1.Location = new Point(col[1], row[4]);
this.but_1.Size = key_Size;
this.but_1.Text = "1";
this.but_1.Click += new EventHandler(but_num_Click);
this.Controls.Add(this.but_1);
// KEY 2
this.but_2 = new Button();
this.but_2.BackColor = bgcolor_Num;
this.but_2.Location = new Point(col[2], row[4]);
this.but_2.Size = key_Size;
this.but_2.Text = "2";
this.but_2.Click += new EventHandler(but_num_Click);
this.Controls.Add(this.but_2);
// KEY 3
this.but_3 = new Button();
this.but_3.BackColor = bgcolor_Num;
this.but_3.Location = new Point(col[3], row[4]);
this.but_3.Size = key_Size;
this.but_3.Text = "3";
this.but_3.Click += new EventHandler(but_num_Click);
this.Controls.Add(this.but_3);
// KEY +
this.but_plus = new Button();
this.but_plus.BackColor = bgcolor_Op;
this.but_plus.Location = new Point(col[4], row[4]);
this.but_plus.Size = key_Size2;
this.but_plus.Text = "+";
this.but_plus.Click += new EventHandler(but_ope_Click);
this.Controls.Add(this.but_plus);
// KEY 0
this.but_0 = new Button();
this.but_0.BackColor = bgcolor_Num;
this.but_0.Location = new Point(col[0], row[5]);
this.but_0.Size = key_Size;
this.but_0.Text = "0";
this.but_0.Click += new EventHandler(but_num_Click);
this.Controls.Add(this.but_0);
// KEY 00
this.but_00 = new Button();
this.but_00.BackColor = bgcolor_Num;
this.but_00.Location = new Point(col[1], row[5]);
this.but_00.Size = key_Size;
this.but_00.Text = "00";
this.but_00.Click += new EventHandler(but_num_Click);
this.Controls.Add(this.but_00);
// KEY ・
this.but_dot = new Button();
this.but_dot.BackColor = bgcolor_Dot;
this.but_dot.Location = new Point(col[2], row[5]);
this.but_dot.Size = key_Size;
this.but_dot.Text = "・";
this.but_dot.Click += new EventHandler(but_dot_Click);
this.Controls.Add(this.but_dot);
// KEY =
this.but_equal = new Button();
this.but_equal.BackColor = bgcolor_Eq;
this.but_equal.Location = new Point(col[3], row[5]);
this.but_equal.Size = key_Size;
this.but_equal.Text = "=";
this.but_equal.Click += new EventHandler(but_equal_Click);
this.Controls.Add(this.but_equal);
}
///////////////////////////////////////////////////////////////////////////
// but_num_Click - NUMBER key enter
private void but_num_Click(object sender, EventArgs e)
{
Button but = (Button)sender;
string n = "0";
switch (but.Text)
{
case "0" : n = "0"; break;
case "00" : n = "00"; break;
case "1" : n = "1"; break;
case "2" : n = "2"; break;
case "3" : n = "3"; break;
case "4" : n = "4"; break;
case "5" : n = "5"; break;
case "6" : n = "6"; break;
case "7" : n = "7"; break;
case "8" : n = "8"; break;
case "9" : n = "9"; break;
}
if (entry_started == false)
{
lab_0.Text = "0";
}
if (lab_0.Text == "0")
{
if (n != "00")
{
lab_0.Text = n;
}
}
else
{
lab_0.Text = lab_0.Text + n;
}
entry_started = true;
}
///////////////////////////////////////////////////////////////////////////
// but_dot_Click - DOT key enter
private void but_dot_Click(object sender, EventArgs e)
{
if (entry_dot == false)
{
if (entry_started == false)
{
lab_0.Text = "0.";
}
else
{
lab_0.Text = lab_0.Text + ".";
}
entry_started = true;
entry_dot = true;
}
}
///////////////////////////////////////////////////////////////////////////
// but_func_Click - Function key enter
private void but_func_Click(object sender, EventArgs e)
{
decimal n;
Button but = (Button)sender;
switch (but.Text)
{
case "±" :
n = decimal.Parse(lab_0.Text) * -1;
lab_0.Text = n.ToString();
break;
case "%" :
n = (decimal)(double.Parse(lab_0.Text) / 100);
lab_0.Text = n.ToString();
break;
case "√" :
try
{
n = (decimal)Math.Sqrt((double)decimal.Parse(lab_0.Text));
lab_0.Text = n.ToString();
}
catch
{
lab_0.Text = "E";
}
break;
}
entry_started = false;
entry_dot = false;
}
///////////////////////////////////////////////////////////////////////////
// but_ope_Click - OPERATION key enter
private void but_ope_Click(object sender, EventArgs e)
{
Button but = (Button)sender;
if (entry_operation != null)
{
but_equal_calculation();
}
entry_operation = but.Text;
entry_result = decimal.Parse(lab_0.Text);
entry_started = false;
entry_dot = false;
}
///////////////////////////////////////////////////////////////////////////
// but_equal_Click - EQUAL key enter
private void but_equal_Click(object sender, EventArgs e)
{
if (entry_operation != null)
{
but_equal_calculation();
}
entry_started = false;
entry_dot = false;
}
///////////////////////////////////////////////////////////////////////////
// but_equal_calculation - sub for EQUAL key enter
private void but_equal_calculation()
{
decimal n = 0;
switch (entry_operation)
{
case "+" :
n = entry_result + decimal.Parse(lab_0.Text);
lab_0.Text = n.ToString();
break;
case "−" :
n = entry_result - decimal.Parse(lab_0.Text);
lab_0.Text = n.ToString();
break;
case "×" :
n = entry_result * decimal.Parse(lab_0.Text);
lab_0.Text = n.ToString();
break;
case "÷" :
try
{
n = entry_result / decimal.Parse(lab_0.Text);
lab_0.Text = n.ToString();
}
catch
{
lab_0.Text = "E";
}
break;
}
entry_operation = null;
}
///////////////////////////////////////////////////////////////////////////
// but_clear_Click - CLEAR key enter
private void but_clear_Click(object sender, EventArgs e)
{
lab_0.Text = "0";
entry_started = false;
entry_dot = false;
entry_result = 0;
entry_operation = null;
}
///////////////////////////////////////////////////////////////////////////
// but_memo_Click - MEMORY key enter
private void but_memo_Click(object sender, EventArgs e)
{
Button but = (Button)sender;
switch (but.Text)
{
case "M+" :
entry_memory = entry_memory + decimal.Parse(lab_0.Text);
break;
case "M-" :
entry_memory = entry_memory - decimal.Parse(lab_0.Text);
break;
case "MRC" :
lab_0.Text = entry_memory.ToString();
entry_memory = 0;
break;
}
entry_started = false;
entry_dot = false;
}
}
}
// END PROGRAM
$ gmcs -pkg:dotnet -target:winexe dentaku.cs
$ mono dentaku.exe &
using System;
using System.Windows.Forms;
class HelloWorldApp {
public static void Main() {
MessageBox.Show("こんにちは、世界!", "mono");
}
}
$ su
パスワード:
# yum install mono-*
読み込んだプラグイン:presto, refresh-packagekit
...
(以下省略)
$ gmcs -pkg:dotnet -target:winexe hello.cs
$ mono hello.exe
$ wine hello.exe
【注記】情報が古くなりましたので、下記で内容を更新しました。