コード例 #1
0
ファイル: PH9903_InputSetting.cs プロジェクト: fwka1605/next
        private void Save()
        {
            try
            {
                var inputGridType = InputGridTypeId == InputGridType.Billing
                    ? "請求" : "入金";
                if (!ShowConfirmDialog(MsgQstConfirmClearEditedXXXData, inputGridType))
                {
                    return;
                }

                SetInputControlInfo();

                InputControlsResult result = null;
                ProgressDialog.Start(ParentForm, Task.Run(async() =>
                {
                    result = await ServiceProxyFactory.DoAsync(async(InputControlMasterClient client)
                                                               => await client.SaveAsync(SessionKey, CompanyId, Login.UserId, InputGridTypeId, InputControlList.ToArray()));
                }), false, SessionKey);

                if (result.ProcessResult.Result)
                {
                    Modified = false;
                    ParentForm.DialogResult = DialogResult.OK;
                }
                else
                {
                    ShowWarningDialog(MsgErrSaveError);
                }
            }
            catch (Exception ex)
            {
                Debug.Fail(ex.ToString());
                NLogHandler.WriteErrorLog(this, ex, SessionKey);
            }
        }
コード例 #2
0
    public void Controls_CanKeepListsOfControls_WithoutAllocatingGCMemory()
    {
        InputSystem.AddDevice <Mouse>(); // Noise.
        var gamepad  = InputSystem.AddDevice <Gamepad>();
        var keyboard = InputSystem.AddDevice <Keyboard>();

        var list = new InputControlList <InputControl>();

        try
        {
            Assert.That(list.Count, Is.Zero);
            Assert.That(list.ToArray(), Is.Empty);
            Assert.That(() => list[0], Throws.TypeOf <ArgumentOutOfRangeException>());

            list.Capacity = 10;

            list.Add(gamepad.leftStick);
            list.Add(null); // Permissible to add null entry.
            list.Add(keyboard.spaceKey);
            list.Add(keyboard);

            Assert.That(list.Count, Is.EqualTo(4));
            Assert.That(list.Capacity, Is.EqualTo(6));
            Assert.That(list[0], Is.SameAs(gamepad.leftStick));
            Assert.That(list[1], Is.Null);
            Assert.That(list[2], Is.SameAs(keyboard.spaceKey));
            Assert.That(list[3], Is.SameAs(keyboard));
            Assert.That(() => list[4], Throws.TypeOf <ArgumentOutOfRangeException>());
            Assert.That(list.ToArray(),
                        Is.EquivalentTo(new InputControl[] { gamepad.leftStick, null, keyboard.spaceKey, keyboard }));
            Assert.That(list.Contains(gamepad.leftStick));
            Assert.That(list.Contains(null));
            Assert.That(list.Contains(keyboard.spaceKey));
            Assert.That(list.Contains(keyboard));

            list.RemoveAt(1);
            list.Remove(keyboard);

            Assert.That(list.Count, Is.EqualTo(2));
            Assert.That(list.Capacity, Is.EqualTo(8));
            Assert.That(list[0], Is.SameAs(gamepad.leftStick));
            Assert.That(list[1], Is.SameAs(keyboard.spaceKey));
            Assert.That(() => list[2], Throws.TypeOf <ArgumentOutOfRangeException>());
            Assert.That(list.ToArray(), Is.EquivalentTo(new InputControl[] { gamepad.leftStick, keyboard.spaceKey }));
            Assert.That(list.Contains(gamepad.leftStick));
            Assert.That(!list.Contains(null));
            Assert.That(list.Contains(keyboard.spaceKey));
            Assert.That(!list.Contains(keyboard));

            list.AddRange(new InputControl[] { keyboard.aKey, keyboard.bKey }, count: 1, destinationIndex: 0);

            Assert.That(list.Count, Is.EqualTo(3));
            Assert.That(list.Capacity, Is.EqualTo(7));
            Assert.That(list,
                        Is.EquivalentTo(new InputControl[]
                                        { keyboard.aKey, gamepad.leftStick, keyboard.spaceKey }));

            list.AddRange(new InputControl[] { keyboard.bKey, keyboard.cKey });

            Assert.That(list.Count, Is.EqualTo(5));
            Assert.That(list.Capacity, Is.EqualTo(5));
            Assert.That(list,
                        Is.EquivalentTo(new InputControl[]
                                        { keyboard.aKey, gamepad.leftStick, keyboard.spaceKey, keyboard.bKey, keyboard.cKey }));

            using (var toAdd = new InputControl[] { gamepad.buttonNorth, gamepad.buttonEast, gamepad.buttonWest }.ToControlList())
                list.AddSlice(toAdd, count: 1, destinationIndex: 1, sourceIndex: 2);

            Assert.That(list.Count, Is.EqualTo(6));
            Assert.That(list.Capacity, Is.EqualTo(4));
            Assert.That(list,
                        Is.EquivalentTo(new InputControl[]
                                        { keyboard.aKey, gamepad.buttonWest, gamepad.leftStick, keyboard.spaceKey, keyboard.bKey, keyboard.cKey }));

            list[0] = keyboard.zKey;

            Assert.That(list,
                        Is.EquivalentTo(new InputControl[]
                                        { keyboard.zKey, gamepad.buttonWest, gamepad.leftStick, keyboard.spaceKey, keyboard.bKey, keyboard.cKey }));

            list.Clear();

            Assert.That(list.Count, Is.Zero);
            Assert.That(list.Capacity, Is.EqualTo(10));
            Assert.That(list.ToArray(), Is.Empty);
            Assert.That(() => list[0], Throws.TypeOf <ArgumentOutOfRangeException>());
            Assert.That(!list.Contains(gamepad.leftStick));
            Assert.That(!list.Contains(null));
            Assert.That(!list.Contains(keyboard.spaceKey));
            Assert.That(!list.Contains(keyboard));
        }
        finally
        {
            list.Dispose();
        }
    }
