2010-03-16 20:14:08 -07:00
|
|
|
|
#if !JAVA
|
|
|
|
|
/*
|
2009-06-25 07:16:22 -07:00
|
|
|
|
* VersionInfo.cs
|
|
|
|
|
* Copyright (c) 2008-2009 kbinani
|
|
|
|
|
*
|
|
|
|
|
* This file is part of Boare.Lib.AppUtil.
|
|
|
|
|
*
|
|
|
|
|
* Boare.Lib.AppUtil is free software; you can redistribute it and/or
|
|
|
|
|
* modify it under the terms of the BSD License.
|
|
|
|
|
*
|
|
|
|
|
* Boare.Lib.AppUtil 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;
|
2010-03-16 20:14:08 -07:00
|
|
|
|
//using System.Drawing;
|
|
|
|
|
//using System.Drawing.Drawing2D;
|
|
|
|
|
//using System.Windows.Forms;
|
|
|
|
|
using bocoree;
|
|
|
|
|
using bocoree.java.awt;
|
|
|
|
|
using bocoree.java.awt.image;
|
2009-06-25 07:16:22 -07:00
|
|
|
|
|
|
|
|
|
namespace Boare.Lib.AppUtil {
|
2010-03-16 20:14:08 -07:00
|
|
|
|
using java = bocoree.java;
|
|
|
|
|
using javax = bocoree.javax;
|
|
|
|
|
using Graphics = bocoree.java.awt.Graphics2D;
|
2009-06-25 07:16:22 -07:00
|
|
|
|
|
2010-03-16 20:14:08 -07:00
|
|
|
|
public partial class VersionInfo : System.Windows.Forms.Form {
|
2009-06-25 07:16:22 -07:00
|
|
|
|
DateTime m_scroll_started;
|
|
|
|
|
private AuthorListEntry[] m_credit;
|
|
|
|
|
const float m_speed = 35f;
|
|
|
|
|
string m_version;
|
|
|
|
|
bool m_credit_mode = false;
|
|
|
|
|
float m_last_t = 0f;
|
|
|
|
|
float m_last_speed = 0f;
|
|
|
|
|
float m_shift = 0f;
|
|
|
|
|
int m_button_width_about = 75;
|
|
|
|
|
int m_button_width_credit = 75;
|
2010-03-16 20:14:08 -07:00
|
|
|
|
BufferedImage m_scroll;
|
2009-06-25 07:16:22 -07:00
|
|
|
|
const int m_height = 380;
|
2010-03-16 20:14:08 -07:00
|
|
|
|
readonly Color m_background = Color.white;
|
2009-06-25 07:16:22 -07:00
|
|
|
|
private string m_app_name = "";
|
2010-03-16 20:14:08 -07:00
|
|
|
|
private Color m_app_name_color = Color.black;
|
|
|
|
|
private Color m_version_color = new Color( 105, 105, 105 );
|
2009-06-25 07:16:22 -07:00
|
|
|
|
private bool m_shadow_enablde = true;
|
|
|
|
|
|
|
|
|
|
public VersionInfo( string app_name, string version ) {
|
|
|
|
|
m_version = version;
|
|
|
|
|
m_app_name = app_name;
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
ApplyLanguage();
|
|
|
|
|
|
2010-03-16 20:14:08 -07:00
|
|
|
|
this.SetStyle( System.Windows.Forms.ControlStyles.DoubleBuffer, true );
|
|
|
|
|
this.SetStyle( System.Windows.Forms.ControlStyles.UserPaint, true );
|
|
|
|
|
this.SetStyle( System.Windows.Forms.ControlStyles.AllPaintingInWmPaint, true );
|
2009-06-25 07:16:22 -07:00
|
|
|
|
|
|
|
|
|
m_credit = new AuthorListEntry[] { };
|
|
|
|
|
btnSaveAuthorList.Visible = false;
|
|
|
|
|
#if DEBUG
|
|
|
|
|
GenerateAuthorList();
|
|
|
|
|
btnSaveAuthorList.Visible = true;
|
|
|
|
|
btnSaveAuthorList.Click += new EventHandler( btnSaveAuthorList_Click );
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool SaveAuthorListVisible {
|
|
|
|
|
set {
|
|
|
|
|
btnSaveAuthorList.Visible = value;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static string _( string s ) {
|
2010-03-16 20:14:08 -07:00
|
|
|
|
return Messaging.getMessage( s );
|
2009-06-25 07:16:22 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// バージョン番号表示の文字色を取得または設定します
|
|
|
|
|
/// </summary>
|
|
|
|
|
public Color VersionColor {
|
|
|
|
|
get {
|
|
|
|
|
return m_version_color;
|
|
|
|
|
}
|
|
|
|
|
set {
|
|
|
|
|
m_version_color = value;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// アプリケーション名表示の文字色を取得または設定します
|
|
|
|
|
/// </summary>
|
|
|
|
|
public Color AppNameColor {
|
|
|
|
|
get {
|
|
|
|
|
return m_app_name_color;
|
|
|
|
|
}
|
|
|
|
|
set {
|
|
|
|
|
m_app_name_color = value;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-03-16 20:14:08 -07:00
|
|
|
|
public BufferedImage Credit {
|
2009-06-25 07:16:22 -07:00
|
|
|
|
set {
|
|
|
|
|
m_scroll = value;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string AppName {
|
|
|
|
|
get {
|
|
|
|
|
return m_app_name;
|
|
|
|
|
}
|
|
|
|
|
set {
|
|
|
|
|
m_app_name = value;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public AuthorListEntry[] AuthorList {
|
|
|
|
|
set {
|
|
|
|
|
m_credit = value;
|
|
|
|
|
GenerateAuthorList();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void GenerateAuthorList() {
|
|
|
|
|
const float shadow_shift = 2f;
|
|
|
|
|
const string font_name = "Arial";
|
|
|
|
|
const int font_size = 10;
|
2010-03-16 20:14:08 -07:00
|
|
|
|
Font font = new Font( font_name, java.awt.Font.PLAIN, font_size );
|
|
|
|
|
Dimension size = Boare.Lib.AppUtil.Util.measureString( "Qjqp", font );
|
2009-06-25 07:16:22 -07:00
|
|
|
|
float width = this.Width;
|
2010-03-16 20:14:08 -07:00
|
|
|
|
float height = size.height;
|
2010-04-10 23:29:55 -07:00
|
|
|
|
System.Drawing.StringFormat sf = new System.Drawing.StringFormat();
|
2010-03-16 20:14:08 -07:00
|
|
|
|
m_scroll = new BufferedImage( (int)width, (int)(40f + m_credit.Length * height * 1.1f), BufferedImage.TYPE_INT_BGR );
|
|
|
|
|
Graphics2D g = m_scroll.createGraphics();
|
2010-04-10 23:29:55 -07:00
|
|
|
|
g.setColor( Color.white );
|
|
|
|
|
g.fillRect( 0, 0, m_scroll.getWidth(), m_scroll.getHeight() );
|
|
|
|
|
sf.Alignment = System.Drawing.StringAlignment.Center;
|
|
|
|
|
Font f = new Font( font_name, java.awt.Font.BOLD, (int)(font_size * 1.1f) );
|
|
|
|
|
g.setFont( f );
|
2010-03-16 20:14:08 -07:00
|
|
|
|
if ( m_shadow_enablde ) {
|
|
|
|
|
g.setColor( new Color( 0, 0, 0, 40 ) );
|
2010-04-10 23:29:55 -07:00
|
|
|
|
g.nativeGraphics.DrawString(
|
|
|
|
|
m_app_name,
|
|
|
|
|
f.font,
|
|
|
|
|
g.brush,
|
|
|
|
|
new System.Drawing.RectangleF( shadow_shift, shadow_shift, width, height ),
|
|
|
|
|
sf );
|
2010-03-16 20:14:08 -07:00
|
|
|
|
}
|
|
|
|
|
g.setColor( Color.black );
|
2010-04-10 23:29:55 -07:00
|
|
|
|
g.nativeGraphics.DrawString(
|
|
|
|
|
m_app_name,
|
|
|
|
|
f.font,
|
|
|
|
|
g.brush,
|
|
|
|
|
new System.Drawing.RectangleF( 0f, 0f, width, height ),
|
|
|
|
|
sf );
|
2010-03-16 20:14:08 -07:00
|
|
|
|
for ( int i = 0; i < m_credit.Length; i++ ) {
|
2010-04-10 23:29:55 -07:00
|
|
|
|
Font f2 = new Font( font_name, m_credit[i].getStyle(), font_size );
|
|
|
|
|
g.setFont( f2 );
|
2009-06-25 07:16:22 -07:00
|
|
|
|
if ( m_shadow_enablde ) {
|
2010-03-16 20:14:08 -07:00
|
|
|
|
g.setColor( new Color( 0, 0, 0, 40 ) );
|
2010-04-10 23:29:55 -07:00
|
|
|
|
g.nativeGraphics.DrawString(
|
|
|
|
|
m_credit[i].getName(),
|
|
|
|
|
f2.font,
|
|
|
|
|
g.brush,
|
|
|
|
|
new System.Drawing.RectangleF( 0f + shadow_shift, 40f + i * height * 1.1f + shadow_shift, width, height ),
|
|
|
|
|
sf );
|
2009-06-25 07:16:22 -07:00
|
|
|
|
}
|
2010-03-16 20:14:08 -07:00
|
|
|
|
g.setColor( Color.black );
|
2010-04-10 23:29:55 -07:00
|
|
|
|
g.nativeGraphics.DrawString(
|
|
|
|
|
m_credit[i].getName(),
|
|
|
|
|
f2.font,
|
|
|
|
|
g.brush,
|
|
|
|
|
new System.Drawing.RectangleF( 0f, 40f + i * height * 1.1f, width, height ),
|
|
|
|
|
sf );
|
2009-06-25 07:16:22 -07:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void btnSaveAuthorList_Click( object sender, EventArgs e ) {
|
|
|
|
|
#if DEBUG
|
2010-03-16 20:14:08 -07:00
|
|
|
|
using ( System.Windows.Forms.SaveFileDialog dlg = new System.Windows.Forms.SaveFileDialog() ){
|
|
|
|
|
if( dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK ){
|
|
|
|
|
javax.imageio.ImageIO.write( m_scroll, "png", new java.io.File( dlg.FileName ) );
|
2009-06-25 07:16:22 -07:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void btnOK_Click( object sender, EventArgs e ) {
|
2010-03-16 20:14:08 -07:00
|
|
|
|
this.DialogResult = System.Windows.Forms.DialogResult.OK;
|
2009-06-25 07:16:22 -07:00
|
|
|
|
this.Close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void btnFlip_Click( object sender, EventArgs e ) {
|
|
|
|
|
m_credit_mode = !m_credit_mode;
|
|
|
|
|
if ( m_credit_mode ) {
|
|
|
|
|
btnFlip.Width = m_button_width_about;
|
|
|
|
|
btnFlip.Text = string.Format( _( "About {0}" ), m_app_name );
|
|
|
|
|
m_scroll_started = DateTime.Now;
|
|
|
|
|
m_last_speed = 0f;
|
|
|
|
|
m_last_t = 0f;
|
|
|
|
|
m_shift = 0f;
|
2009-07-29 10:03:20 -07:00
|
|
|
|
|
2009-06-25 07:16:22 -07:00
|
|
|
|
timer.Enabled = true;
|
|
|
|
|
} else {
|
|
|
|
|
timer.Enabled = false;
|
|
|
|
|
btnFlip.Width = m_button_width_credit;
|
|
|
|
|
btnFlip.Text = _( "Credit" );
|
|
|
|
|
}
|
|
|
|
|
this.Invalidate();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void timer_Tick( object sender, EventArgs e ) {
|
|
|
|
|
this.Invalidate();
|
|
|
|
|
}
|
|
|
|
|
|
2010-03-16 20:14:08 -07:00
|
|
|
|
private void VersionInfoEx_Paint( object sender, System.Windows.Forms.PaintEventArgs e ) {
|
2009-06-25 07:16:22 -07:00
|
|
|
|
try {
|
2010-03-16 20:14:08 -07:00
|
|
|
|
paint( new Graphics2D( e.Graphics ) );
|
2009-06-25 07:16:22 -07:00
|
|
|
|
} catch ( Exception ex ) {
|
|
|
|
|
#if DEBUG
|
|
|
|
|
Console.WriteLine( "VersionInfoEx_Paint" );
|
|
|
|
|
Console.WriteLine( ex.StackTrace );
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-03-16 20:14:08 -07:00
|
|
|
|
public void paint( Graphics g1 ) {
|
|
|
|
|
Graphics2D g = (Graphics2D)g1;
|
|
|
|
|
g.clipRect( 0, 0, this.Width, m_height );
|
|
|
|
|
g.clearRect( 0, 0, this.Width, this.Height );
|
|
|
|
|
if ( m_credit_mode ) {
|
|
|
|
|
float times = (float)(((DateTime.Now).Subtract( m_scroll_started )).TotalSeconds) - 3f;
|
|
|
|
|
float speed = (float)((2.0 - bocoree.math.erfcc( times * 0.8 )) / 2.0) * m_speed;
|
|
|
|
|
float dt = times - m_last_t;
|
|
|
|
|
m_shift += (speed + m_last_speed) * dt / 2f;
|
|
|
|
|
m_last_t = times;
|
|
|
|
|
m_last_speed = speed;
|
|
|
|
|
float dx = (this.Width - m_scroll.getWidth( null )) * 0.5f;
|
|
|
|
|
if ( m_scroll != null ) {
|
|
|
|
|
g.drawImage( m_scroll, (int)dx, (int)(90f - m_shift), null );
|
|
|
|
|
if ( 90f - m_shift + m_scroll.getHeight( null ) < 0 ) {
|
|
|
|
|
m_shift = -m_height * 1.5f;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
int grad_height = 60;
|
|
|
|
|
Rectangle top = new Rectangle( 0, 0, this.Width, grad_height );
|
|
|
|
|
/*using ( LinearGradientBrush lgb = new LinearGradientBrush( top, Color.White, Color.Transparent, LinearGradientMode.Vertical ) ) {
|
|
|
|
|
g.FillRectangle( lgb, top );
|
|
|
|
|
}*/
|
|
|
|
|
Rectangle bottom = new Rectangle( 0, m_height - grad_height, this.Width, grad_height );
|
|
|
|
|
g.clipRect( 0, m_height - grad_height + 1, this.Width, grad_height - 1 );
|
|
|
|
|
/*using ( LinearGradientBrush lgb = new LinearGradientBrush( bottom, Color.Transparent, Color.White, LinearGradientMode.Vertical ) ) {
|
|
|
|
|
g.FillRectangle( lgb, bottom );
|
|
|
|
|
}*/
|
|
|
|
|
g.setClip( null );
|
|
|
|
|
} else {
|
|
|
|
|
g.setFont( new Font( "Century Gorhic", java.awt.Font.BOLD, 24 ) );
|
|
|
|
|
g.setColor( m_app_name_color );
|
|
|
|
|
g.drawString( m_app_name, 20, 110 );
|
|
|
|
|
g.setFont( new Font( "Arial", 0, 10 ) );
|
|
|
|
|
g.drawString( "version " + m_version, 25, 150 );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void VersionInfoEx_KeyDown( object sender, System.Windows.Forms.KeyEventArgs e ) {
|
|
|
|
|
if ( (e.KeyCode & System.Windows.Forms.Keys.Escape) == System.Windows.Forms.Keys.Escape ) {
|
|
|
|
|
this.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
2009-06-25 07:16:22 -07:00
|
|
|
|
this.Close();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void VersionInfoEx_FontChanged( object sender, EventArgs e ) {
|
|
|
|
|
for ( int i = 0; i < this.Controls.Count; i++ ) {
|
2010-03-16 20:14:08 -07:00
|
|
|
|
Util.applyFontRecurse( this.Controls[i], new java.awt.Font( this.Font ) );
|
2009-06-25 07:16:22 -07:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
2010-03-16 20:14:08 -07:00
|
|
|
|
#endif
|