Exemplo n.º 1
0
        /// <summary>
        ///     フォームの初期化
        /// </summary>
        private void InitForm()
        {
            // 技術リストビュー
            techNameColumnHeader.Width       = HoI2EditorController.Settings.ResearchViewer.TechListColumnWidth[0];
            techIdColumnHeader.Width         = HoI2EditorController.Settings.ResearchViewer.TechListColumnWidth[1];
            techYearColumnHeader.Width       = HoI2EditorController.Settings.ResearchViewer.TechListColumnWidth[2];
            techComponentsColumnHeader.Width = HoI2EditorController.Settings.ResearchViewer.TechListColumnWidth[3];

            // 国家リストボックス
            countryListBox.ColumnWidth = DeviceCaps.GetScaledWidth(countryListBox.ColumnWidth);
            countryListBox.ItemHeight  = DeviceCaps.GetScaledHeight(countryListBox.ItemHeight);

            // 研究機関リストビュー
            teamRankColumnHeader.Width       = HoI2EditorController.Settings.ResearchViewer.TeamListColumnWidth[1];
            teamDaysColumnHeader.Width       = HoI2EditorController.Settings.ResearchViewer.TeamListColumnWidth[2];
            teamEndDateColumnHeader.Width    = HoI2EditorController.Settings.ResearchViewer.TeamListColumnWidth[3];
            teamNameColumnHeader.Width       = HoI2EditorController.Settings.ResearchViewer.TeamListColumnWidth[4];
            teamIdColumnHeader.Width         = HoI2EditorController.Settings.ResearchViewer.TeamListColumnWidth[5];
            teamSkillColumnHeader.Width      = HoI2EditorController.Settings.ResearchViewer.TeamListColumnWidth[6];
            teamSpecialityColumnHeader.Width = HoI2EditorController.Settings.ResearchViewer.TeamListColumnWidth[7];

            // ウィンドウの位置
            Location = HoI2EditorController.Settings.ResearchViewer.Location;
            Size     = HoI2EditorController.Settings.ResearchViewer.Size;
        }
Exemplo n.º 2
0
			/// <summary>
			/// MIDI 出力デバイスのコントローラを生成する。
			/// </summary>
			/// <param name="deviceId">対象となる MIDI 出力デバイスの ID。</param>
			public Controller(uint deviceId)
			{
				Win32.MMRESULT ret;

				caps_ = new DeviceCaps(deviceId);

				// MIDIHDR オブジェクトのサイズ
				cb_hdr_ = (uint)Marshal.SizeOf(typeof(Win32.MIDIHDR));

				try
				{
					unsafe
					{
						// HMIDIOUT オブジェクトの取得
						fixed (IntPtr* lphmo = &hmo_)
						{
							ret = Win32.Api.midiOutOpen((IntPtr)lphmo, deviceId, 0, 0, 0);
							if (ret != Win32.MMRESULT.MMSYSERR_NOERROR)
								throw new Win32Exception(ret);
						}

						// 送信バッファの作成
						buffer_ = Marshal.AllocHGlobal((int)MAX_BYTES_PER_SENDING);

						// MIDIHDR データの生成
						hdr_ = Marshal.AllocHGlobal((int)cb_hdr_);
						((Win32.MIDIHDR*)hdr_)->lpData = buffer_;
					}
				}
				catch
				{
					Dispose();
					throw;
				}
			}
Exemplo n.º 3
0
        /// <summary>
        ///     研究機関リストビューの研究特性アイコン描画処理
        /// </summary>
        /// <param name="e"></param>
        /// <param name="research">研究速度データ</param>
        private void DrawTeamSpecialityIcon(DrawListViewSubItemEventArgs e, Research research)
        {
            if (research == null)
            {
                return;
            }

            Rectangle rect = new Rectangle(e.Bounds.X + 4, e.Bounds.Y + 1, DeviceCaps.GetScaledWidth(16),
                                           DeviceCaps.GetScaledHeight(16));

            for (int i = 0; i < Team.SpecialityLength; i++)
            {
                // 研究特性なしならば何もしない
                if (research.Team.Specialities[i] == TechSpeciality.None)
                {
                    continue;
                }

                // 研究特性アイコンを描画する
                if ((int)research.Team.Specialities[i] - 1 < Techs.SpecialityImages.Images.Count)
                {
                    e.Graphics.DrawImage(
                        Techs.SpecialityImages.Images[
                            Array.IndexOf(Techs.Specialities, research.Team.Specialities[i]) - 1], rect);
                }

                // 研究特性オーバーレイアイコンを描画する
                if (research.Tech.Components.Any(component => component.Speciality == research.Team.Specialities[i]))
                {
                    e.Graphics.DrawImage(_techOverlayIcon, rect);
                }

                rect.X += DeviceCaps.GetScaledWidth(16) + 3;
            }
        }
Exemplo n.º 4
0
        public Boolean InitializeGraphics()
        {
            try {
                PresentParameters presentParameters = new PresentParameters();
                presentParameters.Windowed               = true;
                presentParameters.SwapEffect             = SwapEffect.Discard;
                presentParameters.BackBufferFormat       = Format.Unknown;
                presentParameters.AutoDepthStencilFormat = DepthFormat.D16;
                presentParameters.EnableAutoDepthStencil = true;

                DeviceCaps  deviceCaps  = Manager.GetDeviceCaps(Manager.Adapters.Default.Adapter, DeviceType.Hardware).DeviceCaps;
                CreateFlags createFlags = ((deviceCaps.SupportsHardwareTransformAndLight) ? CreateFlags.HardwareVertexProcessing : CreateFlags.SoftwareVertexProcessing);
                if (deviceCaps.SupportsPureDevice)
                {
                    createFlags |= CreateFlags.PureDevice;
                }

                if (this.m_Device != null)
                {
                    this.m_Device.Dispose();
                }

                this.m_Device              = new Device(0, DeviceType.Hardware, this.m_FormRenderSurface, createFlags, presentParameters);
                this.m_Device.DeviceReset += new EventHandler(this.OnResetDevice);
                this.OnResetDevice(this.m_Device, null);
                this.m_Paused = false;
                return(true);
            } catch (DirectXException) {
                return(false);
            }
        }
Exemplo n.º 5
0
        /// <summary>
        ///     技術ツリーに発明イベントを追加する
        /// </summary>
        /// <param name="item">追加対象の項目</param>
        /// <param name="position">追加対象の位置</param>
        private void AddEventItem(TechEvent item, TechPosition position)
        {
            Label label = new Label
            {
                Location  = new Point(DeviceCaps.GetScaledWidth(position.X), DeviceCaps.GetScaledHeight(position.Y)),
                BackColor = Color.Transparent,
                Tag       = new TechLabelInfo {
                    Item = item, Position = position
                },
                Size   = new Size(_eventLabelBitmap.Width, _eventLabelBitmap.Height),
                Region = _eventLabelRegion
            };

            // ラベル画像を設定する
            if (ApplyItemStatus && (QueryItemStatus != null))
            {
                QueryItemStatusEventArgs e = new QueryItemStatusEventArgs(item);
                QueryItemStatus(this, e);
                label.Image = e.Done ? _doneEventLabelBitmap : _eventLabelBitmap;
            }
            else
            {
                label.Image = _doneEventLabelBitmap;
            }

            label.Click        += OnItemLabelClick;
            label.MouseClick   += OnItemLabelMouseClick;
            label.MouseDown    += OnItemLabelMouseDown;
            label.MouseUp      += OnItemLabelMouseUp;
            label.MouseMove    += OnItemLabelMouseMove;
            label.GiveFeedback += OnItemLabelGiveFeedback;

            _pictureBox.Controls.Add(label);
        }
