public int MoonGateLevel = 2;//Domain of the mountainmen public override void Start() { base.Start(); XAxis.enabled = false; YAxis.enabled = false; MouseLookEnabled = false; Cursor.SetCursor(CursorIconBlank, Vector2.zero, CursorMode.ForceSoftware); GuiBase.playerUW = this.gameObject.GetComponent <UWCharacter>(); InteractionMode = UWCharacter.DefaultInteractionMode; //Tells other objects about this component; InventorySlot.playerUW = this.GetComponent <UWCharacter>(); DoorControl.playerUW = this.gameObject.GetComponent <UWCharacter>(); Container.playerUW = this.GetComponent <UWCharacter>(); ContainerOpened.playerUW = this.GetComponent <UWCharacter>(); ActiveRuneSlot.playerUW = this.GetComponent <UWCharacter>(); SpellEffect.playerUW = this.GetComponent <UWCharacter>(); SpellEffectsDisplay.playerUW = this.GetComponent <UWCharacter>(); RuneSlot.playerUW = this.GetComponent <UWCharacter>(); Eyes.playerUW = this.GetComponent <UWCharacter>(); NPC.playerUW = this.GetComponent <UWCharacter>(); object_base.playerUW = this.gameObject.GetComponent <UWCharacter>(); Conversation.playerUW = this.gameObject.GetComponent <UWCharacter>(); StringControl.InitStringController(Application.dataPath + "//..//uw1_strings.txt"); ObjectInteraction.playerUW = this.gameObject.GetComponent <UWCharacter>(); playerHud.InputControl.text = ""; playerHud.InputControl.label.text = ""; playerHud.MessageScroll.Clear(); }
public override UserControl[] GetPropertiesControls() { StringControl control = GetPropertyControl <StringControl>(); control.Title = "Format"; control.Value = Format; var props = base.GetPropertiesControls(); props.OfType <BoolControl>().First().Visibility = System.Windows.Visibility.Collapsed; StringControl[] links = new StringControl[] { GetPropertyControl <StringControl>(), GetPropertyControl <StringControl>(), GetPropertyControl <StringControl>(), GetPropertyControl <StringControl>() }; links[0].Title = "On Start"; links[0].Value = Links[0]; links[0].Tag = 0; links[1].Title = "On Pause"; links[1].Value = Links[1]; links[1].Tag = 1; links[2].Title = "On Stop"; links[2].Value = Links[2]; links[2].Tag = 2; links[3].Title = "On Completion"; links[3].Value = Links.Length > 3 ? Links[3] : ""; links[3].Tag = 3; return(props.Concat(new UserControl[] { control }.Union(links)).ToArray()); }
public AjaxMessage SaveLoginCookie(string loginName, string passWord, bool state) { AjaxMessage ajax = new AjaxMessage(); ajax.IsSuccess = false; ajax.Message = ""; try { if (state) { ajax.IsSuccess = true; StringControl.DeleteCookie("Employee"); HttpCookie cookie = new HttpCookie("Employee"); cookie.Values.Add("Name", loginName); cookie.Values.Add("Pwd", passWord); cookie.Values.Add("State", state.ToString()); cookie.Expires = System.DateTime.Now.AddDays(7); HttpContext.Current.Response.Cookies.Add(cookie); } else { StringControl.DeleteCookie("Employee"); ajax.IsSuccess = true; } } catch (Exception e) { ajax.Message = e.Message; } return(ajax); }
/// <summary> /// 注销当前帐号 /// </summary> public void singOut() { //清除全部Session Session.Abandon(); StringControl.DeleteCookie("Login"); //注销 FormsAuthentication.SignOut(); Response.Write("<script>this.top.window.location.href ='/AdminWorkArea/Login.aspx'</script>"); }
/// <summary> /// 登录 /// </summary> protected void btnLogin_Click(object sender, EventArgs e) { string loginName = Request["loginName"].ToString().Trim(); string passwords = Request["passWord"].ToString().Trim(); bool IsCheck = ChkLoginState.Checked; Sys_Employee m_emp = _empService.GetByLoginName(loginName); if (m_emp != null) { if (m_emp.PassWord != passwords.MD5Hash()) { JavaScriptTools.AlertWindow("密码输入错误", Page); return; } } else { JavaScriptTools.AlertWindow("帐号不存在", Page); return; } #region 利用方法 获取帐号 密码 var form = System.Web.HttpContext.Current.Request.Form; string name = CommonTools.GetKeyValue(form, "loginName"); string password = CommonTools.GetKeyValue(form, "passWord"); #endregion //保存个人登录信息 FormsAuthentication.RedirectFromLoginPage(m_emp.EmployeeID.ToString(), false); //写入登录日志 LoginLog(m_emp); //保存Session UserEmployee user = new UserEmployee(); user.EmployeeId = m_emp.EmployeeID; user.LoginName = m_emp.LoginName; user.EmployeeName = m_emp.EmployeeName; Session["UserInfo"] = user; //html页面验证Cookie是否已经登录(/Script/PublicCommon.js) StringControl.DeleteCookie("Login"); HttpCookie cookie = new HttpCookie("Login"); cookie.Values.Add("EmpId", user.EmployeeId.ToString()); cookie.Expires = System.DateTime.Now.AddDays(7); HttpContext.Current.Response.Cookies.Add(cookie); WebService.Login login = new WebService.Login(); login.SaveLoginCookie(loginName, passwords, IsCheck); }
private void profileListBox_SelectedIndexChanged(object sender, EventArgs e) { customFieldsGroupBox.Controls.Clear(); if (!(profileListBox.SelectedItem is SitecoreProfile profile)) { return; } //Load all the files for the profile var configuration = Utility.GetInstanceConfiguration(profile.Topology, profile.Version); var fields = new List <Field>(); foreach (var field in configuration.FieldSet.Fields) { if (field != null) { fields.Add(field); } } var position = 20; foreach (var field in fields) { switch (field.Type.ToLower()) { case "text": var stringControl = new StringControl(field.Label, field.Map, field.Description) { Top = position, Left = 20 }; stringControl.Value = field.DefaultValue.Replace("[[PREFIX]]", prefixTextBox.Text); stringControl.DefaultValue = field.DefaultValue; prefixTextBox.TextChanged += stringControl.Prefix_Changed; customFieldsGroupBox.Controls.Add(stringControl); break; case "folder": var folderControl = new FolderControl(field.Label, field.Map, field.Description) { Top = position, Left = 20 }; customFieldsGroupBox.Controls.Add(folderControl); break; } position += 25; } }
public override UserControl[] GetPropertiesControls() { StringControl formatString = GetPropertyControl <StringControl>(); formatString.Title = "Format"; formatString.Value = Format; var props = base.GetPropertiesControls(); props.OfType <BoolControl>().First().Visibility = System.Windows.Visibility.Collapsed; StringControl[] links = new StringControl[] { GetPropertyControl <StringControl>(Type + "1"), GetPropertyControl <StringControl>(Type + "2"), GetPropertyControl <StringControl>(Type + "3"), GetPropertyControl <StringControl>(Type + "4") }; var lbl = GetPropertyControl <LabelControl>(); lbl.Title = "Events"; links[0].Title = "On Start"; links[0].Value = Links[0]; //links[0].Tag = "0"; links[1].Title = "On Pause"; links[1].Value = Links[1]; //links[1].Tag = "1"; links[2].Title = "On Stop"; links[2].Value = Links[2]; //links[2].Tag = "2"; links[3].Title = "On Completion"; links[3].Value = Links.Length > 3 ? Links[3] : ""; //links[3].Tag = "3"; return(props.Concat(new UserControl[] { formatString, lbl }.Union(links)).ToArray()); }
public static void GenerateControls(FlowLayoutPanel panel, Block block) { //Suspend panel.SuspendLayout(); //Loop foreach (Field field in block.Fields) { //Prepare Control control = null; //Handle switch (field.Type) { case FieldType.FieldExplanation: control = new ExplanationControl((ExplanationField)field); break; case FieldType.FieldBlock: control = new BlockControl((BlockField)field); break; case FieldType.FieldStruct: control = new StructControl((StructField)field); break; case FieldType.FieldString: case FieldType.FieldLongString: control = new StringControl(field); break; case FieldType.FieldTagReference: control = new TagReferenceControl(field); break; case FieldType.FieldStringId: case FieldType.FieldOldStringId: control = new StringIdControl(field); break; case FieldType.FieldCharInteger: case FieldType.FieldShortInteger: case FieldType.FieldLongInteger: case FieldType.FieldAngle: case FieldType.FieldTag: case FieldType.FieldReal: case FieldType.FieldRealFraction: control = new ValueControl(field); break; case FieldType.FieldCharEnum: case FieldType.FieldEnum: case FieldType.FieldLongEnum: control = new EnumControl(field); break; case FieldType.FieldLongFlags: control = new FlagsControl() { Field = field, Title = field.Name, Information = field.Information, Options = ((LongFlagsField)field).Options.Select(o => o.Name).ToArray(), Details = field.Details, Value = field.Value, ValueChanged = FlagsControl_ValueChanged }; break; case FieldType.FieldWordFlags: control = new FlagsControl() { Field = field, Title = field.Name, Information = field.Information, Options = ((WordFlagsField)field).Options.Select(o => o.Name).ToArray(), Details = field.Details, Value = field.Value, ValueChanged = FlagsControl_ValueChanged }; break; case FieldType.FieldByteFlags: control = new FlagsControl() { Field = field, Title = field.Name, Information = field.Information, Options = ((ByteFlagsField)field).Options.Select(o => o.Name).ToArray(), Details = field.Details, Value = field.Value, ValueChanged = FlagsControl_ValueChanged }; break; case FieldType.FieldShortBounds: control = new RangeControl() { Field = field, Title = field.Name, RangeValue = new string[] { ((ShortBounds)field.Value).Min.ToString(), ((ShortBounds)field.Value).Max.ToString() } }; break; case FieldType.FieldAngleBounds: case FieldType.FieldRealBounds: case FieldType.FieldRealFractionBounds: control = new RangeControl() { Field = field, Title = field.Name, RangeValue = new string[] { ((FloatBounds)field.Value).Min.ToString(), ((FloatBounds)field.Value).Max.ToString() } }; break; case FieldType.FieldPoint2D: control = new TwoTupleControl() { LabelA = "x", LabelB = "y", Field = field, Title = field.Name, TupleValue = new string[] { ((Point2)field.Value).X.ToString(), ((Point2)field.Value).Y.ToString() } }; break; case FieldType.FieldRealPoint2D: control = new TwoTupleControl() { LabelA = "x", LabelB = "y", Field = field, Title = field.Name, TupleValue = new string[] { ((Point2F)field.Value).X.ToString(), ((Point2F)field.Value).Y.ToString() } }; break; case FieldType.FieldRealPoint3D: control = new ThreeTupleControl() { LabelA = "x", LabelB = "y", LabelC = "z", Field = field, Title = field.Name, TupleValue = new string[] { ((Point3F)field.Value).X.ToString(), ((Point3F)field.Value).Y.ToString(), ((Point3F)field.Value).Z.ToString() } }; break; case FieldType.FieldRealVector2D: control = new TwoTupleControl() { LabelA = "i", LabelB = "j", Field = field, Title = field.Name, TupleValue = new string[] { ((Vector2)field.Value).I.ToString(), ((Vector2)field.Value).J.ToString() } }; break; case FieldType.FieldRealVector3D: control = new ThreeTupleControl() { LabelA = "i", LabelB = "j", LabelC = "k", Field = field, Title = field.Name, TupleValue = new string[] { ((Vector3)field.Value).I.ToString(), ((Vector3)field.Value).J.ToString(), ((Vector3)field.Value).K.ToString() } }; break; case FieldType.FieldRectangle2D: control = new FourTupleControl() { LabelA = "t", LabelB = "l", LabelC = "r", LabelD = "b", Field = field, Title = field.Name, TupleValue = new string[] { ((Rectangle2)field.Value).Top.ToString(), ((Rectangle2)field.Value).Left.ToString(), ((Rectangle2)field.Value).Right.ToString(), ((Rectangle2)field.Value).Bottom.ToString() } }; break; case FieldType.FieldRgbColor: control = new ThreeTupleControl() { LabelA = "r", LabelB = "g", LabelC = "b", Field = field, Title = field.Name, }; break; case FieldType.FieldArgbColor: control = new FourTupleControl() { LabelA = "a", LabelB = "r", LabelC = "g", LabelD = "b", Field = field, Title = field.Name, }; break; case FieldType.FieldRealRgbColor: control = new ThreeTupleControl() { LabelA = "r", LabelB = "g", LabelC = "b", Field = field, Title = field.Name, }; break; case FieldType.FieldRealArgbColor: control = new FourTupleControl() { LabelA = "a", LabelB = "r", LabelC = "g", LabelD = "b", Field = field, Title = field.Name, }; break; case FieldType.FieldRealHsvColor: control = new ThreeTupleControl() { LabelA = "h", LabelB = "s", LabelC = "v", Field = field, Title = field.Name, }; break; case FieldType.FieldRealAhsvColor: control = new FourTupleControl() { LabelA = "a", LabelB = "h", LabelC = "s", LabelD = "v", Field = field, Title = field.Name, }; break; case FieldType.FieldQuaternion: control = new FourTupleControl() { LabelA = "w", LabelB = "i", LabelC = "j", LabelD = "k", Field = field, Title = field.Name, TupleValue = new string[] { ((Quaternion)field.Value).W.ToString(), ((Quaternion)field.Value).I.ToString(), ((Quaternion)field.Value).J.ToString(), ((Quaternion)field.Value).K.ToString() } }; break; case FieldType.FieldEulerAngles2D: control = new TwoTupleControl() { LabelA = "i", LabelB = "j", Field = field, Title = field.Name, TupleValue = new string[] { ((Vector2)field.Value).I.ToString(), ((Vector2)field.Value).J.ToString() } }; break; case FieldType.FieldEulerAngles3D: control = new ThreeTupleControl() { LabelA = "i", LabelB = "j", LabelC = "k", Field = field, Title = field.Name, TupleValue = new string[] { ((Vector3)field.Value).I.ToString(), ((Vector3)field.Value).J.ToString(), ((Vector3)field.Value).K.ToString() } }; break; case FieldType.FieldRealPlane2D: control = new ThreeTupleControl() { LabelA = "i", LabelB = "j", LabelC = "d", Field = field, Title = field.Name, TupleValue = new string[] { ((Vector3)field.Value).I.ToString(), ((Vector3)field.Value).J.ToString(), ((Vector3)field.Value).K.ToString() } }; break; case FieldType.FieldRealPlane3D: control = new FourTupleControl() { LabelA = "i", LabelB = "j", LabelC = "k", LabelD = "d", Field = field, Title = field.Name, TupleValue = new string[] { ((Vector4)field.Value).I.ToString(), ((Vector4)field.Value).J.ToString(), ((Vector4)field.Value).K.ToString(), ((Vector4)field.Value).W.ToString() } }; break; default: control = new GuerillaControl() { Visible = false }; break; } //Check if (control != null) { panel.Controls.Add(control); } } //Resume panel.ResumeLayout(); }
private async void DeviceCmdsCmboBox_SelectionChanged_1(object sender, SelectionChangedEventArgs e) { var selectedDevice = (Device)DevicesCmboBox.SelectedItem; DeviceArgSckPnl.Children.Clear(); var deviceTypeCommand = DeviceCmdsCmboBox.SelectedItem as DeviceTypeCommand; if (deviceTypeCommand != null) { #region Device Type Commands switch (deviceTypeCommand.ArgumentType) { case DataType.NONE: { DeviceArgSckPnl.Children.Add(new TextBlock { Text = "None", Margin = new Thickness(30, 0, 0, 0) }); break; } case DataType.BOOL: { //get the current value from the value table list bool defaultValue; if (!bool.TryParse(StoredCommand.Argument, out defaultValue)) { var dv = await Context.DeviceValues.FirstOrDefaultAsync(o => o.DeviceId == selectedDevice.Id && o.UniqueIdentifier == deviceTypeCommand.CustomData2); if (dv != null) { bool.TryParse(dv.Value, out defaultValue); } } _selectedDeviceArg = defaultValue.ToString(); var control = new CheckboxControl(isChecked => { _selectedDeviceArg = isChecked.ToString(); return(Task.FromResult(0)); }, _icon) { Header = deviceTypeCommand.Name, Description = deviceTypeCommand.Description, Value = defaultValue }; DeviceArgSckPnl.Children.Add(control); break; } case DataType.DECIMAL: case DataType.INTEGER: case DataType.BYTE: case DataType.SHORT: { //get the current value from the value table list var defaultValue = "0"; var dv = await Context.DeviceValues.FirstOrDefaultAsync(o => o.DeviceId == selectedDevice.Id && o.UniqueIdentifier == deviceTypeCommand.CustomData2); if (dv != null) { defaultValue = dv.Value; } _selectedDeviceArg = defaultValue; var control = new NumericControl(value => { _selectedDeviceArg = value; return(Task.FromResult(0)); }, _icon, deviceTypeCommand.ArgumentType) { Header = deviceTypeCommand.Name, Description = deviceTypeCommand.Description, Value = defaultValue }; DeviceArgSckPnl.Children.Add(control); break; } case DataType.STRING: { //get the current value from the value table list var defaultValue = "0"; if (!string.IsNullOrEmpty(StoredCommand.Argument)) { defaultValue = StoredCommand.Argument; } else { var dv = await Context.DeviceValues.FirstOrDefaultAsync(o => o.DeviceId == selectedDevice.Id && o.UniqueIdentifier == deviceTypeCommand.CustomData2); if (dv != null) { defaultValue = dv.Value; } } _selectedDeviceArg = defaultValue; var control = new StringControl( value => { _selectedDeviceArg = value; return(Task.FromResult(0)); }, _icon) { Header = deviceTypeCommand.Name, Description = deviceTypeCommand.Description, Value = defaultValue }; DeviceArgSckPnl.Children.Add(control); break; } case DataType.LIST: { //get the current value from the value table list var defaultValue = "0"; if (!string.IsNullOrEmpty(StoredCommand.Argument)) { defaultValue = StoredCommand.Argument; } else { var dv = await Context.DeviceValues.FirstOrDefaultAsync(o => o.DeviceId == selectedDevice.Id && o.UniqueIdentifier == deviceTypeCommand.CustomData2); if (dv != null) { defaultValue = dv.Value; } } _selectedDeviceArg = defaultValue; var control = new ComboboxControl(value => { _selectedDeviceArg = value.ToString(); return(Task.FromResult(0)); }, _icon, deviceTypeCommand.Options.Select(o => o.Name).ToList()) { Header = deviceTypeCommand.Name, Description = deviceTypeCommand.Description, SelectedItem = defaultValue }; DeviceArgSckPnl.Children.Add(control); break; } } #endregion } var item = DeviceCmdsCmboBox.SelectedItem as DeviceCommand; if (item != null) { var dCmd = item; #region Device Commands switch (dCmd.ArgumentType) { case DataType.NONE: { DeviceArgSckPnl.Children.Add(new TextBlock { Text = "None", Margin = new Thickness(30, 0, 0, 0) }); break; } case DataType.BOOL: { //get the current value from the value table list bool defaultValue; if (!bool.TryParse(StoredCommand.Argument, out defaultValue)) { var dv = await Context.DeviceValues.FirstOrDefaultAsync(o => o.DeviceId == selectedDevice.Id && o.UniqueIdentifier == dCmd.CustomData2); if (dv != null) { bool.TryParse(dv.Value, out defaultValue); } } _selectedDeviceArg = defaultValue.ToString(); var control = new CheckboxControl(isChecked => { _selectedDeviceArg = isChecked.ToString(); return(Task.FromResult(0)); }, _icon) { Header = dCmd.Name, Description = dCmd.Description, Value = defaultValue }; DeviceArgSckPnl.Children.Add(control); break; } case DataType.DECIMAL: case DataType.INTEGER: case DataType.BYTE: case DataType.SHORT: { //get the current value from the value table list var defaultValue = StoredCommand.Argument; if (defaultValue == "0") { var dv = await Context.DeviceValues.FirstOrDefaultAsync(o => o.DeviceId == selectedDevice.Id && o.UniqueIdentifier == dCmd.CustomData2); if (dv != null) { defaultValue = dv.Value; } } _selectedDeviceArg = defaultValue; var control = new NumericControl(value => { _selectedDeviceArg = value; return(Task.FromResult(0)); }, _icon, dCmd.ArgumentType) { Header = dCmd.Name, Description = dCmd.Description, Value = defaultValue }; DeviceArgSckPnl.Children.Add(control); break; } case DataType.STRING: { //get the current value from the value table list var defaultValue = ""; if (!string.IsNullOrEmpty(StoredCommand.Argument)) { defaultValue = StoredCommand.Argument; } else { var dv = await Context.DeviceValues.FirstOrDefaultAsync(o => o.DeviceId == selectedDevice.Id && o.UniqueIdentifier == dCmd.CustomData2); if (dv != null) { defaultValue = dv.Value; } } _selectedDeviceArg = defaultValue; var control = new StringControl( value => { _selectedDeviceArg = value; return(Task.FromResult(0)); }, _icon) { Header = dCmd.Name, Description = dCmd.Description, Value = defaultValue }; DeviceArgSckPnl.Children.Add(control); break; } case DataType.LIST: { //get the current value from the value table list var defaultValue = "0"; if (!string.IsNullOrEmpty(StoredCommand.Argument)) { defaultValue = StoredCommand.Argument; } else { var dv = await Context.DeviceValues.FirstOrDefaultAsync(o => o.DeviceId == selectedDevice.Id && o.UniqueIdentifier == dCmd.CustomData2); if (dv != null) { defaultValue = dv.Value; } } _selectedDeviceArg = defaultValue; var control = new ComboboxControl(value => { _selectedDeviceArg = value.ToString(); return(Task.FromResult(0)); }, _icon, dCmd.Options.Select(o => o.Name).ToList()) { Header = dCmd.Name, Description = dCmd.Description, SelectedItem = defaultValue }; DeviceArgSckPnl.Children.Add(control); break; } } #endregion } }
private async void BuiltinCmdsCmboBox_SelectionChanged_1(object sender, SelectionChangedEventArgs e) { BuiltinArgSckPnl.Children.Clear(); var selectedCmd = (BuiltinCommand)BuiltinCmdsCmboBox.SelectedItem; switch (selectedCmd.UniqueIdentifier) { #region Do Custom things for some Builtin Commands case "REPOLL_ME": { Device selectedDevice = null; //Lookup the device involved in the command int deviceId = int.TryParse(StoredCommand.Argument, out deviceId) ? deviceId : 0; var device = await Context.Devices.FirstOrDefaultAsync(o => o.Id == deviceId) ?? await Context.Devices.FirstOrDefaultAsync(); if (device != null) { selectedDevice = device; _selectedBuiltinArg = device.Id.ToString(CultureInfo.InvariantCulture); } var control = new ComboboxControl(obj => { var d = obj as Device; if (d != null) { _selectedBuiltinArg = d.Id.ToString(CultureInfo.InvariantCulture); } return(Task.FromResult(0)); }, _icon, await Context.Devices.ToListAsync()) { Header = selectedCmd.Name, Description = selectedCmd.Description, SelectedItem = selectedDevice }; BuiltinArgSckPnl.Children.Add(control); break; } case "GROUP_ON": case "GROUP_OFF": { Group selectedGroup = null; //Lookup the group involved in the command int groupId = int.TryParse(StoredCommand.Argument, out groupId) ? groupId : 0; var group = await Context.Groups.FirstOrDefaultAsync(o => o.Id == groupId) ?? await Context.Groups.FirstOrDefaultAsync(); if (group != null) { selectedGroup = group; _selectedBuiltinArg = group.Id.ToString(CultureInfo.InvariantCulture); } var control = new ComboboxControl(arg => { var g = arg as Group; if (g != null) { _selectedBuiltinArg = g.Id.ToString(CultureInfo.InvariantCulture); } return(Task.FromResult(0)); }, _icon, await Context.Groups.ToListAsync()) { Header = selectedCmd.Name, Description = selectedCmd.Description, SelectedItem = selectedGroup, }; control.ComboBox.DisplayMemberPath = "Name"; BuiltinArgSckPnl.Children.Add(control); } break; case "RUN_SCENE": { Scene selectedScene = null; //Try to match supplied arg (sceneID) with a scene int sceneId = int.TryParse(StoredCommand.Argument, out sceneId) ? sceneId : 0; var scene = await Context.Scenes.FirstOrDefaultAsync(o => o.Id == sceneId) ?? await Context.Scenes.FirstOrDefaultAsync(); //If this is a new command or we cannot find the old scene, //just preselect the first scene. if (scene != null) { selectedScene = scene; _selectedBuiltinArg = scene.Id.ToString(CultureInfo.InvariantCulture); } var control = new ComboboxControl(arg => { var s = arg as Scene; if (s != null) { _selectedBuiltinArg = s.Id.ToString(CultureInfo.InvariantCulture); } return(Task.FromResult(0)); }, _icon, await Context.Scenes.ToListAsync()) { Header = selectedCmd.Name, Description = selectedCmd.Description, SelectedItem = selectedScene }; control.ComboBox.DisplayMemberPath = "Name"; BuiltinArgSckPnl.Children.Add(control); break; } #endregion default: { #region Built-in Commands switch (selectedCmd.ArgumentType) { case DataType.NONE: { _selectedBuiltinArg = string.Empty; BuiltinArgSckPnl.Children.Add(new TextBlock { Text = "None", Margin = new Thickness(30, 0, 0, 0) }); break; } case DataType.BOOL: { //get the current value from the value table list bool defaultValue; bool.TryParse(StoredCommand.Argument, out defaultValue); _selectedBuiltinArg = defaultValue.ToString(); var control = new CheckboxControl(isChecked => { _selectedBuiltinArg = isChecked.ToString(); return(Task.FromResult(0)); }, _icon) { Header = selectedCmd.Name, Description = selectedCmd.Description, Value = defaultValue }; BuiltinArgSckPnl.Children.Add(control); break; } case DataType.INTEGER: case DataType.DECIMAL: case DataType.BYTE: case DataType.SHORT: { var defaultValue = "0"; if (!string.IsNullOrEmpty(StoredCommand.Argument)) { defaultValue = StoredCommand.Argument; } _selectedBuiltinArg = defaultValue; var control = new NumericControl(value => { _selectedBuiltinArg = value; return(Task.FromResult(0)); }, _icon, selectedCmd.ArgumentType) { Header = selectedCmd.Name, Description = selectedCmd.Description, Value = defaultValue }; BuiltinArgSckPnl.Children.Add(control); break; } case DataType.STRING: { //get the current value from the value table list var defaultValue = "0"; if (!string.IsNullOrEmpty(StoredCommand.Argument)) { defaultValue = StoredCommand.Argument; } _selectedBuiltinArg = defaultValue; var control = new StringControl(value => { _selectedBuiltinArg = value; return(Task.FromResult(0)); }, _icon) { Header = selectedCmd.Name, Description = selectedCmd.Description, Value = defaultValue }; BuiltinArgSckPnl.Children.Add(control); break; } case DataType.LIST: { var defaultValue = ""; var firstOrDefault = selectedCmd.Options.FirstOrDefault(); if (firstOrDefault != null) { var option = firstOrDefault.Name; if (option != null) { defaultValue = option; } } if (!string.IsNullOrEmpty(StoredCommand.Argument)) { defaultValue = StoredCommand.Argument; } _selectedBuiltinArg = defaultValue; var control = new ComboboxControl(value => { _selectedBuiltinArg = value.ToString(); return(Task.FromResult(0)); }, _icon, selectedCmd.Options.Select(o => o.Name).ToList()) { Header = selectedCmd.Name, Description = selectedCmd.Description, SelectedItem = defaultValue }; BuiltinArgSckPnl.Children.Add(control); break; } } #endregion break; } } }
private void AdapterListView_SelectionChanged(object sender, SelectionChangedEventArgs e) { ControlsStkPnl.Children.Clear(); var adapter = (Adapter)AdapterListView.SelectedItem; if (adapter == null) { return; } //ADD THE ENABLED BUTTON var c = new CheckboxControl( async isChecked => { //Save to the database adapter.IsEnabled = isChecked; var result = await Context.TrySaveChangesAsync(App.Cts.Token); if (result.HasError) { await Log.ReportErrorFormatAsync(App.Cts.Token, "Error enabling adapter. {0}", result.Message); } //STOP OR START if (isChecked) { await App.ZvsEngine.AdapterManager.EnableAdapterAsync(adapter.AdapterGuid, App.Cts.Token); } else { await App.ZvsEngine.AdapterManager.DisableAdapterAsync(adapter.AdapterGuid, App.Cts.Token); } }, _icon) { Header = $"{adapter.Name} is enabled", Description = "Starts and stops the selected adapter", Value = adapter.IsEnabled }; ControlsStkPnl.Children.Add(c); //Add all the settings foreach (var a in adapter.Settings) { var adapterSetting = a; switch (adapterSetting.ValueType) { case DataType.BOOL: { bool defaultValue; bool.TryParse(adapterSetting.Value, out defaultValue); var control = new CheckboxControl(async isChecked => { adapterSetting.Value = isChecked.ToString(); var result = await Context.TrySaveChangesAsync(App.Cts.Token); if (result.HasError) { await Log.ReportErrorFormatAsync(App.Cts.Token, "Error saving adapter setting. {0}", result.Message); } }, _icon) { Header = adapterSetting.Name, Description = adapterSetting.Description, Value = defaultValue }; ControlsStkPnl.Children.Add(control); break; } case DataType.BYTE: case DataType.DECIMAL: case DataType.SHORT: case DataType.INTEGER: case DataType.COMPORT: { var control = new NumericControl(async value => { adapterSetting.Value = value; var result = await Context.TrySaveChangesAsync(App.Cts.Token); if (result.HasError) { await Log.ReportErrorFormatAsync(App.Cts.Token, "Error saving adapter setting. {0}", result.Message); } }, _icon, adapterSetting.ValueType) { Header = adapterSetting.Name, Description = adapterSetting.Description, Value = adapterSetting.Value }; ControlsStkPnl.Children.Add(control); break; } case DataType.STRING: { var control = new StringControl( async value => { adapterSetting.Value = value; var result = await Context.TrySaveChangesAsync(App.Cts.Token); if (result.HasError) { await Log.ReportErrorFormatAsync(App.Cts.Token, "Error saving adapter setting. {0}", result.Message); } }, _icon) { Header = adapterSetting.Name, Description = adapterSetting.Description, Value = adapterSetting.Value }; ControlsStkPnl.Children.Add(control); break; } case DataType.LIST: { var control = new ComboboxControl(async value => { adapterSetting.Value = value.ToString(); var result = await Context.TrySaveChangesAsync(App.Cts.Token); if (result.HasError) { await Log.ReportErrorFormatAsync(App.Cts.Token, "Error saving adapter setting. {0}", result.Message); } }, _icon, adapterSetting.Options.Select(o => o.Name).ToList()) { Header = adapterSetting.Name, Description = adapterSetting.Description, SelectedItem = adapterSetting.Value }; ControlsStkPnl.Children.Add(control); break; } } } }
public override void PickupMode() { //Picks up the clicked object in the view. PlayerInventory pInv = this.GetComponent <PlayerInventory>(); if (InvMarker == null) { InvMarker = GameObject.Find("InventoryMarker"); } if (pInv.ObjectInHand == "") //Player is not holding anything. { //Find the object within the pickup range. Ray ray; if (MouseLookEnabled == true) { ray = Camera.main.ViewportPointToRay(new Vector3(0.5f, 0.5f, 0f)); } else { ray = Camera.main.ScreenPointToRay(Input.mousePosition); } RaycastHit hit = new RaycastHit(); if (Physics.Raycast(ray, out hit, GetPickupRange())) { ObjectInteraction objPicked; objPicked = hit.transform.GetComponent <ObjectInteraction>(); if (objPicked != null) //Only objects with ObjectInteraction can be picked. { if (objPicked.CanBePickedUp == true) { //check for weight if (objPicked.GetWeight() > playerInventory.getEncumberance()) { //000~001~095~That is too heavy for you to pick up. playerHud.MessageScroll.Add(StringControl.GetString(1, 95)); return; } if (UICamera.currentTouchID == -2) { //right click check for quant. //Pickup if either not a quantity or is a quantity of one. if ((objPicked.isQuant == false) || ((objPicked.isQuant) && (objPicked.Link == 1)) || (objPicked.isEnchanted)) { Pickup(objPicked, pInv); } else { //Debug.Log("attempting to pick up a quantity"); playerHud.MessageScroll.Set("Move how many?"); UIInput inputctrl = playerHud.InputControl; //playerHud.MessageScroll.GetComponent<UIInput>(); inputctrl.GetComponent <GuiBase>().SetAnchorX(0.3f); inputctrl.eventReceiver = this.gameObject; inputctrl.type = UIInput.KeyboardType.NumberPad; inputctrl.text = "1"; inputctrl.label.text = "1"; inputctrl.selected = true; QuantityObj = objPicked; Time.timeScale = 0.0f; WindowDetect.WaitingForInput = true; } } else { //Left click. Pick them all up. Pickup(objPicked, pInv); } } else { //000~001~096~You cannot pick that up. playerHud.MessageScroll.Add(StringControl.GetString(1, 96)); } } } } }
public override void LookMode() { //Look at the clicked item. Ray ray; if (MouseLookEnabled == true) { ray = Camera.main.ViewportPointToRay(new Vector3(0.5f, 0.5f, 0f)); } else { ray = Camera.main.ScreenPointToRay(Input.mousePosition); } RaycastHit hit = new RaycastHit(); if (Physics.Raycast(ray, out hit, lookRange)) { //Debug.Log ("Hit made" + hit.transform.name); ObjectInteraction objInt = hit.transform.GetComponent <ObjectInteraction>(); if (objInt != null) { objInt.LookDescription(); return; } else { int len = hit.transform.name.Length; if (len > 4) { len = 4; } switch (hit.transform.name.Substring(0, len).ToUpper()) { case "CEIL": playerHud.MessageScroll.Add("You see the ceiling"); //GetMessageLog().text = "You see the ceiling"; break; case "PILL": //GetMessageLog().text = playerHud.MessageScroll.Add("You see a pillar"); break; case "BRID": //000~001~171~You see a bridge. //GetMessageLog().text= playerHud.MessageScroll.Add(StringControl.GetString(1, 171)); break; case "WALL": case "TILE": default: if (hit.transform.GetComponent <PortcullisInteraction>() != null) { ObjectInteraction objPicked = hit.transform.GetComponent <PortcullisInteraction>().getParentObjectInteraction(); if (objPicked != null) { objPicked.LookDescription(); } return; } //Taken from //http://forum.unity3d.com/threads/get-material-from-raycast.53123/ Renderer rend = hit.collider.GetComponent <Renderer>(); if (rend == null) { return; } MeshCollider meshCollider = (MeshCollider)hit.collider; int materialIndex = -1; Mesh mesh = meshCollider.sharedMesh; int triangleIdx = hit.triangleIndex; int lookupIdx1 = mesh.triangles[triangleIdx * 3]; int lookupIdx2 = mesh.triangles[triangleIdx * 3 + 1]; int lookupIdx3 = mesh.triangles[triangleIdx * 3 + 2]; int submeshNr = mesh.subMeshCount; for (int i = 0; i < submeshNr; i++) { int[] tr = mesh.GetTriangles(i); for (int j = 0; j < tr.Length; j += 3) { if ((tr[j] == lookupIdx1) && (tr[j + 1] == lookupIdx2) && (tr[j + 2]) == lookupIdx3) { materialIndex = i; break; } } if (materialIndex != -1) { break; } } if (materialIndex != -1) { if (rend.materials[materialIndex].name.Length >= 7) { int textureIndex = 0; if (int.TryParse(rend.materials[materialIndex].name.Substring(4, 3), out textureIndex)) //int.Parse(rend.materials[materialIndex].name.Substring(4,3)); { //GetMessageLog ().text = playerHud.MessageScroll.Add("You see " + StringControl.GetTextureName(textureIndex)); } } // GetMessageLog().text=rend.materials[materialIndex].name; //Debug.Log (rend.materials[materialIndex].name.Substring(4,3)); } break; } } } }
private async Task LoadCommandsAsync() { PropertiesStkPnl.Children.Clear(); var device = await Context.Devices .Include(o => o.DeviceSettingValues) .Include(o => o.Type.Settings) .FirstOrDefaultAsync(dv => dv.Id == _deviceId); if (device == null) { return; } #region Device Type Settings foreach (var deviceTypeSetting in device.Type.Settings) { //default var value = deviceTypeSetting.Value; //check if this settings has already been set var setting = deviceTypeSetting; var deviceTypeSettingValue = await Context.DeviceTypeSettingValues .Where(o => o.DeviceId == device.Id) .FirstOrDefaultAsync(o => o.DeviceTypeSettingId == setting.Id); if (deviceTypeSettingValue != null) { value = deviceTypeSettingValue.Value; } switch (deviceTypeSetting.ValueType) { case DataType.BOOL: { #region CheckboxControl //get the current value from the value table list bool defaultValue; bool.TryParse(value, out defaultValue); var control = new CheckboxControl(async isChecked => { if (deviceTypeSettingValue != null) { deviceTypeSettingValue.Value = isChecked.ToString(); } else { deviceTypeSettingValue = new DeviceTypeSettingValue { DeviceId = device.Id, DeviceTypeSettingId = setting.Id, Value = isChecked.ToString() }; Context.DeviceTypeSettingValues.Add(deviceTypeSettingValue); } var result = await Context.TrySaveChangesAsync(_app.Cts.Token); if (result.HasError) { await Log.ReportErrorFormatAsync(_app.Cts.Token, "Error saving device type setting. {0}", result.Message); } }, _icon) { Header = deviceTypeSetting.Name, Description = deviceTypeSetting.Description, Value = defaultValue }; PropertiesStkPnl.Children.Add(control); break; #endregion } case DataType.INTEGER: case DataType.DECIMAL: case DataType.SHORT: case DataType.BYTE: { #region NumericControl var control = new NumericControl( async v => { if (deviceTypeSettingValue != null) { deviceTypeSettingValue.Value = v; } else { deviceTypeSettingValue = new DeviceTypeSettingValue() { DeviceId = device.Id, DeviceTypeSettingId = setting.Id, Value = v }; Context.DeviceTypeSettingValues.Add(deviceTypeSettingValue); } var result = await Context.TrySaveChangesAsync(_app.Cts.Token); if (result.HasError) { await Log.ReportErrorFormatAsync(_app.Cts.Token, "Error saving device type setting. {0}", result.Message); } }, _icon, deviceTypeSetting.ValueType) { Header = deviceTypeSetting.Name, Description = deviceTypeSetting.Description, Value = value }; PropertiesStkPnl.Children.Add(control); break; #endregion } case DataType.STRING: { #region StringControl var control = new StringControl(async v => { if (deviceTypeSettingValue != null) { deviceTypeSettingValue.Value = v; } else { deviceTypeSettingValue = new DeviceTypeSettingValue() { DeviceId = device.Id, DeviceTypeSettingId = setting.Id, Value = v }; Context.DeviceTypeSettingValues.Add(deviceTypeSettingValue); } var result = await Context.TrySaveChangesAsync(_app.Cts.Token); if (result.HasError) { await Log.ReportErrorFormatAsync(_app.Cts.Token, "Error saving device type setting. {0}", result.Message); } }, _icon) { Header = deviceTypeSetting.Name, Description = deviceTypeSetting.Description, Value = value, }; PropertiesStkPnl.Children.Add(control); break; #endregion } case DataType.LIST: { #region ComboboxControl var control = new ComboboxControl(async v => { if (deviceTypeSettingValue != null) { deviceTypeSettingValue.Value = v.ToString(); } else { deviceTypeSettingValue = new DeviceTypeSettingValue { DeviceId = device.Id, DeviceTypeSettingId = setting.Id, Value = v.ToString() }; Context.DeviceTypeSettingValues.Add(deviceTypeSettingValue); } var result = await Context.TrySaveChangesAsync(_app.Cts.Token); if (result.HasError) { await Log.ReportErrorFormatAsync(_app.Cts.Token, "Error saving device type setting. {0}", result.Message); } }, _icon, deviceTypeSetting.Options.Select(o => o.Name).ToList()) { Header = deviceTypeSetting.Name, Description = deviceTypeSetting.Description, SelectedItem = value }; PropertiesStkPnl.Children.Add(control); break; #endregion } } } #endregion #region Device Settings foreach (var s in await Context.DeviceSettings.ToListAsync()) { var deviceSetting = s; //See if the device has a value stored for it for this property var deviceSettingValue = await Context.DeviceSettingValues.FirstOrDefaultAsync(v => v.DeviceSetting.Id == deviceSetting.Id && v.DeviceId == device.Id); var _default = deviceSettingValue == null ? deviceSetting.Value : deviceSettingValue.Value; switch (deviceSetting.ValueType) { case DataType.BOOL: { #region CheckboxControl //get the current value from the value table list bool defaultValue; bool.TryParse(_default, out defaultValue); var control = new CheckboxControl(async isChecked => { if (deviceSettingValue != null) { deviceSettingValue.Value = isChecked.ToString(); } else { deviceSettingValue = new DeviceSettingValue() { DeviceSetting = deviceSetting, Value = isChecked.ToString() }; device.DeviceSettingValues.Add(deviceSettingValue); } var result = await Context.TrySaveChangesAsync(_app.Cts.Token); if (result.HasError) { await Log.ReportErrorFormatAsync(_app.Cts.Token, "Error saving device setting. {0}", result.Message); } }, _icon) { Header = deviceSetting.Name, Description = deviceSetting.Description, Value = defaultValue }; PropertiesStkPnl.Children.Add(control); break; #endregion } case DataType.INTEGER: case DataType.DECIMAL: case DataType.SHORT: case DataType.BYTE: { #region NumericControl var control = new NumericControl(async value => { if (deviceSettingValue != null) { deviceSettingValue.Value = value; } else { deviceSettingValue = new DeviceSettingValue() { DeviceSetting = deviceSetting, Value = value }; device.DeviceSettingValues.Add(deviceSettingValue); } var result = await Context.TrySaveChangesAsync(_app.Cts.Token); if (result.HasError) { await Log.ReportErrorFormatAsync(_app.Cts.Token, "Error saving device setting. {0}", result.Message); } }, _icon, deviceSetting.ValueType) { Header = deviceSetting.Name, Description = deviceSetting.Description, Value = _default }; PropertiesStkPnl.Children.Add(control); break; #endregion } case DataType.STRING: { #region StringControl var control = new StringControl( async value => { if (deviceSettingValue != null) { deviceSettingValue.Value = value; } else { deviceSettingValue = new DeviceSettingValue() { DeviceSetting = deviceSetting, Value = value }; device.DeviceSettingValues.Add(deviceSettingValue); } var result = await Context.TrySaveChangesAsync(_app.Cts.Token); if (result.HasError) { await Log.ReportErrorFormatAsync(_app.Cts.Token, "Error saving device setting. {0}", result.Message); } }, _icon) { Header = deviceSetting.Name, Description = deviceSetting.Description, Value = _default, }; PropertiesStkPnl.Children.Add(control); break; #endregion } case DataType.LIST: { #region ComboboxControl var control = new ComboboxControl(async value => { if (deviceSettingValue != null) { deviceSettingValue.Value = value.ToString(); } else { deviceSettingValue = new DeviceSettingValue { DeviceSetting = deviceSetting, Value = value.ToString() }; device.DeviceSettingValues.Add(deviceSettingValue); } var result = await Context.TrySaveChangesAsync(_app.Cts.Token); if (result.HasError) { await Log.ReportErrorFormatAsync(_app.Cts.Token, "Error saving device setting. {0}", result.Message); } }, _icon, deviceSetting.Options.Select(o => o.Name).ToList()) { Header = deviceSetting.Name, Description = deviceSetting.Description, SelectedItem = _default }; PropertiesStkPnl.Children.Add(control); break; #endregion } } } #endregion }
private async Task LoadCommandsAsync() { PropertiesStkPnl.Children.Clear(); var scene = await Context.Scenes .Include(o => o.SettingValues) .FirstOrDefaultAsync(sc => sc.Id == SceneId); if (scene == null) { return; } #region Scene Properties foreach (var sp in await Context.SceneSettings.ToListAsync()) { var sceneSetting = sp; var sceneSettingValue = await Context.SceneSettingValues .FirstOrDefaultAsync(v => v.SceneSetting.Id == sceneSetting.Id && v.SceneId == scene.Id); var _default = sceneSettingValue == null ? sceneSetting.Value : sceneSettingValue.Value; switch (sceneSetting.ValueType) { case DataType.BOOL: { //get the current value from the value table list bool defaultValue; bool.TryParse(_default, out defaultValue); var control = new CheckboxControl(async isChecked => { if (sceneSettingValue != null) { sceneSettingValue.Value = isChecked.ToString(); } else { sceneSettingValue = new SceneSettingValue() { SceneSetting = sceneSetting, Value = isChecked.ToString() }; scene.SettingValues.Add(sceneSettingValue); } var result = await Context.TrySaveChangesAsync(_app.Cts.Token); if (result.HasError) { await Log.ReportErrorFormatAsync(_app.Cts.Token, "Error saving scene. {0}", result.Message); } }, icon) { Header = sceneSetting.Name, Description = string.Empty, Value = defaultValue }; PropertiesStkPnl.Children.Add(control); break; } case DataType.DECIMAL: case DataType.INTEGER: case DataType.BYTE: case DataType.SHORT: { var control = new NumericControl(async value => { if (sceneSettingValue != null) { sceneSettingValue.Value = value; } else { sceneSettingValue = new SceneSettingValue() { SceneSetting = sceneSetting, Value = value }; scene.SettingValues.Add(sceneSettingValue); } var result = await Context.TrySaveChangesAsync(_app.Cts.Token); if (result.HasError) { await Log.ReportErrorFormatAsync(_app.Cts.Token, "Error saving scene. {0}", result.Message); } }, icon, sceneSetting.ValueType) { Header = sceneSetting.Name, Description = string.Empty, Value = _default }; PropertiesStkPnl.Children.Add(control); break; } case DataType.STRING: { var control = new StringControl( async value => { if (sceneSettingValue != null) { sceneSettingValue.Value = value; } else { sceneSettingValue = new SceneSettingValue { SceneSetting = sceneSetting, Value = value }; scene.SettingValues.Add(sceneSettingValue); } var result = await Context.TrySaveChangesAsync(_app.Cts.Token); if (result.HasError) { await Log.ReportErrorFormatAsync(_app.Cts.Token, "Error saving scene. {0}", result.Message); } }, icon) { Header = sceneSetting.Name, Description = string.Empty, Value = _default }; PropertiesStkPnl.Children.Add(control); break; } case DataType.LIST: { var control = new ComboboxControl(async value => { if (sceneSettingValue != null) { sceneSettingValue.Value = value.ToString(); } else { //assign sceneSettingValue so above null check is ran in the case this is called 2 times before the save changes hits. sceneSettingValue = new SceneSettingValue { SceneSetting = sceneSetting, Value = value.ToString() }; scene.SettingValues.Add(sceneSettingValue); } var result = await Context.TrySaveChangesAsync(_app.Cts.Token); if (result.HasError) { await Log.ReportErrorFormatAsync(_app.Cts.Token, "Error saving scene. {0}", result.Message); } }, icon, sceneSetting.Options.Select(o => o.Name).ToList()) { Header = sceneSetting.Name, Description = string.Empty, SelectedItem = _default }; PropertiesStkPnl.Children.Add(control); break; } } } #endregion }
private async Task LoadCommandsAsync() { DeviceCommandsStkPnl.Children.Clear(); TypeCommandsStkPnl.Children.Clear(); var d = await _context.Devices .Include(o => o.Values) .Include(o => o.Type.Commands) .FirstOrDefaultAsync(dv => dv.Id == _deviceId); if (d != null) { #region Device Commands foreach (var dc in d.Commands.OrderByDescending(c => c.SortOrder)) { var deviceCommand = dc; switch (deviceCommand.ArgumentType) { case DataType.NONE: { var bc = new ButtonControl(async() => { await _app.ZvsEngine.RunCommandAsync(deviceCommand.Id, string.Empty, string.Empty, CancellationToken.None); }, _icon) { Header = deviceCommand.Name, ButtonContent = deviceCommand.Name, Description = deviceCommand.Description }; DeviceCommandsStkPnl.Children.Add(bc); break; } case DataType.BOOL: { //get the current value from the value table list var defaultValue = false; var dv = d.Values.FirstOrDefault(v => v.UniqueIdentifier == deviceCommand.CustomData2); if (dv != null) { bool.TryParse(dv.Value, out defaultValue); } var control = new CheckboxControl(async isChecked => { await _app.ZvsEngine.RunCommandAsync(deviceCommand.Id, isChecked.ToString(), string.Empty, CancellationToken.None); }, _icon) { Header = deviceCommand.Name, Description = deviceCommand.Description, Value = defaultValue }; DeviceCommandsStkPnl.Children.Add(control); break; } case DataType.INTEGER: case DataType.DECIMAL: case DataType.BYTE: case DataType.SHORT: { //get the current value from the value table list var defaultValue = "0"; var dv = d.Values.FirstOrDefault(v => v.UniqueIdentifier == deviceCommand.CustomData2); if (dv != null) { defaultValue = dv.Value; } var control = new NumericControl(async value => { await _app.ZvsEngine.RunCommandAsync(deviceCommand.Id, value, string.Empty, CancellationToken.None); }, _icon, deviceCommand.ArgumentType) { Header = deviceCommand.Name, Description = deviceCommand.Description, Value = defaultValue }; DeviceCommandsStkPnl.Children.Add(control); break; } case DataType.STRING: { //get the current value from the value table list var defaultValue = "0"; var dv = d.Values.FirstOrDefault(v => v.UniqueIdentifier == deviceCommand.CustomData2); if (dv != null) { defaultValue = dv.Value; } var control = new StringControl( async value => { await _app.ZvsEngine.RunCommandAsync(deviceCommand.Id, value, string.Empty, CancellationToken.None); }, _icon) { Header = deviceCommand.Name, Description = deviceCommand.Description, Value = defaultValue }; DeviceCommandsStkPnl.Children.Add(control); break; } case DataType.LIST: { //get the current value from the value table list var defaultValue = "0"; var dv = d.Values.FirstOrDefault(v => v.UniqueIdentifier == deviceCommand.CustomData2); if (dv != null) { defaultValue = dv.Value; } var control = new ComboboxControl(async value => { await _app.ZvsEngine.RunCommandAsync(deviceCommand.Id, value.ToString(), string.Empty, CancellationToken.None); }, _icon, deviceCommand.Options.Select(o => o.Name).ToList()) { Header = deviceCommand.Name, Description = deviceCommand.Description, SelectedItem = defaultValue }; DeviceCommandsStkPnl.Children.Add(control); break; } } } #endregion #region Device Type Commands foreach (var dtc in d.Type.Commands.OrderByDescending(c => c.SortOrder)) { var deviceTypeCommand = dtc; switch (deviceTypeCommand.ArgumentType) { case DataType.NONE: { var bc = new ButtonControl(async() => { await _app.ZvsEngine.RunCommandAsync(deviceTypeCommand.Id, string.Empty, d.Id.ToString(CultureInfo.InvariantCulture), CancellationToken.None); }, _icon) { Header = deviceTypeCommand.Name, ButtonContent = deviceTypeCommand.Name, Description = deviceTypeCommand.Description }; TypeCommandsStkPnl.Children.Add(bc); break; } case DataType.BOOL: { //get the current value from the value table list var defaultValue = false; var dv = d.Values.FirstOrDefault(v => v.UniqueIdentifier == deviceTypeCommand.CustomData2); if (dv != null) { bool.TryParse(dv.Value, out defaultValue); } var control = new CheckboxControl(async isChecked => { await _app.ZvsEngine.RunCommandAsync(deviceTypeCommand.Id, isChecked.ToString(), d.Id.ToString(CultureInfo.InvariantCulture), CancellationToken.None); }, _icon) { Header = deviceTypeCommand.Name, Description = deviceTypeCommand.Description, Value = defaultValue }; TypeCommandsStkPnl.Children.Add(control); break; } case DataType.DECIMAL: case DataType.INTEGER: case DataType.SHORT: case DataType.BYTE: { //get the current value from the value table list var defaultValue = "0"; var dv = d.Values.FirstOrDefault(v => v.UniqueIdentifier == deviceTypeCommand.CustomData2); if (dv != null) { defaultValue = dv.Value; } var control = new NumericControl(async value => { await _app.ZvsEngine.RunCommandAsync(deviceTypeCommand.Id, value, d.Id.ToString(CultureInfo.InvariantCulture), CancellationToken.None); }, _icon, deviceTypeCommand.ArgumentType) { Header = deviceTypeCommand.Name, Description = deviceTypeCommand.Description, Value = defaultValue }; TypeCommandsStkPnl.Children.Add(control); break; } case DataType.STRING: { //get the current value from the value table list var defaultValue = "0"; var dv = d.Values.FirstOrDefault(v => v.UniqueIdentifier == deviceTypeCommand.CustomData2); if (dv != null) { defaultValue = dv.Value; } var control = new StringControl( async value => { await _app.ZvsEngine.RunCommandAsync(deviceTypeCommand.Id, value, d.Id.ToString(CultureInfo.InvariantCulture), CancellationToken.None); }, _icon) { Header = deviceTypeCommand.Name, Description = deviceTypeCommand.Description, Value = defaultValue }; TypeCommandsStkPnl.Children.Add(control); break; } case DataType.LIST: { //get the current value from the value table list var defaultValue = "0"; var dv = d.Values.FirstOrDefault(v => v.UniqueIdentifier == deviceTypeCommand.CustomData2); if (dv != null) { defaultValue = dv.Value; } var control = new ComboboxControl(async value => { await _app.ZvsEngine.RunCommandAsync(deviceTypeCommand.Id, value.ToString(), d.Id.ToString(CultureInfo.InvariantCulture), CancellationToken.None); }, _icon, deviceTypeCommand.Options.Select(o => o.Name).ToList()) { Header = deviceTypeCommand.Name, Description = deviceTypeCommand.Description, SelectedItem = defaultValue }; TypeCommandsStkPnl.Children.Add(control); break; } } } #endregion } }