Reorganize files from svn

This commit is contained in:
james
2024-05-20 00:17:44 +00:00
parent c949f4c9a0
commit 7c830b241a
497 changed files with 0 additions and 0 deletions

27
bocoree/Arrays.cs Normal file
View File

@@ -0,0 +1,27 @@
/*
* Array.cs
* Copyright (c) 2009 kbinani
*
* This file is part of bocoree.
*
* bocoree is free software; you can redistribute it and/or
* modify it under the terms of the BSD License.
*
* bocoree is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
#if !JAVA
using System;
using System.Collections.Generic;
namespace bocoree.java.util {
public static class Arrays {
public static Vector<T> asList<T>( T[] a ) {
return new Vector<T>( a );
}
}
}
#endif

View File

@@ -0,0 +1,21 @@
/*
* BBackgroundWorker.cs
* Copyright (c) 2009 kbinani
*
* This file is part of bocoree.
*
* bocoree is free software; you can redistribute it and/or
* modify it under the terms of the BSD License.
*
* bocoree is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
#if JAVA
//INCLUDE ..\BuildJavaUI\src\org\kbinani\componentModel\BBackgroundWorker.java
#else
namespace bocoree.componentModel {
public class BBackgroundWorker : System.ComponentModel.BackgroundWorker {
}
}
#endif

248
bocoree/BButton.cs Normal file
View File

@@ -0,0 +1,248 @@
/*
* BButton.cs
* Copyright (c) 2009 kbinani
*
* This file is part of bocoree.
*
* bocoree is free software; you can redistribute it and/or
* modify it under the terms of the BSD License.
*
* bocoree is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
#if JAVA
//INCLUDE ..\BuildJavaUI\src\org\kbinani\windows\forms\BButton.java
#else
namespace bocoree.windows.forms {
public class BButton : System.Windows.Forms.Button {
#region java.awt.Component
// root implementation of java.awt.Component is in BForm.cs
public void setBounds( int x, int y, int width, int height ) {
base.Bounds = new System.Drawing.Rectangle( x, y, width, height );
}
public void setBounds( bocoree.java.awt.Rectangle rc ) {
base.Bounds = new System.Drawing.Rectangle( rc.x, rc.y, rc.width, rc.height );
}
public bocoree.java.awt.Cursor getCursor() {
System.Windows.Forms.Cursor c = base.Cursor;
bocoree.java.awt.Cursor ret = null;
if ( c.Equals( System.Windows.Forms.Cursors.Arrow ) ) {
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.DEFAULT_CURSOR );
} else if ( c.Equals( System.Windows.Forms.Cursors.Cross ) ) {
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.CROSSHAIR_CURSOR );
} else if ( c.Equals( System.Windows.Forms.Cursors.Default ) ) {
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.DEFAULT_CURSOR );
} else if ( c.Equals( System.Windows.Forms.Cursors.Hand ) ) {
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.HAND_CURSOR );
} else if ( c.Equals( System.Windows.Forms.Cursors.IBeam ) ) {
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.TEXT_CURSOR );
} else if ( c.Equals( System.Windows.Forms.Cursors.PanEast ) ) {
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.E_RESIZE_CURSOR );
} else if ( c.Equals( System.Windows.Forms.Cursors.PanNE ) ) {
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.NE_RESIZE_CURSOR );
} else if ( c.Equals( System.Windows.Forms.Cursors.PanNorth ) ) {
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.N_RESIZE_CURSOR );
} else if ( c.Equals( System.Windows.Forms.Cursors.PanNW ) ) {
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.NW_RESIZE_CURSOR );
} else if ( c.Equals( System.Windows.Forms.Cursors.PanSE ) ) {
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.SE_RESIZE_CURSOR );
} else if ( c.Equals( System.Windows.Forms.Cursors.PanSouth ) ) {
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.S_RESIZE_CURSOR );
} else if ( c.Equals( System.Windows.Forms.Cursors.PanSW ) ) {
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.SW_RESIZE_CURSOR );
} else if ( c.Equals( System.Windows.Forms.Cursors.PanWest ) ) {
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.W_RESIZE_CURSOR );
} else if ( c.Equals( System.Windows.Forms.Cursors.SizeAll ) ) {
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.MOVE_CURSOR );
} else {
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.CUSTOM_CURSOR );
}
ret.cursor = c;
return ret;
}
public void setCursor( bocoree.java.awt.Cursor value ) {
base.Cursor = value.cursor;
}
public bool isVisible() {
return base.Visible;
}
public void setVisible( bool value ) {
base.Visible = value;
}
#if COMPONENT_ENABLE_TOOL_TIP_TEXT
public void setToolTipText( string value )
{
base.ToolTipText = value;
}
public String getToolTipText()
{
return base.ToolTipText;
}
#endif
#if COMPONENT_PARENT_AS_OWNERITEM
public Object getParent() {
return base.OwnerItem;
}
#else
public object getParent() {
return base.Parent;
}
#endif
public string getName() {
return base.Name;
}
public void setName( string value ) {
base.Name = value;
}
#if COMPONENT_ENABLE_LOCATION
public bocoree.java.awt.Point getLocationOnScreen() {
System.Drawing.Point p = base.PointToScreen( base.Location );
return new bocoree.java.awt.Point( p.X, p.Y );
}
public bocoree.java.awt.Point getLocation() {
System.Drawing.Point loc = this.Location;
return new bocoree.java.awt.Point( loc.X, loc.Y );
}
public void setLocation( int x, int y ) {
base.Location = new System.Drawing.Point( x, y );
}
public void setLocation( bocoree.java.awt.Point p ) {
base.Location = new System.Drawing.Point( p.x, p.y );
}
#endif
public bocoree.java.awt.Rectangle getBounds() {
System.Drawing.Rectangle r = base.Bounds;
return new bocoree.java.awt.Rectangle( r.X, r.Y, r.Width, r.Height );
}
#if COMPONENT_ENABLE_X
public int getX() {
return base.Left;
}
#endif
#if COMPONENT_ENABLE_Y
public int getY() {
return base.Top;
}
#endif
public int getWidth() {
return base.Width;
}
public int getHeight() {
return base.Height;
}
public bocoree.java.awt.Dimension getSize() {
return new bocoree.java.awt.Dimension( base.Size.Width, base.Size.Height );
}
public void setSize( int width, int height ) {
base.Size = new System.Drawing.Size( width, height );
}
public void setSize( bocoree.java.awt.Dimension d ) {
setSize( d.width, d.height );
}
public void setBackground( bocoree.java.awt.Color color ) {
base.BackColor = System.Drawing.Color.FromArgb( color.getRed(), color.getGreen(), color.getBlue() );
}
public bocoree.java.awt.Color getBackground() {
return new bocoree.java.awt.Color( base.BackColor.R, base.BackColor.G, base.BackColor.B );
}
public void setForeground( bocoree.java.awt.Color color ) {
base.ForeColor = color.color;
}
public bocoree.java.awt.Color getForeground() {
return new bocoree.java.awt.Color( base.ForeColor.R, base.ForeColor.G, base.ForeColor.B );
}
public bool isEnabled() {
return base.Enabled;
}
public void setEnabled( bool value ) {
base.Enabled = value;
}
public void requestFocus() {
base.Focus();
}
public bool isFocusOwner() {
return base.Focused;
}
public void setPreferredSize( bocoree.java.awt.Dimension size ) {
base.Size = new System.Drawing.Size( size.width, size.height );
}
public bocoree.java.awt.Font getFont() {
return new bocoree.java.awt.Font( base.Font );
}
public void setFont( bocoree.java.awt.Font font ) {
if ( font == null ) {
return;
}
if ( font.font == null ) {
return;
}
base.Font = font.font;
}
#endregion
#region javax.swing.AbstractButton
public string getText() {
return base.Text;
}
public void setText( string value ) {
base.Text = value;
}
#if ABSTRACT_BUTTON_ENABLE_IS_SELECTED
public bool isSelected() {
return base.Checked;
}
public void setSelected( bool value ) {
base.Checked = value;
}
#endif
public bocoree.java.awt.Icon getIcon() {
bocoree.java.awt.Icon ret = new bocoree.java.awt.Icon();
ret.image = base.Image;
return ret;
}
public void setIcon( bocoree.java.awt.Icon value ) {
base.Image = value.image;
}
#endregion
}
}
#endif

View File

@@ -0,0 +1,16 @@
/*
* BCancelEventArgs.cs
* Copyright (c) 2009 kbinani
*
* This file is part of bocoree.
*
* bocoree is free software; you can redistribute it and/or
* modify it under the terms of the BSD License.
*
* bocoree is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
#if JAVA
//INCLUDE ..\BuildJavaUI\src\org\kbinani\componentModel\BCancelEventArgs.java
#endif

105
bocoree/BCheckBox.cs Normal file
View File

@@ -0,0 +1,105 @@
/*
* BCheckBox.cs
* Copyright (c) 2009 kbinani
*
* This file is part of bocoree.
*
* bocoree is free software; you can redistribute it and/or
* modify it under the terms of the BSD License.
*
* bocoree is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
#if JAVA
//INCLUDE ..\BuildJavaUI\src\org\kbinani\windows\forms\BCheckBox.java
#else
#define ABSTRACT_BUTTON_ENABLE_IS_SELECTED
namespace bocoree.windows.forms {
public class BCheckBox : System.Windows.Forms.CheckBox{
#region java.awt.Component
public bocoree.java.awt.Point getLocation() {
System.Drawing.Point loc = this.Location;
return new bocoree.java.awt.Point( loc.X, loc.Y );
}
public void setLocation( int x, int y ) {
base.Location = new System.Drawing.Point( x, y );
}
public void setLocation( bocoree.java.awt.Point p ) {
base.Location = new System.Drawing.Point( p.x, p.y );
}
public bocoree.java.awt.Rectangle getBounds() {
System.Drawing.Rectangle r = base.Bounds;
return new bocoree.java.awt.Rectangle( r.X, r.Y, r.Width, r.Height );
}
public int getX() {
return base.Left;
}
public int getY() {
return base.Top;
}
public int getWidth() {
return base.Width;
}
public int getHeight() {
return base.Height;
}
public bocoree.java.awt.Dimension getSize() {
return new bocoree.java.awt.Dimension( base.Size.Width, base.Size.Height );
}
public void setSize( int width, int height ) {
base.Size = new System.Drawing.Size( width, height );
}
public void setSize( bocoree.java.awt.Dimension d ) {
setSize( d.width, d.height );
}
public void setBackground( bocoree.java.awt.Color color ) {
base.BackColor = System.Drawing.Color.FromArgb( color.getRed(), color.getGreen(), color.getBlue() );
}
public void setFont( bocoree.java.awt.Font font ) {
base.Font = font.font;
}
public bool getEnabled() {
return base.Enabled;
}
public void setEnabled( bool value ) {
base.Enabled = value;
}
#endregion
#region javax.swing.AbstractButton
public string getText() {
return base.Text;
}
public void setText( string value ) {
base.Text = value;
}
#if ABSTRACT_BUTTON_ENABLE_IS_SELECTED
public bool isSelected() {
return base.Checked;
}
public void setSelected( bool value ) {
base.Checked = true;
}
#endif
#endregion
}
}
#endif

255
bocoree/BComboBox.cs Normal file
View File

@@ -0,0 +1,255 @@
#if JAVA
//INCLUDE ..\BuildJavaUI\src\org\kbinani\windows\forms\BComboBox.java
#else
using System;
using System.Windows.Forms;
namespace bocoree.windows.forms{
public class BComboBox : ComboBox {
public void addItem( object item ) {
base.Items.Add( item );
}
public object getItemAt( int index ) {
return base.Items[index];
}
public int getItemCount() {
return base.Items.Count;
}
public int getSelectedIndex() {
return base.SelectedIndex;
}
public object getSelectedItem() {
return base.SelectedItem;
}
public void insertItemAt( object item, int index ) {
base.Items.Insert( index, item );
}
public void removeAllItems() {
base.Items.Clear();
}
public void removeItem( object item ) {
base.Items.Remove( item );
}
public void removeItemAt( int index ) {
base.Items.RemoveAt( index );
}
public void setSelectedItem( object item ) {
base.SelectedItem = item;
}
public void setSelectedIndex( int index ) {
base.SelectedIndex = index;
}
#region java.awt.Component
// root implementation of java.awt.Component is in BForm.cs
public void setBounds( int x, int y, int width, int height ) {
base.Bounds = new System.Drawing.Rectangle( x, y, width, height );
}
public void setBounds( bocoree.java.awt.Rectangle rc ) {
base.Bounds = new System.Drawing.Rectangle( rc.x, rc.y, rc.width, rc.height );
}
public bocoree.java.awt.Cursor getCursor() {
System.Windows.Forms.Cursor c = base.Cursor;
bocoree.java.awt.Cursor ret = null;
if ( c.Equals( System.Windows.Forms.Cursors.Arrow ) ) {
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.DEFAULT_CURSOR );
} else if ( c.Equals( System.Windows.Forms.Cursors.Cross ) ) {
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.CROSSHAIR_CURSOR );
} else if ( c.Equals( System.Windows.Forms.Cursors.Default ) ) {
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.DEFAULT_CURSOR );
} else if ( c.Equals( System.Windows.Forms.Cursors.Hand ) ) {
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.HAND_CURSOR );
} else if ( c.Equals( System.Windows.Forms.Cursors.IBeam ) ) {
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.TEXT_CURSOR );
} else if ( c.Equals( System.Windows.Forms.Cursors.PanEast ) ) {
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.E_RESIZE_CURSOR );
} else if ( c.Equals( System.Windows.Forms.Cursors.PanNE ) ) {
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.NE_RESIZE_CURSOR );
} else if ( c.Equals( System.Windows.Forms.Cursors.PanNorth ) ) {
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.N_RESIZE_CURSOR );
} else if ( c.Equals( System.Windows.Forms.Cursors.PanNW ) ) {
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.NW_RESIZE_CURSOR );
} else if ( c.Equals( System.Windows.Forms.Cursors.PanSE ) ) {
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.SE_RESIZE_CURSOR );
} else if ( c.Equals( System.Windows.Forms.Cursors.PanSouth ) ) {
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.S_RESIZE_CURSOR );
} else if ( c.Equals( System.Windows.Forms.Cursors.PanSW ) ) {
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.SW_RESIZE_CURSOR );
} else if ( c.Equals( System.Windows.Forms.Cursors.PanWest ) ) {
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.W_RESIZE_CURSOR );
} else if ( c.Equals( System.Windows.Forms.Cursors.SizeAll ) ) {
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.MOVE_CURSOR );
} else {
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.CUSTOM_CURSOR );
}
ret.cursor = c;
return ret;
}
public void setCursor( bocoree.java.awt.Cursor value ) {
base.Cursor = value.cursor;
}
public bool isVisible() {
return base.Visible;
}
public void setVisible( bool value ) {
base.Visible = value;
}
#if COMPONENT_ENABLE_TOOL_TIP_TEXT
public void setToolTipText( string value )
{
base.ToolTipText = value;
}
public String getToolTipText()
{
return base.ToolTipText;
}
#endif
#if COMPONENT_PARENT_AS_OWNERITEM
public Object getParent() {
return base.OwnerItem;
}
#else
public object getParent() {
return base.Parent;
}
#endif
public string getName() {
return base.Name;
}
public void setName( string value ) {
base.Name = value;
}
#if COMPONENT_ENABLE_LOCATION
public bocoree.java.awt.Point getLocationOnScreen() {
System.Drawing.Point p = base.PointToScreen( base.Location );
return new bocoree.java.awt.Point( p.X, p.Y );
}
public bocoree.java.awt.Point getLocation() {
System.Drawing.Point loc = this.Location;
return new bocoree.java.awt.Point( loc.X, loc.Y );
}
public void setLocation( int x, int y ) {
base.Location = new System.Drawing.Point( x, y );
}
public void setLocation( bocoree.java.awt.Point p ) {
base.Location = new System.Drawing.Point( p.x, p.y );
}
#endif
public bocoree.java.awt.Rectangle getBounds() {
System.Drawing.Rectangle r = base.Bounds;
return new bocoree.java.awt.Rectangle( r.X, r.Y, r.Width, r.Height );
}
#if COMPONENT_ENABLE_X
public int getX() {
return base.Left;
}
#endif
#if COMPONENT_ENABLE_Y
public int getY() {
return base.Top;
}
#endif
public int getWidth() {
return base.Width;
}
public int getHeight() {
return base.Height;
}
public bocoree.java.awt.Dimension getSize() {
return new bocoree.java.awt.Dimension( base.Size.Width, base.Size.Height );
}
public void setSize( int width, int height ) {
base.Size = new System.Drawing.Size( width, height );
}
public void setSize( bocoree.java.awt.Dimension d ) {
setSize( d.width, d.height );
}
public void setBackground( bocoree.java.awt.Color color ) {
base.BackColor = System.Drawing.Color.FromArgb( color.getRed(), color.getGreen(), color.getBlue() );
}
public bocoree.java.awt.Color getBackground() {
return new bocoree.java.awt.Color( base.BackColor.R, base.BackColor.G, base.BackColor.B );
}
public void setForeground( bocoree.java.awt.Color color ) {
base.ForeColor = color.color;
}
public bocoree.java.awt.Color getForeground() {
return new bocoree.java.awt.Color( base.ForeColor.R, base.ForeColor.G, base.ForeColor.B );
}
public bool isEnabled() {
return base.Enabled;
}
public void setEnabled( bool value ) {
base.Enabled = value;
}
public void requestFocus() {
base.Focus();
}
public bool isFocusOwner() {
return base.Focused;
}
public void setPreferredSize( bocoree.java.awt.Dimension size ) {
base.Size = new System.Drawing.Size( size.width, size.height );
}
public bocoree.java.awt.Font getFont() {
return new bocoree.java.awt.Font( base.Font );
}
public void setFont( bocoree.java.awt.Font font ) {
if ( font == null ) {
return;
}
if ( font.font == null ) {
return;
}
base.Font = font.font;
}
#endregion
}
}
#endif

16
bocoree/BDelegate.cs Normal file
View File

@@ -0,0 +1,16 @@
/*
* BDelegate.cs
* Copyright (c) 2009 kbinani
*
* This file is part of bocoree.
*
* bocoree is free software; you can redistribute it and/or
* modify it under the terms of the BSD License.
*
* bocoree is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
#if JAVA
//INCLUDE ..\BuildJavaUI\src\org\kbinani\BDelegate.java
#endif

27
bocoree/BDialogResult.cs Normal file
View File

@@ -0,0 +1,27 @@
/*
* BDialogResult.cs
* Copyright (c) 2009 kbinani
*
* This file is part of bocoree.
*
* bocoree is free software; you can redistribute it and/or
* modify it under the terms of the BSD License.
*
* bocoree is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
#if JAVA
//INCLUDE ..\BuildJavaUI\src\org\kbinani\windows\forms\BDialogResult.java
#else
namespace bocoree.windows.forms {
public enum BDialogResult {
OK,
CANCEL,
YES,
NO,
}
}
#endif

View File

@@ -0,0 +1,16 @@
/*
* BDoWorkEventArgs.cs
* Copyright (c) 2009 kbinani
*
* This file is part of bocoree.
*
* bocoree is free software; you can redistribute it and/or
* modify it under the terms of the BSD License.
*
* bocoree is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
#if JAVA
//INCLUDE ..\BuildJavaUI\src\org\kbinani\componentModel\BDoWorkEventArgs.java
#endif

View File

@@ -0,0 +1,16 @@
/*
* BDoWorkEventHandler.cs
* Copyright (c) 2009 kbinani
*
* This file is part of bocoree.
*
* bocoree is free software; you can redistribute it and/or
* modify it under the terms of the BSD License.
*
* bocoree is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
#if JAVA
//INCLUDE ..\BuildJavaUI\src\org\kbinani\componentModel\BDoWorkEventHandler.java
#endif

16
bocoree/BEvent.cs Normal file
View File

@@ -0,0 +1,16 @@
/*
* BEvent.cs
* Copyright (c) 2009 kbinani
*
* This file is part of bocoree.
*
* bocoree is free software; you can redistribute it and/or
* modify it under the terms of the BSD License.
*
* bocoree is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
#if JAVA
//INCLUDE ..\BuildJavaUI\src\org\kbinani\BEvent.java
#endif

16
bocoree/BEventArgs.cs Normal file
View File

@@ -0,0 +1,16 @@
/*
* BEventArgs.cs
* Copyright (c) 2009 kbinani
*
* This file is part of bocoree.
*
* bocoree is free software; you can redistribute it and/or
* modify it under the terms of the BSD License.
*
* bocoree is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
#if JAVA
//INCLUDE ..\BuildJavaUI\src\org\kbinani\BEventArgs.java
#endif

16
bocoree/BEventHandler.cs Normal file
View File

@@ -0,0 +1,16 @@
/*
* BEventHandler.cs
* Copyright (c) 2009 kbinani
*
* This file is part of bocoree.
*
* bocoree is free software; you can redistribute it and/or
* modify it under the terms of the BSD License.
*
* bocoree is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
#if JAVA
//INCLUDE ..\BuildJavaUI\src\org\kbinani\BEventHandler.java
#endif

159
bocoree/BFileChooser.cs Normal file
View File

@@ -0,0 +1,159 @@
/*
* BFileChooser.cs
* Copyright (c) 2009 kbinani
*
* This file is part of bocoree.
*
* bocoree is free software; you can redistribute it and/or
* modify it under the terms of the BSD License.
*
* bocoree is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
#if JAVA
//INCLUDE ..\BuildJavaUI\src\org\kbinani\windows\forms\BFileChooser.java
#else
using System;
using System.IO;
using System.Windows.Forms;
using System.Collections.Generic;
namespace bocoree.windows.forms {
public class BFileChooser : IDisposable {
public const int APPROVE_OPTION = 0;
public const int CANCEL_OPTION = 1;
public const int ERROR_OPTION = -1;
private string m_current_directory = "";
private List<string> m_filters = new List<string>();
private OpenFileDialog m_open = new OpenFileDialog();
private SaveFileDialog m_save = new SaveFileDialog();
private string m_current_filter = "";
private string m_selected_file = "";
public BFileChooser( String currentDirectoryPath ) {
m_current_directory = currentDirectoryPath;
}
public void addFileFilter( String filter ) {
m_filters.Add( filter );
}
public String getFileFilter() {
return m_current_filter;
}
public void setFileFilter( String value ) {
m_current_filter = value;
}
public void clearChoosableFileFilter() {
m_filters.Clear();
}
public string[] getChoosableFileFilter() {
return m_filters.ToArray();
}
public String getSelectedFile() {
return m_selected_file;
}
public void setSelectedFile( String value ) {
m_selected_file = value;
m_open.FileName = m_selected_file;
m_save.FileName = m_selected_file;
}
public void setInitialDirectory( string value ) {
m_open.InitialDirectory = value;
m_save.InitialDirectory = value;
}
public int showOpenDialog( Control parent ) {
m_open.InitialDirectory = m_current_directory;
string filter = "";
int count = 0;
int selected = -1;
foreach ( string f in m_filters ) {
filter += (count == 0 ? "" : "|") + f;
if ( f == m_current_filter ) {
selected = count;
}
count++;
}
m_open.Filter = filter;
if ( selected >= 0 ) {
m_open.FilterIndex = selected;
}
DialogResult dr = m_open.ShowDialog();
m_selected_file = m_open.FileName;
int filter_index = m_open.FilterIndex;
if ( 0 <= filter_index && filter_index < m_filters.Count ) {
m_current_filter = m_filters[filter_index];
}
if ( m_selected_file != "" ) {
m_current_directory = Path.GetDirectoryName( m_selected_file );
}
if ( dr == DialogResult.OK ) {
return APPROVE_OPTION;
} else if ( dr == DialogResult.Cancel ) {
return CANCEL_OPTION;
} else {
return ERROR_OPTION;
}
}
public int showSaveDialog( Control parent ) {
m_save.InitialDirectory = m_current_directory;
string filter = "";
int count = 0;
int selected = -1;
foreach ( string f in m_filters ) {
filter += (count == 0 ? "" : "|") + f;
if ( f == m_current_filter ) {
selected = count;
}
count++;
}
m_save.Filter = filter;
if ( selected >= 0 ) {
m_save.FilterIndex = selected;
}
DialogResult dr = m_save.ShowDialog();
m_selected_file = m_save.FileName;
int filter_index = m_save.FilterIndex;
if ( 0 <= filter_index && filter_index < m_filters.Count ) {
m_current_filter = m_filters[filter_index];
}
if ( m_selected_file != "" ) {
m_current_directory = Path.GetDirectoryName( m_selected_file );
}
if ( dr == DialogResult.OK ) {
return APPROVE_OPTION;
} else if ( dr == DialogResult.Cancel ) {
return CANCEL_OPTION;
} else {
return ERROR_OPTION;
}
}
public void setDialogTitle( String value ) {
m_open.Title = value;
m_save.Title = value;
}
public void Dispose() {
if ( m_open == null ) {
m_open.Dispose();
}
if ( m_save == null ) {
m_save.Dispose();
}
}
}
}
#endif

64
bocoree/BFolderBrowser.cs Normal file
View File

@@ -0,0 +1,64 @@
/*
* BFolderBrowser.cs
* Copyright (c) 2009 kbinani
*
* This file is part of bocoree.
*
* bocoree is free software; you can redistribute it and/or
* modify it under the terms of the BSD License.
*
* bocoree is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
#if JAVA
//INCLUDE ..\BuildJavaUI\src\org\kbinani\windows\forms\BFolderBrowser.java
#else
using System;
using System.Windows.Forms;
namespace bocoree.windows.forms {
public class BFolderBrowser {
public FolderBrowserDialog dialog;
public BFolderBrowser() {
dialog = new FolderBrowserDialog();
dialog.RootFolder = Environment.SpecialFolder.Desktop;
}
public bool isNewFolderButtonVisible() {
return dialog.ShowNewFolderButton;
}
public void setNewFolderButtonVisible( bool value ) {
dialog.ShowNewFolderButton = value;
}
public string getDescription() {
return dialog.Description;
}
public void setDescription( string value ) {
dialog.Description = value;
}
public string getSelectedPath() {
return dialog.SelectedPath;
}
public void setSelectedPath( string value ) {
dialog.SelectedPath = value;
}
public BDialogResult showDialog() {
if ( dialog.ShowDialog() == DialogResult.OK ) {
return BDialogResult.OK;
} else {
return BDialogResult.CANCEL;
}
}
}
}
#endif

50
bocoree/BFontChooser.cs Normal file
View File

@@ -0,0 +1,50 @@
/*
* BFontChooser.cs
* Copyright (c) 2009 kbinani
*
* This file is part of bocoree.
*
* bocoree is free software; you can redistribute it and/or
* modify it under the terms of the BSD License.
*
* bocoree is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
#if JAVA
//INCLUDE ..\BuildJavaUI\src\org\kbinani\windows\forms\BFontChooser.java
#else
using System;
using System.Windows.Forms;
using bocoree.java.awt;
namespace bocoree.windows.forms {
public class BFontChooser {
public FontDialog dialog = null;
public BFontChooser() {
dialog = new FontDialog();
}
public BDialogResult showDialog() {
DialogResult dr = dialog.ShowDialog();
if ( dr == DialogResult.OK ) {
return BDialogResult.OK;
} else if ( dr == DialogResult.Cancel ) {
return BDialogResult.CANCEL;
}
return BDialogResult.CANCEL;
}
public void setSelectedFont( Font font ) {
dialog.Font = font.font;
}
public Font getSelectedFont() {
return new Font( dialog.Font );
}
}
}
#endif

413
bocoree/BForm.cs Normal file
View File

@@ -0,0 +1,413 @@
/*
* BForm.cs
* Copyright (c) 2009 kbinani
*
* This file is part of bocoree.
*
* bocoree is free software; you can redistribute it and/or
* modify it under the terms of the BSD License.
*
* bocoree is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
#if JAVA
//INCLUDE ..\BuildJavaUI\src\org\kbinani\windows\forms\BForm.java
#else
#define COMPONENT_ENABLE_LOCATION
#define COMPONENT_ENABLE_Y
#define COMPONENT_ENABLE_X
#define COMPONENT_ENABLE_FOCUS
#define COMPONENT_ENABLE_CURSOR
#define COMPONENT_ENABLE_REPAINT
using System;
namespace bocoree.windows.forms {
using boolean = System.Boolean;
public class BForm : System.Windows.Forms.Form {
protected BDialogResult m_result = BDialogResult.CANCEL;
public void setDialogResult( BDialogResult value ) {
switch ( value ) {
case BDialogResult.YES:
this.DialogResult = System.Windows.Forms.DialogResult.Yes;
break;
case BDialogResult.NO:
this.DialogResult = System.Windows.Forms.DialogResult.No;
break;
case BDialogResult.OK:
this.DialogResult = System.Windows.Forms.DialogResult.OK;
break;
case BDialogResult.CANCEL:
this.DialogResult = System.Windows.Forms.DialogResult.Cancel;
break;
}
}
public BDialogResult getDialogResult() {
return m_result;
}
public BDialogResult showDialog() {
System.Windows.Forms.DialogResult dr = base.ShowDialog();
if ( dr == System.Windows.Forms.DialogResult.OK ) {
m_result = BDialogResult.OK;
} else if ( dr == System.Windows.Forms.DialogResult.Cancel ) {
m_result = BDialogResult.CANCEL;
} else if ( dr == System.Windows.Forms.DialogResult.Yes ) {
m_result = BDialogResult.YES;
} else if ( dr == System.Windows.Forms.DialogResult.No ) {
m_result = BDialogResult.NO;
}
return m_result;
}
public void close() {
base.Close();
}
public bocoree.java.awt.Dimension getClientSize() {
System.Drawing.Size s = base.Size;
return new bocoree.java.awt.Dimension( s.Width, s.Height );
}
// root implementation: common APIs of org.kbinani.*
#region common APIs of org.kbinani.*
// root implementation is in BForm.cs
public bocoree.java.awt.Point pointToScreen( bocoree.java.awt.Point point_on_client ) {
bocoree.java.awt.Point p = getLocationOnScreen();
return new bocoree.java.awt.Point( p.x + point_on_client.x, p.y + point_on_client.y );
}
public bocoree.java.awt.Point pointToClient( bocoree.java.awt.Point point_on_screen ) {
bocoree.java.awt.Point p = getLocationOnScreen();
return new bocoree.java.awt.Point( point_on_screen.x - p.x, point_on_screen.y - p.y );
}
#endregion
// root implementation of java.awt.Component
#region java.awt.Component
// root implementation of java.awt.Component is in BForm.cs
public void invalidate() {
base.Invalidate();
}
#if COMPONENT_ENABLE_REPAINT
public void repaint() {
base.Refresh();
}
#endif
#if COMPONENT_ENABLE_CURSOR
public bocoree.java.awt.Cursor getCursor() {
System.Windows.Forms.Cursor c = base.Cursor;
bocoree.java.awt.Cursor ret = null;
if( c.Equals( System.Windows.Forms.Cursors.Arrow ) ){
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.DEFAULT_CURSOR );
} else if ( c.Equals( System.Windows.Forms.Cursors.Cross ) ){
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.CROSSHAIR_CURSOR );
} else if ( c.Equals( System.Windows.Forms.Cursors.Default ) ){
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.DEFAULT_CURSOR );
} else if ( c.Equals( System.Windows.Forms.Cursors.Hand ) ){
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.HAND_CURSOR );
} else if ( c.Equals( System.Windows.Forms.Cursors.IBeam ) ) {
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.TEXT_CURSOR );
} else if ( c.Equals( System.Windows.Forms.Cursors.PanEast ) ) {
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.E_RESIZE_CURSOR );
} else if ( c.Equals( System.Windows.Forms.Cursors.PanNE ) ) {
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.NE_RESIZE_CURSOR );
} else if ( c.Equals( System.Windows.Forms.Cursors.PanNorth ) ) {
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.N_RESIZE_CURSOR );
} else if ( c.Equals( System.Windows.Forms.Cursors.PanNW ) ) {
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.NW_RESIZE_CURSOR );
} else if ( c.Equals( System.Windows.Forms.Cursors.PanSE ) ) {
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.SE_RESIZE_CURSOR );
} else if ( c.Equals( System.Windows.Forms.Cursors.PanSouth ) ) {
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.S_RESIZE_CURSOR );
} else if ( c.Equals( System.Windows.Forms.Cursors.PanSW ) ) {
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.SW_RESIZE_CURSOR );
} else if ( c.Equals( System.Windows.Forms.Cursors.PanWest ) ) {
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.W_RESIZE_CURSOR );
} else if ( c.Equals( System.Windows.Forms.Cursors.SizeAll ) ) {
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.MOVE_CURSOR );
} else {
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.CUSTOM_CURSOR );
}
ret.cursor = c;
return ret;
}
public void setCursor( bocoree.java.awt.Cursor value ) {
base.Cursor = value.cursor;
}
#endif
public bool isVisible() {
return base.Visible;
}
public void setVisible( bool value ) {
base.Visible = value;
}
#if COMPONENT_ENABLE_TOOL_TIP_TEXT
public void setToolTipText( string value )
{
base.ToolTipText = value;
}
public String getToolTipText()
{
return base.ToolTipText;
}
#endif
#if COMPONENT_PARENT_AS_OWNERITEM
public Object getParent() {
return base.OwnerItem;
}
#else
public object getParent() {
return base.Parent;
}
#endif
public string getName() {
return base.Name;
}
public void setName( string value ) {
base.Name = value;
}
#if COMPONENT_ENABLE_LOCATION
public void setBounds( int x, int y, int width, int height ) {
base.Bounds = new System.Drawing.Rectangle( x, y, width, height );
}
public void setBounds( bocoree.java.awt.Rectangle rc ) {
base.Bounds = new System.Drawing.Rectangle( rc.x, rc.y, rc.width, rc.height );
}
public bocoree.java.awt.Point getLocationOnScreen() {
System.Drawing.Point p = base.PointToScreen( base.Location );
return new bocoree.java.awt.Point( p.X, p.Y );
}
public bocoree.java.awt.Point getLocation() {
System.Drawing.Point loc = this.Location;
return new bocoree.java.awt.Point( loc.X, loc.Y );
}
public void setLocation( int x, int y ) {
base.Location = new System.Drawing.Point( x, y );
}
public void setLocation( bocoree.java.awt.Point p ) {
base.Location = new System.Drawing.Point( p.x, p.y );
}
#endif
public bocoree.java.awt.Rectangle getBounds() {
System.Drawing.Rectangle r = base.Bounds;
return new bocoree.java.awt.Rectangle( r.X, r.Y, r.Width, r.Height );
}
#if COMPONENT_ENABLE_X
public int getX() {
return base.Left;
}
#endif
#if COMPONENT_ENABLE_Y
public int getY() {
return base.Top;
}
#endif
public int getWidth() {
return base.Width;
}
public int getHeight() {
return base.Height;
}
public bocoree.java.awt.Dimension getSize() {
return new bocoree.java.awt.Dimension( base.Size.Width, base.Size.Height );
}
public void setSize( int width, int height ) {
base.Size = new System.Drawing.Size( width, height );
}
public void setSize( bocoree.java.awt.Dimension d ) {
setSize( d.width, d.height );
}
public void setBackground( bocoree.java.awt.Color color ) {
base.BackColor = System.Drawing.Color.FromArgb( color.getRed(), color.getGreen(), color.getBlue() );
}
public bocoree.java.awt.Color getBackground() {
return new bocoree.java.awt.Color( base.BackColor.R, base.BackColor.G, base.BackColor.B );
}
public void setForeground( bocoree.java.awt.Color color ) {
base.ForeColor = color.color;
}
public bocoree.java.awt.Color getForeground() {
return new bocoree.java.awt.Color( base.ForeColor.R, base.ForeColor.G, base.ForeColor.B );
}
public bool isEnabled() {
return base.Enabled;
}
public void setEnabled( bool value ) {
base.Enabled = value;
}
#if COMPONENT_ENABLE_FOCUS
public void requestFocus() {
base.Focus();
}
public bool isFocusOwner() {
return base.Focused;
}
#endif
public void setPreferredSize( bocoree.java.awt.Dimension size ) {
base.Size = new System.Drawing.Size( size.width, size.height );
}
public bocoree.java.awt.Font getFont() {
return new bocoree.java.awt.Font( base.Font );
}
public void setFont( bocoree.java.awt.Font font ) {
if ( font == null ) {
return;
}
if ( font.font == null ) {
return;
}
base.Font = font.font;
}
#endregion
// root implementation of java.awt.Window
#region java.awt.Window
// root implementation of java.awt.Window is in BForm.cs
public void setMinimumSize( bocoree.java.awt.Dimension size ) {
base.MinimumSize = new System.Drawing.Size( size.width, size.height );
}
public bocoree.java.awt.Dimension getMinimumSize() {
return new bocoree.java.awt.Dimension( base.MinimumSize.Width, base.MinimumSize.Height );
}
public void setAlwaysOnTop( boolean alwaysOnTop ) {
base.TopMost = alwaysOnTop;
}
public boolean isAlwaysOnTop() {
return base.TopMost;
}
#endregion
// root implementation of java.awt.Frame
#region java.awt.Frame
// root implementation of java.awt.Frame is in BForm.cs
public const int CROSSHAIR_CURSOR = 1;
public const int DEFAULT_CURSOR = 0;
public const int E_RESIZE_CURSOR = 11;
public const int HAND_CURSOR = 12;
public const int ICONIFIED = 1;
public const int MAXIMIZED_BOTH = 6;
public const int MAXIMIZED_HORIZ = 2;
public const int MAXIMIZED_VERT = 4;
public const int MOVE_CURSOR = 13;
public const int N_RESIZE_CURSOR = 8;
public const int NE_RESIZE_CURSOR = 7;
public const int NORMAL = 0;
public const int NW_RESIZE_CURSOR = 6;
public const int S_RESIZE_CURSOR = 9;
public const int SE_RESIZE_CURSOR = 5;
public const int SW_RESIZE_CURSOR = 4;
public const int TEXT_CURSOR = 2;
public const int W_RESIZE_CURSOR = 10;
public const int WAIT_CURSOR = 3;
public void setIconImage( System.Drawing.Icon icon ) {
base.Icon = icon;
}
public System.Drawing.Icon getIconImage() {
return base.Icon;
}
public int getState() {
if ( base.WindowState == System.Windows.Forms.FormWindowState.Minimized ) {
return ICONIFIED;
} else {
return NORMAL;
}
}
public void setState( int state ) {
if ( state == ICONIFIED ) {
if ( base.WindowState != System.Windows.Forms.FormWindowState.Minimized ) {
base.WindowState = System.Windows.Forms.FormWindowState.Minimized;
}
} else {
if ( base.WindowState == System.Windows.Forms.FormWindowState.Minimized ) {
base.WindowState = System.Windows.Forms.FormWindowState.Normal;
}
}
}
public int getExtendedState() {
if ( base.WindowState == System.Windows.Forms.FormWindowState.Maximized ) {
return MAXIMIZED_BOTH;
} else if ( base.WindowState == System.Windows.Forms.FormWindowState.Minimized ) {
return ICONIFIED;
} else {
return NORMAL;
}
}
public void setExtendedState( int value ) {
if ( value == ICONIFIED ) {
base.WindowState = System.Windows.Forms.FormWindowState.Minimized;
} else if ( value == MAXIMIZED_BOTH ) {
base.WindowState = System.Windows.Forms.FormWindowState.Maximized;
} else {
base.WindowState = System.Windows.Forms.FormWindowState.Normal;
}
}
public string getTitle() {
return base.Text;
}
public void setTitle( string value ) {
base.Text = value;
}
#endregion
// root implementation of javax.swing.JComponent
#region javax.swing.JComponent
// root implementation of javax.swing.JComponent is in BForm.cs
public bool requestFocusInWindow() {
return base.Focus();
}
#endregion
}
}
#endif

View File

@@ -0,0 +1,16 @@
/*
* BFormClosedEventArgs.cs
* Copyright (c) 2009 kbinani
*
* This file is part of bocoree.
*
* bocoree is free software; you can redistribute it and/or
* modify it under the terms of the BSD License.
*
* bocoree is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
#if JAVA
//INCLUDE ..\BuildJavaUI\src\org\kbinani\windows\forms\BFormClosedEventArgs.java
#endif

View File

@@ -0,0 +1,16 @@
/*
* BFormClosingEventArgs.cs
* Copyright (c) 2009 kbinani
*
* This file is part of bocoree.
*
* bocoree is free software; you can redistribute it and/or
* modify it under the terms of the BSD License.
*
* bocoree is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
#if JAVA
//INCLUDE ..\BuildJavaUI\src\org\kbinani\windows\forms\BFormClosingEventArgs.java
#endif

View File

@@ -0,0 +1,16 @@
/*
* BFormClosingEventHandler.cs
* Copyright (c) 2009 kbinani
*
* This file is part of bocoree.
*
* bocoree is free software; you can redistribute it and/or
* modify it under the terms of the BSD License.
*
* bocoree is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
#if JAVA
//INCLUDE ..\BuildJavaUI\src\org\kbinani\windows\forms\BFormClosingEventHandler.java
#endif

View File

@@ -0,0 +1,26 @@
/*
* BFormWindowState.cs
* Copyright (c) 2009 kbinani
*
* This file is part of bocoree.
*
* bocoree is free software; you can redistribute it and/or
* modify it under the terms of the BSD License.
*
* bocoree is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
#if JAVA
//INCLUDE ..\BuildJavaUI\src\org\kbinani\windows\forms\BFormWindowState.java
#else
namespace bocoree.windows.forms{
public enum BFormWindowState {
Normal,
Minimized,
Maximized,
}
}
#endif

15
bocoree/BGroupBox.cs Normal file
View File

@@ -0,0 +1,15 @@
#if JAVA
//INCLUDE ..\BuildJavaUI\src\org\kbinani\windows\forms\BGroupBox.java
#else
namespace bocoree.windows.forms{
public class BGroupBox : System.Windows.Forms.GroupBox {
public string getTitle() {
return base.Text;
}
public void setTitle( string value ) {
base.Text = value;
}
}
}
#endif

228
bocoree/BHScrollBar.cs Normal file
View File

@@ -0,0 +1,228 @@
/*
* BHScrollBar.cs
* Copyright (c) 2009 kbinani
*
* This file is part of bocoree.
*
* bocoree is free software; you can redistribute it and/or
* modify it under the terms of the BSD License.
*
* bocoree is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
#if JAVA
//INCLUDE ..\BuildJavaUI\src\org\kbinani\windows\forms\BHScrollBar.java
#else
namespace bocoree.windows.forms{
public class BHScrollBar : System.Windows.Forms.HScrollBar{
#region javax.swing.ScrollBar
public void setMaximum( int value ) {
base.Maximum = value;
}
public int getMaximum() {
return base.Maximum;
}
public void setMinimum( int value ) {
base.Minimum = value;
}
public int getMinimum() {
return base.Minimum;
}
public int getValue() {
return base.Value;
}
public void setValue( int value ) {
base.Value = value;
}
public int getVisibleAmount() {
return base.LargeChange;
}
public void setVisibleAmount( int value ) {
base.LargeChange = value;
}
#endregion
#region java.awt.Component
// root implementation of java.awt.Component is in BForm.cs
public bocoree.java.awt.Cursor getCursor() {
System.Windows.Forms.Cursor c = base.Cursor;
bocoree.java.awt.Cursor ret = null;
if ( c.Equals( System.Windows.Forms.Cursors.Arrow ) ) {
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.DEFAULT_CURSOR );
} else if ( c.Equals( System.Windows.Forms.Cursors.Cross ) ) {
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.CROSSHAIR_CURSOR );
} else if ( c.Equals( System.Windows.Forms.Cursors.Default ) ) {
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.DEFAULT_CURSOR );
} else if ( c.Equals( System.Windows.Forms.Cursors.Hand ) ) {
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.HAND_CURSOR );
} else if ( c.Equals( System.Windows.Forms.Cursors.IBeam ) ) {
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.TEXT_CURSOR );
} else if ( c.Equals( System.Windows.Forms.Cursors.PanEast ) ) {
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.E_RESIZE_CURSOR );
} else if ( c.Equals( System.Windows.Forms.Cursors.PanNE ) ) {
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.NE_RESIZE_CURSOR );
} else if ( c.Equals( System.Windows.Forms.Cursors.PanNorth ) ) {
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.N_RESIZE_CURSOR );
} else if ( c.Equals( System.Windows.Forms.Cursors.PanNW ) ) {
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.NW_RESIZE_CURSOR );
} else if ( c.Equals( System.Windows.Forms.Cursors.PanSE ) ) {
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.SE_RESIZE_CURSOR );
} else if ( c.Equals( System.Windows.Forms.Cursors.PanSouth ) ) {
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.S_RESIZE_CURSOR );
} else if ( c.Equals( System.Windows.Forms.Cursors.PanSW ) ) {
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.SW_RESIZE_CURSOR );
} else if ( c.Equals( System.Windows.Forms.Cursors.PanWest ) ) {
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.W_RESIZE_CURSOR );
} else if ( c.Equals( System.Windows.Forms.Cursors.SizeAll ) ) {
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.MOVE_CURSOR );
} else {
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.CUSTOM_CURSOR );
}
ret.cursor = c;
return ret;
}
public void setCursor( bocoree.java.awt.Cursor value ) {
base.Cursor = value.cursor;
}
public bool isVisible() {
return base.Visible;
}
public void setVisible( bool value ) {
base.Visible = value;
}
#if COMPONENT_ENABLE_TOOL_TIP_TEXT
public void setToolTipText( string value )
{
base.ToolTipText = value;
}
public String getToolTipText()
{
return base.ToolTipText;
}
#endif
#if COMPONENT_PARENT_AS_OWNERITEM
public Object getParent() {
return base.OwnerItem;
}
#else
public object getParent() {
return base.Parent;
}
#endif
public string getName() {
return base.Name;
}
public void setName( string value ) {
base.Name = value;
}
#if COMPONENT_ENABLE_LOCATION
public bocoree.java.awt.Point getLocationOnScreen() {
System.Drawing.Point p = base.PointToScreen( base.Location );
return new bocoree.java.awt.Point( p.X, p.Y );
}
public bocoree.java.awt.Point getLocation() {
System.Drawing.Point loc = this.Location;
return new bocoree.java.awt.Point( loc.X, loc.Y );
}
public void setLocation( int x, int y ) {
base.Location = new System.Drawing.Point( x, y );
}
public void setLocation( bocoree.java.awt.Point p ) {
base.Location = new System.Drawing.Point( p.x, p.y );
}
#endif
public bocoree.java.awt.Rectangle getBounds() {
System.Drawing.Rectangle r = base.Bounds;
return new bocoree.java.awt.Rectangle( r.X, r.Y, r.Width, r.Height );
}
#if COMPONENT_ENABLE_X
public int getX() {
return base.Left;
}
#endif
#if COMPONENT_ENABLE_Y
public int getY() {
return base.Top;
}
#endif
public int getWidth() {
return base.Width;
}
public int getHeight() {
return base.Height;
}
public bocoree.java.awt.Dimension getSize() {
return new bocoree.java.awt.Dimension( base.Size.Width, base.Size.Height );
}
public void setSize( int width, int height ) {
base.Size = new System.Drawing.Size( width, height );
}
public void setSize( bocoree.java.awt.Dimension d ) {
setSize( d.width, d.height );
}
public void setBackground( bocoree.java.awt.Color color ) {
base.BackColor = System.Drawing.Color.FromArgb( color.getRed(), color.getGreen(), color.getBlue() );
}
public bocoree.java.awt.Color getBackground() {
return new bocoree.java.awt.Color( base.BackColor.R, base.BackColor.G, base.BackColor.B );
}
public void setForeground( bocoree.java.awt.Color color ) {
base.ForeColor = color.color;
}
public bocoree.java.awt.Color getForeground() {
return new bocoree.java.awt.Color( base.ForeColor.R, base.ForeColor.G, base.ForeColor.B );
}
public void setFont( bocoree.java.awt.Font font ) {
base.Font = font.font;
}
public bool isEnabled() {
return base.Enabled;
}
public void setEnabled( bool value ) {
base.Enabled = value;
}
public void requestFocus() {
base.Focus();
}
#endregion
}
}
#endif

16
bocoree/BKeyEventArgs.cs Normal file
View File

@@ -0,0 +1,16 @@
/*
* BKeyEventArgs.cs
* Copyright (c) 2009 kbinani
*
* This file is part of bocoree.
*
* bocoree is free software; you can redistribute it and/or
* modify it under the terms of the BSD License.
*
* bocoree is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
#if JAVA
//INCLUDE ..\BuildJavaUI\src\org\kbinani\windows\forms\BKeyEventArgs.java
#endif

View File

@@ -0,0 +1,16 @@
/*
* BKeyEventHandler.cs
* Copyright (c) 2009 kbinani
*
* This file is part of bocoree.
*
* bocoree is free software; you can redistribute it and/or
* modify it under the terms of the BSD License.
*
* bocoree is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
#if JAVA
//INCLUDE ..\BuildJavaUI\src\org\kbinani\windows\forms\BKeyEventHandler.java
#endif

View File

@@ -0,0 +1,16 @@
/*
* BKeyPressEventArgs.cs
* Copyright (c) 2009 kbinani
*
* This file is part of bocoree.
*
* bocoree is free software; you can redistribute it and/or
* modify it under the terms of the BSD License.
*
* bocoree is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
#if JAVA
//INCLUDE ..\BuildJavaUI\src\org\kbinani\windows\forms\BKeyPressEventArgs.java
#endif

432
bocoree/BKeys.cs Normal file
View File

@@ -0,0 +1,432 @@
/*
* BKeys.cs
* Copyright (c) 2009 kbinani
*
* This file is part of bocoree.
*
* bocoree is free software; you can redistribute it and/or
* modify it under the terms of the BSD License.
*
* bocoree is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
#if JAVA
package org.kbinani.windows.forms;
public enum BKeys{
Modifiers( -65536 ),
None( 0 ),
LButton( 1 ),
RButton( 2 ),
Cancel( 3 ),
MButton( 4 ),
XButton1( 5 ),
XButton2( 6 ),
Back( 8 ),
Tab( 9 ),
LineFeed( 10 ),
Clear( 12 ),
Enter( 13 ),
Return( 13 ),
ShiftKey( 16 ),
ControlKey( 17 ),
Menu( 18 ),
Pause( 19 ),
CapsLock( 20 ),
Capital( 20 ),
KanaMode( 21 ),
HanguelMode( 21 ),
HangulMode( 21 ),
JunjaMode( 23 ),
FinalMode( 24 ),
KanjiMode( 25 ),
HanjaMode( 25 ),
Escape( 27 ),
IMEConvert( 28 ),
IMENonconvert( 29 ),
IMEAceept( 30 ),
IMEAccept( 30 ),
IMEModeChange( 31 ),
Space( 32 ),
Prior( 33 ),
PageUp( 33 ),
Next( 34 ),
PageDown( 34 ),
End( 35 ),
Home( 36 ),
Left( 37 ),
Up( 38 ),
Right( 39 ),
Down( 40 ),
Select( 41 ),
Print( 42 ),
Execute( 43 ),
PrintScreen( 44 ),
Snapshot( 44 ),
Insert( 45 ),
Delete( 46 ),
Help( 47 ),
D0( 48 ),
D1( 49 ),
D2( 50 ),
D3( 51 ),
D4( 52 ),
D5( 53 ),
D6( 54 ),
D7( 55 ),
D8( 56 ),
D9( 57 ),
A( 65 ),
B( 66 ),
C( 67 ),
D( 68 ),
E( 69 ),
F( 70 ),
G( 71 ),
H( 72 ),
I( 73 ),
J( 74 ),
K( 75 ),
L( 76 ),
M( 77 ),
N( 78 ),
O( 79 ),
P( 80 ),
Q( 81 ),
R( 82 ),
S( 83 ),
T( 84 ),
U( 85 ),
V( 86 ),
W( 87 ),
X( 88 ),
Y( 89 ),
Z( 90 ),
LWin( 91 ),
RWin( 92 ),
Apps( 93 ),
Sleep( 95 ),
NumPad0( 96 ),
NumPad1( 97 ),
NumPad2( 98 ),
NumPad3( 99 ),
NumPad4( 100 ),
NumPad5( 101 ),
NumPad6( 102 ),
NumPad7( 103 ),
NumPad8( 104 ),
NumPad9( 105 ),
Multiply( 106 ),
Add( 107 ),
Separator( 108 ),
Subtract( 109 ),
Decimal( 110 ),
Divide( 111 ),
F1( 112 ),
F2( 113 ),
F3( 114 ),
F4( 115 ),
F5( 116 ),
F6( 117 ),
F7( 118 ),
F8( 119 ),
F9( 120 ),
F10( 121 ),
F11( 122 ),
F12( 123 ),
F13( 124 ),
F14( 125 ),
F15( 126 ),
F16( 127 ),
F17( 128 ),
F18( 129 ),
F19( 130 ),
F20( 131 ),
F21( 132 ),
F22( 133 ),
F23( 134 ),
F24( 135 ),
NumLock( 144 ),
Scroll( 145 ),
LShiftKey( 160 ),
RShiftKey( 161 ),
LControlKey( 162 ),
RControlKey( 163 ),
LMenu( 164 ),
RMenu( 165 ),
BrowserBack( 166 ),
BrowserForward( 167 ),
BrowserRefresh( 168 ),
BrowserStop( 169 ),
BrowserSearch( 170 ),
BrowserFavorites( 171 ),
BrowserHome( 172 ),
VolumeMute( 173 ),
VolumeDown( 174 ),
VolumeUp( 175 ),
MediaNextTrack( 176 ),
MediaPreviousTrack( 177 ),
MediaStop( 178 ),
MediaPlayPause( 179 ),
LaunchMail( 180 ),
SelectMedia( 181 ),
LaunchApplication1( 182 ),
LaunchApplication2( 183 ),
Oem1( 186 ),
OemSemicolon( 186 ),
Oemplus( 187 ),
Oemcomma( 188 ),
OemMinus( 189 ),
OemPeriod( 190 ),
OemQuestion( 191 ),
Oem2( 191 ),
Oemtilde( 192 ),
Oem3( 192 ),
Oem4( 219 ),
OemOpenBrackets( 219 ),
OemPipe( 220 ),
Oem5( 220 ),
Oem6( 221 ),
OemCloseBrackets( 221 ),
Oem7( 222 ),
OemQuotes( 222 ),
Oem8( 223 ),
Oem102( 226 ),
OemBackslash( 226 ),
ProcessKey( 229 ),
Packet( 231 ),
Attn( 246 ),
Crsel( 247 ),
Exsel( 248 ),
EraseEof( 249 ),
Play( 250 ),
Zoom( 251 ),
NoName( 252 ),
Pa1( 253 ),
OemClear( 254 ),
KeyCode( 65535 ),
Shift( 65536 ),
Control( 131072 ),
Alt( 262144 );
private int m_value;
private BKeys( int value ){
m_value = value;
}
public int getValue(){
return m_value;
}
public boolean equals( BKeys item ){
if( item == null ){
return false;
}else{
return item.getValue() == getValue();
}
}
}
#else
namespace bocoree.windows.forms {
public enum BKeys {
Modifiers = -65536,
None = 0,
LButton = 1,
RButton = 2,
Cancel = 3,
MButton = 4,
XButton1 = 5,
XButton2 = 6,
Back = 8,
Tab = 9,
LineFeed = 10,
Clear = 12,
Enter = 13,
Return = 13,
ShiftKey = 16,
ControlKey = 17,
Menu = 18,
Pause = 19,
CapsLock = 20,
Capital = 20,
KanaMode = 21,
HanguelMode = 21,
HangulMode = 21,
JunjaMode = 23,
FinalMode = 24,
KanjiMode = 25,
HanjaMode = 25,
Escape = 27,
IMEConvert = 28,
IMENonconvert = 29,
IMEAceept = 30,
IMEAccept = 30,
IMEModeChange = 31,
Space = 32,
Prior = 33,
PageUp = 33,
Next = 34,
PageDown = 34,
End = 35,
Home = 36,
Left = 37,
Up = 38,
Right = 39,
Down = 40,
Select = 41,
Print = 42,
Execute = 43,
PrintScreen = 44,
Snapshot = 44,
Insert = 45,
Delete = 46,
Help = 47,
D0 = 48,
D1 = 49,
D2 = 50,
D3 = 51,
D4 = 52,
D5 = 53,
D6 = 54,
D7 = 55,
D8 = 56,
D9 = 57,
A = 65,
B = 66,
C = 67,
D = 68,
E = 69,
F = 70,
G = 71,
H = 72,
I = 73,
J = 74,
K = 75,
L = 76,
M = 77,
N = 78,
O = 79,
P = 80,
Q = 81,
R = 82,
S = 83,
T = 84,
U = 85,
V = 86,
W = 87,
X = 88,
Y = 89,
Z = 90,
LWin = 91,
RWin = 92,
Apps = 93,
Sleep = 95,
NumPad0 = 96,
NumPad1 = 97,
NumPad2 = 98,
NumPad3 = 99,
NumPad4 = 100,
NumPad5 = 101,
NumPad6 = 102,
NumPad7 = 103,
NumPad8 = 104,
NumPad9 = 105,
Multiply = 106,
Add = 107,
Separator = 108,
Subtract = 109,
Decimal = 110,
Divide = 111,
F1 = 112,
F2 = 113,
F3 = 114,
F4 = 115,
F5 = 116,
F6 = 117,
F7 = 118,
F8 = 119,
F9 = 120,
F10 = 121,
F11 = 122,
F12 = 123,
F13 = 124,
F14 = 125,
F15 = 126,
F16 = 127,
F17 = 128,
F18 = 129,
F19 = 130,
F20 = 131,
F21 = 132,
F22 = 133,
F23 = 134,
F24 = 135,
NumLock = 144,
Scroll = 145,
LShiftKey = 160,
RShiftKey = 161,
LControlKey = 162,
RControlKey = 163,
LMenu = 164,
RMenu = 165,
BrowserBack = 166,
BrowserForward = 167,
BrowserRefresh = 168,
BrowserStop = 169,
BrowserSearch = 170,
BrowserFavorites = 171,
BrowserHome = 172,
VolumeMute = 173,
VolumeDown = 174,
VolumeUp = 175,
MediaNextTrack = 176,
MediaPreviousTrack = 177,
MediaStop = 178,
MediaPlayPause = 179,
LaunchMail = 180,
SelectMedia = 181,
LaunchApplication1 = 182,
LaunchApplication2 = 183,
Oem1 = 186,
OemSemicolon = 186,
Oemplus = 187,
Oemcomma = 188,
OemMinus = 189,
OemPeriod = 190,
OemQuestion = 191,
Oem2 = 191,
Oemtilde = 192,
Oem3 = 192,
Oem4 = 219,
OemOpenBrackets = 219,
OemPipe = 220,
Oem5 = 220,
Oem6 = 221,
OemCloseBrackets = 221,
Oem7 = 222,
OemQuotes = 222,
Oem8 = 223,
Oem102 = 226,
OemBackslash = 226,
ProcessKey = 229,
Packet = 231,
Attn = 246,
Crsel = 247,
Exsel = 248,
EraseEof = 249,
Play = 250,
Zoom = 251,
NoName = 252,
Pa1 = 253,
OemClear = 254,
KeyCode = 65535,
Shift = 65536,
Control = 131072,
Alt = 262144,
}
}
#endif

236
bocoree/BLabel.cs Normal file
View File

@@ -0,0 +1,236 @@
/*
* BLabel.cs
* Copyright (c) 2009 kbinani
*
* This file is part of bocoree.
*
* bocoree is free software; you can redistribute it and/or
* modify it under the terms of the GPLv3 License.
*
* bocoree is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
#if JAVA
//INCLUDE ..\BuildJavaUI\src\org\kbinani\windows\forms\BLabel.java
#else
namespace bocoree.windows.forms{
public class BLabel : System.Windows.Forms.Label {
public string getText() {
return base.Text;
}
public void setText( string value ) {
base.Text = value;
}
#region java.awt.Component
// root implementation of java.awt.Component is in BForm.cs
public void invalidate() {
base.Invalidate();
}
public void repaint() {
base.Refresh();
}
public void setBounds( int x, int y, int width, int height ) {
base.Bounds = new System.Drawing.Rectangle( x, y, width, height );
}
public void setBounds( bocoree.java.awt.Rectangle rc ) {
base.Bounds = new System.Drawing.Rectangle( rc.x, rc.y, rc.width, rc.height );
}
public bocoree.java.awt.Cursor getCursor() {
System.Windows.Forms.Cursor c = base.Cursor;
bocoree.java.awt.Cursor ret = null;
if ( c.Equals( System.Windows.Forms.Cursors.Arrow ) ) {
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.DEFAULT_CURSOR );
} else if ( c.Equals( System.Windows.Forms.Cursors.Cross ) ) {
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.CROSSHAIR_CURSOR );
} else if ( c.Equals( System.Windows.Forms.Cursors.Default ) ) {
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.DEFAULT_CURSOR );
} else if ( c.Equals( System.Windows.Forms.Cursors.Hand ) ) {
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.HAND_CURSOR );
} else if ( c.Equals( System.Windows.Forms.Cursors.IBeam ) ) {
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.TEXT_CURSOR );
} else if ( c.Equals( System.Windows.Forms.Cursors.PanEast ) ) {
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.E_RESIZE_CURSOR );
} else if ( c.Equals( System.Windows.Forms.Cursors.PanNE ) ) {
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.NE_RESIZE_CURSOR );
} else if ( c.Equals( System.Windows.Forms.Cursors.PanNorth ) ) {
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.N_RESIZE_CURSOR );
} else if ( c.Equals( System.Windows.Forms.Cursors.PanNW ) ) {
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.NW_RESIZE_CURSOR );
} else if ( c.Equals( System.Windows.Forms.Cursors.PanSE ) ) {
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.SE_RESIZE_CURSOR );
} else if ( c.Equals( System.Windows.Forms.Cursors.PanSouth ) ) {
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.S_RESIZE_CURSOR );
} else if ( c.Equals( System.Windows.Forms.Cursors.PanSW ) ) {
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.SW_RESIZE_CURSOR );
} else if ( c.Equals( System.Windows.Forms.Cursors.PanWest ) ) {
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.W_RESIZE_CURSOR );
} else if ( c.Equals( System.Windows.Forms.Cursors.SizeAll ) ) {
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.MOVE_CURSOR );
} else {
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.CUSTOM_CURSOR );
}
ret.cursor = c;
return ret;
}
public void setCursor( bocoree.java.awt.Cursor value ) {
base.Cursor = value.cursor;
}
public bool isVisible() {
return base.Visible;
}
public void setVisible( bool value ) {
base.Visible = value;
}
#if COMPONENT_ENABLE_TOOL_TIP_TEXT
public void setToolTipText( string value )
{
base.ToolTipText = value;
}
public String getToolTipText()
{
return base.ToolTipText;
}
#endif
#if COMPONENT_PARENT_AS_OWNERITEM
public Object getParent() {
return base.OwnerItem;
}
#else
public object getParent() {
return base.Parent;
}
#endif
public string getName() {
return base.Name;
}
public void setName( string value ) {
base.Name = value;
}
#if COMPONENT_ENABLE_LOCATION
public bocoree.java.awt.Point getLocationOnScreen() {
System.Drawing.Point p = base.PointToScreen( base.Location );
return new bocoree.java.awt.Point( p.X, p.Y );
}
public bocoree.java.awt.Point getLocation() {
System.Drawing.Point loc = this.Location;
return new bocoree.java.awt.Point( loc.X, loc.Y );
}
public void setLocation( int x, int y ) {
base.Location = new System.Drawing.Point( x, y );
}
public void setLocation( bocoree.java.awt.Point p ) {
base.Location = new System.Drawing.Point( p.x, p.y );
}
#endif
public bocoree.java.awt.Rectangle getBounds() {
System.Drawing.Rectangle r = base.Bounds;
return new bocoree.java.awt.Rectangle( r.X, r.Y, r.Width, r.Height );
}
#if COMPONENT_ENABLE_X
public int getX() {
return base.Left;
}
#endif
#if COMPONENT_ENABLE_Y
public int getY() {
return base.Top;
}
#endif
public int getWidth() {
return base.Width;
}
public int getHeight() {
return base.Height;
}
public bocoree.java.awt.Dimension getSize() {
return new bocoree.java.awt.Dimension( base.Size.Width, base.Size.Height );
}
public void setSize( int width, int height ) {
base.Size = new System.Drawing.Size( width, height );
}
public void setSize( bocoree.java.awt.Dimension d ) {
setSize( d.width, d.height );
}
public void setBackground( bocoree.java.awt.Color color ) {
base.BackColor = System.Drawing.Color.FromArgb( color.getRed(), color.getGreen(), color.getBlue() );
}
public bocoree.java.awt.Color getBackground() {
return new bocoree.java.awt.Color( base.BackColor.R, base.BackColor.G, base.BackColor.B );
}
public void setForeground( bocoree.java.awt.Color color ) {
base.ForeColor = color.color;
}
public bocoree.java.awt.Color getForeground() {
return new bocoree.java.awt.Color( base.ForeColor.R, base.ForeColor.G, base.ForeColor.B );
}
public bool isEnabled() {
return base.Enabled;
}
public void setEnabled( bool value ) {
base.Enabled = value;
}
public void requestFocus() {
base.Focus();
}
public bool isFocusOwner() {
return base.Focused;
}
public void setPreferredSize( bocoree.java.awt.Dimension size ) {
base.Size = new System.Drawing.Size( size.width, size.height );
}
public bocoree.java.awt.Font getFont() {
return new bocoree.java.awt.Font( base.Font );
}
public void setFont( bocoree.java.awt.Font font ) {
if ( font == null ) {
return;
}
if ( font.font == null ) {
return;
}
base.Font = font.font;
}
#endregion
}
}
#endif

217
bocoree/BListView.cs Normal file
View File

@@ -0,0 +1,217 @@
/*
* BListView.cs
* Copyright (c) 2009 kbinani
*
* This file is part of bocoree.
*
* bocoree is free software; you can redistribute it and/or
* modify it under the terms of the BSD License.
*
* bocoree is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
#if JAVA
//INCLUDE ..\BuildJavaUI\src\org\kbinani\windows\forms\BListView.java
#else
using System;
using System.Collections.Generic;
using System.Windows.Forms;
using bocoree.java.awt;
namespace bocoree.windows.forms {
public class BListView : System.Windows.Forms.ListView {
private List<ColumnHeader> m_headers = new List<ColumnHeader>();
public BListView() {
ListViewGroup def = new ListViewGroup();
def.Name = "";
base.Groups.Add( def );
}
public void ensureRowVisible( String group, int row ) {
ListViewGroup g = getGroupFromName( group );
g.Items[row].EnsureVisible();
}
public void setGroupHeader( String group, String header ) {
ListViewGroup g = getGroupFromName( group );
g.Header = header;
}
public void setItemBackColorAt( String group, int index, Color color ) {
ListViewGroup g = getGroupFromName( group );
g.Items[index].BackColor = color.color;
}
public void clear() {
List<ColumnHeader> cache = new List<ColumnHeader>();
foreach ( ColumnHeader hdr in base.Columns ) {
cache.Add( hdr );
}
base.Clear();
foreach ( ColumnHeader hdr in cache ) {
base.Columns.Add( hdr );
}
}
public string getGroupNameAt( int index ) {
return base.Groups[index].Name;
}
public int getGroupCount() {
return base.Groups.Count;
}
public void setItemAt( string group, int index, BListViewItem item ) {
ListViewGroup g = getGroupFromName( group );
g.Items[index] = item;
}
public void removeItemAt( string group, int index ) {
ListViewGroup g = getGroupFromName( group );
g.Items.RemoveAt( index );
}
public BListViewItem getItemAt( string group, int index ) {
ListViewGroup g = getGroupFromName( group );
return (BListViewItem)g.Items[index];
}
public int getItemCount( String group ) {
ListViewGroup g = getGroupFromName( group );
return g.Items.Count;
}
private ListViewGroup getGroupFromName( string name ) {
foreach ( ListViewGroup group in base.Groups ) {
if ( name == group.Name ) {
if ( name == "" ) {
group.Header = "Default";
}
return group;
}
}
#if DEBUG
Console.WriteLine( "BListView#getGroupFromName; creating new group" );
#endif
System.Windows.Forms.ListViewGroup g = new System.Windows.Forms.ListViewGroup();
g.Name = name;
if ( name == "" ) {
g.Header = "Default";
} else {
g.Header = name;
}
base.Groups.Add( g );
return g;
}
public Boolean isItemCheckedAt( string group, int index ) {
ListViewGroup g = getGroupFromName( group );
return g.Items[index].Checked;
}
public void setItemCheckedAt( string group, int index, bool value ) {
ListViewGroup g = getGroupFromName( group );
g.Items[index].Checked = value;
}
public int getSelectedIndex( string group ) {
ListViewGroup g = getGroupFromName( group );
int count = g.Items.Count;
for ( int i = 0; i < count; i++ ) {
if ( g.Items[i].Selected ) {
return i;
}
}
return -1;
}
public void clearSelection( string group ) {
ListViewGroup g = getGroupFromName( group );
foreach ( ListViewItem item in g.Items ) {
item.Selected = false;
}
}
public void setItemSelectedAt( string group, int index, bool value ) {
ListViewGroup g = getGroupFromName( group );
g.Items[index].Selected = value;
}
public void addItem( string group, BListViewItem item, bool value ) {
int dif = item.getSubItemCount() - base.Columns.Count;
for ( int i = 0; i < dif; i++ ) {
ColumnHeader hdr = new ColumnHeader();
m_headers.Add( hdr );
base.Columns.Add( hdr );
}
ListViewGroup g = getGroupFromName( group );
item.Checked = value;
item.Group = g;
base.Items.Add( item );
#if DEBUG
//Console.WriteLine( "BListView#addItem; columnWidths;" + base.Columns[0].Width + "," + base.Columns[1].Width );
#endif
}
public void addItem( string group, BListViewItem item ) {
addItem( group, item, false );
}
public bool isMultiSelect() {
return base.MultiSelect;
}
public void setMultiSelect( bool value ) {
base.MultiSelect = value;
}
public void setColumnHeaders( string[] headers ) {
#if DEBUG
Console.WriteLine( "BListView#setColumnHeaders; before; base.Columns.Count=" + base.Columns.Count );
#endif
int dif = headers.Length - base.Columns.Count;
for ( int i = 0; i < dif; i++ ) {
ColumnHeader hdr = new ColumnHeader();
m_headers.Add( hdr );
base.Columns.Add( hdr );
}
for ( int i = 0; i < headers.Length; i++ ) {
base.Columns[i].Text = headers[i];
base.Columns[i].Name = headers[i];
}
#if DEBUG
Console.WriteLine( "BListView#setColumnHeaders; after; base.Columns.Count=" + base.Columns.Count );
#endif
}
public void setColumnWidth( int index, int width ) {
base.Columns[index].Width = width;
}
public int getColumnWidth( int index ) {
return base.Columns[index].Width;
}
public string[] getColumnHeaders() {
int len = base.Columns.Count;
string[] ret = new string[len];
for ( int i = 0; i < len; i++ ) {
ret[i] = base.Columns[i].Text;
}
return ret;
}
public bool isCheckBoxes() {
return base.CheckBoxes;
}
public void setCheckBoxes( bool value ) {
base.CheckBoxes = value;
}
}
}
#endif

52
bocoree/BListViewItem.cs Normal file
View File

@@ -0,0 +1,52 @@
/*
* BFontChooser.cs
* Copyright (c) 2009 kbinani
*
* This file is part of bocoree.
*
* bocoree is free software; you can redistribute it and/or
* modify it under the terms of the BSD License.
*
* bocoree is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
#if JAVA
//INCLUDE ..\BuildJavaUI\src\org\kbinani\windows\forms\BListViewItem.java
#else
namespace bocoree.windows.forms {
public class BListViewItem : System.Windows.Forms.ListViewItem {
private string group = "";
public BListViewItem( string[] values )
: base( values ) {
}
public object clone() {
return base.Clone();
}
public object getTag() {
return base.Tag;
}
public void setTag( object value ) {
base.Tag = value;
}
public int getSubItemCount() {
return base.SubItems.Count;
}
public string getSubItemAt( int index ) {
return base.SubItems[index].Text;
}
public void setSubItemAt( int index, string value ) {
base.SubItems[index].Text = value;
}
}
}
#endif

229
bocoree/BMenu.cs Normal file
View File

@@ -0,0 +1,229 @@
/*
* BMenuItem.cs
* Copyright (c) 2009 kbinani
*
* This file is part of bocoree.
*
* bocoree is free software; you can redistribute it and/or
* modify it under the terms of the BSD License.
*
* bocoree is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
#if JAVA
//INCLUDE ..\BuildJavaUI\src\org\kbinani\windows\forms\BMenu.java
#else
#define ABSTRACT_BUTTON_ENABLE_IS_SELECTED
#define COMPONENT_PARENT_AS_OWNERITEM
#define COMPONENT_ENABLE_TOOL_TIP_TEXT
using System.Collections.Generic;
using System.Windows.Forms;
using bocoree.javax.swing;
namespace bocoree.windows.forms {
// このクラスの中身はBMenuItem.csのコピー
public class BMenu : System.Windows.Forms.ToolStripMenuItem, MenuElement {
// root implementation of javax.swing.AbstractButton
#region javax.swing.AbstractButton
public string getText() {
return base.Text;
}
public void setText( string value ) {
base.Text = value;
}
#if ABSTRACT_BUTTON_ENABLE_IS_SELECTED
public bool isSelected() {
return base.Checked;
}
public void setSelected( bool value ) {
base.Checked = value;
}
#endif
public System.Drawing.Image getIcon() {
return base.Image;
}
public void setIcon( System.Drawing.Image value ) {
base.Image = value;
}
#endregion
#region java.awt.Component
public bool isVisible() {
return base.Visible;
}
public void setVisible( bool value ) {
base.Visible = value;
}
#if COMPONENT_ENABLE_TOOL_TIP_TEXT
public void setToolTipText( string value ) {
base.ToolTipText = value;
}
public string getToolTipText() {
return base.ToolTipText;
}
#endif
#if COMPONENT_PARENT_AS_OWNERITEM
public object getParent() {
return base.OwnerItem;
}
#else
public object getParent()
{
return base.Parent;
}
#endif
public string getName() {
return base.Name;
}
public void setName( string value ) {
base.Name = value;
}
#if COMPONENT_ENABLE_LOCATION
public bocoree.java.awt.Point getLocation()
{
System.Drawing.Point loc = this.Location;
return new bocoree.java.awt.Point( loc.X, loc.Y );
}
public void setLocation( int x, int y )
{
base.Location = new System.Drawing.Point( x, y );
}
public void setLocation( bocoree.java.awt.Point p )
{
base.Location = new System.Drawing.Point( p.x, p.y );
}
#endif
public bocoree.java.awt.Rectangle getBounds() {
System.Drawing.Rectangle r = base.Bounds;
return new bocoree.java.awt.Rectangle( r.X, r.Y, r.Width, r.Height );
}
#if COMPONENT_ENABLE_X
public int getX()
{
return base.Left;
}
#endif
#if COMPONENT_ENABLE_Y
public int getY()
{
return base.Top;
}
#endif
public int getWidth() {
return base.Width;
}
public int getHeight() {
return base.Height;
}
public bocoree.java.awt.Dimension getSize() {
return new bocoree.java.awt.Dimension( base.Size.Width, base.Size.Height );
}
public void setSize( int width, int height ) {
base.Size = new System.Drawing.Size( width, height );
}
public void setSize( bocoree.java.awt.Dimension d ) {
setSize( d.width, d.height );
}
public void setBackground( bocoree.java.awt.Color color ) {
base.BackColor = System.Drawing.Color.FromArgb( color.getRed(), color.getGreen(), color.getBlue() );
}
public bocoree.java.awt.Color getBackground() {
return new bocoree.java.awt.Color( base.BackColor.R, base.BackColor.G, base.BackColor.B );
}
public void setForeground( bocoree.java.awt.Color color ) {
base.ForeColor = color.color;
}
public bocoree.java.awt.Color getForeground() {
return new bocoree.java.awt.Color( base.ForeColor.R, base.ForeColor.G, base.ForeColor.B );
}
public void setFont( bocoree.java.awt.Font font ) {
base.Font = font.font;
}
public bool getEnabled() {
return base.Enabled;
}
public void setEnabled( bool value ) {
base.Enabled = value;
}
#endregion
#region javax.swing.MenuElement
public MenuElement[] getSubElements() {
List<MenuElement> list = new List<MenuElement>();
foreach ( ToolStripItem item in base.DropDownItems ) {
if ( item is MenuElement ) {
list.Add( (MenuElement)item );
}
}
return list.ToArray();
}
#endregion
public bool isCheckOnClick() {
return base.CheckOnClick;
}
public void setCheckOnClick( bool value ) {
base.CheckOnClick = value;
}
public KeyStroke getAccelerator() {
KeyStroke ret = KeyStroke.getKeyStroke( 0, 0 );
ret.keys = base.ShortcutKeys;
return ret;
}
public void setAccelerator( KeyStroke stroke ) {
base.ShortcutKeys = stroke.keys;
}
public void add( ToolStripItem item ) {
base.DropDownItems.Add( item );
}
public void addSeparator() {
base.DropDownItems.Add( new ToolStripSeparator() );
}
public void removeAll() {
base.DropDownItems.Clear();
}
public void setTag( object value ) {
base.Tag = value;
}
public object getTag() {
return base.Tag;
}
}
}
#endif

155
bocoree/BMenuBar.cs Normal file
View File

@@ -0,0 +1,155 @@
/*
* BMenuBar.cs
* Copyright (c) 2009 kbinani
*
* This file is part of bocoree.
*
* bocoree is free software; you can redistribute it and/or
* modify it under the terms of the BSD License.
*
* bocoree is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
#if JAVA
//INCLUDE ..\BuildJavaUI\src\org\kbinani\windows\forms\BMenuBar.java
#else
using System;
using System.Collections.Generic;
using System.Windows.Forms;
namespace bocoree.windows.forms {
public interface MenuElement {
MenuElement[] getSubElements();
String getName();
String getText();
void setAccelerator( bocoree.javax.swing.KeyStroke stroke );
bocoree.javax.swing.KeyStroke getAccelerator();
object getParent();
}
public class BMenuBar : System.Windows.Forms.MenuStrip, MenuElement {
// root implementation of javax.swing.MenuElement
#region javax.swing.MenuElement
public MenuElement[] getSubElements() {
List<MenuElement> list = new List<MenuElement>();
foreach ( ToolStripMenuItem item in base.Items ) {
if ( item is MenuElement ) {
list.Add( (MenuElement)item );
}
}
return list.ToArray();
}
#endregion
#region javax.swing.AbstractButton
public string getText() {
return base.Text;
}
public void setText( string value ) {
base.Text = value;
}
#if ABSTRACT_BUTTON_ENABLE_IS_SELECTED
public bool isSelected() {
return base.Checked;
}
public void setSelected( bool value ) {
base.Checked = true;
}
#endif
#endregion
#region java.awt.Component
public object getParent() {
return base.Parent;
}
public string getName() {
return base.Name;
}
public void setName( string value ) {
base.Name = value;
}
#if COMPONENT_ENABLE_LOCATION
public bocoree.java.awt.Point getLocation() {
System.Drawing.Point loc = this.Location;
return new bocoree.java.awt.Point( loc.X, loc.Y );
}
public void setLocation( int x, int y ) {
base.Location = new System.Drawing.Point( x, y );
}
public void setLocation( bocoree.java.awt.Point p ) {
base.Location = new System.Drawing.Point( p.x, p.y );
}
#endif
public bocoree.java.awt.Rectangle getBounds() {
System.Drawing.Rectangle r = base.Bounds;
return new bocoree.java.awt.Rectangle( r.X, r.Y, r.Width, r.Height );
}
#if COMPONENT_ENABLE_X
public int getX() {
return base.Left;
}
#endif
#if COMPONENT_ENABLE_Y
public int getY() {
return base.Top;
}
#endif
public int getWidth() {
return base.Width;
}
public int getHeight() {
return base.Height;
}
public bocoree.java.awt.Dimension getSize() {
return new bocoree.java.awt.Dimension( base.Size.Width, base.Size.Height );
}
public void setSize( int width, int height ) {
base.Size = new System.Drawing.Size( width, height );
}
public void setSize( bocoree.java.awt.Dimension d ) {
setSize( d.width, d.height );
}
public void setBackground( bocoree.java.awt.Color color ) {
base.BackColor = System.Drawing.Color.FromArgb( color.getRed(), color.getGreen(), color.getBlue() );
}
public void setFont( bocoree.java.awt.Font font ) {
base.Font = font.font;
}
public bool getEnabled() {
return base.Enabled;
}
public void setEnabled( bool value ) {
base.Enabled = value;
}
#endregion
public void setAccelerator( bocoree.javax.swing.KeyStroke stroke ) {
}
public bocoree.javax.swing.KeyStroke getAccelerator() {
return null;
}
}
}
#endif

234
bocoree/BMenuItem.cs Normal file
View File

@@ -0,0 +1,234 @@
/*
* BMenuItem.cs
* Copyright (c) 2009 kbinani
*
* This file is part of bocoree.
*
* bocoree is free software; you can redistribute it and/or
* modify it under the terms of the BSD License.
*
* bocoree is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
#if JAVA
//INCLUDE ..\BuildJavaUI\src\org\kbinani\windows\forms\BMenuItem.java
#else
#define ABSTRACT_BUTTON_ENABLE_IS_SELECTED
#define COMPONENT_PARENT_AS_OWNERITEM
#define COMPONENT_ENABLE_TOOL_TIP_TEXT
using System.Collections.Generic;
using System.Windows.Forms;
using bocoree.javax.swing;
namespace bocoree.windows.forms {
public class BMenuItem : System.Windows.Forms.ToolStripMenuItem, MenuElement {
// root implementation of javax.swing.AbstractButton
#region javax.swing.AbstractButton
// root implementation of javax.swing.AbstractButton is in BMenuItem.cs
public string getText() {
return base.Text;
}
public void setText( string value ) {
base.Text = value;
}
#if ABSTRACT_BUTTON_ENABLE_IS_SELECTED
public bool isSelected() {
return base.Checked;
}
public void setSelected( bool value ) {
base.Checked = value;
}
#endif
public bocoree.java.awt.Icon getIcon() {
bocoree.java.awt.Icon ret = new bocoree.java.awt.Icon();
ret.image = base.Image;
return ret;
}
public void setIcon( bocoree.java.awt.Icon value ) {
if ( value == null ) {
base.Image = null;
} else {
base.Image = value.image;
}
}
#endregion
#region java.awt.Component
public bool isVisible() {
return base.Visible;
}
public void setVisible( bool value ) {
base.Visible = value;
}
#if COMPONENT_ENABLE_TOOL_TIP_TEXT
public void setToolTipText( string value ) {
base.ToolTipText = value;
}
public string getToolTipText() {
return base.ToolTipText;
}
#endif
#if COMPONENT_PARENT_AS_OWNERITEM
public object getParent() {
return base.OwnerItem;
}
#else
public object getParent(){
return base.Parent;
}
#endif
public string getName() {
return base.Name;
}
public void setName( string value ) {
base.Name = value;
}
#if COMPONENT_ENABLE_LOCATION
public bocoree.java.awt.Point getLocation()
{
System.Drawing.Point loc = this.Location;
return new bocoree.java.awt.Point( loc.X, loc.Y );
}
public void setLocation( int x, int y )
{
base.Location = new System.Drawing.Point( x, y );
}
public void setLocation( bocoree.java.awt.Point p )
{
base.Location = new System.Drawing.Point( p.x, p.y );
}
#endif
public bocoree.java.awt.Rectangle getBounds() {
System.Drawing.Rectangle r = base.Bounds;
return new bocoree.java.awt.Rectangle( r.X, r.Y, r.Width, r.Height );
}
#if COMPONENT_ENABLE_X
public int getX()
{
return base.Left;
}
#endif
#if COMPONENT_ENABLE_Y
public int getY()
{
return base.Top;
}
#endif
public int getWidth() {
return base.Width;
}
public int getHeight() {
return base.Height;
}
public bocoree.java.awt.Dimension getSize() {
return new bocoree.java.awt.Dimension( base.Size.Width, base.Size.Height );
}
public void setSize( int width, int height ) {
base.Size = new System.Drawing.Size( width, height );
}
public void setSize( bocoree.java.awt.Dimension d ) {
setSize( d.width, d.height );
}
public void setBackground( bocoree.java.awt.Color color ) {
base.BackColor = System.Drawing.Color.FromArgb( color.getRed(), color.getGreen(), color.getBlue() );
}
public bocoree.java.awt.Color getBackground() {
return new bocoree.java.awt.Color( base.BackColor.R, base.BackColor.G, base.BackColor.B );
}
public void setForeground( bocoree.java.awt.Color color ) {
base.ForeColor = color.color;
}
public bocoree.java.awt.Color getForeground() {
return new bocoree.java.awt.Color( base.ForeColor.R, base.ForeColor.G, base.ForeColor.B );
}
public void setFont( bocoree.java.awt.Font font ) {
base.Font = font.font;
}
public bool getEnabled() {
return base.Enabled;
}
public void setEnabled( bool value ) {
base.Enabled = value;
}
#endregion
#region javax.swing.MenuElement
public MenuElement[] getSubElements() {
List<MenuElement> list = new List<MenuElement>();
foreach ( ToolStripItem item in base.DropDownItems ) {
if ( item is MenuElement ) {
list.Add( (MenuElement)item );
}
}
return list.ToArray();
}
#endregion
public bool isCheckOnClick() {
return base.CheckOnClick;
}
public void setCheckOnClick( bool value ) {
base.CheckOnClick = value;
}
public KeyStroke getAccelerator() {
KeyStroke ret = KeyStroke.getKeyStroke( 0, 0 );
ret.keys = base.ShortcutKeys;
return ret;
}
public void setAccelerator( KeyStroke stroke ) {
base.ShortcutKeys = stroke.keys;
}
public void add( ToolStripItem item ) {
base.DropDownItems.Add( item );
}
public void addSeparator() {
base.DropDownItems.Add( new ToolStripSeparator() );
}
public void removeAll() {
base.DropDownItems.Clear();
}
public void setTag( object value ) {
base.Tag = value;
}
public object getTag() {
return base.Tag;
}
}
}
#endif

237
bocoree/BMenuSeparator.cs Normal file
View File

@@ -0,0 +1,237 @@
/*
* BMenuSeparator.cs
* Copyright (c) 2009 kbinani
*
* This file is part of bocoree.
*
* bocoree is free software; you can redistribute it and/or
* modify it under the terms of the BSD License.
*
* bocoree is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
#if JAVA
//INCLUDE ..\BuildJavaUI\src\org\kbinani\windows\forms\BMenuSeparator.java
#else
using System;
using System.Windows.Forms;
namespace bocoree.windows.forms{
public class BMenuSeparator : ToolStripSeparator {
#region java.awt.Component
// root implementation of java.awt.Component is in BForm.cs
public void invalidate() {
base.Invalidate();
}
#if COMPONENT_ENABLE_REPAINT
public void repaint() {
base.Refresh();
}
#endif
#if COMPONENT_ENABLE_CURSOR
public bocoree.java.awt.Cursor getCursor() {
System.Windows.Forms.Cursor c = base.Cursor;
bocoree.java.awt.Cursor ret = null;
if( c.Equals( System.Windows.Forms.Cursors.Arrow ) ){
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.DEFAULT_CURSOR );
} else if ( c.Equals( System.Windows.Forms.Cursors.Cross ) ){
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.CROSSHAIR_CURSOR );
} else if ( c.Equals( System.Windows.Forms.Cursors.Default ) ){
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.DEFAULT_CURSOR );
} else if ( c.Equals( System.Windows.Forms.Cursors.Hand ) ){
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.HAND_CURSOR );
} else if ( c.Equals( System.Windows.Forms.Cursors.IBeam ) ) {
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.TEXT_CURSOR );
} else if ( c.Equals( System.Windows.Forms.Cursors.PanEast ) ) {
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.E_RESIZE_CURSOR );
} else if ( c.Equals( System.Windows.Forms.Cursors.PanNE ) ) {
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.NE_RESIZE_CURSOR );
} else if ( c.Equals( System.Windows.Forms.Cursors.PanNorth ) ) {
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.N_RESIZE_CURSOR );
} else if ( c.Equals( System.Windows.Forms.Cursors.PanNW ) ) {
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.NW_RESIZE_CURSOR );
} else if ( c.Equals( System.Windows.Forms.Cursors.PanSE ) ) {
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.SE_RESIZE_CURSOR );
} else if ( c.Equals( System.Windows.Forms.Cursors.PanSouth ) ) {
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.S_RESIZE_CURSOR );
} else if ( c.Equals( System.Windows.Forms.Cursors.PanSW ) ) {
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.SW_RESIZE_CURSOR );
} else if ( c.Equals( System.Windows.Forms.Cursors.PanWest ) ) {
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.W_RESIZE_CURSOR );
} else if ( c.Equals( System.Windows.Forms.Cursors.SizeAll ) ) {
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.MOVE_CURSOR );
} else {
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.CUSTOM_CURSOR );
}
ret.cursor = c;
return ret;
}
public void setCursor( bocoree.java.awt.Cursor value ) {
base.Cursor = value.cursor;
}
#endif
public bool isVisible() {
return base.Visible;
}
public void setVisible( bool value ) {
base.Visible = value;
}
#if COMPONENT_ENABLE_TOOL_TIP_TEXT
public void setToolTipText( string value )
{
base.ToolTipText = value;
}
public String getToolTipText()
{
return base.ToolTipText;
}
#endif
#if COMPONENT_PARENT_AS_OWNERITEM
public Object getParent() {
return base.OwnerItem;
}
#else
public object getParent() {
return base.Parent;
}
#endif
public string getName() {
return base.Name;
}
public void setName( string value ) {
base.Name = value;
}
#if COMPONENT_ENABLE_LOCATION
public void setBounds( int x, int y, int width, int height ) {
base.Bounds = new System.Drawing.Rectangle( x, y, width, height );
}
public void setBounds( bocoree.java.awt.Rectangle rc ) {
base.Bounds = new System.Drawing.Rectangle( rc.x, rc.y, rc.width, rc.height );
}
public bocoree.java.awt.Point getLocationOnScreen() {
System.Drawing.Point p = base.PointToScreen( base.Location );
return new bocoree.java.awt.Point( p.X, p.Y );
}
public bocoree.java.awt.Point getLocation() {
System.Drawing.Point loc = this.Location;
return new bocoree.java.awt.Point( loc.X, loc.Y );
}
public void setLocation( int x, int y ) {
base.Location = new System.Drawing.Point( x, y );
}
public void setLocation( bocoree.java.awt.Point p ) {
base.Location = new System.Drawing.Point( p.x, p.y );
}
#endif
public bocoree.java.awt.Rectangle getBounds() {
System.Drawing.Rectangle r = base.Bounds;
return new bocoree.java.awt.Rectangle( r.X, r.Y, r.Width, r.Height );
}
#if COMPONENT_ENABLE_X
public int getX() {
return base.Left;
}
#endif
#if COMPONENT_ENABLE_Y
public int getY() {
return base.Top;
}
#endif
public int getWidth() {
return base.Width;
}
public int getHeight() {
return base.Height;
}
public bocoree.java.awt.Dimension getSize() {
return new bocoree.java.awt.Dimension( base.Size.Width, base.Size.Height );
}
public void setSize( int width, int height ) {
base.Size = new System.Drawing.Size( width, height );
}
public void setSize( bocoree.java.awt.Dimension d ) {
setSize( d.width, d.height );
}
public void setBackground( bocoree.java.awt.Color color ) {
base.BackColor = System.Drawing.Color.FromArgb( color.getRed(), color.getGreen(), color.getBlue() );
}
public bocoree.java.awt.Color getBackground() {
return new bocoree.java.awt.Color( base.BackColor.R, base.BackColor.G, base.BackColor.B );
}
public void setForeground( bocoree.java.awt.Color color ) {
base.ForeColor = color.color;
}
public bocoree.java.awt.Color getForeground() {
return new bocoree.java.awt.Color( base.ForeColor.R, base.ForeColor.G, base.ForeColor.B );
}
public bool isEnabled() {
return base.Enabled;
}
public void setEnabled( bool value ) {
base.Enabled = value;
}
#if COMPONENT_ENABLE_FOCUS
public void requestFocus() {
base.Focus();
}
public bool isFocusOwner() {
return base.Focused;
}
#endif
public void setPreferredSize( bocoree.java.awt.Dimension size ) {
base.Size = new System.Drawing.Size( size.width, size.height );
}
public bocoree.java.awt.Font getFont() {
return new bocoree.java.awt.Font( base.Font );
}
public void setFont( bocoree.java.awt.Font font ) {
if ( font == null ) {
return;
}
if ( font.font == null ) {
return;
}
base.Font = font.font;
}
#endregion
}
}
#endif

16
bocoree/BMouseButtons.cs Normal file
View File

@@ -0,0 +1,16 @@
/*
* BMouseButtons.cs
* Copyright (c) 2009 kbinani
*
* This file is part of bocoree.
*
* bocoree is free software; you can redistribute it and/or
* modify it under the terms of the BSD License.
*
* bocoree is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
#if JAVA
//INCLUDE ..\BuildJavaUI\src\org\kbinani\windows\forms\BMouseButtons.java
#endif

View File

@@ -0,0 +1,16 @@
/*
* BMouseEventArgs.cs
* Copyright (c) 2009 kbinani
*
* This file is part of bocoree.
*
* bocoree is free software; you can redistribute it and/or
* modify it under the terms of the BSD License.
*
* bocoree is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
#if JAVA
//INCLUDE ..\BuildJavaUI\src\org\kbinani\windows\forms\BMouseEventArgs.java
#endif

View File

@@ -0,0 +1,16 @@
/*
* BMouseEventHandler.cs
* Copyright (c) 2009 kbinani
*
* This file is part of bocoree.
*
* bocoree is free software; you can redistribute it and/or
* modify it under the terms of the BSD License.
*
* bocoree is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
#if JAVA
//INCLUDE ..\BuildJavaUI\src\org\kbinani\windows\forms\BMouseEventhandler.java
#endif

269
bocoree/BNumericUpDown.cs Normal file
View File

@@ -0,0 +1,269 @@
/*
* BNumericUpDown.cs
* Copyright (c) 2009 kbinani
*
* This file is part of bocoree.
*
* bocoree is free software; you can redistribute it and/or
* modify it under the terms of the BSD License.
*
* bocoree is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
#if JAVA
//INCLUDE ..\BuildJavaUI\src\org\kbinani\windows\forms\BNumericUpDown.java
#else
#define COMPONENT_ENABLE_FOCUS
#define COMPONENT_ENABLE_REPAINT
namespace bocoree.windows.forms {
public class BNumericUpDown : System.Windows.Forms.NumericUpDown {
public int getIncrement() {
return (int)base.Increment;
}
public void setIncrement( int value ) {
base.Increment = value;
}
public int getValue() {
return (int)base.Value;
}
public void setValue( int value ) {
base.Value = value;
}
public int getMaximum() {
return (int)base.Maximum;
}
public void setMaximum( int value ) {
base.Maximum = value;
}
public int getMinimum() {
return (int)base.Minimum;
}
public void setMinimum( int value ) {
base.Minimum = value;
}
#region java.awt.Component
// root implementation of java.awt.Component is in BForm.cs
public void invalidate() {
base.Invalidate();
}
#if COMPONENT_ENABLE_REPAINT
public void repaint() {
base.Refresh();
}
#endif
#if COMPONENT_ENABLE_CURSOR
public bocoree.java.awt.Cursor getCursor() {
System.Windows.Forms.Cursor c = base.Cursor;
bocoree.java.awt.Cursor ret = null;
if( c.Equals( System.Windows.Forms.Cursors.Arrow ) ){
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.DEFAULT_CURSOR );
} else if ( c.Equals( System.Windows.Forms.Cursors.Cross ) ){
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.CROSSHAIR_CURSOR );
} else if ( c.Equals( System.Windows.Forms.Cursors.Default ) ){
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.DEFAULT_CURSOR );
} else if ( c.Equals( System.Windows.Forms.Cursors.Hand ) ){
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.HAND_CURSOR );
} else if ( c.Equals( System.Windows.Forms.Cursors.IBeam ) ) {
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.TEXT_CURSOR );
} else if ( c.Equals( System.Windows.Forms.Cursors.PanEast ) ) {
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.E_RESIZE_CURSOR );
} else if ( c.Equals( System.Windows.Forms.Cursors.PanNE ) ) {
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.NE_RESIZE_CURSOR );
} else if ( c.Equals( System.Windows.Forms.Cursors.PanNorth ) ) {
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.N_RESIZE_CURSOR );
} else if ( c.Equals( System.Windows.Forms.Cursors.PanNW ) ) {
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.NW_RESIZE_CURSOR );
} else if ( c.Equals( System.Windows.Forms.Cursors.PanSE ) ) {
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.SE_RESIZE_CURSOR );
} else if ( c.Equals( System.Windows.Forms.Cursors.PanSouth ) ) {
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.S_RESIZE_CURSOR );
} else if ( c.Equals( System.Windows.Forms.Cursors.PanSW ) ) {
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.SW_RESIZE_CURSOR );
} else if ( c.Equals( System.Windows.Forms.Cursors.PanWest ) ) {
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.W_RESIZE_CURSOR );
} else if ( c.Equals( System.Windows.Forms.Cursors.SizeAll ) ) {
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.MOVE_CURSOR );
} else {
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.CUSTOM_CURSOR );
}
ret.cursor = c;
return ret;
}
public void setCursor( bocoree.java.awt.Cursor value ) {
base.Cursor = value.cursor;
}
#endif
public bool isVisible() {
return base.Visible;
}
public void setVisible( bool value ) {
base.Visible = value;
}
#if COMPONENT_ENABLE_TOOL_TIP_TEXT
public void setToolTipText( string value )
{
base.ToolTipText = value;
}
public String getToolTipText()
{
return base.ToolTipText;
}
#endif
#if COMPONENT_PARENT_AS_OWNERITEM
public Object getParent() {
return base.OwnerItem;
}
#else
public object getParent() {
return base.Parent;
}
#endif
public string getName() {
return base.Name;
}
public void setName( string value ) {
base.Name = value;
}
#if COMPONENT_ENABLE_LOCATION
public void setBounds( int x, int y, int width, int height ) {
base.Bounds = new System.Drawing.Rectangle( x, y, width, height );
}
public void setBounds( bocoree.java.awt.Rectangle rc ) {
base.Bounds = new System.Drawing.Rectangle( rc.x, rc.y, rc.width, rc.height );
}
public bocoree.java.awt.Point getLocationOnScreen() {
System.Drawing.Point p = base.PointToScreen( base.Location );
return new bocoree.java.awt.Point( p.X, p.Y );
}
public bocoree.java.awt.Point getLocation() {
System.Drawing.Point loc = this.Location;
return new bocoree.java.awt.Point( loc.X, loc.Y );
}
public void setLocation( int x, int y ) {
base.Location = new System.Drawing.Point( x, y );
}
public void setLocation( bocoree.java.awt.Point p ) {
base.Location = new System.Drawing.Point( p.x, p.y );
}
#endif
public bocoree.java.awt.Rectangle getBounds() {
System.Drawing.Rectangle r = base.Bounds;
return new bocoree.java.awt.Rectangle( r.X, r.Y, r.Width, r.Height );
}
#if COMPONENT_ENABLE_X
public int getX() {
return base.Left;
}
#endif
#if COMPONENT_ENABLE_Y
public int getY() {
return base.Top;
}
#endif
public int getWidth() {
return base.Width;
}
public int getHeight() {
return base.Height;
}
public bocoree.java.awt.Dimension getSize() {
return new bocoree.java.awt.Dimension( base.Size.Width, base.Size.Height );
}
public void setSize( int width, int height ) {
base.Size = new System.Drawing.Size( width, height );
}
public void setSize( bocoree.java.awt.Dimension d ) {
setSize( d.width, d.height );
}
public void setBackground( bocoree.java.awt.Color color ) {
base.BackColor = System.Drawing.Color.FromArgb( color.getRed(), color.getGreen(), color.getBlue() );
}
public bocoree.java.awt.Color getBackground() {
return new bocoree.java.awt.Color( base.BackColor.R, base.BackColor.G, base.BackColor.B );
}
public void setForeground( bocoree.java.awt.Color color ) {
base.ForeColor = color.color;
}
public bocoree.java.awt.Color getForeground() {
return new bocoree.java.awt.Color( base.ForeColor.R, base.ForeColor.G, base.ForeColor.B );
}
public bool isEnabled() {
return base.Enabled;
}
public void setEnabled( bool value ) {
base.Enabled = value;
}
#if COMPONENT_ENABLE_FOCUS
public void requestFocus() {
base.Focus();
}
public bool isFocusOwner() {
return base.Focused;
}
#endif
public void setPreferredSize( bocoree.java.awt.Dimension size ) {
base.Size = new System.Drawing.Size( size.width, size.height );
}
public bocoree.java.awt.Font getFont() {
return new bocoree.java.awt.Font( base.Font );
}
public void setFont( bocoree.java.awt.Font font ) {
if ( font == null ) {
return;
}
if ( font.font == null ) {
return;
}
base.Font = font.font;
}
#endregion
}
}
#endif

View File

@@ -0,0 +1,16 @@
/*
* BPaintEventArgs.cs
* Copyright (c) 2009 kbinani
*
* This file is part of bocoree.
*
* bocoree is free software; you can redistribute it and/or
* modify it under the terms of the BSD License.
*
* bocoree is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
#if JAVA
//INCLUDE ..\BuildJavaUI\src\org\kbinani\windows\forms\BPaintEventArgs.java
#endif

232
bocoree/BPanel.cs Normal file
View File

@@ -0,0 +1,232 @@
/*
* BPanel.cs
* Copyright (c) 2009 kbinani
*
* This file is part of bocoree.
*
* bocoree is free software; you can redistribute it and/or
* modify it under the terms of the BSD License.
*
* bocoree is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
#if JAVA
//INCLUDE ..\BuildJavaUI\src\org\kbinani\windows\forms\BPanel.java
#else
namespace bocoree.windows.forms {
public class BPanel : System.Windows.Forms.UserControl {
#region java.awt.Component
// root implementation of java.awt.Component is in BForm.cs
public void invalidate() {
base.Invalidate();
}
#if COMPONENT_ENABLE_REPAINT
public void repaint() {
base.Refresh();
}
#endif
#if COMPONENT_ENABLE_CURSOR
public bocoree.java.awt.Cursor getCursor() {
System.Windows.Forms.Cursor c = base.Cursor;
bocoree.java.awt.Cursor ret = null;
if( c.Equals( System.Windows.Forms.Cursors.Arrow ) ){
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.DEFAULT_CURSOR );
} else if ( c.Equals( System.Windows.Forms.Cursors.Cross ) ){
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.CROSSHAIR_CURSOR );
} else if ( c.Equals( System.Windows.Forms.Cursors.Default ) ){
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.DEFAULT_CURSOR );
} else if ( c.Equals( System.Windows.Forms.Cursors.Hand ) ){
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.HAND_CURSOR );
} else if ( c.Equals( System.Windows.Forms.Cursors.IBeam ) ) {
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.TEXT_CURSOR );
} else if ( c.Equals( System.Windows.Forms.Cursors.PanEast ) ) {
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.E_RESIZE_CURSOR );
} else if ( c.Equals( System.Windows.Forms.Cursors.PanNE ) ) {
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.NE_RESIZE_CURSOR );
} else if ( c.Equals( System.Windows.Forms.Cursors.PanNorth ) ) {
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.N_RESIZE_CURSOR );
} else if ( c.Equals( System.Windows.Forms.Cursors.PanNW ) ) {
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.NW_RESIZE_CURSOR );
} else if ( c.Equals( System.Windows.Forms.Cursors.PanSE ) ) {
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.SE_RESIZE_CURSOR );
} else if ( c.Equals( System.Windows.Forms.Cursors.PanSouth ) ) {
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.S_RESIZE_CURSOR );
} else if ( c.Equals( System.Windows.Forms.Cursors.PanSW ) ) {
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.SW_RESIZE_CURSOR );
} else if ( c.Equals( System.Windows.Forms.Cursors.PanWest ) ) {
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.W_RESIZE_CURSOR );
} else if ( c.Equals( System.Windows.Forms.Cursors.SizeAll ) ) {
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.MOVE_CURSOR );
} else {
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.CUSTOM_CURSOR );
}
ret.cursor = c;
return ret;
}
public void setCursor( bocoree.java.awt.Cursor value ) {
base.Cursor = value.cursor;
}
#endif
public bool isVisible() {
return base.Visible;
}
public void setVisible( bool value ) {
base.Visible = value;
}
#if COMPONENT_ENABLE_TOOL_TIP_TEXT
public void setToolTipText( string value )
{
base.ToolTipText = value;
}
public String getToolTipText()
{
return base.ToolTipText;
}
#endif
#if COMPONENT_PARENT_AS_OWNERITEM
public Object getParent() {
return base.OwnerItem;
}
#else
public object getParent() {
return base.Parent;
}
#endif
public string getName() {
return base.Name;
}
public void setName( string value ) {
base.Name = value;
}
#if COMPONENT_ENABLE_LOCATION
public void setBounds( int x, int y, int width, int height ) {
base.Bounds = new System.Drawing.Rectangle( x, y, width, height );
}
public void setBounds( bocoree.java.awt.Rectangle rc ) {
base.Bounds = new System.Drawing.Rectangle( rc.x, rc.y, rc.width, rc.height );
}
public bocoree.java.awt.Point getLocationOnScreen() {
System.Drawing.Point p = base.PointToScreen( base.Location );
return new bocoree.java.awt.Point( p.X, p.Y );
}
public bocoree.java.awt.Point getLocation() {
System.Drawing.Point loc = this.Location;
return new bocoree.java.awt.Point( loc.X, loc.Y );
}
public void setLocation( int x, int y ) {
base.Location = new System.Drawing.Point( x, y );
}
public void setLocation( bocoree.java.awt.Point p ) {
base.Location = new System.Drawing.Point( p.x, p.y );
}
#endif
public bocoree.java.awt.Rectangle getBounds() {
System.Drawing.Rectangle r = base.Bounds;
return new bocoree.java.awt.Rectangle( r.X, r.Y, r.Width, r.Height );
}
#if COMPONENT_ENABLE_X
public int getX() {
return base.Left;
}
#endif
#if COMPONENT_ENABLE_Y
public int getY() {
return base.Top;
}
#endif
public int getWidth() {
return base.Width;
}
public int getHeight() {
return base.Height;
}
public bocoree.java.awt.Dimension getSize() {
return new bocoree.java.awt.Dimension( base.Size.Width, base.Size.Height );
}
public void setSize( int width, int height ) {
base.Size = new System.Drawing.Size( width, height );
}
public void setSize( bocoree.java.awt.Dimension d ) {
setSize( d.width, d.height );
}
public void setBackground( bocoree.java.awt.Color color ) {
base.BackColor = System.Drawing.Color.FromArgb( color.getRed(), color.getGreen(), color.getBlue() );
}
public bocoree.java.awt.Color getBackground() {
return new bocoree.java.awt.Color( base.BackColor.R, base.BackColor.G, base.BackColor.B );
}
public void setForeground( bocoree.java.awt.Color color ) {
base.ForeColor = color.color;
}
public bocoree.java.awt.Color getForeground() {
return new bocoree.java.awt.Color( base.ForeColor.R, base.ForeColor.G, base.ForeColor.B );
}
public bool isEnabled() {
return base.Enabled;
}
public void setEnabled( bool value ) {
base.Enabled = value;
}
#if COMPONENT_ENABLE_FOCUS
public void requestFocus() {
base.Focus();
}
public bool isFocusOwner() {
return base.Focused;
}
#endif
public void setPreferredSize( bocoree.java.awt.Dimension size ) {
base.Size = new System.Drawing.Size( size.width, size.height );
}
public bocoree.java.awt.Font getFont() {
return new bocoree.java.awt.Font( base.Font );
}
public void setFont( bocoree.java.awt.Font font ) {
if ( font == null ) {
return;
}
if ( font.font == null ) {
return;
}
base.Font = font.font;
}
#endregion
}
}
#endif

273
bocoree/BPictureBox.cs Normal file
View File

@@ -0,0 +1,273 @@
/*
* BPictureBox.cs
* Copyright (c) 2009 kbinani
*
* This file is part of Boare.Cadencii.
*
* Boare.Cadencii is free software; you can redistribute it and/or
* modify it under the terms of the GPLv3 License.
*
* Boare.Cadencii is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
#if JAVA
//INCLUDE ..\BuildJavaUI\src\org\kbinani\windows\forms\BPictureBox.java
#else
using System.Windows.Forms;
namespace bocoree.windows.forms {
/// <summary>
/// KeyDownとKeyUpを受信できるPictureBox
/// </summary>
public class BPictureBox : PictureBox {
public event KeyEventHandler BKeyDown;
public event KeyEventHandler BKeyUp;
protected override void OnKeyDown( KeyEventArgs e ) {
if ( BKeyDown != null ) {
BKeyDown( this, e );
}
}
protected override void OnKeyUp( KeyEventArgs e ) {
if ( BKeyUp != null ) {
BKeyUp( this, e );
}
}
protected override void OnMouseDown( MouseEventArgs e ) {
base.OnMouseDown( e );
this.Focus();
}
public void setImage( bocoree.java.awt.Image value ) {
if ( value != null ) {
if ( value.image != null ) {
base.Image = value.image;
}
} else {
base.Image = null;
}
}
public bocoree.java.awt.Image getImage() {
if ( base.Image == null ) {
return null;
} else {
bocoree.java.awt.Image ret = new bocoree.java.awt.Image();
ret.image = base.Image;
return ret;
}
}
#region java.awt.Component
// root implementation of java.awt.Component is in BForm.cs
public void invalidate() {
base.Invalidate();
}
public void repaint() {
base.Refresh();
}
public void setBounds( int x, int y, int width, int height ) {
base.Bounds = new System.Drawing.Rectangle( x, y, width, height );
}
public void setBounds( bocoree.java.awt.Rectangle rc ) {
base.Bounds = new System.Drawing.Rectangle( rc.x, rc.y, rc.width, rc.height );
}
public bocoree.java.awt.Cursor getCursor() {
System.Windows.Forms.Cursor c = base.Cursor;
bocoree.java.awt.Cursor ret = null;
if ( c.Equals( System.Windows.Forms.Cursors.Arrow ) ) {
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.DEFAULT_CURSOR );
} else if ( c.Equals( System.Windows.Forms.Cursors.Cross ) ) {
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.CROSSHAIR_CURSOR );
} else if ( c.Equals( System.Windows.Forms.Cursors.Default ) ) {
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.DEFAULT_CURSOR );
} else if ( c.Equals( System.Windows.Forms.Cursors.Hand ) ) {
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.HAND_CURSOR );
} else if ( c.Equals( System.Windows.Forms.Cursors.IBeam ) ) {
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.TEXT_CURSOR );
} else if ( c.Equals( System.Windows.Forms.Cursors.PanEast ) ) {
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.E_RESIZE_CURSOR );
} else if ( c.Equals( System.Windows.Forms.Cursors.PanNE ) ) {
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.NE_RESIZE_CURSOR );
} else if ( c.Equals( System.Windows.Forms.Cursors.PanNorth ) ) {
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.N_RESIZE_CURSOR );
} else if ( c.Equals( System.Windows.Forms.Cursors.PanNW ) ) {
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.NW_RESIZE_CURSOR );
} else if ( c.Equals( System.Windows.Forms.Cursors.PanSE ) ) {
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.SE_RESIZE_CURSOR );
} else if ( c.Equals( System.Windows.Forms.Cursors.PanSouth ) ) {
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.S_RESIZE_CURSOR );
} else if ( c.Equals( System.Windows.Forms.Cursors.PanSW ) ) {
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.SW_RESIZE_CURSOR );
} else if ( c.Equals( System.Windows.Forms.Cursors.PanWest ) ) {
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.W_RESIZE_CURSOR );
} else if ( c.Equals( System.Windows.Forms.Cursors.SizeAll ) ) {
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.MOVE_CURSOR );
} else {
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.CUSTOM_CURSOR );
}
ret.cursor = c;
return ret;
}
public void setCursor( bocoree.java.awt.Cursor value ) {
base.Cursor = value.cursor;
}
public bool isVisible() {
return base.Visible;
}
public void setVisible( bool value ) {
base.Visible = value;
}
#if COMPONENT_ENABLE_TOOL_TIP_TEXT
public void setToolTipText( string value )
{
base.ToolTipText = value;
}
public String getToolTipText()
{
return base.ToolTipText;
}
#endif
#if COMPONENT_PARENT_AS_OWNERITEM
public Object getParent() {
return base.OwnerItem;
}
#else
public object getParent() {
return base.Parent;
}
#endif
public string getName() {
return base.Name;
}
public void setName( string value ) {
base.Name = value;
}
#if COMPONENT_ENABLE_LOCATION
public bocoree.java.awt.Point getLocationOnScreen() {
System.Drawing.Point p = base.PointToScreen( base.Location );
return new bocoree.java.awt.Point( p.X, p.Y );
}
public bocoree.java.awt.Point getLocation() {
System.Drawing.Point loc = this.Location;
return new bocoree.java.awt.Point( loc.X, loc.Y );
}
public void setLocation( int x, int y ) {
base.Location = new System.Drawing.Point( x, y );
}
public void setLocation( bocoree.java.awt.Point p ) {
base.Location = new System.Drawing.Point( p.x, p.y );
}
#endif
public bocoree.java.awt.Rectangle getBounds() {
System.Drawing.Rectangle r = base.Bounds;
return new bocoree.java.awt.Rectangle( r.X, r.Y, r.Width, r.Height );
}
#if COMPONENT_ENABLE_X
public int getX() {
return base.Left;
}
#endif
#if COMPONENT_ENABLE_Y
public int getY() {
return base.Top;
}
#endif
public int getWidth() {
return base.Width;
}
public int getHeight() {
return base.Height;
}
public bocoree.java.awt.Dimension getSize() {
return new bocoree.java.awt.Dimension( base.Size.Width, base.Size.Height );
}
public void setSize( int width, int height ) {
base.Size = new System.Drawing.Size( width, height );
}
public void setSize( bocoree.java.awt.Dimension d ) {
setSize( d.width, d.height );
}
public void setBackground( bocoree.java.awt.Color color ) {
base.BackColor = System.Drawing.Color.FromArgb( color.getRed(), color.getGreen(), color.getBlue() );
}
public bocoree.java.awt.Color getBackground() {
return new bocoree.java.awt.Color( base.BackColor.R, base.BackColor.G, base.BackColor.B );
}
public void setForeground( bocoree.java.awt.Color color ) {
base.ForeColor = color.color;
}
public bocoree.java.awt.Color getForeground() {
return new bocoree.java.awt.Color( base.ForeColor.R, base.ForeColor.G, base.ForeColor.B );
}
public bool isEnabled() {
return base.Enabled;
}
public void setEnabled( bool value ) {
base.Enabled = value;
}
public void requestFocus() {
base.Focus();
}
public bool isFocusOwner() {
return base.Focused;
}
public void setPreferredSize( bocoree.java.awt.Dimension size ) {
base.Size = new System.Drawing.Size( size.width, size.height );
}
public bocoree.java.awt.Font getFont() {
return new bocoree.java.awt.Font( base.Font );
}
public void setFont( bocoree.java.awt.Font font ) {
if ( font == null ) {
return;
}
if ( font.font == null ) {
return;
}
base.Font = font.font;
}
#endregion
}
}
#endif

163
bocoree/BPopupMenu.cs Normal file
View File

@@ -0,0 +1,163 @@
/*
* BPopupMenu.cs
* Copyright (c) 2009 kbinani
*
* This file is part of bocoree.
*
* bocoree is free software; you can redistribute it and/or
* modify it under the terms of the BSD License.
*
* bocoree is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
#if JAVA
//INCLUDE ..\BuildJavaUI\src\org\kbinani\windows\forms\BPopupMenu.java
#else
using System;
using System.Collections.Generic;
using System.Windows.Forms;
using bocoree.javax.swing;
namespace bocoree.windows.forms {
public class BPopupMenu : System.Windows.Forms.ContextMenuStrip, MenuElement {
public BPopupMenu( System.ComponentModel.IContainer container )
: base( container ) {
}
public string getText() {
return base.Text;
}
public KeyStroke getAccelerator() {
return KeyStroke.getKeyStroke( 0, 0 );
}
public void setAccelerator( KeyStroke stroke ) {
}
public void show( Control c, int x, int y ) {
base.Show( c, x, y );
}
#region javax.swing.MenuElement
public MenuElement[] getSubElements() {
List<MenuElement> list = new List<MenuElement>();
foreach ( ToolStripItem item in base.Items ) {
if ( item is MenuElement ) {
list.Add( (MenuElement)item );
}
}
return list.ToArray();
}
#endregion
#region java.awt.Component
#if COMPONENT_PARENT_AS_OWNERITEM
public object getParent() {
return base.OwnerItem;
}
#else
public object getParent() {
return base.Parent;
}
#endif
public string getName() {
return base.Name;
}
public void setName( string value ) {
base.Name = value;
}
#if COMPONENT_ENABLE_LOCATION
public bocoree.java.awt.Point getLocation()
{
System.Drawing.Point loc = this.Location;
return new bocoree.java.awt.Point( loc.X, loc.Y );
}
public void setLocation( int x, int y )
{
base.Location = new System.Drawing.Point( x, y );
}
public void setLocation( bocoree.java.awt.Point p )
{
base.Location = new System.Drawing.Point( p.x, p.y );
}
#endif
public bocoree.java.awt.Rectangle getBounds() {
System.Drawing.Rectangle r = base.Bounds;
return new bocoree.java.awt.Rectangle( r.X, r.Y, r.Width, r.Height );
}
#if COMPONENT_ENABLE_X
public int getX()
{
return base.Left;
}
#endif
#if COMPONENT_ENABLE_Y
public int getY()
{
return base.Top;
}
#endif
public int getWidth() {
return base.Width;
}
public int getHeight() {
return base.Height;
}
public bocoree.java.awt.Dimension getSize() {
return new bocoree.java.awt.Dimension( base.Size.Width, base.Size.Height );
}
public void setSize( int width, int height ) {
base.Size = new System.Drawing.Size( width, height );
}
public void setSize( bocoree.java.awt.Dimension d ) {
setSize( d.width, d.height );
}
public void setBackground( bocoree.java.awt.Color color ) {
base.BackColor = System.Drawing.Color.FromArgb( color.getRed(), color.getGreen(), color.getBlue() );
}
public bocoree.java.awt.Color getBackground() {
return new bocoree.java.awt.Color( base.BackColor.R, base.BackColor.G, base.BackColor.B );
}
public void setForeground( bocoree.java.awt.Color color ) {
base.ForeColor = color.color;
}
public bocoree.java.awt.Color getForeground() {
return new bocoree.java.awt.Color( base.ForeColor.R, base.ForeColor.G, base.ForeColor.B );
}
public void setFont( bocoree.java.awt.Font font ) {
base.Font = font.font;
}
public bool getEnabled() {
return base.Enabled;
}
public void setEnabled( bool value ) {
base.Enabled = value;
}
#endregion
}
}
#endif

View File

@@ -0,0 +1,16 @@
/*
* BPreviewKeyDownEventArgs.cs
* Copyright (c) 2009 kbinani
*
* This file is part of bocoree.
*
* bocoree is free software; you can redistribute it and/or
* modify it under the terms of the BSD License.
*
* bocoree is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
#if JAVA
//INCLUDE ..\BuildJavaUI\src\org\kbinani\windows\forms\BPreviewKeyDownEventArgs.java
#endif

46
bocoree/BProgressBar.cs Normal file
View File

@@ -0,0 +1,46 @@
/*
* BProgressBar.cs
* Copyright (c) 2009 kbinani
*
* This file is part of bocoree.
*
* bocoree is free software; you can redistribute it and/or
* modify it under the terms of the BSD License.
*
* bocoree is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
#if JAVA
//INCLUDE ..\BuildJavaUI\src\org\kbinani\windows\forms\BProgressBar.java
#else
namespace bocoree.windows.forms {
public class BProgressBar : System.Windows.Forms.ProgressBar {
public int getMaximum() {
return base.Maximum;
}
public void setMaximum( int value ) {
base.Maximum = value;
}
public int getMinimum() {
return base.Minimum;
}
public void setMinimum( int value ) {
base.Minimum = value;
}
public int getValue() {
return base.Value;
}
public void setValue( int value ) {
base.Value = value;
}
}
}
#endif

View File

@@ -0,0 +1,16 @@
/*
* BProgressChangedEventArgs.cs
* Copyright (c) 2009 kbinani
*
* This file is part of bocoree.
*
* bocoree is free software; you can redistribute it and/or
* modify it under the terms of the BSD License.
*
* bocoree is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
#if JAVA
//INCLUDE ..\BuildJavaUI\src\org\kbinani\componentModel\BProgressChangedEventArgs.java
#endif

View File

@@ -0,0 +1,16 @@
/*
* BProgressChangedEventHandler.cs
* Copyright (c) 2009 kbinani
*
* This file is part of bocoree.
*
* bocoree is free software; you can redistribute it and/or
* modify it under the terms of the BSD License.
*
* bocoree is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
#if JAVA
//INCLUDE ..\BuildJavaUI\src\org\kbinani\componentModel\BProgressChangedEventHandler.java
#endif

View File

@@ -0,0 +1,16 @@
/*
* BRunWorkerCompletedEventArgs.cs
* Copyright (c) 2009 kbinani
*
* This file is part of bocoree.
*
* bocoree is free software; you can redistribute it and/or
* modify it under the terms of the BSD License.
*
* bocoree is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
#if JAVA
//INCLUDE ..\BuildJavaUI\src\org\kbinani\componentModel\BRunWorkerCompletedEventArgs.java
#endif

View File

@@ -0,0 +1,16 @@
/*
* BRunWorkerCompletedEventhandler.cs
* Copyright (c) 2009 kbinani
*
* This file is part of bocoree.
*
* bocoree is free software; you can redistribute it and/or
* modify it under the terms of the BSD License.
*
* bocoree is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
#if JAVA
//INCLUDE ..\BuildJavaUI\src\org\kbinani\componentModel\BRunWorkerCompletedEventHandler.java
#endif

158
bocoree/BSlider.cs Normal file
View File

@@ -0,0 +1,158 @@
#if JAVA
//INCLUDE ..\BuildJavaUI\src\org\kbinani\windows\forms\BSlider.java
#else
namespace bocoree.windows.forms {
public class BSlider : System.Windows.Forms.TrackBar {
public int getValue() {
return base.Value;
}
public void setValue( int value ) {
base.Value = value;
}
public int getMinimum() {
return base.Minimum;
}
public void setMinimum( int value ) {
base.Minimum = value;
}
public int getMaximum() {
return base.Maximum;
}
public void setMaximum( int value ) {
base.Maximum = value;
}
#region java.awt.Component
// root implementation of java.awt.Component is in BForm.cs
public bool isVisible() {
return base.Visible;
}
public void setVisible( bool value ) {
base.Visible = value;
}
#if COMPONENT_ENABLE_TOOL_TIP_TEXT
public void setToolTipText( string value )
{
base.ToolTipText = value;
}
public String getToolTipText()
{
return base.ToolTipText;
}
#endif
#if COMPONENT_PARENT_AS_OWNERITEM
public Object getParent() {
return base.OwnerItem;
}
#else
public object getParent() {
return base.Parent;
}
#endif
public string getName() {
return base.Name;
}
public void setName( string value ) {
base.Name = value;
}
#if COMPONENT_ENABLE_LOCATION
public bocoree.java.awt.Point getLocation() {
System.Drawing.Point loc = this.Location;
return new bocoree.java.awt.Point( loc.X, loc.Y );
}
public void setLocation( int x, int y ) {
base.Location = new System.Drawing.Point( x, y );
}
public void setLocation( bocoree.java.awt.Point p ) {
base.Location = new System.Drawing.Point( p.x, p.y );
}
#endif
public bocoree.java.awt.Rectangle getBounds() {
System.Drawing.Rectangle r = base.Bounds;
return new bocoree.java.awt.Rectangle( r.X, r.Y, r.Width, r.Height );
}
#if COMPONENT_ENABLE_X
public int getX() {
return base.Left;
}
#endif
#if COMPONENT_ENABLE_Y
public int getY() {
return base.Top;
}
#endif
public int getWidth() {
return base.Width;
}
public int getHeight() {
return base.Height;
}
public bocoree.java.awt.Dimension getSize() {
return new bocoree.java.awt.Dimension( base.Size.Width, base.Size.Height );
}
public void setSize( int width, int height ) {
base.Size = new System.Drawing.Size( width, height );
}
public void setSize( bocoree.java.awt.Dimension d ) {
setSize( d.width, d.height );
}
public void setBackground( bocoree.java.awt.Color color ) {
base.BackColor = System.Drawing.Color.FromArgb( color.getRed(), color.getGreen(), color.getBlue() );
}
public bocoree.java.awt.Color getBackground() {
return new bocoree.java.awt.Color( base.BackColor.R, base.BackColor.G, base.BackColor.B );
}
public void setForeground( bocoree.java.awt.Color color ) {
base.ForeColor = color.color;
}
public bocoree.java.awt.Color getForeground() {
return new bocoree.java.awt.Color( base.ForeColor.R, base.ForeColor.G, base.ForeColor.B );
}
public void setFont( bocoree.java.awt.Font font ) {
base.Font = font.font;
}
public bool isEnabled() {
return base.Enabled;
}
public void setEnabled( bool value ) {
base.Enabled = value;
}
public void requestFocus() {
base.Focus();
}
#endregion
}
}
#endif

46
bocoree/BSplitPane.cs Normal file
View File

@@ -0,0 +1,46 @@
/*
* BSplitPane.cs
* Copyright (c) 2009 kbinani
*
* This file is part of bocoree.
*
* bocoree is free software; you can redistribute it and/or
* modify it under the terms of the BSD License.
*
* bocoree is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
#if JAVA
//INCLUDE ..\BuildJavaUI\src\org\kbinani\windows\forms\BSplitPane.java
#else
namespace bocoree.windows.forms {
public class BSplitPane : System.Windows.Forms.SplitContainer {
public int getDividerLocation() {
return base.SplitterDistance;
}
public int getDividerSize() {
return base.SplitterWidth;
}
public void setDividerLocation( int value ) {
base.SplitterDistance = value;
}
public void setDividerSize( int value ) {
base.SplitterWidth = value;
}
public bool isSplitterFixed() {
return base.IsSplitterFixed;
}
public void setSplitterFixed( bool value ) {
base.IsSplitterFixed = value;
}
}
}
#endif

50
bocoree/BStatusLabel.cs Normal file
View File

@@ -0,0 +1,50 @@
/*
* BStatusLabel.cs
* Copyright (c) 2009 kbinani
*
* This file is part of bocoree.
*
* bocoree is free software; you can redistribute it and/or
* modify it under the terms of the BSD License.
*
* bocoree is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
#if JAVA
//INCLUDE ..\BuildJavaUI\src\org\kbinani\windows\forms\BStatusLabel.java
#else
namespace bocoree.windows.forms {
public class BStatusLabel : System.Windows.Forms.ToolStripStatusLabel {
public void setText( string value ) {
base.Text = value;
}
public string getText() {
return base.Text;
}
public void setToolTipText( string value ) {
base.ToolTipText = value;
}
public string getToolTipText() {
return base.ToolTipText;
}
public bocoree.java.awt.Icon getIcon() {
return new bocoree.java.awt.ImageIcon( base.Image );
}
public void setIcon( bocoree.java.awt.Icon value ) {
if ( value == null ) {
base.Image = null;
} else {
base.Image = value.image;
}
}
}
}
#endif

30
bocoree/BTextArea.cs Normal file
View File

@@ -0,0 +1,30 @@
/*
* BTextArea.cs
* Copyright (c) 2009 kbinani
*
* This file is part of bocoree.
*
* bocoree is free software; you can redistribute it and/or
* modify it under the terms of the BSD License.
*
* bocoree is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
#if JAVA
//INCLUDE ..\BuildJavaUI\src\org\kbinani\windows\forms\BTextArea.java
#else
namespace bocoree.windows.forms {
public class BTextArea : System.Windows.Forms.TextBox {
public BTextArea() {
base.Multiline = true;
base.AcceptsReturn = true;
base.AcceptsTab = true;
base.WordWrap = false;
base.ScrollBars = System.Windows.Forms.ScrollBars.Both;
}
}
}
#endif

185
bocoree/BTextBox.cs Normal file
View File

@@ -0,0 +1,185 @@
/*
* BTextBox.cs
* Copyright (c) 2009 kbinani
*
* This file is part of bocoree.
*
* bocoree is free software; you can redistribute it and/or
* modify it under the terms of the BSD License.
*
* bocoree is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
#if JAVA
//INCLUDE ..\BuildJavaUI\src\org\kbinani\windows\forms\BTextBox.java
#else
#define COMPONENT_ENABLE_LOCATION
namespace bocoree.windows.forms{
public class BTextBox : System.Windows.Forms.TextBox {
#region java.awt.Component
// root implementation of java.awt.Component is in BForm.cs
public bool isVisible() {
return base.Visible;
}
public void setVisible( bool value ) {
base.Visible = value;
}
#if COMPONENT_ENABLE_TOOL_TIP_TEXT
public void setToolTipText( string value )
{
base.ToolTipText = value;
}
public string getToolTipText()
{
return base.ToolTipText;
}
#endif
#if COMPONENT_PARENT_AS_OWNERITEM
public object getParent() {
return base.OwnerItem;
}
#else
public object getParent() {
return base.Parent;
}
#endif
public string getName() {
return base.Name;
}
public void setName( string value ) {
base.Name = value;
}
#if COMPONENT_ENABLE_LOCATION
public bocoree.java.awt.Point getLocation() {
System.Drawing.Point loc = this.Location;
return new bocoree.java.awt.Point( loc.X, loc.Y );
}
public void setLocation( int x, int y ) {
base.Location = new System.Drawing.Point( x, y );
}
public void setLocation( bocoree.java.awt.Point p ) {
base.Location = new System.Drawing.Point( p.x, p.y );
}
#endif
public bocoree.java.awt.Rectangle getBounds() {
System.Drawing.Rectangle r = base.Bounds;
return new bocoree.java.awt.Rectangle( r.X, r.Y, r.Width, r.Height );
}
#if COMPONENT_ENABLE_X
public int getX() {
return base.Left;
}
#endif
#if COMPONENT_ENABLE_Y
public int getY() {
return base.Top;
}
#endif
public int getWidth() {
return base.Width;
}
public int getHeight() {
return base.Height;
}
public bocoree.java.awt.Dimension getSize() {
return new bocoree.java.awt.Dimension( base.Size.Width, base.Size.Height );
}
public void setSize( int width, int height ) {
base.Size = new System.Drawing.Size( width, height );
}
public void setSize( bocoree.java.awt.Dimension d ) {
setSize( d.width, d.height );
}
public void setBackground( bocoree.java.awt.Color color ) {
base.BackColor = System.Drawing.Color.FromArgb( color.getRed(), color.getGreen(), color.getBlue() );
}
public bocoree.java.awt.Color getBackground() {
return new bocoree.java.awt.Color( base.BackColor.R, base.BackColor.G, base.BackColor.B );
}
public void setForeground( bocoree.java.awt.Color color ) {
base.ForeColor = color.color;
}
public bocoree.java.awt.Color getForeground() {
return new bocoree.java.awt.Color( base.ForeColor.R, base.ForeColor.G, base.ForeColor.B );
}
public void setFont( bocoree.java.awt.Font font ) {
base.Font = font.font;
}
public bool getEnabled() {
return base.Enabled;
}
public void setEnabled( bool value ) {
base.Enabled = value;
}
public void requestFocus() {
base.Focus();
}
#endregion
#region java.awt.TextComponent
public string getText() {
return base.Text;
}
public void setText( string value ) {
base.Text = value;
}
#endregion
#region javax.swing.JComponent
// root implementation of javax.swing.JComponent is in BForm.cs
public bool requestFocusInWindow() {
return base.Focus();
}
#endregion
public bool isImeModeOn() {
return base.ImeMode == System.Windows.Forms.ImeMode.Hiragana;
}
public void setImeModeOn( bool value ){
base.ImeMode = value ? System.Windows.Forms.ImeMode.Hiragana : System.Windows.Forms.ImeMode.Off;
}
public void selectAll() {
base.SelectAll();
}
public void setTag( object value ) {
base.Tag = value;
}
public object getTag() {
return base.Tag;
}
}
}
#endif

39
bocoree/BTimer.cs Normal file
View File

@@ -0,0 +1,39 @@
#if JAVA
//INCLUDE ..\BuildJavaUI\src\org\kbinani\windows\forms\BTimer.java
#else
using System;
namespace bocoree.windows.forms {
public class BTimer : System.Windows.Forms.Timer {
public void start() {
base.Start();
}
public BTimer()
: base() {
}
public BTimer( System.ComponentModel.IContainer container )
: base( container ) {
}
public void stop() {
base.Stop();
}
public int getDelay() {
return base.Interval;
}
public void setDelay( int value ) {
base.Interval = value;
}
public bool isRunning() {
return base.Enabled;
}
}
}
#endif

23
bocoree/BToggleButton.cs Normal file
View File

@@ -0,0 +1,23 @@
/*
* BToggleButton.cs
* Copyright (c) 2009 kbinani
*
* This file is part of bocoree.
*
* bocoree is free software; you can redistribute it and/or
* modify it under the terms of the BSD License.
*
* bocoree is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
#if JAVA
//INCLUDE ..\BuildJavaUI\src\org\kbinani\windows\forms\BToggleButton.java
#else
namespace bocoree.windows.forms {
public class BToggleButton : System.Windows.Forms.ToolStripButton {
}
}
#endif

36
bocoree/BToolBar.cs Normal file
View File

@@ -0,0 +1,36 @@
/*
* BToolBar.cs
* Copyright (c) 2009 kbinani
*
* This file is part of bocoree.
*
* bocoree is free software; you can redistribute it and/or
* modify it under the terms of the BSD License.
*
* bocoree is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
#if JAVA
//INCLUDE ..\BuildJavaUI\src\org\kbinani\windows\forms\BToolBar.java
#else
namespace bocoree.windows.forms {
public class BToolBar : System.Windows.Forms.ToolStrip {
public int getComponentCount() {
return base.Items.Count;
}
public System.Windows.Forms.ToolStripItem getComponentAtIndex( int index ) {
return base.Items[index];
}
public void add( System.Windows.Forms.ToolStripItem value ) {
base.Items.Add( value );
}
public void addSeparator() {
base.Items.Add( new System.Windows.Forms.ToolStripSeparator() );
}
}
}
#endif

192
bocoree/BToolStripButton.cs Normal file
View File

@@ -0,0 +1,192 @@
/*
* BToolStripButton.cs
* Copyright (c) 2009 kbinani
*
* This file is part of bocoree.
*
* bocoree is free software; you can redistribute it and/or
* modify it under the terms of the BSD License.
*
* bocoree is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
#if JAVA
//INCLUDE ..\BuildJavaUI\src\org\kbinani\windows\forms\BToolStripButton.java
#else
#define COMPONENT_PARENT_AS_OWNERITEM
#define COMPONENT_ENABLE_TOOL_TIP_TEXT
#define ABSTRACT_BUTTON_ENABLE_IS_SELECTED
namespace bocoree.windows.forms {
public class BToolStripButton : System.Windows.Forms.ToolStripButton {
private object tag = null;
public object getTag() {
return tag;
}
public void setTag( object value ) {
tag = value;
}
public bool isCheckOnClick() {
return base.CheckOnClick;
}
public void setCheckOnClick( bool value ) {
base.CheckOnClick = value;
}
#region java.awt.Component
#if COMPONENT_ENABLE_TOOL_TIP_TEXT
public void setToolTipText( string value ) {
base.ToolTipText = value;
}
public string getToolTipText() {
return base.ToolTipText;
}
#endif
#if COMPONENT_PARENT_AS_OWNERITEM
public object getParent() {
return base.OwnerItem;
}
#else
public object getParent()
{
return base.Parent;
}
#endif
public string getName() {
return base.Name;
}
public void setName( string value ) {
base.Name = value;
}
#if COMPONENT_ENABLE_LOCATION
public bocoree.java.awt.Point getLocation()
{
System.Drawing.Point loc = this.Location;
return new bocoree.java.awt.Point( loc.X, loc.Y );
}
public void setLocation( int x, int y )
{
base.Location = new System.Drawing.Point( x, y );
}
public void setLocation( bocoree.java.awt.Point p )
{
base.Location = new System.Drawing.Point( p.x, p.y );
}
#endif
public bocoree.java.awt.Rectangle getBounds() {
System.Drawing.Rectangle r = base.Bounds;
return new bocoree.java.awt.Rectangle( r.X, r.Y, r.Width, r.Height );
}
#if COMPONENT_ENABLE_X
public int getX()
{
return base.Left;
}
#endif
#if COMPONENT_ENABLE_Y
public int getY()
{
return base.Top;
}
#endif
public int getWidth() {
return base.Width;
}
public int getHeight() {
return base.Height;
}
public bocoree.java.awt.Dimension getSize() {
return new bocoree.java.awt.Dimension( base.Size.Width, base.Size.Height );
}
public void setSize( int width, int height ) {
base.Size = new System.Drawing.Size( width, height );
}
public void setSize( bocoree.java.awt.Dimension d ) {
setSize( d.width, d.height );
}
public void setBackground( bocoree.java.awt.Color color ) {
base.BackColor = System.Drawing.Color.FromArgb( color.getRed(), color.getGreen(), color.getBlue() );
}
public bocoree.java.awt.Color getBackground() {
return new bocoree.java.awt.Color( base.BackColor.R, base.BackColor.G, base.BackColor.B );
}
public void setForeground( bocoree.java.awt.Color color ) {
base.ForeColor = color.color;
}
public bocoree.java.awt.Color getForeground() {
return new bocoree.java.awt.Color( base.ForeColor.R, base.ForeColor.G, base.ForeColor.B );
}
public void setFont( bocoree.java.awt.Font font ) {
base.Font = font.font;
}
public bool getEnabled() {
return base.Enabled;
}
public void setEnabled( bool value ) {
base.Enabled = value;
}
#endregion
#region javax.swing.AbstractButton
// root implementation of javax.swing.AbstractButton is in BMenuItem.cs
public string getText() {
return base.Text;
}
public void setText( string value ) {
base.Text = value;
}
#if ABSTRACT_BUTTON_ENABLE_IS_SELECTED
public bool isSelected() {
return base.Checked;
}
public void setSelected( bool value ) {
base.Checked = value;
}
#endif
public bocoree.java.awt.Icon getIcon() {
bocoree.java.awt.Icon ret = new bocoree.java.awt.Icon();
ret.image = base.Image;
return ret;
}
public void setIcon( bocoree.java.awt.Icon value ) {
if ( value == null ) {
base.Image = null;
} else {
base.Image = value.image;
}
}
#endregion
}
}
#endif

View File

@@ -0,0 +1,9 @@
namespace bocoree.windows.forms {
public class BToolStripDropDownButton : System.Windows.Forms.ToolStripDropDownButton {
public void setText( string value ) {
base.Text = value;
}
}
}

View File

@@ -0,0 +1,7 @@
namespace bocoree.windows.forms {
public class BToolStripLabel : System.Windows.Forms.ToolStripLabel {
public void setText( string value ) {
base.Text = value;
}
}
}

View File

@@ -0,0 +1,13 @@
namespace bocoree.windows.forms {
public class BToolStripTextBox : System.Windows.Forms.ToolStripTextBox {
public void setText( string value ) {
base.Text = value;
}
public string getText() {
return base.Text;
}
}
}

216
bocoree/BVScrollBar.cs Normal file
View File

@@ -0,0 +1,216 @@
#if JAVA
//INCLUDE ..\BuildJavaUI\src\org\kbinani\windows\forms\BVScrollBar.java
#else
namespace bocoree.windows.forms {
public class BVScrollBar : System.Windows.Forms.VScrollBar {
// root implementation of javax.swing.ScrollBar
#region javax.swing.ScrollBar
public void setMaximum( int value ) {
base.Maximum = value;
}
public int getMaximum() {
return base.Maximum;
}
public void setMinimum( int value ) {
base.Minimum = value;
}
public int getMinimum() {
return base.Minimum;
}
public int getValue() {
return base.Value;
}
public void setValue( int value ) {
base.Value = value;
}
public int getVisibleAmount() {
return base.LargeChange;
}
public void setVisibleAmount( int value ) {
base.LargeChange = value;
}
#endregion
#region java.awt.Component
// root implementation of java.awt.Component is in BForm.cs
public bocoree.java.awt.Cursor getCursor() {
System.Windows.Forms.Cursor c = base.Cursor;
bocoree.java.awt.Cursor ret = null;
if ( c.Equals( System.Windows.Forms.Cursors.Arrow ) ) {
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.DEFAULT_CURSOR );
} else if ( c.Equals( System.Windows.Forms.Cursors.Cross ) ) {
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.CROSSHAIR_CURSOR );
} else if ( c.Equals( System.Windows.Forms.Cursors.Default ) ) {
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.DEFAULT_CURSOR );
} else if ( c.Equals( System.Windows.Forms.Cursors.Hand ) ) {
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.HAND_CURSOR );
} else if ( c.Equals( System.Windows.Forms.Cursors.IBeam ) ) {
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.TEXT_CURSOR );
} else if ( c.Equals( System.Windows.Forms.Cursors.PanEast ) ) {
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.E_RESIZE_CURSOR );
} else if ( c.Equals( System.Windows.Forms.Cursors.PanNE ) ) {
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.NE_RESIZE_CURSOR );
} else if ( c.Equals( System.Windows.Forms.Cursors.PanNorth ) ) {
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.N_RESIZE_CURSOR );
} else if ( c.Equals( System.Windows.Forms.Cursors.PanNW ) ) {
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.NW_RESIZE_CURSOR );
} else if ( c.Equals( System.Windows.Forms.Cursors.PanSE ) ) {
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.SE_RESIZE_CURSOR );
} else if ( c.Equals( System.Windows.Forms.Cursors.PanSouth ) ) {
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.S_RESIZE_CURSOR );
} else if ( c.Equals( System.Windows.Forms.Cursors.PanSW ) ) {
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.SW_RESIZE_CURSOR );
} else if ( c.Equals( System.Windows.Forms.Cursors.PanWest ) ) {
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.W_RESIZE_CURSOR );
} else if ( c.Equals( System.Windows.Forms.Cursors.SizeAll ) ) {
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.MOVE_CURSOR );
} else {
ret = new bocoree.java.awt.Cursor( bocoree.java.awt.Cursor.CUSTOM_CURSOR );
}
ret.cursor = c;
return ret;
}
public void setCursor( bocoree.java.awt.Cursor value ) {
base.Cursor = value.cursor;
}
public bool isVisible() {
return base.Visible;
}
public void setVisible( bool value ) {
base.Visible = value;
}
#if COMPONENT_ENABLE_TOOL_TIP_TEXT
public void setToolTipText( string value )
{
base.ToolTipText = value;
}
public String getToolTipText()
{
return base.ToolTipText;
}
#endif
#if COMPONENT_PARENT_AS_OWNERITEM
public Object getParent() {
return base.OwnerItem;
}
#else
public object getParent() {
return base.Parent;
}
#endif
public string getName() {
return base.Name;
}
public void setName( string value ) {
base.Name = value;
}
#if COMPONENT_ENABLE_LOCATION
public bocoree.java.awt.Point getLocationOnScreen() {
System.Drawing.Point p = base.PointToScreen( base.Location );
return new bocoree.java.awt.Point( p.X, p.Y );
}
public bocoree.java.awt.Point getLocation() {
System.Drawing.Point loc = this.Location;
return new bocoree.java.awt.Point( loc.X, loc.Y );
}
public void setLocation( int x, int y ) {
base.Location = new System.Drawing.Point( x, y );
}
public void setLocation( bocoree.java.awt.Point p ) {
base.Location = new System.Drawing.Point( p.x, p.y );
}
#endif
public bocoree.java.awt.Rectangle getBounds() {
System.Drawing.Rectangle r = base.Bounds;
return new bocoree.java.awt.Rectangle( r.X, r.Y, r.Width, r.Height );
}
#if COMPONENT_ENABLE_X
public int getX() {
return base.Left;
}
#endif
#if COMPONENT_ENABLE_Y
public int getY() {
return base.Top;
}
#endif
public int getWidth() {
return base.Width;
}
public int getHeight() {
return base.Height;
}
public bocoree.java.awt.Dimension getSize() {
return new bocoree.java.awt.Dimension( base.Size.Width, base.Size.Height );
}
public void setSize( int width, int height ) {
base.Size = new System.Drawing.Size( width, height );
}
public void setSize( bocoree.java.awt.Dimension d ) {
setSize( d.width, d.height );
}
public void setBackground( bocoree.java.awt.Color color ) {
base.BackColor = System.Drawing.Color.FromArgb( color.getRed(), color.getGreen(), color.getBlue() );
}
public bocoree.java.awt.Color getBackground() {
return new bocoree.java.awt.Color( base.BackColor.R, base.BackColor.G, base.BackColor.B );
}
public void setForeground( bocoree.java.awt.Color color ) {
base.ForeColor = color.color;
}
public bocoree.java.awt.Color getForeground() {
return new bocoree.java.awt.Color( base.ForeColor.R, base.ForeColor.G, base.ForeColor.B );
}
public void setFont( bocoree.java.awt.Font font ) {
base.Font = font.font;
}
public bool isEnabled() {
return base.Enabled;
}
public void setEnabled( bool value ) {
base.Enabled = value;
}
public void requestFocus() {
base.Focus();
}
#endregion
}
}
#endif

156
bocoree/Base64.cs Normal file
View File

@@ -0,0 +1,156 @@
/*
* Base64.cs
* Copyright (c) 2009 kbinani
*
* This file is part of bocoree.
*
* bocoree is free software; you can redistribute it and/or
* modify it under the terms of the BSD License.
*
* bocoree is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
#if JAVA
package org.kbinani;
public class Base64{
static final char TABLE[] = {
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',
'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f',
'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
'o', 'p', 'q', 'r', 's', 't', 'u', 'v',
'w', 'x', 'y', 'z', '0', '1', '2', '3',
'4', '5', '6', '7', '8', '9', '+', '/'
};
private Base64(){
}
public static String encode( byte[] value ){
StringBuilder ret = new StringBuilder();
int buf = 0;
int filled = 0; // bufに格納されているビット数
int count = 0;
for( int i = 0; i < value.length; i++ ){
int v = value[i] & 0xff;
if( filled == 0 ){
buf = 0x3f & (v >>> 2);
ret.append( TABLE[buf] );
buf = 0x3f & (v << 4);
filled = 2;
count++;
}else if( filled == 2 ){
buf = buf | (v >>> 4);
ret.append( TABLE[buf] );
buf = 0x3f & (v << 2);
filled = 4;
count++;
}else if( filled == 4 ){
buf = buf | (v >>> 6);
ret.append( TABLE[buf] );
buf = 0x3f & v;
ret.append( TABLE[buf] );
filled = 0;
count += 2;
}
}
if( filled > 0 ){
ret.append( TABLE[buf] );
count++;
}
int r = count & 0x03;
if( r != 0 ){
for( int i = 0; i < 4 - r; i++ ){
ret.append( "=" );
}
}
return ret.toString();
}
public static byte[] decode( String value ){
int index = value.lastIndexOf( '=' );
int len = 0;
int c = value.length();
if( index < 0 ){
len = c * 6;
}else{
len = index * 6;
}
int total;
if( (len & 0x07) == 0 ){
total = len >>> 3;
}else{
total = (len >>> 3) + 1;
}
byte[] ret = new byte[total];
int buf = 0;
int filled = 0;
index = 0;
for( int i = 0; i < c; i++ ){
char ch = value.charAt( i );
if( ch == '=' ){
break;
}
int v = decodeUnit( ch );
if( filled == 0 ){
buf = v << 2;
filled = 6;
}else if( filled == 6 ){
buf = buf | (v >>> 4);
ret[index] = (byte)buf;
buf = v << 4;
filled = 4;
index++;
}else if( filled == 4 ){
buf = buf | (v >>> 2);
ret[index] = (byte)buf;
buf = v << 6;
filled = 2;
index++;
}else if( filled == 2 ){
buf = buf | v;
ret[index] = (byte)buf;
buf = 0;
filled = 0;
index++;
}
}
if( filled > 0 ){
ret[index] = (byte)buf;
}
return ret;
}
private static int decodeUnit( char c ){
int code = (int)c;
if( 97 <= code ){
return code - 71;
}else if( 65 <= code ){
return code - 65;
}else if( 48 <= code ){
return code + 4;
}else if( code == 43 ){
return 62;
}else{
return 63;
}
}
}
#else
using System;
namespace bocoree {
public static class Base64 {
public static string encode( byte[] value ) {
return Convert.ToBase64String( value );
}
public static byte[] decode( String value ) {
return Convert.FromBase64String( value );
}
}
}
#endif

92
bocoree/BufferedReader.cs Normal file
View File

@@ -0,0 +1,92 @@
#if !JAVA
/*
* BufferedReader.cs
* Copyright (c) 2009 kbinani
*
* This file is part of bocoree.
*
* bocoree is free software; you can redistribute it and/or
* modify it under the terms of the BSD License.
*
* bocoree is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
using System;
using System.IO;
using System.Text;
namespace bocoree.java.io {
public class FileReader{
public StreamReader m_reader;
public FileReader( String fileName ){
m_reader = new StreamReader( fileName );
}
}
public class FileInputStream : FileStream, InputStream {
public FileInputStream( String fileName )
: base( fileName, FileMode.Open, FileAccess.Read ) {
}
public void close() {
base.Close();
}
public int read( byte[] b, int off, int len ) {
return base.Read( b, off, len );
}
public int read( byte[] b ) {
return read( b, 0, b.Length );
}
public int read() {
return base.ReadByte();
}
}
public class InputStreamReader {
public StreamReader m_reader;
public InputStreamReader( FileInputStream stream, String charsetName ) {
m_reader = new StreamReader( stream, Encoding.GetEncoding( charsetName ) );
}
}
public class BufferedReader {
private StreamReader m_reader;
public BufferedReader( FileReader reader ) {
m_reader = reader.m_reader;
}
public BufferedReader( InputStreamReader reader ) {
m_reader = reader.m_reader;
}
public void close() {
m_reader.Close();
}
public int read() {
return m_reader.Read();
}
public int read( char[] cbuf, int off, int len ) {
return m_reader.Read( cbuf, off, len );
}
public String readLine() {
return m_reader.ReadLine();
}
public bool ready() {
return m_reader.Peek() >= 0;
}
}
}
#endif

126
bocoree/BufferedWriter.cs Normal file
View File

@@ -0,0 +1,126 @@
#if !JAVA
/*
* BufferedWriter.cs
* Copyright (c) 2009 kbinani
*
* This file is part of bocoree.
*
* bocoree is free software; you can redistribute it and/or
* modify it under the terms of the BSD License.
*
* bocoree is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
using System;
using System.IO;
using System.Text;
namespace bocoree.java.io {
public class FileWriter {
public StreamWriter m_writer;
public FileWriter( String fileName ) {
m_writer = new StreamWriter( fileName );
}
}
public class FileOutputStream : FileStream, OutputStream {
public FileOutputStream( String fileName )
: base( fileName, FileMode.Create, FileAccess.Write ) {
}
public void close() {
base.Close();
}
/// <summary>
/// 出力ストリームをフラッシュして、バッファリングされていたすべての出力バイトを強制的にストリームに書き込みます。
/// </summary>
public void flush() {
base.Flush();
}
/// <summary>
/// b.length バイトのデータを出力ストリームに書き込みます。
/// </summary>
/// <param name="b"></param>
public void write( byte[] b ) {
base.Write( b, 0, b.Length );
}
/// <summary>
/// 指定された byte 配列の、オフセット位置 off から始まる len バイトを出力ストリームに書き込みます。
/// </summary>
/// <param name="b"></param>
/// <param name="off"></param>
/// <param name="len"></param>
public void write( byte[] b, int off, int len ) {
base.Write( b, off, len );
}
/// <summary>
/// 指定された byte を出力ストリームに書き込みます。
/// </summary>
/// <param name="b"></param>
public void write( int b ) {
base.WriteByte( (byte)b );
}
}
public class OutputStreamWriter {
public StreamWriter m_writer;
public OutputStreamWriter( FileOutputStream stream, String charsetName ) {
m_writer = new StreamWriter( stream, Encoding.GetEncoding( charsetName ) );
}
}
public class BufferedWriter {
private StreamWriter m_writer;
public BufferedWriter( FileWriter writer ) {
m_writer = writer.m_writer;
}
public BufferedWriter( OutputStreamWriter writer ) {
m_writer = writer.m_writer;
}
public void close() {
m_writer.Close();
}
public void flush() {
m_writer.Flush();
}
public void newLine() {
m_writer.WriteLine();
}
public void write( char[] cbuf, int off, int len ) {
m_writer.Write( cbuf, off, len );
}
public void write( int c ) {
m_writer.Write( (char)c );
}
public void write( String s, int off, int len ) {
m_writer.Write( s.ToCharArray(), off, len );
}
public void write( String str ) {
m_writer.Write( str );
}
public void write( char[] cbuf ) {
m_writer.Write( cbuf );
}
}
}
#endif

35
bocoree/ByRef.cs Normal file
View File

@@ -0,0 +1,35 @@
/*
* ByRef.cs
* Copyright (c) 2009 kbinani
*
* This file is part of bocoree.
*
* bocoree is free software; you can redistribute it and/or
* modify it under the terms of the BSD License.
*
* Boare.Lib.Vsq is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
#if JAVA
package org.kbinani;
#else
using System;
namespace bocoree {
#endif
public class ByRef<T> {
public T value;
public ByRef() {
}
public ByRef( T value_ ) {
value = value_;
}
}
#if !JAVA
}
#endif

27
bocoree/Collections.cs Normal file
View File

@@ -0,0 +1,27 @@
#if !JAVA
/*
* Collections.cs
* Copyright (c) 2009 kbinani
*
* This file is part of bocoree.
*
* bocoree is free software; you can redistribute it and/or
* modify it under the terms of the BSD License.
*
* bocoree is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
//#define VECTOR_TEST
namespace bocoree.java.util {
public static class Collections {
public static void sort<T>( Vector<T> list ) {
#if !VECTOR_TEST
list.Sort();
#endif
}
}
}
#endif

475
bocoree/File.cs Normal file
View File

@@ -0,0 +1,475 @@
/*#if !JAVA
using System;
using System.Collections.Generic;
namespace bocoree {
public class File {
public readonly string separator = System.IO.Path.DirectorySeparatorChar + "";
public readonly char separatorChar = System.IO.Path.DirectorySeparatorChar;
private string m_path;
/// <summary>
/// 指定されたパス名文字列を抽象パス名に変換して、新しい File のインスタンスを生成します。
/// </summary>
/// <param name="pathname"></param>
public File( String pathname ) {
m_path = pathname;
}
/// <summary>
/// この抽象パス名が示すファイルをアプリケーションが実行できるかどうかを判定します。
/// </summary>
public bool canExecute() {
throw new NotImplementedException();
}
/// <summary>
/// この抽象パス名が示すファイルをアプリケーションが読み込めるかどうかを判定します。
/// </summary>
public bool canRead() {
System.IO.FileStream fs = null;
bool ret = false;
try {
fs = System.IO.File.OpenRead( m_path );
ret = true;
} catch {
ret = false;
} finally {
if ( fs != null ) {
try {
fs.Close();
} catch {
}
}
}
return ret;
}
/// <summary>
/// この抽象パス名が示すファイルをアプリケーションが変更できるかどうかを判定します。
/// </summary>
public bool canWrite() {
System.IO.FileStream fs = null;
bool ret = false;
try {
fs = System.IO.File.OpenWrite( m_path );
ret = true;
} catch {
ret = false;
} finally {
if ( fs != null ) {
try {
fs.Close();
} catch {
}
}
}
return ret;
}
/// <summary>
/// 2 つの抽象パス名を語彙的に比較します。
/// </summary>
public int compareTo( File pathname ) {
return System.IO.Path.GetFullPath( this.m_path ).CompareTo( System.IO.Path.GetFullPath( pathname.m_path ) );
}
/// <summary>
/// この抽象パス名が示す空の新しいファイルを不可分 (atomic) に生成します (その名前のファイルがまだ存在しない場合だけ)。
/// </summary>
public bool createNewFile() {
if ( System.IO.File.Exists( m_path ) ) {
return false;
} else {
System.IO.File.Create( m_path );
return true;
}
}
/// <summary>
/// 指定された接頭辞と接尾辞をファイル名の生成に使用して、デフォルトの一時ファイルディレクトリに空のファイルを生成します。
/// </summary>
public static File createTempFile( string prefix, string suffix ) {
string tmp = System.IO.Path.GetTempFileName();
string dir = System.IO.Path.GetDirectoryName( tmp );
string file = System.IO.Path.GetFileName( tmp );
return new File( System.IO.Path.Combine( dir, prefix + file + suffix ) );
}
/// <summary>
/// 指定されたディレクトリで新しい空のファイルを生成し、その名前には、指定された接頭辞および接尾辞の文字列が使用されます。
/// </summary>
public static File createTempFile( string prefix, string suffix, File directory ) {
String dir = System.IO.Path.GetTempPath();
if ( directory != null ) {
dir = directory.m_path;
}
if ( !System.IO.Directory.Exists( dir ) ) {
throw new System.IO.IOException();
}
while ( true ) {
String f = prefix + System.IO.Path.GetRandomFileName() + suffix;
String full = System.IO.Path.Combine( dir, f );
if ( !System.IO.File.Exists( full ) ) {
System.IO.File.Create( full );
return new File( full );
}
}
throw new System.IO.IOException();
}
/// <summary>
/// この抽象パス名が示すファイルまたはディレクトリを削除します。
/// </summary>
public bool delete() {
try {
System.IO.File.Delete( m_path );
return true;
} catch {
}
return false;
}
/// <summary>
/// この抽象パス名が示すファイルまたはディレクトリが、仮想マシンが終了したときに削除されるように要求します。
/// </summary>
public void deleteOnExit() {
throw new NotImplementedException();
}
/// <summary>
/// この抽象パス名が指定されたオブジェクトと等しいかどうかを判定します。
/// </summary>
public bool equals( object obj ) {
return base.Equals( obj );
}
/// <summary>
/// この抽象パス名が示すファイルまたはディレクトリが存在するかどうかを判定します。
/// </summary>
public bool exists() {
bool file = System.IO.File.Exists( m_path );
bool dir = System.IO.Directory.Exists( m_path );
return file || dir;
}
/// <summary>
/// この抽象パス名の絶対形式を返します。
/// </summary>
public File getAbsoluteFile() {
return new File( getAbsolutePath() );
}
/// <summary>
/// この抽象パス名の絶対パス名文字列を返します。
/// </summary>
public string getAbsolutePath() {
return System.IO.Path.GetFullPath( m_path );
}
/// <summary>
/// この抽象パス名の正規の形式を返します。
/// </summary>
public File getCanonicalFile() {
throw new NotImplementedException();
}
/// <summary>
/// この抽象パス名の正規のパス名文字列を返します。
/// </summary>
public string getCanonicalPath() {
throw new NotImplementedException();
}
/// <summary>
/// この抽象パス名で指定されるパーティション内で未割り当てのバイト数を返します。
/// </summary>
public long getFreeSpace() {
string drive = System.IO.Path.GetPathRoot( m_path );
foreach ( System.IO.DriveInfo di in System.IO.DriveInfo.GetDrives() ) {
if ( di.RootDirectory.FullName == drive ) {
return di.TotalFreeSpace;
}
}
return 0;
}
/// <summary>
/// この抽象パス名が示すファイルまたはディレクトリの名前を返します。
/// </summary>
public string getName() {
return System.IO.Path.GetFileName( m_path );
}
/// <summary>
/// この抽象パス名の親のパス名文字列を返します。
/// </summary>
public string getParent() {
return System.IO.Path.GetDirectoryName( m_path );
}
/// <summary>
/// この抽象パス名の親の抽象パス名を返します。
/// </summary>
public File getParentFile() {
return new File( getParent() );
}
/// <summary>
/// この抽象パス名をパス名文字列に変換します。
/// </summary>
public string getPath() {
return m_path;
}
/// <summary>
/// この抽象パス名で指定されるパーティションのサイズを返します。
/// </summary>
public long getTotalSpace() {
return getFreeSpace();
}
/// <summary>
/// この抽象パス名で指定されるパーティション上で、この仮想マシンが利用できるバイト数を返します。
/// </summary>
public long getUsableSpace() {
return getFreeSpace();
}
/// <summary>
/// この抽象パス名のハッシュコードを計算します。
/// </summary>
public int hashCode() {
return m_path.GetHashCode();
}
/// <summary>
/// この抽象パス名が絶対かどうかを判定します。
/// </summary>
public bool isAbsolute() {
return System.IO.Path.IsPathRooted( m_path );
}
/// <summary>
/// この抽象パス名が示すファイルがディレクトリであるかどうかを判定します。
/// </summary>
public bool isDirectory() {
bool dir = System.IO.Directory.Exists( m_path );
if ( dir ) {
return true;
} else {
return false;
}
}
/// <summary>
/// この抽象パス名が示すファイルが普通のファイルかどうかを判定します。
/// </summary>
public bool isFile() {
throw new NotImplementedException();
}
/// <summary>
/// この抽象パス名が示すファイルが隠しファイルかどうかを判定します。
/// </summary>
public bool isHidden() {
throw new NotImplementedException();
}
/// <summary>
/// この抽象パス名が示すファイルが最後に変更された時刻を返します。
/// </summary>
public long lastModified() {
System.IO.FileInfo f = new System.IO.FileInfo( m_path );
return f.LastWriteTimeUtc.Ticks;
}
/// <summary>
/// この抽象パス名に指定されているファイルの長さを返します。
/// </summary>
public long length() {
System.IO.FileInfo f = new System.IO.FileInfo( m_path );
return f.Length;
}
/// <summary>
/// この抽象パス名が示すディレクトリにあるファイルおよびディレクトリを示す文字列の配列を返します。
/// </summary>
public string[] list() {
List<string> list = new List<string>();
list.AddRange( System.IO.Directory.GetDirectories( m_path ) );
list.AddRange( System.IO.Directory.GetFiles( m_path ) );
return list.ToArray();
}
/// <summary>
/// この抽象パス名が示すディレクトリにあるファイルおよびディレクトリの中で、指定されたフィルタの基準を満たすものの文字列の配列を返します。
/// </summary>
public string[] list( FilenameFilter filter ) {
List<string> ret = new List<string>();
foreach ( string s in list() ) {
if ( filter.accept( this, s ) ) {
ret.Add( s );
}
}
return ret.ToArray();
}
/// <summary>
/// この抽象パス名が示すディレクトリ内のファイルを示す抽象パス名の配列を返します。
/// </summary>
public File[] listFiles() {
string[] files = System.IO.Directory.GetFiles( m_path );
File[] ret = new File[files.Length];
for ( int i = 0; i < files.Length; i++ ) {
ret[i] = new File( m_path + separator + files[i] );
}
return ret;
}
/// <summary>
/// この抽象パス名が示すディレクトリにあるファイルおよびディレクトリの中で、指定されたフィルタの基準を満たすものの抽象パス名の配列を返します。
/// </summary>
public File[] listFiles( FileFilter filter ) {
List<File> ret = new List<File>();
foreach ( string s in list() ) {
File f = new File( m_path + separator + s );
if ( filter.accept( f ) ) {
ret.Add( f );
}
}
return ret.ToArray();
}
/// <summary>
/// この抽象パス名が示すディレクトリにあるファイルおよびディレクトリの中で、指定されたフィルタの基準を満たすものの抽象パス名の配列を返します。
/// </summary>
public File[] listFiles( FilenameFilter filter ) {
List<File> ret = new List<File>();
foreach ( string s in list() ) {
if ( filter.accept( this, s ) ) {
File f = new File( m_path + separator + s );
ret.Add( f );
}
}
return ret.ToArray();
}
/// <summary>
/// 有効なファイルシステムのルートをリスト表示します。
/// </summary>
public static File[] listRoots() {
throw new NotImplementedException();
}
/// <summary>
/// この抽象パス名が示すディレクトリを生成します。
/// </summary>
public bool mkdir() {
try {
System.IO.Directory.CreateDirectory( m_path );
return true;
} catch {
}
return false;
}
/// <summary>
/// この抽象パス名が示すディレクトリを生成します。
/// </summary>
public bool mkdirs() {
throw new NotImplementedException();
}
/// <summary>
/// この抽象パス名が示すファイルの名前を変更します。
/// </summary>
public bool renameTo( File dest ) {
try {
System.IO.File.Replace( m_path, dest.m_path, m_path + "BAK" );
return true;
} catch {
}
return false;
}
/// <summary>
/// この抽象パス名に所有者の実行権を設定する簡易メソッドです。
/// </summary>
public bool setExecutable( bool executable ) {
throw new NotImplementedException();
}
/// <summary>
/// この抽象パス名に所有者または全員の実行権を設定します。
/// </summary>
public bool setExecutable( bool executable, bool ownerOnly ) {
throw new NotImplementedException();
}
/// <summary>
/// この抽象パス名が示すファイルまたはディレクトリが変更された時刻を設定します。
/// </summary>
public bool setLastModified( long time ) {
try {
System.IO.FileInfo f = new System.IO.FileInfo( m_path );
f.LastWriteTimeUtc = new DateTime( time );
return true;
} catch {
}
return false;
}
/// <summary>
/// この抽象パス名に所有者の読み取り権を設定する簡易メソッドです。
/// </summary>
public bool setReadable( bool readable ) {
throw new NotImplementedException();
}
/// <summary>
/// この抽象パス名に所有者または全員の読み取り権を設定します。
/// </summary>
public bool setReadable( bool readable, bool ownerOnly ) {
throw new NotImplementedException();
}
/// <summary>
/// この抽象パス名が示すファイルまたはディレクトリにマークを設定し、読み込みオペレーションだけが許可されるようにします。
/// </summary>
public bool setReadOnly() {
throw new NotImplementedException();
}
/// <summary>
/// この抽象パス名に所有者の書き込み権を設定する簡易メソッドです。
/// </summary>
public bool setWritable( bool writable ) {
throw new NotImplementedException();
}
/// <summary>
/// この抽象パス名に所有者または全員の書き込み権を設定します。
/// </summary>
public bool setWritable( bool writable, bool ownerOnly ) {
throw new NotImplementedException();
}
/// <summary>
/// この抽象パス名のパス名文字列を返します。
/// </summary>
public string toString() {
return m_path;
}
}
public interface FilenameFilter {
bool accept( File dir, String name );
}
public interface FileFilter {
bool accept( File filepath );
}
}
#endif*/