Exemplo n.º 6
0
        //* -----------------------------------------------------------------------*
        /// <summary>デバイスの性能レポートを作成します。</summary>
        ///
        /// <param name="caps">デバイスの性能 列挙オブジェクト</param>
        /// <returns>デバイスの性能レポート 文字列</returns>
        public static string createCapsReport(this DeviceCaps caps)
        {
            string strResult = "▽ レガシ ゲームパッド デバイスの能力一覧" + Environment.NewLine;

            strResult += "  ドライバ バージョン       : " + caps.FFDriverVersion + Environment.NewLine;
            strResult += "  ファームウェア バージョン : " + caps.FirmwareRevision + Environment.NewLine;
            strResult += "  ハードウェア バージョン   : " + caps.HardwareRevision + Environment.NewLine;
            strResult += "  デバイスの最小分解能      : " + caps.FFMinTimeResolution + " ミリ秒" + Environment.NewLine;
            strResult += "  フォース命令送信最小間隔  : " + caps.FFSamplePeriod + " ミリ秒" + Environment.NewLine;
            strResult += "  使用可能な軸の数          : " + caps.NumberAxes + Environment.NewLine;
            strResult += "  使用可能なボタンの数      : " + caps.NumberButtons + Environment.NewLine;
            strResult += "  使用可能なPOVの数         : " + caps.NumberPointOfViews + Environment.NewLine;
            strResult += "  別デバイスのエイリアス    : " + caps.Alias.ToStringOX() + Environment.NewLine;
            strResult += "  物理的にアタッチされた    : " + caps.Attatched.ToStringOX() + Environment.NewLine;
            strResult += "  Emulateされた仮想デバイス : " + caps.Hidden.ToStringOX() + Environment.NewLine;
            strResult += "  ユーザー モード デバイス  : " + caps.Emulated.ToStringOX() + Environment.NewLine;
            strResult += "  デッドバンド              : " + caps.DeadBand.ToStringOX() + Environment.NewLine;
            strResult += "  フォース フィードバック   : " + caps.ForceFeedback.ToStringOX() + Environment.NewLine;
            strResult += "  フェード エフェクト       : " + caps.Fade.ToStringOX() + Environment.NewLine;
            strResult += "  遅延フォース エフェクト   : " + caps.StartDelay.ToStringOX() + Environment.NewLine;
            strResult += "  条件エフェクトの飽和      : " + caps.Saturation.ToStringOX() + Environment.NewLine;
            strResult += "  PosNegCoefficients        : " + caps.PosNegCoefficients.ToStringOX() + Environment.NewLine;
            strResult += "  PosNegSaturation          : " + caps.PosNegSaturation.ToStringOX() + Environment.NewLine;
            strResult += "  プレース ホルダ           : " + caps.Phantom.ToStringOX() + Environment.NewLine;
            strResult += "  Attack                    : " + caps.Attack.ToStringOX() + Environment.NewLine;
            strResult += "  PolledDataFormat          : " + caps.PolledDataFormat.ToStringOX() + Environment.NewLine;
            strResult += "  PolledDevice              : " + caps.PolledDevice.ToStringOX() + Environment.NewLine;
            return(strResult);
        }
Exemplo n.º 7
0
        /// <summary>
        ///     フォーム読み込み時の処理
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnFormLoad(object sender, EventArgs e)
        {
            Graphics g      = Graphics.FromHwnd(Handle);
            int      margin = DeviceCaps.GetScaledWidth(2) + 1;

            // 選択国コンボボックス
            srcComboBox.BeginUpdate();
            srcComboBox.Items.Clear();
            int width = srcComboBox.Width;

            foreach (string s in Countries.Tags
                     .Select(country => Countries.Strings[(int)country])
                     .Select(name => Config.ExistsKey(name)
                    ? $"{name} {Config.GetText(name)}"
                    : name))
            {
                srcComboBox.Items.Add(s);
                width = Math.Max(width,
                                 (int)g.MeasureString(s, srcComboBox.Font).Width + SystemInformation.VerticalScrollBarWidth +
                                 margin);
            }
            srcComboBox.DropDownWidth = width;
            srcComboBox.EndUpdate();
            if (srcComboBox.Items.Count > 0)
            {
                srcComboBox.SelectedIndex = Countries.Tags.ToList().IndexOf(_args.TargetCountries[0]);
            }
            srcComboBox.SelectedIndexChanged += OnSrcComboBoxSelectedIndexChanged;

            // コピー/移動先コンボボックス
            destComboBox.BeginUpdate();
            destComboBox.Items.Clear();
            width = destComboBox.Width;
            foreach (string s in Countries.Tags
                     .Select(country => Countries.Strings[(int)country])
                     .Select(name => Config.ExistsKey(name)
                    ? $"{name} {Config.GetText(name)}"
                    : name))
            {
                destComboBox.Items.Add(s);
                width = Math.Max(width,
                                 (int)g.MeasureString(s, srcComboBox.Font).Width +
                                 SystemInformation.VerticalScrollBarWidth +
                                 margin);
            }
            destComboBox.DropDownWidth = width;
            destComboBox.EndUpdate();
            if (_args.TargetCountries.Count > 0)
            {
                destComboBox.SelectedIndex = Countries.Tags.ToList().IndexOf(_args.TargetCountries[0]);
            }
            destComboBox.SelectedIndexChanged += OnDestComboBoxSelectedIndexChanged;

            // 開始ID
            if (_args.TargetCountries.Count > 0)
            {
                idNumericUpDown.Value = Teams.GetNewId(_args.TargetCountries[0]);
            }
            idNumericUpDown.ValueChanged += OnIdNumericUpDownValueChanged;
        }
