public void ChangeKeyboard() { var colors = new ColorBuffer[] { Section1, Section2, Section3, Section4 }; KeyboardModel myKeyboardModel = new KeyboardModel { function = "SetEffectALL", mode = "Lighting", effect = "Single", light = Dim, speed = "0", direction = "None", nv_save = "NOT_SAVE", backgroundcolor = 1, alphabet = "", solution = 0, level = 0, powerstatus = 1, type = 0, color = new Color() { isCircular = true, ColorBlocks = colors.Count(), ColorBuffer = colors } }; mQTTDatsService.PublishTopic("Keyboard/Ctrl", myKeyboardModel); }
public Keyboard(KeyboardModel model) { this.model = model; grids = new Dictionary <string, Grid>(); InheritStyleFromApplication(); BuildAndCacheGrid(model.DefaultGrid.Id); }
public void RenderBitmaps() { var visual = new DrawingVisual(); using (var c = visual.RenderOpen()) { c.PushClip(new RectangleGeometry(_rect)); c.DrawRectangle(new SolidColorBrush(Color.FromArgb(0, 0, 0, 0)), null, _rect); if (MouseModel != null) { MouseModel.CloseDrawingContext(); c.DrawRectangle(new VisualBrush(MouseModel), new Pen(), MouseModel.RelativeRect); } if (HeadsetModel != null) { HeadsetModel.CloseDrawingContext(); c.DrawRectangle(new VisualBrush(HeadsetModel), new Pen(), HeadsetModel.RelativeRect); } if (GenericModel != null) { GenericModel.CloseDrawingContext(); c.DrawRectangle(new VisualBrush(GenericModel), new Pen(), GenericModel.RelativeRect); } if (MousematModel != null) { MousematModel.CloseDrawingContext(); c.DrawRectangle(new VisualBrush(MousematModel), new Pen(), MousematModel.RelativeRect); } KeyboardModel.CloseDrawingContext(); c.DrawRectangle(new VisualBrush(KeyboardModel), new Pen(), KeyboardModel.RelativeRect); c.Pop(); } var frameBitmap = ImageUtilities.DrawingVisualToBitmap(visual, _rect); if (MouseModel != null) { MouseBitmap = MouseModel.GetBitmapFromFrame(frameBitmap); } if (HeadsetModel != null) { HeadsetBitmap = HeadsetModel.GetBitmapFromFrame(frameBitmap); } if (GenericModel != null) { GenericBitmap = GenericModel.GetBitmapFromFrame(frameBitmap); } if (MousematModel != null) { MousematBitmap = MousematModel.GetBitmapFromFrame(frameBitmap); } KeyboardBitmap = KeyboardModel.GetBitmapFromFrame(frameBitmap); }
/// <summary> /// Looks for a matching child and position it accordingly. /// </summary> private void PositionModel(KeyboardModel model) { var keyboardModel = transform.Find(model.ToString("G")); Pose keyboardLocalPose; if (KeyboardModelPose.TryGetValue(model, out keyboardLocalPose)) { keyboardModel.localPosition = keyboardLocalPose.position; keyboardModel.localRotation = keyboardLocalPose.rotation; } }
public Keyboard BuildKeyboard() { KeyboardModel model = OpenKeyboardModel(); try { return(new Keyboard(model)); } catch (Exception e) { string msg = "Exception occurred while building keyboard form model!"; logger.Error(ExceptionUtil.Format(msg, e)); throw new Exception(msg); } }
/// <summary> /// 设置gridview值 /// </summary> private void SetGridView() { IList <KeyboardModel> models = new List <KeyboardModel>(); if (curSubModule.GridRow != null) { foreach (var row in curSubModule.GridRow.RowList) { KeyboardModel model = new KeyboardModel(); foreach (var item in row.Params) { do { if (KeyboardConfigParam.Row_AvailableIn.Equals(item.Name)) { model.AvailableIn = item.Value; model.AvailableInList = (from r in item.List select new ComboxModel() { Code = r, Name = r, Type = r }).ToList(); if (this.AvailableInList == null || this.AvailableInList.Count == 0)//设置行中"有效范围"数据源 { this.AvailableInList = (from r in item.List select new ComboxModel() { Code = r, Name = r, Type = r }).ToList(); } break; } if (KeyboardConfigParam.Row_KeyName.Equals(item.Name)) { model.KeyName = item.Value; break; } if (KeyboardConfigParam.Row_KeyValue.Equals(item.Name)) { model.KeyValue = item.Value; break; } if (KeyboardConfigParam.Row_KeyCode.Equals(item.Name)) { model.KeyCode = item.Value; break; } } while (false); } models.Add(model); } } this.KeyboardConfigDataGrid.ItemsSource = models; this.KeyboardConfigDataGrid.Items.Refresh(); }
public Keyboard BuildKeyboard() { try { KeyboardModel model = Creator.CreateDevKeyboard(kbdId); return(new Keyboard(model)); } catch (Exception e) { logger.Error("Exception occurred while building DevKB{0}!\n{1}", kbdId, e); throw; } }
/// <summary> /// 新增按钮点击事件 /// </summary> private void Add_Click(object sender, RoutedEventArgs e) { //获取配置 IList <KeyboardModel> models = this.KeyboardConfigDataGrid.ItemsSource as IList <KeyboardModel>; KeyboardModel model = new KeyboardModel() { AvailableInList = this.AvailableInList }; model.AvailableIn = (model.AvailableInList != null && model.AvailableInList.Count > 0) ? model.AvailableInList.First().Name : string.Empty; models.Add(model); this.KeyboardConfigDataGrid.ItemsSource = models; this.KeyboardConfigDataGrid.Items.Refresh(); }
/// <summary> /// 删除按钮点击事件 /// </summary> private void Detete_Click(object sender, RoutedEventArgs e) { if (this.KeyboardConfigDataGrid.SelectedItem == null) { MessageBox.Show("请选择一条按键配置信息"); } else { List <KeyboardModel> list = this.KeyboardConfigDataGrid.ItemsSource as List <KeyboardModel>; KeyboardModel removeModel = this.KeyboardConfigDataGrid.SelectedItem as KeyboardModel; list.Remove(removeModel); this.KeyboardConfigDataGrid.ItemsSource = list; this.KeyboardConfigDataGrid.Items.Refresh(); } }
public Keyboard(KeyboardModel keyboardModel) { Name = keyboardModel.Name; Price = keyboardModel.Price; IsAvailable = keyboardModel.IsAvailable; Description = keyboardModel.Description; ProducerId = keyboardModel.ProducerId; ManufacturerId = keyboardModel.ManufacturerId; MaterialValue = keyboardModel.Material; ColorValue = keyboardModel.Color; TypeValue = keyboardModel.Type; if (keyboardModel.UserId != null && keyboardModel.UserId != new Guid()) { UserId = keyboardModel.UserId; } }
public async Task <int> AddKeyboard(KeyboardModel keyboardModel, string email) { try { keyboardModel.UserId = (await _context.Users.FirstOrDefaultAsync(user => user.Email == email)).Id; var keyboard = new Keyboard(keyboardModel); await AddGoodData(keyboardModel.ImageIds, keyboard); await _context.Keyboards.AddAsync(keyboard); await _context.SaveChangesAsync(); return(1); } catch (Exception) { throw; } }
/// <summary> /// Gets the openvr device id of the first tracked device whose product id /// corresponds to the required keyboard model. Returns true if such a /// device could be found. /// </summary> /// <param name="model">The keyboard model to look for.</param> /// <param name="deviceId">The id of the first device found if the function /// returned true, -1 otherwise.</param> /// <returns>True if a device could be found, false otherwise.</returns> private bool GetFirstKeyboard(KeyboardModel model, out int deviceId) { // KeyboardModel as a 4-digit hex string pid = "0x" + model.ToString("X").Substring(4); var system = OpenVR.System; if (system != null) { for (uint i = 0; i < OpenVR.k_unMaxTrackedDeviceCount; i++) { // check if a model number exists for device i var error = ETrackedPropertyError.TrackedProp_Success; var capacity = system.GetStringTrackedDeviceProperty(i, ETrackedDeviceProperty.Prop_ModelNumber_String, null, 0, ref error); if (capacity <= 1) { continue; } // get that model number var modelNumber = new System.Text.StringBuilder((int)capacity); system.GetStringTrackedDeviceProperty(i, ETrackedDeviceProperty.Prop_ModelNumber_String, modelNumber, capacity, ref error); // compare against required one // note: a proper regex could be used here to avoid corner cases if (modelNumber.ToString().Contains(logitechVid) && modelNumber.ToString().Contains(pid)) { deviceId = (int)i; return(true); } } } else { Debug.LogError("SteamVR likely not initialized, cannot look for a tracked keyboard."); } deviceId = -1; return(false); }
/// <summary> /// Lists all OpenVR devices connected, looking for a given keyboard model. /// Repeats the search every 2 seconds if no keyboard could be found. /// </summary> /// <param name="model"></param> private IEnumerator LookForKeyboard(KeyboardModel model) { int keyboardIndex; int retryInterval = 1; while (!GetFirstKeyboard(keyboardModel, out keyboardIndex)) { if (retryInterval < 60) { retryInterval *= 2; MrKeyboardWatchdog.Instance.DebugText("'" + keyboardModel + "' not found, will try again in " + retryInterval + "s."); } else { MrKeyboardWatchdog.Instance.DebugText("Keyboard takes a while to appear, you may need to restart SteamVR."); } yield return(new WaitForSeconds(retryInterval)); } svrTrackedObject.SetDeviceIndex(keyboardIndex); PositionModel(model); KeyboardFound = true; Debug.Log("Found the keyboard object."); }
public void Setup() { _keyboardmodel = new StubKeyboardModel(); }
public async Task <int> AddKeyboard([FromBody] KeyboardModel keyboardModel) { return(await _goodsCreator.AddKeyboard(keyboardModel, User.Identity.Name)); }