66
bocoree/Graphics.cs Normal file
View File

@@ -0,0 +1,66 @@
#if !JAVA
/*
* Graphics.cs
* Copyright (c) 2009 kbinani
*
* This file is part of bocoree.
*
* bocoree is free software; you can redistribute it and/or
* modify it under the terms of the BSD License.
*
* bocoree is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
using System;
using System.Drawing;
namespace bocoree {
public class Graphics2D {
private System.Drawing.Graphics m_graphics;
private Color m_color = Color.Black;
private Pen m_pen = Pens.Black;
private SolidBrush m_brush = new SolidBrush( Color.Black );
public Graphics2D( System.Drawing.Graphics g ) {
m_graphics = g;
}
public void clearRect( int x, int y, int width, int height ) {
m_graphics.FillRectangle( System.Drawing.Brushes.White, x, y, width, height );
}
public void drawLine( int x1, int y1, int x2, int y2 ) {
m_graphics.DrawLine( m_pen, x1, y1, x2, y2 );
}
public void drawRect( int x, int y, int width, int height ) {
m_graphics.DrawRectangle( m_pen, x, y, width, height );
}
public void fillRect( int x, int y, int width, int height ) {
m_graphics.FillRectangle( m_brush, x, y, width, height );
}
public void drawOval( int x, int y, int width, int height ) {
m_graphics.DrawEllipse( m_pen, x, y, width, height );
}
public void fillOval( int x, int y, int width, int height ) {
m_graphics.FillRectangle( m_brush, x, y, width, height );
}
public void setColor( System.Drawing.Color c ) {
m_color = c;
m_pen.Color = c;
m_brush.Color = c;
}
public Color getColor() {
return m_color;
}
}
}
#endif

16
bocoree/IEventHandler.cs Normal file
View File

@@ -0,0 +1,16 @@
/*
* IEventHandler.cs
* Copyright (c) 2009 kbinani
*
* This file is part of bocoree.
*
* bocoree is free software; you can redistribute it and/or
* modify it under the terms of the BSD License.
*
* bocoree is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
#if JAVA
//INCLUDE ..\BuildJavaUI\src\org\kbinani\IEventHandler.java
#endif

24
bocoree/Iterator.cs Normal file
View File

@@ -0,0 +1,24 @@
#if !JAVA
/*
* Iterator.cs
* Copyright (c) 2009 kbinani
*
* This file is part of bocoree.
*
* bocoree is free software; you can redistribute it and/or
* modify it under the terms of the BSD License.
*
* bocoree is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
namespace bocoree.java.util {
public interface Iterator {
bool hasNext();
object next();
void remove();
}
}
#endif

60
bocoree/ListIterator.cs Normal file
View File

@@ -0,0 +1,60 @@
#if !JAVA
/*
* ListIterator.cs
* Copyright (c) 2009 kbinani
*
* This file is part of bocoree.
*
* bocoree is free software; you can redistribute it and/or
* modify it under the terms of the BSD License.
*
* bocoree is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
using System;
using System.Collections.Generic;
namespace bocoree.java.util {
public class ListIterator<T> : Iterator {
private List<T> m_list;
private int m_pos;
public ListIterator( Vector<T> list ) {
m_list = new List<T>();
int c = list.size();
for( int i = 0; i < c; i++ ){
m_list.Add( list.get( i ) );
}
m_pos = -1;
}
public ListIterator( List<T> list ) {
m_list = list;
m_pos = -1;
}
public Boolean hasNext() {
if ( m_list != null && 0 <= m_pos + 1 && m_pos + 1 < m_list.Count ) {
return true;
} else {
return false;
}
}
public Object next() {
if ( m_list == null ) {
return null;
}
m_pos++;
return m_list[m_pos];
}
public void remove() {
m_list.RemoveAt( m_pos );
}
}
}
#endif

1574
bocoree/PortUtil.cs Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,25 @@
/*
* AssemblyInfo.cs
* Copyright (c) 2008-2009 kbinani
*
* This file is part of bocoree.
*
* bocoree is free software; you can redistribute it and/or
* modify it under the terms of the BSD License.
*
* bocoree is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
[assembly: System.Reflection.AssemblyTitle( "bocoree" )]
[assembly: System.Reflection.AssemblyDescription( "" )]
[assembly: System.Reflection.AssemblyConfiguration( "" )]
[assembly: System.Reflection.AssemblyCompany( "Boare" )]
[assembly: System.Reflection.AssemblyProduct( "bocoree" )]
[assembly: System.Reflection.AssemblyCopyright( "Copyright © 2008-2009" )]
[assembly: System.Reflection.AssemblyTrademark( "" )]
[assembly: System.Reflection.AssemblyCulture( "" )]
[assembly: System.Runtime.InteropServices.ComVisible( false )]
[assembly: System.Runtime.InteropServices.Guid( "9ea2c6a6-558e-4c38-9961-096e964d085e" )]
[assembly: System.Reflection.AssemblyVersion( "1.0.0.0" )]
[assembly: System.Reflection.AssemblyFileVersion( "1.0.0" )]

View File

@@ -0,0 +1,78 @@
#if !JAVA
/*
* RandomAccessFile.cs
* Copyright (c) 2009 kbinani
*
* This file is part of bocoree.
*
* bocoree is free software; you can redistribute it and/or
* modify it under the terms of the BSD License.
*
* bocoree is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
using System;
namespace bocoree.java.io {
public class RandomAccessFile {
private System.IO.FileStream m_stream;
public RandomAccessFile( String name, String mode ) {
if( mode == "r" ){
m_stream = new System.IO.FileStream( name, System.IO.FileMode.Open, System.IO.FileAccess.Read );
} else if ( mode == "rw" ) {
m_stream = new System.IO.FileStream( name, System.IO.FileMode.OpenOrCreate, System.IO.FileAccess.ReadWrite );
} else {
throw new ArgumentException( "mode: \"" + mode + "\" is not supported", "mode" );
}
}
public void close() {
m_stream.Close();
}
public long length() {
return m_stream.Length;
}
public int read() {
return m_stream.ReadByte();
}
public int read( byte[] b ) {
return m_stream.Read( b, 0, b.Length );
}
public int read( byte[] b, int off, int len ) {
return m_stream.Read( b, off, len );
}
public void seek( long pos ) {
m_stream.Seek( pos, System.IO.SeekOrigin.Begin );
}
public void write( byte[] b ) {
m_stream.Write( b, 0, b.Length );
}
public void write( byte[] b, int off, int len ) {
m_stream.Write( b, off, len );
}
public void write( int b ) {
m_stream.WriteByte( (byte)b );
}
public void writeByte( int b ) {
write( b );
}
public long getFilePointer() {
return m_stream.Position;
}
}
}
#endif

108
bocoree/TreeMap.cs Normal file
View File

@@ -0,0 +1,108 @@
#if !JAVA
/*
* TreeMap.cs
* Copyright (c) 2009 kbinani
*
* This file is part of bocoree.
*
* bocoree is free software; you can redistribute it and/or
* modify it under the terms of the BSD License.
*
* bocoree is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
//#define DICTIONARY_TEST
using System;
using System.Collections.Generic;
using System.Runtime.Serialization;
namespace bocoree {
[Serializable]
#if DICTIONARY_TEST
public class TreeMap<K, V> {
public V remove( Object key ) {
return default( V );
}
public Vector<K> keySet() {
return null;
}
public V get( K key ) {
return default( V );
}
public V put( K key, V value ) {
return default( V );
}
public bool containsKey( Object key ) {
return false;
}
public void clear() {
}
public int size() {
return 0;
}
}
#else
public class TreeMap<K, V> : Dictionary<K, V> {
public TreeMap()
: base() {
}
protected TreeMap( SerializationInfo info, StreamingContext context )
: base( info, context ) {
}
public V remove( Object key ) {
K k = (K)key;
if ( base.ContainsKey( k ) ) {
V old = base[k];
base.Remove( k );
return old;
} else {
base.Remove( k );
return default( V );
}
}
public Vector<K> keySet() {
return new Vector<K>( base.Keys );
}
public V get( K key ){
return base[key];
}
public int size(){
return base.Count;
}
public bool containsKey( Object key ) {
return base.ContainsKey( (K)key );
}
public void clear() {
base.Clear();
}
public V put( K key, V value ) {
if ( base.ContainsKey( key ) ){
V old = base[key];
base[key] = value;
return old;
} else {
base.Add( key, value );
return default( V );
}
}
}
#endif
}
#endif

91
bocoree/ValuePair.cs Normal file
View File

@@ -0,0 +1,91 @@
/*
* ValuePair.cs
* Copyright (c) 2009 kbinani
*
* This file is part of bocoree.
*
* bocoree is free software; you can redistribute it and/or
* modify it under the terms of the BSD License.
*
* bocoree is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
#if JAVA
package org.kbinani;
#else
using System;
namespace bocoree {
#endif
#if JAVA
public class ValuePair<K extends Comparable<K>, V> implements Comparable<ValuePair<K, V>>{
#else
public class ValuePair<K, V> : IComparable<ValuePair<K, V>> where K : IComparable {
#endif
private K m_key;
private V m_value;
public ValuePair() {
}
public ValuePair( K key_, V value_ ) {
m_key = key_;
m_value = value_;
}
public int compareTo( ValuePair<K, V> item ) {
#if JAVA
return m_key.compareTo( item.m_key );
#else
return m_key.CompareTo( item.m_key );
#endif
}
#if !JAVA
public int CompareTo( ValuePair<K, V> item ){
return compareTo( item );
}
#endif
public K getKey() {
return m_key;
}
public void setKey( K value ) {
m_key = value;
}
public V getValue() {
return m_value;
}
public void setValue( V v ) {
m_value = v;
}
#if !JAVA
public K Key {
get {
return getKey();
}
set {
setKey( value );
}
}
public V Value {
get {
return getValue();
}
set {
setValue( value );
}
}
#endif
}
#if !JAVA
}
#endif

172
bocoree/Vector.cs Normal file
View File

@@ -0,0 +1,172 @@
#if !JAVA
/*
* Vector.cs
* Copyright (c) 2009 kbinani
*
* This file is part of bocoree.
*
* bocoree is free software; you can redistribute it and/or
* modify it under the terms of the BSD License.
*
* bocoree is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
//#define VECTOR_TEST
using System;
using System.Collections.Generic;
using System.Runtime.Serialization;
namespace bocoree.java.util {
[Serializable]
#if VECTOR_TEST
public class Vector<T> {
public Vector( int capacity ) {
}
public Vector( Vector<T> array ) {
}
public Vector( T[] array ){
}
public Vector(){
}
public void addAll( T[] array ) {
}
public void addAll( Vector<T> array ) {
}
public void insertElementAt( T obj, int index ) {
}
public void removeElementAt( int index ) {
}
public int size() {
return 0;
}
public T get( int index ) {
return default( T );
}
public void set( int index, T value ) {
}
public Object[] toArray() {
return null;
}
public T[] toArray( T[] array ) {
return null;
}
public Iterator iterator() {
return null;
}
public void add( T obj ) {
}
public void Add( T obj ) {
}
public bool contains( T obj ) {
return false;
}
public void clear() {
}
}
#else
public class Vector<T> : List<T> {
public Vector( ICollection<T> list ) :
base( list ) {
}
public Vector( int capacity )
: base( capacity ) {
}
public Vector( Vector<T> array )
: base( array.toArray( new T[]{} ) ){
}
public void addAll( Vector<T> array ) {
base.AddRange( array );
}
public int indexOf( T obj ) {
return base.IndexOf( obj );
}
public void insertElementAt( T obj, int index ){
base.Insert( index, obj );
}
public bool removeElement( T obj ) {
return base.Remove( obj );
}
public void removeElementAt( int index ){
base.RemoveAt( index );
}
public Vector()
: base() {
}
public void clear(){
base.Clear();
}
public bool contains( T obj ){
return base.Contains( obj );
}
public void add( T obj ) {
base.Add( obj );
}
public int size() {
return base.Count;
}
public T get( int index ) {
return base[index];
}
public void set( int index, T value ) {
base[index] = value;
}
public Object[] toArray() {
int c = size();
Object[] ret = new Object[c];
for( int i = 0; i < c; i++ ){
ret[i] = base[i];
}
return ret;
}
public T[] toArray( T[] array ) {
int c = size();
T[] ret = new T[c];
for( int i = 0; i < c; i++ ){
ret[i] = base[i];
}
return ret;
}
public Iterator iterator() {
return new ListIterator<T>( this );
}
}
#endif
}
#endif

288
bocoree/XmlMember.cs Normal file
View File

@@ -0,0 +1,288 @@
#if JAVA
/*
* XmlMember.java
* Copyright (c) 2009 kbinani
*
* This file is part of org.kbinani.util.
*
* org.kbinani.util is free software; you can redistribute it and/or
* modify it under the terms of the BSD License.
*
* org.kbinani.util is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
package org.kbinani.xml;
import java.util.*;
import java.lang.reflect.*;
public class XmlMember{
private String m_name;
private Method m_getter = null;
private Method m_setter = null;
private Field m_field = null;
private Class m_type = null;
private Method m_elementname_getter = null;
private Method m_isignored_getter = null;
private XmlMember(){
}
public String getName(){
return m_name;
}
public Class getType(){
return m_type;
}
public static XmlMember[] extractMembers( Class t ){
XmlSerializable descripter = null;
try
{
Object tinstance = t.newInstance();
if( tinstance instanceof XmlSerializable )
{
descripter = (XmlSerializable)tinstance;
}
}
catch( Exception ex )
{
System.out.println( "XmlMember#extractMembers; ex=" + ex );
}
//Method elementname_getter = null;
//Method isignored_getter = null;
/*try{
elementname_getter = t.getMethod( "getXmlElementName", String.class );
int m = elementname_getter.getModifiers();
if( !Modifier.isPublic( m ) || !Modifier.isStatic( m ) ){
elementname_getter = null;
}
}catch( Exception ex ){
elementname_getter = null;
}
try{
isignored_getter = t.getMethod( "isXmlIgnored", String.class );
int m = isignored_getter.getModifiers();
if( !Modifier.isPublic( m ) || !Modifier.isStatic( m ) ){
isignored_getter = null;
}
}catch( Exception ex ){
isignored_getter = null;
}*/
Vector<XmlMember> members = new Vector<XmlMember>();
// superクラスのプロパティを取得
if( t.getSuperclass() != null ){
XmlMember[] super_members = extractMembers( t.getSuperclass() );
for( XmlMember xm : super_members ){
members.add( xm );
}
}
Vector<String> props = new Vector<String>();
for( Field f : t.getDeclaredFields() ){
int m = f.getModifiers();
if( !Modifier.isPublic( m ) || Modifier.isStatic( m ) ){
continue;
}
props.add( f.getName() );
}
// get, set, isで始まるメソッド名を持つ、publicでstaticでないメソッドを抽出
for( Method method : t.getDeclaredMethods() ){
int m = method.getModifiers();
if( !Modifier.isPublic( m ) || Modifier.isStatic( m ) ){
continue;
}
String name = method.getName();
if( name.startsWith( "get" ) ){
name = name.substring( 3 );
if( !props.contains( name ) ){
props.add( name );
}
}else if( name.startsWith( "set" ) ){
name = name.substring( 3 );
if( !props.contains( name ) ){
props.add( name );
}
}else if( name.startsWith( "is" ) ){
name = name.substring( 2 );
if( !props.contains( name ) ){
props.add( name );
}
}
}
for( String name : props ){
boolean ignore = false;
if( descripter != null ){
try{
ignore = descripter.isXmlIgnored( name );
}catch( Exception ex ){
}
}
if( ignore ){
continue;
}
String xmlname = name;
if( descripter != null ){
try{
xmlname = descripter.getXmlElementName( name );
}catch( Exception ex ){
}
}
XmlMember xm = extract( t, name );
if( xm != null ){
xm.m_name = xmlname;
members.add( xm );
}
}
return members.toArray( new XmlMember[]{} );
}
public static XmlMember extract( Class cls, String property_name ){
for( Field f : cls.getDeclaredFields() ){
int m = f.getModifiers();
if( !Modifier.isPublic( m ) || Modifier.isStatic( m ) ){
continue;
}
String name = f.getName();
if( name.equals( property_name ) ){
XmlMember xm = new XmlMember();
xm.m_name = property_name;
xm.m_field = f;
xm.m_getter = null;
xm.m_setter = null;
xm.m_type = f.getType();
return xm;
}
}
// get, set, isで始まるメソッド名を持つ、publicでstaticでないメソッドを抽出
Method getter = null;
Method setter = null;
Class prop_type = null;
for( Method method : cls.getDeclaredMethods() ){
int m = method.getModifiers();
if( !Modifier.isPublic( m ) || Modifier.isStatic( m ) ){
continue;
}
String name = method.getName();
Class ret_type = method.getReturnType();
if( name.startsWith( "set" ) && setter == null ){
if( !name.substring( 3 ).equals( property_name ) ){
continue;
}
// setterなので、戻り値の型はvoid
if( !ret_type.equals( Void.TYPE ) && !ret_type.equals( Void.class ) ){
continue;
}
// 引数の個数は1
Class[] args = method.getParameterTypes();
if( args.length != 1 ){
continue;
}
// 探している型と合致するか
if( prop_type == null ){
prop_type = args[0];
}else{
if( !prop_type.equals( args[0] ) ){
continue;
}
}
setter = method;
}else if( name.startsWith( "is" ) && getter == null ){
if( !name.substring( 2 ).equals( property_name ) ){
continue;
}
if( setter != null ){
// setterが既に見つかっていて、ret_typeがboolean/Booleanじゃない場合
if( !ret_type.equals( Boolean.TYPE ) || !ret_type.equals( Boolean.class ) ){
return null;
}
}
// isで始まるgetterは、戻り値の型がBoolean or boolean
if( !ret_type.equals( Boolean.TYPE ) && !ret_type.equals( Boolean.class ) ){
continue;
}
// 引数の個数は0
Class[] args = method.getParameterTypes();
if( args.length != 0 ){
continue;
}
if( prop_type == null ){
prop_type = ret_type;
}else{
if( !prop_type.equals( ret_type ) ){
continue;
}
}
getter = method;
}else if( name.startsWith( "get" ) && getter == null ){
if( !name.substring( 3 ).equals( property_name ) ){
continue;
}
// 引数の個数は0
Class[] args = method.getParameterTypes();
if( args.length != 0 ){
continue;
}
if( prop_type == null ){
prop_type = ret_type;
}else{
if( !prop_type.equals( ret_type ) ){
continue;
}
}
getter = method;
}
if( getter != null && setter != null ){
break;
}
}
if( getter != null && setter != null ){
XmlMember xm = new XmlMember();
xm.m_name = property_name;
xm.m_field = null;
xm.m_getter = getter;
xm.m_setter = setter;
xm.m_type = prop_type;
return xm;
}else{
return null;
}
}
public Object get( Object obj ){
try{
if( m_field != null ){
return m_field.get( obj );
}else{
return m_getter.invoke( obj );
}
}catch( Exception ex ){
System.out.println( "org.kbinani.util.XmlMember.get; ex=" + ex );
return null;
}
}
public void set( Object obj, Object value ){
try{
if( m_field != null ){
m_field.set( obj, value );
}else{
m_setter.invoke( obj, value );
}
}catch( Exception ex ){
System.out.println( "org.kbinani.util.XmlMember.set; ex=" + ex );
}
}
}
#endif

