public static void OnTabBtnIsOnPatch_multiCourseSelect(ref UIElective __instance, ref int index) { if (multiCourseSelect.Value) { CtrlElective controller = Traverse.Create(__instance).Field("controller").GetValue <CtrlElective>(); EnumArray <Grade, List <ElectiveInfo> > sort = Traverse.Create(controller).Field("sort").GetValue <EnumArray <Grade, List <ElectiveInfo> > >(); int gradeIndex = Traverse.Create(controller).Field("gradeIndex").GetValue <int>(); List <ElectiveInfo> courses = sort[gradeIndex]; InputSelectable ElectiveSelectable = Traverse.Create(__instance).Field("ElectiveSelectable").GetValue <InputSelectable>(); List <InputNavigation> InputNavigations = ElectiveSelectable.InputNavigations; for (int i = 0; i < courses.Count; i++) { InputNavigation CurrentSelected = InputNavigations[i]; if (selectElectiveInfos.Contains(courses[i])) { showSelectIcon(CurrentSelected); } else { hideSelectIcon(CurrentSelected); } } } }
internal static void CreateBasetable(string address) { const string underDatabaseName = "SysDatabse"; const string tableName = "SysTable"; const string Namespace = "SysNamespace"; var userName = new List <string>() { "Iner", "guest" }; var fieldTypes = new Dictionary <string, string> { { "No", EnumArray.fieldType(EnumArray.FieldType.Int) }, //数字 { "Name", EnumArray.fieldType(EnumArray.FieldType.String) }, //普通字符串 { "Remark", EnumArray.fieldType(EnumArray.FieldType.Text) }, //备注 { "UpdateDatatime", EnumArray.fieldType(EnumArray.FieldType.Object) }, //修改时间 { "CreateTime", EnumArray.fieldType(EnumArray.FieldType.Datetime) }, //创建时间 { "Status", EnumArray.fieldType(EnumArray.FieldType.Local) }, //局部,有限制值 { "Close", EnumArray.fieldType(EnumArray.FieldType.Trigger) }, //关闭的时候指向一个触发器或事件 { "File", EnumArray.fieldType(EnumArray.FieldType.FileAddress) } //指向一个地址,这个地址可以指向一个表,也可以指向一个数据库,一个命名空间,一个文件等在取出数据的时候其实就是将这个数据一同取出 }; const string modifier = "private"; var json = CreateBasetable(fieldTypes, tableName, underDatabaseName, modifier, Namespace, userName); ServiceYSQL.ReadAndWrite.Write(json, address); }
static TrackingActivator() { handJointMapping = new EnumArray <WVR_HandJoint, HandJointName>(); handJointMapping[WVR_HandJoint.WVR_HandJoint_Palm] = HandJointName.Palm; handJointMapping[WVR_HandJoint.WVR_HandJoint_Wrist] = HandJointName.Wrist; handJointMapping[WVR_HandJoint.WVR_HandJoint_Thumb_Joint0] = HandJointName.ThumbMetacarpal; handJointMapping[WVR_HandJoint.WVR_HandJoint_Thumb_Joint1] = HandJointName.ThumbProximal; handJointMapping[WVR_HandJoint.WVR_HandJoint_Thumb_Joint2] = HandJointName.ThumbDistal; handJointMapping[WVR_HandJoint.WVR_HandJoint_Thumb_Tip] = HandJointName.ThumbTip; handJointMapping[WVR_HandJoint.WVR_HandJoint_Index_Joint0] = HandJointName.IndexMetacarpal; handJointMapping[WVR_HandJoint.WVR_HandJoint_Index_Joint1] = HandJointName.IndexProximal; handJointMapping[WVR_HandJoint.WVR_HandJoint_Index_Joint2] = HandJointName.IndexIntermediate; handJointMapping[WVR_HandJoint.WVR_HandJoint_Index_Joint3] = HandJointName.IndexDistal; handJointMapping[WVR_HandJoint.WVR_HandJoint_Index_Tip] = HandJointName.IndexTip; handJointMapping[WVR_HandJoint.WVR_HandJoint_Middle_Joint0] = HandJointName.MiddleMetacarpal; handJointMapping[WVR_HandJoint.WVR_HandJoint_Middle_Joint1] = HandJointName.MiddleProximal; handJointMapping[WVR_HandJoint.WVR_HandJoint_Middle_Joint2] = HandJointName.MiddleIntermediate; handJointMapping[WVR_HandJoint.WVR_HandJoint_Middle_Joint3] = HandJointName.MiddleDistal; handJointMapping[WVR_HandJoint.WVR_HandJoint_Middle_Tip] = HandJointName.MiddleTip; handJointMapping[WVR_HandJoint.WVR_HandJoint_Ring_Joint0] = HandJointName.RingMetacarpal; handJointMapping[WVR_HandJoint.WVR_HandJoint_Ring_Joint1] = HandJointName.RingProximal; handJointMapping[WVR_HandJoint.WVR_HandJoint_Ring_Joint2] = HandJointName.RingIntermediate; handJointMapping[WVR_HandJoint.WVR_HandJoint_Ring_Joint3] = HandJointName.RingDistal; handJointMapping[WVR_HandJoint.WVR_HandJoint_Ring_Tip] = HandJointName.RingTip; handJointMapping[WVR_HandJoint.WVR_HandJoint_Pinky_Joint0] = HandJointName.PinkyMetacarpal; handJointMapping[WVR_HandJoint.WVR_HandJoint_Pinky_Joint1] = HandJointName.PinkyProximal; handJointMapping[WVR_HandJoint.WVR_HandJoint_Pinky_Joint2] = HandJointName.PinkyIntermediate; handJointMapping[WVR_HandJoint.WVR_HandJoint_Pinky_Joint3] = HandJointName.PinkyDistal; handJointMapping[WVR_HandJoint.WVR_HandJoint_Pinky_Tip] = HandJointName.PinkyTip; }
public ContentArea(Game game, string routeName, TrackContent trackContent, EnumArray <string, ColorSetting> colorPreferences, TrackViewerViewSettings viewSettings) : base(game) { if (null == game) { throw new ArgumentNullException(nameof(game)); } if (null == colorPreferences) { throw new ArgumentNullException(nameof(colorPreferences)); } Enabled = false; RouteName = routeName; TrackContent = trackContent ?? throw new ArgumentNullException(nameof(trackContent)); bounds = trackContent.Bounds; spriteBatch = new SpriteBatch(GraphicsDevice); fontManager = FontManager.Exact("Segoe UI", System.Drawing.FontStyle.Regular); inputComponent = game.Components.OfType <MouseInputGameComponent>().Single(); inputComponent.AddMouseEvent(MouseMovedEventType.MouseMoved, MouseMove); foreach (ColorSetting setting in EnumExtension.GetValues <ColorSetting>()) { UpdateColor(setting, ColorExtension.FromName(colorPreferences[setting])); } this.viewSettings = viewSettings; game.Window.ClientSizeChanged += Window_ClientSizeChanged; }
public static void OnCourseBtnPressedPatch_multiCourseSelect(ref UIElective __instance) { if (multiCourseSelect.Value) { Heluo.Logger.LogError("OnCourseBtnPressedPatch_multiCourseSelect start"); CtrlElective controller = Traverse.Create(__instance).Field("controller").GetValue <CtrlElective>(); EnumArray <Grade, List <ElectiveInfo> > sort = Traverse.Create(controller).Field("sort").GetValue <EnumArray <Grade, List <ElectiveInfo> > >(); int gradeIndex = Traverse.Create(controller).Field("gradeIndex").GetValue <int>(); int courseIndex = Traverse.Create(controller).Field("courseIndex").GetValue <int>(); ElectiveInfo electiveInfo = sort[gradeIndex][courseIndex]; InputSelectable ElectiveSelectable = Traverse.Create(__instance).Field("ElectiveSelectable").GetValue <InputSelectable>(); InputNavigation CurrentSelected = ElectiveSelectable.CurrentSelected; if (selectElectiveInfos.Contains(electiveInfo)) { selectElectiveInfos.Remove(electiveInfo); hideSelectIcon(CurrentSelected); } else { selectElectiveInfos.Add(electiveInfo); showSelectIcon(CurrentSelected); } Heluo.Logger.LogError("OnCourseBtnPressedPatch_multiCourseSelect end"); } }
private DefaultTooltipPrefab CloneOrGetPrefab(ControllerButton button) { var prefabClone = GetClonedPrefab(button); if (prefabClone != null) { return(prefabClone); } if (m_tooltipPrefab == null) { return(null); } if (prefabClones == null) { prefabClones = new EnumArray <ControllerButton, DefaultTooltipPrefab>(); } var obj = Instantiate(m_tooltipPrefab); prefabClones[(int)button] = prefabClone = obj.GetComponent <DefaultTooltipPrefab>(); prefabClone.name = button.ToString(); prefabClone.transform.SetParent(m_tooltipParent == null ? transform : m_tooltipParent); prefabClone.transform.localPosition = Vector3.zero; prefabClone.transform.localRotation = Quaternion.identity; return(prefabClone); }
//================================================================================================// // // Constructor from other route element // public TrackCircuitRouteElement(TrackCircuitRouteElement source) { if (null == source) { throw new ArgumentNullException(nameof(source)); } TrackCircuitSection = source.TrackCircuitSection; Direction = source.Direction; OutPin = new EnumArray <TrackDirection, Location>(source.OutPin); if (source.StartAlternativePath != null) { StartAlternativePath = new AlternativePath() { PathIndex = source.StartAlternativePath.PathIndex, TrackCircuitSection = source.StartAlternativePath.TrackCircuitSection, }; } if (source.EndAlternativePath != null) { EndAlternativePath = new AlternativePath() { PathIndex = source.EndAlternativePath.PathIndex, TrackCircuitSection = source.EndAlternativePath.TrackCircuitSection, }; } FacingPoint = source.FacingPoint; UsedAlternativePath = source.UsedAlternativePath; MovingTableApproachPath = source.MovingTableApproachPath; }
public override int GetHashCode() { unchecked { int hashCode = (Prop1 != null ? Prop1.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Prop2 != null ? Prop2.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (EnumArray != null ? EnumArray.GetHashCode() : 0); return(hashCode); } }
public void Initialize(EnumArray <byte, T> userCommands, RailDriverInputGameComponent inputGameComponent, UserCommandController <T> userCommandController) { if (null == userCommands) { throw new ArgumentNullException(nameof(userCommands)); } this.userCommandController = userCommandController ?? throw new ArgumentNullException(nameof(userCommandController)); this.inputGameComponent = inputGameComponent ?? throw new ArgumentNullException(nameof(inputGameComponent)); (T Command, byte CommandValue, bool AvailableForMapping)emergencyCommand = (default, byte.MaxValue, false);
public void InitAnimMaxSize <TDir>(int Length, TDir eDirection) { _eDirection = (Enum)Enum.ToObject(eDirection.GetType(), eDirection); for (int n = 0; n < Length; ++n) { EnumArray <AnimationInfo> enumArray = new EnumArray <AnimationInfo>(); enumArray.Allocate(eDirection); _animationInfos.Add(enumArray); } }
void Awake() { _keyInput = new EnumArray <EnumArray <KeyCode> >(); _keyInput.Allocate(InputAction.MAX); for (int i = 0; i < (int)InputAction.MAX; ++i) { _keyInput[i] = new EnumArray <KeyCode>(); _keyInput[i].Allocate(InputDirection.MAX); } RegisterInputKey(InputAction.PLAYER_ATTACK, InputDirection.ALL, KeyCode.Mouse0); RegisterInputKey(InputAction.PLAYER_BLOCK, InputDirection.ALL, KeyCode.Space); }
protected override void SetSettingValue <T, TEnum>(string name, EnumArray <T, TEnum> value) { StringBuilder builder = new StringBuilder(); foreach (TEnum item in EnumExtension.GetValues <TEnum>()) { if ((dynamic)value[item] != default(T)) { if (typeof(T).IsArray) { builder.Append($"{item}="); foreach (dynamic arrayItem in (Array)(dynamic)value[item]) { builder.Append($"{arrayItem},"); } if (builder[^ 1] == ',')
public override void ReadValue( ref Utf8JsonReader reader, ref EnumArray <K, V> arr, string name, JsonSerializerOptions options) { if (!Enum <K> .Map.TryGetValue(name.ToPascal(), out var key)) { throw new Exception($"Unknown value { name } for enum { typeof(K).ToString() }"); } var value = JsonSerializer.Deserialize <V>(ref reader, options); if (value == null) { throw new Exception(); } arr[key] = value; }
public override void OnActivated() { m_prevTrackingSpace = XRDevice.GetTrackingSpaceType(); UpdateTrackingSpaceType(); EnsureDeviceStateLength(16); m_index2nodeID = new ulong[GetDeviceStateLength()]; m_index2nodeValidity = new bool[GetDeviceStateLength()]; m_index2nodeTouched = new bool[GetDeviceStateLength()]; if (s_nodeType2DeviceClass == null) { s_nodeType2DeviceClass = new EnumArray <XRNode, VRModuleDeviceClass>(VRModuleDeviceClass.Invalid); s_nodeType2DeviceClass[XRNode.Head] = VRModuleDeviceClass.HMD; s_nodeType2DeviceClass[XRNode.RightHand] = VRModuleDeviceClass.Controller; s_nodeType2DeviceClass[XRNode.LeftHand] = VRModuleDeviceClass.Controller; s_nodeType2DeviceClass[XRNode.GameController] = VRModuleDeviceClass.Controller; s_nodeType2DeviceClass[XRNode.HardwareTracker] = VRModuleDeviceClass.GenericTracker; s_nodeType2DeviceClass[XRNode.TrackingReference] = VRModuleDeviceClass.TrackingReference; } }
public static bool TryGetDefaultAsset(VRModuleDeviceModel model, out TooltipRigAsset rigAsset) { if (!EnumArrayBase <VRModuleDeviceModel> .StaticIsValidIndex((int)model)) { rigAsset = null; return(false); } if (s_defaultTooltipRigSets == null) { s_defaultTooltipRigSets = new EnumArray <VRModuleDeviceModel, LoadedRigSet>(); } var loadedRigSet = s_defaultTooltipRigSets[(int)model]; if (!loadedRigSet.haveLoaded) { TooltipRigAsset asset = null; int modelNameIndex; var info = EnumUtils.GetDisplayInfo(typeof(VRModuleDeviceModel)); if (info.value2displayedIndex.TryGetValue((int)model, out modelNameIndex)) { asset = Resources.Load <TooltipRigAsset>("TooltipRig/VIUTooltipRig" + info.displayedNames[modelNameIndex]); } s_defaultTooltipRigSets[(int)model] = loadedRigSet = new LoadedRigSet() { haveLoaded = true, asset = asset, }; } if (loadedRigSet.asset == null) { rigAsset = null; return(false); } rigAsset = loadedRigSet.asset; return(rigAsset != null); }
private void SetDefaultRimImages() { const int size = 80; var w = new Bitmap(size, size); Graphics.FromImage(w).Clear(Color.FromArgb(0xf0d9b5)); var b = new Bitmap(size, size); Graphics.FromImage(w).Clear(Color.FromArgb(0xb58863)); LightRimSide = new EnumArray <RimSide, Image>(); DarkRimSide = new EnumArray <RimSide, Image>(); LightRimCorner = new EnumArray <RimCorner, Image>(); DarkRimCorner = new EnumArray <RimCorner, Image>(); LightRimSide[RimSide.Left] = w; LightRimSide[RimSide.Right] = w; LightRimSide[RimSide.Top] = w; LightRimSide[RimSide.Bottom] = w; DarkRimSide[RimSide.Left] = b; DarkRimSide[RimSide.Right] = b; DarkRimSide[RimSide.Top] = b; DarkRimSide[RimSide.Bottom] = b; LightRimCorner[RimCorner.TopLeft] = w; LightRimCorner[RimCorner.TopRight] = w; LightRimCorner[RimCorner.BottomLeft] = w; LightRimCorner[RimCorner.BottomRight] = w; DarkRimCorner[RimCorner.TopLeft] = b; DarkRimCorner[RimCorner.TopRight] = b; DarkRimCorner[RimCorner.BottomLeft] = b; DarkRimCorner[RimCorner.BottomRight] = b; }
public void ArrayOfEnums() { var obj = new EnumArray() { Array = new ShortEnum[] { (ShortEnum)1, (ShortEnum)3, (ShortEnum)5, } }; var stream = new MemoryStream(); BinaryMapping.WriteObject(stream, obj); Assert.Equal(6, stream.Length); stream.Position = 0; var actual = BinaryMapping.ReadObject <EnumArray>(stream); Assert.Equal(obj.Array[0], actual.Array[0]); Assert.Equal(obj.Array[1], actual.Array[1]); Assert.Equal(obj.Array[2], actual.Array[2]); }
//================================================================================================// // // Restore // public TrackCircuitRouteElement(BinaryReader inf) { if (null == inf) { throw new ArgumentNullException(nameof(inf)); } TrackCircuitSection = TrackCircuitSection.TrackCircuitList[inf.ReadInt32()]; Direction = (TrackDirection)inf.ReadInt32(); OutPin = new EnumArray <TrackDirection, Location>(new TrackDirection[] { (TrackDirection)inf.ReadInt32(), (TrackDirection)inf.ReadInt32() }); int altindex = inf.ReadInt32(); if (altindex >= 0) { StartAlternativePath = new AlternativePath() { PathIndex = altindex, TrackCircuitSection = TrackCircuitSection.TrackCircuitList[inf.ReadInt32()], }; } altindex = inf.ReadInt32(); if (altindex >= 0) { EndAlternativePath = new AlternativePath() { PathIndex = altindex, TrackCircuitSection = TrackCircuitSection.TrackCircuitList[inf.ReadInt32()], }; } FacingPoint = inf.ReadBoolean(); UsedAlternativePath = inf.ReadInt32(); MovingTableApproachPath = inf.ReadInt32(); }
public override object Clone() { EnumArray newObj = new EnumArray(this); array.CopyTo(newObj.array, 0); return newObj; }
private EnumArray(EnumArray c) : base(c) { array = new _ElementType[c.Count]; }
public async Task ListT_Enum_Test() { /*******************************************************************************************************************/ var xx1 = ""; var enums = new List <AgentLevel> { AgentLevel.CityAgent, AgentLevel.DistiAgent }; // where in -- variable List<enum> var res1 = await Conn.OpenDebug() .Selecter <Agent>() .Where(it => enums.Contains(it.AgentLevel)) .QueryListAsync(); var tuple1 = (XDebug.SQL, XDebug.Parameters); /*******************************************************************************************************************/ var xx2 = ""; // where in -- obj.prop List<enum> var res2 = await Conn.OpenDebug() .Selecter <Agent>() .Where(it => WhereTest.In_List_枚举.Contains(it.AgentLevel)) .QueryListAsync(); var tuple2 = (XDebug.SQL, XDebug.Parameters); /*******************************************************************************************************************/ var xx3 = ""; EnumList = enums; // where in -- this.prop List<enum> var res3 = await Conn.OpenDebug() .Selecter <Agent>() .Where(it => EnumList.Contains(it.AgentLevel)) .QueryListAsync(); var tuple3 = (XDebug.SQL, XDebug.Parameters); Assert.True(res1.Count == res2.Count); Assert.True(res2.Count == res3.Count); Assert.True(res1.Count == 555); /*******************************************************************************************************************/ var xx4 = ""; var names = new List <string> { "黄银凤", "刘建芬" }; // where in -- variable List<string> var res4 = await Conn.OpenDebug() .Selecter <Agent>() .Where(it => names.Contains(it.Name)) .QueryListAsync(); var tuple4 = (XDebug.SQL, XDebug.Parameters); /*******************************************************************************************************************/ var xx5 = ""; // where in -- obj.prop List<string> var res5 = await Conn.OpenDebug() .Selecter <Agent>() .Where(it => WhereTest.In_List_String.Contains(it.Name)) .QueryListAsync(); var tuple5 = (XDebug.SQL, XDebug.Parameters); /*******************************************************************************************************************/ var xx6 = ""; StringList = names; // where in -- this.prop List<string> var res6 = await Conn.OpenDebug() .Selecter <Agent>() .Where(it => StringList.Contains(it.Name)) .QueryListAsync(); var tuple6 = (XDebug.SQL, XDebug.Parameters); Assert.True(res4.Count == res5.Count); Assert.True(res5.Count == res6.Count); Assert.True(res4.Count == 2); /*******************************************************************************************************************/ await PereValue(); /*******************************************************************************************************************/ var xx7 = ""; // where in -- List<int> init var res7 = await Conn.OpenDebug() .Selecter <Agent>() .Where(it => new List <int> { 5, 10 }.Contains(it.DirectorStarCount)) .QueryListAsync(); var tuple7 = (XDebug.SQL, XDebug.Parameters); /*******************************************************************************************************************/ var xx8 = ""; // where in -- List<long> init var res8 = await Conn.OpenDebug() .Selecter <Agent>() .Where(it => new List <long> { 5, 10 }.Contains(it.DirectorStarCount)) .QueryListAsync(); var tuple8 = (XDebug.SQL, XDebug.Parameters); /*******************************************************************************************************************/ var xx9 = ""; // where in -- List<short> init var res9 = await Conn.OpenDebug() .Selecter <Agent>() .Where(it => new List <short> { 5, 10 }.Contains((short)(it.DirectorStarCount))) .QueryListAsync(); var tuple9 = (XDebug.SQL, XDebug.Parameters); Assert.True(res7.Count == res8.Count); Assert.True(res8.Count == res9.Count); Assert.True(res7.Count == 2); /*******************************************************************************************************************/ var xx10 = ""; // where in -- List<string> init var res10 = await Conn.OpenDebug() .Selecter <Agent>() .Where(it => new List <string> { "黄银凤", "刘建芬" }.Contains(it.Name)) .QueryListAsync(); Assert.True(res10.Count == 2); var tuple10 = (XDebug.SQL, XDebug.Parameters); /*******************************************************************************************************************/ var xx11 = ""; // where in -- List<enum> init var res11 = await Conn.OpenDebug() .Selecter <Agent>() .Where(it => new List <AgentLevel> { AgentLevel.CityAgent, AgentLevel.DistiAgent }.Contains(it.AgentLevel)) .QueryListAsync(); Assert.True(res11.Count == 555); var tuple11 = (XDebug.SQL, XDebug.Parameters); /*******************************************************************************************************************/ var xx12 = ""; var enumArray = new AgentLevel[] { AgentLevel.CityAgent, AgentLevel.DistiAgent }; // where in -- variable enum[] var res12 = await Conn.OpenDebug() .Selecter <Agent>() .Where(it => enumArray.Contains(it.AgentLevel)) .QueryListAsync(); var tuple12 = (XDebug.SQL, XDebug.Parameters); /*******************************************************************************************************************/ var xx13 = ""; // where in -- obj.prop enum[] var res13 = await Conn.OpenDebug() .Selecter <Agent>() .Where(it => WhereTest.In_Array_枚举.Contains(it.AgentLevel)) .QueryListAsync(); var tuple13 = (XDebug.SQL, XDebug.Parameters); /*******************************************************************************************************************/ var xx14 = ""; EnumArray = enumArray; // where in -- this.prop enum[] var res14 = await Conn.OpenDebug() .Selecter <Agent>() .Where(it => EnumArray.Contains(it.AgentLevel)) .QueryListAsync(); var tuple14 = (XDebug.SQL, XDebug.Parameters); Assert.True(res12.Count == res13.Count); Assert.True(res13.Count == res14.Count); Assert.True(res12.Count == 555); /*******************************************************************************************************************/ var xx15 = ""; var nameArray = new string[] { "黄银凤", "刘建芬" }; // where in -- variable string[] var res15 = await Conn.OpenDebug() .Selecter <Agent>() .Where(it => nameArray.Contains(it.Name)) .QueryListAsync(); var tuple15 = (XDebug.SQL, XDebug.Parameters); /*******************************************************************************************************************/ var xx16 = ""; // where in -- obj.prop string[] var res16 = await Conn.OpenDebug() .Selecter <Agent>() .Where(it => WhereTest.In_Array_String.Contains(it.Name)) .QueryListAsync(); var tuple16 = (XDebug.SQL, XDebug.Parameters); /*******************************************************************************************************************/ var xx17 = ""; StringArray = nameArray; // where in -- this.prop string[] var res17 = await Conn.OpenDebug() .Selecter <Agent>() .Where(it => StringArray.Contains(it.Name)) .QueryListAsync(); var tuple17 = (XDebug.SQL, XDebug.Parameters); Assert.True(res15.Count == res16.Count); Assert.True(res16.Count == res17.Count); Assert.True(res15.Count == 2); /*******************************************************************************************************************/ await PereValue(); /*******************************************************************************************************************/ var xx18 = ""; // where in -- int[] init var res18 = await Conn.OpenDebug() .Selecter <Agent>() .Where(it => new int[] { 5, 10 }.Contains(it.DirectorStarCount)) .QueryListAsync(); var tuple18 = (XDebug.SQL, XDebug.Parameters); /*******************************************************************************************************************/ var xx19 = ""; // where in -- long[] init var res19 = await Conn.OpenDebug() .Selecter <Agent>() .Where(it => new long[] { 5L, 10L }.Contains(it.DirectorStarCount)) .QueryListAsync(); var tuple19 = (XDebug.SQL, XDebug.Parameters); /*******************************************************************************************************************/ var xx20 = ""; // where in -- short[] init var res20 = await Conn.OpenDebug() .Selecter <Agent>() .Where(it => new short[] { 5, 10 }.Contains((short)(it.DirectorStarCount))) .QueryListAsync(); var tuple20 = (XDebug.SQL, XDebug.Parameters); Assert.True(res18.Count == res19.Count); Assert.True(res19.Count == res20.Count); Assert.True(res18.Count == 2); /*******************************************************************************************************************/ var xx21 = ""; // where in -- string[] init var res21 = await Conn.OpenDebug() .Selecter <Agent>() .Where(it => new string[] { "黄银凤", "刘建芬" }.Contains(it.Name)) .QueryListAsync(); Assert.True(res21.Count == 2); var tuple21 = (XDebug.SQL, XDebug.Parameters); /*******************************************************************************************************************/ var xx22 = ""; // where in -- enum[] init var res22 = await Conn.OpenDebug() .Selecter <Agent>() .Where(it => new AgentLevel[] { AgentLevel.CityAgent, AgentLevel.DistiAgent }.Contains(it.AgentLevel)) .QueryListAsync(); Assert.True(res22.Count == 555); var tuple22 = (XDebug.SQL, XDebug.Parameters); /*******************************************************************************************************************/ var xx23 = ""; // where in -- enum[] init var res23 = await Conn.OpenDebug() .Joiner <Agent, AgentInventoryRecord>(out var agent, out var record) .From(() => agent) .InnerJoin(() => record) .On(() => agent.Id == record.AgentId) .Where(() => new AgentLevel[] { AgentLevel.CityAgent, AgentLevel.DistiAgent }.Contains(agent.AgentLevel)) .QueryListAsync <Agent>(); Assert.True(res23.Count == 574); var tuple23 = (XDebug.SQL, XDebug.Parameters); /*******************************************************************************************************************/ var xx = ""; }
// subtracts totalEloError from expectedElo public static double CalculateGoodness( Player sideToMove, EnumArray <GameLevel, AggregatedEntry> aggregatedEntries, ChessDBCNScore score, Options options ) { const double maxAllowedPlayerEloDiff = 400; const double maxCalculatedEloDiff = 800; bool useEval = options.EvalWeight > 0.0; bool useGames = options.GamesWeight > 0.0; AggregatedEntry totalEntry = new AggregatedEntry(); foreach (KeyValuePair <GameLevel, AggregatedEntry> e in aggregatedEntries) { totalEntry.Combine(e.Value); } if (useGames && totalEntry.Count == 0) { return(0.0); } if (useEval && score == null && Math.Abs(totalEntry.TotalEloDiff / (double)totalEntry.Count) > maxAllowedPlayerEloDiff) { return(0.0); } double gamesWeight = options.GamesWeight; double evalWeight = options.EvalWeight; double calculateAdjustedPerf(AggregatedEntry e) { if (e.Count > 0) { ulong? lowNThreshold = options.IncreaseErrorBarForLowN ? (ulong?)options.LowN : null; ulong totalWins = e.WinCount; ulong totalDraws = e.DrawCount; ulong totalLosses = e.Count - totalWins - totalDraws; double totalEloError = EloCalculator.Clamp( EloCalculator.EloError99pct(totalWins, totalDraws, totalLosses, lowNThreshold), 2 * maxCalculatedEloDiff ); double totalPerf = (totalWins + totalDraws * options.DrawScore) / e.Count; double expectedTotalPerf = EloCalculator.GetExpectedPerformance(e.TotalEloDiff / (double)e.Count); if (sideToMove == Player.Black) { totalPerf = 1.0 - totalPerf; expectedTotalPerf = 1.0 - expectedTotalPerf; } double adjustedPerf = EloCalculator.GetAdjustedPerformance(totalPerf, expectedTotalPerf, maxCalculatedEloDiff); double expectedElo = EloCalculator.Clamp( EloCalculator.Clamp( EloCalculator.GetEloFromPerformance(adjustedPerf), maxCalculatedEloDiff ) - totalEloError, maxCalculatedEloDiff); adjustedPerf = EloCalculator.GetExpectedPerformance(expectedElo); return(adjustedPerf); } else { return(0.0); } } double adjustedGamesPerf = calculateAdjustedPerf(totalEntry); double gamesGoodness = EloCalculator.Clamp( EloCalculator.GetEloFromPerformance(adjustedGamesPerf), maxCalculatedEloDiff ) * gamesWeight; // If eval is not present then assume 0.5 but reduce it for moves with low game count. // The idea is that we don't want missing eval to penalize common moves. double evalGoodness = ( score != null ? EloCalculator.GetEloFromPerformance(score.Perf) : -EloCalculator.EloError99pct( totalEntry.WinCount, totalEntry.DrawCount, totalEntry.LossCount ) ) * evalWeight; double weightSum = gamesWeight + evalWeight; double goodness = EloCalculator.GetExpectedPerformance((gamesGoodness + evalGoodness) / weightSum); return(goodness); }
public async Task ListT_Enum_Test() { /*******************************************************************************************************************/ var xx1 = ""; var enums = new List <AgentLevel?> { AgentLevel.CityAgent, AgentLevel.DistiAgent }; // where in -- variable List<enum> var res1 = await Conn .Selecter <Agent>() .Where(it => enums.Contains(it.AgentLevel)) .ListAsync(); Assert.True(res1.Count == 555); var tuple1 = (XDebug.SQL, XDebug.Parameters, XDebug.SqlWithParams); /*******************************************************************************************************************/ var xx2 = ""; // where in -- obj.prop List<enum> var res2 = await Conn .Selecter <Agent>() .Where(it => WhereTest.In_List_枚举.Contains(it.AgentLevel)) .ListAsync(); var tuple2 = (XDebug.SQL, XDebug.Parameters); /*******************************************************************************************************************/ var xx3 = ""; EnumList = enums; // where in -- this.prop List<enum> var res3 = await Conn .Selecter <Agent>() .Where(it => EnumList.Contains(it.AgentLevel)) .ListAsync(); var tuple3 = (XDebug.SQL, XDebug.Parameters); Assert.True(res1.Count == res2.Count); Assert.True(res2.Count == res3.Count); Assert.True(res1.Count == 555); /*******************************************************************************************************************/ var xx4 = ""; var names = new List <string> { "黄银凤", "刘建芬" }; // where in -- variable List<string> var res4 = await Conn .Selecter <Agent>() .Where(it => names.Contains(it.Name)) .ListAsync(); var tuple4 = (XDebug.SQL, XDebug.Parameters); /*******************************************************************************************************************/ var xx5 = ""; // where in -- obj.prop List<string> var res5 = await Conn .Selecter <Agent>() .Where(it => WhereTest.In_List_String.Contains(it.Name)) .ListAsync(); var tuple5 = (XDebug.SQL, XDebug.Parameters); /*******************************************************************************************************************/ var xx6 = ""; StringList = names; // where in -- this.prop List<string> var res6 = await Conn .Selecter <Agent>() .Where(it => StringList.Contains(it.Name)) .ListAsync(); var tuple6 = (XDebug.SQL, XDebug.Parameters); Assert.True(res4.Count == res5.Count); Assert.True(res5.Count == res6.Count); Assert.True(res4.Count == 2); /*******************************************************************************************************************/ await PereValue(); /*******************************************************************************************************************/ var xx7 = ""; // where in -- List<int> init var res7 = await Conn .Selecter <Agent>() .Where(it => new List <int> { 5, 10 }.Contains(it.DirectorStarCount)) .ListAsync(); var tuple7 = (XDebug.SQL, XDebug.Parameters); /*******************************************************************************************************************/ var xx8 = ""; // where in -- List<long> init var res8 = await Conn .Selecter <Agent>() .Where(it => new List <long> { 5, 10 }.Contains(it.DirectorStarCount)) .ListAsync(); var tuple8 = (XDebug.SQL, XDebug.Parameters); /*******************************************************************************************************************/ var xx9 = ""; // where in -- List<short> init var res9 = await Conn .Selecter <Agent>() .Where(it => new List <short> { 5, 10 }.Contains((short)(it.DirectorStarCount))) .ListAsync(); var tuple9 = (XDebug.SQL, XDebug.Parameters); Assert.True(res7.Count == res8.Count); Assert.True(res8.Count == res9.Count); Assert.True(res7.Count == 2); /*******************************************************************************************************************/ var xx10 = ""; // where in -- List<string> init var res10 = await Conn .Selecter <Agent>() .Where(it => new List <string> { "黄银凤", "刘建芬" }.Contains(it.Name)) .ListAsync(); Assert.True(res10.Count == 2); var tuple10 = (XDebug.SQL, XDebug.Parameters); /*******************************************************************************************************************/ var xx11 = ""; // where in -- List<enum> init var res11 = await Conn .Selecter <Agent>() .Where(it => new List <AgentLevel?> { AgentLevel.CityAgent, AgentLevel.DistiAgent }.Contains(it.AgentLevel)) .ListAsync(); Assert.True(res11.Count == 555); var tuple11 = (XDebug.SQL, XDebug.Parameters); /*******************************************************************************************************************/ var xx12 = ""; var enumArray = new AgentLevel?[] { AgentLevel.CityAgent, AgentLevel.DistiAgent }; // where in -- variable enum[] var res12 = await Conn .Selecter <Agent>() .Where(it => enumArray.Contains(it.AgentLevel)) .ListAsync(); var tuple12 = (XDebug.SQL, XDebug.Parameters); /*******************************************************************************************************************/ var xx13 = ""; // where in -- obj.prop enum[] var res13 = await Conn .Selecter <Agent>() .Where(it => WhereTest.In_Array_枚举.Contains(it.AgentLevel)) .ListAsync(); var tuple13 = (XDebug.SQL, XDebug.Parameters); /*******************************************************************************************************************/ var xx14 = ""; EnumArray = enumArray; // where in -- this.prop enum[] var res14 = await Conn .Selecter <Agent>() .Where(it => EnumArray.Contains(it.AgentLevel)) .ListAsync(); var tuple14 = (XDebug.SQL, XDebug.Parameters); Assert.True(res12.Count == res13.Count); Assert.True(res13.Count == res14.Count); Assert.True(res12.Count == 555); /*******************************************************************************************************************/ var xx15 = ""; var nameArray = new string[] { "黄银凤", "刘建芬" }; // where in -- variable string[] var res15 = await Conn .Selecter <Agent>() .Where(it => nameArray.Contains(it.Name)) .ListAsync(); var tuple15 = (XDebug.SQL, XDebug.Parameters); /*******************************************************************************************************************/ var xx16 = ""; // where in -- obj.prop string[] var res16 = await Conn .Selecter <Agent>() .Where(it => WhereTest.In_Array_String.Contains(it.Name)) .ListAsync(); var tuple16 = (XDebug.SQL, XDebug.Parameters); /*******************************************************************************************************************/ var xx17 = ""; StringArray = nameArray; // where in -- this.prop string[] var res17 = await Conn .Selecter <Agent>() .Where(it => StringArray.Contains(it.Name)) .ListAsync(); var tuple17 = (XDebug.SQL, XDebug.Parameters); Assert.True(res15.Count == res16.Count); Assert.True(res16.Count == res17.Count); Assert.True(res15.Count == 2); /*******************************************************************************************************************/ await PereValue(); /*******************************************************************************************************************/ var xx18 = ""; // where in -- int[] init var res18 = await Conn .Selecter <Agent>() .Where(it => new int[] { 5, 10 }.Contains(it.DirectorStarCount)) .ListAsync(); var tuple18 = (XDebug.SQL, XDebug.Parameters); /*******************************************************************************************************************/ var xx19 = ""; // where in -- long[] init var res19 = await Conn .Selecter <Agent>() .Where(it => new long[] { 5L, 10L }.Contains(it.DirectorStarCount)) .ListAsync(); var tuple19 = (XDebug.SQL, XDebug.Parameters); /*******************************************************************************************************************/ var xx20 = ""; // where in -- short[] init var res20 = await Conn .Selecter <Agent>() .Where(it => new short[] { 5, 10 }.Contains((short)(it.DirectorStarCount))) .ListAsync(); var tuple20 = (XDebug.SQL, XDebug.Parameters); Assert.True(res18.Count == res19.Count); Assert.True(res19.Count == res20.Count); Assert.True(res18.Count == 2); /*******************************************************************************************************************/ var xx21 = ""; // where in -- string[] init var res21 = await Conn .Selecter <Agent>() .Where(it => new string[] { "黄银凤", "刘建芬" }.Contains(it.Name)) .ListAsync(); Assert.True(res21.Count == 2); var tuple21 = (XDebug.SQL, XDebug.Parameters); /*******************************************************************************************************************/ var xx22 = ""; // where in -- enum[] init var res22 = await Conn .Selecter <Agent>() .Where(it => new AgentLevel?[] { AgentLevel.CityAgent, AgentLevel.DistiAgent }.Contains(it.AgentLevel)) .ListAsync(); Assert.True(res22.Count == 555); var tuple22 = (XDebug.SQL, XDebug.Parameters); /*******************************************************************************************************************/ var xx23 = ""; // where in -- enum[] init var res23 = await Conn .Joiner <Agent, AgentInventoryRecord>(out var agent, out var record) .From(() => agent) .InnerJoin(() => record) .On(() => agent.Id == record.AgentId) .Where(() => new AgentLevel?[] { AgentLevel.CityAgent, AgentLevel.DistiAgent }.Contains(agent.AgentLevel)) .ListAsync <Agent>(); Assert.True(res23.Count == 574); var tuple23 = (XDebug.SQL, XDebug.Parameters); /*******************************************************************************************************************/ var xx24 = ""; var guid241 = Guid.Parse("0048793b-ca61-457e-a2b4-0165442f3684"); var guid242 = Guid.Parse("004f4290-9576-43b9-903f-01654434da0f"); // where in -- string[] init var res24 = await Conn .Selecter <Agent>() .Where(it => new string[] { "黄银凤", "刘建芬" }.Contains(it.Name) || new List <Guid> { guid241, guid242 }.Contains(it.Id)) .ListAsync(); Assert.True(res24.Count == 4); var tuple24 = (XDebug.SQL, XDebug.Parameters, XDebug.SqlWithParams); /*******************************************************************************************************************/ var xx25 = ""; // where in -- string[] init var res25 = await Conn .Selecter <Agent>() .Where(it => new string[] { "刘建芬" }.Contains(it.Name)) .ListAsync(); Assert.True(res25.Count == 1); var tuple25 = (XDebug.SQL, XDebug.Parameters, XDebug.SqlWithParams); /*******************************************************************************************************************/ var xx26 = ""; // where in -- string[] init var res26 = await Conn .Selecter <Agent>() .Where(it => new string[] { "刘建芬" }.Contains(it.Name) || new List <Guid> { guid241 }.Contains(it.Id)) .ListAsync(); Assert.True(res26.Count == 2); var tuple26 = (XDebug.SQL, XDebug.Parameters, XDebug.SqlWithParams); /*******************************************************************************************************************/ var xx27 = ""; try { // where in -- string[] init var res27 = await Conn .Selecter <Agent>() .Where(it => new List <Guid> { }.Contains(it.Id)) .ListAsync(); } catch (Exception ex) { Assert.True(ex.Message.Equals("【new List`1() {}.Contains(it.Id)】 中 集合为空!!!", StringComparison.OrdinalIgnoreCase)); } /*******************************************************************************************************************/ var xx = ""; }
protected bool Equals(SubModel other) { return(string.Equals(Prop1, other.Prop1) && string.Equals(Prop2, other.Prop2) && EnumArray.SequenceEqual(other.EnumArray)); }
public static IEnumerable <UserCommand> GetScanCodeCommands(int scanCode, EnumArray <UserCommandInput, UserCommand> commands) { return(EnumExtension.GetValues <UserCommand>().Where(uc => ((commands[uc] as UserCommandKeyInput)?.ScanCode == scanCode))); }
public void Set(EnumArray <TEnum, T> other) { System.Array.Copy(other.Array, Array, Array.Length); }
public BoardTheme(string path) { try { LightSquare = Image.FromFile(path + "/light_square.png"); DarkSquare = Image.FromFile(path + "/dark_square.png"); Name = System.IO.Path.GetFileName(path.TrimEnd(System.IO.Path.DirectorySeparatorChar)); try { Name = File.ReadAllText(path + "/name"); } catch (Exception) { } Config = BoardThemeConfig.FromJsonFile(path + "/config.json"); } catch (System.IO.FileNotFoundException) { SetDefaultImages(); } try { var lightRimSideLeft = Image.FromFile(path + "/light_rim_side.png"); var lightRimCornerTopLeft = Image.FromFile(path + "/light_rim_corner.png"); var darkRimSideLeft = Image.FromFile(path + "/dark_rim_side.png"); var darkRimCornerTopLeft = Image.FromFile(path + "/dark_rim_corner.png"); LightRimSide = new EnumArray <RimSide, Image>(); DarkRimSide = new EnumArray <RimSide, Image>(); LightRimCorner = new EnumArray <RimCorner, Image>(); DarkRimCorner = new EnumArray <RimCorner, Image>(); LightRimSide[RimSide.Left] = lightRimSideLeft; LightRimSide[RimSide.Right] = (Image)lightRimSideLeft.Clone(); LightRimSide[RimSide.Top] = (Image)lightRimSideLeft.Clone(); LightRimSide[RimSide.Bottom] = (Image)lightRimSideLeft.Clone(); LightRimSide[RimSide.Top].RotateFlip(RotateFlipType.Rotate90FlipNone); LightRimSide[RimSide.Right].RotateFlip(RotateFlipType.Rotate180FlipNone); LightRimSide[RimSide.Bottom].RotateFlip(RotateFlipType.Rotate270FlipNone); DarkRimSide[RimSide.Left] = darkRimSideLeft; DarkRimSide[RimSide.Right] = (Image)darkRimSideLeft.Clone(); DarkRimSide[RimSide.Top] = (Image)darkRimSideLeft.Clone(); DarkRimSide[RimSide.Bottom] = (Image)darkRimSideLeft.Clone(); DarkRimSide[RimSide.Top].RotateFlip(RotateFlipType.Rotate90FlipNone); DarkRimSide[RimSide.Right].RotateFlip(RotateFlipType.Rotate180FlipNone); DarkRimSide[RimSide.Bottom].RotateFlip(RotateFlipType.Rotate270FlipNone); LightRimCorner[RimCorner.TopLeft] = lightRimCornerTopLeft; LightRimCorner[RimCorner.TopRight] = (Image)lightRimCornerTopLeft.Clone(); LightRimCorner[RimCorner.BottomLeft] = (Image)lightRimCornerTopLeft.Clone(); LightRimCorner[RimCorner.BottomRight] = (Image)lightRimCornerTopLeft.Clone(); LightRimCorner[RimCorner.TopRight].RotateFlip(RotateFlipType.Rotate90FlipNone); LightRimCorner[RimCorner.BottomRight].RotateFlip(RotateFlipType.Rotate180FlipNone); LightRimCorner[RimCorner.BottomLeft].RotateFlip(RotateFlipType.Rotate270FlipNone); DarkRimCorner[RimCorner.TopLeft] = darkRimCornerTopLeft; DarkRimCorner[RimCorner.TopRight] = (Image)darkRimCornerTopLeft.Clone(); DarkRimCorner[RimCorner.BottomLeft] = (Image)darkRimCornerTopLeft.Clone(); DarkRimCorner[RimCorner.BottomRight] = (Image)darkRimCornerTopLeft.Clone(); DarkRimCorner[RimCorner.TopRight].RotateFlip(RotateFlipType.Rotate90FlipNone); DarkRimCorner[RimCorner.BottomRight].RotateFlip(RotateFlipType.Rotate180FlipNone); DarkRimCorner[RimCorner.BottomLeft].RotateFlip(RotateFlipType.Rotate270FlipNone); } catch (System.IO.FileNotFoundException) { SetDefaultRimImages(); } }
// multiplies games weight by e^-(elo_error/EloErrorHalfWeight) public static double CalculateGoodnessPrioritizeEval( Player sideToMove, EnumArray <GameLevel, AggregatedEntry> aggregatedEntries, ChessDBCNScore score, Options options ) { const double eloErrorHalfWeight = 100; const double maxAllowedPlayerEloDiff = 400; const double maxCalculatedEloDiff = 800; AggregatedEntry totalEntry = new AggregatedEntry(); foreach (KeyValuePair <GameLevel, AggregatedEntry> e in aggregatedEntries) { totalEntry.Combine(e.Value); } if (score == null && Math.Abs(totalEntry.TotalEloDiff / (double)totalEntry.Count) > maxAllowedPlayerEloDiff) { return(0.0); } double evalWeight = options.EvalWeight; Tuple <double, double> calculateAdjustedPerf(AggregatedEntry e) { ulong? lowNThreshold = options.IncreaseErrorBarForLowN ? (ulong?)options.LowN : null; ulong totalWins = e.WinCount; ulong totalDraws = e.DrawCount; ulong totalLosses = e.Count - totalWins - totalDraws; double totalEloError = EloCalculator.Clamp( EloCalculator.EloError99pct(totalWins, totalDraws, totalLosses, lowNThreshold), 2 * maxCalculatedEloDiff ); double gw = options.GamesWeight * Math.Exp(-(totalEloError / eloErrorHalfWeight)); if (e.Count > 0) { double totalPerf = (totalWins + totalDraws * options.DrawScore) / e.Count; double expectedTotalPerf = EloCalculator.GetExpectedPerformance(e.TotalEloDiff / (double)e.Count); if (sideToMove == Player.Black) { totalPerf = 1.0 - totalPerf; expectedTotalPerf = 1.0 - expectedTotalPerf; } double adjustedPerf = EloCalculator.GetAdjustedPerformance(totalPerf, expectedTotalPerf, maxCalculatedEloDiff); if (score == null) { // If the score is null there's nothing to moderate the bad empirical data. // So we apply the old method to reduce the QI of this move based on elo error. double expectedElo = EloCalculator.Clamp( EloCalculator.Clamp( EloCalculator.GetEloFromPerformance(adjustedPerf), maxCalculatedEloDiff ) - totalEloError, maxCalculatedEloDiff); adjustedPerf = EloCalculator.GetExpectedPerformance(expectedElo); } return(new Tuple <double, double>(gw, adjustedPerf)); } else { return(new Tuple <double, double>(0, 0)); } } (double gamesWeight, double adjustedGamesPerf) = calculateAdjustedPerf(totalEntry); double gamesGoodness = EloCalculator.Clamp( EloCalculator.GetEloFromPerformance(adjustedGamesPerf), maxCalculatedEloDiff ) * gamesWeight; // If eval is not present then assume 0.5 but reduce it for moves with low game count. // The idea is that we don't want missing eval to penalize common moves. double evalGoodness = ( score != null ? EloCalculator.GetEloFromPerformance(score.Perf) : -EloCalculator.EloError99pct( totalEntry.WinCount, totalEntry.DrawCount, totalEntry.LossCount ) ) * evalWeight; double weightSum = gamesWeight + evalWeight; double goodness = EloCalculator.GetExpectedPerformance((gamesGoodness + evalGoodness) / weightSum); return(goodness); }
public async Task History() { var enums = new List <AgentLevel?> { AgentLevel.CityAgent, AgentLevel.DistiAgent }; /*******************************************************************************************************************/ xx = string.Empty; EnumList = enums; // where in -- this.prop List<enum> var res3 = await Conn .Queryer <Agent>() .Where(it => EnumList.Contains(it.AgentLevel)) .QueryListAsync(); Assert.True(res3.Count == 555); /*******************************************************************************************************************/ xx = string.Empty; var names = new List <string> { "黄银凤", "刘建芬" }; // where in -- variable List<string> var res4 = await Conn .Queryer <Agent>() .Where(it => names.Contains(it.Name)) .QueryListAsync(); /*******************************************************************************************************************/ xx = string.Empty; StringList = names; // where in -- this.prop List<string> var res6 = await Conn .Queryer <Agent>() .Where(it => StringList.Contains(it.Name)) .QueryListAsync(); Assert.True(res4.Count == res6.Count); Assert.True(res4.Count == 2); /*******************************************************************************************************************/ await PereValue(); /*******************************************************************************************************************/ xx = string.Empty; // where in -- List<int> init var res7 = await Conn .Queryer <Agent>() .Where(it => new List <int> { 5, 10 }.Contains(it.DirectorStarCount)) .QueryListAsync(); /*******************************************************************************************************************/ xx = string.Empty; // where in -- List<long> init var res8 = await Conn .Queryer <Agent>() .Where(it => new List <long> { 5, 10 }.Contains(it.DirectorStarCount)) .QueryListAsync(); /*******************************************************************************************************************/ xx = string.Empty; // where in -- List<short> init var res9 = await Conn .Queryer <Agent>() .Where(it => new List <short> { 5, 10 }.Contains((short)(it.DirectorStarCount))) .QueryListAsync(); Assert.True(res7.Count == res8.Count); Assert.True(res8.Count == res9.Count); Assert.True(res7.Count == 2); /*******************************************************************************************************************/ xx = string.Empty; // where in -- List<string> init var res10 = await Conn .Queryer <Agent>() .Where(it => new List <string> { "黄银凤", "刘建芬" }.Contains(it.Name)) .QueryListAsync(); Assert.True(res10.Count == 2); /*******************************************************************************************************************/ xx = string.Empty; // where in -- List<enum> init var res11 = await Conn .Queryer <Agent>() .Where(it => new List <AgentLevel?> { AgentLevel.CityAgent, AgentLevel.DistiAgent }.Contains(it.AgentLevel)) .QueryListAsync(); Assert.True(res11.Count == 555); /*******************************************************************************************************************/ var enumArray = new AgentLevel?[] { AgentLevel.CityAgent, AgentLevel.DistiAgent }; xx = string.Empty; // where in -- obj.prop enum[] var res13 = await Conn .Queryer <Agent>() .Where(it => WhereTest.In_Array_枚举.Contains(it.AgentLevel)) .QueryListAsync(); /*******************************************************************************************************************/ xx = string.Empty; EnumArray = enumArray; // where in -- this.prop enum[] var res14 = await Conn .Queryer <Agent>() .Where(it => EnumArray.Contains(it.AgentLevel)) .QueryListAsync(); Assert.True(res13.Count == res14.Count); Assert.True(res13.Count == 555); /*******************************************************************************************************************/ xx = string.Empty; var nameArray = new string[] { "黄银凤", "刘建芬" }; // where in -- variable string[] var res15 = await Conn .Queryer <Agent>() .Where(it => nameArray.Contains(it.Name)) .QueryListAsync(); /*******************************************************************************************************************/ xx = string.Empty; // where in -- obj.prop string[] var res16 = await Conn .Queryer <Agent>() .Where(it => WhereTest.In_Array_String.Contains(it.Name)) .QueryListAsync(); /*******************************************************************************************************************/ xx = string.Empty; StringArray = nameArray; // where in -- this.prop string[] var res17 = await Conn .Queryer <Agent>() .Where(it => StringArray.Contains(it.Name)) .QueryListAsync(); Assert.True(res15.Count == res16.Count); Assert.True(res16.Count == res17.Count); Assert.True(res15.Count == 2); /*******************************************************************************************************************/ await PereValue(); /*******************************************************************************************************************/ xx = string.Empty; // where in -- int[] init var res18 = await Conn .Queryer <Agent>() .Where(it => new int[] { 5, 10 }.Contains(it.DirectorStarCount)) .QueryListAsync(); /*******************************************************************************************************************/ var xx19 = string.Empty; // where in -- long[] init var res19 = await Conn .Queryer <Agent>() .Where(it => new long[] { 5L, 10L }.Contains(it.DirectorStarCount)) .QueryListAsync(); /*******************************************************************************************************************/ xx = string.Empty; // where in -- short[] init var res20 = await Conn .Queryer <Agent>() .Where(it => new short[] { 5, 10 }.Contains((short)(it.DirectorStarCount))) .QueryListAsync(); Assert.True(res18.Count == res19.Count); Assert.True(res19.Count == res20.Count); Assert.True(res18.Count == 2); /*******************************************************************************************************************/ xx = string.Empty; // where in -- string[] init var res21 = await Conn .Queryer <Agent>() .Where(it => new string[] { "黄银凤", "刘建芬" }.Contains(it.Name)) .QueryListAsync(); Assert.True(res21.Count == 2); /*******************************************************************************************************************/ var xx22 = string.Empty; // where in -- enum[] init var res22 = await Conn .Queryer <Agent>() .Where(it => new AgentLevel?[] { AgentLevel.CityAgent, AgentLevel.DistiAgent }.Contains(it.AgentLevel)) .QueryListAsync(); Assert.True(res22.Count == 555); /*******************************************************************************************************************/ var guid241 = Guid.Parse("0048793b-ca61-457e-a2b4-0165442f3684"); var guid242 = Guid.Parse("004f4290-9576-43b9-903f-01654434da0f"); // where in -- string[] init var res24 = await Conn .Queryer <Agent>() .Where(it => new string[] { "黄银凤", "刘建芬" }.Contains(it.Name) || new List <Guid> { guid241, guid242 }.Contains(it.Id)) .QueryListAsync(); Assert.True(res24.Count == 4); /*******************************************************************************************************************/ var xx25 = string.Empty; // where in -- string[] init var res25 = await Conn .Queryer <Agent>() .Where(it => new string[] { "刘建芬" }.Contains(it.Name)) .QueryListAsync(); Assert.True(res25.Count == 1); /*******************************************************************************************************************/ var xx26 = string.Empty; // where in -- string[] init var res26 = await Conn .Queryer <Agent>() .Where(it => new string[] { "刘建芬" }.Contains(it.Name) || new List <Guid> { guid241 }.Contains(it.Id)) .QueryListAsync(); Assert.True(res26.Count == 2); /*******************************************************************************************************************/ var xx27 = string.Empty; try { // where in -- string[] init var res27 = await Conn .Queryer <Agent>() .Where(it => new List <Guid> { }.Contains(it.Id)) .QueryListAsync(); } catch (Exception ex) { var errStr = "【ERR-050】 -- [[【new List`1() {}.Contains(it.Id)】 中 集合为空!!!]] ,请 EMail: --> [email protected] <--"; Assert.Equal(errStr, ex.Message, ignoreCase: true); } /*******************************************************************************************************************/ xx = string.Empty; }
private static void InitializeCommands(EnumArray <UserCommandInput, UserCommand> commands) { // All UserCommandModifierInput commands go here. commands[UserCommand.GameSwitchWithMouse] = new UserCommandModifierInput(KeyModifiers.Alt); commands[UserCommand.DisplayNextWindowTab] = new UserCommandModifierInput(KeyModifiers.Shift); commands[UserCommand.CameraMoveFast] = new UserCommandModifierInput(KeyModifiers.Shift); commands[UserCommand.GameSuspendOldPlayer] = new UserCommandModifierInput(KeyModifiers.Shift); commands[UserCommand.CameraMoveSlow] = new UserCommandModifierInput(KeyModifiers.Control); // Everything else goes here, sorted alphabetically please (and grouped by first word of name). commands[UserCommand.CameraBrakeman] = new UserCommandKeyInput(0x07); commands[UserCommand.CameraBrowseBackwards] = new UserCommandKeyInput(0x4F, KeyModifiers.Shift | KeyModifiers.Alt); commands[UserCommand.CameraBrowseForwards] = new UserCommandKeyInput(0x47, KeyModifiers.Shift | KeyModifiers.Alt); commands[UserCommand.CameraCab] = new UserCommandKeyInput(0x02); commands[UserCommand.CameraToggleThreeDimensionalCab] = new UserCommandKeyInput(0x02, KeyModifiers.Alt); commands[UserCommand.CameraCarFirst] = new UserCommandKeyInput(0x47, KeyModifiers.Alt); commands[UserCommand.CameraCarLast] = new UserCommandKeyInput(0x4F, KeyModifiers.Alt); commands[UserCommand.CameraCarNext] = new UserCommandKeyInput(0x49, KeyModifiers.Alt); commands[UserCommand.CameraCarPrevious] = new UserCommandKeyInput(0x51, KeyModifiers.Alt); commands[UserCommand.CameraFree] = new UserCommandKeyInput(0x09); commands[UserCommand.CameraHeadOutBackward] = new UserCommandKeyInput(0x4F); commands[UserCommand.CameraHeadOutForward] = new UserCommandKeyInput(0x47); commands[UserCommand.CameraJumpBackPlayer] = new UserCommandKeyInput(0x0A); commands[UserCommand.CameraJumpingTrains] = new UserCommandKeyInput(0x0A, KeyModifiers.Alt); commands[UserCommand.CameraJumpSeeSwitch] = new UserCommandKeyInput(0x22, KeyModifiers.Control | KeyModifiers.Alt); commands[UserCommand.CameraOutsideFront] = new UserCommandKeyInput(0x03); commands[UserCommand.CameraOutsideRear] = new UserCommandKeyInput(0x04); commands[UserCommand.CameraPanDown] = new UserCommandModifiableKeyInput(0x50, commands[UserCommand.CameraMoveFast], commands[UserCommand.CameraMoveSlow]); commands[UserCommand.CameraPanLeft] = new UserCommandModifiableKeyInput(0x4B, commands[UserCommand.CameraMoveFast], commands[UserCommand.CameraMoveSlow]); commands[UserCommand.CameraPanRight] = new UserCommandModifiableKeyInput(0x4D, commands[UserCommand.CameraMoveFast], commands[UserCommand.CameraMoveSlow]); commands[UserCommand.CameraPanUp] = new UserCommandModifiableKeyInput(0x48, commands[UserCommand.CameraMoveFast], commands[UserCommand.CameraMoveSlow]); commands[UserCommand.CameraPassenger] = new UserCommandKeyInput(0x06); commands[UserCommand.CameraPreviousFree] = new UserCommandKeyInput(0x09, KeyModifiers.Shift); commands[UserCommand.CameraReset] = new UserCommandKeyInput(0x09, KeyModifiers.Control); commands[UserCommand.CameraRotateDown] = new UserCommandModifiableKeyInput(0x50, KeyModifiers.Alt, commands[UserCommand.CameraMoveFast], commands[UserCommand.CameraMoveSlow]); commands[UserCommand.CameraRotateLeft] = new UserCommandModifiableKeyInput(0x4B, KeyModifiers.Alt, commands[UserCommand.CameraMoveFast], commands[UserCommand.CameraMoveSlow]); commands[UserCommand.CameraRotateRight] = new UserCommandModifiableKeyInput(0x4D, KeyModifiers.Alt, commands[UserCommand.CameraMoveFast], commands[UserCommand.CameraMoveSlow]); commands[UserCommand.CameraRotateUp] = new UserCommandModifiableKeyInput(0x48, KeyModifiers.Alt, commands[UserCommand.CameraMoveFast], commands[UserCommand.CameraMoveSlow]); commands[UserCommand.CameraScrollLeft] = new UserCommandModifiableKeyInput(0x4B, KeyModifiers.Alt); commands[UserCommand.CameraScrollRight] = new UserCommandModifiableKeyInput(0x4D, KeyModifiers.Alt); commands[UserCommand.CameraChangePassengerViewPoint] = new UserCommandKeyInput(0x06, KeyModifiers.Shift); commands[UserCommand.CameraToggleLetterboxCab] = new UserCommandKeyInput(0x02, KeyModifiers.Control); commands[UserCommand.CameraToggleShowCab] = new UserCommandKeyInput(0x02, KeyModifiers.Shift); commands[UserCommand.CameraTrackside] = new UserCommandKeyInput(0x05);; commands[UserCommand.CameraSpecialTracksidePoint] = new UserCommandKeyInput(0x05, KeyModifiers.Shift); commands[UserCommand.CameraVibrate] = new UserCommandKeyInput(0x2F, KeyModifiers.Control); commands[UserCommand.CameraZoomIn] = new UserCommandModifiableKeyInput(0x49, commands[UserCommand.CameraMoveFast], commands[UserCommand.CameraMoveSlow]); commands[UserCommand.CameraZoomOut] = new UserCommandModifiableKeyInput(0x51, commands[UserCommand.CameraMoveFast], commands[UserCommand.CameraMoveSlow]); commands[UserCommand.ControlAIFireOn] = new UserCommandKeyInput(0x23, KeyModifiers.Alt); commands[UserCommand.ControlAIFireOff] = new UserCommandKeyInput(0x23, KeyModifiers.Control); commands[UserCommand.ControlAIFireReset] = new UserCommandKeyInput(0x23, KeyModifiers.Control | KeyModifiers.Alt); commands[UserCommand.ControlAlerter] = new UserCommandKeyInput(0x2C); commands[UserCommand.ControlBailOff] = new UserCommandKeyInput(0x35); commands[UserCommand.ControlBell] = new UserCommandKeyInput(0x30); commands[UserCommand.ControlBellToggle] = new UserCommandKeyInput(0x30, KeyModifiers.Shift); commands[UserCommand.ControlBlowerDecrease] = new UserCommandKeyInput(0x31, KeyModifiers.Shift); commands[UserCommand.ControlBlowerIncrease] = new UserCommandKeyInput(0x31); commands[UserCommand.ControlSteamHeatDecrease] = new UserCommandKeyInput(0x20, KeyModifiers.Alt); commands[UserCommand.ControlSteamHeatIncrease] = new UserCommandKeyInput(0x16, KeyModifiers.Alt); commands[UserCommand.ControlBrakeHoseConnect] = new UserCommandKeyInput(0x2B); commands[UserCommand.ControlBrakeHoseDisconnect] = new UserCommandKeyInput(0x2B, KeyModifiers.Shift); commands[UserCommand.ControlCabRadio] = new UserCommandKeyInput(0x13, KeyModifiers.Alt); commands[UserCommand.ControlCircuitBreakerClosingOrder] = new UserCommandKeyInput(0x18); commands[UserCommand.ControlCircuitBreakerOpeningOrder] = new UserCommandKeyInput(0x17); commands[UserCommand.ControlCircuitBreakerClosingAuthorization] = new UserCommandKeyInput(0x18, KeyModifiers.Shift); commands[UserCommand.ControlCylinderCocks] = new UserCommandKeyInput(0x2E); commands[UserCommand.ControlLargeEjectorIncrease] = new UserCommandKeyInput(0x24, KeyModifiers.Control); commands[UserCommand.ControlLargeEjectorDecrease] = new UserCommandKeyInput(0x24, KeyModifiers.Alt); commands[UserCommand.ControlSmallEjectorIncrease] = new UserCommandKeyInput(0x24); commands[UserCommand.ControlSmallEjectorDecrease] = new UserCommandKeyInput(0x24, KeyModifiers.Shift); commands[UserCommand.ControlVacuumExhausterPressed] = new UserCommandKeyInput(0x24); commands[UserCommand.ControlCylinderCompound] = new UserCommandKeyInput(0x19); commands[UserCommand.ControlDamperDecrease] = new UserCommandKeyInput(0x32, KeyModifiers.Shift); commands[UserCommand.ControlDamperIncrease] = new UserCommandKeyInput(0x32); commands[UserCommand.ControlDieselHelper] = new UserCommandKeyInput(0x15, KeyModifiers.Control); commands[UserCommand.ControlDieselPlayer] = new UserCommandKeyInput(0x15, KeyModifiers.Shift); commands[UserCommand.ControlDoorLeft] = new UserCommandKeyInput(0x10); commands[UserCommand.ControlDoorRight] = new UserCommandKeyInput(0x10, KeyModifiers.Shift); commands[UserCommand.ControlDynamicBrakeDecrease] = new UserCommandKeyInput(0x33); commands[UserCommand.ControlDynamicBrakeIncrease] = new UserCommandKeyInput(0x34); commands[UserCommand.ControlEmergencyPushButton] = new UserCommandKeyInput(0x0E); commands[UserCommand.ControlEngineBrakeDecrease] = new UserCommandKeyInput(0x1A); commands[UserCommand.ControlEngineBrakeIncrease] = new UserCommandKeyInput(0x1B); commands[UserCommand.ControlBrakemanBrakeDecrease] = new UserCommandKeyInput(0x1A, KeyModifiers.Alt); commands[UserCommand.ControlBrakemanBrakeIncrease] = new UserCommandKeyInput(0x1B, KeyModifiers.Alt); commands[UserCommand.ControlFireboxClose] = new UserCommandKeyInput(0x21, KeyModifiers.Shift); commands[UserCommand.ControlFireboxOpen] = new UserCommandKeyInput(0x21); commands[UserCommand.ControlFireShovelFull] = new UserCommandKeyInput(0x13, KeyModifiers.Control); commands[UserCommand.ControlFiring] = new UserCommandKeyInput(0x21, KeyModifiers.Control); commands[UserCommand.ControlFiringRateDecrease] = new UserCommandKeyInput(0x13, KeyModifiers.Shift); commands[UserCommand.ControlFiringRateIncrease] = new UserCommandKeyInput(0x13); commands[UserCommand.ControlGearDown] = new UserCommandKeyInput(0x12, KeyModifiers.Shift); commands[UserCommand.ControlGearUp] = new UserCommandKeyInput(0x12); commands[UserCommand.ControlGeneric1] = new UserCommandKeyInput(0x33, KeyModifiers.Control); commands[UserCommand.ControlGeneric2] = new UserCommandKeyInput(0x34, KeyModifiers.Control); commands[UserCommand.ControlHandbrakeFull] = new UserCommandKeyInput(0x28, KeyModifiers.Shift); commands[UserCommand.ControlHandbrakeNone] = new UserCommandKeyInput(0x27, KeyModifiers.Shift); commands[UserCommand.ControlHeadlightDecrease] = new UserCommandKeyInput(0x23, KeyModifiers.Shift); commands[UserCommand.ControlHeadlightIncrease] = new UserCommandKeyInput(0x23); commands[UserCommand.ControlHorn] = new UserCommandKeyInput(0x39); commands[UserCommand.ControlImmediateRefill] = new UserCommandKeyInput(0x14, KeyModifiers.Shift); commands[UserCommand.ControlInitializeBrakes] = new UserCommandKeyInput(0x35, KeyModifiers.Shift); commands[UserCommand.ControlInjector1] = new UserCommandKeyInput(0x17); commands[UserCommand.ControlInjector1Decrease] = new UserCommandKeyInput(0x25, KeyModifiers.Shift); commands[UserCommand.ControlInjector1Increase] = new UserCommandKeyInput(0x25); commands[UserCommand.ControlInjector2] = new UserCommandKeyInput(0x18); commands[UserCommand.ControlInjector2Decrease] = new UserCommandKeyInput(0x26, KeyModifiers.Shift); commands[UserCommand.ControlInjector2Increase] = new UserCommandKeyInput(0x26); commands[UserCommand.ControlBlowdownValve] = new UserCommandKeyInput(0x2E, KeyModifiers.Shift); commands[UserCommand.ControlLight] = new UserCommandKeyInput(0x26); commands[UserCommand.ControlMirror] = new UserCommandKeyInput(0x2F, KeyModifiers.Shift); commands[UserCommand.ControlPantograph1] = new UserCommandKeyInput(0x19); commands[UserCommand.ControlPantograph2] = new UserCommandKeyInput(0x19, KeyModifiers.Shift); commands[UserCommand.ControlPantograph3] = new UserCommandKeyInput(0x19, KeyModifiers.Control); commands[UserCommand.ControlPantograph4] = new UserCommandKeyInput(0x19, KeyModifiers.Shift | KeyModifiers.Control); commands[UserCommand.ControlOdoMeterShowHide] = new UserCommandKeyInput(0x2C, KeyModifiers.Shift); commands[UserCommand.ControlOdoMeterReset] = new UserCommandKeyInput(0x2C, KeyModifiers.Control); commands[UserCommand.ControlOdoMeterDirection] = new UserCommandKeyInput(0x2C, KeyModifiers.Control | KeyModifiers.Shift); commands[UserCommand.ControlRefill] = new UserCommandKeyInput(0x14); commands[UserCommand.ControlRetainersOff] = new UserCommandKeyInput(0x1A, KeyModifiers.Shift); commands[UserCommand.ControlRetainersOn] = new UserCommandKeyInput(0x1B, KeyModifiers.Shift); commands[UserCommand.ControlReverserBackward] = new UserCommandKeyInput(0x1F); commands[UserCommand.ControlReverserForward] = new UserCommandKeyInput(0x11); commands[UserCommand.ControlSander] = new UserCommandKeyInput(0x2D); commands[UserCommand.ControlSanderToggle] = new UserCommandKeyInput(0x2D, KeyModifiers.Shift); commands[UserCommand.ControlThrottleDecrease] = new UserCommandKeyInput(0x1E); commands[UserCommand.ControlThrottleIncrease] = new UserCommandKeyInput(0x20); commands[UserCommand.ControlThrottleZero] = new UserCommandKeyInput(0x1E, KeyModifiers.Control); commands[UserCommand.ControlTrainBrakeDecrease] = new UserCommandKeyInput(0x27); commands[UserCommand.ControlTrainBrakeIncrease] = new UserCommandKeyInput(0x28); commands[UserCommand.ControlTrainBrakeZero] = new UserCommandKeyInput(0x27, KeyModifiers.Control); commands[UserCommand.ControlTurntableClockwise] = new UserCommandKeyInput(0x2E, KeyModifiers.Alt); commands[UserCommand.ControlTurntableCounterclockwise] = new UserCommandKeyInput(0x2E, KeyModifiers.Control); commands[UserCommand.ControlWaterScoop] = new UserCommandKeyInput(0x15); commands[UserCommand.ControlWiper] = new UserCommandKeyInput(0x2F); commands[UserCommand.DebugClockBackwards] = new UserCommandKeyInput(0x0C); commands[UserCommand.DebugClockForwards] = new UserCommandKeyInput(0x0D); commands[UserCommand.DebugDumpKeymap] = new UserCommandKeyInput(0x3B, KeyModifiers.Alt); commands[UserCommand.DebugFogDecrease] = new UserCommandKeyInput(0x0C, KeyModifiers.Shift); commands[UserCommand.DebugFogIncrease] = new UserCommandKeyInput(0x0D, KeyModifiers.Shift); commands[UserCommand.DebugLockShadows] = new UserCommandKeyInput(0x1F, KeyModifiers.Control | KeyModifiers.Alt); commands[UserCommand.DebugLogger] = new UserCommandKeyInput(0x58); commands[UserCommand.DebugLogRenderFrame] = new UserCommandKeyInput(0x58, KeyModifiers.Alt); commands[UserCommand.DebugOvercastDecrease] = new UserCommandKeyInput(0x0C, KeyModifiers.Control); commands[UserCommand.DebugOvercastIncrease] = new UserCommandKeyInput(0x0D, KeyModifiers.Control); commands[UserCommand.DebugPhysicsForm] = new UserCommandKeyInput(0x3D, KeyModifiers.Alt); commands[UserCommand.DebugPrecipitationDecrease] = new UserCommandKeyInput(0x0C, KeyModifiers.Alt); commands[UserCommand.DebugPrecipitationIncrease] = new UserCommandKeyInput(0x0D, KeyModifiers.Alt); commands[UserCommand.DebugPrecipitationLiquidityDecrease] = new UserCommandKeyInput(0x0C, KeyModifiers.Control); commands[UserCommand.DebugPrecipitationLiquidityIncrease] = new UserCommandKeyInput(0x0D, KeyModifiers.Control); commands[UserCommand.DebugResetWheelSlip] = new UserCommandKeyInput(0x2D, KeyModifiers.Alt); commands[UserCommand.DebugSignalling] = new UserCommandKeyInput(0x57, KeyModifiers.Control | KeyModifiers.Alt); commands[UserCommand.DebugSoundForm] = new UserCommandKeyInput(0x1F, KeyModifiers.Alt); commands[UserCommand.DebugSpeedDown] = new UserCommandKeyInput(0x51, KeyModifiers.Control | KeyModifiers.Alt); commands[UserCommand.DebugSpeedReset] = new UserCommandKeyInput(0x47, KeyModifiers.Control | KeyModifiers.Alt); commands[UserCommand.DebugSpeedUp] = new UserCommandKeyInput(0x49, KeyModifiers.Control | KeyModifiers.Alt); commands[UserCommand.DebugToggleAdvancedAdhesion] = new UserCommandKeyInput(0x2D, KeyModifiers.Control | KeyModifiers.Alt); commands[UserCommand.DebugTracks] = new UserCommandKeyInput(0x40, KeyModifiers.Control | KeyModifiers.Alt); commands[UserCommand.DebugWeatherChange] = new UserCommandKeyInput(0x19, KeyModifiers.Alt); commands[UserCommand.DebugToggleConfirmations] = new UserCommandKeyInput(0x44, KeyModifiers.Control | KeyModifiers.Alt); commands[UserCommand.DisplayTrainListWindow] = new UserCommandKeyInput(0x43, KeyModifiers.Alt); commands[UserCommand.DisplayBasicHUDToggle] = new UserCommandKeyInput(0x3F, KeyModifiers.Alt); commands[UserCommand.DisplayCarLabels] = new UserCommandModifiableKeyInput(0x41, commands[UserCommand.DisplayNextWindowTab]); commands[UserCommand.DisplayCompassWindow] = new UserCommandKeyInput(0x0B); commands[UserCommand.DisplayHelpWindow] = new UserCommandModifiableKeyInput(0x3B, commands[UserCommand.DisplayNextWindowTab]); commands[UserCommand.DisplayHUD] = new UserCommandModifiableKeyInput(0x3F, commands[UserCommand.DisplayNextWindowTab]); commands[UserCommand.DisplayTrainDrivingWindow] = new UserCommandModifiableKeyInput(0x3F, KeyModifiers.Control); commands[UserCommand.DisplayNextStationWindow] = new UserCommandKeyInput(0x44); commands[UserCommand.DisplayStationLabels] = new UserCommandModifiableKeyInput(0x40, commands[UserCommand.DisplayNextWindowTab]); commands[UserCommand.DisplaySwitchWindow] = new UserCommandKeyInput(0x42); commands[UserCommand.DisplayTrackMonitorWindow] = new UserCommandModifiableKeyInput(0x3E, commands[UserCommand.DisplayNextWindowTab]); commands[UserCommand.DisplayTrainOperationsWindow] = new UserCommandKeyInput(0x43); commands[UserCommand.GameAutopilotMode] = new UserCommandKeyInput(0x1E, KeyModifiers.Alt); commands[UserCommand.GameChangeCab] = new UserCommandKeyInput(0x12, KeyModifiers.Control); commands[UserCommand.GameClearSignalBackward] = new UserCommandKeyInput(0x0F, KeyModifiers.Shift); commands[UserCommand.GameClearSignalForward] = new UserCommandKeyInput(0x0F); commands[UserCommand.GameExternalCabController] = new UserCommandKeyInput(0x29); commands[UserCommand.GameFullscreen] = new UserCommandKeyInput(0x1C, KeyModifiers.Alt); commands[UserCommand.GameMultiPlayerDispatcher] = new UserCommandKeyInput(0x0A, KeyModifiers.Control); commands[UserCommand.GameMultiPlayerTexting] = new UserCommandKeyInput(0x14, KeyModifiers.Control); commands[UserCommand.GamePause] = new UserCommandKeyInput(Keys.Pause); commands[UserCommand.GamePauseMenu] = new UserCommandKeyInput(0x01); commands[UserCommand.GameQuit] = new UserCommandKeyInput(0x3E, KeyModifiers.Alt); commands[UserCommand.GameRequestControl] = new UserCommandKeyInput(0x12, KeyModifiers.Alt); commands[UserCommand.GameResetSignalBackward] = new UserCommandKeyInput(0x0F, KeyModifiers.Control | KeyModifiers.Shift); commands[UserCommand.GameResetSignalForward] = new UserCommandKeyInput(0x0F, KeyModifiers.Control); commands[UserCommand.GameSave] = new UserCommandKeyInput(0x3C); commands[UserCommand.GameScreenshot] = new UserCommandKeyInput(Keys.PrintScreen); commands[UserCommand.GameSignalPicked] = new UserCommandKeyInput(0x22, KeyModifiers.Control); commands[UserCommand.GameSwitchAhead] = new UserCommandKeyInput(0x22); commands[UserCommand.GameSwitchBehind] = new UserCommandKeyInput(0x22, KeyModifiers.Shift); commands[UserCommand.GameSwitchManualMode] = new UserCommandKeyInput(0x32, KeyModifiers.Control); commands[UserCommand.GameSwitchPicked] = new UserCommandKeyInput(0x22, KeyModifiers.Alt); commands[UserCommand.GameUncoupleWithMouse] = new UserCommandKeyInput(0x16); }
protected static EnumArray <T, TEnum> InitializeEnumArray <T, TEnum>(Type expectedType, EnumArray <T, TEnum> defaultValues, string[] values) where TEnum : Enum { if (null == values) { throw new ArgumentNullException(nameof(values)); } if (null == defaultValues) { throw new ArgumentNullException(nameof(defaultValues)); } if (null == expectedType) { throw new ArgumentNullException(nameof(expectedType)); } Type[] genericArguments = expectedType.GenericTypeArguments; Debug.Assert(genericArguments.Length == 2 && genericArguments[1].IsEnum); Type enumType = genericArguments[1]; foreach (string value in values) { string[] enumValues = value.Split('=', StringSplitOptions.RemoveEmptyEntries); if (enumValues.Length == 2) { dynamic enumIndex = Enum.Parse(enumType, enumValues[0]); if (SettingsBase.TryParseValues(genericArguments[0], enumValues[1], out dynamic result)) { defaultValues[enumIndex] = result; } } } return(defaultValues); }
protected abstract void SetSettingValue <T, TEnum>(string name, EnumArray <T, TEnum> value) where TEnum : Enum;