FreeTrainの進化系を目指す
MRT Drawing.(IndexMap,NightColor etc.) Switch output RenderTarget by 0~5 keys.
Form key event trial.
| @@ -3,7 +3,23 @@ | ||
| 3 | 3 | <title>サンプル構造物セット</title> |
| 4 | 4 | <author>C477</author> |
| 5 | 5 | <homepage>https://sourceforge.jp/users/c477/</homepage> |
| 6 | - | |
| 6 | + | |
| 7 | + <contribution type="CommandUI" id="TestCommandUI"> | |
| 8 | + <name>建物設置</name> | |
| 9 | + <short-caption>建物</short-caption> | |
| 10 | + <long-caption>建造物設置</long-caption> | |
| 11 | + <description>建造物を設置します</description> | |
| 12 | + <icon index="1">../../res/plugin_icons.bmp</icon> | |
| 13 | + <setup> | |
| 14 | + <menu-item parent="BUILD" id="STRUCTURES"/> | |
| 15 | + </setup> | |
| 16 | + </contribution> | |
| 17 | + <contribution type="Command" id="C_BuildTool"> | |
| 18 | + <name>建造物設置フォーム</name> | |
| 19 | + <class name="nft.ui.core.BuildToolForm" codebase=".UI"/> | |
| 20 | + <command type="ModelessForm" menupath="BUILD\STRUCTURES" /> | |
| 21 | + </contribution> | |
| 22 | + | |
| 7 | 23 | <contribution type="image" id="pic.ModernDepartment"> |
| 8 | 24 | <default src="stationMDNDepart.bmp"/> |
| 9 | 25 | <condition when="night" src="stationMDNDepart_n.bmp"/> |
| @@ -98,6 +98,8 @@ | ||
| 98 | 98 | </item> |
| 99 | 99 | <item mid="VIEW" caption="表示(&V)"> |
| 100 | 100 | </item> |
| 101 | + <item mid="BUILD" caption="建設(&B)"> | |
| 102 | + </item> | |
| 101 | 103 | <item mid="HELP" caption="ヘルプ(&H)"> |
| 102 | 104 | <item mid="DEBUG|XNAFORMTEST" caption="XNAコントロールテスト"/> |
| 103 | 105 | <item mid="DEBUG|TABLEFORMTEST" caption="テーブルレイアウトのテスト"/> |
| @@ -24,6 +24,7 @@ | ||
| 24 | 24 | #region Effect Parameters |
| 25 | 25 | |
| 26 | 26 | protected EffectParameter textureParam; |
| 27 | + protected EffectParameter textureNightParam; | |
| 27 | 28 | protected EffectParameter diffuseColorParam; |
| 28 | 29 | protected EffectParameter alphaTestParam; |
| 29 | 30 | protected EffectParameter objKeyParam; |
| @@ -209,6 +210,18 @@ | ||
| 209 | 210 | set { textureParam.SetValue(value); } |
| 210 | 211 | } |
| 211 | 212 | |
| 213 | + /// <summary> | |
| 214 | + /// Gets or sets the current Night override texture. | |
| 215 | + /// set null to use Day texture by darken it. | |
| 216 | + /// </summary> | |
| 217 | + public Texture2D NightTexture { | |
| 218 | + get { | |
| 219 | + return textureNightParam.GetValueTexture2D(); | |
| 220 | + } | |
| 221 | + set { | |
| 222 | + textureNightParam.SetValue(value); | |
| 223 | + } | |
| 224 | + } | |
| 212 | 225 | |
| 213 | 226 | /// <summary> |
| 214 | 227 | /// Gets or sets whether vertex color is enabled. |
| @@ -356,9 +369,10 @@ | ||
| 356 | 369 | protected virtual void CacheEffectParameters() |
| 357 | 370 | { |
| 358 | 371 | textureParam = Parameters["Texture"]; |
| 372 | + textureNightParam = Parameters["Texture_Night"]; | |
| 359 | 373 | diffuseColorParam = Parameters["DiffuseColor"]; |
| 360 | 374 | alphaTestParam = Parameters["AlphaTest"]; |
| 361 | - objKeyParam = Parameters["ObjKey"]; | |
| 375 | + objKeyParam = Parameters["IdxColor"]; | |
| 362 | 376 | fogColorParam = Parameters["FogColor"]; |
| 363 | 377 | fogVectorParam = Parameters["FogVector"]; |
| 364 | 378 | worldViewProjParam = Parameters["WorldViewProj"]; |
| @@ -374,8 +388,9 @@ | ||
| 374 | 388 | /// </summary> |
| 375 | 389 | protected override void OnApply() |
| 376 | 390 | { |
| 377 | - Vector3 v3 = new Vector3((htid & 0xffff)/65536f, (htid >>16)/65536f, 1); | |
| 378 | - objKeyParam.SetValue(v3); | |
| 391 | + byte[] arr = BitConverter.GetBytes(htid); | |
| 392 | + Vector4 v4 = new Vector4(arr[0] / 255f, arr[1] / 255f, arr[2] / 255f, arr[3] / 255f); | |
| 393 | + objKeyParam.SetValue(v4); | |
| 379 | 394 | // Recompute the world+view+projection matrix or fog vector? |
| 380 | 395 | dirtyFlags = EffectHelpers.SetWorldViewProjAndFog(dirtyFlags, ref world, ref view, ref projection, ref worldView, fogEnabled, fogStart, fogEnd, worldViewProjParam, fogVectorParam); |
| 381 | 396 | //if((dirtyFlags & EffectDirtyFlags.World) != 0) |
| @@ -421,10 +436,14 @@ | ||
| 421 | 436 | // Recompute the shader index? |
| 422 | 437 | if ((dirtyFlags & EffectDirtyFlags.ShaderIndex) != 0) |
| 423 | 438 | { |
| 424 | - int shaderIndex = ((int)usage)*2; | |
| 425 | - if (vertexColorEnabled) | |
| 426 | - shaderIndex ++; | |
| 427 | - | |
| 439 | + int shaderIndex; | |
| 440 | + if (textureNightParam.GetValueTexture2D() != null && usage!=EffectUsage.Normal) { | |
| 441 | + shaderIndex = 5 + ((int)usage); | |
| 442 | + } else { | |
| 443 | + shaderIndex = ((int)usage) * 2; | |
| 444 | + if (vertexColorEnabled) | |
| 445 | + shaderIndex++; | |
| 446 | + } | |
| 428 | 447 | //if (!fogEnabled) |
| 429 | 448 | // shaderIndex += 1; |
| 430 | 449 |
| @@ -24,6 +24,10 @@ | ||
| 24 | 24 | |
| 25 | 25 | public class XnaSurface : ISurface |
| 26 | 26 | { |
| 27 | + public enum RenderOutput : int { | |
| 28 | + Default=-1, DayColor=0, ObjKeyMap=1, Lighting=2, NightColor=3, DepthMap=6 | |
| 29 | + } | |
| 30 | + | |
| 27 | 31 | static protected Stopwatch watch = new Stopwatch(); |
| 28 | 32 | |
| 29 | 33 | static internal XnaSurface CreateForControl(Control c, SurfaceUsage usage) { |
| @@ -80,6 +84,7 @@ | ||
| 80 | 84 | protected Size szPrefferd; |
| 81 | 85 | private int objcount; |
| 82 | 86 | private int mrtcount; //Mulit Render Target count |
| 87 | + private int idx_out=-1; // Output Render Target (-1:Final image) | |
| 83 | 88 | |
| 84 | 89 | protected PostProcessEffect ppEffect; |
| 85 | 90 | protected SpriteBatch spriteBatch; |
| @@ -142,10 +147,10 @@ | ||
| 142 | 147 | #endif |
| 143 | 148 | switch (usage) { |
| 144 | 149 | case SurfaceUsage.GameView: |
| 145 | - mrtcount = 3; | |
| 150 | + mrtcount = 4; | |
| 146 | 151 | break; |
| 147 | 152 | case SurfaceUsage.PreCombinedTexture: |
| 148 | - mrtcount = 2; | |
| 153 | + mrtcount = 3; | |
| 149 | 154 | break; |
| 150 | 155 | default: |
| 151 | 156 | mrtcount = 0; |
| @@ -224,6 +229,15 @@ | ||
| 224 | 229 | return new Point((int)vout.X, (int)vout.Y); |
| 225 | 230 | } |
| 226 | 231 | |
| 232 | + public RenderOutput Output{ | |
| 233 | + get { | |
| 234 | + return (RenderOutput)idx_out; | |
| 235 | + } | |
| 236 | + set { | |
| 237 | + idx_out = (int)value; | |
| 238 | + } | |
| 239 | + } | |
| 240 | + | |
| 227 | 241 | internal int WorkBuffersCount { |
| 228 | 242 | get { |
| 229 | 243 | return mrtcount; |
| @@ -294,16 +308,29 @@ | ||
| 294 | 308 | void PostProcess() { |
| 295 | 309 | if (mrtcount > 0) { |
| 296 | 310 | GraphicsDevice.SetRenderTarget(target); |
| 297 | - ppEffect.CurrentTechnique = ppEffect.Techniques["EdgeDetect"]; | |
| 298 | - ppEffect.DepthTexture = WorkTarget(1); | |
| 299 | - // ポストプロセス エフェクトを適用する全画面スプライトを描画します。 | |
| 300 | - //spriteBatch.Begin(0, BlendState.Opaque); | |
| 301 | - spriteBatch.Begin(0, BlendState.Opaque, null, null, null, ppEffect); | |
| 302 | - RenderTarget2D finalImage = WorkTarget(0); | |
| 311 | + RenderTarget2D finalImage; | |
| 312 | + if (idx_out < 0) { | |
| 313 | + ppEffect.CurrentTechnique = ppEffect.Techniques["EdgeDetect"]; | |
| 314 | + ppEffect.DepthTexture = WorkTarget(2); | |
| 315 | + // ポストプロセス エフェクトを適用する全画面スプライトを描画します。 | |
| 316 | + spriteBatch.Begin(0, BlendState.Opaque, null, null, null, ppEffect); | |
| 317 | + finalImage = WorkTarget(0); | |
| 318 | + } else if (idx_out < mrtcount){ | |
| 319 | + // デバッグ用:指定作業バッファの出力 | |
| 320 | + spriteBatch.Begin(0, BlendState.Opaque); | |
| 321 | + finalImage = WorkTarget(idx_out); | |
| 322 | + } else { | |
| 323 | + // デバッグ用:指定作業バッファの出力(Alpha値をグレースケール表示) | |
| 324 | + ppEffect.CurrentTechnique = ppEffect.Techniques["AlphaToGS"]; | |
| 325 | + ppEffect.DepthTexture = WorkTarget(idx_out-mrtcount); | |
| 326 | + spriteBatch.Begin(0, BlendState.Opaque, null, null, null, ppEffect); | |
| 327 | + finalImage = WorkTarget(0); | |
| 328 | + } | |
| 303 | 329 | XnaRect rct = viewport.Bounds; |
| 304 | 330 | rct.Width = Math.Min(rct.Width, finalImage.Width); |
| 305 | 331 | rct.Height = Math.Min(rct.Height, finalImage.Height); |
| 306 | 332 | spriteBatch.Draw(finalImage, Vector2.Zero, viewport.Bounds, XnaColor.White); |
| 333 | + | |
| 307 | 334 | #if false //DEBUG |
| 308 | 335 | PointF3D v = CameraPosition; |
| 309 | 336 |
| @@ -151,6 +151,7 @@ | ||
| 151 | 151 | ctrl.Dock = DockStyle.Fill; |
| 152 | 152 | parent.Controls.Add(ctrl); |
| 153 | 153 | eventtarget = ctrl; |
| 154 | + parent.KeyUp += new KeyEventHandler(ctrl.XnaControl_KeyUp); | |
| 154 | 155 | return ctrl.Surface; |
| 155 | 156 | } |
| 156 | 157 |
| @@ -13,8 +13,7 @@ | ||
| 13 | 13 | using Microsoft.Xna.Framework; |
| 14 | 14 | using System.Diagnostics; |
| 15 | 15 | |
| 16 | -namespace nft.xna | |
| 17 | -{ | |
| 16 | +namespace nft.xna { | |
| 18 | 17 | |
| 19 | 18 | /// <summary> |
| 20 | 19 | /// このカスタム コントロールは、XNA Framework GraphicsDevice を使用して、 |
| @@ -21,36 +20,35 @@ | ||
| 21 | 20 | /// Windows フォームにレンダリングします。 |
| 22 | 21 | /// ※サンプルにあったGraphicDeviceContorlを大幅カスタマイズ c477 |
| 23 | 22 | /// </summary> |
| 24 | - public class XnaControl : Control | |
| 25 | - { | |
| 23 | + public class XnaControl : Control { | |
| 26 | 24 | protected XnaSurface surface = null; |
| 27 | 25 | SurfaceUsage usage; |
| 28 | 26 | #region Initialization |
| 29 | 27 | |
| 30 | 28 | public XnaControl(SurfaceUsage usage) { |
| 31 | - this.usage = usage; | |
| 29 | + this.usage = usage; | |
| 30 | + KeyUp += new KeyEventHandler(XnaControl_KeyUp); | |
| 32 | 31 | } |
| 33 | 32 | |
| 34 | - public XnaControl() : this(SurfaceUsage.Normal) { | |
| 33 | + public XnaControl() | |
| 34 | + : this(SurfaceUsage.Normal) { | |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | public XnaSurface Surface { |
| 38 | - get { return surface; } | |
| 38 | + get { | |
| 39 | + return surface; | |
| 40 | + } | |
| 39 | 41 | } |
| 40 | 42 | |
| 41 | - protected override void OnCreateControl() | |
| 42 | - { | |
| 43 | - if (!DesignMode) | |
| 44 | - { | |
| 43 | + protected override void OnCreateControl() { | |
| 44 | + if (!DesignMode) { | |
| 45 | 45 | surface = XnaSurface.CreateForControl(this, usage); |
| 46 | 46 | } |
| 47 | 47 | base.OnCreateControl(); |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | - protected override void Dispose(bool disposing) | |
| 51 | - { | |
| 52 | - if (disposing && surface != null) | |
| 53 | - { | |
| 50 | + protected override void Dispose(bool disposing) { | |
| 51 | + if (disposing && surface != null) { | |
| 54 | 52 | surface.Dispose(); |
| 55 | 53 | surface = null; |
| 56 | 54 | } |
| @@ -59,8 +57,7 @@ | ||
| 59 | 57 | #endregion |
| 60 | 58 | |
| 61 | 59 | #region Paint |
| 62 | - protected override void OnPaint(PaintEventArgs evt) | |
| 63 | - { | |
| 60 | + protected override void OnPaint(PaintEventArgs evt) { | |
| 64 | 61 | if (surface == null) { |
| 65 | 62 | // Assume running in DesignMode. |
| 66 | 63 | PaintErrorMessage(evt.Graphics, Text + "\n\n" + GetType()); |
| @@ -87,13 +84,10 @@ | ||
| 87 | 84 | |
| 88 | 85 | // Called when GraphicsDevice is not available. |
| 89 | 86 | // For example, Device lost or Running in 'DesignMode==true' |
| 90 | - protected virtual void PaintErrorMessage(Graphics graphics, string text) | |
| 91 | - { | |
| 87 | + protected virtual void PaintErrorMessage(Graphics graphics, string text) { | |
| 92 | 88 | graphics.Clear(SysColor.CornflowerBlue); |
| 93 | - using (Brush brush = new SolidBrush(SysColor.Black)) | |
| 94 | - { | |
| 95 | - using (StringFormat format = new StringFormat()) | |
| 96 | - { | |
| 89 | + using (Brush brush = new SolidBrush(SysColor.Black)) { | |
| 90 | + using (StringFormat format = new StringFormat()) { | |
| 97 | 91 | format.Alignment = StringAlignment.Center; |
| 98 | 92 | format.LineAlignment = StringAlignment.Center; |
| 99 | 93 | graphics.DrawString(text, Font, brush, ClientRectangle, format); |
| @@ -107,6 +101,35 @@ | ||
| 107 | 101 | Invalidate(); |
| 108 | 102 | } |
| 109 | 103 | |
| 104 | + | |
| 105 | + internal void XnaControl_KeyUp(object sender, KeyEventArgs e) { | |
| 106 | + if (e.Control) { | |
| 107 | + switch (e.KeyCode) { | |
| 108 | + case Keys.D0: | |
| 109 | + surface.Output = XnaSurface.RenderOutput.Default; | |
| 110 | + break; | |
| 111 | + case Keys.D1: | |
| 112 | + surface.Output = XnaSurface.RenderOutput.DayColor; | |
| 113 | + break; | |
| 114 | + case Keys.D2: | |
| 115 | + surface.Output = XnaSurface.RenderOutput.NightColor; | |
| 116 | + break; | |
| 117 | + case Keys.D3: | |
| 118 | + surface.Output = XnaSurface.RenderOutput.DepthMap; | |
| 119 | + break; | |
| 120 | + case Keys.D4: | |
| 121 | + surface.Output = XnaSurface.RenderOutput.ObjKeyMap; | |
| 122 | + break; | |
| 123 | + case Keys.D5: | |
| 124 | + surface.Output = XnaSurface.RenderOutput.Lighting; | |
| 125 | + break; | |
| 126 | + } | |
| 127 | + Invalidate(); | |
| 128 | + } | |
| 129 | + } | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 110 | 133 | /* |
| 111 | 134 | protected override void SetBoundsCore(int x, int y, int width, int height, BoundsSpecified specified) { |
| 112 | 135 | width = ((width + 1) | 1) - 1; |
| @@ -116,13 +139,11 @@ | ||
| 116 | 139 | */ |
| 117 | 140 | |
| 118 | 141 | // override to cancel default background fill. |
| 119 | - protected override void OnPaintBackground(PaintEventArgs pevent) | |
| 120 | - { | |
| 142 | + protected override void OnPaintBackground(PaintEventArgs pevent) { | |
| 121 | 143 | } |
| 122 | 144 | #endregion |
| 123 | 145 | |
| 124 | - private void InitializeComponent() | |
| 125 | - { | |
| 146 | + private void InitializeComponent() { | |
| 126 | 147 | this.SuspendLayout(); |
| 127 | 148 | // |
| 128 | 149 | // XnaControl |
| @@ -59,12 +59,13 @@ | ||
| 59 | 59 | return entity.CreateTerrainTemplate(rkey, basecol, vertices, brightness); |
| 60 | 60 | } |
| 61 | 61 | |
| 62 | - | |
| 62 | + /* | |
| 63 | 63 | public ITerrainPlate CreateTerrainPlate(Location loc, ITerrainPlateTemplate template) { |
| 64 | - UInt32 id = (UInt32)((loc.X << 16) + loc.Y); | |
| 64 | + UInt32 id = (UInt32)(loc.X + loc.Y); //((loc.X << 16) + loc.Y); | |
| 65 | 65 | return entity.CreateTerrainPlate(id, template); |
| 66 | 66 | } |
| 67 | - | |
| 67 | + */ | |
| 68 | + | |
| 68 | 69 | public ITerrainPlate CreateTerrainPlate(UInt32 id, ITerrainPlateTemplate template) { |
| 69 | 70 | return entity.CreateTerrainPlate(id, template); |
| 70 | 71 | } |
| @@ -16,7 +16,9 @@ | ||
| 16 | 16 | public class GameViewPanel : UserControl |
| 17 | 17 | { |
| 18 | 18 | SceneBuilder builder; |
| 19 | + bool prepared; | |
| 19 | 20 | public GameViewPanel(GameImpl game) { |
| 21 | + prepared = false; | |
| 20 | 22 | InitializeComponent(); |
| 21 | 23 | //renderPanel.SurfaceUsage = SurfaceUsage.Normal; |
| 22 | 24 | touchPanel.Scroll2 += new ScrollEventHandler(OnTouchPanelScroll); |
| @@ -25,9 +27,11 @@ | ||
| 25 | 27 | } |
| 26 | 28 | |
| 27 | 29 | void EventTarget_MouseMove(object sender, MouseEventArgs e) { |
| 28 | - //UInt32 u = renderPanel.Surface.HitTestAt(e.X, e.Y); | |
| 29 | - object o = builder.GetObjectAt(e.Location); | |
| 30 | - renderPanel.Refresh(); | |
| 30 | + if (prepared) { | |
| 31 | + //UInt32 u = renderPanel.Surface.HitTestAt(e.X, e.Y); | |
| 32 | + object o = builder.GetObjectAt(e.Location); | |
| 33 | + renderPanel.Refresh(); | |
| 34 | + } | |
| 31 | 35 | } |
| 32 | 36 | |
| 33 | 37 | public SceneBuilder SceneBuilder { |
| @@ -48,6 +52,7 @@ | ||
| 48 | 52 | |
| 49 | 53 | void SurfaceReady(object sender, EventArgs e) { |
| 50 | 54 | builder.AttachSurface(renderPanel.Surface); |
| 55 | + prepared = true; | |
| 51 | 56 | } |
| 52 | 57 | |
| 53 | 58 | protected override void OnLoad(EventArgs e) { |
| @@ -73,7 +73,8 @@ | ||
| 73 | 73 | holder = Add(key, templ); |
| 74 | 74 | } |
| 75 | 75 | templ = holder.AddRef(); |
| 76 | - return GraphicManager.CreateTerrainPlate(loc, templ); | |
| 76 | + UInt32 idkey = (UInt32)(hint.VX + hint.VY+0x800000); | |
| 77 | + return GraphicManager.CreateTerrainPlate(idkey, templ); | |
| 77 | 78 | } |
| 78 | 79 | |
| 79 | 80 | protected TemplateHolder Add(T key, ITerrainPlateTemplate templ) { |
| @@ -137,7 +138,8 @@ | ||
| 137 | 138 | holder = Add(key, templ); |
| 138 | 139 | } |
| 139 | 140 | templ = holder.AddRef(); |
| 140 | - return GraphicManager.CreateTerrainPlate(UInt32.MaxValue, templ); | |
| 141 | + UInt32 idkey = (UInt32)(hint.VX + hint.VY); | |
| 142 | + return GraphicManager.CreateTerrainPlate(idkey, templ); | |
| 141 | 143 | } |
| 142 | 144 | |
| 143 | 145 | protected TemplateHolder Add(T key, ITerrainPlateTemplate templ) { |
| @@ -42,7 +42,8 @@ | ||
| 42 | 42 | { |
| 43 | 43 | IGraphicManager gm = (IGraphicManager)GlobalModules.GetModule(typeof(IGraphicManager)); |
| 44 | 44 | surface = gm.CreateSurfaceForControl(this, out eventtarget, usage); |
| 45 | - | |
| 45 | + //((Control)surface).KeyDown+=new KeyEventHandler(RenderViewPanel_surface_KeyDown); | |
| 46 | + this.KeyDown += new KeyEventHandler(RenderViewPanel_KeyDown); | |
| 46 | 47 | // Disable control to all events are processed by parent. |
| 47 | 48 | eventtarget.Enabled = false; |
| 48 | 49 | eventtarget = this; |
| @@ -50,6 +51,10 @@ | ||
| 50 | 51 | OnSurfacePrepared(this, new EventArgs()); |
| 51 | 52 | } |
| 52 | 53 | } |
| 54 | + | |
| 55 | + void RenderViewPanel_KeyDown(object sender, KeyEventArgs e) { | |
| 56 | + Debug.WriteLine("RenderViewPanel_KeyDown:" + e.KeyData); | |
| 57 | + } | |
| 53 | 58 | |
| 54 | 59 | public ISurface Surface |
| 55 | 60 | { |
| @@ -12,6 +12,7 @@ | ||
| 12 | 12 | using nft.framework.drawing; |
| 13 | 13 | using System.IO; |
| 14 | 14 | using WeifenLuo.WinFormsUI.Docking; |
| 15 | +using System.Security.Permissions; | |
| 15 | 16 | |
| 16 | 17 | |
| 17 | 18 | namespace nft.ui.mainframe |
| @@ -44,9 +45,8 @@ | ||
| 44 | 45 | //IsMdiContainer = true; |
| 45 | 46 | dockManager = new DockingManagerEx(panelCenter); |
| 46 | 47 | stripManager = new ToolStripManager(toolStripPanel, mainMenu); |
| 47 | - //KeyPreview = true; | |
| 48 | - //KeyDown += new KeyEventHandler(MainFrame_KeyDown); | |
| 49 | - //KeyUp += new KeyEventHandler(MainFrame_KeyUp); | |
| 48 | + KeyPreview = true; | |
| 49 | + PreviewKeyDown += new PreviewKeyDownEventHandler(MainFrame_PreviewKeyDown); | |
| 50 | 50 | /* |
| 51 | 51 | Bitmap bmp = new Bitmap(2000, 2000, PixelFormat.Format32bppArgb); |
| 52 | 52 | Bitmap b2 = bmp; |
| @@ -61,20 +61,34 @@ | ||
| 61 | 61 | Show(); |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | - void MainFrame_KeyUp(object sender, KeyEventArgs e) { | |
| 65 | - if (e.KeyCode == Keys.Left) { | |
| 66 | - Debug.WriteLine("Handled!"); | |
| 67 | - e.Handled = true; | |
| 68 | - } else { | |
| 69 | - Debug.Write(e.KeyCode); | |
| 70 | - } | |
| 64 | + void MainFrame_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e) { | |
| 65 | + Debug.WriteLine("PreviewKeyDown:" + e.KeyData); | |
| 71 | 66 | } |
| 72 | 67 | |
| 73 | - void MainFrame_KeyDown(object sender, KeyEventArgs e) { | |
| 74 | - Debug.WriteLine("MainFrame getKeyEvent="+e.KeyCode); | |
| 68 | + #region Key event management | |
| 69 | + /* | |
| 70 | + [UIPermission(SecurityAction.Demand, Window = UIPermissionWindow.AllWindows)] | |
| 71 | + protected override bool ProcessDialogKey(Keys keyData) { | |
| 72 | + Debug.WriteLine("ProcessDialogKey:" + keyData); | |
| 73 | + //処理されたとき(consume)は、trueを返す | |
| 74 | + return base.ProcessDialogKey(keyData); | |
| 75 | 75 | } |
| 76 | + */ | |
| 76 | 77 | |
| 77 | - /// <summary> | |
| 78 | + //他のMDI子ウィンドウに渡る前にチェックできる。ここで処理するのが望ましい | |
| 79 | + //PreviewKeyDownは思うように機能しない | |
| 80 | + [UIPermission(SecurityAction.Demand, Window = UIPermissionWindow.AllWindows)] | |
| 81 | + protected override bool ProcessCmdKey(ref Message msg, Keys keyData) { | |
| 82 | + Debug.WriteLine("ProcessCmdKey:" + keyData); | |
| 83 | + //処理されたとき(consume)は、trueを返す | |
| 84 | + //一般のキーとして処理したい場合はfalseを返す | |
| 85 | + //return false; | |
| 86 | + return base.ProcessCmdKey(ref msg, keyData); | |
| 87 | + } | |
| 88 | + | |
| 89 | + #endregion | |
| 90 | + | |
| 91 | + /// <summary> | |
| 78 | 92 | /// 使用されているリソースに後処理を実行します。 |
| 79 | 93 | /// </summary> |
| 80 | 94 | protected override void Dispose( bool disposing ) |
| @@ -79,8 +79,8 @@ | ||
| 79 | 79 | ゲームビュー&プレコンバインドでは下記 |
| 80 | 80 | 0:RGB=昼間色、A=透過情報 |
| 81 | 81 | 1:AR=グループ内ID GB=ID塗り分け |
| 82 | -2:RGB=夜間色、A= | |
| 83 | -3:RGB=照り返し、A=深度 | |
| 82 | +2:RGB=照り返し、A=深度 | |
| 83 | +3:RGB=夜間色、A= | |
| 84 | 84 | |
| 85 | 85 | IDは24bit枠 |
| 86 | 86 | ・地形は(x-y)値(16bit)+0xff |
| @@ -0,0 +1,23 @@ | ||
| 1 | +using System; | |
| 2 | +using System.Collections.Generic; | |
| 3 | +using System.Linq; | |
| 4 | +using System.Text; | |
| 5 | +using nft.framework; | |
| 6 | +using System.Windows.Forms; | |
| 7 | + | |
| 8 | +namespace nft.test.test { | |
| 9 | + public class KeyControlTest { | |
| 10 | + [TestEntry("静的フォームのキーイベント制御")] | |
| 11 | + public static void ModlessFormKeyControlTest() { | |
| 12 | + KeyControlForm form = new KeyControlForm(); | |
| 13 | + form.Show(Application.OpenForms[0]); | |
| 14 | + } | |
| 15 | + | |
| 16 | + [TestEntry("モーダルフォームのキーイベント制御")] | |
| 17 | + public static void ModalFormKeyControlTest() { | |
| 18 | + KeyControlForm form = new KeyControlForm(); | |
| 19 | + form.ShowDialog(Application.OpenForms[0]); | |
| 20 | + } | |
| 21 | + | |
| 22 | + } | |
| 23 | +} |
| @@ -0,0 +1,167 @@ | ||
| 1 | +namespace nft.test.test { | |
| 2 | + partial class KeyControlForm { | |
| 3 | + /// <summary> | |
| 4 | + /// Required designer variable. | |
| 5 | + /// </summary> | |
| 6 | + private System.ComponentModel.IContainer components = null; | |
| 7 | + | |
| 8 | + /// <summary> | |
| 9 | + /// Clean up any resources being used. | |
| 10 | + /// </summary> | |
| 11 | + /// <param name="disposing">true if managed resources should be disposed; otherwise, 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 Form Designer generated code | |
| 20 | + | |
| 21 | + /// <summary> | |
| 22 | + /// Required method for Designer support - do not modify | |
| 23 | + /// the contents of this method with the code editor. | |
| 24 | + /// </summary> | |
| 25 | + private void InitializeComponent() { | |
| 26 | + System.Windows.Forms.ListViewItem listViewItem1 = new System.Windows.Forms.ListViewItem(new string[] { | |
| 27 | + "Item1", | |
| 28 | + "Sub1"}, -1); | |
| 29 | + System.Windows.Forms.ListViewItem listViewItem2 = new System.Windows.Forms.ListViewItem(new string[] { | |
| 30 | + "Item2", | |
| 31 | + "Sub2"}, -1); | |
| 32 | + System.Windows.Forms.ListViewItem listViewItem3 = new System.Windows.Forms.ListViewItem(new string[] { | |
| 33 | + "Item3", | |
| 34 | + "Sub3"}, -1); | |
| 35 | + System.Windows.Forms.TreeNode treeNode1 = new System.Windows.Forms.TreeNode("Child1"); | |
| 36 | + System.Windows.Forms.TreeNode treeNode2 = new System.Windows.Forms.TreeNode("Child2"); | |
| 37 | + System.Windows.Forms.TreeNode treeNode3 = new System.Windows.Forms.TreeNode("Node1", new System.Windows.Forms.TreeNode[] { | |
| 38 | + treeNode1, | |
| 39 | + treeNode2}); | |
| 40 | + System.Windows.Forms.TreeNode treeNode4 = new System.Windows.Forms.TreeNode("Root", new System.Windows.Forms.TreeNode[] { | |
| 41 | + treeNode3}); | |
| 42 | + this.button1 = new System.Windows.Forms.Button(); | |
| 43 | + this.listBox1 = new System.Windows.Forms.ListBox(); | |
| 44 | + this.listView1 = new System.Windows.Forms.ListView(); | |
| 45 | + this.textBox1 = new System.Windows.Forms.TextBox(); | |
| 46 | + this.c1 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); | |
| 47 | + this.c2 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); | |
| 48 | + this.dateTimePicker1 = new System.Windows.Forms.DateTimePicker(); | |
| 49 | + this.numericUpDown1 = new System.Windows.Forms.NumericUpDown(); | |
| 50 | + this.treeView1 = new System.Windows.Forms.TreeView(); | |
| 51 | + ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit(); | |
| 52 | + this.SuspendLayout(); | |
| 53 | + // | |
| 54 | + // button1 | |
| 55 | + // | |
| 56 | + this.button1.Location = new System.Drawing.Point(12, 12); | |
| 57 | + this.button1.Name = "button1"; | |
| 58 | + this.button1.Size = new System.Drawing.Size(75, 23); | |
| 59 | + this.button1.TabIndex = 0; | |
| 60 | + this.button1.Text = "Click me!"; | |
| 61 | + this.button1.UseVisualStyleBackColor = true; | |
| 62 | + // | |
| 63 | + // listBox1 | |
| 64 | + // | |
| 65 | + this.listBox1.FormattingEnabled = true; | |
| 66 | + this.listBox1.ItemHeight = 12; | |
| 67 | + this.listBox1.Items.AddRange(new object[] { | |
| 68 | + "Item1", | |
| 69 | + "Item2", | |
| 70 | + "Item3"}); | |
| 71 | + this.listBox1.Location = new System.Drawing.Point(12, 180); | |
| 72 | + this.listBox1.Name = "listBox1"; | |
| 73 | + this.listBox1.Size = new System.Drawing.Size(107, 52); | |
| 74 | + this.listBox1.TabIndex = 1; | |
| 75 | + // | |
| 76 | + // listView1 | |
| 77 | + // | |
| 78 | + this.listView1.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { | |
| 79 | + this.c1, | |
| 80 | + this.c2}); | |
| 81 | + this.listView1.Items.AddRange(new System.Windows.Forms.ListViewItem[] { | |
| 82 | + listViewItem1, | |
| 83 | + listViewItem2, | |
| 84 | + listViewItem3}); | |
| 85 | + this.listView1.Location = new System.Drawing.Point(134, 135); | |
| 86 | + this.listView1.Name = "listView1"; | |
| 87 | + this.listView1.Size = new System.Drawing.Size(138, 97); | |
| 88 | + this.listView1.TabIndex = 2; | |
| 89 | + this.listView1.UseCompatibleStateImageBehavior = false; | |
| 90 | + this.listView1.View = System.Windows.Forms.View.Details; | |
| 91 | + // | |
| 92 | + // textBox1 | |
| 93 | + // | |
| 94 | + this.textBox1.Location = new System.Drawing.Point(12, 42); | |
| 95 | + this.textBox1.Name = "textBox1"; | |
| 96 | + this.textBox1.Size = new System.Drawing.Size(99, 19); | |
| 97 | + this.textBox1.TabIndex = 3; | |
| 98 | + this.textBox1.Text = "ABC"; | |
| 99 | + // | |
| 100 | + // dateTimePicker1 | |
| 101 | + // | |
| 102 | + this.dateTimePicker1.Location = new System.Drawing.Point(12, 89); | |
| 103 | + this.dateTimePicker1.Name = "dateTimePicker1"; | |
| 104 | + this.dateTimePicker1.Size = new System.Drawing.Size(98, 19); | |
| 105 | + this.dateTimePicker1.TabIndex = 4; | |
| 106 | + // | |
| 107 | + // numericUpDown1 | |
| 108 | + // | |
| 109 | + this.numericUpDown1.Location = new System.Drawing.Point(12, 155); | |
| 110 | + this.numericUpDown1.Name = "numericUpDown1"; | |
| 111 | + this.numericUpDown1.Size = new System.Drawing.Size(46, 19); | |
| 112 | + this.numericUpDown1.TabIndex = 5; | |
| 113 | + // | |
| 114 | + // treeView1 | |
| 115 | + // | |
| 116 | + this.treeView1.FullRowSelect = true; | |
| 117 | + this.treeView1.Location = new System.Drawing.Point(134, 13); | |
| 118 | + this.treeView1.Name = "treeView1"; | |
| 119 | + treeNode1.Name = "c1"; | |
| 120 | + treeNode1.Text = "Child1"; | |
| 121 | + treeNode2.Name = "c2"; | |
| 122 | + treeNode2.Text = "Child2"; | |
| 123 | + treeNode3.Name = "n1"; | |
| 124 | + treeNode3.Text = "Node1"; | |
| 125 | + treeNode4.Name = "root"; | |
| 126 | + treeNode4.Text = "Root"; | |
| 127 | + this.treeView1.Nodes.AddRange(new System.Windows.Forms.TreeNode[] { | |
| 128 | + treeNode4}); | |
| 129 | + this.treeView1.Size = new System.Drawing.Size(138, 116); | |
| 130 | + this.treeView1.TabIndex = 6; | |
| 131 | + // | |
| 132 | + // KeyControlForm | |
| 133 | + // | |
| 134 | + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); | |
| 135 | + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; | |
| 136 | + this.ClientSize = new System.Drawing.Size(284, 244); | |
| 137 | + this.Controls.Add(this.treeView1); | |
| 138 | + this.Controls.Add(this.numericUpDown1); | |
| 139 | + this.Controls.Add(this.dateTimePicker1); | |
| 140 | + this.Controls.Add(this.textBox1); | |
| 141 | + this.Controls.Add(this.listView1); | |
| 142 | + this.Controls.Add(this.listBox1); | |
| 143 | + this.Controls.Add(this.button1); | |
| 144 | + this.KeyPreview = true; | |
| 145 | + this.Name = "KeyControlForm"; | |
| 146 | + this.Text = "KeyControlForm"; | |
| 147 | + this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.KeyControlForm_KeyDown); | |
| 148 | + this.PreviewKeyDown += new System.Windows.Forms.PreviewKeyDownEventHandler(this.KeyControlForm_PreviewKeyDown); | |
| 149 | + ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit(); | |
| 150 | + this.ResumeLayout(false); | |
| 151 | + this.PerformLayout(); | |
| 152 | + | |
| 153 | + } | |
| 154 | + | |
| 155 | + #endregion | |
| 156 | + | |
| 157 | + private System.Windows.Forms.Button button1; | |
| 158 | + private System.Windows.Forms.ListBox listBox1; | |
| 159 | + private System.Windows.Forms.ListView listView1; | |
| 160 | + private System.Windows.Forms.ColumnHeader c1; | |
| 161 | + private System.Windows.Forms.ColumnHeader c2; | |
| 162 | + private System.Windows.Forms.TextBox textBox1; | |
| 163 | + private System.Windows.Forms.DateTimePicker dateTimePicker1; | |
| 164 | + private System.Windows.Forms.NumericUpDown numericUpDown1; | |
| 165 | + private System.Windows.Forms.TreeView treeView1; | |
| 166 | + } | |
| 167 | +} | |
| \ No newline at end of file |
| @@ -0,0 +1,50 @@ | ||
| 1 | +using System; | |
| 2 | +using System.Collections.Generic; | |
| 3 | +using System.ComponentModel; | |
| 4 | +using System.Data; | |
| 5 | +using System.Drawing; | |
| 6 | +using System.Linq; | |
| 7 | +using System.Text; | |
| 8 | +using System.Windows.Forms; | |
| 9 | +using System.Security.Permissions; | |
| 10 | +using System.Diagnostics; | |
| 11 | + | |
| 12 | +namespace nft.test.test { | |
| 13 | + public partial class KeyControlForm : Form { | |
| 14 | + public KeyControlForm() { | |
| 15 | + InitializeComponent(); | |
| 16 | + } | |
| 17 | + | |
| 18 | + [UIPermission(SecurityAction.Demand,Window = UIPermissionWindow.AllWindows)] | |
| 19 | + protected override bool ProcessDialogKey(Keys keyData) { | |
| 20 | + Debug.WriteLine("ProcessDialogKey:" + keyData); | |
| 21 | + //本来の処理をさせたくないときは、trueを返す | |
| 22 | + return true; | |
| 23 | + //return base.ProcessDialogKey(keyData); | |
| 24 | + } | |
| 25 | + [UIPermission(SecurityAction.Demand, Window = UIPermissionWindow.AllWindows)] | |
| 26 | + protected override bool ProcessTabKey(bool forward) { | |
| 27 | + Debug.WriteLine("ProcessTabKey"); | |
| 28 | + return true; | |
| 29 | + } | |
| 30 | + | |
| 31 | + protected override bool ProcessCmdKey(ref Message msg, Keys keyData) { | |
| 32 | + Debug.WriteLine("ProcessCmdKey:" + keyData); | |
| 33 | + return base.ProcessCmdKey(ref msg, keyData); | |
| 34 | + } | |
| 35 | + protected override bool ProcessDialogChar(char charCode) { | |
| 36 | + Debug.WriteLine("ProcessDialogChar:" + new string(charCode,1)+", "+ (uint)charCode); | |
| 37 | + return base.ProcessDialogChar(charCode); | |
| 38 | + } | |
| 39 | + | |
| 40 | + private void KeyControlForm_KeyDown(object sender, KeyEventArgs e) { | |
| 41 | + e.Handled = true; // 子コントロールにイベントを渡さない | |
| 42 | + Debug.WriteLine("Event KeyDown:" + e.KeyCode + ", " + e.KeyValue); | |
| 43 | + } | |
| 44 | + | |
| 45 | + private void KeyControlForm_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e) { | |
| 46 | + Debug.WriteLine("Event PreviewKeyDown:" + e.KeyCode + ", " + e.KeyValue+", inputKey="+e.IsInputKey); | |
| 47 | + } | |
| 48 | + | |
| 49 | + } | |
| 50 | +} |
| @@ -0,0 +1,68 @@ | ||
| 1 | +namespace nft.ui.core { | |
| 2 | + partial class BuildToolForm { | |
| 3 | + /// <summary> | |
| 4 | + /// Required designer variable. | |
| 5 | + /// </summary> | |
| 6 | + private System.ComponentModel.IContainer components = null; | |
| 7 | + | |
| 8 | + /// <summary> | |
| 9 | + /// Clean up any resources being used. | |
| 10 | + /// </summary> | |
| 11 | + /// <param name="disposing">true if managed resources should be disposed; otherwise, 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 Form Designer generated code | |
| 20 | + | |
| 21 | + /// <summary> | |
| 22 | + /// Required method for Designer support - do not modify | |
| 23 | + /// the contents of this method with the code editor. | |
| 24 | + /// </summary> | |
| 25 | + private void InitializeComponent() { | |
| 26 | + this.renderView = new nft.framework.drawing.RenderViewPanel(); | |
| 27 | + this.lbStructures = new System.Windows.Forms.ListBox(); | |
| 28 | + this.SuspendLayout(); | |
| 29 | + // | |
| 30 | + // renderView | |
| 31 | + // | |
| 32 | + this.renderView.Location = new System.Drawing.Point(0, 80); | |
| 33 | + this.renderView.Name = "renderView"; | |
| 34 | + this.renderView.Size = new System.Drawing.Size(192, 195); | |
| 35 | + this.renderView.SurfaceUsage = nft.framework.drawing.SurfaceUsage.Normal; | |
| 36 | + this.renderView.TabIndex = 0; | |
| 37 | + // | |
| 38 | + // lbStructures | |
| 39 | + // | |
| 40 | + this.lbStructures.FormattingEnabled = true; | |
| 41 | + this.lbStructures.ItemHeight = 12; | |
| 42 | + this.lbStructures.Location = new System.Drawing.Point(0, 1); | |
| 43 | + this.lbStructures.Name = "lbStructures"; | |
| 44 | + this.lbStructures.Size = new System.Drawing.Size(192, 76); | |
| 45 | + this.lbStructures.TabIndex = 1; | |
| 46 | + // | |
| 47 | + // BuildToolForm | |
| 48 | + // | |
| 49 | + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); | |
| 50 | + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; | |
| 51 | + this.ClientSize = new System.Drawing.Size(192, 274); | |
| 52 | + this.Controls.Add(this.lbStructures); | |
| 53 | + this.Controls.Add(this.renderView); | |
| 54 | + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow; | |
| 55 | + this.Name = "BuildToolForm"; | |
| 56 | + this.ShowInTaskbar = false; | |
| 57 | + this.Text = "建造物設置"; | |
| 58 | + this.ResumeLayout(false); | |
| 59 | + | |
| 60 | + } | |
| 61 | + | |
| 62 | + #endregion | |
| 63 | + | |
| 64 | + private framework.drawing.RenderViewPanel renderView; | |
| 65 | + private System.Windows.Forms.ListBox lbStructures; | |
| 66 | + | |
| 67 | + } | |
| 68 | +} | |
| \ No newline at end of file |
| @@ -0,0 +1,15 @@ | ||
| 1 | +using System; | |
| 2 | +using System.Collections.Generic; | |
| 3 | +using System.ComponentModel; | |
| 4 | +using System.Data; | |
| 5 | +using System.Drawing; | |
| 6 | +using System.Text; | |
| 7 | +using System.Windows.Forms; | |
| 8 | + | |
| 9 | +namespace nft.ui.core { | |
| 10 | + public partial class BuildToolForm : Form { | |
| 11 | + public BuildToolForm() { | |
| 12 | + InitializeComponent(); | |
| 13 | + } | |
| 14 | + } | |
| 15 | +} |