109
bocoree/XmlPoint.cs Normal file
View File

@@ -0,0 +1,109 @@
/*
* XmlPoint.cs
* Copyright (c) 2009 kbinani
*
* This file is part of bocoree.
*
* bocoree is free software; you can redistribute it and/or
* modify it under the terms of the BSD License.
*
* bocoree is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
#if JAVA
package org.kbinani;
import java.awt.*;
#else
using System.Xml.Serialization;
using bocoree.java.awt;
namespace bocoree
{
#endif
public class XmlPoint
{
#if !JAVA
[XmlIgnore]
#endif
public int x;
#if !JAVA
[XmlIgnore]
#endif
public int y;
public XmlPoint()
{
}
public XmlPoint( int x_, int y_ )
{
x = x_;
y = y_;
}
public XmlPoint( Point p )
{
x = p.x;
y = p.y;
}
public Point toPoint()
{
return new Point( x, y );
}
public int getX()
{
return x;
}
public void setX( int value )
{
x = value;
}
public int getY()
{
return y;
}
public void setY( int value )
{
y = value;
}
#if !JAVA
public int X
{
get
{
return getX();
}
set
{
setX( value );
}
}
public int Y
{
get
{
return getY();
}
set
{
setY( value );
}
}
#endif
}
#if !JAVA
}
#endif

138
bocoree/XmlRectangle.cs Normal file
View File

@@ -0,0 +1,138 @@
/*
* XmlRectangle.cs
* Copyright (c) 2009 kbinani
*
* This file is part of bocoree.
*
* bocoree is free software; you can redistribute it and/or
* modify it under the terms of the BSD License.
*
* bocoree is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
#if JAVA
package org.kbinani;
import java.awt.*;
#else
using System.Xml.Serialization;
using bocoree.java.awt;
namespace bocoree{
#endif
public class XmlRectangle{
#if !JAVA
[XmlIgnore]
#endif
public int x;
#if !JAVA
[XmlIgnore]
#endif
public int y;
#if !JAVA
[XmlIgnore]
#endif
public int width;
#if !JAVA
[XmlIgnore]
#endif
public int height;
public XmlRectangle()
{
}
public XmlRectangle( int x_, int y_, int width_, int height_ ){
x = x_;
y = y_;
width = width_;
height = height_;
}
public XmlRectangle( Rectangle rc ) {
x = rc.x;
y = rc.y;
width = rc.width;
height = rc.height;
}
public Rectangle toRectangle() {
return new Rectangle( x, y, width, height );
}
public int getX() {
return x;
}
public void setX( int value ) {
x = value;
}
public int getY() {
return y;
}
public void setY( int value ) {
y = value;
}
public int getWidth() {
return width;
}
public void setWidth( int value ) {
width = value;
}
public int getHeight() {
return height;
}
public void setHeight( int value ) {
height = value;
}
#if !JAVA
public int X{
get{
return getX();
}
set{
setX( value );
}
}
public int Y{
get{
return getY();
}
set{
setY( value );
}
}
public int Width{
get{
return getWidth();
}
set{
setWidth( value );
}
}
public int Height{
get{
return getHeight();
}
set{
setHeight( value );
}
}
#endif
}
#if !JAVA
}
#endif

View File

@@ -0,0 +1,31 @@
/*
* XmlSerializable.cs
* Copyright (c) 2009 kbinani
*
* This file is part of bocoree.
*
* bocoree is free software; you can redistribute it and/or
* modify it under the terms of the BSD License.
*
* bocoree is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
#if JAVA
package org.kbinani.xml;
#else
using System;
namespace bocoree.xml {
using boolean = System.Boolean;
#endif
public interface XmlSerializable {
String getXmlElementName( String name );
boolean isXmlIgnored( String name );
String getGenericTypeName( String name );
}
#if !JAVA
}
#endif

View File

@@ -0,0 +1,272 @@
#if !JAVA
/*
* XmlSerializeWithDescription.cs
* Copyright (c) 2009 kbinani
*
* This file is part of bocoree.
*
* bocoree is free software; you can redistribute it and/or
* modify it under the terms of the BSD License.
*
* bocoree is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
using System.Reflection;
using System.IO;
namespace bocoree
{
/// <summary>
/// フィールド、またはプロパティの概要を格納するattribute
/// </summary>
[AttributeUsage( AttributeTargets.Field | AttributeTargets.Property, AllowMultiple = false )]
public class XmlItemDescription : Attribute
{
private string m_value = "";
private string m_attribute_name = "description";
public XmlItemDescription( string Value )
{
m_value = Value;
}
public XmlItemDescription( string AttributeName, string Value )
{
m_value = Value;
m_attribute_name = AttributeName;
}
public string AttributeName
{
get
{
return m_attribute_name;
}
}
public string Value
{
get
{
return m_value;
}
}
}
/// <summary>
/// フィールドおよびプロパティを、XmlItemDescription属性の文字列を付加しながらXmlシリアライズする
/// </summary>
public class XmlSerializeWithDescription
{
private XmlTextWriter m_writer;
private Type m_type;
public XmlSerializeWithDescription()
{
}
public void Serialize( Stream stream, object obj )
{
m_writer = new XmlTextWriter( stream, null );
m_writer.Formatting = Formatting.Indented;
m_writer.Indentation = 4;
m_writer.IndentChar = ' ';
m_writer.WriteStartDocument();
m_writer.WriteStartElement( obj.GetType().Name );
PrintItemRecurse( obj );
m_writer.WriteEndElement();
m_writer.WriteEndDocument();
m_writer.Flush();
}
private void PrintItemRecurse( object obj )
{
Type t = obj.GetType();
if ( !TryWriteValueType( obj ) )
{
if ( t.IsGenericType )
{
List<int> f = new List<int>();
Type list_type = f.GetType().GetGenericTypeDefinition();
if ( t.GetGenericTypeDefinition().Equals( list_type ) )
{
Type[] gen = t.GetGenericArguments();
if ( gen.Length == 1 )
{
PropertyInfo count_property = t.GetProperty( "Count", typeof( int ) );
int count = (int)count_property.GetValue( obj, new object[] { } );
Type returntype = gen[0];
MethodInfo indexer = t.GetMethod( "get_Item", new Type[] { typeof( int ) } );
string name = "";
if ( returntype.Equals( typeof( Boolean ) ) )
{
name = "boolean";
}
else if ( returntype.Equals( typeof( DateTime ) ) )
{
name = "dateTime";
}
else if ( returntype.Equals( typeof( Decimal ) ) )
{
name = "decimal";
}
else if ( returntype.Equals( typeof( Double ) ) )
{
name = "double";
}
else if ( returntype.Equals( typeof( Int32 ) ) )
{
name = "int";
}
else if ( returntype.Equals( typeof( Int64 ) ) )
{
name = "long";
}
else if ( returntype.Equals( typeof( Single ) ) )
{
name = "float";
}
else if ( returntype.Equals( typeof( String ) ) )
{
name = "string";
}
else if ( returntype.IsEnum )
{
name = returntype.Name;
}
if ( indexer != null && name != "" )
{
for ( int i = 0; i < count; i++ )
{
object value = indexer.Invoke( obj, new object[] { i } );
m_writer.WriteStartElement( name );
TryWriteValueType( value );
m_writer.WriteEndElement();
}
}
}
}
}
else
{
foreach ( FieldInfo fi in t.GetFields() )
{
if ( fi.IsPrivate || fi.IsStatic )
{
continue;
}
object[] attr = fi.GetCustomAttributes( typeof( XmlItemDescription ), false );
XmlItemDescription xid = null;
if ( attr.Length > 0 )
{
xid = (XmlItemDescription)attr[0];
}
WriteContents( fi.Name, fi.GetValue( obj ), xid );
}
foreach ( PropertyInfo pi in t.GetProperties() )
{
if ( !pi.CanRead | !pi.CanWrite )
{
continue;
}
if ( !pi.GetSetMethod().IsPublic | !pi.GetGetMethod().IsPublic )
{
continue;
}
if ( pi.GetSetMethod().IsStatic | pi.GetGetMethod().IsStatic )
{
continue;
}
object[] attr = pi.GetCustomAttributes( typeof( XmlItemDescription ), false );
XmlItemDescription xid = null;
if ( attr.Length > 0 )
{
xid = (XmlItemDescription)attr[0];
}
WriteContents( pi.Name, pi.GetValue( obj, new object[] { } ), xid );
}
}
}
}
private bool TryWriteValueType( object obj )
{
Type t = obj.GetType();
if ( t.Equals( typeof( Boolean ) ) )
{
m_writer.WriteValue( (Boolean)obj );
return true;
}
else if ( t.Equals( typeof( DateTime ) ) )
{
m_writer.WriteValue( (DateTime)obj );
return true;
}
else if ( t.Equals( typeof( Decimal ) ) )
{
m_writer.WriteValue( (Decimal)obj );
return true;
}
else if ( t.Equals( typeof( Double ) ) )
{
m_writer.WriteValue( (Double)obj );
return true;
}
else if ( t.Equals( typeof( Int32 ) ) )
{
m_writer.WriteValue( (Int32)obj );
return true;
}
else if ( t.Equals( typeof( Int64 ) ) )
{
m_writer.WriteValue( (Int64)obj );
return true;
}
else if ( t.Equals( typeof( Single ) ) )
{
m_writer.WriteValue( (Single)obj );
return true;
}
else if ( t.Equals( typeof( String ) ) )
{
m_writer.WriteString( (String)obj );
return true;
}
else if ( t.IsEnum )
{
string val = Enum.GetName( t, obj );
m_writer.WriteString( val );
return true;
}
else
{
return false;
}
}
private void WriteContents( string name, object next_obj, XmlItemDescription xid )
{
m_writer.WriteStartElement( name );
if ( xid != null )
{
m_writer.WriteAttributeString( xid.AttributeName, xid.Value );
}
PrintItemRecurse( next_obj );
m_writer.WriteEndElement();
}
private void test()
{
System.Xml.Serialization.XmlSerializer xs = new System.Xml.Serialization.XmlSerializer( typeof( int ) );
}
}
}
#endif

431
bocoree/XmlSerializer.cs Normal file
View File

@@ -0,0 +1,431 @@
/*
* XmlSerializer.cs
* Copyright (c) 2009 kbinani
*
* This file is part of bocoree.
*
* bocoree is free software; you can redistribute it and/or
* modify it under the terms of the BSD License.
*
* bocoree is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
#if JAVA
package org.kbinani.xml;
import java.io.*;
import java.util.*;
import java.lang.reflect.*;
import javax.xml.parsers.*;
import javax.xml.transform.*;
import javax.xml.transform.dom.*;
import javax.xml.transform.stream.*;
import org.w3c.dom.*;
/**
* .NETのSystem.Xml.Serialization.XmlSerializerと同じ書式で入出力するためのXMLシリアライザ<br>
* シリアライズしたいクラスには,以下のメソッドを実装しておく必要があります.<br>
* <dl>
* <dt>getXmlElementNameメソッド</dt>
* <dd>フィールド名やgetter/setter名からXMLのード名を調べる</dd>
* <dt>isXmlIgnoredメソッド</dt>
* <dd>アイテムをXMLに出力するかどうかを決める</dd>
* <dt>getGenericTypeNameメソッド</dt>
* <dd>アイテムが総称型を含むクラスの場合に,その総称型名を調べる</dd>
* </dl>
* <pre>
* public class Test2{
public float value = 1.0f;
private boolean m_b = true;
private int m_i = 2;
public Vector<Integer> list = new Vector<Integer>();
public boolean isHoge(){
return m_b;
}
public void setHoge( boolean value ){
m_b = value;
}
public int getInteger(){
return m_i;
}
public void setInteger( int value ){
m_i = value;
}
public static String getXmlElementName( String name ){
if( name.equals( "value" ) ){
return "Value";
}else if( name.equals( "list" ) ){
return "List";
}
return name;
}
public static boolean isXmlIgnored( String name ){
if( name.equals( "Integer" ) ){
return true;
}
return false;
}
public static String getGenericTypeName( String name ){
if( name.equals( "list" ) ){
return "java.lang.Integer";
}
return "";
}
}
* </pre>
* このように実装しておくとだいたい以下のようなXMLの入出力が可能になります
* <pre>
&lt;Test2&gt;
&lt;Value&gt;1.0&lt;/Value&gt;
&lt;Hoge&gt;true&lt;/Hoge&gt;
&lt;List&gt;
&lt;int&gt;1&lt;/int&gt;
&lt;int&gt;2&lt;/int&gt;
&lt;/List&gt;
&lt;/Test2&gt;
* </pre>
*/
public class XmlSerializer{
private Document m_document;
private Class m_class;
private boolean m_static_mode = false;
private boolean m_indent = true;
private int m_indent_width = 2;
public boolean isIndent(){
return m_indent;
}
public void setIndent( boolean value ){
m_indent = value;
}
public int getIndentWidth(){
return m_indent_width;
}
public void setIndentWidth( int value ){
if( value < 0 ){
m_indent_width = 0;
}else{
m_indent_width = value;
}
}
public XmlSerializer( Class cls ){
m_class = cls;
}
public Object deserialize( InputStream stream ){
try{
DocumentBuilderFactory fact = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = fact.newDocumentBuilder();
Document doc = builder.parse( stream );
Object ret = parseNode( m_class, null, doc.getDocumentElement() );
return ret;
}catch( Exception ex ){
System.out.println( "XmlSerializer.deserialize; ex=" + ex );
return null;
}
}
private Object parseNode( Class t, Class parent_class, Node node ){
NodeList childs = node.getChildNodes();
int numChild = childs.getLength();
Object obj;
String str = node.getTextContent() + "";
if( t.equals( Integer.TYPE ) || t.equals( Integer.class ) ){
return Integer.parseInt( str );
}else if( t.equals( Byte.TYPE ) || t.equals( Byte.class ) ){
return Byte.parseByte( str );
}else if( t.equals( Short.TYPE ) || t.equals( Short.class ) ){
return Short.parseShort( str );
}else if( t.equals( Float.TYPE ) || t.equals( Float.class ) ){
return Float.parseFloat( str );
}else if( t.equals( Double.TYPE ) || t.equals( Double.class ) ){
return Double.parseDouble( str );
}else if( t.equals( Boolean.TYPE ) || t.equals( Boolean.class ) ){
return Boolean.parseBoolean( str );
}else if( t.equals( String.class ) ){
return str;
}else if( t.isEnum() ){
return Enum.valueOf( t, str );
}else if( t.isArray() || t.equals( Vector.class ) ){
// Class tがstatic String getGenericTypeName( String )を実装しているかどうか調べる
Method method = null;
if( parent_class == null ){
return null;
}
for( Method m : parent_class.getDeclaredMethods() ){
if( !m.getName().equals( "getGenericTypeName" ) ){
continue;
}
int modifier = m.getModifiers();
if( !Modifier.isStatic( modifier ) || !Modifier.isPublic( modifier ) ){
continue;
}
if( !m.getReturnType().equals( String.class ) ){
continue;
}
Class[] args = m.getParameterTypes();
if( args.length != 1 ){
continue;
}
if( !args[0].equals( String.class ) ){
continue;
}
method = m;
break;
}
if( method == null ){
return null;
}
try{
String content_class_name = (String)method.invoke( null, node.getNodeName() );
Class content_class = Class.forName( content_class_name );
Vector<Object> vec = new Vector<Object>();
String element_name = getCliTypeName( content_class );
if( element_name.equals( "" ) ){
element_name = content_class.getSimpleName();
}
for( int i = 0; i < numChild; i++ ){
Node c = childs.item( i );
if( c.getNodeType() == Node.ELEMENT_NODE ){
Element f = (Element)c;
if( !f.getTagName().equals( element_name ) ){
continue;
}
vec.add( parseNode( content_class, t, c ) );
}
}
if( t.isArray() ){
int length = vec.size();
Object arr = Array.newInstance( content_class, length );
for( int i = 0; i < length; i++ ){
Array.set( arr, i, vec.get( i ) );
}
return arr;
}else if( t.equals( Vector.class ) ){
return vec;
}
}catch( Exception ex ){
System.out.println( "XmlSerializer.parseNode; ex=" + ex );
return null;
}
}
try{
obj = t.newInstance();
}catch( Exception ex ){
return null;
}
XmlMember[] members = XmlMember.extractMembers( t );
for( int i = 0; i < numChild; i++ ){
Node c = childs.item( i );
if( c.getNodeType() == Node.ELEMENT_NODE ) {
Element f = (Element)c;
String name = f.getTagName();
for( XmlMember xm : members ){
if( f.getTagName().equals( xm.getName() ) ) {
xm.set( obj, parseNode( xm.getType(), t, c ) );
break;
}
}
}
}
return obj;
}
public void serialize( OutputStream stream, Object obj ) throws TransformerConfigurationException,
ParserConfigurationException,
TransformerException,
IllegalAccessException{
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
DOMImplementation domImpl=builder.getDOMImplementation();
m_document = domImpl.createDocument( null, m_class.getSimpleName(), null );
Element root = m_document.getDocumentElement();
parseFieldAndProperty( m_class, obj, root );
TransformerFactory tfactory = TransformerFactory.newInstance();
Transformer transformer = tfactory.newTransformer();
if( m_indent ){
transformer.setOutputProperty( OutputKeys.INDENT, "yes" );
}
transformer.setOutputProperty( OutputKeys.METHOD, "xml" );
if( m_indent ){
transformer.setOutputProperty( "{http://xml.apache.org/xalan}indent-amount", "" + m_indent_width );
}
transformer.transform( new DOMSource( m_document ), new StreamResult( stream ) );
}
private void parseFieldAndProperty( Class t, Object obj, Element el ) throws IllegalAccessException{
if( obj == null ){
return;
}
XmlMember[] members = XmlMember.extractMembers( t );
for( XmlMember xm : members ){
String name = xm.getName();
Element el2 = m_document.createElement( name );
printItemRecurse( xm.getType(), xm.get( obj ), el2 );
el.appendChild( el2 );
}
}
private void printItemRecurse( Class t, Object obj, Element parent ) throws IllegalAccessException{
try{
if ( !tryWriteValueType( t, obj, parent ) ){
if( t.isArray() || t.equals( Vector.class ) ){
Object[] array = null;
if( t.isArray() ){
array = (Object[])obj;
}else if( t.equals( Vector.class ) ){
array = ((Vector)obj).toArray();
}
if( array != null ){
for( Object o : array ){
if( o != null ){
String name = getCliTypeName( o.getClass() );
if( name.equals( "" ) ){
name = o.getClass().getSimpleName();
}
Element element = m_document.createElement( name );
printItemRecurse( o.getClass(), o, element );
parent.appendChild( element );
}
}
}
}else{
parseFieldAndProperty( t, obj, parent );
}
}
}catch( Exception ex ){
System.out.println( "printItemRecurse; ex=" + ex );
}
}
private static String getCliTypeName( Class t ){
if( t.equals( Boolean.class ) || t.equals( Boolean.TYPE ) ){
return "bool";
}else if( t.equals( Double.class ) || t.equals( Double.TYPE ) ){
return "double";
}else if( t.equals( Integer.class ) || t.equals( Integer.TYPE ) ){
return "int";
}else if( t.equals( Long.class ) || t.equals( Long.TYPE ) ){
return "long";
}else if( t.equals( Short.class ) || t.equals( Short.TYPE ) ){
return "short";
}else if( t.equals( Float.class ) || t.equals( Float.TYPE ) ){
return "float";
}else if( t.equals( String.class ) ){
return "string";
}else{
return "";
}
}
private boolean tryWriteValueType( Class t, Object obj, Element element ){
if( t.equals( Boolean.class ) || t.equals( Boolean.TYPE ) ){
element.appendChild( m_document.createTextNode( (Boolean)obj + "" ) );
return true;
}else if( t.equals( Double.class ) || t.equals( Double.TYPE ) ){
element.appendChild( m_document.createTextNode( (Double)obj + "" ) );
return true;
}else if( t.equals( Integer.class ) || t.equals( Integer.TYPE ) ){
element.appendChild( m_document.createTextNode( (Integer)obj + "" ) );
return true;
}else if( t.equals( Long.class ) || t.equals( Long.TYPE ) ){
element.appendChild( m_document.createTextNode( (Long)obj + "" ) );
return true;
}else if( t.equals( Short.class ) || t.equals( Short.TYPE ) ){
element.appendChild( m_document.createTextNode( (Short)obj + "" ) );
return true;
}else if( t.equals( Float.class ) || t.equals( Float.TYPE ) ){
element.appendChild( m_document.createTextNode( (Float)obj + "" ) );
return true;
}else if( t.equals( String.class ) ){
if( obj == null ){
element.appendChild( m_document.createTextNode( "" ) );
}else{
element.appendChild( m_document.createTextNode( (String)obj ) );
}
return true;
}else if( t.isEnum() ){
if( obj == null ){
for( Field f : t.getDeclaredFields() ){
String name = f.getName();
if( !name.startsWith( "$" ) ){
element.appendChild( m_document.createTextNode( name ) );
break;
}
}
}else{
element.appendChild( m_document.createTextNode( obj + "" ) );
}
return true;
}else{
return false;
}
}
}
#else
using System;
using System.IO;
using bocoree.xml;
namespace bocoree.xml {
public class XmlSerializer {
private bool m_serialize_static_mode = false;
System.Xml.Serialization.XmlSerializer m_serializer;
XmlStaticMemberSerializer m_static_serializer;
public XmlSerializer( Type cls ) {
m_serializer = new System.Xml.Serialization.XmlSerializer( cls );
}
public XmlSerializer( Type cls, bool serialize_static_mode )
{
m_serialize_static_mode = serialize_static_mode;
if ( serialize_static_mode )
{
m_static_serializer = new XmlStaticMemberSerializer( cls );
}
else
{
m_serializer = new System.Xml.Serialization.XmlSerializer( cls );
}
}
public object deserialize( Stream stream ) {
if ( m_serialize_static_mode )
{
m_static_serializer.Deserialize( stream );
return null;
}
else
{
return m_serializer.Deserialize( stream );
}
}
public void serialize( Stream stream, object obj ) {
if ( m_serialize_static_mode )
{
m_static_serializer.Serialize( stream );
}
else
{
m_serializer.Serialize( stream, obj );
}
}
}
}
#endif