Exemplo n.º 8
0
        /// <summary>
        /// Acquire the named joystick. You can find this joystick through the <see cref="FindJoysticks"/> method.
        /// </summary>
        /// <param name="name">Name of the joystick.</param>
        /// <returns>The success of the connection.</returns>
        public bool AcquireJoystick(string name)
        {
            try
            {
                DeviceList gameControllerList = Manager.GetDevices(DeviceClass.GameControl, EnumDevicesFlags.AttachedOnly);
                int        i     = 0;
                bool       found = false;
                // loop through the devices.
                foreach (DeviceInstance deviceInstance in gameControllerList)
                {
                    if (deviceInstance.InstanceName == name)
                    {
                        found = true;
                        // create a device from this controller so we can retrieve info.
                        joystickDevice = new Device(deviceInstance.InstanceGuid);
                        joystickDevice.SetCooperativeLevel(hWnd,
                                                           CooperativeLevelFlags.Background |
                                                           CooperativeLevelFlags.NonExclusive);
                        break;
                    }

                    i++;
                }

                if (!found)
                {
                    return(false);
                }

                // Tell DirectX that this is a Joystick.
                joystickDevice.SetDataFormat(DeviceDataFormat.Joystick);

                // Finally, acquire the device.
                joystickDevice.Acquire();

                // How many axes?
                // Find the capabilities of the joystick
                DeviceCaps cps    = joystickDevice.Caps;
                string     strMsg = "Joystick Axis: " + cps.NumberAxes;
                MessageBox.Show(strMsg);
                strMsg = "Joystick Buttons: " + cps.NumberButtons;
                MessageBox.Show(strMsg);
                //Ojw.CMessage.Write("Joystick Axis: " + cps.NumberAxes);
                //Ojw.CMessage.Write("Joystick Buttons: " + cps.NumberButtons);

                axisCount = cps.NumberAxes;

                UpdateStatus();
            }
            catch (Exception err)
            {
                //Ojw.CMessage.Write_Error("FindJoysticks()");
                //Ojw.CMessage.Write_Error(err.Message);
                //Ojw.CMessage.Write_Error(err.StackTrace);
                return(false);
            }

            return(true);
        }
        public static void ListDevCaps(DeviceCaps devCaps, ListBox listCaps)
        {
            listCaps.Items.Add(" -----  Device Caps ------------------------");

            if(devCaps.SupportsExecuteSystemMemory) {
                listCaps.Items.Add("Device can use execute buffers from system memory.");
            }
            if(devCaps.SupportsExecuteVideoMemory) {
                listCaps.Items.Add("Device can use execute buffers from video memory. ");
            }
            if(devCaps.SupportsTransformedVertexSystemMemory) {
                listCaps.Items.Add("Device can use buffers from system memory for transformed and lit vertices. ");
            }
            if(devCaps.SupportsTransformedVertexVideoMemory) {
                listCaps.Items.Add("Device can use buffers from video memory for transformed and lit vertices. ");
            }
            if(devCaps.SupportsTextureSystemMemory) {
                listCaps.Items.Add("Device can retrieve textures from system memory. ");
            }
            if(devCaps.SupportsTextureVideoMemory) {
                listCaps.Items.Add("Device can retrieve textures from device memory.");
            }
            if(devCaps.SupportsDrawPrimitivesTransformedVertex) {
                listCaps.Items.Add("Device exports a DrawPrimitives-aware hardware abstraction layer (HAL).");
            }
            if(devCaps.CanRenderAfterFlip) {
                listCaps.Items.Add("Device can queue rendering commands after a page flip.");
            }
            if(devCaps.SupportsTextureNonLocalVideoMemory) {
                listCaps.Items.Add("Device can retrieve textures from nonlocal video memory. ");
            }
            if(devCaps.SupportsSeparateTextureMemories) {
                listCaps.Items.Add("Device is texturing from separate memory pools. ");
            }
            if(devCaps.SupportsHardwareTransformAndLight) {
                listCaps.Items.Add("Device can support transformation and lighting in hardware. ");
            }
            if(devCaps.CanDrawSystemToNonLocal) {
                listCaps.Items.Add("Device supports blits from system-memory textures to nonlocal video-memory textures. ");
            }
            if(devCaps.SupportsHardwareRasterization) {
                listCaps.Items.Add("Device has hardware acceleration for scene rasterization. ");
            }
            if(devCaps.SupportsPureDevice) {
                listCaps.Items.Add("Device can support rasterization, transform, lighting, and shading in hardware. ");
            }
            if(devCaps.SupportsQuinticRtPatches) {
                listCaps.Items.Add("Device supports quintic béziers and B-splines.");
            }
            if(devCaps.SupportsRtPatches) {
                listCaps.Items.Add("Device supports high-order surfaces. ");
            }
            if(devCaps.SupportsRtPatchHandleZero) {
                listCaps.Items.Add("High-order surfaces can be drawn efficiently using a handle value of 0. ");
            }
            if(devCaps.SupportsNPatches) {
                listCaps.Items.Add("Device supports N patches. ");
            }
        }
Exemplo n.º 10
0
        /// <summary>
        ///     フォームの初期化
        /// </summary>
        private void InitForm()
        {
            // 国家リストボックス
            countryListBox.ItemHeight = DeviceCaps.GetScaledHeight(countryListBox.ItemHeight);

            // ウィンドウの位置
            Location = HoI2EditorController.Settings.RandomLeaderEditor.Location;
            Size     = HoI2EditorController.Settings.RandomLeaderEditor.Size;
        }
