• R/O
  • SSH
  • HTTPS

cadencii: コミット


コミットメタ情報

リビジョン5 (tree)
日時2009-03-16 22:59:36
作者kbinani

ログメッセージ

(メッセージはありません)

変更サマリ

差分

--- trunk/Cadencii/AppManager.cs (nonexistent)
+++ trunk/Cadencii/AppManager.cs (revision 5)
@@ -0,0 +1,361 @@
1+/*
2+ * AppManager.cs
3+ * Copyright (c) 2009 kbinani
4+ *
5+ * This file is part of Boare.Cadencii.
6+ *
7+ * Boare.Cadencii is free software; you can redistribute it and/or
8+ * modify it under the terms of the BSD License.
9+ *
10+ * Boare.Cadencii is distributed in the hope that it will be useful,
11+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13+ */
14+using System;
15+using System.Collections.Generic;
16+using System.Drawing;
17+using System.IO;
18+using System.Reflection;
19+using System.Runtime.Serialization.Formatters.Binary;
20+using System.Threading;
21+using System.Windows.Forms;
22+using System.Xml.Serialization;
23+
24+using Boare.Lib.Vsq;
25+/*
26+-ビブラートを、ダイアログを出さずにピアノロールと同じ画面で調整
27+-アクセント・ディケイパラメータを、ダイアログを出さずにピアノロールと同じ画面で調整
28+-コントロールカーブのテンプレートの登録&貼付け機能
29+-Mac、Linuxでの編集作業を可能にする
30+-ショートカットキーのカスタマイズ
31+-選択したノートのプロパティを一括変更する機能
32+-選択したノートを指定したクロック数分一括シフトする機能
33+-MIDIキーボード(?用語があってるか不明)を使えるようにする
34+-前回レンダリングしたWAVEファイルをリサイクルする(起動ごとにレンダリングするのは面倒?)
35+-横軸を変更するショートカットキー
36+-音符の時間位置を秒指定で入力できるモード
37+-コントロールカーブのリアルタイムかつアナログ的な入力(ジョイスティックorゲームコントローラ)
38+-コントロールカーブエディタを幾つか積めるような機能
39+ */
40+/*DONE:
41+ */
42+namespace Boare.Cadencii {
43+
44+ public delegate void BSimpleDelegate<T>( T arg );
45+
46+ public partial class AppManager : Form {
47+ /// <summary>
48+ /// 鍵盤の表示幅(pixel)
49+ /// </summary>
50+ public const int _KEY_LENGTH = 68;
51+
52+ private static int m_base_tempo = 480000;
53+ /// <summary>
54+ /// エディタの設定
55+ /// </summary>
56+ public static EditorConfig EditorConfig = new EditorConfig();
57+ /// <summary>
58+ /// EditorConfigクラス用のシリアライザ
59+ /// </summary>
60+ //public static XmlSerializer XmlSerializerEditorConfig = new XmlSerializer( typeof( EditorConfig ) );
61+ /// <summary>
62+ /// List&lt;BezierCurves&gt;用のシリアライザ
63+ /// </summary>
64+ public static XmlSerializer XmlSerializerListBezierCurves = new XmlSerializer( typeof( List<BezierCurves> ) );
65+ /// <summary>
66+ /// コピーorカットなどで複製されたエントリ
67+ /// </summary>
68+ public static List<VsqEvent> CopiedEvent = null;
69+ /// <summary>
70+ /// コピーorカットで複製されたテンポ
71+ /// </summary>
72+ public static List<TempoTableEntry> CopiedTempo = null;
73+ /// <summary>
74+ /// コピーorカットで複製された拍子
75+ /// </summary>
76+ public static List<TimeSigTableEntry> CopiedTimesig = null;
77+ /// <summary>
78+ /// コピーorカットで複製されたカーブ
79+ /// </summary>
80+ public static List<BPPair> CopiedCurve = null;
81+ /// <summary>
82+ /// コピーorカットで複製されたカーブの種類
83+ /// </summary>
84+ public static CurveType CopiedCurveType = CurveType.DYN;
85+ /// <summary>
86+ /// 複数種類のコントロールカーブのコピー用。
87+ /// </summary>
88+ public static Dictionary<CurveType, List<BPPair>> CopiedCurveWhole = null;
89+ /// <summary>
90+ /// 複数種類のコントロールカーブがコピーされた状態かどうかを表すフラグ
91+ /// </summary>
92+ public static bool IsWholeCurveCopied = false;
93+ private object m_locker = new object();
94+
95+ #region Static Readonly Fields
96+ public static readonly Color[] s_HILIGHT = new Color[] {
97+ Color.FromArgb( 181, 220, 16 ),
98+ Color.FromArgb( 231, 244, 49 ),
99+ Color.FromArgb( 252, 230, 29 ),
100+ Color.FromArgb( 247, 171, 20 ),
101+ Color.FromArgb( 249, 94, 17 ),
102+ Color.FromArgb( 234, 27, 47 ),
103+ Color.FromArgb( 175, 20, 80 ),
104+ Color.FromArgb( 183, 24, 149 ),
105+ Color.FromArgb( 105, 22, 158 ),
106+ Color.FromArgb( 22, 36, 163 ),
107+ Color.FromArgb( 37, 121, 204 ),
108+ Color.FromArgb( 29, 179, 219 ),
109+ Color.FromArgb( 24, 239, 239 ),
110+ Color.FromArgb( 25, 206, 175 ),
111+ Color.FromArgb( 23, 160, 134 ),
112+ Color.FromArgb( 79, 181, 21 ) };
113+ public static readonly Color[] s_RENDER = new Color[]{
114+ Color.FromArgb( 19, 143, 52 ),
115+ Color.FromArgb( 158, 154, 18 ),
116+ Color.FromArgb( 160, 143, 23 ),
117+ Color.FromArgb( 145, 98, 15 ),
118+ Color.FromArgb( 142, 52, 12 ),
119+ Color.FromArgb( 142, 19, 37 ),
120+ Color.FromArgb( 96, 13, 47 ),
121+ Color.FromArgb( 117, 17, 98 ),
122+ Color.FromArgb( 62, 15, 99 ),
123+ Color.FromArgb( 13, 23, 84 ),
124+ Color.FromArgb( 25, 84, 132 ),
125+ Color.FromArgb( 20, 119, 142 ),
126+ Color.FromArgb( 19, 142, 139 ),
127+ Color.FromArgb( 17, 122, 102 ),
128+ Color.FromArgb( 13, 86, 72 ),
129+ Color.FromArgb( 43, 91, 12 ) };
130+ #endregion
131+
132+ #region Private Static Fields
133+ private static SolidBrush s_hilight_brush = new SolidBrush( Color.CornflowerBlue );
134+ private static object s_locker;
135+ #endregion
136+
137+ private const string _CONFIG_PATH = "config.xml";
138+ public delegate void MainFormClosedEventHandler( EditorManager manager );
139+ public delegate void EditorConfigChangedEventHandler( EditorManager manager );
140+
141+ private static List<EditorManager> s_editor_managers = null;
142+ private static XmlSerializer s_serizlizer = null;
143+
144+ public AppManager() {
145+ s_locker = new object();
146+ InitializeComponent();
147+ s_editor_managers = new List<EditorManager>();
148+ SymbolTable.LoadDictionary();
149+ LoadConfig();
150+ VSTiProxy.CurrentUser = "";
151+
152+ #region Apply User Dictionary Configuration
153+ List<BKeyValuePair<string, bool>> current = new List<BKeyValuePair<string, bool>>();
154+ for ( int i = 0; i < SymbolTable.Count; i++ ) {
155+ current.Add( new BKeyValuePair<string, bool>( SymbolTable.GetSymbolTable( i ).Name, false ) );
156+ }
157+ List<BKeyValuePair<string, bool>> config_data = new List<BKeyValuePair<string, bool>>();
158+ for ( int i = 0; i < EditorConfig.UserDictionaries.Count; i++ ) {
159+ string[] spl = EditorConfig.UserDictionaries[i].Split( "\t".ToCharArray(), 2 );
160+ config_data.Add( new BKeyValuePair<string, bool>( spl[0], (spl[1] == "T" ? true : false) ) );
161+#if DEBUG
162+ Common.DebugWriteLine( " " + spl[0] + "," + spl[1] );
163+#endif
164+ }
165+ List<KeyValuePair<string, bool>> common = new List<KeyValuePair<string, bool>>();
166+ for ( int i = 0; i < config_data.Count; i++ ) {
167+ for ( int j = 0; j < current.Count; j++ ) {
168+ if ( config_data[i].Key == current[j].Key ) {
169+ current[j].Value = true; //こっちのboolは、AppManager.EditorConfigのUserDictionariesにもKeyが含まれているかどうかを表すので注意
170+ common.Add( new KeyValuePair<string, bool>( config_data[i].Key, config_data[i].Value ) );
171+ break;
172+ }
173+ }
174+ }
175+ for ( int i = 0; i < current.Count; i++ ) {
176+ if ( !current[i].Value ) {
177+ common.Add( new KeyValuePair<string, bool>( current[i].Key, false ) );
178+ }
179+ }
180+ SymbolTable.ChangeOrder( common.ToArray() );
181+ #endregion
182+
183+ Boare.Lib.AppUtil.Messaging.LoadMessages();
184+ Boare.Lib.AppUtil.Messaging.Language = EditorConfig.Language;
185+
186+ KeySoundPlayer.Init();
187+ }
188+
189+ /// <summary>
190+ /// 位置クオンタイズ時の音符の最小単位を、クロック数に換算したものを取得します
191+ /// </summary>
192+ /// <returns></returns>
193+ public static int GetPositionQuantizeClock() {
194+ return QuantizeModeUtil.GetQuantizeClock( EditorConfig.PositionQuantize, EditorConfig.PositionQuantizeTriplet );
195+ }
196+
197+ /// <summary>
198+ /// 音符長さクオンタイズ時の音符の最小単位を、クロック数に換算したものを取得します
199+ /// </summary>
200+ /// <returns></returns>
201+ public static int GetLengthQuantizeClock() {
202+ return QuantizeModeUtil.GetQuantizeClock( EditorConfig.LengthQuantize, EditorConfig.LengthQuantizeTriplet );
203+ }
204+
205+ public static void SaveConfig() {
206+ // ユーザー辞書の情報を取り込む
207+ EditorConfig.UserDictionaries.Clear();
208+ for ( int i = 0; i < SymbolTable.Count; i++ ) {
209+ EditorConfig.UserDictionaries.Add( SymbolTable.GetSymbolTable( i ).Name + "\t" + (SymbolTable.GetSymbolTable( i ).Enabled ? "T" : "F") );
210+ }
211+
212+ if ( s_serizlizer == null ) {
213+ s_serizlizer = new XmlSerializer( typeof( EditorConfig ) );
214+ }
215+ string file = Path.Combine( Application.StartupPath, _CONFIG_PATH );
216+ using ( FileStream fs = new FileStream( file, FileMode.Create ) ) {
217+ s_serizlizer.Serialize( fs, EditorConfig );
218+ }
219+ }
220+
221+ public static void LoadConfig() {
222+ string config_file = Path.Combine( Application.StartupPath, _CONFIG_PATH );
223+ EditorConfig ret = null;
224+ if ( File.Exists( config_file ) ) {
225+ FileStream fs = null;
226+ try {
227+ if ( s_serizlizer == null ) {
228+ s_serizlizer = new XmlSerializer( typeof( EditorConfig ) );
229+ }
230+ fs = new FileStream( config_file, FileMode.Open );
231+ ret = (EditorConfig)s_serizlizer.Deserialize( fs );
232+ } catch {
233+ } finally {
234+ if ( fs != null ) {
235+ fs.Close();
236+ }
237+ }
238+ }
239+ if ( ret == null ) {
240+ ret = new EditorConfig();
241+ }
242+ EditorConfig = ret;
243+ for ( int i = 0; i < SymbolTable.Count; i++ ) {
244+ SymbolTable st = SymbolTable.GetSymbolTable( i );
245+ bool found = false;
246+ foreach ( string s in EditorConfig.UserDictionaries ) {
247+ string[] spl = s.Split( "\t".ToCharArray(), 2 );
248+ if ( st.Name == spl[0] ) {
249+ found = true;
250+ break;
251+ }
252+ }
253+ if ( !found ) {
254+ EditorConfig.UserDictionaries.Add( st.Name + "\tT" );
255+ }
256+ }
257+ }
258+
259+ public static string _VERSION {
260+ get {
261+ string prefix = "";
262+#if DEBUG
263+ prefix = "(build: debug)";
264+#else
265+ prefix = "(build: release)";
266+#endif
267+ return GetAssemblyFileVersion( typeof( AppManager ) ) + " " + prefix;
268+ }
269+ }
270+
271+ public static string GetAssemblyFileVersion( Type t ) {
272+ Assembly a = Assembly.GetAssembly( t );
273+ AssemblyFileVersionAttribute afva = (AssemblyFileVersionAttribute)Attribute.GetCustomAttribute( a, typeof( AssemblyFileVersionAttribute ) );
274+ return afva.Version;
275+ }
276+
277+ public static string GetAssemblyNameAndFileVersion( Type t ) {
278+ Assembly a = Assembly.GetAssembly( t );
279+ AssemblyFileVersionAttribute afva = (AssemblyFileVersionAttribute)Attribute.GetCustomAttribute( a, typeof( AssemblyFileVersionAttribute ) );
280+ return a.GetName().Name + " v" + afva.Version;
281+ }
282+
283+ public static SolidBrush HilightBrush {
284+ get {
285+ return s_hilight_brush;
286+ }
287+ }
288+
289+ public static Color HilightColor {
290+ get {
291+ return s_hilight_brush.Color;
292+ }
293+ set {
294+ s_hilight_brush = new SolidBrush( value );
295+ }
296+ }
297+
298+ /// <summary>
299+ /// ベースとなるテンポ。
300+ /// </summary>
301+ public static int BaseTempo {
302+ get {
303+ return m_base_tempo;
304+ }
305+ set {
306+ m_base_tempo = value;
307+ }
308+ }
309+
310+ private void FormRoot_Load( object sender, EventArgs e ) {
311+ StartNewForm();
312+ }
313+
314+ public void StartNewForm() {
315+ lock ( m_locker ) {
316+ EditorManager em = new EditorManager();
317+ em.SetFormRoot( this );
318+ string s = s_editor_managers.Count + ":" + DateTime.Now.ToBinary();
319+ string id = bocoree.misc.getmd5( s );
320+ em.ID = id;
321+ em.MainFormClosed += new MainFormClosedEventHandler( em_MainFormClosed );
322+ em.EditorConfigChanged += new EditorConfigChangedEventHandler( em_EditorConfigChanged );
323+ s_editor_managers.Add( em );
324+ Thread t = new Thread( new ParameterizedThreadStart( EditorStart ) );
325+ t.SetApartmentState( ApartmentState.STA );
326+ t.Start( em );
327+ }
328+ }
329+
330+ private void em_EditorConfigChanged( EditorManager manager ) {
331+ for ( int i = 0; i < s_editor_managers.Count; i++ ) {
332+ if ( s_editor_managers[i].ID != manager.ID ) {
333+ s_editor_managers[i].SendApplyEditorConfigMessage();
334+ }
335+ }
336+ }
337+
338+ private void em_MainFormClosed( EditorManager sender ) {
339+ for ( int i = 0; i < s_editor_managers.Count; i++ ) {
340+ if ( s_editor_managers[i].Equals( sender ) ) {
341+ s_editor_managers.RemoveAt( i );
342+ break;
343+ }
344+ }
345+ if ( s_editor_managers.Count == 0 ) {
346+ VSTiProxy.AbortRendering();
347+ this.Invoke( new EventHandler( WindowClose ) );
348+ }
349+ }
350+
351+ private void WindowClose( object sender, EventArgs e ) {
352+ this.Close();
353+ }
354+
355+ private void EditorStart( object manager ) {
356+ EditorManager em = (EditorManager)manager;
357+ Application.Run( new FormMain( em ) );
358+ }
359+ }
360+
361+}
--- trunk/Cadencii/VersionHistory.cs (nonexistent)
+++ trunk/Cadencii/VersionHistory.cs (revision 5)
@@ -0,0 +1,51 @@
1+/*
2+ * VersionHistory.cs
3+ * Copyright (c) 2008-2009 kbinani
4+ *
5+ * This file is part of Boare.Cadencii.
6+ *
7+ * Boare.Cadencii is free software; you can redistribute it and/or
8+ * modify it under the terms of the BSD License.
9+ *
10+ * Boare.Cadencii is distributed in the hope that it will be useful,
11+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13+ */
14+using System.Net;
15+using System.Xml.Serialization;
16+
17+using System.Collections.Generic;
18+
19+namespace Boare.Cadencii {
20+
21+ public class VersionHistory {
22+ public List<Version> History;
23+
24+ public VersionHistory() {
25+ History = new List<Version>();
26+ }
27+
28+ /// <summary>
29+ /// 最新のリリース情報をダウンロードします
30+ /// </summary>
31+ /// <returns></returns>
32+ public static VersionHistory DownloadLatestVersionInfo( string uri ) {
33+ HttpWebRequest req = WebRequest.Create( uri ) as HttpWebRequest;
34+ HttpWebResponse res = null;
35+ try {
36+ res = req.GetResponse() as HttpWebResponse;
37+ } catch {
38+ return null;
39+ }
40+ XmlSerializer xs = new XmlSerializer( typeof( VersionHistory ) );
41+ VersionHistory vh = null;
42+ try {
43+ vh = (VersionHistory)xs.Deserialize( res.GetResponseStream() );
44+ vh.History.Sort();
45+ } catch {
46+ }
47+ return vh;
48+ }
49+ }
50+
51+}
--- trunk/Cadencii/AppManager.Designer.cs (nonexistent)
+++ trunk/Cadencii/AppManager.Designer.cs (revision 5)
@@ -0,0 +1,44 @@
1+namespace Boare.Cadencii {
2+ partial class AppManager {
3+ /// <summary>
4+ /// 必要なデザイナ変数です。
5+ /// </summary>
6+ private System.ComponentModel.IContainer components = null;
7+
8+ /// <summary>
9+ /// 使用中のリソースをすべてクリーンアップします。
10+ /// </summary>
11+ /// <param name="disposing">マネージ リソースが破棄される場合 true、破棄されない場合は false です。</param>
12+ protected override void Dispose( bool disposing ) {
13+ if ( disposing && (components != null) ) {
14+ components.Dispose();
15+ }
16+ base.Dispose( disposing );
17+ }
18+
19+ #region Windows フォーム デザイナで生成されたコード
20+
21+ /// <summary>
22+ /// デザイナ サポートに必要なメソッドです。このメソッドの内容を
23+ /// コード エディタで変更しないでください。
24+ /// </summary>
25+ private void InitializeComponent() {
26+ this.SuspendLayout();
27+ //
28+ // AppManager
29+ //
30+ this.AutoScaleDimensions = new System.Drawing.SizeF( 6F, 12F );
31+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
32+ this.ClientSize = new System.Drawing.Size( 380, 332 );
33+ this.Name = "AppManager";
34+ this.ShowInTaskbar = false;
35+ this.Text = "FormRoot";
36+ this.WindowState = System.Windows.Forms.FormWindowState.Minimized;
37+ this.Load += new System.EventHandler( this.FormRoot_Load );
38+ this.ResumeLayout( false );
39+
40+ }
41+
42+ #endregion
43+ }
44+}
\ No newline at end of file
旧リポジトリブラウザで表示