public override void Initialize() { image = new UnclickableScreenImage2D { Image = CreateStatusImage(""), }; this.Scene.ScreenObjects.Add(image); }
public override void Run(CommandArgs e) { var mode = this.Scene.Mode; Action reset = null; if (mode != EditMode.ModelMode && mode != EditMode.AccessoryMode && mode != EditMode.EffectMode || mode == EditMode.ModelMode && this.Scene.ActiveModel == null || mode == EditMode.AccessoryMode && this.Scene.ActiveAccessory == null || mode == EditMode.EffectMode && this.Scene.ActiveEffect == null) { MessageBox.Show(this.ApplicationForm, Util.Bilingual ( this.Scene.Language, "対象のモデル、アクセサリ、またはエフェクトがありません。\r\n対象のキーフレームを選択してから実行してください。", "No target selected.\r\nPlease select one or more keyframes to rotate." ), Util.Bilingual(this.Scene.Language, this.Text, this.EnglishText), MessageBoxButtons.OK, MessageBoxIcon.Information); e.Cancel = true; return; } using (new EnableScreenObjectBlock(this.Scene)) using (var image = new ScreenImage_2D(Point.Empty, Resources.Origin)) using (var f = new ApplyRotationForm(this.Scene.Language) { Position = position, Rotation = rotation, IsMoveOnly = isMoveOnly, }) try { this.Scene.ScreenObjects.Add(image); f.ValueChanged += (sender, e2) => { var camera = this.Scene.ActiveCamera ?? this.Scene.Cameras.First(); var pt = Vector3.Project ( f.Position, 0, 0, this.Scene.ScreenSize.Width, this.Scene.ScreenSize.Height, this.Scene.SystemInformation.NearPlane, this.Scene.SystemInformation.FarPlane, camera.ViewMatrix * camera.ProjectionMatrix ); image.Position = new Point((int)pt.X - image.Size.Width / 2, (int)pt.Y - image.Size.Height / 2); Apply(mode, f, true, ref reset); }; var rt = f.ShowDialog(this.ApplicationForm); if (reset != null) { reset(); reset = null; } if (rt != DialogResult.OK) { e.Cancel = true; return; } position = f.Position; rotation = f.Rotation; isMoveOnly = f.IsMoveOnly; using (new UndoBlock(this.Scene)) Apply(mode, f, false, ref reset); } finally { this.Scene.ScreenObjects.Remove(image); } }