/// <summary> /// xamlファイル適用時に呼ばれます。 /// </summary> public override void OnApplyTemplate() { base.OnApplyTemplate(); this.normalContainer = (UIElement)GetTemplateChild(NormalContainerName); this.valueText = (DecoratedText)GetTemplateChild(ValueTextName); this.specialContainer = (UIElement)GetTemplateChild(SpecialContainerName); this.stringText = (DecoratedText)GetTemplateChild(StringTextName); ValueUpdated(Value); }
/// <summary> /// xamlファイル適用時に呼ばれます。 /// </summary> public override void OnApplyTemplate() { base.OnApplyTemplate(); this.normalContainer = (UIElement)GetTemplateChild(NormalContainerName); this.specialContainer = (UIElement)GetTemplateChild(SpecialContainerName); this.stringText = (DecoratedText)GetTemplateChild(StringTextName); for (var i = 0; i < this.valueTexts.Length; ++i) { this.valueTexts[i] = (DecoratedText)GetTemplateChild(Part_ValueTextName(i)); } for (var i = 0; i < this.colonTexts.Length; ++i) { this.colonTexts[i] = (DecoratedText)GetTemplateChild(Part_ColonTextName(i)); } ValueUpdated(Value); }
/// <summary> /// 駒オブジェクトなどを初期化します。 /// </summary> protected override void InitializeImpl() { base.InitializeImpl(); // 駒はマウスクリックを識別したいので、 // ModelUIElement3Dクラスを使います。 Element = new ModelUIElement3D() { Model = ModelGroup, }; // 表示用の駒オブジェクトを追加します。 var pieceObject = new PieceObject( this.shogi, new BoardPiece(BWType, PieceType)); AddChild(pieceObject); this.numberText = new DecoratedText() { TextFormat = "×{0}", Foreground = Brushes.Black, FontWeight = FontWeights.ExtraBlack, Stroke = Brushes.White, StrokeThickness = 0.8, }; // 駒数の表示用オブジェクトを追加します。 var w = this.shogi.CellSize.Width; var h = this.shogi.CellSize.Height; var numberModel = new GeometryModel3D() { Geometry = CreateDefaultMesh(0.7, 0.4), Material = new DiffuseMaterial(new VisualBrush(this.numberText)), Transform = new Transform3DGroup() .Apply(_ => _.Children.Add(new TranslateTransform3D(0.4, -0.4, 0.0)), _ => _.Children.Add(new ScaleTransform3D(w, h, 1.0))), }; ModelGroup.Children.Add(numberModel); UpdateElement(); }
/// <summary> /// 駒オブジェクトなどを初期化します。 /// </summary> protected override void OnInitialize() { base.OnInitialize(); BaseScale = new Vector3D( this.shogi.CellSize.Width, this.shogi.CellSize.Height, 1.0); // 駒台の駒の場合 if (Square == null) { this.numberText = new DecoratedText() { TextFormat = "×{0}", Foreground = Brushes.Black, FontWeight = FontWeights.ExtraBlack, Stroke = Brushes.White, StrokeThickness = 0.8, }; } UpdateModel(); UpdateElement(); }