View File

@@ -0,0 +1,246 @@
#if !JAVA
/*
* XmlStaticMemberSerializer.cs
* Copyright (c) 2009 kbinani
*
* This file is part of bocoree.
*
* bocoree is free software; you can redistribute it and/or
* modify it under the terms of the BSD License.
*
* bocoree is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
using System;
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using System.Xml.Serialization;
using Microsoft.CSharp;
namespace bocoree
{
/// <summary>
/// クラスのstaticメンバーのxmlシリアライズ/デシリアライズを行うclass
/// </summary>
public class XmlStaticMemberSerializer
{
/// <summary>
/// ターゲットとなるクラスから,シリアライズするメンバーを抽出する時に使用
/// </summary>
private class MemberEntry
{
/// <summary>
/// プロパティ/フィールドの名前
/// </summary>
public string Name;
/// <summary>
/// プロパティ/フィールドの型
/// </summary>
public Type Type;
/// <summary>
/// プロパティ/フィールドのデフォルト値
/// </summary>
public object Default;
public MemberEntry( string name, Type type, object default_ )
{
Name = name;
Type = type;
Default = default_;
}
}
/// <summary>
/// シリアライズする対象の型staticメンバーだけなのでインスタンスではなく型を保持
/// </summary>
private Type m_item;
/// <summary>
/// シリアライズ/デシリアライズするための内部型
/// </summary>
private Type m_config_type = null;
/// <summary>
/// m_config_typeで初期化されたシリアライザ
/// </summary>
private XmlSerializer m_xs = null;
private XmlStaticMemberSerializer()
{
}
/// <summary>
/// 指定された型をシリアライズするための初期化を行います
/// </summary>
/// <param name="item"></param>
public XmlStaticMemberSerializer( Type item )
{
m_item = item;
}
/// <summary>
/// シリアライズを行い,ストリームに書き込みます
/// </summary>
/// <param name="stream"></param>
public void Serialize( Stream stream )
{
if ( m_config_type == null )
{
GenerateConfigType();
}
ConstructorInfo ci = m_config_type.GetConstructor( new Type[] { } );
object config = ci.Invoke( new object[] { } );
foreach ( FieldInfo target in m_config_type.GetFields() )
{
foreach ( PropertyInfo pi in m_item.GetProperties( BindingFlags.Public | BindingFlags.Static ) )
{
if ( target.Name == pi.Name && target.FieldType.Equals( pi.PropertyType ) && pi.CanRead && pi.CanWrite )
{
target.SetValue( config, pi.GetValue( m_item, new object[] { } ) );
break;
}
}
foreach ( FieldInfo fi in m_item.GetFields( BindingFlags.Public | BindingFlags.Static ) )
{
if ( target.Name == fi.Name && target.FieldType.Equals( fi.FieldType ) )
{
target.SetValue( config, fi.GetValue( m_item ) );
break;
}
}
}
m_xs.Serialize( stream, config );
}
/// <summary>
/// 指定したストリームを使って,デシリアライズを行います
/// </summary>
/// <param name="stream"></param>
public void Deserialize( Stream stream )
{
if ( m_config_type == null )
{
GenerateConfigType();
}
object config = m_xs.Deserialize( stream );
if ( config == null )
{
throw new ApplicationException( "failed serializing internal config object" );
}
foreach ( FieldInfo target in m_config_type.GetFields() )
{
foreach ( PropertyInfo pi in m_item.GetProperties( BindingFlags.Public | BindingFlags.Static ) )
{
if ( target.Name == pi.Name && target.FieldType.Equals( pi.PropertyType ) && pi.CanRead && pi.CanWrite )
{
pi.SetValue( m_item, target.GetValue( config ), new object[] { } );
break;
}
}
foreach ( FieldInfo fi in m_item.GetFields( BindingFlags.Public | BindingFlags.Static ) )
{
if ( target.Name == fi.Name && target.FieldType.Equals( fi.FieldType ) )
{
fi.SetValue( m_item, target.GetValue( config ) );
break;
}
}
}
}
/// <summary>
/// シリアライズ用の内部型をコンパイルしm_xsが使用できるようにします
/// </summary>
private void GenerateConfigType()
{
List<MemberEntry> config_names = CollectScriptConfigEntries( m_item );
string code = GenerateClassCodeForXmlSerialization( config_names, m_item );
CSharpCodeProvider provider = new CSharpCodeProvider();
CompilerParameters parameters = new CompilerParameters();
parameters.ReferencedAssemblies.Add( "System.Windows.Forms.dll" );
parameters.ReferencedAssemblies.Add( "System.dll" );
parameters.ReferencedAssemblies.Add( "System.Drawing.dll" );
parameters.ReferencedAssemblies.Add( "System.Xml.dll" );
parameters.GenerateInMemory = true;
parameters.GenerateExecutable = false;
parameters.IncludeDebugInformation = true;
CompilerResults results = provider.CompileAssemblyFromSource( parameters, code );
Assembly asm = results.CompiledAssembly;
if ( asm.GetTypes().Length <= 0 )
{
m_config_type = null;
m_xs = null;
throw new ApplicationException( "failed generating internal xml serizlizer" );
}
else
{
m_config_type = (asm.GetTypes())[0];
m_xs = new XmlSerializer( m_config_type );
}
}
/// <summary>
/// 設定ファイルから読込むための型情報を蒐集
/// </summary>
/// <param name="item"></param>
/// <returns></returns>
private static List<MemberEntry> CollectScriptConfigEntries( Type item )
{
List<MemberEntry> config_names = new List<MemberEntry>();
foreach ( PropertyInfo pi in item.GetProperties( BindingFlags.Static | BindingFlags.Public ) )
{
object[] attrs = pi.GetCustomAttributes( true );
foreach ( object obj in attrs )
{
if ( obj.GetType().Equals( typeof( System.Xml.Serialization.XmlIgnoreAttribute ) ) )
{
continue;
}
}
if ( pi.CanRead && pi.CanWrite )
{
config_names.Add( new MemberEntry( pi.Name, pi.PropertyType, pi.GetValue( item, new object[] { } ) ) );
}
}
foreach ( FieldInfo fi in item.GetFields( BindingFlags.Static | BindingFlags.Public ) )
{
object[] attrs = fi.GetCustomAttributes( true );
foreach ( object obj in attrs )
{
if ( obj.GetType().Equals( typeof( System.Xml.Serialization.XmlIgnoreAttribute ) ) )
{
continue;
}
}
config_names.Add( new MemberEntry( fi.Name, fi.FieldType, fi.GetValue( item ) ) );
}
return config_names;
}
/// <summary>
/// 指定した型から、Reflectionを使ってxmlシリアライズ用のクラスをコンパイルするためのC#コードを作成します
/// </summary>
/// <param name="implemented"></param>
/// <returns></returns>
private static string GenerateClassCodeForXmlSerialization( List<MemberEntry> config_names, Type item )
{
// XmlSerialization用の型を作成
string code = "";
code += "using System;\n";
code += "namespace Boare.Lib.AppUtil{\n";
code += " public class StaticMembersOf" + item.Name + "{\n";
foreach ( MemberEntry entry in config_names )
{
code += " public " + entry.Type.ToString() + " " + entry.Name + ";\n";
}
code += " }\n";
code += "}\n";
return code;
}
}
}
#endif

536
bocoree/awt.cs Normal file
View File

@@ -0,0 +1,536 @@
/*
* awt.cs
* Copyright (c) 2009 kbinani
*
* This file is part of bocoree.
*
* bocoree is free software; you can redistribute it and/or
* modify it under the terms of the BSD License.
*
* bocoree is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
#if !JAVA
namespace bocoree.java.awt {
public class Icon {
public System.Drawing.Image image;
}
public class ImageIcon : Icon {
public ImageIcon( System.Drawing.Image image ) {
this.image = image;
}
public ImageIcon( Image image ) {
if ( image != null ) {
this.image = image.image;
}
}
}
public class Image{
public System.Drawing.Image image;
public int getWidth( object observer ) {
return image.Width;
}
public int getHeight( object observer ) {
return image.Height;
}
}
public class Cursor {
public const int CROSSHAIR_CURSOR = 1;
public const int CUSTOM_CURSOR = -1;
public const int DEFAULT_CURSOR = 0;
public const int E_RESIZE_CURSOR = 11;
public const int HAND_CURSOR = 12;
public const int MOVE_CURSOR = 13;
public const int N_RESIZE_CURSOR = 8;
public const int NE_RESIZE_CURSOR = 7;
public const int NW_RESIZE_CURSOR = 6;
public const int S_RESIZE_CURSOR = 9;
public const int SE_RESIZE_CURSOR = 5;
public const int SW_RESIZE_CURSOR = 4;
public const int TEXT_CURSOR = 2;
public const int W_RESIZE_CURSOR = 10;
public const int WAIT_CURSOR = 3;
private int m_type = DEFAULT_CURSOR;
public System.Windows.Forms.Cursor cursor = System.Windows.Forms.Cursors.Default;
public Cursor( int type ) {
m_type = type;
if ( m_type == CROSSHAIR_CURSOR ) {
cursor = System.Windows.Forms.Cursors.Cross;
} else if ( m_type == HAND_CURSOR ) {
cursor = System.Windows.Forms.Cursors.Hand;
} else if ( m_type == TEXT_CURSOR ) {
cursor = System.Windows.Forms.Cursors.IBeam;
} else if ( m_type == E_RESIZE_CURSOR ){
cursor = System.Windows.Forms.Cursors.PanEast;
} else if ( m_type == NE_RESIZE_CURSOR ){
cursor = System.Windows.Forms.Cursors.PanNE;
} else if ( m_type == N_RESIZE_CURSOR ){
cursor = System.Windows.Forms.Cursors.PanNorth;
} else if ( m_type == NW_RESIZE_CURSOR ) {
cursor = System.Windows.Forms.Cursors.PanNW;
} else if ( m_type == SE_RESIZE_CURSOR ){
cursor = System.Windows.Forms.Cursors.PanSE;
} else if ( m_type == S_RESIZE_CURSOR ){
cursor = System.Windows.Forms.Cursors.PanSouth;
} else if ( m_type == SW_RESIZE_CURSOR ){
cursor = System.Windows.Forms.Cursors.PanSW;
} else if( m_type == W_RESIZE_CURSOR ){
cursor = System.Windows.Forms.Cursors.PanWest;
} else if ( m_type == MOVE_CURSOR ){
cursor = System.Windows.Forms.Cursors.SizeAll;
}
}
public int getType() {
return m_type;
}
}
public class Graphics2D {
public System.Drawing.Graphics nativeGraphics;
public Color color = Color.black;
private BasicStroke m_stroke = new BasicStroke();
public System.Drawing.SolidBrush brush = new System.Drawing.SolidBrush( System.Drawing.Color.Black );
private System.Drawing.Font m_font = new System.Drawing.Font( "Arial", 10 );
public Graphics2D( System.Drawing.Graphics g ) {
nativeGraphics = g;
}
public void clearRect( int x, int y, int width, int height ) {
nativeGraphics.FillRectangle( System.Drawing.Brushes.White, x, y, width, height );
}
public void drawLine( int x1, int y1, int x2, int y2 ) {
nativeGraphics.DrawLine( m_stroke.pen, x1, y1, x2, y2 );
}
public void drawRect( int x, int y, int width, int height ) {
nativeGraphics.DrawRectangle( m_stroke.pen, x, y, width, height );
}
public void fillRect( int x, int y, int width, int height ) {
nativeGraphics.FillRectangle( brush, x, y, width, height );
}
public void drawOval( int x, int y, int width, int height ) {
nativeGraphics.DrawEllipse( m_stroke.pen, x, y, width, height );
}
public void fillOval( int x, int y, int width, int height ) {
nativeGraphics.FillRectangle( brush, x, y, width, height );
}
public void setColor( Color c ) {
color = c;
m_stroke.pen.Color = c.color;
brush.Color = c.color;
}
public Color getColor() {
return color;
}
public void setFont( Font font ) {
m_font = font.font;
}
public void drawString( string str, float x, float y ) {
nativeGraphics.DrawString( str, m_font, brush, x, y );
}
public void drawPolygon( Polygon p ) {
drawPolygon( p.xpoints, p.ypoints, p.npoints );
}
public void drawPolygon( int[] xPoints, int[] yPoints, int nPoints ) {
System.Drawing.Point[] points = new System.Drawing.Point[nPoints];
for ( int i = 0; i < nPoints; i++ ) {
points[i] = new System.Drawing.Point( xPoints[i], yPoints[i] );
}
nativeGraphics.DrawLines( m_stroke.pen, points );
}
public void fillPolygon( Polygon p ) {
fillPolygon( p.xpoints, p.ypoints, p.npoints );
}
public void fillPolygon( int[] xPoints, int[] yPoints, int nPoints ) {
System.Drawing.Point[] points = new System.Drawing.Point[nPoints];
for ( int i = 0; i < nPoints; i++ ) {
points[i] = new System.Drawing.Point( xPoints[i], yPoints[i] );
}
nativeGraphics.FillPolygon( brush, points );
}
public void setStroke( Stroke stroke ) {
if ( stroke is BasicStroke ) {
BasicStroke bstroke = (BasicStroke)stroke;
m_stroke.pen = bstroke.pen;
m_stroke.pen.Color = color.color;
}
}
public Stroke getStroke() {
return m_stroke;
}
public Shape getClip() {
Shape ret = new Shape();
ret.region = nativeGraphics.Clip;
return ret;
}
public void setClip( Shape clip ) {
if ( clip == null ) {
nativeGraphics.Clip = new System.Drawing.Region();
} else {
nativeGraphics.Clip = clip.region;
}
}
public void clipRect( int x, int y, int width, int height ) {
nativeGraphics.Clip = new System.Drawing.Region( new System.Drawing.Rectangle( x, y, width, height ) );
}
public void drawImage( bocoree.java.awt.image.BufferedImage img, int x, int y, object obs ) {
if ( img is bocoree.java.awt.image.BufferedImage ) {
nativeGraphics.DrawImage( ((bocoree.java.awt.image.BufferedImage)img).m_image, new System.Drawing.Point( x, y ) );
}
}
public void drawImage( bocoree.java.awt.Image img, int x, int y, object obs ) {
if ( img == null ) {
return;
}
nativeGraphics.DrawImage( img.image, new System.Drawing.Point( x, y ) );
}
}
/*public interface Image{
int getHeight( object observer );
int getWidth( object observer );
}*/
public struct Color {
/// <summary>
/// 黒を表します。
/// </summary>
public static Color black = new Color( System.Drawing.Color.Black );
/// <summary>
/// 黒を表します。
/// </summary>
public static Color BLACK = new Color( System.Drawing.Color.Black );
/// <summary>
/// 青を表します。
/// </summary>
public static Color blue = new Color( System.Drawing.Color.Blue );
/// <summary>
/// 青を表します。
/// </summary>
public static Color BLUE = new Color( System.Drawing.Color.Blue );
/// <summary>
/// シアンを表します。
/// </summary>
public static Color cyan = new Color( System.Drawing.Color.Cyan );
/// <summary>
/// シアンを表します。
/// </summary>
public static Color CYAN = new Color( System.Drawing.Color.Cyan );
/// <summary>
/// ダークグレイを表します。
/// </summary>
public static Color DARK_GRAY = new Color( System.Drawing.Color.DarkGray );
/// <summary>
/// ダークグレイを表します。
/// </summary>
public static Color darkGray = new Color( System.Drawing.Color.DarkGray );
/// <summary>
/// グレイを表します。
/// </summary>
public static Color gray = new Color( System.Drawing.Color.Gray );
/// <summary>
/// グレイを表します。
/// </summary>
public static Color GRAY = new Color( System.Drawing.Color.Gray );
/// <summary>
/// 緑を表します。
/// </summary>
public static Color green = new Color( System.Drawing.Color.Green );
/// <summary>
/// 緑を表します。
/// </summary>
public static Color GREEN = new Color( System.Drawing.Color.Green );
/// <summary>
/// ライトグレイを表します。
/// </summary>
public static Color LIGHT_GRAY = new Color( System.Drawing.Color.LightGray );
/// <summary>
/// ライトグレイを表します。
/// </summary>
public static Color lightGray = new Color( System.Drawing.Color.LightGray );
/// <summary>
/// マゼンタを表します。
/// </summary>
public static Color magenta = new Color( System.Drawing.Color.Magenta );
/// <summary>
/// マゼンタを表します。
/// </summary>
public static Color MAGENTA = new Color( System.Drawing.Color.Magenta );
/// <summary>
/// オレンジを表します。
/// </summary>
public static Color orange = new Color( System.Drawing.Color.Orange );
/// <summary>
/// オレンジを表します。
/// </summary>
public static Color ORANGE = new Color( System.Drawing.Color.Orange );
/// <summary>
/// ピンクを表します。
/// </summary>
public static Color pink = new Color( System.Drawing.Color.Pink );
/// <summary>
/// ピンクを表します。
/// </summary>
public static Color PINK = new Color( System.Drawing.Color.Pink );
/// <summary>
/// 赤を表します。
/// </summary>
public static Color red = new Color( System.Drawing.Color.Red );
/// <summary>
/// 赤を表します。
/// </summary>
public static Color RED = new Color( System.Drawing.Color.Red );
/// <summary>
/// 白を表します。
/// </summary>
public static Color white = new Color( System.Drawing.Color.White );
/// <summary>
/// 白を表します。
/// </summary>
public static Color WHITE = new Color( System.Drawing.Color.White );
/// <summary>
/// 黄を表します。
/// </summary>
public static Color yellow = new Color( System.Drawing.Color.Yellow );
/// <summary>
/// 黄を表します。
/// </summary>
public static Color YELLOW = new Color( System.Drawing.Color.Yellow );
public System.Drawing.Color color;
public Color( System.Drawing.Color value ) {
color = value;
}
public Color( int r, int g, int b ) {
color = System.Drawing.Color.FromArgb( r, g, b );
}
public Color( int r, int g, int b, int a ) {
color = System.Drawing.Color.FromArgb( a, r, g, b );
}
public int getRed() {
return color.R;
}
public int getGreen() {
return color.G;
}
public int getBlue() {
return color.B;
}
}
public struct Rectangle {
public int height;
public int width;
public int x;
public int y;
public Rectangle( int width_, int height_ ) {
x = 0;
y = 0;
width = width_;
height = height_;
}
public Rectangle( int x_, int y_, int width_, int height_ ) {
x = x_;
y = y_;
width = width_;
height = height_;
}
public Rectangle( Rectangle r ) {
x = r.x;
y = r.y;
width = r.width;
height = r.height;
}
}
public struct Point {
public int x;
public int y;
public Point( int x_, int y_ ) {
x = x_;
y = y_;
}
public Point( Point p ) {
x = p.x;
y = p.y;
}
}
public class Font {
public const int PLAIN = 0;
public const int ITALIC = 2;
public const int BOLD = 1;
public static readonly string DIALOG = "Dialog";
public static readonly string DIALOG_INPUT = "DialogInput";
public static readonly string MONOSPACED = "Monospaced";
public static readonly string SANS_SERIF = "SansSerif";
public static readonly string SERIF = "Serif";
public System.Drawing.Font font;
public Font( System.Drawing.Font value ) {
font = value;
}
public Font( string name, int style, int size ) {
System.Drawing.FontStyle fstyle = System.Drawing.FontStyle.Regular;
if ( style >= Font.BOLD ) {
fstyle = fstyle | System.Drawing.FontStyle.Bold;
}
if ( style >= Font.ITALIC ) {
fstyle = fstyle | System.Drawing.FontStyle.Italic;
}
font = new System.Drawing.Font( name, size, fstyle );
}
public string getName() {
return font.Name;
}
public int getSize() {
return (int)font.SizeInPoints;
}
public float getSize2D() {
return font.SizeInPoints;
}
}
public interface Stroke {
}
public class BasicStroke : Stroke {
public const int CAP_BUTT = 0;
public const int CAP_ROUND = 1;
public const int CAP_SQUARE = 2;
public const int JOIN_BEVEL = 2;
public const int JOIN_MITER = 0;
public const int JOIN_ROUND = 1;
public System.Drawing.Pen pen;
public BasicStroke() {
pen = new System.Drawing.Pen( System.Drawing.Color.Black );
}
public BasicStroke( float width )
: this( width, 0, 0, 10.0f ) {
}
public BasicStroke( float width, int cap, int join )
: this( width, cap, join, 10.0f ) {
}
public BasicStroke( float width, int cap, int join, float miterlimit ) {
pen = new System.Drawing.Pen( System.Drawing.Color.Black, width );
System.Drawing.Drawing2D.LineCap linecap = System.Drawing.Drawing2D.LineCap.Flat;
if ( cap == 1 ) {
linecap = System.Drawing.Drawing2D.LineCap.Round;
} else if ( cap == 2 ) {
linecap = System.Drawing.Drawing2D.LineCap.Square;
}
pen.StartCap = linecap;
pen.EndCap = linecap;
System.Drawing.Drawing2D.LineJoin linejoin = System.Drawing.Drawing2D.LineJoin.Miter;
if ( join == 1 ) {
linejoin = System.Drawing.Drawing2D.LineJoin.Round;
} else if ( join == 2 ) {
linejoin = System.Drawing.Drawing2D.LineJoin.Bevel;
}
pen.LineJoin = linejoin;
pen.MiterLimit = miterlimit;
}
public BasicStroke( float width, int cap, int join, float miterlimit, float[] dash, float dash_phase )
: this( width, cap, join, miterlimit ) {
pen.DashPattern = dash;
pen.DashOffset = dash_phase;
}
}
public class Polygon {
/// <summary>
/// 点の総数です。
/// </summary>
public int npoints;
/// <summary>
/// X 座標の配列です。
/// </summary>
public int[] xpoints;
/// <summary>
/// Y 座標の配列です。
/// </summary>
public int[] ypoints;
public Polygon() {
npoints = 0;
xpoints = new int[0];
ypoints = new int[0];
}
public Polygon( int[] xpoints_, int[] ypoints_, int npoints_ ) {
npoints = npoints_;
xpoints = xpoints_;
ypoints = ypoints_;
}
}
public class Shape {
public System.Drawing.Region region;
}
public struct Dimension {
public int height;
public int width;
public Dimension( int width_, int height_ ) {
width = width_;
height = height_;
}
}
public class Frame : System.Windows.Forms.Form {
}
}
#endif

