/// <summary> /// コンストラクタ。 /// </summary> /// <param name="accessoryFileConfig">アクセサリファイル設定。</param> /// <param name="effectFileConfig">エフェクトファイル設定。</param> public ConfigViewModel( AccessoryFileConfig accessoryFileConfig, EffectFileConfig effectFileConfig) { if (accessoryFileConfig == null) { throw new ArgumentNullException("accessoryFileConfig"); } if (effectFileConfig == null) { throw new ArgumentNullException("effectFileConfig"); } // ファイル設定を設定 AccessoryFileConfig = accessoryFileConfig; EffectFileConfig = effectFileConfig; // 色の ViewModel 作成 FaceColorViewModel = ColorViewModel.Bind(AccessoryFileConfig, "FaceColor"); EmissiveColorViewModel = ColorViewModel.Bind(AccessoryFileConfig, "EmissiveColor"); SpecularColorViewModel = ColorViewModel.Bind(AccessoryFileConfig, "SpecularColor"); // コマンド作成 ResetCommand = new DelegateCommand( _ => { AccessoryFileConfig.Reset(); EffectFileConfig.Reset(); }); // ファイル設定変更時の処理を登録 AccessoryFileConfig.PropertyChanged += Config_PropertyChanged; EffectFileConfig.PropertyChanged += Config_PropertyChanged; // RenderType 関連プロパティ初期化 ChangeRenderTypeStatus(EffectFileConfig.RenderType); }
/// <summary> /// コンストラクタ。 /// </summary> /// <param name="accessoryFileConfig">アクセサリファイル設定。</param> /// <param name="effectFileConfig">エフェクトファイル設定。</param> /// <param name="textureAtlasLoader">テクスチャアトラスローダ。</param> /// <param name="textureAtlasFilePathes"> /// テクスチャアトラスファイルパス列挙。 /// </param> public MakerViewModel( AccessoryFileConfig accessoryFileConfig, EffectFileConfig effectFileConfig, Func<string, TextureAtlas> textureAtlasLoader, IEnumerable<string> textureAtlasFilePathes) { if (accessoryFileConfig == null) { throw new ArgumentNullException("accessoryFileConfig"); } if (effectFileConfig == null) { throw new ArgumentNullException("effectFileConfig"); } if (textureAtlasLoader == null) { throw new ArgumentNullException("textureAtlasLoader"); } if (textureAtlasFilePathes == null) { throw new ArgumentNullException("textureAtlasFilePathes"); } // 処理中に設定値が書き換わらないようにクローンを作成 var accConfig = accessoryFileConfig.Clone(); var effectConfig = effectFileConfig.Clone(); // SpriteMaker コレクション作成 Makers = textureAtlasFilePathes .Where(p => !string.IsNullOrWhiteSpace(p)) .Select(p => Path.GetFullPath(p)) .Distinct() // あまりアテにならないが一応重複を弾く .Select( p => new SpriteMaker { TextureAtlasLoader = textureAtlasLoader, InputTextureAtlasPath = p, AccessoryFileConfig = accConfig, EffectFileConfig = effectConfig, }) .ToList() .AsReadOnly(); if (Makers.Count <= 0) { throw new ArgumentException( "textureAtlasFilePathes is invalid.", "textureAtlasFilePathes"); } // コマンド作成 RunCommand = new DelegateCommand( _ => ExecuteRunCommand(), _ => !Running && !Finished); CancelCommand = new DelegateCommand( _ => CancelTokenSource.Cancel(), _ => CancelTokenSource != null); CopyLogCommand = new DelegateCommand( _ => Clipboard.SetText( string.Join(Environment.NewLine, LogLines) + Environment.NewLine)); // キャプション更新 UpdateViewCaption(); }
/// <summary> /// コンストラクタ。 /// </summary> public EffectFileMaker() { Config = new EffectFileConfig(); }
/// <summary> /// アプリケーション設定をプロセス間排他で初期化する。 /// </summary> private void InitializeSettings() { try { mutexForSettingFile.WaitOne(); // 読み込み LoadSettings(); bool needSave = false; // ファイル設定が null ならば初期化 if (AccessoryFileConfig == null) { AccessoryFileConfig = new AccessoryFileConfig(); needSave = true; } if (EffectFileConfig == null) { EffectFileConfig = new EffectFileConfig(); needSave = true; } // 必要であれば保存 if (needSave) { SaveSettings(); } } finally { mutexForSettingFile.ReleaseMutex(); } // 設定値が変更されたら即保存するようにする AccessoryFileConfig.PropertyChanged += OnSettingsPropertyChanged; EffectFileConfig.PropertyChanged += OnSettingsPropertyChanged; Settings.PropertyChanged += OnSettingsPropertyChanged; }
/// <summary> /// コンストラクタ。 /// </summary> public SpriteMaker() { AccessoryFileConfig = new AccessoryFileConfig(); EffectFileConfig = new EffectFileConfig(); }
/// <summary> /// エフェクトファイル設定が指定そのままに適用されるか否かを取得する。 /// </summary> /// <param name="config">エフェクトファイル設定。</param> /// <returns> /// 指定そのままに適用されるならば true 。そうでなければ false 。 /// </returns> private static bool IsEffectFileConfigApplied(EffectFileConfig config) { // RenderType 次第ではそのまま適用されない値をチェック return ( config.LightSetting == config.GetLightSetting() && config.RenderingBack == config.IsRenderingBack() && config.PostEffect == config.IsPostEffect()); }