示例#1
0
        /// <summary>
        /// コンストラクタ
        /// </summary>
        /// <param name="config">リストビューの設定</param>
        /// <param name="extensions">拡張機能の配列</param>
        /// <param name="extnensions_dir">拡張機能のファイルパス</param>
        public UMAListViewTpl( UMAListView.Config config, ReadWriteMode mode, WP7_2012ULV.Setting.ExtensionSetting.Command[] extensions, String extnensions_dir )
        {
            this.ListViewConfig = config;
            this.ExtensionsDir = extnensions_dir;
            this.Extensions = extensions;
            this.Mode = mode;

            this.InitializeComponent();
            this.ListView1_Setup();
            this.ContextMenu_Setup();
        }
示例#2
0
        protected override void ExecCSharpExtension( System.Reflection.MethodInfo method, WP7_2012ULV.Setting.ExtensionSetting.Manifest manifest )
        {
            var data = new KOEI.WP7_2012.Datastruct.HDamData();

            SelectedItemsEach( ( item_index, horse_num ) => {
                this.WP7.HDamTable.GetData( horse_num, ref data );

                var args = new object[]{
                    this.WP7,
                    horse_num,
                    data
                };
                data = (KOEI.WP7_2012.Datastruct.HDamData) method.Invoke( null, args );

                if( this.Mode == ReadWriteMode.ReadWrite && manifest.Mode == ReadWriteMode.ReadWrite ) {
                    this.WP7.HDamTable.SetData( horse_num, ref data );
                    this.WP7.HDamTable.Commit( horse_num );
                    this.ListView1_VirtualItems[ item_index ] = this.CreateListViewItemByHorseNum( this.WP7, horse_num, ref data );
                }
            });
            this.ListView1.Refresh();
            this.ListView1_OddColor();
        }
示例#3
0
        /// <summary>
        /// 拡張機能をコンパイルして実行するメソッド
        /// </summary>
        /// <param name="extension">実行する拡張機能</param>
        private void ExecExtensionMain( WP7_2012ULV.Setting.ExtensionSetting.Command extension )
        {
            var file = String.Format( "{0}\\{{{1}}}.cs", this.ExtensionsDir, extension.Guid );

            if( !System.IO.File.Exists( file ) ) {
                var message = String.Format( "{0} 拡張機能ファイルが見つかりませんでした", file );
                MessageBox.Show( message, "エラー", MessageBoxButtons.OK, MessageBoxIcon.Error );
                return ;
            }

            if( this.WP7.TransactionWeekNumber != this.WP7.GetCurrentWeekNumber() ) {
                var message = String.Format(
                    "データ取得時から週が変わっています({0}→{1})\r\n安全のため書き込みは行いません、再取得してください",
                    this.WP7.TransactionWeekNumber,
                    this.WP7.GetCurrentWeekNumber()
                );
                MessageBox.Show( message, "エラー", MessageBoxButtons.OK, MessageBoxIcon.Error );
                return;
            }

            var compiler_option = new Dictionary< string, string >() {
                { "CompilerVersion", "v3.5" }
            };
            var compiler = new Microsoft.CSharp.CSharpCodeProvider( compiler_option );

            var options = new System.CodeDom.Compiler.CompilerParameters();

            options.GenerateInMemory = true;
            options.WarningLevel = 4;
            options.TreatWarningsAsErrors = true;

            options.ReferencedAssemblies.Add("System.dll");
            options.ReferencedAssemblies.Add("System.Data.dll");
            options.ReferencedAssemblies.Add("System.Windows.Forms.dll");
            options.ReferencedAssemblies.Add("System.Drawing.dll");
            options.ReferencedAssemblies.Add("KOEI.WP7_2012.dll");

            using( var sr = new System.IO.StreamReader( file, Encoding.UTF8 ) ) {
                var source = sr.ReadToEnd();
                var program = compiler.CompileAssemblyFromSource( options, new[]{ source } );

                if( program.Errors.Count > 0 ) {
                    var error_string = "コンパイルエラー\r\n";
                    foreach( var error in program.Errors ) {
                        error_string += ((System.CodeDom.Compiler.CompilerError)error).ErrorText;
                        error_string += "\r\n";
                    }
                    throw new Exception( error_string );
                }
                Type klass;

                try {
                    klass = program.CompiledAssembly.GetType( EXTENSION_CLASS_NAME );
                } catch( Exception ex ) {
                    throw new Exception( String.Format( "{0}クラスの取得に失敗 - {1}", EXTENSION_CLASS_NAME, ex.Message ) );
                }

                var method = klass.GetMethod(
                    EXTENSION_METHOD_NAME,
                    System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Public,
                    null,
                    ExtensionArgTypes,
                    null
                );

                if( method == null ) {
                    throw new Exception( String.Format( "{0}メソッドの取得に失敗", EXTENSION_METHOD_NAME ) );
                }
                this.ExecCSharpExtension( method, extension.Manifest );
            }
        }
示例#4
0
 /// <summary>
 /// 派生クラスで実装するメソッド
 /// C#の拡張機能を実行する
 /// </summary>
 /// <param name="method">呼び出す拡張機能のメソッド</param>
 protected abstract void ExecCSharpExtension( System.Reflection.MethodInfo method, WP7_2012ULV.Setting.ExtensionSetting.Manifest manifest );
 /// <summary>
 /// 派生クラスで実装するメソッド
 /// C#の拡張機能を実行する
 /// </summary>
 /// <param name="method">呼び出す拡張機能のメソッド</param>
 protected override void ExecCSharpExtension( System.Reflection.MethodInfo method, WP7_2012ULV.Setting.ExtensionSetting.Manifest manifest )
 {
     // pass
 }
 /// <summary>
 /// コンストラクタ
 /// </summary>
 /// <param name="config"></param>
 /// <param name="extensions"></param>
 /// <param name="extnensions_dir"></param>
 public BreedingToSireListView( UMAListView.Config config, ReadWriteMode mode, WP7_2012ULV.Setting.ExtensionSetting.Command[] extensions, String extnensions_dir )
     : base(config, mode, extensions, extnensions_dir)
 {
     // pass
 }