239
bocoree/awt.event.cs Normal file
View File

@@ -0,0 +1,239 @@
/*
* awt.event.cs
* Copyright (c) 2009 kbinani
*
* This file is part of bocoree.
*
* bocoree is free software; you can redistribute it and/or
* modify it under the terms of the BSD License.
*
* bocoree is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
#if !JAVA
namespace bocoree.java.awt.event_{
public class InputEvent {
public const int ALT_DOWN_MASK = 512;
public const int ALT_GRAPH_DOWN_MASK = 8192;
public const int ALT_GRAPH_MASK = 32;
public const int ALT_MASK = 8;
public const int BUTTON1_DOWN_MASK = 1024;
public const int BUTTON1_MASK = 16;
public const int BUTTON2_DOWN_MASK = 2048;
public const int BUTTON2_MASK = 8;
public const int BUTTON3_DOWN_MASK = 4096;
public const int BUTTON3_MASK = 4;
public const int CTRL_DOWN_MASK = 128;
public const int CTRL_MASK = 2;
public const int META_DOWN_MASK = 256;
public const int META_MASK = 4;
public const int SHIFT_DOWN_MASK = 64;
public const int SHIFT_MASK = 1;
}
public class KeyEvent {
//public const char CHAR_UNDEFINED = 65535;
public const int KEY_FIRST = 400;
public const int KEY_LAST = 402;
public const int KEY_LOCATION_LEFT = 2;
public const int KEY_LOCATION_NUMPAD = 4;
public const int KEY_LOCATION_RIGHT = 3;
public const int KEY_LOCATION_STANDARD = 1;
public const int KEY_LOCATION_UNKNOWN = 0;
public const int KEY_PRESSED = 401;
public const int KEY_RELEASED = 402;
public const int KEY_TYPED = 400;
public const int VK_0 = 48;
public const int VK_1 = 49;
public const int VK_2 = 50;
public const int VK_3 = 51;
public const int VK_4 = 52;
public const int VK_5 = 53;
public const int VK_6 = 54;
public const int VK_7 = 55;
public const int VK_8 = 56;
public const int VK_9 = 57;
public const int VK_A = 65;
public const int VK_ACCEPT = 30;
public const int VK_ADD = 107;
public const int VK_AGAIN = 65481;
public const int VK_ALL_CANDIDATES = 256;
public const int VK_ALPHANUMERIC = 240;
public const int VK_ALT = 18;
public const int VK_ALT_GRAPH = 65406;
public const int VK_AMPERSAND = 150;
public const int VK_ASTERISK = 151;
public const int VK_AT = 512;
public const int VK_B = 66;
public const int VK_BACK_QUOTE = 192;
public const int VK_BACK_SLASH = 92;
public const int VK_BACK_SPACE = 8;
public const int VK_BEGIN = 65368;
public const int VK_BRACELEFT = 161;
public const int VK_BRACERIGHT = 162;
public const int VK_C = 67;
public const int VK_CANCEL = 3;
public const int VK_CAPS_LOCK = 20;
public const int VK_CIRCUMFLEX = 514;
public const int VK_CLEAR = 12;
public const int VK_CLOSE_BRACKET = 93;
public const int VK_CODE_INPUT = 258;
public const int VK_COLON = 513;
public const int VK_COMMA = 44;
public const int VK_COMPOSE = 65312;
public const int VK_CONTEXT_MENU = 525;
public const int VK_CONTROL = 17;
public const int VK_CONVERT = 28;
public const int VK_COPY = 65485;
public const int VK_CUT = 65489;
public const int VK_D = 68;
public const int VK_DEAD_ABOVEDOT = 134;
public const int VK_DEAD_ABOVERING = 136;
public const int VK_DEAD_ACUTE = 129;
public const int VK_DEAD_BREVE = 133;
public const int VK_DEAD_CARON = 138;
public const int VK_DEAD_CEDILLA = 139;
public const int VK_DEAD_CIRCUMFLEX = 130;
public const int VK_DEAD_DIAERESIS = 135;
public const int VK_DEAD_DOUBLEACUTE = 137;
public const int VK_DEAD_GRAVE = 128;
public const int VK_DEAD_IOTA = 141;
public const int VK_DEAD_MACRON = 132;
public const int VK_DEAD_OGONEK = 140;
public const int VK_DEAD_SEMIVOICED_SOUND = 143;
public const int VK_DEAD_TILDE = 131;
public const int VK_DEAD_VOICED_SOUND = 142;
public const int VK_DECIMAL = 110;
public const int VK_DELETE = 127;
public const int VK_DIVIDE = 111;
public const int VK_DOLLAR = 515;
public const int VK_DOWN = 40;
public const int VK_E = 69;
public const int VK_END = 35;
public const int VK_ENTER = 10;
public const int VK_EQUALS = 61;
public const int VK_ESCAPE = 27;
public const int VK_EURO_SIGN = 516;
public const int VK_EXCLAMATION_MARK = 517;
public const int VK_F = 70;
public const int VK_F1 = 112;
public const int VK_F10 = 121;
public const int VK_F11 = 122;
public const int VK_F12 = 123;
public const int VK_F13 = 61440;
public const int VK_F14 = 61441;
public const int VK_F15 = 61442;
public const int VK_F16 = 61443;
public const int VK_F17 = 61444;
public const int VK_F18 = 61445;
public const int VK_F19 = 61446;
public const int VK_F2 = 113;
public const int VK_F20 = 61447;
public const int VK_F21 = 61448;
public const int VK_F22 = 61449;
public const int VK_F23 = 61450;
public const int VK_F24 = 61451;
public const int VK_F3 = 114;
public const int VK_F4 = 115;
public const int VK_F5 = 116;
public const int VK_F6 = 117;
public const int VK_F7 = 118;
public const int VK_F8 = 119;
public const int VK_F9 = 120;
public const int VK_FINAL = 24;
public const int VK_FIND = 65488;
public const int VK_FULL_WIDTH = 243;
public const int VK_G = 71;
public const int VK_GREATER = 160;
public const int VK_H = 72;
public const int VK_HALF_WIDTH = 244;
public const int VK_HELP = 156;
public const int VK_HIRAGANA = 242;
public const int VK_HOME = 36;
public const int VK_I = 73;
public const int VK_INPUT_METHOD_ON_OFF = 263;
public const int VK_INSERT = 155;
public const int VK_INVERTED_EXCLAMATION_MARK = 518;
public const int VK_J = 74;
public const int VK_JAPANESE_HIRAGANA = 260;
public const int VK_JAPANESE_KATAKANA = 259;
public const int VK_JAPANESE_ROMAN = 261;
public const int VK_K = 75;
public const int VK_KANA = 21;
public const int VK_KANA_LOCK = 262;
public const int VK_KANJI = 25;
public const int VK_KATAKANA = 241;
public const int VK_KP_DOWN = 225;
public const int VK_KP_LEFT = 226;
public const int VK_KP_RIGHT = 227;
public const int VK_KP_UP = 224;
public const int VK_L = 76;
public const int VK_LEFT = 37;
public const int VK_LEFT_PARENTHESIS = 519;
public const int VK_LESS = 153;
public const int VK_M = 77;
public const int VK_META = 157;
public const int VK_MINUS = 45;
public const int VK_MODECHANGE = 31;
public const int VK_MULTIPLY = 106;
public const int VK_N = 78;
public const int VK_NONCONVERT = 29;
public const int VK_NUM_LOCK = 144;
public const int VK_NUMBER_SIGN = 520;
public const int VK_NUMPAD0 = 96;
public const int VK_NUMPAD1 = 97;
public const int VK_NUMPAD2 = 98;
public const int VK_NUMPAD3 = 99;
public const int VK_NUMPAD4 = 100;
public const int VK_NUMPAD5 = 101;
public const int VK_NUMPAD6 = 102;
public const int VK_NUMPAD7 = 103;
public const int VK_NUMPAD8 = 104;
public const int VK_NUMPAD9 = 105;
public const int VK_O = 79;
public const int VK_OPEN_BRACKET = 91;
public const int VK_P = 80;
public const int VK_PAGE_DOWN = 34;
public const int VK_PAGE_UP = 33;
public const int VK_PASTE = 65487;
public const int VK_PAUSE = 19;
public const int VK_PERIOD = 46;
public const int VK_PLUS = 521;
public const int VK_PREVIOUS_CANDIDATE = 257;
public const int VK_PRINTSCREEN = 154;
public const int VK_PROPS = 65482;
public const int VK_Q = 81;
public const int VK_QUOTE = 222;
public const int VK_QUOTEDBL = 152;
public const int VK_R = 82;
public const int VK_RIGHT = 39;
public const int VK_RIGHT_PARENTHESIS = 522;
public const int VK_ROMAN_CHARACTERS = 245;
public const int VK_S = 83;
public const int VK_SCROLL_LOCK = 145;
public const int VK_SEMICOLON = 59;
public const int VK_SEPARATER = 108;
public const int VK_SEPARATOR = 108;
public const int VK_SHIFT = 16;
public const int VK_SLASH = 47;
public const int VK_SPACE = 32;
public const int VK_STOP = 65480;
public const int VK_SUBTRACT = 109;
public const int VK_T = 84;
public const int VK_TAB = 9;
public const int VK_U = 85;
public const int VK_UNDEFINED = 0;
public const int VK_UNDERSCORE = 523;
public const int VK_UNDO = 65483;
public const int VK_UP = 38;
public const int VK_V = 86;
public const int VK_W = 87;
public const int VK_WINDOWS = 524;
public const int VK_X = 88;
public const int VK_Y = 89;
public const int VK_Z = 90;
}
}
#endif

30
bocoree/awt.geom.cs Normal file
View File

@@ -0,0 +1,30 @@
/*
* awt.geom.cs
* Copyright (c) 2009 kbinani
*
* This file is part of bocoree.
*
* bocoree is free software; you can redistribute it and/or
* modify it under the terms of the BSD License.
*
* bocoree is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
#if !JAVA
namespace bocoree.java {
public class AffineTransform {
System.Drawing.Drawing2D.Matrix m_matrix;
public AffineTransform() {
m_matrix = new System.Drawing.Drawing2D.Matrix();
}
public AffineTransform( float m00, float m10, float m01, float m11, float m02, float m12 ) {
m_matrix = new System.Drawing.Drawing2D.Matrix( m00, m01, m10, m11, m02, m12 );
}
}
}
#endif

54
bocoree/awt.image.cs Normal file
View File

@@ -0,0 +1,54 @@
/*
* awt.image.cs
* Copyright (c) 2009 kbinani
*
* This file is part of bocoree.
*
* bocoree is free software; you can redistribute it and/or
* modify it under the terms of the BSD License.
*
* bocoree is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
#if !JAVA
namespace bocoree.java.awt.image {
public class BufferedImage/* : bocoree.awt.Image*/{
public static int TYPE_INT_BGR = 0;
public static int TYPE_INT_RGB = 1;
public static int TYPE_INT_ARGB = 2;
public System.Drawing.Bitmap m_image;
public BufferedImage( int width, int height, int imageType ) {
System.Drawing.Imaging.PixelFormat format = System.Drawing.Imaging.PixelFormat.Format24bppRgb;
if ( imageType == TYPE_INT_ARGB ) {
format = System.Drawing.Imaging.PixelFormat.Format32bppArgb;
}
m_image = new System.Drawing.Bitmap( width, height, format );
}
public Graphics2D createGraphics() {
return new Graphics2D( System.Drawing.Graphics.FromImage( m_image ) );
}
public int getHeight( object observer ) {
return m_image.Height;
}
public int getWidth( object observer ) {
return m_image.Width;
}
public int getWidth() {
return m_image.Width;
}
public int getHeight() {
return m_image.Height;
}
}
}
#endif

