public Tuple <string, int> GetValidKeyResponse(List <string> validKeys) { // same as above, but only keys from the validKeys list will be accepted // program will not proceed until a correct key is pressed so make sure the user knows what to do if (validKeys.Count == 0) { return(null); } parentPage.Movable = false; var watch = System.Diagnostics.Stopwatch.StartNew(); CurrentKey = ""; bool stillTesting = true; while (stillTesting) { Wait(100); if (CurrentKey.Length == 2 && CurrentKey[0] == 'D') { CurrentKey = CurrentKey.Remove(0, 1); } foreach (string vk in validKeys) { if (CurrentKey == vk) { stillTesting = false; break; } } } watch.Stop(); parentPage.Movable = true; return(new Tuple <string, int>(CurrentKey, (int)watch.ElapsedMilliseconds)); }
/// <summary> /// If the sprite has animations for walking in the /// four directions then it switches between the /// animations depending on the direction /// </summary> public override void Update(GameTime gameTime) { PreviousKey = CurrentKey; CurrentKey = Keyboard.GetState(); IsActive = false; Vector2 newDirection = movement.ChangeDirection(CurrentKey); if (newDirection != Vector2.Zero) { Direction = newDirection; IsActive = true; } if (CanWalk) { Walk(); } if (CurrentKey.IsKeyDown(Keys.Space) && PreviousKey.IsKeyUp(Keys.Space) && (BulletController != null)) { BulletController.AddBullet(this); } base.Update(gameTime); }
/// <summary> /// 关联对应的UI /// </summary> public void AttachButton(Button button) { DefaultButton = button; DefaultButton.onClick.RemoveAllListeners(); DefaultButton.onClick.AddListener(BtnClick); DefaultButton.transform.Find("btnTxt").GetComponent <Text>().text = CurrentKey.ToString(); }
public void HandleChannelMessageKeys(int chnl, int NoteID, int Velocity, bool NoteOn = true) { // // Keyboard Key Pressed Channel Messages // if (NoteID < MinNote || NoteID > MaxNote) { return; } NoteMsg.SetText(NoteID.ToString()); //display note value Entity CurrentKey; //get the key entity CurrentKey = this.FindEntity("pkey" + NoteID.ToString()); if (CurrentKey == null) { return; } SpriteRenderer sp = CurrentKey.GetComponent <SpriteRenderer>(); //sp.renderLayer = -8; //same render layer for black or white key if (NoteOn) { outDevice.Send(new ChannelMessage(ChannelCommand.NoteOn, 0, NoteID, Velocity)); sp.Color = Color.Blue; //current key turned blue } else { outDevice.Send(new ChannelMessage(ChannelCommand.NoteOff, 0, NoteID, Velocity)); sp.Color = Color.Yellow; //current key turned white } }
public virtual void Play(KeyType key, bool forceReset = true) { if (IsDisposed) { return; } IsPlaying = true; if (CurrentTrack == null || !CurrentKey.Equals(key)) { CurrentKey = key; CurrentTrack = Tracks[CurrentKey]; ElapsedTime = 0; if (forceReset) { CurrentTrack.Reset(); } UpdateClippingRegion(); } else if (forceReset) { ElapsedTime = 0; CurrentTrack.Reset(); UpdateClippingRegion(); } }
public byte[] Decrypt(byte[] data) { // Clone the key so that we don't modify it byte[] key = (byte[])CurrentKey.Clone(); // Get the actual data length int dataLength = data.Length - 1; // Security check (padded correctly?) if (dataLength % key.Length != 0) { return(new byte[0]); } // Make a new array to build our return value byte[] returnVal = new byte[data.Length]; returnVal[0] = data[0]; // Go through the data int z = 1; for (int i = 0; i < (dataLength / key.Length); i++) { for (int x = 0; x < key.Length; x++) { returnVal[z] = (byte)(data[z] ^ key[x]); key[x] = data[z++]; } } // Skip the padding bytes byte padding = returnVal[0]; return(returnVal.Skip(1 + padding).ToArray()); }
/// <summary> /// Maps all object from the parent's coordinate system to the global coordinate system. </summary> /// <param name="base"> the root bone to start at. Set it to <code>null</code> to traverse the whole bone hierarchy. </param> public virtual void UnmapObjects(Mainline.Key.BoneRef @base) { int start = @base == null ? -1 : @base.Id - 1; for (int i = start + 1; i < CurrentKey.BoneRefs.Length; i++) { Mainline.Key.BoneRef @ref = CurrentKey.GetBoneRef(i); if (@ref.Parent != @base && @base != null) { continue; } Bone parent = @ref.Parent == null ? this.Root : this.UnmappedTweenedKeys[@ref.Parent.Timeline].Object; UnmappedTweenedKeys[@ref.Timeline].Object.Set(TweenedKeys[@ref.Timeline].Object); UnmappedTweenedKeys[@ref.Timeline].Object.Unmap(parent); UnmapObjects(@ref); } foreach (Mainline.Key.ObjectRef @ref in CurrentKey.ObjectRefs) { if (@ref.Parent != @base && @base != null) { continue; } Bone parent = @ref.Parent == null ? this.Root : this.UnmappedTweenedKeys[@ref.Parent.Timeline].Object; UnmappedTweenedKeys[@ref.Timeline].Object.Set(TweenedKeys[@ref.Timeline].Object); UnmappedTweenedKeys[@ref.Timeline].Object.Unmap(parent); } }
private void iButtonBitmapColor_Click(object sender, EventArgs e) { if (Forms.DlgBox.ShowDialog(iColorDialog) != DialogResult.Cancel) { //Save font settings CurrentKey.FillBitmap(iColorDialog.Color); // SaveModelAndReload(); } }
public IEnumerable <string> DumpValues() { if (Seek(Slice.BeforeAllKeys) == false) { yield break; } do { yield return(CurrentKey.ToString()); } while (MoveNext()); }
/// <summary> /// Sets the given values of the bone with the given name. </summary> /// <param name="name"> the name of the bone </param> /// <param name="x"> the new x value of the bone </param> /// <param name="y"> the new y value of the bone </param> /// <param name="angle"> the new angle of the bone </param> /// <param name="scaleX"> the new scale in x direction of the bone </param> /// <param name="scaleY"> the new scale in y direction of the bone </param> /// <exception cref="SpriterException"> if no bone exists of the given name </exception> public virtual void SetBone(string name, float x, float y, float angle, float scaleX, float scaleY) { int index = GetBoneIndex(name); if (index == -1) { throw new SpriterException("No bone found of name \"" + name + "\""); } Mainline.Key.BoneRef @ref = CurrentKey.GetBoneRef(index); Bone bone = GetBone(index); bone.Set(x, y, angle, scaleX, scaleY, 0f, 0f); UnmapObjects(@ref); }
/// <summary> /// Sets the given values of the object with the given name. </summary> /// <param name="name"> the name of the object </param> /// <param name="x"> the new position in x direction of the object </param> /// <param name="y"> the new position in y direction of the object </param> /// <param name="angle"> the new angle of the object </param> /// <param name="scaleX"> the new scale in x direction of the object </param> /// <param name="scaleY"> the new scale in y direction of the object </param> /// <param name="pivotX"> the new pivot in x direction of the object </param> /// <param name="pivotY"> the new pivot in y direction of the object </param> /// <param name="alpha"> the new alpha value of the object </param> /// <param name="folder"> the new folder index of the object </param> /// <param name="file"> the new file index of the object </param> /// <exception cref="SpriterException"> if no object exists of the given name </exception> public virtual void SetObject(string name, float x, float y, float angle, float scaleX, float scaleY, float pivotX, float pivotY, float alpha, int folder, int file) { int index = GetObjectIndex(name); if (index == -1) { throw new SpriterException("No object found for name \"" + name + "\""); } Mainline.Key.ObjectRef @ref = CurrentKey.GetObjectRef(index); Object @object = GetObject(index); @object.Set(x, y, angle, scaleX, scaleY, pivotX, pivotY, alpha, folder, file); UnmapObjects(@ref); }
public override bool Read() { if (m_index < m_measurements.Length) { var measurement = m_measurements[m_index]; CurrentKey.Timestamp = (ulong)(long)measurement.Timestamp; CurrentKey.PointId = measurement.Key.ID; CurrentValue.Value1 = BitMath.ConvertToUInt64((float)measurement.AdjustedValue); CurrentValue.Value3 = (ulong)measurement.StateFlags; m_index++; return(true); } CurrentKey.Clear(); CurrentValue.Clear(); return(false); }
public byte[] Encrypt(byte[] data) { // Clone the key so that we don't modify it byte[] key = (byte[])CurrentKey.Clone(); // Work out how much padding needs to be done int wholeIterations = data.Length / key.Length; byte padding = (byte)((key.Length * (wholeIterations + 1)) - data.Length); if (padding > 0) { wholeIterations++; } // Create a new array for our return value byte[] returnVal = new byte[data.Length + padding + 1]; returnVal[0] = padding; // Add the padding bytes Random rnd = new Random(); for (int y = 0; y < padding; y++) { returnVal[y + 1] = (byte)rnd.Next(0, 255); } // Add the data Array.Copy(data, 0, returnVal, padding + 1, data.Length); // Encrypt the data and padding bytes int z = 1; for (int i = 0; i < wholeIterations; i++) { for (int x = 0; x < key.Length; x++) { returnVal[z] ^= key[x]; key[x] = returnVal[z++]; } } return(returnVal); }
/// <summary> /// constructor /// </summary> /// <param name="expression"></param> /// <param name="key"></param> public ExpressionModel(string expression, string key) { Expression = expression; Key = key; var keys = Key.Split('.'); CurrentKey = keys.FirstOrDefault(); Match match = Regex.Match(CurrentKey, @"\[\d+\]$"); IsArray = match.Success; if (match.Success) { Index = int.Parse(match.Value.Substring(1, match.Value.Length - 2)); ArrayKey = CurrentKey.Replace($"[{Index}]", ""); } if (CurrentKey != Key) { SubExpression = new ExpressionModel(string.Empty, key.Substring(CurrentKey.Length + 1)); } }
public string GetString() { string s = ""; if (IsCtrl) { s += "Ctrl + "; } if (IsShift) { s += "Shift + "; } if (IsAlt) { s += "Alt + "; } s += CurrentKey.GetString(); return(s); }
protected override void Update(GameTime gameTime) { PreviousKey = CurrentKey; CurrentKey = Keyboard.GetState(); if (_currentState is MenuState) { if (Graphics.IsFullScreen) { Graphics.ToggleFullScreen(); } if (CurrentKey.IsKeyDown(Keys.Escape) && PreviousKey.IsKeyUp(Keys.Escape)) { Exit(); } } if (CurrentKey.IsKeyDown(Keys.F11) && PreviousKey.IsKeyUp(Keys.F11) && !(_currentState is MenuState)) { Graphics.ToggleFullScreen(); } ScreenWidth = GraphicsDevice.Viewport.Bounds.Width; ScreenHeight = GraphicsDevice.Viewport.Bounds.Height; if (_nextState != null) { _currentState = _nextState; _currentState.LoadContent(); _nextState = null; } _currentState.Update(gameTime); _currentState.PostUpdate(gameTime); base.Update(gameTime); }
/*************************** KEYBOARD ***************************/ public Tuple <string, int> GetKeyResponse() { // usage: GetKeyResponse().Item1 will return the capital letter corresponding to the next key pressed by the user // GetKeyResponse().Item2 will return time before getting the response (in milliseconds) // do not use for keys other than A-Z or 0-9 (unless you know their windows codes) parentPage.Movable = false; var watch = System.Diagnostics.Stopwatch.StartNew(); CurrentKey = ""; while (CurrentKey == "") { Wait(100); } watch.Stop(); if (CurrentKey.Length == 2 && CurrentKey[0] == 'D') { CurrentKey = CurrentKey.Remove(0, 1); // remove windows code for digits } parentPage.Movable = true; return(new Tuple <string, int>(CurrentKey, (int)watch.ElapsedMilliseconds)); }
public void HandleOctaveColor(int NoteID) { Color clr = Color.White; Entity CurrentKey; //the key entity SpriteRenderer sp; //the key sprite // // reset all keys to white // int MinNote = 24; int MaxNote = 99; for (int i = MinNote; i <= MaxNote; i++) { CurrentKey = this.FindEntity("pkey" + i.ToString()); if (CurrentKey == null) { continue; } sp = CurrentKey.GetComponent <SpriteRenderer>(); sp.Color = Color.White; //current key turned white } // // turn the octave keys to yellow starting at NoteID // MinNote = NoteID; MaxNote = MinNote + 12; for (int i = MinNote; i <= MaxNote; i++) { CurrentKey = this.FindEntity("pkey" + i.ToString()); if (CurrentKey == null) { continue; } sp = CurrentKey.GetComponent <SpriteRenderer>(); sp.Color = Color.Yellow; //current key turned white } }
/// <summary> /// Добавить значения для экспорта /// </summary> /// <param name="compValues">Значения (админ. + ПБР) для одного из компонентов ТЭЦ</param> /// <param name="date">Дата, за которую получены значения</param> /// <returns>Очередной индекс для запроса значений из БД</returns> public FormChangeMode.KeyDevice AddValueToExportRDGValues(RDGStruct[] compValues, DateTime date) { FormChangeMode.KeyDevice keyRes = new FormChangeMode.KeyDevice(); if ((date - DateTime.MinValue.Date).Days > 0) { if ((_listTECComponentKey.Count > 0) && (!(CurrentKey.Id < 0)) && (!(_listTECComponentKey [0].Id < 0))) { if (CurrentKey.Id - _listTECComponentKey[0].Id == 0) { //??? ошибка не в этом методе //Logging.Logg().Action(string.Format("AdminTS_KomDisp::AddValueToExportRDGValues () - получены значения для [ID={0}, Index={1}, за дату={2}, кол-во={3}] компонента..." // , _listTECComponentKey[0].Id, _listTECComponentKey[0], date, compValues.Length) // , Logging.INDEX_MESSAGE.D_006); actionReport(string.Format("получены значения для [ID={0}, Index={1}, за дату={2}, кол-во={3}] компонента..." , _listTECComponentKey[0].Id, _listTECComponentKey[0], date, compValues.Length)); if ((_msExcelIOExportPBRValues.AddTECComponent(allTECComponents.Find(comp => comp.m_id == CurrentKey.Id)) == 0) && (_msExcelIOExportPBRValues.SetDate(date) == true)) { TECComponentComplete(-1, true); // дубликатов быть не должно (см. добавление элементов) //Console.WriteLine(@"AdminTS_KomDisp::AddValueToExportRDGValues () - обработка элемента=[{0}], остатолось элементов={1}", indxTECComponents, _lisTECComponentIndex.Count); // добавить значения по составному ключу: [DateTime, Index] _msExcelIOExportPBRValues.AddPBRValues(CurrentKey.Id, compValues); keyRes = FirstTECComponentKey; // проверить повторно после удаления элемента if (keyRes == FormChangeMode.KeyDevice.Empty) { // все значения по всем компонентам получены/добавлены Logging.Logg().Action(string.Format("AdminTS_KomDisp::AddValueToExportRDGValues () - получены все значения для всех компонентов...") , Logging.INDEX_MESSAGE.NOT_SET); actionReport(string.Format("получены все значения для всех компонентов...")); _msExcelIOExportPBRValues.Run(); // установить штатного признак завершения keyRes.Id = 0; } else { // очередной индекс компонента для запрооса ; } } else { Logging.Logg().Error(string.Format($"AdminTS_KomDisp::AddValueToExportRDGValues () - компонент с ключом [{CurrentKey.ToString ()}] не может быть добавлен (пред. опреация экспорта не завершена)...") , Logging.INDEX_MESSAGE.NOT_SET); // завершить обработку _listTECComponentKey.Clear(); _msExcelIOExportPBRValues.Abort(); // установить признак аварийного завершения keyRes.Id = -1; errorReport("Экспорт ПБР-значений"); } } else { // текущий индекс и 0-ой элемент массива индексов должны совпадать Logging.Logg().Error(string.Format($"AdminTS_KomDisp::AddValueToExportRDGValues () - текущий ключ <{CurrentKey.ToString ()}> и 0-ой <{_listTECComponentKey [0].ToString()}> элемент массива индексов не совпадают...") , Logging.INDEX_MESSAGE.NOT_SET); } } else { //??? ошибка, т.к. выполнен запрос и получены значения, а индекс компонента не известен Logging.Logg().Error(string.Format("AdminTS_KomDisp::AddValueToExportRDGValues () - получены значения для неизвестного компонента ключ={0}..." , CurrentKey.ToString()) , Logging.INDEX_MESSAGE.NOT_SET); } } else { // дата для полученных значений неизвестна ; } _eventUnitTestExportPBRValuesRequest?.Invoke(keyRes, date, CurrentKey, _listTECComponentKey); return(keyRes); }
/// <summary> /// Returns a time line object at the given index. </summary> /// <param name="index"> the index of the object </param> /// <returns> the object with the given index. </returns> public virtual Object GetObject(int index) { return(this.UnmappedTweenedKeys[CurrentKey.GetObjectRef(index).Timeline].Object); }
public IEnumerable <string> DumpValues() { yield return(CurrentKey.ToString()); }