/// <summary> /// Renders an input tag for the specified model element /// </summary> /// <typeparam name="TProperty">Property type of the element</typeparam> /// <param name="expression">Property expression</param> /// <param name="inputTagType">Type of the input tag</param> /// <param name="autoFocus">Autofocus type</param> /// <param name="validationOption">Validation type</param> public MvcHtmlString InputFor <TProperty>( Expression <Func <TModel, TProperty> > expression, InputTagType inputTagType = InputTagType.Text, AutoFocus autoFocus = AutoFocus.None, ValidationOption validationOption = ValidationOption.Always) { var modelMetadata = ModelMetadata.FromLambdaExpression(expression, HtmlHelper.ViewData); return(_form.IsHorizontal ? _buildHelper.BuildHorizontalInput(modelMetadata, inputTagType, autoFocus, validationOption) : _buildHelper.BuildColumnarInput(modelMetadata, inputTagType, autoFocus, validationOption)); }
private void Start() { camScript = Camera.main.GetComponent <CameraController>(); af = FindObjectOfType <AutoFocus>(); if (af != null) { autoFocus = true; } CameraController.UpdateSelection += UpdatePosition; CameraController.UpdateSelection += UpdatePanel; selectionIcon.SetActive(false); anim = infoPanel.gameObject.GetComponent <Animator>(); if (panelToggle == null) { Debug.LogError("Panel Toggle needs to be set (to the button that toggles the visibility of the options panel, called ShowHideButton in scene KitchenTypeA)!"); } }
/// <summary> /// Most of the work happens here for generating the hook up script code /// </summary> /// <param name="e"></param> protected override void OnPreRender(EventArgs e) { // Ignore if we're calling this in a Callback if (AjaxMethodCallback.IsCallback) { return; } base.OnPreRender(e); // MS AJAX aware script management ClientScriptProxy scriptProxy = ClientScriptProxy.Current; // Register resources RegisterResources(scriptProxy); // Capture and map the various option parameters StringBuilder sbOptions = new StringBuilder(512); sbOptions.Append("{"); if (!string.IsNullOrEmpty(OnClientSelection)) { sbOptions.Append("select: " + OnClientSelection + ","); } else { sbOptions.AppendLine( @"select: function (e, ui) { $(""#" + this.UniqueID + @""").val(ui.item.value); },"); } if (CallbackHandler != null) { // point the service Url back to the current page method if (AjaxMethodCallback != null) { ServerUrl = Page.Request.Url.LocalPath + "?" + "Method=AutoCompleteCallbackHandler&CallbackTarget=" + AjaxMethodCallback.ID; } } if (!string.IsNullOrEmpty(ServerUrl)) { sbOptions.Append("source: \"" + ServerUrl + "\","); } sbOptions.AppendFormat("autoFocus: {0},delay: {1},minLength: {2},", AutoFocus.ToString().ToLower(), Delay, MinLength); // strip off trailing , sbOptions.Length--; sbOptions.Append("}"); // Write out initilization code for calendar StringBuilder sbStartupScript = new StringBuilder(400); sbStartupScript.AppendLine("$(document).ready( function() {"); sbStartupScript.AppendFormat(" var autocompl = $(\"#{0}\").autocomplete({1});\r\n", ClientID, sbOptions.ToString()); // close out the script function sbStartupScript.AppendLine("} );"); scriptProxy.RegisterStartupScript(Page, typeof(WebResources), "_cal" + UniqueID, sbStartupScript.ToString(), true); }
/// <summary> /// Builds a horizontal input control /// </summary> /// <param name="modelMetadata">Model metadata</param> /// <param name="inputTagType">Type of the input tag</param> /// <param name="autoFocus">Autofocus type</param> /// <param name="validationOption">Validation type</param> public MvcHtmlString BuildHorizontalInput(ModelMetadata modelMetadata, InputTagType inputTagType, AutoFocus autoFocus, ValidationOption validationOption) { // --- The form group that encapsulates the label and the control var propName = CamelCase(modelMetadata.PropertyName); var formGroup = new BsFormGroup { Depth = _formBuilder.Depth + 1 }; var condition = string.Format("{0}{1}", "{0}.{1}.$invalid", validationOption == ValidationOption.WhenDirty ? " && {0}.{1}.$dirty" : ""); formGroup.Attr(NgTag.NgClass, string.Format("{{'has-error': " + condition + ", 'has-feedback': " + condition + "}}", _formBuilder.BsForm.FormName, propName)); if (inputTagType == InputTagType.Text) { var label = CreateTextLabel(modelMetadata); var inputDiv = new BsHtmlElement(HtmlTag.Div); inputDiv.ApplyColumnWidths(null, _formBuilder.BsForm.InputWidthXs, _formBuilder.BsForm.InputWidthSm, _formBuilder.BsForm.InputWidthMd, _formBuilder.BsForm.InputWidthLg); var input = CreateInput(inputTagType, autoFocus, modelMetadata, propName); // --- Assemble the elements formGroup.AddChild(label).AddChild(inputDiv); inputDiv.AddChild(input); // --- Add optional help text if (!string.IsNullOrEmpty(modelMetadata.Description)) { var helpText = new BsHtmlElement(HtmlTag.Span); helpText.CssClass(BsClass.Control.Help); helpText.AddChild(new HtmlText(modelMetadata.Description)); inputDiv.AddChild(helpText); } // --- Create validation tags AddValidationTags(inputDiv, modelMetadata, validationOption); } else if (inputTagType == InputTagType.CheckBox) { var sizingDiv = new BsHtmlElement(HtmlTag.Div); sizingDiv.ApplyColumnWidths(null, _formBuilder.BsForm.InputWidthXs, _formBuilder.BsForm.InputWidthSm, _formBuilder.BsForm.InputWidthMd, _formBuilder.BsForm.InputWidthLg); sizingDiv.ApplyColumnOffsets(null, _formBuilder.BsForm.LabelWidthXs, _formBuilder.BsForm.LabelWidthSm, _formBuilder.BsForm.LabelWidthMd, _formBuilder.BsForm.LabelWidthLg); var checkBoxDiv = new BsHtmlElement(HtmlTag.Div).CssClass(BsClass.Control.CheckBox); var label = new BsHtmlElement(HtmlTag.Label); var input = CreateInput(inputTagType, autoFocus, modelMetadata, propName); input.Attr(modelMetadata.Model != null && modelMetadata.Model.ToString().ToLower() == "true", HtmlAttr.Checked, HtmlAttr.Checked); var hiddenInput = new BsHtmlElement(HtmlTag.Input) .Attr(HtmlAttr.Name, modelMetadata.PropertyName) .Attr(HtmlAttr.Type, HtmlInputType.Hidden) .Attr(HtmlAttr.Value, "false"); // --- Assemble the elements formGroup.AddChild(sizingDiv); sizingDiv.AddChild(checkBoxDiv); checkBoxDiv.AddChild(label); label .AddChild(input) .AddChild(new HtmlText(modelMetadata.DisplayName ?? modelMetadata.PropertyName)) .AddChild(hiddenInput); } return(formGroup.Markup); }
public HtmlElementBase <BsHtmlElement> CreateInput(InputTagType inputTagType, AutoFocus autoFocus, ModelMetadata modelMetadata, string name) { name = CamelCase(name); var input = new BsHtmlElement(HtmlTag.Input) .CssClass(inputTagType != InputTagType.CheckBox, BsClass.Control.FormControl) .Attr(HtmlAttr.Type, GetInputTypeString(modelMetadata, inputTagType)) .Attr(HtmlAttr.Id, name) .Attr(HtmlAttr.Name, name) .Attr(NgTag.NgModel, string.Format("model.{0}", name)); if (modelMetadata.Model != null) { var modelValue = modelMetadata.Model.ToString(); input .Attr(HtmlAttr.Value, modelValue) .Attr(NgTag.NgInit, string.Format("model.{0}={1}", name, JsonConvert.SerializeObject(modelMetadata.Model))); } // --- Set the appropriate autofocus if (autoFocus == AutoFocus.Set || (_formBuilder.HtmlHelper.ViewData.ModelState.IsValid && autoFocus == AutoFocus.OnFormValid) || (!_formBuilder.HtmlHelper.ViewData.ModelState.IsValid && autoFocus == AutoFocus.OnFormInvalid)) { input.Attr(HtmlAttr.AutoFocus); } // --- Validation attributes for input foreach (var attribute in modelMetadata.AdditionalValues.Values.OfType <ValidationAttributeMetadata>()) { foreach (var directive in attribute.DirectiveSet) { input.Attr(directive.Key, directive.Value ?? ""); } if (attribute.AdditionalAttributes == null) { continue; } foreach (var key in attribute.AdditionalAttributes.Keys) { input.Attr(key, attribute.AdditionalAttributes[key]); } } return(input); }
/// <summary> /// Builds a columnar input control /// </summary> /// <param name="modelMetadata">Model metadata</param> /// <param name="inputTagType">Type of the input tag</param> /// <param name="autoFocus">Autofocus type</param> /// <param name="validationOption">Validation type</param> public MvcHtmlString BuildColumnarInput(ModelMetadata modelMetadata, InputTagType inputTagType, AutoFocus autoFocus, ValidationOption validationOption) { return(MvcHtmlString.Empty); }
public override int GetHashCode() { int hash = 1; if (CameraDev.Length != 0) { hash ^= CameraDev.GetHashCode(); } if (FrameId.Length != 0) { hash ^= FrameId.GetHashCode(); } if (PixelFormat.Length != 0) { hash ^= PixelFormat.GetHashCode(); } if (IoMethod != 0) { hash ^= IoMethod.GetHashCode(); } if (Width != 0) { hash ^= Width.GetHashCode(); } if (Height != 0) { hash ^= Height.GetHashCode(); } if (FrameRate != 0) { hash ^= FrameRate.GetHashCode(); } if (Monochrome != false) { hash ^= Monochrome.GetHashCode(); } if (Brightness != 0) { hash ^= Brightness.GetHashCode(); } if (Contrast != 0) { hash ^= Contrast.GetHashCode(); } if (Saturation != 0) { hash ^= Saturation.GetHashCode(); } if (Sharpness != 0) { hash ^= Sharpness.GetHashCode(); } if (Gain != 0) { hash ^= Gain.GetHashCode(); } if (AutoFocus != false) { hash ^= AutoFocus.GetHashCode(); } if (Focus != 0) { hash ^= Focus.GetHashCode(); } if (AutoExposure != false) { hash ^= AutoExposure.GetHashCode(); } if (Exposure != 0) { hash ^= Exposure.GetHashCode(); } if (AutoWhiteBalance != false) { hash ^= AutoWhiteBalance.GetHashCode(); } if (WhiteBalance != 0) { hash ^= WhiteBalance.GetHashCode(); } if (BytesPerPixel != 0) { hash ^= BytesPerPixel.GetHashCode(); } if (TriggerInternal != 0) { hash ^= TriggerInternal.GetHashCode(); } if (TriggerFps != 0) { hash ^= TriggerFps.GetHashCode(); } if (ChannelName.Length != 0) { hash ^= ChannelName.GetHashCode(); } if (DeviceWaitMs != 0) { hash ^= DeviceWaitMs.GetHashCode(); } if (SpinRate != 0) { hash ^= SpinRate.GetHashCode(); } if (OutputType != 0) { hash ^= OutputType.GetHashCode(); } if (compressConf_ != null) { hash ^= CompressConf.GetHashCode(); } return(hash); }