232
bocoree/bocoree.csproj Normal file
View File

@@ -0,0 +1,232 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>9.0.30729</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{C8AAE632-9C6C-4372-8175-811528A66742}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>bocoree</RootNamespace>
<AssemblyName>bocoree</AssemblyName>
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<SignAssembly>false</SignAssembly>
<AssemblyOriginatorKeyFile>
</AssemblyOriginatorKeyFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<PlatformTarget>x86</PlatformTarget>
<OutputPath>bin\x86\Debug\</OutputPath>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<DefineConstants>DEBUG</DefineConstants>
<DocumentationFile>bin\x86\Debug\bocoree.XML</DocumentationFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<PlatformTarget>x86</PlatformTarget>
<OutputPath>bin\x86\Release\</OutputPath>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<DocumentationFile>bin\x86\Release\bocoree.XML</DocumentationFile>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Drawing" />
<Reference Include="System.Data" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Arrays.cs" />
<Compile Include="awt.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="awt.event.cs" />
<Compile Include="awt.geom.cs" />
<Compile Include="awt.image.cs" />
<Compile Include="Base64.cs" />
<Compile Include="BBackgroundWorker.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="BButton.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="BCancelEventArgs.cs" />
<Compile Include="BCheckBox.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="BComboBox.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="BDelegate.cs" />
<Compile Include="BDialogResult.cs" />
<Compile Include="BDoWorkEventArgs.cs" />
<Compile Include="BDoWorkEventHandler.cs" />
<Compile Include="BEvent.cs" />
<Compile Include="BEventArgs.cs" />
<Compile Include="BEventHandler.cs" />
<Compile Include="BFileChooser.cs">
</Compile>
<Compile Include="BFolderBrowser.cs" />
<Compile Include="BFontChooser.cs" />
<Compile Include="BForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="BFormClosedEventArgs.cs" />
<Compile Include="BFormClosingEventArgs.cs" />
<Compile Include="BFormClosingEventHandler.cs" />
<Compile Include="BFormWindowState.cs" />
<Compile Include="BGroupBox.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="BKeyEventArgs.cs" />
<Compile Include="BKeyEventHandler.cs" />
<Compile Include="BKeyPressEventArgs.cs" />
<Compile Include="BKeys.cs" />
<Compile Include="BLabel.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="BListView.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="BListViewItem.cs" />
<Compile Include="BMenu.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="BMenuBar.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="BMenuItem.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="BMouseButtons.cs" />
<Compile Include="BMouseEventArgs.cs" />
<Compile Include="BMouseEventHandler.cs" />
<Compile Include="BNumericUpDown.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="BPaintEventArgs.cs" />
<Compile Include="BPanel.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="BPictureBox.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="BPopupMenu.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="BPreviewKeyDownEventArgs.cs" />
<Compile Include="BProgressBar.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="BProgressChangedEventArgs.cs" />
<Compile Include="BProgressChangedEventHandler.cs" />
<Compile Include="BRunWorkerCompletedEventHandler.cs" />
<Compile Include="BRunWorkerCompletedEventArgs.cs" />
<Compile Include="BHScrollBar.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="BMenuSeparator.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="BSlider.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="BSplitPane.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="BStatusLabel.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="BTextArea.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="BTextBox.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="BTimer.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="BToggleButton.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="BToolBar.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="BToolStripButton.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="BToolStripDropDownButton.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="BToolStripLabel.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="BToolStripTextBox.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="BufferedReader.cs" />
<Compile Include="BufferedWriter.cs" />
<Compile Include="BVScrollBar.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="ByRef.cs" />
<Compile Include="Collections.cs" />
<Compile Include="cp932.cs" />
<Compile Include="cp932reader.cs" />
<Compile Include="cp932writer.cs" />
<Compile Include="fft.cs" />
<Compile Include="IEventHandler.cs" />
<Compile Include="imageio.cs" />
<Compile Include="io.cs" />
<Compile Include="Iterator.cs" />
<Compile Include="ListIterator.cs" />
<Compile Include="math.cs" />
<Compile Include="Misc.cs" />
<Compile Include="PortUtil.cs" />
<Compile Include="RandomAccessFile.cs" />
<Compile Include="swing.cs">
</Compile>
<Compile Include="util.cs" />
<Compile Include="ValuePair.cs" />
<Compile Include="Vector.cs" />
<Compile Include="winmm.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="windows.cs" />
<Compile Include="wingdi.cs" />
<Compile Include="XmlMember.cs" />
<Compile Include="XmlPoint.cs" />
<Compile Include="XmlRectangle.cs" />
<Compile Include="XmlSerializable.cs" />
<Compile Include="XmlSerializer.cs" />
<Compile Include="XmlSerializeWithDescription.cs" />
<Compile Include="XmlStaticMemberSerializer.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

