Index 扉へ 首頁
人類の品種・宇宙人・系外銀河など
UI ライブラリのソースコードです (C#)
0   商湯      2026年2月5日 木 10:12
Download source files:
http://www.jkofsp.net/files/

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using Microsoft.DirectX.DirectDraw;
using Takaku.Simulation;

namespace Takaku.UI
{
   public abstract class Element : ISimulationRemovable
   {
       public int X, Y, DX, DY;
       public Cached<int> FullX, FullY;
       public Cached<int> MouseX, MouseY;
       public Cached<bool> MouseInside, MouseInsideTmp;
       public bool Visible, Enabled;
       public Cached<bool> TrueVisible, TrueEnabled;

       public Element Parent; // controls
       public List<Element> Children = new List<Element>(); // forms

       public Cached<bool> OnMouseButtonDown, OnMouseButtonUp, OnMouseButtonDownTmp;

       public Element(int x, int y, int dx, int dy)
       {
           X = x;
           Y = y;
           DX = dx;
           DY = dy;

           FullX = new Cached<int>(() => Parent == null ? X : Parent.X + X);
           FullY = new Cached<int>(() => Parent == null ? Y : Parent.Y + Y);

           MouseX = new Cached<int>(() => Core.TheCore.MouseX - (Parent == null ? 0 : Parent.X) - X);
           MouseY = new Cached<int>(() => Core.TheCore.MouseY - (Parent == null ? 0 : Parent.Y) - Y);

           MouseInside = new Cached<bool>(() =>
               {
                   if (MouseX < 0 || MouseX >= DX || MouseY < 0 || MouseY >= DY
                       || (!TrueVisible))
                       return false;
                   // truely visible:
                   if (Parent == null) // a form
                   {
                       for (int i = Core.TheCore.Root.Count - 1; i >= 0; i--)
                       {
                           Element e = Core.TheCore.Root[i];
                           if (e == this)
                               break;
                           else
                               if (e.MouseX >= 0 && e.MouseX < e.DX && e.MouseY >= 0 && e.MouseY < e.DY
                                   && e.TrueVisible)
                                   return false;
                       }
                       for (int i = Children.Count - 1; i >= 0; i--)
                       {
                           Element e = Children[i];
                           if (e.MouseX >= 0 && e.MouseX < e.DX && e.MouseY >= 0 && e.MouseY < e.DY
                               && e.TrueVisible)
                               return false;
                       }
                       return MouseX >= 0 && MouseX < DX && MouseY >= 0 && MouseY < DY;
                   }
                   else // a control
                   {
                       for (int i = Core.TheCore.Root.Count - 1; i >= 0; i--)
                       {
                           Element e = Core.TheCore.Root[i];
                           if (e == Parent)
                               break;
                           else
                               if (e.MouseX >= 0 && e.MouseX < e.DX && e.MouseY >= 0 && e.MouseY < e.DY
                                   && e.TrueVisible)
                                   return false;
                       }
                       return MouseX >= 0 && MouseX < DX && MouseY >= 0 && MouseY < DY;                        
                   }
               });

           MouseInsideTmp = new Cached<bool>(() =>
               {
                   if (MouseX < 0 || MouseX >= DX || MouseY < 0 || MouseY >= DY
                          || (!TrueVisible))
                       return false;
                   // truely visible:
                   if (Parent == null) // a form
                   {
                       for (int i = Core.TheCore.Root.Count - 1; i >= 0; i--)
                       {
                           Element e = Core.TheCore.Root[i];
                           if (e == this)
                               return MouseX >= 0 && MouseX < DX && MouseY >= 0 && MouseY < DY;
                           else
                               if (e.MouseX >= 0 && e.MouseX < e.DX && e.MouseY >= 0 && e.MouseY < e.DY
                                   && e.TrueVisible)
                                   return false;
                       }
                       return false;
                   }
                   else // a control
                       return MouseInside;
               });

           Visible = true;
           Enabled = true;

           TrueVisible = new Cached<bool>(() => (Parent == null ? true : Parent.Visible) && Visible);
           TrueEnabled = new Cached<bool>(() => (Parent == null ? true : Parent.Enabled) && Enabled);
           
           OnMouseButtonDown = new Cached<bool>(() => (TrueEnabled && MouseInside) ? Core.TheCore.MouseButtonDown : false);
           OnMouseButtonUp = new Cached<bool>(() => (TrueEnabled && MouseInside) ? Core.TheCore.MouseButtonUp : false);
           OnMouseButtonDownTmp = new Cached<bool>(() => (TrueEnabled && MouseInsideTmp) ? Core.TheCore.MouseButtonDown : false);
       }

       public virtual void RemoveSimulation()
       {
           FullX.Remove();
           FullY.Remove();
           MouseX.Remove();
           MouseY.Remove();
           MouseInside.Remove();
           MouseInsideTmp.Remove();
           TrueVisible.Remove();
           TrueEnabled.Remove();
           OnMouseButtonDown.Remove();
           OnMouseButtonUp.Remove();
           OnMouseButtonDownTmp.Remove();
       }

       public abstract Element Update(); // returns a form to be bringed to the top
       public abstract void Render(Surface backSurface);
   }

   public class Core
   {
       public static Core TheCore;

       public bool AllowDragging;

       public int DX, DY;

       public int MouseDX, MouseDY, MouseDZ, MouseX, MouseY;
       public bool MouseLeftButton, MouseRightButton, MouseMiddleButton;
       public bool MouseButtonDown, MouseButtonUp;

       public Cached<bool> MouseOutside;

       public List<Element> Root = new List<Element>();

       public Core(int dx, int dy, bool allowDragging)
       {
           AllowDragging = allowDragging;

           DX = dx;
           DY = dy;

           MouseOutside = new Cached<bool>(() =>
               {
                   foreach (Element e in Root)
                       if (e.MouseInsideTmp || ((Form)e).IsDragging)
                           return false;

                   return true;
               });
       }

       public void Update()
       {
           List<Element> tmps = new List<Element>();
           foreach (Element e in Root)
           {
               Element tmp = e.Update();
               if (tmp != null)
                   tmps.Add(tmp);

               foreach (Element f in e.Children)
                   f.Update();
           }
           foreach (Element tmp in tmps)
           {
               Root.Remove(tmp);
               Root.Add(tmp);
           }
       }

       public void Render(Surface backSurface)
       {
           foreach (Element e in Root)
           {
               if (e.TrueVisible)
                   e.Render(backSurface);

               foreach (Element f in e.Children)
                   if (f.TrueVisible)
                       f.Render(backSurface);
           }
       }
   }

   public class Form : Element
   {
       public Color BorderColor, FillColor;

       public State<bool> IsDragging;

       public Form(int x, int y, int dx, int dy)
           : base(x, y, dx, dy)
       {
           Core.TheCore.Root.Add(this);

           BorderColor = Color.FromArgb(unchecked((int)0xFF0000ff));
           FillColor = Color.FromArgb(unchecked((int)0xFF000000));

           IsDragging = new State<bool>(false,
               state =>
               {
                   if (!Core.TheCore.AllowDragging)
                       return false;

                   if (OnMouseButtonDown && Core.TheCore.MouseLeftButton)
                       return true;
                   if (OnMouseButtonUp)
                       return false;
                   return state;
               });
       }

       public override void RemoveSimulation()
       {
           IsDragging.Remove();

           base.RemoveSimulation();
       }

       public override Element Update() // returns a form to be bringed to the top
       {
           if (OnMouseButtonDownTmp)
               return this;

           if (IsDragging)
           {
               X += Core.TheCore.MouseDX;
               Y += Core.TheCore.MouseDY;
           }
           
           if (X < 0)
               X = 0;
           if (Y < 0)
               Y = 0;
           if (X + DX >= Core.TheCore.DX)
               X = Core.TheCore.DX - DX;
           if (Y + DY >= Core.TheCore.DY)
               Y = Core.TheCore.DY - DY;
           if (DX > Core.TheCore.DX)
               DX = Core.TheCore.DX;
           if (DY > Core.TheCore.DY)
               DY = Core.TheCore.DY;
           
           return null;
       }

       public override void Render(Surface backSurface)
       {
           backSurface.ForeColor = BorderColor;
           backSurface.FillColor = FillColor;
           backSurface.DrawRoundedBox(X, Y, X + DX, Y + DY, 5, 5);
       }
   }

   public enum ButtonState
   {
       Normal,
       Hovered,
       Pressed,

       PressedToHovered,
   }

   public class Button : Element
   {
       public string Text;
       public Font Font;
       public int TextX, TextY, TextDX, TextDY;
       bool PictureMode;
       public Color BorderColor, FillColor, TextColor;
       public Color HoveredBorderColor, HoveredFillColor, HoveredTextColor;
       public Color PressedBorderColor, PressedFillColor, PressedTextColor;
       public Surface Picture, HoveredPicture, PressedPicture;
       public State<ButtonState> State;

       private Diff<ButtonState> dState;
       public Cached<bool> OnMouseClick;

       public Button(Form form, int x, int y, int dx, int dy)
           : base(x, y, dx, dy)
       {
           form.Children.Add(this);
           Parent = form;
           
           Text = "Button";
           Font = new Font("Arial", 9.0f);
           TextX = 5;
           TextY = 5;
           TextDX = dx - 10;
           TextDY = dy - 10;

           BorderColor = Color.FromArgb(unchecked((int)0xFF0000ff));
           FillColor = Color.FromArgb(unchecked((int)0xFF000000));
           TextColor = Color.FromArgb(unchecked((int)0xFFffff00));

           HoveredBorderColor = Color.FromArgb(unchecked((int)0xFFff0000));
           HoveredFillColor = Color.FromArgb(unchecked((int)0xFFffff00));
           HoveredTextColor = Color.FromArgb(unchecked((int)0xFFff0000));

           PressedBorderColor = Color.FromArgb(unchecked((int)0xFF00ff00));
           PressedFillColor = Color.FromArgb(unchecked((int)0xFFff0000));
           PressedTextColor = Color.FromArgb(unchecked((int)0xFF0000ff));

           State = new State<ButtonState>(ButtonState.Normal,
               state =>
               {
                   if (!TrueEnabled)
                       return ButtonState.Normal;
                   if (state == ButtonState.Normal)
                   {
                       if (MouseInside)
                       {
                           if (Core.TheCore.MouseLeftButton)
                               return ButtonState.Pressed;
                           else
                               return ButtonState.Hovered;
                       }
                       else
                           return ButtonState.Normal;
                   }
                   else if (state == ButtonState.Hovered)
                   {
                       if (MouseInside)
                       {
                           if (Core.TheCore.MouseLeftButton)
                               return ButtonState.Pressed;
                           else
                               return ButtonState.Hovered;
                       }
                       else
                           return ButtonState.Normal;
                   }
                   else if (state == ButtonState.Pressed)
                   {
                       if (Core.TheCore.MouseLeftButton)
                           return ButtonState.Pressed;
                       else
                       {
                           if (MouseInside)
                               return ButtonState.Hovered;
                           else
                               return ButtonState.Normal;
                       }
                   }
                   else
                       return ButtonState.Normal;
               });

           Diff<ButtonState>.FuncSub = new Func<ButtonState, ButtonState, ButtonState>((a, b) => (a == ButtonState.Hovered && b == ButtonState.Pressed) ? ButtonState.PressedToHovered : a);
           dState = new Diff<ButtonState>(ButtonState.Normal, () => State);
           OnMouseClick = new Cached<bool>(() => dState == ButtonState.PressedToHovered ? true : false);
       }

       public override void RemoveSimulation()
       {
           State.Remove();
           dState.Remove();
           OnMouseClick.Remove();

           base.RemoveSimulation();
       }

       public override Element Update() // returns a form to be bringed to the top
       {
           return null;
       }

       public override void Render(Surface backSurface)        
       {
           if (!PictureMode)
           {
               if (State == ButtonState.Normal)
               {
                   backSurface.ForeColor = BorderColor;
                   backSurface.FillColor = FillColor;
               }
               else if (State == ButtonState.Hovered)
               {
                   backSurface.ForeColor = HoveredBorderColor;
                   backSurface.FillColor = HoveredFillColor;
               }
               else if (State == ButtonState.Pressed)
               {
                   backSurface.ForeColor = PressedBorderColor;
                   backSurface.FillColor = PressedFillColor;
               }
               backSurface.DrawRoundedBox(FullX, FullY, FullX + DX, FullY + DY, 5, 5);

               Color textColor = new Color();
               if (State == ButtonState.Normal)
                   textColor = TextColor;
               else if (State == ButtonState.Hovered)
                   textColor = HoveredTextColor;
               else if (State == ButtonState.Pressed)
                   textColor = PressedTextColor;
               
               IntPtr hdc = backSurface.GetDc();
               Graphics g = Graphics.FromHdc(hdc);
               g.DrawString(
                   Text,
                   Font,
                   new SolidBrush(textColor),
                   new RectangleF((float)FullX + TextX, (float)FullY + TextY, (float)TextDX, (float)TextDY));
               backSurface.ReleaseDc(hdc);
           }
           else // PictureMode
           {
               Surface surf = null;
               if (State == ButtonState.Normal)
               {
                   surf = Picture;
               }
               else if (State == ButtonState.Hovered)
               {
                   surf = HoveredPicture;
               }
               else if (State == ButtonState.Pressed)
               {
                   surf = PressedPicture;
               }
               backSurface.Draw(
                   new Rectangle(FullX, FullY, DX, DY),
                   surf,
                   DrawFlags.KeySource | DrawFlags.Wait);
           }
       }
   }

   public class TextBox : Element
   {
       public Bind<string> Text;
       public Font Font;
       public Color BorderColor, FillColor, TextColor;
       public bool Transparent;

       public TextBox(Form form, int x, int y, int dx, int dy)
           : base(x, y, dx, dy)
       {
           form.Children.Add(this);
           Parent = form;

           Font = new Font("Arial", 9.0f);
           BorderColor = Color.FromArgb(unchecked((int)0xFF0000ff));
           FillColor = Color.FromArgb(unchecked((int)0xFF000000));
           TextColor = Color.FromArgb(unchecked((int)0xFFffff00));
           Transparent = false;
       }

       public override Element Update() // returns a form to be bringed to the top
       {
           return null;
       }

       public override void Render(Surface backSurface)
       {
           if (!Transparent)
           {
               backSurface.ForeColor = BorderColor;
               backSurface.FillColor = FillColor;
               backSurface.DrawRoundedBox(FullX, FullY, FullX + DX, FullY + DY, 5, 5);
           }

           IntPtr hdc = backSurface.GetDc();
           Graphics g = Graphics.FromHdc(hdc);
           g.DrawString(
               Text(),
               Font,
               new SolidBrush(TextColor),
               new RectangleF((float)FullX + 5, (float)FullY + 5, (float)DX - 10, (float)DY - 10));
           backSurface.ReleaseDc(hdc);
       }
   }

   public class PictureBox : Element
   {
       public Surface Surface;

       public PictureBox(Form form, int x, int y, int dx, int dy)
           : base(x, y, dx, dy)
       {
           form.Children.Add(this);
           Parent = form;

           Surface = null;
       }

       public override Element Update() // returns a form to be bringed to the top
       {
           return null;
       }

       public override void Render(Surface backSurface)
       {
           backSurface.Draw(
               new Rectangle(FullX, FullY, DX, DY),
               Surface,
               DrawFlags.KeySource | DrawFlags.Wait);
       }
   }

   public class ListBox : Element
   {
       public Font Font;
       public Color BorderColor, FillColor, TextColor;
       public Color SelectedBorderColor, SelectedFillColor, SelectedTextColor;
       public bool Transparent;
       public List<List<string>> Items = new List<List<string>>();
       public int? SelectedIndex;
       public int LineDY;
       public List<int> ColumnsX = new List<int>();

       public ListBox(Form form, int x, int y, int dx, int dy)
           : base(x, y, dx, dy)
       {
           form.Children.Add(this);
           Parent = form;

           Font = new Font("Arial", 9.0f);
           BorderColor = Color.FromArgb(unchecked((int)0xFF0000ff));
           FillColor = Color.FromArgb(unchecked((int)0xFF000000));
           TextColor = Color.FromArgb(unchecked((int)0xFFffff00));
           SelectedBorderColor = Color.FromArgb(unchecked((int)0xFFff0000));
           SelectedFillColor = Color.FromArgb(unchecked((int)0xFFffff00));
           SelectedTextColor = Color.FromArgb(unchecked((int)0xFF000000));
           Transparent = false;
           SelectedIndex = null;
           LineDY = 15;
       }

       public override Element Update() // returns a form to be bringed to the top
       {
           if (Core.TheCore.MouseLeftButton && OnMouseButtonDown)
           {
               SelectedIndex = MouseY / LineDY;
           }

           if (SelectedIndex >= Items.Count)
               SelectedIndex = null;

           return null;
       }

       public override void Render(Surface backSurface)
       {
           if (!Transparent)
           {
               backSurface.ForeColor = BorderColor;
               backSurface.FillColor = FillColor;
               backSurface.DrawBox(FullX, FullY, FullX + DX, FullY + DY);
           }

           for (int i = 0; i < Items.Count; i++) // line
           {
               if (SelectedIndex != null && SelectedIndex == i)
               {
                   backSurface.ForeColor = SelectedBorderColor;
                   backSurface.FillColor = SelectedFillColor;
                   backSurface.DrawBox(
                       FullX,
                       FullY + SelectedIndex.Value * LineDY,
                       FullX + DX,
                       FullY + SelectedIndex.Value * LineDY + LineDY);
               }
               for (int j = 0; j < Items[i].Count; j++) // column
               {
                   IntPtr hdc = backSurface.GetDc();
                   Graphics g = Graphics.FromHdc(hdc);
                   g.DrawString(
                       Items[i][j],
                       Font,
                       new SolidBrush((SelectedIndex == null || SelectedIndex != i) ? TextColor : SelectedTextColor),
                       new RectangleF(
                           (float)(FullX + ColumnsX[j]),
                           (float)(FullY + LineDY * i),
                           (float)(((j < ColumnsX.Count - 1) ? ColumnsX[j + 1] : DX) - ColumnsX[j]),
                           (float)LineDY));
                   backSurface.ReleaseDc(hdc);
               }
           }
       }
   }

   public class ProgressBar : Element
   {
       public Bind<double> Progress;
       public Color BorderColor, BackColor, ForeColor;

       public ProgressBar(Form form, int x, int y, int dx, int dy)
           : base(x, y, dx, dy)
       {
           form.Children.Add(this);
           Parent = form;

           BorderColor = Color.FromArgb(unchecked((int)0xFF0000ff));
           BackColor = Color.FromArgb(unchecked((int)0xFFffffff));
           ForeColor = Color.FromArgb(unchecked((int)0xFF00ff00));
       }

       public override void Render(Surface backSurface)
       {
           backSurface.ForeColor = BorderColor;
           backSurface.FillColor = BackColor;
           backSurface.DrawBox(FullX, FullY, FullX + DX, FullY + DY);

           backSurface.ForeColor = ForeColor;
           backSurface.FillColor = ForeColor;
           backSurface.DrawBox(FullX + 1, FullY + 1, FullX + (int)(Progress() * DX) - 1, FullY + DY - 1);
       }

       public override Element Update() // returns a form to be bringed to the top
       {
           return null;
       }
   }
}
1   商湯      2026年2月5日 木 10:14
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using Microsoft.DirectX;
using Microsoft.DirectX.DirectDraw;
using Microsoft.DirectX.DirectInput;
using Takaku.Simulation;
using Takaku.UI;

namespace UITest
{
   public partial class Form1 : System.Windows.Forms.Form
   {
       int GWL_STYLE = -16;
       [DllImport("user32.dll", CharSet = CharSet.Unicode)]
       static extern int GetWindowLong(IntPtr hwnd, int nIndex);
       [StructLayout(LayoutKind.Sequential)]
       struct RECT
       {
           public int Left, Top, Right, Bottom;
       }
       [DllImport("user32.dll", CharSet = CharSet.Unicode)]
       static extern int AdjustWindowRect(ref RECT rc, int style, bool bMenu);
       [StructLayout(LayoutKind.Sequential)]
       struct POINT
       {
           public int X, Y;
       }
       [DllImport("user32.dll", CharSet = CharSet.Unicode)]
       static extern int GetCursorPos(out POINT pt);
       [DllImport("user32.dll", CharSet = CharSet.Unicode)]
       static extern int SetCursorPos(int x, int y);

       Microsoft.DirectX.DirectDraw.Device DDrawDevice;
       Surface FrontSurface, BackSurface;

       Microsoft.DirectX.DirectInput.Device DInputDevice;
       int MouseDX, MouseDY, MouseDZ, MouseScreenX, MouseScreenY, MouseX, MouseY;
       bool MouseLeftButton, MouseRightButton, MouseMiddleButton;
       bool OldMouseLeftButton, OldMouseRightButton, OldMouseMiddleButton;
       bool MouseButtonDown, MouseButtonUp;

       public Form1()
       {
           InitializeComponent();
       }

       private void Form1_Load(object sender, EventArgs e)
       {
           RECT rc;
           rc.Left = 0;
           rc.Top = 0;
           rc.Right = 640;
           rc.Bottom = 480;
           AdjustWindowRect(ref rc, GetWindowLong(Handle, GWL_STYLE), false);
           Width = rc.Right - rc.Left;
           Height = rc.Bottom - rc.Top;
           Left = Screen.PrimaryScreen.Bounds.Width / 2 - Width / 2;
           Top = Screen.PrimaryScreen.Bounds.Height / 2 - Height / 2;

           DDrawDevice = new Microsoft.DirectX.DirectDraw.Device();
           DDrawDevice.SetCooperativeLevel(this, Microsoft.DirectX.DirectDraw.CooperativeLevelFlags.Normal);

           SurfaceDescription desc;

           desc = new SurfaceDescription();
           desc.SurfaceCaps.PrimarySurface = true;
           FrontSurface = new Surface(desc, DDrawDevice);
           FrontSurface.Clipper = new Clipper(DDrawDevice);
           FrontSurface.Clipper.Window = this;

           desc = new SurfaceDescription();
           desc.SurfaceCaps.VideoMemory = true;
           desc.Width = 640;
           desc.Height = 480;
           BackSurface = new Surface(desc, DDrawDevice);
           BackSurface.Clipper = new Clipper(DDrawDevice);
           BackSurface.Clipper.ClipList = new Rectangle[] { new Rectangle(0, 0, 640, 480) };

           POINT pt;
           GetCursorPos(out pt);
           MouseScreenX = pt.X;
           MouseScreenY = pt.Y;
           Point point;
           point = PointToClient(new Point(MouseScreenX, MouseScreenY));
           MouseX = point.X;
           MouseY = point.Y;

           DInputDevice = new Microsoft.DirectX.DirectInput.Device(SystemGuid.Mouse);
           DInputDevice.SetCooperativeLevel(Handle, Microsoft.DirectX.DirectInput.CooperativeLevelFlags.Background
               | Microsoft.DirectX.DirectInput.CooperativeLevelFlags.NonExclusive);
           DInputDevice.SetDataFormat(DeviceDataFormat.Mouse);
           DInputDevice.Acquire();

           Core.TheCore = new Core(640, 480, false);

           MouseState mouseState;

           Show();
           Activate();

           Takaku.UI.Form formA = new Takaku.UI.Form(0, 0, 100, 200);

           Takaku.UI.Button buttonA = new Takaku.UI.Button(formA, 10, 10, 50, 30);

           Takaku.UI.Form formB = new Takaku.UI.Form(50, 50, 100, 200);

           Takaku.UI.TextBox textBoxA = new Takaku.UI.TextBox(formB, 10, 10, 80, 50);
           textBoxA.Text = () => "Text";

           desc = new SurfaceDescription();
           desc.SurfaceCaps.OffScreenPlain = true;
           desc.SurfaceCaps.VideoMemory = true;
           Takaku.UI.PictureBox pictureBoxA = new Takaku.UI.PictureBox(formB, 10, 90, 80, 80);
           pictureBoxA.Surface = new Surface(new Bitmap(Image.FromFile("tmp.png")), desc, DDrawDevice);
           ColorKey ckey = new ColorKey();
           ckey.ColorSpaceHighValue = ckey.ColorSpaceLowValue = 0;
           pictureBoxA.Surface.SetColorKey(ColorKeyFlags.SourceDraw, ckey);
           
           Takaku.UI.ListBox listBoxA = new Takaku.UI.ListBox(formA, 10, 60, 80, 80);
           listBoxA.ColumnsX.Add(0);
           listBoxA.ColumnsX.Add(50);
           listBoxA.Items.Add(new List<string>());
           listBoxA.Items[0].Add("(0,0)");
           listBoxA.Items[0].Add("(0,1)");
           listBoxA.Items.Add(new List<string>());
           listBoxA.Items[1].Add("(1,0)");
           listBoxA.Items[1].Add("(1,1)");
           listBoxA.Items.Add(new List<string>());
           listBoxA.Items[2].Add("(2,0)");
           listBoxA.Items[2].Add("(2,1)");

           Takaku.UI.ProgressBar progressBarA = new Takaku.UI.ProgressBar(formB, 10, 65, 80, 15);
           progressBarA.Progress = () => 0.5;
2   商湯      2026年2月5日 木 10:14
           while (Visible)
           {
               Application.DoEvents();

               Takaku.Simulation.ManagerState.TheManagerState.Update();
               Takaku.Simulation.ManagerDiff.TheManagerDiff.Update();

               mouseState = DInputDevice.CurrentMouseState;
               byte[] mouseButtons = mouseState.GetMouseButtons();
               MouseLeftButton = mouseButtons[0] != 0;
               MouseRightButton = mouseButtons[1] != 0;
               MouseMiddleButton = mouseButtons[2] != 0;
               if ((MouseLeftButton && (!OldMouseLeftButton))
                   || (MouseRightButton && (!OldMouseRightButton))
                   || (MouseMiddleButton && (!OldMouseMiddleButton)))
                   MouseButtonDown = true;
               if (((!MouseLeftButton) && OldMouseLeftButton)
                   || ((!MouseRightButton) && OldMouseRightButton)
                   || ((!MouseMiddleButton) && OldMouseMiddleButton))
                   MouseButtonUp = true;
               if (MouseLeftButton == OldMouseLeftButton
                   && MouseRightButton == OldMouseRightButton
                   && MouseMiddleButton == OldMouseMiddleButton)
                   MouseButtonUp = MouseButtonDown = false;
               OldMouseLeftButton = MouseLeftButton;
               OldMouseRightButton = MouseRightButton;
               OldMouseMiddleButton = MouseMiddleButton;
               MouseDX = mouseState.X;
               MouseDY = mouseState.Y;
               MouseDZ = mouseState.Z;
               MouseScreenX += mouseState.X;
               MouseScreenY += mouseState.Y;
               if (MouseScreenX < 0)
                   MouseScreenX = 0;
               if (MouseScreenX >= Screen.PrimaryScreen.Bounds.Width)
                   MouseScreenX = Screen.PrimaryScreen.Bounds.Width - 1;
               if (MouseScreenY < 0)
                   MouseScreenY = 0;
               if (MouseScreenY >= Screen.PrimaryScreen.Bounds.Height)
                   MouseScreenY = Screen.PrimaryScreen.Bounds.Height - 1;
               SetCursorPos(MouseScreenX, MouseScreenY);
               try
               {
                   point = PointToClient(new Point(MouseScreenX, MouseScreenY));
                   MouseX = Math.Min(Math.Max(0, point.X), 639);
                   MouseY = Math.Min(Math.Max(0, point.Y), 479);
               }
               catch (Exception) { }
               if (MouseX == 0 || MouseX == 639)
                   MouseDX = 0;
               if (MouseY == 0 || MouseY == 479)
                   MouseDY = 0;

               Core.TheCore.MouseDX = MouseDX;
               Core.TheCore.MouseDY = MouseDY;
               Core.TheCore.MouseDZ = MouseDZ;
               Core.TheCore.MouseX = MouseX;
               Core.TheCore.MouseY = MouseY;
               Core.TheCore.MouseLeftButton = MouseLeftButton;
               Core.TheCore.MouseRightButton = MouseRightButton;
               Core.TheCore.MouseMiddleButton = MouseMiddleButton;
               Core.TheCore.MouseButtonDown = MouseButtonDown;
               Core.TheCore.MouseButtonUp = MouseButtonUp;

               Core.TheCore.Update();

               if (buttonA.OnMouseClick)
               {
                   //Core.TheCore.Root.Remove(formA);
                   formA.Visible = false;
                   Text += "x";
               }
               if (Core.TheCore.MouseOutside)
               {
                   Text = Core.TheCore.MouseX.ToString() + ", " + Core.TheCore.MouseY.ToString();
               }
               else
               {
                   Text = "-";
               }

               BackSurface.ColorFill(0);
               Core.TheCore.Render(BackSurface);
               try
               {
                   FrontSurface.Draw(RectangleToScreen(ClientRectangle), BackSurface, DrawFlags.Wait);
               }
               catch (Exception) { }

               Takaku.Simulation.ManagerCached.TheManagerCached.Flush();
Takaku.Simulation.ManagerState.TheManagerState.Flush();
           }

           formA.RemoveSimulation();
           buttonA.RemoveSimulation();
           formB.RemoveSimulation();
           textBoxA.RemoveSimulation();
           pictureBoxA.RemoveSimulation();
           listBoxA.RemoveSimulation();

           Application.Exit();
       
       }
   }
}
名前      編集用パスワード(省略可)    パスワードの記憶
数式 αβγ IPA http:// 画像 B I U 上 下
(添付ファイルは http://www.jkofsp.net/up/ にアップロードしてください)