コード例 #3
0
    public void Controls_CanKeepListsOfControls_WithoutAllocatingGCMemory()
    {
        InputSystem.AddDevice <Mouse>(); // Noise.
        var gamepad  = InputSystem.AddDevice <Gamepad>();
        var keyboard = InputSystem.AddDevice <Keyboard>();

        var list = new InputControlList <InputControl>();

        try
        {
            Assert.That(list.Count, Is.Zero);
            Assert.That(list.ToArray(), Is.Empty);
            Assert.That(() => list[0], Throws.TypeOf <ArgumentOutOfRangeException>());

            list.Capacity = 10;

            list.Add(gamepad.leftStick);
            list.Add(null); // Permissible to add null entry.
            list.Add(keyboard.spaceKey);
            list.Add(keyboard);

            Assert.That(list.Count, Is.EqualTo(4));
            Assert.That(list.Capacity, Is.EqualTo(6));
            Assert.That(list[0], Is.SameAs(gamepad.leftStick));
            Assert.That(list[1], Is.Null);
            Assert.That(list[2], Is.SameAs(keyboard.spaceKey));
            Assert.That(list[3], Is.SameAs(keyboard));
            Assert.That(() => list[4], Throws.TypeOf <ArgumentOutOfRangeException>());
            Assert.That(list.ToArray(),
                        Is.EquivalentTo(new InputControl[] { gamepad.leftStick, null, keyboard.spaceKey, keyboard }));
            Assert.That(list.Contains(gamepad.leftStick));
            Assert.That(list.Contains(null));
            Assert.That(list.Contains(keyboard.spaceKey));
            Assert.That(list.Contains(keyboard));

            list.RemoveAt(1);
            list.Remove(keyboard);

            Assert.That(list.Count, Is.EqualTo(2));
            Assert.That(list.Capacity, Is.EqualTo(8));
            Assert.That(list[0], Is.SameAs(gamepad.leftStick));
            Assert.That(list[1], Is.SameAs(keyboard.spaceKey));
            Assert.That(() => list[2], Throws.TypeOf <ArgumentOutOfRangeException>());
            Assert.That(list.ToArray(), Is.EquivalentTo(new InputControl[] { gamepad.leftStick, keyboard.spaceKey }));
            Assert.That(list.Contains(gamepad.leftStick));
            Assert.That(!list.Contains(null));
            Assert.That(list.Contains(keyboard.spaceKey));
            Assert.That(!list.Contains(keyboard));

            list.Clear();

            Assert.That(list.Count, Is.Zero);
            Assert.That(list.Capacity, Is.EqualTo(10));
            Assert.That(list.ToArray(), Is.Empty);
            Assert.That(() => list[0], Throws.TypeOf <ArgumentOutOfRangeException>());
            Assert.That(!list.Contains(gamepad.leftStick));
            Assert.That(!list.Contains(null));
            Assert.That(!list.Contains(keyboard.spaceKey));
            Assert.That(!list.Contains(keyboard));
        }
        finally
        {
            list.Dispose();
        }
    }