9599
bocoree/cp932.cs Normal file

File diff suppressed because it is too large Load Diff

112
bocoree/cp932reader.cs Normal file
View File

@@ -0,0 +1,112 @@
#if !JAVA
/*
* cp932reader.cs
* Copyright (c) 2009 kbinani
*
* This file is part of bocoree
*
* bocoree is free software; you can redistribute it and/or
* modify it under the terms of the BSD License.
*
* bocoree is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
namespace bocoree {
public class cp932reader : IDisposable {
private Stream m_stream;
private cp932reader() {
}
public cp932reader( Stream stream )
: this() {
m_stream = stream;
}
public cp932reader( string path )
: this() {
m_stream = new FileStream( path, FileMode.Open, FileAccess.Read );
}
public string ReadLine() {
byte[] line;
if ( get_line( out line ) ) {
return cp932.convert( line );
} else {
return null;
}
}
public void Close() {
if ( m_stream != null ) {
m_stream.Close();
}
}
public void Dispose() {
Close();
}
public int Peek() {
int ch = m_stream.ReadByte();
if ( ch < 0 ) {
return ch;
} else {
m_stream.Seek( -1, SeekOrigin.Current );
return ch;
}
}
public string ReadToEnd() {
StringBuilder sb = new StringBuilder();
while ( Peek() >= 0 ) {
sb.Append( ReadLine() + Environment.NewLine );
}
return sb.ToString();
}
private bool get_line( out byte[] line ) {
List<byte> ret = new List<byte>();
if ( !m_stream.CanRead ) {
line = ret.ToArray();
return false;
}
if ( !m_stream.CanSeek ) {
line = ret.ToArray();
return false;
}
int ch = m_stream.ReadByte();
if ( ch < 0 ) {
line = ret.ToArray();
return false;
}
while ( ch >= 0 ) {
if ( ch == 0x0d ) {
ch = m_stream.ReadByte();
if ( ch < 0 ) {
break;
} else if ( ch != 0x0a ) {
m_stream.Seek( -1, SeekOrigin.Current );
}
break;
} else if ( ch == 0x0a ) {
break;
}
ret.Add( (byte)ch );
ch = m_stream.ReadByte();
}
line = ret.ToArray();
return true;
}
}
}
#endif

62
bocoree/cp932writer.cs Normal file
View File

@@ -0,0 +1,62 @@
#if !JAVA
/*
* cp932writer.cs
* Copyright (c) 2009 kbinani
*
* This file is part of bocoree
*
* bocoree is free software; you can redistribute it and/or
* modify it under the terms of the BSD License.
*
* bocoree is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
using System;
using System.IO;
using System.Text;
namespace bocoree {
public class cp932writer : IDisposable {
Stream m_stream;
byte[] m_newline;
private cp932writer() {
m_newline = Encoding.ASCII.GetBytes( Environment.NewLine );
}
public cp932writer( Stream stream )
: this() {
m_stream = stream;
}
public cp932writer( string file )
: this() {
m_stream = new FileStream( file, FileMode.Create );
}
public void WriteLine( string line ) {
byte[] bytes = cp932.convert( line );
m_stream.Write( bytes, 0, bytes.Length );
m_stream.Write( m_newline, 0, m_newline.Length );
}
public void Write( string line ) {
byte[] bytes = cp932.convert( line );
m_stream.Write( bytes, 0, bytes.Length );
}
public void Close() {
if ( m_stream != null ) {
m_stream.Close();
}
}
public void Dispose() {
Close();
}
}
}
#endif

3257
bocoree/fft.cs Normal file

File diff suppressed because it is too large Load Diff

65
bocoree/imageio.cs Normal file
View File

@@ -0,0 +1,65 @@
/*
* imageio.cs
* Copyright (c) 2009 kbinani
*
* This file is part of bocoree.
*
* bocoree is free software; you can redistribute it and/or
* modify it under the terms of the BSD License.
*
* bocoree is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
#if !JAVA
using bocoree.java.awt.image;
using bocoree.java.io;
namespace bocoree.javax.imageio {
public class ImageIO {
public static bool write( BufferedImage im, string formatName, File output ) {
System.Drawing.Imaging.ImageFormat fmt = System.Drawing.Imaging.ImageFormat.Bmp;
switch ( formatName ) {
case "BMP":
case "bmp":
fmt = System.Drawing.Imaging.ImageFormat.Bmp;
break;
case "jpg":
case "JPG":
case "jpeg":
case "JPEG":
fmt = System.Drawing.Imaging.ImageFormat.Jpeg;
break;
case "png":
case "PNG":
fmt = System.Drawing.Imaging.ImageFormat.Png;
break;
case "GIF":
case "gif":
fmt = System.Drawing.Imaging.ImageFormat.Gif;
break;
default:
return false;
}
System.IO.FileStream fs = null;
bool ret = false;
try {
fs = new System.IO.FileStream( output.getPath(), System.IO.FileMode.Open, System.IO.FileAccess.Write );
im.m_image.Save( fs, fmt );
ret = true;
} catch {
ret = false;
} finally {
if ( fs != null ) {
try {
fs.Close();
} catch { }
}
}
return ret;
}
}
}
#endif

541
bocoree/io.cs Normal file
View File

@@ -0,0 +1,541 @@
/*
* io.cs
* Copyright (c) 2009 kbinani
*
* This file is part of bocoree.
*
* bocoree is free software; you can redistribute it and/or
* modify it under the terms of the BSD License.
*
* bocoree is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
#if !JAVA
using System;
using System.Collections.Generic;
namespace bocoree.java.io {
public interface OutputStream {
}
public interface InputStream {
}
public class ObjectInputStream : InputStream {
private System.Runtime.Serialization.Formatters.Binary.BinaryFormatter m_formatter;
private System.IO.Stream m_stream;
public ObjectInputStream( System.IO.Stream stream ) {
m_stream = stream;
m_formatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
}
public object readObject() {
return m_formatter.Deserialize( m_stream );
}
}
public class ObjectOutputStream : OutputStream {
private System.Runtime.Serialization.Formatters.Binary.BinaryFormatter m_formatter;
private System.IO.Stream m_stream;
public ObjectOutputStream( System.IO.Stream stream ) {
m_formatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
m_stream = stream;
}
public void writeObject( Object obj ) {
m_formatter.Serialize( m_stream, obj );
}
}
public class ByteArrayOutputStream : System.IO.MemoryStream, OutputStream {
public ByteArrayOutputStream()
: base() {
}
public byte[] toByteArray() {
base.Seek( 0, System.IO.SeekOrigin.Begin );
byte[] ret = new byte[base.Length];
base.Read( ret, 0, ret.Length );
return ret;
}
}
public class ByteArrayInputStream : System.IO.MemoryStream, InputStream {
public ByteArrayInputStream( byte[] buf )
: base( buf ) {
}
}
public class File {
public readonly string separator = System.IO.Path.DirectorySeparatorChar + "";
public readonly char separatorChar = System.IO.Path.DirectorySeparatorChar;
private string m_path;
/// <summary>
/// 指定されたパス名文字列を抽象パス名に変換して、新しい File のインスタンスを生成します。
/// </summary>
/// <param name="pathname"></param>
public File( String pathname ) {
m_path = pathname;
}
/// <summary>
/// この抽象パス名が示すファイルをアプリケーションが実行できるかどうかを判定します。
/// </summary>
public bool canExecute() {
throw new NotImplementedException();
}
/// <summary>
/// この抽象パス名が示すファイルをアプリケーションが読み込めるかどうかを判定します。
/// </summary>
public bool canRead() {
System.IO.FileStream fs = null;
bool ret = false;
try {
fs = System.IO.File.OpenRead( m_path );
ret = true;
} catch {
ret = false;
} finally {
if ( fs != null ) {
try {
fs.Close();
} catch {
}
}
}
return ret;
}
/// <summary>
/// この抽象パス名が示すファイルをアプリケーションが変更できるかどうかを判定します。
/// </summary>
public bool canWrite() {
System.IO.FileStream fs = null;
bool ret = false;
try {
fs = System.IO.File.OpenWrite( m_path );
ret = true;
} catch {
ret = false;
} finally {
if ( fs != null ) {
try {
fs.Close();
} catch {
}
}
}
return ret;
}
/// <summary>
/// 2 つの抽象パス名を語彙的に比較します。
/// </summary>
public int compareTo( File pathname ) {
return System.IO.Path.GetFullPath( this.m_path ).CompareTo( System.IO.Path.GetFullPath( pathname.m_path ) );
}
/// <summary>
/// この抽象パス名が示す空の新しいファイルを不可分 (atomic) に生成します (その名前のファイルがまだ存在しない場合だけ)。
/// </summary>
public bool createNewFile() {
if ( System.IO.File.Exists( m_path ) ) {
return false;
} else {
System.IO.File.Create( m_path );
return true;
}
}
/// <summary>
/// 指定された接頭辞と接尾辞をファイル名の生成に使用して、デフォルトの一時ファイルディレクトリに空のファイルを生成します。
/// </summary>
public static File createTempFile( string prefix, string suffix ) {
string tmp = System.IO.Path.GetTempFileName();
string dir = System.IO.Path.GetDirectoryName( tmp );
string file = System.IO.Path.GetFileName( tmp );
return new File( System.IO.Path.Combine( dir, prefix + file + suffix ) );
}
/// <summary>
/// 指定されたディレクトリで新しい空のファイルを生成し、その名前には、指定された接頭辞および接尾辞の文字列が使用されます。
/// </summary>
public static File createTempFile( string prefix, string suffix, File directory ) {
String dir = System.IO.Path.GetTempPath();
if ( directory != null ) {
dir = directory.m_path;
}
if ( !System.IO.Directory.Exists( dir ) ) {
throw new System.IO.IOException();
}
while ( true ) {
String f = prefix + System.IO.Path.GetRandomFileName() + suffix;
String full = System.IO.Path.Combine( dir, f );
if ( !System.IO.File.Exists( full ) ) {
System.IO.File.Create( full );
return new File( full );
}
}
throw new System.IO.IOException();
}
/// <summary>
/// この抽象パス名が示すファイルまたはディレクトリを削除します。
/// </summary>
public bool delete() {
try {
System.IO.File.Delete( m_path );
return true;
} catch {
}
return false;
}
/// <summary>
/// この抽象パス名が示すファイルまたはディレクトリが、仮想マシンが終了したときに削除されるように要求します。
/// </summary>
public void deleteOnExit() {
throw new NotImplementedException();
}
/// <summary>
/// この抽象パス名が指定されたオブジェクトと等しいかどうかを判定します。
/// </summary>
public bool equals( object obj ) {
return base.Equals( obj );
}
/// <summary>
/// この抽象パス名が示すファイルまたはディレクトリが存在するかどうかを判定します。
/// </summary>
public bool exists() {
bool file = System.IO.File.Exists( m_path );
bool dir = System.IO.Directory.Exists( m_path );
return file || dir;
}
/// <summary>
/// この抽象パス名の絶対形式を返します。
/// </summary>
public File getAbsoluteFile() {
return new File( getAbsolutePath() );
}
/// <summary>
/// この抽象パス名の絶対パス名文字列を返します。
/// </summary>
public string getAbsolutePath() {
return System.IO.Path.GetFullPath( m_path );
}
/// <summary>
/// この抽象パス名の正規の形式を返します。
/// </summary>
public File getCanonicalFile() {
throw new NotImplementedException();
}
/// <summary>
/// この抽象パス名の正規のパス名文字列を返します。
/// </summary>
public string getCanonicalPath() {
throw new NotImplementedException();
}
/// <summary>
/// この抽象パス名で指定されるパーティション内で未割り当てのバイト数を返します。
/// </summary>
public long getFreeSpace() {
string drive = System.IO.Path.GetPathRoot( m_path );
foreach ( System.IO.DriveInfo di in System.IO.DriveInfo.GetDrives() ) {
if ( di.RootDirectory.FullName == drive ) {
return di.TotalFreeSpace;
}
}
return 0;
}
/// <summary>
/// この抽象パス名が示すファイルまたはディレクトリの名前を返します。
/// </summary>
public string getName() {
return System.IO.Path.GetFileName( m_path );
}
/// <summary>
/// この抽象パス名の親のパス名文字列を返します。
/// </summary>
public string getParent() {
return System.IO.Path.GetDirectoryName( m_path );
}
/// <summary>
/// この抽象パス名の親の抽象パス名を返します。
/// </summary>
public File getParentFile() {
return new File( getParent() );
}
/// <summary>
/// この抽象パス名をパス名文字列に変換します。
/// </summary>
public string getPath() {
return m_path;
}
/// <summary>
/// この抽象パス名で指定されるパーティションのサイズを返します。
/// </summary>
public long getTotalSpace() {
return getFreeSpace();
}
/// <summary>
/// この抽象パス名で指定されるパーティション上で、この仮想マシンが利用できるバイト数を返します。
/// </summary>
public long getUsableSpace() {
return getFreeSpace();
}
/// <summary>
/// この抽象パス名のハッシュコードを計算します。
/// </summary>
public int hashCode() {
return m_path.GetHashCode();
}
/// <summary>
/// この抽象パス名が絶対かどうかを判定します。
/// </summary>
public bool isAbsolute() {
return System.IO.Path.IsPathRooted( m_path );
}
/// <summary>
/// この抽象パス名が示すファイルがディレクトリであるかどうかを判定します。
/// </summary>
public bool isDirectory() {
bool dir = System.IO.Directory.Exists( m_path );
if ( dir ) {
return true;
} else {
return false;
}
}
/// <summary>
/// この抽象パス名が示すファイルが普通のファイルかどうかを判定します。
/// </summary>
public bool isFile() {
throw new NotImplementedException();
}
/// <summary>
/// この抽象パス名が示すファイルが隠しファイルかどうかを判定します。
/// </summary>
public bool isHidden() {
throw new NotImplementedException();
}
/// <summary>
/// この抽象パス名が示すファイルが最後に変更された時刻を返します。
/// </summary>
public long lastModified() {
System.IO.FileInfo f = new System.IO.FileInfo( m_path );
return f.LastWriteTimeUtc.Ticks;
}
/// <summary>
/// この抽象パス名に指定されているファイルの長さを返します。
/// </summary>
public long length() {
System.IO.FileInfo f = new System.IO.FileInfo( m_path );
return f.Length;
}
/// <summary>
/// この抽象パス名が示すディレクトリにあるファイルおよびディレクトリを示す文字列の配列を返します。
/// </summary>
public string[] list() {
List<string> list = new List<string>();
list.AddRange( System.IO.Directory.GetDirectories( m_path ) );
list.AddRange( System.IO.Directory.GetFiles( m_path ) );
return list.ToArray();
}
/// <summary>
/// この抽象パス名が示すディレクトリにあるファイルおよびディレクトリの中で、指定されたフィルタの基準を満たすものの文字列の配列を返します。
/// </summary>
public string[] list( FilenameFilter filter ) {
List<string> ret = new List<string>();
foreach ( string s in list() ) {
if ( filter.accept( this, s ) ) {
ret.Add( s );
}
}
return ret.ToArray();
}
/// <summary>
/// この抽象パス名が示すディレクトリ内のファイルを示す抽象パス名の配列を返します。
/// </summary>
public File[] listFiles() {
string[] files = System.IO.Directory.GetFiles( m_path );
File[] ret = new File[files.Length];
for ( int i = 0; i < files.Length; i++ ) {
ret[i] = new File( m_path + separator + files[i] );
}
return ret;
}
/// <summary>
/// この抽象パス名が示すディレクトリにあるファイルおよびディレクトリの中で、指定されたフィルタの基準を満たすものの抽象パス名の配列を返します。
/// </summary>
public File[] listFiles( FileFilter filter ) {
List<File> ret = new List<File>();
foreach ( string s in list() ) {
File f = new File( m_path + separator + s );
if ( filter.accept( f ) ) {
ret.Add( f );
}
}
return ret.ToArray();
}
/// <summary>
/// この抽象パス名が示すディレクトリにあるファイルおよびディレクトリの中で、指定されたフィルタの基準を満たすものの抽象パス名の配列を返します。
/// </summary>
public File[] listFiles( FilenameFilter filter ) {
List<File> ret = new List<File>();
foreach ( string s in list() ) {
if ( filter.accept( this, s ) ) {
File f = new File( m_path + separator + s );
ret.Add( f );
}
}
return ret.ToArray();
}
/// <summary>
/// 有効なファイルシステムのルートをリスト表示します。
/// </summary>
public static File[] listRoots() {
throw new NotImplementedException();
}
/// <summary>
/// この抽象パス名が示すディレクトリを生成します。
/// </summary>
public bool mkdir() {
try {
System.IO.Directory.CreateDirectory( m_path );
return true;
} catch {
}
return false;
}
/// <summary>
/// この抽象パス名が示すディレクトリを生成します。
/// </summary>
public bool mkdirs() {
throw new NotImplementedException();
}
/// <summary>
/// この抽象パス名が示すファイルの名前を変更します。
/// </summary>
public bool renameTo( File dest ) {
try {
System.IO.File.Replace( m_path, dest.m_path, m_path + "BAK" );
return true;
} catch {
}
return false;
}
/// <summary>
/// この抽象パス名に所有者の実行権を設定する簡易メソッドです。
/// </summary>
public bool setExecutable( bool executable ) {
throw new NotImplementedException();
}
/// <summary>
/// この抽象パス名に所有者または全員の実行権を設定します。
/// </summary>
public bool setExecutable( bool executable, bool ownerOnly ) {
throw new NotImplementedException();
}
/// <summary>
/// この抽象パス名が示すファイルまたはディレクトリが変更された時刻を設定します。
/// </summary>
public bool setLastModified( long time ) {
try {
System.IO.FileInfo f = new System.IO.FileInfo( m_path );
f.LastWriteTimeUtc = new DateTime( time );
return true;
} catch {
}
return false;
}
/// <summary>
/// この抽象パス名に所有者の読み取り権を設定する簡易メソッドです。
/// </summary>
public bool setReadable( bool readable ) {
throw new NotImplementedException();
}
/// <summary>
/// この抽象パス名に所有者または全員の読み取り権を設定します。
/// </summary>
public bool setReadable( bool readable, bool ownerOnly ) {
throw new NotImplementedException();
}
/// <summary>
/// この抽象パス名が示すファイルまたはディレクトリにマークを設定し、読み込みオペレーションだけが許可されるようにします。
/// </summary>
public bool setReadOnly() {
throw new NotImplementedException();
}
/// <summary>
/// この抽象パス名に所有者の書き込み権を設定する簡易メソッドです。
/// </summary>
public bool setWritable( bool writable ) {
throw new NotImplementedException();
}
/// <summary>
/// この抽象パス名に所有者または全員の書き込み権を設定します。
/// </summary>
public bool setWritable( bool writable, bool ownerOnly ) {
throw new NotImplementedException();
}
/// <summary>
/// この抽象パス名のパス名文字列を返します。
/// </summary>
public string toString() {
return m_path;
}
}
public interface FilenameFilter {
bool accept( File dir, String name );
}
public interface FileFilter {
bool accept( File filepath );
}
}
#endif

8
bocoree/makefile Normal file
View File

@@ -0,0 +1,8 @@
CP=cp
RM=rm
bocoree.dll: *.cs
gmcs -recurse:*.cs -unsafe+ -target:library -out:bocoree.dll -r:System,System.Drawing,System.Windows.Forms
clean:
$(RM) bocoree.dll

275
bocoree/math.cs Normal file
View File

@@ -0,0 +1,275 @@
#if !JAVA
/*
* math.cs
* Copyright (c) 2008-2009 kbinani
*
* This file is part of bocoree.
*
* bocoree is free software; you can redistribute it and/or
* modify it under the terms of the BSD License.
*
* bocoree is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
using System;
using System.Collections.Generic;
namespace bocoree {
public partial class math {
private const double _PI2 = 2.0 * Math.PI;
private const double _PI4 = 4.0 * Math.PI;
private const double _PI6 = 6.0 * Math.PI;
private const double _PI8 = 8.0 * Math.PI;
public enum WindowFunctionType {
Hamming,
rectangular,
Gauss,
Hann,
Blackman,
Bartlett,
Nuttall,
Blackman_Harris,
Blackman_Nattall,
flap_top,
Parzen,
Akaike,
Welch,
Kaiser,
}
public static double window_func( WindowFunctionType type, double x ) {
switch ( type ) {
case WindowFunctionType.Akaike:
return wnd_akaike( x );
case WindowFunctionType.Bartlett:
return wnd_bartlett( x );
case WindowFunctionType.Blackman:
return wnd_blackman( x );
case WindowFunctionType.Blackman_Harris:
return wnd_blackman_harris( x );
case WindowFunctionType.Blackman_Nattall:
return wnd_blackman_nattall( x );
case WindowFunctionType.flap_top:
return wnd_flap_top( x );
case WindowFunctionType.Gauss:
throw new ApplicationException( "too few argument for Gauss window function" );
case WindowFunctionType.Hamming:
return wnd_hamming( x );
case WindowFunctionType.Hann:
return wnd_hann( x );
case WindowFunctionType.Kaiser:
throw new ApplicationException( "too few argument for Kaiser window function" );
case WindowFunctionType.Nuttall:
return wnd_nuttall( x );
case WindowFunctionType.Parzen:
return wnd_parzen( x );
case WindowFunctionType.rectangular:
return wnd_rectangular( x );
case WindowFunctionType.Welch:
return wnd_welch( x );
}
return 0.0;
}
public static double window_func( WindowFunctionType type, double x, params double[] param ) {
switch ( type ) {
case WindowFunctionType.Akaike:
return wnd_akaike( x );
case WindowFunctionType.Bartlett:
return wnd_bartlett( x );
case WindowFunctionType.Blackman:
return wnd_blackman( x );
case WindowFunctionType.Blackman_Harris:
return wnd_blackman_harris( x );
case WindowFunctionType.Blackman_Nattall:
return wnd_blackman_nattall( x );
case WindowFunctionType.flap_top:
return wnd_flap_top( x );
case WindowFunctionType.Gauss:
return wnd_gauss( x, param[0] );
case WindowFunctionType.Hamming:
return wnd_hamming( x );
case WindowFunctionType.Hann:
return wnd_hann( x );
case WindowFunctionType.Kaiser:
return wnd_kaiser( x, param[0] );
case WindowFunctionType.Nuttall:
return wnd_nuttall( x );
case WindowFunctionType.Parzen:
return wnd_parzen( x );
case WindowFunctionType.rectangular:
return wnd_rectangular( x );
case WindowFunctionType.Welch:
return wnd_welch( x );
}
return 0.0;
}
public static double wnd_kaiser( double x, double alpha ) {
if ( 0.0 <= x && x <= 1.0 ) {
double t = 2.0 * x - 1.0;
return besi0( Math.PI * alpha * Math.Sqrt( 1.0 - t * t ) ) / besi0( Math.PI * alpha );
} else {
return 0.0;
}
}
public static double wnd_welch( double x ) {
if ( 0.0 <= x && x <= 1.0 ) {
return 4.0 * x * (1.0 - x);
} else {
return 0.0;
}
}
public static double wnd_akaike( double x ) {
if ( 0.0 <= x && x <= 1.0 ) {
return 0.625 - 0.5 * Math.Cos( _PI2 * x )
- 0.125 * Math.Cos( _PI4 * x );
} else {
return 0.0;
}
}
public static double wnd_parzen( double x ) {
double x0 = Math.Abs( x );
if ( x0 <= 1.0 ) {
return (0.75 * x0 - 1.5) * x0 * x0 + 1.0;
} else {
x0 = 2.0 - x0;
return 0.25 * x0 * x0 * x0;
}
}
public static double wnd_flap_top( double x ) {
if ( 0.0 <= x && x <= 1.0 ) {
return 1.0 - 1.93 * Math.Cos( _PI2 * x )
+ 1.29 * Math.Cos( _PI4 * x )
- 0.388 * Math.Cos( _PI6 * x )
+ 0.032 * Math.Cos( _PI8 * x );
} else {
return 0.0;
}
}
public static double wnd_blackman_nattall( double x ) {
if ( 0.0 <= x && x <= 1.0 ) {
return 0.3635819 - 0.4891775 * Math.Cos( _PI2 * x )
+ 0.1365995 * Math.Cos( _PI4 * x )
- 0.0106411 * Math.Cos( _PI6 * x );
} else {
return 0.0;
}
}
public static double wnd_blackman_harris( double x ) {
if ( 0.0 <= x && x <= 1.0 ) {
return 0.35875 - 0.48829 * Math.Cos( _PI2 * x )
+ 0.14128 * Math.Cos( _PI4 * x )
- 0.01168 * Math.Cos( _PI6 * x );
} else {
return 0.0;
}
}
public static double wnd_nuttall( double x ) {
if ( 0.0 <= x && x <= 1.0 ) {
return 0.355768 - 0.487396 * Math.Cos( _PI2 * x )
+ 0.144232 * Math.Cos( _PI4 * x )
- 0.012604 * Math.Cos( _PI6 * x );
} else {
return 0.0;
}
}
public static double wnd_bartlett( double x ) {
if ( 0.0 <= x && x <= 1.0 ) {
return 1.0 - 2.0 * Math.Abs( x - 0.5 );
} else {
return 0.0;
}
}
public static double wnd_blackman( double x ) {
if ( 0.0 <= x && x <= 1.0 ) {
return 0.42 - 0.5 * Math.Cos( _PI2 * x ) + 0.08 * Math.Cos( _PI4 * x );
} else {
return 0.0;
}
}
public static double wnd_hann( double x ) {
if ( 0.0 <= x && x <= 1.0 ) {
return 0.5 - 0.5 * Math.Cos( _PI2 * x );
} else {
return 0.0;
}
}
public static double wnd_gauss( double x, double sigma ) {
return Math.Exp( -x * x / (sigma * sigma) );
}
public static double wnd_rectangular( double x ) {
if ( 0.0 <= x && x <= 1.0 ) {
return 1.0;
} else {
return 0.0;
}
}
public static double wnd_hamming( double x ) {
if ( 0.0 <= x && x <= 1.0 ) {
return 0.54 - 0.46 * Math.Cos( _PI2 * x );
} else {
return 0.0;
}
}
public static double besi0( double x ) {
int i;
double w, wx375;
double[] a = { 1.0, 3.5156229, 3.0899424,
1.2067492, 0.2659732, 0.0360768};
double[] b = { 0.39894228, 0.013285917, 0.002253187,
-0.001575649, 0.009162808, -0.020577063,
0.026355372, -0.016476329};
if ( x < 0.0 ) {
return 0.0;
}
if ( x <= 3.75 ) {
wx375 = x * x / 14.0625;
w = 0.0045813;
for ( i = 5; i >= 0; i-- ) {
w = w * wx375 + a[i];
}
return w;
}
wx375 = 3.75 / x;
w = 0.003923767;
for ( i = 7; i >= 0; i-- ) {
w = w * wx375 + b[i];
}
return w / Math.Sqrt( x ) * Math.Exp( x );
}
public static double erfcc( double x ) {
double t, z, res;
z = Math.Abs( x );
t = 1.0 / (1.0 + 0.5 * z);
res = t * Math.Exp( -z * z - 1.26551223 + t * (1.00002368 + t * (0.37409196
+ t * (0.09678418 + t * (-0.18628806 + t * (0.27886807
+ t * (-1.13520398 + t * (1.48851587 + t * (-0.82215223
+ t * 0.17087277)))))))) );
if ( x < 0.0 ) {
res = 2.0 - res;
}
return res;
}
}
}
#endif

172
bocoree/misc.cs Normal file
View File

@@ -0,0 +1,172 @@
#if !JAVA
/*
* misc.cs
* Copyright (c) 2009 kbinani
*
* This file is part of bocoree.
*
* bocoree is free software; you can redistribute it and/or
* modify it under the terms of the BSD License.
*
* bocoree is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
using System;
using System.IO;
using System.Security.Cryptography;
using System.Text;
using System.Collections.Generic;
namespace bocoree {
public static class Misc {
/// <summary>
/// Reflectionを利用して、インスタンスのディープなクローニングを行います。
/// クローン操作の対象はインスタンスのフィールドであり、値型のものは単なる代入を、
/// 参照型の物であってかつClone(void)メソッドが実装されているものはCloneしたものを、
/// それ以外は単に参照が代入されます
/// </summary>
/// <param name="obj"></param>
/// <returns></returns>
public static object obj_clone( object obj ) {
Type t = obj.GetType();
object ret;
if ( t.IsValueType ) {
return obj; //値型の場合
} else {
System.Reflection.MethodInfo mi = t.GetMethod( "Clone", new Type[] { } );
if ( mi != null && (mi.ReturnType == typeof( object ) || mi.ReturnType == t) ) {
// return値がobject型またはt型のCloneメソッドを持っている場合
ret = mi.Invoke( obj, new object[] { } );
} else {
// Cloneメソッドが無い場合。型のフィールドを列挙してobj_cloneをRecursiveに呼び出す
// 最初にコンストラクタを取得
System.Reflection.ConstructorInfo ctor = t.GetConstructor( new Type[] { } );
if ( ctor == null ) {
// 引数無しのコンストラクタが必要。無い場合はどうしようもないので例外を投げる
throw new ApplicationException( "obj_clone requires zero-argument constructor" );
}
// インスタンスを作成
ret = ctor.Invoke( new object[] { } );
// 全てのフィールドに対してobj_cloneを呼び、値をセットする
foreach ( System.Reflection.FieldInfo fi in t.GetFields() ) {
Type fieldtype = fi.FieldType;
fi.SetValue( ret, obj_clone( obj ) );
}
}
return ret;
}
}
public static string getmd5( string s ) {
MD5 md5 = MD5.Create();
byte[] data = Encoding.Unicode.GetBytes( s );
byte[] hash = md5.ComputeHash( data );
return BitConverter.ToString( hash ).ToLower().Replace( "-", "_" );
}
public static string getmd5( FileStream file_stream ) {
MD5 md5 = MD5.Create();
byte[] hash = md5.ComputeHash( file_stream );
return BitConverter.ToString( hash ).ToLower().Replace( "-", "_" );
}
/// <summary>
/// 現在の実行アセンブリで使用されている型のリストを取得します
/// </summary>
/// <returns></returns>
public static Type[] get_executing_types() {
System.Reflection.Assembly asm = System.Reflection.Assembly.GetExecutingAssembly();
List<Type> types = new List<Type>( asm.GetTypes() );
foreach ( System.Reflection.AssemblyName asmname in asm.GetReferencedAssemblies() ) {
System.Reflection.Assembly asmref = System.Reflection.Assembly.Load( asmname );
types.AddRange( asmref.GetTypes() );
}
asm = System.Reflection.Assembly.GetCallingAssembly();
types.AddRange( asm.GetTypes() );
foreach ( System.Reflection.AssemblyName asmname in asm.GetReferencedAssemblies() ) {
System.Reflection.Assembly asmref = System.Reflection.Assembly.Load( asmname );
types.AddRange( asmref.GetTypes() );
}
asm = System.Reflection.Assembly.GetEntryAssembly();
types.AddRange( asm.GetTypes() );
foreach ( System.Reflection.AssemblyName asmname in asm.GetReferencedAssemblies() ) {
System.Reflection.Assembly asmref = System.Reflection.Assembly.Load( asmname );
types.AddRange( asmref.GetTypes() );
}
List<Type> ret = new List<Type>();
foreach ( Type t in types ) {
if ( t.IsPublic && !ret.Contains( t ) ) {
ret.Add( t );
}
}
return ret.ToArray();
}
/// <summary>
/// 現在の実行アセンブリで使用されている名前空間のリストを取得します
/// </summary>
/// <returns></returns>
public static string[] get_executing_namespaces() {
Type[] types = get_executing_types();
List<string> list = new List<string>();
foreach ( Type t in types ) {
if ( !list.Contains( t.Namespace ) ) {
list.Add( t.Namespace );
}
}
list.Sort();
return list.ToArray();
}
}
public static class debug {
private static StreamWriter s_debug_out = null;
private static string s_path = "";
public static void force_logfile_path( string path ) {
try {
if ( s_debug_out != null ) {
s_debug_out.Close();
s_debug_out = new StreamWriter( path );
}
} catch {
}
s_path = path;
}
public static void push_log( string s ) {
try {
if ( s_debug_out == null ) {
if ( s_path == "" ) {
s_debug_out = new StreamWriter( Path.Combine( System.Windows.Forms.Application.StartupPath, "run.log" ) );
} else {
s_debug_out = new StreamWriter( s_path );
}
s_debug_out.AutoFlush = true;
s_debug_out.WriteLine( "************************************************************************" );
s_debug_out.WriteLine( " Date: " + DateTime.Now.ToString() );
s_debug_out.WriteLine( "------------------------------------------------------------------------" );
}
s_debug_out.WriteLine( s );
} catch ( Exception ex ) {
Console.WriteLine( "bocoree.debug.push_log; log file I/O Exception" );
}
Console.WriteLine( s );
}
public static void close() {
if ( s_debug_out != null ) {
s_debug_out.Close();
s_debug_out = null;
s_path = "";
}
}
}
}
#endif

86
bocoree/swing.cs Normal file
View File

@@ -0,0 +1,86 @@
/*
* swing.cs
* Copyright (c) 2009 kbinani
*
* This file is part of bocoree.
*
* bocoree is free software; you can redistribute it and/or
* modify it under the terms of the BSD License.
*
* bocoree is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
#if !JAVA
using System;
using bocoree.java.awt.event_;
namespace bocoree.javax.swing {
public class KeyStroke {
public System.Windows.Forms.Keys keys = System.Windows.Forms.Keys.None;
private static bocoree.java.util.TreeMap<string, int> keyCodes = null;
private KeyStroke(){
}
public int getKeyCode() {
System.Windows.Forms.Keys k = keys;
if ( (keys & System.Windows.Forms.Keys.Alt) == System.Windows.Forms.Keys.Alt ) {
k -= System.Windows.Forms.Keys.Alt;
}
if ( (keys & System.Windows.Forms.Keys.Control) == System.Windows.Forms.Keys.Control ) {
k -= System.Windows.Forms.Keys.Control;
}
if ( (keys & System.Windows.Forms.Keys.Shift) == System.Windows.Forms.Keys.Shift ) {
k -= System.Windows.Forms.Keys.Shift;
}
return (int)k;
}
public int getModifiers() {
int modifier = 0;
if ( (keys & System.Windows.Forms.Keys.Alt) == System.Windows.Forms.Keys.Alt ) {
modifier += InputEvent.ALT_MASK;
}
if ( (keys & System.Windows.Forms.Keys.Control) == System.Windows.Forms.Keys.Control ) {
modifier += InputEvent.CTRL_MASK;
}
if ( (keys & System.Windows.Forms.Keys.Shift) == System.Windows.Forms.Keys.Shift ) {
modifier += InputEvent.SHIFT_MASK;
}
return modifier;
}
public static KeyStroke getKeyStroke( int keyCode, int modifiers ) {
KeyStroke ret = new KeyStroke();
if( (InputEvent.ALT_MASK & modifiers) == InputEvent.ALT_MASK ){
ret.keys = ret.keys | System.Windows.Forms.Keys.Alt;
}
if ( (InputEvent.CTRL_MASK & modifiers) == InputEvent.CTRL_MASK ){
ret.keys = ret.keys | System.Windows.Forms.Keys.Control;
}
if ( (InputEvent.SHIFT_MASK & modifiers) == InputEvent.SHIFT_MASK ){
ret.keys = ret.keys | System.Windows.Forms.Keys.Shift;
}
System.Windows.Forms.Keys key = (System.Windows.Forms.Keys)keyCode;
ret.keys = ret.keys | key;
return ret;
}
/* private static bocoree.util.TreeMap<string, int> getKeyCodes() {
if ( keyCodes == null ) {
keyCodes = new bocoree.util.TreeMap<string, int>();
foreach ( System.Reflection.FieldInfo fi in typeof( bocoree.awt.event_.KeyEvent ).GetFields() ) {
if ( fi.IsStatic && fi.IsPublic && fi.FieldType == typeof( int ) ) {
string name = fi.Name;
int value = fi.GetValue( typeof( bocoree.awt.event_.KeyEvent ) );
keyCodes.put( name, value );
}
}
}
return keyCodes;
}*/
}
}
#endif

