1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225
|
/*
* FormBeatConfigController.cs
* Copyright © 2011 kbinani
*
* This file is part of org.kbinani.cadencii.
*
* org.kbinani.cadencii is free software; you can redistribute it and/or
* modify it under the terms of the GPLv3 License.
*
* org.kbinani.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
package org.kbinani.cadencii;
import java.awt.event.*;
import org.kbinani.*;
import org.kbinani.apputil.*;
import org.kbinani.windows.forms.*;
#else
using System;
using org.kbinani.java.awt.event_;
using org.kbinani.apputil;
using org.kbinani;
using org.kbinani.windows.forms;
namespace org.kbinani.cadencii
{
using boolean = System.Boolean;
using BEventArgs = System.EventArgs;
using BEventHandler = System.EventHandler;
#endif
#if JAVA
public class FormBeatConfigController extends ControllerBase implements FormBeatConfigUiListener
#else
public class FormBeatConfigController : ControllerBase, FormBeatConfigUiListener
#endif
{
private FormBeatConfigUi mUi;
public FormBeatConfigController( int bar_count, int numerator, int denominator, boolean num_enabled, int pre_measure )
{
mUi = new FormBeatConfigUiImpl( this );
applyLanguage();
mUi.setEnabledStartNum( num_enabled );
mUi.setEnabledEndNum( num_enabled );
mUi.setEnabledEndCheckbox( num_enabled );
mUi.setMinimumStartNum( -pre_measure + 1 );
mUi.setMaximumStartNum( int.MaxValue );
mUi.setMinimumEndNum( -pre_measure + 1 );
mUi.setMaximumEndNum( int.MaxValue );
// 拍子の分母
mUi.removeAllItemsDenominatorCombobox();
mUi.addItemDenominatorCombobox( "1" );
int count = 1;
for ( int i = 1; i <= 5; i++ )
{
count *= 2;
mUi.addItemDenominatorCombobox( count + "" );
}
count = 0;
while ( denominator > 1 )
{
count++;
denominator /= 2;
}
mUi.setSelectedIndexDenominatorCombobox( count );
// 拍子の分子
if ( numerator < mUi.getMinimumNumeratorNum() )
{
mUi.setValueNumeratorNum( mUi.getMinimumNumeratorNum() );
}
else if ( mUi.getMaximumNumeratorNum() < numerator )
{
mUi.setValueNumeratorNum( mUi.getMaximumNumeratorNum() );
}
else
{
mUi.setValueNumeratorNum( numerator );
}
// 始点
if ( bar_count < mUi.getMinimumStartNum() )
{
mUi.setValueStartNum( mUi.getMinimumStartNum() );
}
else if ( mUi.getMaximumStartNum() < bar_count )
{
mUi.setValueStartNum( mUi.getMaximumStartNum() );
}
else
{
mUi.setValueStartNum( bar_count );
}
// 終点
if ( bar_count < mUi.getMinimumEndNum() )
{
mUi.setValueEndNum( mUi.getMinimumEndNum() );
}
else if ( mUi.getMaximumEndNum() < bar_count )
{
mUi.setValueEndNum( mUi.getMaximumEndNum() );
}
else
{
mUi.setValueEndNum( bar_count );
}
mUi.setFont( AppManager.editorConfig.BaseFontName, AppManager.editorConfig.BaseFontSize );
}
#region FormBeatConfigUiListenerインターフェースの実装
public void buttonOkClickedSlot()
{
mUi.setDialogResult( true );
}
public void buttonCancelClickedSlot()
{
mUi.setDialogResult( false );
}
public void checkboxEndCheckedChangedSlot()
{
mUi.setEnabledEndNum( mUi.isCheckedEndCheckbox() );
}
#endregion
#region public methods
public void close()
{
mUi.close();
}
public void setLocation( int x, int y )
{
mUi.setLocation( x, y );
}
public int getWidth()
{
return mUi.getWidth();
}
public int getHeight()
{
return mUi.getHeight();
}
public FormBeatConfigUi getUi()
{
return mUi;
}
public int getStart()
{
return (int)mUi.getValueStartNum();
}
public boolean isEndSpecified()
{
return mUi.isCheckedEndCheckbox();
}
public int getEnd()
{
return (int)mUi.getValueEndNum();
}
public int getNumerator()
{
return (int)mUi.getValueNumeratorNum();
}
public int getDenominator()
{
int ret = 1;
for ( int i = 0; i < mUi.getSelectedIndexDenominatorCombobox(); i++ )
{
ret *= 2;
}
return ret;
}
public void applyLanguage()
{
mUi.setTitle( _( "Beat Change" ) );
mUi.setTextPositionGroup( _( "Position" ) );
mUi.setTextBeatGroup( _( "Beat" ) );
mUi.setTextOkButton( _( "OK" ) );
mUi.setTextCancelButton( _( "Cancel" ) );
mUi.setTextStartLabel( _( "From" ) );
//lblStart.setMnemonic( KeyEvent.VK_F, numStart );
mUi.setTextEndCheckbox( _( "To" ) );
//chkEnd.setDisplayedMnemonicIndex( 0 );
mUi.setTextBar1Label( _( "Measure" ) );
mUi.setTextBar2Label( _( "Measure" ) );
}
#endregion
private static String _( String id )
{
return Messaging.getMessage( id );
}
}
#if !JAVA
}
#endif
|