Exemplo n.º 11
0
        private void Connect2Joystick()
        {
            richTextBox1.Text = "Settings:";
            try
            {
                // Find all the GameControl devices that are attached.
                DeviceList gameControllerList = Manager.GetDevices(
                    DeviceClass.GameControl,
                    EnumDevicesFlags.AttachedOnly);

                // check that we have at least one device.
                if (gameControllerList.Count > 0)
                {
                    timer1.Start(); // Read Joystick status by polling base on a timer_tick

                    // Move to the first device
                    gameControllerList.MoveNext();
                    DeviceInstance deviceInstance = (DeviceInstance)
                                                    gameControllerList.Current;

                    // create a device from this controller.
                    joystickDevice = new Device(deviceInstance.InstanceGuid);
                    joystickDevice.SetCooperativeLevel(this,
                                                       CooperativeLevelFlags.Background |
                                                       CooperativeLevelFlags.NonExclusive);


                    // Tell DirectX that this is a Joystick.
                    joystickDevice.SetDataFormat(DeviceDataFormat.Joystick);

                    // Finally, acquire the device.
                    joystickDevice.Acquire();

                    // Find the capabilities of the joystick
                    DeviceCaps cps = joystickDevice.Caps;

                    // number of Axes
                    richTextBox1.Text += ("\n Joystick Axes = " + cps.NumberAxes);

                    // number of Buttons
                    richTextBox1.Text += ("\n Joystick Buttons = " + cps.NumberButtons);

                    // number of PoV hats
                    richTextBox1.Text += ("\n Joystick PoV hats = "
                                          + cps.NumberPointOfViews);
                }
                else
                {
                    // "There is no Joystics available!"
                    MessageBox.Show("There is no Joystics available!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            catch (Exception err)
            {
                MessageBox.Show(err.Message);
            }
        }
Exemplo n.º 12
0
        /// <summary>
        ///     フォームの初期化
        /// </summary>
        private void InitForm()
        {
            // 国家リストボックス
            countryListBox.ItemHeight = DeviceCaps.GetScaledHeight(countryListBox.ItemHeight);
            // ユニット種類リストボックス
            typeListBox.ItemHeight = DeviceCaps.GetScaledHeight(typeListBox.ItemHeight);

            // ウィンドウの位置
            Location = HoI2EditorController.Settings.UnitNameEditor.Location;
            Size     = HoI2EditorController.Settings.UnitNameEditor.Size;
        }
Exemplo n.º 13
0
        /// <summary>
        ///     フォームの初期化
        /// </summary>
        private void InitForm()
        {
            // 兵科リストボックス
            branchListBox.ItemHeight = DeviceCaps.GetScaledHeight(branchListBox.ItemHeight);
            // 国家リストボックス
            countryListBox.ItemHeight = DeviceCaps.GetScaledHeight(countryListBox.ItemHeight);

            // ウィンドウの位置
            Location = HoI2EditorController.Settings.CorpsNameEditor.Location;
            Size     = HoI2EditorController.Settings.CorpsNameEditor.Size;
        }
Exemplo n.º 14
0
        static public DeviceCaps GetDeviceInfo(int id)
        {
            var devCaps = new NativeMethods.MIDIINCAPS();

            if (NativeMethods.midiInGetDevCaps((uint)id, ref devCaps, (uint)Marshal.SizeOf(typeof(NativeMethods.MIDIINCAPS))) != NativeMethods.MMSYSERR_NOERROR)
            {
                return(null);
            }
            var caps = new DeviceCaps();

            caps.deviceName = devCaps.szPname;
            return(caps);
        }
Exemplo n.º 15
0
        private void InitializeGameFramework()
        {
            parm = new DeviceParams();

            DeviceCaps _device_caps = AGT_GameFramework.GetDeviceCapabilities().DeviceCaps;

            parm.ClrFlags      = ClearFlags.Target | ClearFlags.ZBuffer;
            parm.ZDepth        = 1.0f;
            parm.Stencil       = 0;
            parm.TargetControl = this;

            parm.OnResize = new DeviceResizeHandler(OnResize);

            parm.PresentationParameters            = new PresentParameters();
            parm.PresentationParameters.Windowed   = true;
            parm.PresentationParameters.SwapEffect = SwapEffect.Discard;

            if (parm.PresentationParameters.Windowed)
            {
                parm.PresentationParameters.PresentationInterval   = PresentInterval.Default;
                parm.PresentationParameters.EnableAutoDepthStencil = true;
                parm.PresentationParameters.AutoDepthStencilFormat = DepthFormat.D16;
            }
            else
            {
                parm.PresentationParameters.PresentationInterval   = PresentInterval.Immediate;
                parm.PresentationParameters.EnableAutoDepthStencil = false;
                parm.PresentationParameters.BackBufferCount        = 1;
                parm.PresentationParameters.BackBufferHeight       = Microsoft.DirectX.Direct3D.Manager.Adapters.Default.CurrentDisplayMode.Height;
                parm.PresentationParameters.BackBufferWidth        = Microsoft.DirectX.Direct3D.Manager.Adapters.Default.CurrentDisplayMode.Width;
                parm.PresentationParameters.BackBufferFormat       = Microsoft.DirectX.Direct3D.Manager.Adapters.Default.CurrentDisplayMode.Format;
            }

            if (_device_caps.SupportsHardwareTransformAndLight)
            {
                parm.Flags = CreateFlags.HardwareVertexProcessing;
                if (_device_caps.SupportsPureDevice)
                {
                    parm.Flags |= CreateFlags.PureDevice;
                    parm.Flags |= CreateFlags.MultiThreaded;
                }
            }
            else
            {
                parm.Flags  = CreateFlags.SoftwareVertexProcessing;
                parm.Flags |= CreateFlags.MultiThreaded;
            }

            gf = new AGT_GameFramework(parm);
        }
Exemplo n.º 16
0
        /// <summary>
        ///     フォームの初期化
        /// </summary>
        private void InitForm()
        {
            // ウィンドウの位置
            Location = HoI2EditorController.Settings.MiscEditor.Location;
            //Size = HoI2Editor.Settings.MiscEditor.Size;

            // 画面解像度が十分に広い場合はタブページが広く表示できるようにする
            int longHeight = DeviceCaps.GetScaledHeight(720);

            if (Screen.GetWorkingArea(this).Height >= longHeight)
            {
                Height = longHeight;
            }
        }
Exemplo n.º 17
0
			/// <summary>
			/// MIDI 出力デバイスのコントローラを生成する。
			/// </summary>
			/// <param name="deviceName">対象となる MIDI 出力デバイスの名前。DeviceCaps.Name の値を使用できる。</param>
			/// <returns>
			/// deviceName で指定した名前のデバイスが見つかった場合は、そのデバイスを表す Controller オブジェクト。
			/// 見つからなかった場合は null。
			/// </returns>
			public static Controller FromName(string deviceName)
			{
				// 名前の一致するデバイスを探す
				uint n = DeviceCaps.NumDevices;
				for (uint i = 0; i < n; ++i)
				{
					DeviceCaps caps = new DeviceCaps(i);
					if (caps.Name == deviceName)
						// デバイスを発見したので初期化
						return new Controller(i);
				}

				// 名前の一致するデバイスがなかった
				return null;
			}
Exemplo n.º 18
0
        /// <summary>
        ///     技術ツリーの項目を更新する
        /// </summary>
        /// <param name="item">更新対象の項目</param>
        /// <param name="position">更新対象の座標</param>
        public void UpdateItem(ITechItem item, TechPosition position)
        {
            Control.ControlCollection labels = _pictureBox.Controls;
            foreach (Label label in labels)
            {
                TechLabelInfo info = label.Tag as TechLabelInfo;
                if (info == null)
                {
                    continue;
                }

                if (info.Item != item)
                {
                    continue;
                }

                // ラベルの位置を更新する
                if (info.Position == position)
                {
                    label.Location = new Point(DeviceCaps.GetScaledWidth(position.X),
                                               DeviceCaps.GetScaledHeight(position.Y));
                }

                // 項目ラベルの表示に項目の状態を反映しないならば座標変更のみ
                if (!ApplyItemStatus || (QueryItemStatus == null))
                {
                    continue;
                }

                if (item is TechItem)
                {
                    // ラベル画像を設定する
                    QueryItemStatusEventArgs e = new QueryItemStatusEventArgs(item);
                    QueryItemStatus(this, e);
                    label.Image = e.Done
                        ? (e.Blueprint ? _blueprintDoneTechLabelBitmap : _doneTechLabelBitmap)
                        : (e.Blueprint ? _blueprintTechLabelBitmap : _techLabelBitmap);
                }
                else if (item is TechEvent)
                {
                    // ラベル画像を設定する
                    QueryItemStatusEventArgs e = new QueryItemStatusEventArgs(item);
                    QueryItemStatus(this, e);
                    label.Image = e.Done ? _doneEventLabelBitmap : _eventLabelBitmap;
                }
            }
        }
Exemplo n.º 19
0
            /// <summary>
            /// MIDI 出力デバイスのコントローラを生成する。
            /// </summary>
            /// <param name="deviceName">対象となる MIDI 出力デバイスの名前。DeviceCaps.Name の値を使用できる。</param>
            /// <returns>
            /// deviceName で指定した名前のデバイスが見つかった場合は、そのデバイスを表す Controller オブジェクト。
            /// 見つからなかった場合は null。
            /// </returns>
            public static Controller FromName(string deviceName)
            {
                // 名前の一致するデバイスを探す
                uint n = DeviceCaps.NumDevices;

                for (uint i = 0; i < n; ++i)
                {
                    DeviceCaps caps = new DeviceCaps(i);
                    if (caps.Name == deviceName)
                    {
                        // デバイスを発見したので初期化
                        return(new Controller(i));
                    }
                }

                // 名前の一致するデバイスがなかった
                return(null);
            }
Exemplo n.º 20
0
        /// <summary>
        ///     技術ツリーピクチャーボックスにドロップした時の処理
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnPictureBoxDragDrop(object sender, DragEventArgs e)
        {
            // ドラッグアンドドロップが無効ならば何もしない
            if (!AllowDragDrop)
            {
                return;
            }

            // ラベルでなければ何もしない
            if (!e.Data.GetDataPresent(typeof(Label)))
            {
                return;
            }

            Label label = e.Data.GetData(typeof(Label)) as Label;

            if (label == null)
            {
                return;
            }

            // 技術ツリー上のドロップ座標を計算する
            Point p = new Point(e.X, e.Y);

            p   = _pictureBox.PointToClient(p);
            p.X = label.Left + p.X - _dragPoint.X;
            p.Y = label.Top + p.Y - _dragPoint.Y;

            // ラベル情報の座標を更新する
            TechLabelInfo info = label.Tag as TechLabelInfo;

            if (info == null)
            {
                return;
            }
            info.Position.X = DeviceCaps.GetUnscaledWidth(p.X);
            info.Position.Y = DeviceCaps.GetUnscaledHeight(p.Y);

            // ラベルの座標を更新する
            label.Location = p;

            // イベントハンドラを呼び出す
            ItemDragDrop?.Invoke(this, new ItemDragEventArgs(info.Item, info.Position, e));
        }
Exemplo n.º 21
0
        /// <summary>
        ///     フォーム読み込み時の処理
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnFormLoad(object sender, EventArgs e)
        {
            // 国家データを初期化する
            Countries.Init();

            // 研究特性を初期化する
            Techs.InitSpecialities();

            // ゲーム設定ファイルを読み込む
            Misc.Load();

            // 文字列定義ファイルを読み込む
            Config.Load();

            // 技術リストビューの高さを設定するためにダミーのイメージリストを作成する
            techListView.SmallImageList = new ImageList {
                ImageSize = new Size(1, DeviceCaps.GetScaledHeight(18))
            };

            // 研究機関リストビューの高さを設定するためにダミーのイメージリストを作成する
            teamListView.SmallImageList = new ImageList {
                ImageSize = new Size(1, DeviceCaps.GetScaledHeight(18))
            };

            // 研究特性オーバーレイアイコンを初期化する
            _techOverlayIcon = new Bitmap(Game.GetReadFileName(Game.TechIconOverlayPathName));
            _techOverlayIcon.MakeTransparent(Color.Lime);

            // オプション項目を初期化する
            InitOptionItems();

            // 技術定義ファイルを読み込む
            Techs.Load();

            // 研究機関ファイルを読み込む
            Teams.Load();

            // 国家リストボックスを初期化する
            InitCountryListBox();

            // データ読み込み後の処理
            OnFileLoaded();
        }
        private void InitializeD3D()
        {
            if (this.m_Filename != null)
            {
                try {
                    this.m_FormRenderSurface          = new FormDDSTGAPreviewRenderSurface(this);
                    this.m_FormRenderSurface.Anchor   = AnchorStyles.Top | AnchorStyles.Left;
                    this.m_FormRenderSurface.Location = new Point(0, 0);
                    this.m_FormRenderSurface.Size     = new Size(1, 1);
                    this.m_FormRenderSurface.Visible  = true;
                    this.panelRenderSurfaceContainer.Controls.Add(this.m_FormRenderSurface);

                    PresentParameters presentParameters = new PresentParameters();
                    presentParameters.Windowed               = true;
                    presentParameters.SwapEffect             = SwapEffect.Discard;
                    presentParameters.BackBufferFormat       = Format.Unknown;
                    presentParameters.AutoDepthStencilFormat = DepthFormat.D16;
                    presentParameters.EnableAutoDepthStencil = true;

                    DeviceCaps  deviceCaps  = Manager.GetDeviceCaps(Manager.Adapters.Default.Adapter, DeviceType.Hardware).DeviceCaps;
                    CreateFlags createFlags = ((deviceCaps.SupportsHardwareTransformAndLight) ? CreateFlags.HardwareVertexProcessing : CreateFlags.SoftwareVertexProcessing);
                    if (deviceCaps.SupportsPureDevice)
                    {
                        createFlags |= CreateFlags.PureDevice;
                    }

                    if (this.m_Device != null)
                    {
                        this.m_Device.Dispose();
                    }

                    this.m_Device                 = new Device(0, DeviceType.Hardware, this.m_FormRenderSurface, createFlags, presentParameters);
                    this.m_Device.DeviceReset    += new EventHandler(this.OnResetDevice);
                    this.m_Device.DeviceLost     += new EventHandler(this.OnDeviceLost);
                    this.m_Device.DeviceResizing += new CancelEventHandler(this.OnDeviceResizing);
                    OnResetDevice(this.m_Device, null);

                    SetUpViews();
                } catch {
                }
            }
        }
Exemplo n.º 23
0
        /// <summary>
        ///     技術ツリー画像を更新する
        /// </summary>
        private void UpdateTechTreeImage()
        {
            Bitmap original = new Bitmap(Game.GetReadFileName(Game.PicturePathName, TechTreeFileNames[(int)Category]));

            original.MakeTransparent(Color.Lime);

            int      width  = DeviceCaps.GetScaledWidth(original.Width);
            int      height = DeviceCaps.GetScaledHeight(original.Height);
            Bitmap   bitmap = new Bitmap(width, height);
            Graphics g      = Graphics.FromImage(bitmap);

            g.DrawImage(original, 0, 0, width, height);
            g.Dispose();
            original.Dispose();

            Image prev = _pictureBox.Image;

            _pictureBox.Image = bitmap;
            prev?.Dispose();
        }
Exemplo n.º 24
0
        /// <summary>
        ///     技術リストビューの研究特性項目描画処理
        /// </summary>
        /// <param name="e"></param>
        /// <param name="tech">技術項目</param>
        private void DrawTechSpecialityItems(DrawListViewSubItemEventArgs e, TechItem tech)
        {
            if (tech == null)
            {
                e.DrawDefault = true;
                return;
            }

            Rectangle gr = new Rectangle(e.Bounds.X + 4, e.Bounds.Y + 1, DeviceCaps.GetScaledWidth(16),
                                         DeviceCaps.GetScaledHeight(16));
            Rectangle tr = new Rectangle(e.Bounds.X + DeviceCaps.GetScaledWidth(16) + 3, e.Bounds.Y + 3,
                                         e.Bounds.Width - DeviceCaps.GetScaledWidth(16) - 3, e.Bounds.Height);
            Brush brush = new SolidBrush(
                (techListView.SelectedIndices.Count > 0) && (e.ItemIndex == techListView.SelectedIndices[0])
                    ? (techListView.Focused ? SystemColors.HighlightText : SystemColors.ControlText)
                    : SystemColors.WindowText);

            foreach (TechComponent component in tech.Components)
            {
                // 研究特性アイコンを描画する
                if ((component.Speciality != TechSpeciality.None) &&
                    ((int)component.Speciality - 1 < Techs.SpecialityImages.Images.Count))
                {
                    e.Graphics.DrawImage(
                        Techs.SpecialityImages.Images[Array.IndexOf(Techs.Specialities, component.Speciality) - 1], gr);
                }

                // 研究難易度を描画する
                e.Graphics.DrawString(IntHelper.ToString(component.Difficulty), techListView.Font, brush, tr);

                // 次の項目の開始位置を計算する
                int offset = DeviceCaps.GetScaledWidth(32);
                gr.X += offset;
                tr.X += offset;
            }

            brush.Dispose();
        }
Exemplo n.º 25
0
        /// <summary>
        ///     技術ツリーに技術ラベルを追加する
        /// </summary>
        /// <param name="item">追加対象の項目</param>
        /// <param name="position">追加対象の位置</param>
        private void AddLabelItem(TechLabel item, TechPosition position)
        {
            Label label = new Label
            {
                Location  = new Point(DeviceCaps.GetScaledWidth(position.X), DeviceCaps.GetScaledHeight(position.Y)),
                BackColor = Color.Transparent,
                Tag       = new TechLabelInfo {
                    Item = item, Position = position
                }
            };

            label.Size = Graphics.FromHwnd(label.Handle).MeasureString(item.ToString(), label.Font).ToSize();

            label.Click        += OnItemLabelClick;
            label.MouseClick   += OnItemLabelMouseClick;
            label.MouseDown    += OnItemLabelMouseDown;
            label.MouseUp      += OnItemLabelMouseUp;
            label.MouseMove    += OnItemLabelMouseMove;
            label.GiveFeedback += OnItemLabelGiveFeedback;
            label.Paint        += OnTechLabelPaint;

            _pictureBox.Controls.Add(label);
        }
Exemplo n.º 26
0
            /// <summary>
            /// MIDI 出力デバイスのコントローラを生成する。
            /// </summary>
            /// <param name="deviceId">対象となる MIDI 出力デバイスの ID。</param>
            public Controller(uint deviceId)
            {
                Win32.MMRESULT ret;

                caps_ = new DeviceCaps(deviceId);

                // MIDIHDR オブジェクトのサイズ
                cb_hdr_ = (uint)Marshal.SizeOf(typeof(Win32.MIDIHDR));

                try
                {
                    unsafe
                    {
                        // HMIDIOUT オブジェクトの取得
                        fixed(IntPtr *lphmo = &hmo_)
                        {
                            ret = Win32.Api.midiOutOpen((IntPtr)lphmo, deviceId, 0, 0, 0);
                            if (ret != Win32.MMRESULT.MMSYSERR_NOERROR)
                            {
                                throw new Win32Exception(ret);
                            }
                        }

                        // 送信バッファの作成
                        buffer_ = Marshal.AllocHGlobal((int)MAX_BYTES_PER_SENDING);

                        // MIDIHDR データの生成
                        hdr_ = Marshal.AllocHGlobal((int)cb_hdr_);
                        ((Win32.MIDIHDR *)hdr_)->lpData = buffer_;
                    }
                }
                catch
                {
                    Dispose();
                    throw;
                }
            }
        /// <summary>
        /// Acquire the named joystick. You can find this joystick through the <see cref="FindJoysticks"/> method.
        /// </summary>
        /// <param name="name">Name of the joystick.</param>
        /// <returns>The success of the connection.</returns>
        public bool AcquireJoystick(string name)
        {
            try
            {
                DeviceList gameControllerList = Manager.GetDevices(DeviceClass.GameControl,
                                                                   EnumDevicesFlags.AttachedOnly);
                bool found = false;
                // loop through the devices.
                foreach (DeviceInstance deviceInstance in gameControllerList)
                {
                    if (deviceInstance.InstanceName != name)
                    {
                        continue;
                    }

                    // create a device from this controller so we can retrieve info.
                    DirectInputDevice = new Device(deviceInstance.InstanceGuid);
                    DirectInputDevice.SetCooperativeLevel(_hWnd,
                                                          CooperativeLevelFlags.Background |
                                                          CooperativeLevelFlags.NonExclusive);
                    found = true;
                    break;
                }

                if (!found)
                {
                    return(false);
                }

                // Tell DirectX that this is a Joystick.
                DirectInputDevice.SetDataFormat(DeviceDataFormat.Joystick);

                // Finally, acquire the device.
                DirectInputDevice.Acquire();

                DeviceCaps cps = DirectInputDevice.Caps;
                AxisCount   = cps.NumberAxes;
                ButtonCount = cps.NumberButtons;
                AxisInfo    = new AxisInformation[AxisCount];


                DeviceObjectList axisIter = DirectInputDevice.GetObjects(DeviceObjectTypeFlags.Axis);
                int i = 0;
                while (axisIter.MoveNext())
                {
                    var info = (DeviceObjectInstance)axisIter.Current;
                    AxisInfo[i++] = new AxisInformation(info);
                }

                UpdateStatus();
            }
            catch (Exception err)
            {
                Debug.WriteLine("FindJoysticks()");
                Debug.WriteLine(err.Message);
                Debug.WriteLine(err.StackTrace);
                return(false);
            }

            return(true);
        }
Exemplo n.º 28
0
 public static extern int GetDeviceCaps(SafeHandle hdc, DeviceCaps nIndex);
Exemplo n.º 29
0
 internal static extern int GetDeviceCaps(IntPtr hdc, DeviceCaps nIndex);
Exemplo n.º 30
0
        /// <summary>
        ///     フォーム読み込み時の処理
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnFormLoad(object sender, EventArgs e)
        {
            Graphics g      = Graphics.FromHwnd(Handle);
            int      margin = DeviceCaps.GetScaledWidth(2) + 1;

            // 対象国コンボボックス
            srcComboBox.BeginUpdate();
            srcComboBox.Items.Clear();
            int width = srcComboBox.Width;

            foreach (string s in Countries.Tags
                     .Select(country => Countries.Strings[(int)country])
                     .Select(name => Config.ExistsKey(name)
                    ? $"{name} {Config.GetText(name)}"
                    : name))
            {
                srcComboBox.Items.Add(s);
                width = Math.Max(width,
                                 (int)g.MeasureString(s, srcComboBox.Font).Width +
                                 SystemInformation.VerticalScrollBarWidth +
                                 margin);
            }
            srcComboBox.DropDownWidth = width;
            srcComboBox.EndUpdate();
            if (_args.TargetCountries.Count > 0)
            {
                srcComboBox.SelectedIndex = Countries.Tags.ToList().IndexOf(_args.TargetCountries[0]);
            }
            srcComboBox.SelectedIndexChanged += OnSrcComboBoxSelectedIndexChanged;

            // 兵科
            armyCheckBox.Text     = Config.GetText(TextId.BranchArmy);
            navyCheckBox.Text     = Config.GetText(TextId.BranchNavy);
            airforceCheckBox.Text = Config.GetText(TextId.BranchAirForce);

            // コピー/移動先コンボボックス
            destComboBox.BeginUpdate();
            destComboBox.Items.Clear();
            width = destComboBox.Width;
            foreach (string s in Countries.Tags
                     .Select(country => Countries.Strings[(int)country])
                     .Select(name => Config.ExistsKey(name)
                    ? $"{name} {Config.GetText(name)}"
                    : name))
            {
                destComboBox.Items.Add(s);
                width = Math.Max(width,
                                 (int)g.MeasureString(s, srcComboBox.Font).Width +
                                 SystemInformation.VerticalScrollBarWidth +
                                 margin);
            }
            destComboBox.DropDownWidth = width;
            destComboBox.EndUpdate();
            if (_args.TargetCountries.Count > 0)
            {
                destComboBox.SelectedIndex = Countries.Tags.ToList().IndexOf(_args.TargetCountries[0]);
            }
            destComboBox.SelectedIndexChanged += OnDestComboBoxSelectedIndexChanged;

            // 開始ID
            if (_args.TargetCountries.Count > 0)
            {
                idNumericUpDown.Value = Leaders.GetNewId(_args.TargetCountries[0]);
            }
            idNumericUpDown.ValueChanged += OnIdNumericUpDownValueChanged;

            // 理想階級コンボボックス
            idealRankComboBox.BeginUpdate();
            idealRankComboBox.Items.Clear();
            width = idealRankComboBox.Width;
            foreach (string s in Leaders.RankNames.Where(name => !string.IsNullOrEmpty(name)))
            {
                idealRankComboBox.Items.Add(s);
                width = Math.Max(width, (int)g.MeasureString(s, idealRankComboBox.Font).Width + margin);
            }
            idealRankComboBox.DropDownWidth = width;
            idealRankComboBox.EndUpdate();
            if (idealRankComboBox.Items.Count > 0)
            {
                idealRankComboBox.SelectedIndex = 0;
            }
            idealRankComboBox.SelectedIndexChanged += OnIdealRankComboBoxSelectedIndexChanged;

            // 引退年
            if ((Game.Type != GameType.DarkestHour) || (Game.Version < 103))
            {
                retirementYearCheckBox.Enabled      = false;
                retirementYearNumericUpDown.Enabled = false;
                retirementYearNumericUpDown.ResetText();
            }
        }
Exemplo n.º 31
0
 public static extern int GetDeviceCaps(IntPtr hDC, DeviceCaps nIndex);
Exemplo n.º 32
0
 public static extern int GetDeviceCaps(SafeHandle hdc, DeviceCaps nIndex);
Exemplo n.º 33
0
        /// <summary>
        /// Acquire the named joystick. You can find this joystick through the <see cref="FindJoysticks"/> method.
        /// </summary>
        /// <param name="name">Name of the joystick.</param>
        /// <returns>The success of the connection.</returns>
        public bool AcquireJoystick(string name)
        {
            #if windows
            try
            {
                DeviceList gameControllerList = Manager.GetDevices(DeviceClass.GameControl, EnumDevicesFlags.AttachedOnly);
                int        i     = 0;
                bool       found = false;
                // loop through the devices.
                foreach (DeviceInstance deviceInstance in gameControllerList)
                {
                    if (deviceInstance.InstanceName == name)
                    {
                        found = true;
                        // create a device from this controller so we can retrieve info.
                        joystickDevice = new Device(deviceInstance.InstanceGuid);
                        joystickDevice.SetCooperativeLevel(hWnd,
                                                           CooperativeLevelFlags.Background |
                                                           CooperativeLevelFlags.NonExclusive);

                        break;
                    }

                    i++;
                }

                if (!found)
                {
                    return(false);
                }

                // Tell DirectX that this is a Joystick.
                joystickDevice.SetDataFormat(DeviceDataFormat.Joystick);

                // Finally, acquire the device.
                joystickDevice.Acquire();

                // How many axes?
                // Find the capabilities of the joystick
                DeviceCaps cps = joystickDevice.Caps;
                Debug.WriteLine("Joystick Axis: " + cps.NumberAxes);
                Debug.WriteLine("Joystick Buttons: " + cps.NumberButtons);

                axisCount = cps.NumberAxes;

                for (int j = 0; j < axisCount + 3; j++)
                {
                    this.Axis.Add(0);
                }

                updater = new Timer(update, null, 0, 10);
            }
            catch (Exception err)
            {
                Debug.WriteLine("FindJoysticks()");
                Debug.WriteLine(err.Message);
                Debug.WriteLine(err.StackTrace);
                return(false);
            }
#endif
            return(true);
        }
Exemplo n.º 34
0
        /// <summary>
        ///     編集項目を作成する
        /// </summary>
        /// <param name="tabPage">対象のタブページ</param>
        private void CreateEditableItems(TabPage tabPage)
        {
            List <List <MiscItemId> > table = tabPage.Tag as List <List <MiscItemId> >;

            if (table == null)
            {
                return;
            }

            Graphics g                   = Graphics.FromHwnd(Handle);
            int      itemHeight          = DeviceCaps.GetScaledHeight(25);
            int      labelStartX         = DeviceCaps.GetScaledWidth(10);
            int      labelStartY         = DeviceCaps.GetScaledHeight(13);
            int      editStartY          = DeviceCaps.GetScaledHeight(10);
            int      labelEditMargin     = DeviceCaps.GetScaledWidth(8);
            int      columnMargin        = DeviceCaps.GetScaledWidth(10);
            int      textBoxWidth        = DeviceCaps.GetScaledWidth(50);
            int      textBoxHeight       = DeviceCaps.GetScaledHeight(19);
            int      comboBoxWidthUnit   = DeviceCaps.GetScaledWidth(15);
            int      comboBoxWidthBase   = DeviceCaps.GetScaledWidth(50);
            int      comboBoxWidthMargin = DeviceCaps.GetScaledWidth(8);
            int      comboBoxHeight      = DeviceCaps.GetScaledHeight(20);

            int labelX = labelStartX;

            foreach (List <MiscItemId> list in table)
            {
                int labelY = labelStartY;
                int editX  = labelX; // 編集コントロールの右端X座標(左端ではない)
                foreach (MiscItemId id in list)
                {
                    // ラベルを作成する
                    Label label = new Label
                    {
                        Text     = Misc.GetItemName(id),
                        AutoSize = true,
                        Location = new Point(labelX, labelY)
                    };
                    string t = Misc.GetItemToolTip(id);
                    if (!string.IsNullOrEmpty(t))
                    {
                        miscToolTip.SetToolTip(label, t);
                    }
                    tabPage.Controls.Add(label);

                    // 編集コントロールの幅のみ求める
                    int          x    = labelX + label.Width + labelEditMargin;
                    MiscItemType type = Misc.ItemTypes[(int)id];
                    switch (type)
                    {
                    case MiscItemType.Bool:
                    case MiscItemType.Enum:
                        int maxWidth = comboBoxWidthBase;
                        for (int i = Misc.IntMinValues[id]; i <= Misc.IntMaxValues[id]; i++)
                        {
                            string s = Misc.GetItemChoice(id, i);
                            if (string.IsNullOrEmpty(s))
                            {
                                continue;
                            }
                            maxWidth = Math.Max(maxWidth,
                                                (int)g.MeasureString(s, Font).Width + SystemInformation.VerticalScrollBarWidth
                                                + comboBoxWidthMargin);
                            maxWidth = comboBoxWidthBase
                                       + (maxWidth - comboBoxWidthBase + (comboBoxWidthUnit - 1))
                                       / comboBoxWidthUnit * comboBoxWidthUnit;
                        }
                        x += maxWidth;
                        break;

                    default:
                        // テキストボックスの項目は固定
                        x += textBoxWidth;
                        break;
                    }
                    if (x > editX)
                    {
                        editX = x;
                    }
                    labelY += itemHeight;
                }
                int editY = editStartY;
                foreach (MiscItemId id in list)
                {
                    // 編集コントロールを作成する
                    MiscItemType type = Misc.ItemTypes[(int)id];
                    switch (type)
                    {
                    case MiscItemType.Bool:
                    case MiscItemType.Enum:
                        ComboBox comboBox = new ComboBox
                        {
                            DropDownStyle = ComboBoxStyle.DropDownList,
                            DrawMode      = DrawMode.OwnerDrawFixed,
                            Tag           = id
                        };
                        // コンボボックスの選択項目を登録し、最大幅を求める
                        int maxWidth = comboBoxWidthBase;
                        for (int i = Misc.IntMinValues[id]; i <= Misc.IntMaxValues[id]; i++)
                        {
                            string s = Misc.GetItemChoice(id, i);
                            if (string.IsNullOrEmpty(s))
                            {
                                continue;
                            }
                            comboBox.Items.Add(s);
                            maxWidth = Math.Max(maxWidth,
                                                (int)g.MeasureString(s, Font).Width + SystemInformation.VerticalScrollBarWidth
                                                + comboBoxWidthMargin);
                            maxWidth = comboBoxWidthBase
                                       + (maxWidth - comboBoxWidthBase + (comboBoxWidthUnit - 1))
                                       / comboBoxWidthUnit * comboBoxWidthUnit;
                        }
                        comboBox.Size                  = new Size(maxWidth, comboBoxHeight);
                        comboBox.Location              = new Point(editX - maxWidth, editY);
                        comboBox.DrawItem             += OnItemComboBoxDrawItem;
                        comboBox.SelectedIndexChanged += OnItemComboBoxSelectedIndexChanged;
                        tabPage.Controls.Add(comboBox);
                        break;

                    default:
                        TextBox textBox = new TextBox
                        {
                            Size      = new Size(textBoxWidth, textBoxHeight),
                            Location  = new Point(editX - textBoxWidth, editY),
                            TextAlign = HorizontalAlignment.Right,
                            Tag       = id
                        };
                        textBox.Validated += OnItemTextBoxValidated;
                        tabPage.Controls.Add(textBox);
                        break;
                    }
                    editY += itemHeight;
                }
                // 次の列との間を空ける
                labelX = editX + columnMargin;
            }
        }
Exemplo n.º 35
0
        /// <summary>
        ///     タブページ群を初期化する
        /// </summary>
        private void InitTabPages()
        {
            miscTabControl.TabPages.Clear();

            MiscGameType type           = Misc.GetGameType();
            int          itemHeight     = DeviceCaps.GetScaledHeight(25);
            int          itemMargin     = DeviceCaps.GetScaledWidth(20);
            int          itemsPerColumn = (miscTabControl.ClientSize.Height - miscTabControl.ItemSize.Height - itemMargin) /
                                          itemHeight;
            const int columnsPerPage = 3;

            foreach (MiscSectionId section in Enum.GetValues(typeof(MiscSectionId))
                     .Cast <MiscSectionId>()
                     .Where(section => Misc.SectionTable[(int)section, (int)type]))
            {
                TabPage tabPage = new TabPage
                {
                    Text      = Misc.GetSectionName(section),
                    BackColor = SystemColors.Control
                };
                List <List <MiscItemId> > table = new List <List <MiscItemId> >();
                List <MiscItemId>         list  = new List <MiscItemId>();
                int row    = 0;
                int column = 0;
                int page   = 1;
                foreach (MiscItemId id in Misc.SectionItems[(int)section]
                         .Where(id => Misc.ItemTable[(int)id, (int)type]))
                {
                    if (row >= itemsPerColumn)
                    {
                        table.Add(list);

                        list = new List <MiscItemId>();
                        column++;
                        row = 0;

                        if (column >= columnsPerPage)
                        {
                            if (page == 1)
                            {
                                tabPage.Text += IntHelper.ToString(page);
                            }
                            tabPage.Tag = table;
                            miscTabControl.TabPages.Add(tabPage);

                            page++;
                            tabPage = new TabPage
                            {
                                Text      = Misc.GetSectionName(section) + IntHelper.ToString(page),
                                BackColor = SystemColors.Control
                            };
                            table  = new List <List <MiscItemId> >();
                            column = 0;
                        }
                    }

                    list.Add(id);
                    row++;
                }

                table.Add(list);
                tabPage.Tag = table;
                miscTabControl.TabPages.Add(tabPage);
            }
        }
Exemplo n.º 36
0
 public static DeviceCaps GetDeviceInfo(int id)
 {
     var devCaps = new NativeMethods.MIDIOUTCAPS();
     if (NativeMethods.midiOutGetDevCaps((uint)id, ref devCaps, (uint)Marshal.SizeOf(typeof(NativeMethods.MIDIOUTCAPS))) != NativeMethods.MMSYSERR_NOERROR)
         return null;
     var caps = new DeviceCaps();
     caps.deviceName = devCaps.szPname;
     return caps;
 }
Exemplo n.º 37
0
		/// <summary>
		/// This function retrieves device-specific information about a connected device.
		/// </summary>
		/// <param name="CapabiltyToGet">Capabilty to query</param>
		/// <returns>Value reported for capability</returns>
		public int GetDeviceCapabilities(DeviceCaps CapabiltyToGet)
		{
			CheckConnection();

			return CeGetDesktopDeviceCaps((int)CapabiltyToGet);
		}
Exemplo n.º 38
0
 internal static extern int GetDeviceCaps(IntPtr hdc, DeviceCaps nIndex);