369
bocoree/util.cs Normal file
View File

@@ -0,0 +1,369 @@
#if !JAVA
/*
* TreeMap.cs
* Copyright (c) 2009 kbinani
*
* This file is part of bocoree.
*
* bocoree is free software; you can redistribute it and/or
* modify it under the terms of the BSD License.
*
* bocoree is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
//#define DICTIONARY_TEST
using System;
using System.Collections.Generic;
using System.Runtime.Serialization;
namespace bocoree.java.util {
using boolean = Boolean;
public interface Entry<K, V> {
}
public interface Map<K, V> {
/// <summary>
/// マップからマッピングをすべて削除します (任意のオペレーション)。
/// </summary>
void clear();
/// <summary>
/// マップが指定のキーのマッピングを保持する場合に true を返します。
/// </summary>
/// <param name="key"></param>
/// <returns></returns>
boolean containsKey( Object key );
/// <summary>
/// マップが 1 つまたは複数のキーと指定された値をマッピングしている場合に true を返します。
/// </summary>
/// <param name="value"></param>
/// <returns></returns>
boolean containsValue( Object value );
/// <summary>
/// このマップに含まれるマップの Set ビューを返します。
/// </summary>
/// <returns></returns>
Set<Entry<K, V>> entrySet();
/// <summary>
/// 指定されたオブジェクトがこのマップと等しいかどうかを比較します。
/// </summary>
/// <param name="o"></param>
/// <returns></returns>
boolean equals( Object o );
/// <summary>
/// 指定されたキーがマップされている値を返します。
/// </summary>
/// <param name="key"></param>
/// <returns></returns>
V get( Object key );
/// <summary>
/// マップのハッシュコード値を返します。
/// </summary>
/// <returns></returns>
int hashCode();
/// <summary>
/// マップがキーと値のマッピングを保持しない場合に true を返します。 }
/// </summary>
/// <returns></returns>
boolean isEmpty();
}
public interface Set<E> {
/// <summary>
/// 指定された要素がセット内になかった場合、セットに追加します (任意のオペレーション)。
/// </summary>
/// <param name="e"></param>
/// <returns></returns>
boolean add( E e );
/// <summary>
/// 指定されたコレクションのすべての要素について、その要素がこのセット内にない場合、セットに追加します (任意のオペレーション)。
/// </summary>
/// <param name="extends"></param>
/// <returns></returns>
boolean addAll( Collection<E> c );
/// <summary>
/// セットからすべての要素を削除します (任意のオペレーション)。
/// </summary>
void clear();
/// <summary>
/// セットが、指定された要素を保持している場合に true を返します。
/// </summary>
/// <param name="o"></param>
/// <returns></returns>
boolean contains( Object o );
/// <summary>
/// 指定されたコレクションのすべての要素がセット内にある場合に true を返します。
/// </summary>
/// <param name="?"></param>
/// <returns></returns>
boolean containsAll( Collection<E> c );
/// <summary>
/// 指定されたオブジェクトがセットと同じかどうかを比較します。
/// </summary>
/// <param name="o"></param>
/// <returns></returns>
boolean equals( Object o );
/// <summary>
/// セットのハッシュコード値を返します。
/// </summary>
/// <returns></returns>
int hashCode();
/// <summary>
/// セットが要素を 1 つも保持していない場合に true を返します。
/// </summary>
/// <returns></returns>
boolean isEmpty();
/// <summary>
/// セット内の各要素についての反復子を返します。
/// </summary>
/// <returns></returns>
Iterator iterator();
/// <summary>
/// 指定された要素がセット内にあった場合、セットから削除します (任意のオペレーション)。
/// </summary>
/// <param name="o"></param>
/// <returns></returns>
boolean remove( Object o );
/// <summary>
/// このセットから、指定されたコレクションに含まれる要素をすべて削除します (任意のオペレーション)。
/// </summary>
/// <param name="?"></param>
/// <returns></returns>
boolean removeAll( Collection<E> c );
/// <summary>
/// セット内の要素のうち、指定されたコレクション内にある要素だけを保持します (任意のオペレーション)。
/// </summary>
/// <param name="?"></param>
/// <returns></returns>
boolean retainAll( Collection<E> c );
/// <summary>
/// セット内の要素数 (そのカーディナリティ) を返します。
/// </summary>
/// <returns></returns>
int size();
/// <summary>
/// セット内のすべての要素が格納されている配列を返します。
/// </summary>
/// <returns></returns>
Object[] toArray();
/// <summary>
/// セット内のすべての要素を格納している配列を返します。
/// </summary>
/// <param name="a"></param>
T[] toArray<T>( T[] a );
}
public interface Collection<E> {
}
/*class TreeMapItem<K, V> : Entry<K, V> {
public K key;
public V value;
public TreeMapItem( K k, V v ) {
key = k;
value = v;
}
}
class TreeMapItemSet<K, V> : Set<Entry<K, V>> {
private TreeMap<K, V> m_dict;
public TreeMapItemSet( TreeMap<K, V> item ) {
m_dict = item;
}
public T[] toArray<T>( T[] arr ) {
if ( typeof( T ) == typeof( Entry<K, V> ) ) {
int c = size();
TreeMapItem<K, V>[] items = new TreeMapItem<K, V>[c];
int i = 0;
foreach ( K key in m_dict.Keys ) {
items[i] = new TreeMapItem<K, V>( key, m_dict[key] );
i++;
}
return (T[])(object)items;
} else {
return null;
}
}
public Object[] toArray() {
}
public int size() {
return m_dict.Count;
}
public bool retainAll( Collection<Entry<K, V>> v ) {
}
public bool removeAll( Collection<Entry<K, V>> v ) {
}
public bool remove( Object obj ) {
}
public Iterator iterator() {
}
public bool isEmpty() {
return m_dict.Count <= 0;
}
public int hashCode() {
return m_dict.hashCode();
}
public bool equals( Object obj ) {
return m_dict.equals( obj );
}
public bool contains( Object obj ) {
}
public void clear() {
m_dict.clear();
}
public bool containsAll( Collection<Entry<K, V>> v ) {
}
public bool addAll( Collection<Entry<K, V>> v ) {
}
public bool add( Entry<K, V> v ) {
}
}*/
[Serializable]
#if DICTIONARY_TEST
public class TreeMap<K, V> {
public V remove( Object key ) {
return default( V );
}
public Vector<K> keySet() {
return null;
}
public V get( K key ) {
return default( V );
}
public V put( K key, V value ) {
return default( V );
}
public bool containsKey( Object key ) {
return false;
}
public void clear() {
}
public int size() {
return 0;
}
}
#else
public class TreeMap<K, V> : SortedDictionary<K, V>/*, Map<K, V>*/ {
public TreeMap()
: base() {
}
/*protected TreeMap( SerializationInfo info, StreamingContext context )
: base( info, context ) {
}*/
public K lastKey() {
if ( base.Count <= 0 ) {
throw new ApplicationException( "NoSuchElementException" );
} else {
K v = default( K );
foreach ( K key in base.Keys ) {
v = key;
}
return v;
}
}
public K firstKey() {
if ( base.Count <= 0 ) {
throw new ApplicationException( "NoSuchElementException" );
} else {
foreach ( K key in base.Keys ) {
return key;
}
throw new ApplicationException( "NoSuchElementException" );
}
}
public V remove( Object key ) {
K k = (K)key;
if ( base.ContainsKey( k ) ) {
V old = base[k];
base.Remove( k );
return old;
} else {
base.Remove( k );
return default( V );
}
}
public Vector<K> keySet() {
return new Vector<K>( base.Keys );
}
public V get( Object key ) {
return base[(K)key];
}
public int size() {
return base.Count;
}
public bool containsKey( Object key ) {
return base.ContainsKey( (K)key );
}
public bool containsValue( Object value ) {
return base.ContainsValue( (V)value );
}
public bool equals( Object obj ) {
return base.Equals( obj );
}
public void clear() {
base.Clear();
}
/*public Set<Entry<K, V>> entrySet() {
return new TreeMapItemSet<K, V>( this );
}*/
public bool isEmpty() {
return base.Count <= 0;
}
public int hashCode() {
return base.GetHashCode();
}
public V put( K key, V value ) {
if ( base.ContainsKey( key ) ) {
V old = base[key];
base[key] = value;
return old;
} else {
base.Add( key, value );
return default( V );
}
}
}
#endif
}
#endif

Some files were not shown because too many files have changed in this diff Show More