internal void ExtractProfileFromControl(Control p_control) { if (p_control.GetType().GetMember(PersistableProperty)[0].MemberType != System.Reflection.MemberTypes.Property) return; object value = p_control.GetType().GetProperty(this.PersistableProperty).GetValue(p_control, null); this.PropertyValue = value; }
protected override void CreateControlInternal(Control control) { if (GetProperty<bool>("Windowless") && !(control is Window)) return; if (handlesByControl.ContainsKey(control)) return; string className = control.ClassName; bool classNameRequiresRegistration = true; if (className == null) { if (ControlClassNames.ContainsKey(control.GetType())) { className = ControlClassNames[control.GetType()]; classNameRequiresRegistration = false; } } else if (ControlClassNames.ContainsValue(className)) { classNameRequiresRegistration = false; } if (classNameRequiresRegistration) { EnsureWindowClassRegistered(className); } IntPtr hWndParent = IntPtr.Zero; if (control.Parent != null) { hWndParent = handlesByControl[control.Parent]; } Rectangle bounds = new Rectangle(); if (control is Window) { bounds = ClientBoundsToPhysicalBounds((control as Window).Bounds); } else { bounds = control.Parent.Layout.GetControlBounds(control); } IntPtr handle = Internal.Windows.Methods.User32.CreateWindowEx(GetWindowStylesExForControl(control), className, control.Text, GetWindowStylesForControl(control), (int)bounds.X, (int)bounds.Y, (int)bounds.Width, (int)bounds.Height, hWndParent, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero); if (handle != IntPtr.Zero) { Font font = control.Font; if (font == null) font = SystemFonts.MenuFont; { font = Font.FromFamily("Tahoma", 10); } IntPtr hFont = GetHandleByFont(Internal.Windows.Methods.User32.GetDC(handle), font); Internal.Windows.Methods.User32.SendMessage(handle, Internal.Windows.Constants.User32.WindowMessages.SetFont, hFont, new IntPtr(1)); controlsByHandle[handle] = control; handlesByControl[control] = handle; } }
internal void LoadControlFromProfile(Control p_control) { if (p_control == null || this.PropertyValue == null) return; if(p_control.GetType().GetMember(PersistableProperty).Length == 0) return; if (p_control.GetType().GetMember(PersistableProperty)[0].MemberType == System.Reflection.MemberTypes.Property) { p_control.GetType().GetProperty(this.PersistableProperty).SetValue(p_control, this.PropertyValue, null); } }
public static IHtmlString Render(this HtmlHelper html, Control control) { if (control == null) { return MvcHtmlString.Empty; } var theme = Theme.Current; var template = theme.ResolveControl(control.GetType()); if (string.IsNullOrEmpty(template)) { return MvcHtmlString.Create("there is no template for control " + control.GetType().FullName); } return html.Partial(template, control); }
public override bool ContainsText(string text) { return(TizenAppium.RunOnMainThread <bool>(() => { string[] TextProperties = { "Text", "Label" }; foreach (var prop in TextProperties) { var value = Control?.GetType().GetProperty(prop)?.GetValue(Control).ToString(); if (value == text) { return true; } } string[] TextParts = { "elm.text", "elm.test.end", "elm.test.sub", "elm.test.sub.end", "elm.swallow.content" }; foreach (var part in TextParts) { string str = Control?.GetPartText(part); if (str == text) { return true; } } return false; })); }
/// <summary> /// Returns <see langword="true"/> if the instance can render <paramref name="control"/>; otherwise <see langword="false"/>. /// </summary> /// <param name="control">The control to be rendered.</param> /// <returns><see langword="true"/> if the instance can render <paramref name="control"/>; otherwise <see langword="false"/>.</returns> public override bool CanRender(Control control) { Type controlType = control.GetType(); return controlType == typeof(HeadingControl) || controlType == typeof(LabelControl) || controlType == typeof(HtmlControl); }
public virtual bool SetPropertyValue(string propertyName, object value) { return TizenAppium.RunOnMainThread<bool>(() => { var property = Control?.GetType().GetProperty(propertyName); if (property == null) { Log.Debug(Id + " element does not have " + propertyName + " property."); return false; } try { var valueType = property.GetValue(Control).GetType(); var convertedValue = Convert.ChangeType(value, valueType); property.SetValue(Control, convertedValue); } catch (Exception e) { Log.Debug(e.ToString()); return false; } return true; }); }
public void ClearControl(Control control) { switch (control.GetType().Name) { case "TextBox": var txtBox = (TextBox)control; txtBox.Text = String.Empty; break; case "DropDownList": var ddl = (DropDownList)control; ddl.SelectedIndex = 0; break; case "CheckBox": var chk = (CheckBox)control; chk.Checked = false; break; case "CheckBoxList": var chkList = (CheckBoxList)control; foreach (ListItem li in chkList.Items) li.Selected = false; break; case "Panel": ClearFields((Panel)control); break; case "RadioButtonList": var rbl = (RadioButtonList)control; rbl.SelectedIndex = -1; break; } }
public TreeNode(Control control) { Control = control; Type = control.GetType().Name; var classesChanged = Observable.FromEventPattern< NotifyCollectionChangedEventHandler, NotifyCollectionChangedEventArgs>( x => control.Classes.CollectionChanged += x, x => control.Classes.CollectionChanged -= x); classesChanged.Select(_ => Unit.Default) .StartWith(Unit.Default) .Subscribe(_ => { if (control.Classes.Count > 0) { Classes = "(" + string.Join(" ", control.Classes) + ")"; } else { Classes = string.Empty; } }); }
protected override void OnDetached() { try { if (Control?.GetType() is Type controlType) { if (controlType.GetMethodInfo("PreviewKeyDown") is System.Reflection.MethodInfo) { Control.PreviewKeyDown -= OnKeyDown; } else if (controlType.GetMethodInfo("KeyDown") is System.Reflection.MethodInfo) { Control.KeyDown -= OnKeyDown; } Control.CharacterReceived -= OnCharacterReceived; } else if (Container?.GetType() is Type containerType) { if (containerType.GetMethodInfo("PreviewKeyDown") is System.Reflection.MethodInfo) { Container.PreviewKeyDown -= OnKeyDown; } else if (containerType.GetMethodInfo("KeyDown") is System.Reflection.MethodInfo) { Container.KeyDown -= OnKeyDown; } Container.CharacterReceived -= OnCharacterReceived; } } catch (Exception) { } }
public override void VerifyRenderingInServerForm(Control control) { if (!(control.GetType().Name.Equals("SmartGridView"))) { base.VerifyRenderingInServerForm(control); } }
public static void SetLabelColumnWidth(this PropertyGrid grid, int width) { FieldInfo fi = grid?.GetType().GetField("gridView", BindingFlags.Instance | BindingFlags.NonPublic); Control view = fi?.GetValue(grid) as Control; MethodInfo mi = view?.GetType().GetMethod("MoveSplitterTo", BindingFlags.Instance | BindingFlags.NonPublic); mi?.Invoke(view, new object[] { width }); }
public Binding(Control source, string sourcePropertyName, object target, string targetPropertyName, Func<object,object> targetValueConverter) { _targetValueConverter = targetValueConverter; _target = target; _targetProperty = target.GetType().GetProperty(targetPropertyName); _targetField = target.GetType().GetField(targetPropertyName); _targetMethod = target.GetType().GetMethod(targetPropertyName); if (_target is INotifyPropertyChanged && _targetMethod == null) { (_target as INotifyPropertyChanged).PropertyChanged += TargetPropertyChanged; } _source = source; //If it's the default property we support two way binding if (sourcePropertyName == null) { switch (_source.GetType().Name) { case "TextBoxEx": sourcePropertyName = "Text"; (_source as TextBoxEx).TextChanged += Binding_TextChanged; (_source as TextBoxEx).CanTextCommit += Binding_CanTextCommit; (_source as TextBoxEx).TextCommit += Binding_TextCommit; break; case "CheckBox": sourcePropertyName = "Checked"; (_source as CheckBox).CheckedChanged += Binding_CheckedChanged; break; case "DropDownList": sourcePropertyName = "SelectedItem"; (_source as DropDownList).SelectedItemChanged += Binding_SelectedItemChanged; break; case "ColorButton": sourcePropertyName = "Color"; (_source as ColorButton).ColorChanged += Binding_ColorChanged; break; } } if (sourcePropertyName == null) throw new NotImplementedException(string.Format("No default property defined for control {0}!", _source.GetType().Name)); _sourceProperty = source.GetType().GetProperty(sourcePropertyName); if (_targetMethod == null) TargetPropertyChanged(_source, null); }
public virtual object GetPropertyValue(string propertyName) { return TizenAppium.RunOnMainThread<object>(() => { var value = Control?.GetType().GetProperty(propertyName)?.GetValue(Control); return value; }); }
public virtual bool HasProperty(string propertyName) { var property = Control?.GetType().GetProperty(propertyName); if (property == null) return false; return true; }
void setpgColumnWidth(PropertyGrid grid, int width) { FieldInfo fi = grid?.GetType().GetField("tabViewWorkflow", BindingFlags.Instance | BindingFlags.NonPublic); Control view = fi?.GetValue(grid) as Control; MethodInfo mi = view?.GetType().GetMethod("MoveSplitterTo", BindingFlags.Instance | BindingFlags.NonPublic); mi?.Invoke(view, new object[] { width }); }
/// <summary> /// </summary> public ControlCollection(Control owner) : base(owner) { if (owner == null || owner.GetType() != typeof(MultiPanelPage)) throw new ArgumentNullException("owner", "Tried to create a MultiPanelPage.ControlCollection with a null owner."); MultiPanelPage c = owner as MultiPanelPage; if (c == null) throw new ArgumentException("Tried to create a MultiPanelPage.ControlCollection with a non-MultiPanelPage owner.", "owner"); }
/// <summary> /// Returns <see langword="true"/> if the instance can render <paramref name="control"/>; otherwise <see langword="false"/>. /// </summary> /// <param name="control">The control to be rendered.</param> /// <returns><see langword="true"/> if the instance can render <paramref name="control"/>; otherwise <see langword="false"/>.</returns> public bool CanRender(Control control) { Type controlType = control.GetType(); return controlType == typeof(CalculationControl) || controlType == typeof(FileBrowserControl) || controlType == typeof(GeolocationControl) || controlType == typeof(HiddenControl) || controlType == typeof(SearchControl) || controlType == typeof(SummaryControl); }
/// <summary> /// 清除所指定的元件的所有 controls /// </summary> private void ClearControls(Control control) { for (int i = control.Controls.Count - 1; i >= 0; i--) { ClearControls(control.Controls[i]); } if (!(control is TableCell)) { if (control.GetType().GetProperty("SelectedItem") != null) { control.Parent.Controls.Remove(control); } else if (control.GetType().GetProperty("Text") != null) { control.Parent.Controls.Remove(control); } } return; }
public string GenerateControlId(Control control , int index) { if (control.Id != null) return control.Id; string name = control.Name; if (string.IsNullOrEmpty(name)) name = control.GetType().Name; return name + "_id" + index; }
/// <summary> /// Called when the effect is attached. /// </summary> protected override void OnAttached() { _elementFontFamilyProperty = Element?.GetType().GetProperty("FontFamily"); _controlFontFamilyProperty = Control?.GetType().GetProperty("FontFamily"); _controlTextProperty = Control.GetType().GetProperty("Text"); if (_elementFontFamilyProperty != null) { _instance = _instances++; _embeddedResourceFontEffect = (Forms9Patch.EmbeddedResourceFontEffect)Element.Effects.FirstOrDefault(e => e is Forms9Patch.EmbeddedResourceFontEffect); UpdateFont(); } }
private void AssignValueToControl(Form form, string controlName, string controlProperty, object value) { if (value == null) { return; } Control ctrl = form.Controls.Find(controlName, true).FirstOrDefault(); if (ctrl == null) { return; } if (string.IsNullOrEmpty(controlProperty)) { if (ctrl?.GetType() == typeof(Label)) { ctrl.GetType().GetProperties().Select(x => x).Where(x => x.Name == "Text").FirstOrDefault().SetValue(ctrl, ((double)value).ToString("###0.00")); } else if (ctrl?.GetType() == typeof(NumericUpDown)) { ctrl.GetType().GetProperties().Select(x => x).Where(x => x.Name == "Value").FirstOrDefault().SetValue(ctrl, decimal.Parse(value.ToString())); ctrl.Enabled = true; } else if (ctrl?.GetType() == typeof(PictureBox)) { ctrl.GetType().GetProperties().Select(x => x).Where(x => x.Name == "Image").FirstOrDefault().SetValue(ctrl, (bool)value ? new Bitmap(FolderHmi.Properties.Resources.check) : new Bitmap(FolderHmi.Properties.Resources.bad)); } else if (ctrl?.GetType() == typeof(Button)) { Button b = ctrl as Button; b.ImageIndex = (bool)value ? 1 : 0; b.Enabled = !(bool)value; } } else { ctrl?.GetType().GetProperties().Select(x => x).Where(x => x.Name == controlProperty).FirstOrDefault().SetValue(ctrl, value); } }
public static void RegistrarScriptBlock(string pstrClave, string pstrScript, Control pctlControl) { Page pg_Pagina = (Page)HttpContext.Current.Handler; if (IsInAsyncPostBack(pg_Pagina)) { if (pctlControl == null) pctlControl = pg_Pagina; System.Web.UI.ScriptManager.RegisterClientScriptBlock(pctlControl, pctlControl.GetType(), pstrClave, pstrScript, true); } else { pg_Pagina.ClientScript.RegisterClientScriptBlock(pg_Pagina.GetType(), pstrClave, pstrScript, true); } }
/// <devdoc> /// Returns a list of all the propery names for a given control. /// </devdoc> private string[] GetPropertyNames(Control control) { ArrayList array = new ArrayList(); PropertyDescriptorCollection pdc = TypeDescriptor.GetProperties(control.GetType()); foreach (PropertyDescriptor desc in pdc) { array.Add(desc.Name); } array.Sort(Comparer.Default); return (string[])array.ToArray(typeof(string)); }
void ApplyEffect(bool apply) { if (EditText == null) { throw new NotSupportedException($"Control of type: {Control?.GetType()?.Name} is not supported by this effect."); } EditText.GotFocus -= OnGotFocus; if (apply) { EditText.GotFocus += OnGotFocus; } }
public virtual bool ContainsText(string text) { return TizenAppium.RunOnMainThread<bool>(() => { foreach (var prop in DisplayedTextProperies) { var textValue = Control?.GetType().GetProperty(prop)?.GetValue(Control)?.ToString(); if (!string.IsNullOrEmpty(textValue)) { if (textValue.Equals(text)) { return true; } } } return false; }); }
public TreeNode(Control control) { Control = control; Type = control.GetType().Name; control.Classes.Changed.Select(_ => Unit.Default) .StartWith(Unit.Default) .Subscribe(_ => { if (control.Classes.Count > 0) { Classes = "(" + string.Join(" ", control.Classes) + ")"; } else { Classes = string.Empty; } }); }
public void UpdateDecoratorData( Control control ) { foreach( Control child in Children ) { if ( child is DecoratorItem ) { DecoratorItem item = child as DecoratorItem; item.BoundDecoratorlSelected -= item_BoundDecoratorlSelected; item.Release(); RemoveChild( item ); } } int i = 0; int count = 0; Control c = (Control)Activator.CreateInstance( control.GetType() ); int builtinDecorators = c.Decorators.Count; foreach ( Decorator d in control.Decorators ) { count++; if ( count <= builtinDecorators ) { continue; } DecoratorItem item = new DecoratorItem( d ); AddChild( item ); item.SetPosition( LEVEL_INDENT * ( m_depth + 1 ), ( i + 1 ) * LINE_HEIGHT ); i++; item.BoundDecoratorlSelected += item_BoundDecoratorlSelected; } SetHeight( ( i + 1 ) * LINE_HEIGHT ); }
public static void RegisterMessageBox(int pintMsgBox, string pstrMensaje, Control pctlAsyncTarget, string pstrURL) { pintMsgBox += 1; Page pg_Pagina = (Page)HttpContext.Current.Handler; pstrMensaje = pstrMensaje.Replace("'", string.Empty); pstrMensaje = pstrMensaje.Replace("\n", "\\n"); pstrMensaje = pstrMensaje.Replace("\r", "\\r"); if (pstrURL.Length > 0) pstrURL = String.Format("window.location = '{0}';", pstrURL); System.Web.UI.ScriptManager obj_ScManager = System.Web.UI.ScriptManager.GetCurrent(pg_Pagina); if (obj_ScManager.IsInAsyncPostBack && pctlAsyncTarget != null) { ScriptManager.RegisterStartupScript(pctlAsyncTarget, pctlAsyncTarget.GetType(), String.Format("__alert{0}", pintMsgBox), String.Format(" alert('{0}');{1}", pstrMensaje, pstrURL), true); } else { pg_Pagina.ClientScript.RegisterStartupScript(pg_Pagina.GetType(), String.Format("__alert{0}", pintMsgBox), String.Format(" alert('{0}');{1}", pstrMensaje, pstrURL), true); } }
static bool ResolveDesignMode( Control control ) { System.Reflection.PropertyInfo designModeProperty; bool designMode; // Get the protected property designModeProperty = control.GetType().GetProperty( "DesignMode", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic ); // Get the controls DesignMode value designMode = (bool)designModeProperty.GetValue( control, null ); // Test the parent if it exists if( control.Parent != null ) { designMode |= ResolveDesignMode( control.Parent ); } return designMode; }
/// <devdoc> /// Walks up the stack of NamingContainers starting at 'control' to find a control with the ID 'controlID'. /// Important : Note that the search is never done on the 'control' itself by this method. /// </devdoc> public static Control FindControl(Control control, string controlID) { Debug.Assert(control != null, "control should not be null"); Debug.Assert(!String.IsNullOrEmpty(controlID), "controlID should not be empty"); Control currentContainer = control; Control foundControl = null; if (control == control.Page) { // If we get to the Page itself while we're walking up the // hierarchy, just return whatever item we find (if anything) // since we can't walk any higher. return control.FindControl(controlID); } while (foundControl == null && currentContainer != control.Page) { currentContainer = currentContainer.NamingContainer; if (currentContainer == null) { throw new HttpException(SR.GetString(SR.DataBoundControlHelper_NoNamingContainer, control.GetType().Name, control.ID)); } foundControl = currentContainer.FindControl(controlID); } return foundControl; }
private void ContainerleriGizle(Control c) { if (c.GetType().Name == "HtmlForm") return; if (c.GetType().Name == "HtmlGenericControl") { c.Visible = false; ContainerleriGizle(c.Parent); } }
private void SaveCFF() { bool exit = false; string description = string.Empty; int _block = 0; string assessment = string.Empty; string _letter = string.Empty; CultureInfo ci = new CultureInfo("es-AR"); string separator = ci.NumberFormat.NumberDecimalSeparator; string username = UserHelper.GetUserId(Request.LogonUserIdentity.Name); string[] _params = new string[] { }; _params = Encryption.Decrypt(Request.Params["."]).Split('.'); int groupId = Convert.ToInt16(_params[0]); int profile = Convert.ToInt16(_params[1]); if (profile > 1) { username = _params[2]; } for (int i = 0; !exit; i++) { Control answer = (Control)this.Master.FindControl("CPH").FindControl("CFF").FindControl("ctl" + i.ToString("00")); exit = answer == null; if (!exit) { if (answer.GetType().ToString() == "System.Web.UI.WebControls.TextBox") { TextBox myControl = (TextBox)answer; string[] values = myControl.SkinID.Split('_'); if (!myControl.ReadOnly) { // ********* 1 linea modificada del original //SQLHelper.ExecuteNonQuery(Cache["ApplicationDatabase"].ToString(), "[SaveResultComment]", new object[] { values[0], 5, myControl.Text, values[1] }); SQLHelper.ExecuteNonQuery(Cache["ApplicationDatabase"].ToString( ), "[SaveResultComment]", new object[] { values[0], 5, myControl.Text, values[1], "0" }); } myControl.Dispose(); } if (answer.GetType().ToString() == "System.Web.UI.WebControls.RadioButton") { RadioButton myControl = (RadioButton)answer; string[] values = myControl.SkinID.ToUpper().Split('_'); if (myControl.Checked) { // ************ 9 linea agregada al original if (values.Length != 1) { _block = (Convert.ToInt16(values[1]) <= 5) ? 2 : 3; SQLHelper.ExecuteNonQuery(Cache["ApplicationDatabase"].ToString( ), "SaveResultCompetency", new object[] { values[0], _block, values[1], values[2], values[3], true }); } } myControl.Dispose(); } answer.Dispose(); } } SQLHelper.ExecuteNonQuery(Cache["ApplicationDatabase"].ToString(), "SaveOverallResult", new object[] { username, groupId }); }
public virtual void InitCloneControlProperties(Control currentControl, ControlPropertyDefineWrapper propertyDefineWrapper) { if (propertyDefineWrapper != null && !propertyDefineWrapper.UseTemplate) { if (propertyDefineWrapper.ControlPropertyDefineList != null) { foreach (ControlPropertyDefine define in propertyDefineWrapper.ControlPropertyDefineList) { PropertyInfo piDest = TypePropertiesCacheQueue.Instance.GetPropertyInfo(currentControl.GetType(), define.PropertyName); if (piDest != null) { if (string.IsNullOrEmpty(define.StringValue) == true || piDest.CanWrite == false) { continue; } if (piDest.PropertyType == typeof(Unit)) { piDest.SetValue(currentControl, Unit.Parse(define.StringValue), null); } else { piDest.SetValue(currentControl, define.GetRealValue(), null); } } } } } }
private static void AddControl(KPFormCustomization kpfc, Control c) { if ((kpfc == null) || (c == null)) { Debug.Assert(false); return; } bool bAdd = true; Type t = c.GetType(); if (c.Text.Length == 0) { bAdd = false; } else if (c.Name.Length == 0) { bAdd = false; } else if (t == typeof(MenuStrip)) { bAdd = false; } else if (t == typeof(PictureBox)) { bAdd = false; } else if (t == typeof(TreeView)) { bAdd = false; } else if (t == typeof(ToolStrip)) { bAdd = false; } else if (t == typeof(WebBrowser)) { bAdd = false; } else if (t == typeof(Panel)) { bAdd = false; } else if (t == typeof(StatusStrip)) { bAdd = false; } else if (c.Text.StartsWith(@"<") && c.Text.EndsWith(@">")) { bAdd = false; } if (t == typeof(TabControl)) { bAdd = true; } else if (t == typeof(ProgressBar)) { bAdd = true; } else if (t == typeof(TextBox)) { bAdd = true; } else if (t == typeof(PromptedTextBox)) { bAdd = true; } else if (t == typeof(RichTextBox)) { bAdd = true; } else if (t == typeof(ComboBox)) { bAdd = true; } else if (t == typeof(Label)) { bAdd = true; } else if (t == typeof(ListView)) { bAdd = true; } else if (t == typeof(Button)) { bAdd = true; } else if (t == typeof(KeePass.UI.QualityProgressBar)) { bAdd = true; } else if (t == typeof(DateTimePicker)) { bAdd = true; } if (bAdd && (c.Name.Length > 0)) { KPControlCustomization kpcc = new KPControlCustomization(); kpcc.Name = c.Name; kpcc.BaseHash = KPControlCustomization.HashControl(c); if ((t != typeof(TabControl)) && (t != typeof(NumericUpDown))) { kpcc.TextEnglish = c.Text; } else { kpcc.TextEnglish = string.Empty; } kpfc.Controls.Add(kpcc); } foreach (Control cSub in c.Controls) { AddControl(kpfc, cSub); } }
private void SaveMI() { bool exit = false; string description = string.Empty; decimal weight = 0; decimal result = 0; decimal _total = 0; string assessment = string.Empty; bool _delete = false; string _letter = string.Empty; CultureInfo ci = new CultureInfo("es-AR"); string separator = ci.NumberFormat.NumberDecimalSeparator; for (int i = 0; !exit; i++) { Control answer = (Control)this.Master.FindControl("CPH").FindControl("MI").FindControl("ctl" + i.ToString("00")); exit = answer == null; if (!exit) { if (answer.GetType().ToString() == "System.Web.UI.WebControls.TextBox") { TextBox myControl = (TextBox)answer; string[] values = myControl.SkinID.ToUpper().Split('_'); switch (values[0]) { case "1": description = myControl.Text.ToString(); break; case "2": weight = (myControl.Text.ToString() == string.Empty) ? 0 : Convert.ToDecimal(myControl.Text); break; case "4": _delete = (bool)(assessment != values[1]); if (_delete) { HiddenField letter = (HiddenField)this.Master.FindControl("CPH").FindControl("MI").FindControl(myControl.Parent.Parent.Parent.ID + "_l"); string[] _values = letter.Value.Trim().Split('_'); if (_values.Length != 1) { _letter = _values[0]; _total = Convert.ToDecimal(_values[1].Replace('.', Convert.ToChar(separator))); } else { _letter = string.Empty; _total = 0; } letter.Dispose(); } assessment = values[1]; result = (myControl.Text.ToString() == string.Empty) ? 0 : Convert.ToDecimal(myControl.Text); SQLHelper.ExecuteNonQuery(Cache["ApplicationDatabase"].ToString(), "SaveResultVariable", new object[] { values[1], 1, values[2], description, weight, result, _letter, _total, _delete }); description = string.Empty; weight = 0; result = 0; break; } myControl.Dispose(); } answer.Dispose(); } } }
private void ApplyReadRules( Control ctl, Binding binding, bool canRead) { var status = GetControlStatus(ctl); // enable/disable reading of the value if (canRead) { ctl.Enabled = true; // if !CanRead remove format event and refresh value if (!status.CanRead) { binding.Format -= ReturnEmpty; binding.ReadValue(); } } else { ctl.Enabled = false; if (status.CanRead) { binding.Format += ReturnEmpty; } // clear the value displayed by the control var propertyInfo = ctl.GetType().GetProperty(binding.PropertyName, BindingFlags.FlattenHierarchy | BindingFlags.Instance | BindingFlags.Public); if (propertyInfo != null) { propertyInfo.SetValue(ctl, GetEmptyValue( Utilities.GetPropertyType( propertyInfo.PropertyType)), new object[] { }); } } // store new status status.CanRead = canRead; }
public static void JQueryErrMsg(string StrMessage, object Page) { Control Ctr = (Control)Page; ScriptManager.RegisterStartupScript(Ctr, Ctr.GetType(), "BootboxAlert" + StrMessage, "bootbox.alert('" + StrMessage.Replace("'", "\\'") + "');", true); }
/// <summary> /// Lets process our .Body content and build up our controls collection /// inside the 'BodyContent' placeholder. /// /// User controls are insterted into the blog in the following format.. /// [UserControl:~/path/usercontrol.ascx] /// /// TODO : Expose user control parameters. /// /// </summary> protected void Page_Load(object sender, EventArgs e) { // Used to track where we are in the 'Body' as we parse it. int currentPosition = 0; string content = Body; PlaceHolder bodyContent = (PlaceHolder)FindControl("BodyContent"); if (bodyContent != null) { MatchCollection myMatches = _BodyRegex.Matches(content); foreach (Match myMatch in myMatches) { // Add literal for content before custom tag should it exist. if (myMatch.Index > currentPosition) { bodyContent.Controls.Add(new LiteralControl(content.Substring(currentPosition, myMatch.Index - currentPosition))); } // Now lets add our user control. try { string all = myMatch.Groups[1].Value.Trim(); Control usercontrol = null; if (!all.EndsWith(".ascx", StringComparison.OrdinalIgnoreCase)) { int index = all.IndexOf(".ascx", StringComparison.OrdinalIgnoreCase) + 5; usercontrol = LoadControl(all.Substring(0, index)); string parameters = Server.HtmlDecode(all.Substring(index)); Type type = usercontrol.GetType(); string[] paramCollection = parameters.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); foreach (string param in paramCollection) { string name = param.Split('=')[0].Trim(); string value = param.Split('=')[1].Trim(); System.Reflection.PropertyInfo property = type.GetProperty(name); property.SetValue(usercontrol, Convert.ChangeType(value, property.PropertyType, CultureInfo.InvariantCulture), null); } } else { usercontrol = LoadControl(all); } bodyContent.Controls.Add(usercontrol); // Now we will update our position. //currentPosition = myMatch.Index + myMatch.Groups[0].Length; } catch (Exception) { // Whoopss, can't load that control so lets output something that tells the developer that theres a problem. bodyContent.Controls.Add(new LiteralControl("ERROR - UNABLE TO LOAD CONTROL : " + myMatch.Groups[1].Value)); } currentPosition = myMatch.Index + myMatch.Groups[0].Length; } // Finally we add any trailing static text. bodyContent.Controls.Add(new LiteralControl(content.Substring(currentPosition, content.Length - currentPosition))); } else { // We have no placeholder so we assume this is an old style <% =Body %> theme and do nothing. } }
///<summary></summary> public static void C(Control sender, Control[] arrayControls, bool isRecursive) { string classType = (sender == null ? "All": sender.GetType().Name); C(classType, arrayControls, isRecursive); }
///<summary>C is for control. Translates the text of all menu items to another language.</summary> public static void C(Control sender, params Menu[] arrayMenus) { string classType = (sender == null ? "All": sender.GetType().Name); C(classType, arrayMenus); }
// ******************* 3 linea modificada del original private void SetStatus(int current_profile) { // **************** 2 linea modificada del original //string username = UserHelper.GetUserId(Request.LogonUserIdentity.Name); //SQLHelper.ExecuteNonQuery(Cache["ApplicationDatabase"].ToString(), "[SetAssessmentsSatus]", new object[] { null, Convert.ToInt16(_params[0]), username, _status }); string username = UserHelper.GetUserId(Request.LogonUserIdentity.Name); //SqlDataReader myReader = SQLHelper.ExecuteReader( Cache["ApplicationDatabase"].ToString( ) , "GetEvaluatedPeople" , new object[] { _params[2] } ); //myReader.Read( ); bool exit = false; string description = string.Empty; string assessment = string.Empty; string _letter = string.Empty; CultureInfo ci = new CultureInfo("es-AR"); string separator = ci.NumberFormat.NumberDecimalSeparator; _params = Encryption.Decrypt(Request.Params["."]).Split('.'); int groupId = Convert.ToInt16(_params[0]); int profile = Convert.ToInt16(_params[1]); if (current_profile == 1) // Si el que firma es el evaluador envia la evaluacion al concurrente.... { //SQLHelper.ExecuteNonQuery( Cache["ApplicationDatabase"].ToString( ) , "[SetAssessmentsSatus]" , new object[] { null , Convert.ToInt16( _params[0] ) , username , 3 } ); if (profile > 1) { username = _params[2]; } for (int i = 0; !exit; i++) { Control answer = (Control)this.Master.FindControl("CPH").FindControl("CFF").FindControl("ctl" + i.ToString("00")); exit = answer == null; if (!exit) { if (answer.GetType( ).ToString( ) == "System.Web.UI.WebControls.TextBox") { TextBox myControl = (TextBox)answer; string[] values = ((TextBox)answer).SkinID.Split('_'); if (!myControl.ReadOnly) { Control radio = (Control)this.Master.FindControl("CPH").FindControl("CFF").FindControl("ctl" + (i - 1).ToString("00")); //if( ( (RadioButton)radio ).Checked ) if (profile == 1) // Si envia el evaluador... { SqlDataReader ReaderDR = SQLHelper.ExecuteReader(Cache["ApplicationDatabase"].ToString( ), "EvaluatedHasConcurrent", new object[] { Convert.ToInt32(((TextBox)answer).SkinID.Split('_')[0].ToString( )) }); ReaderDR.Read( ); if (ReaderDR.HasRows) // si el concurrente no es nulo va al concurrente y el envia un email... { SQLHelper.ExecuteNonQuery(Cache["ApplicationDatabase"].ToString( ), "[SetAssessmentsSatus]", new object[] { ((TextBox)answer).SkinID.Split('_')[0], Convert.ToInt16(_params[0]), _params[2], 3 }); } else // si no tiene concurrente se fija si tiene doble reporte { ReaderDR = SQLHelper.ExecuteReader(Cache["ApplicationDatabase"].ToString( ), "EvaluatedHasDoubleReport", new object[] { Convert.ToInt32(((TextBox)answer).SkinID.Split('_')[0].ToString( )) }); ReaderDR.Read( ); if (ReaderDR.HasRows) // si tiene doble reporte va al Doble Reporte y el envia un email... { SQLHelper.ExecuteNonQuery(Cache["ApplicationDatabase"].ToString( ), "[SetAssessmentsSatus]", new object[] { ((TextBox)answer).SkinID.Split('_')[0], Convert.ToInt16(_params[0]), _params[2], 6 }); } else // si no tiene doble reporte va a RRHH y le envia un email... { SQLHelper.ExecuteNonQuery(Cache["ApplicationDatabase"].ToString( ), "[SetAssessmentsSatus]", new object[] { ((TextBox)answer).SkinID.Split('_')[0], Convert.ToInt16(_params[0]), _params[2], 9 }); } } } } myControl.Dispose( ); } } } } else { //bool exit = false; //string description = string.Empty; //string assessment = string.Empty; //string _letter = string.Empty; //CultureInfo ci = new CultureInfo( "es-AR" ); //string separator = ci.NumberFormat.NumberDecimalSeparator; //_params = Encryption.Decrypt( Request.Params["."] ).Split( '.' ); //int groupId = Convert.ToInt16( _params[0] ); //int profile = Convert.ToInt16( _params[1] ); if (profile > 1) { username = _params[2]; } for (int i = 0; !exit; i++) { Control answer = (Control)this.Master.FindControl("CPH").FindControl("CFF").FindControl("ctl" + i.ToString("00")); exit = answer == null; if (!exit) { if (answer.GetType( ).ToString( ) == "System.Web.UI.WebControls.TextBox") { TextBox myControl = (TextBox)answer; string[] values = ((TextBox)answer).SkinID.Split('_'); if (!myControl.ReadOnly) { Control radio = (Control)this.Master.FindControl("CPH").FindControl("CFF").FindControl("ctl" + (i - 1).ToString("00")); if (((RadioButton)radio).Checked) { if (((System.Web.UI.WebControls.CheckBox)(((RadioButton)radio))).Text == "Aprobar") { if (profile == 2) // Si firma el concurrente... { SqlDataReader ReaderDR = SQLHelper.ExecuteReader(Cache["ApplicationDatabase"].ToString( ), "EvaluatedHasDoubleReport", new object[] { Convert.ToInt32(((TextBox)answer).SkinID.Split('_')[0].ToString( )) }); ReaderDR.Read( ); if (ReaderDR.HasRows) // si tiene doble reporte va al Doble Reporte y el envia un email... { SQLHelper.ExecuteNonQuery(Cache["ApplicationDatabase"].ToString( ), "[SetAssessmentsSatus]", new object[] { ((TextBox)answer).SkinID.Split('_')[0], Convert.ToInt16(_params[0]), _params[2], 6 }); } else // si no tiene doble reporte va a RRHH y le envia un email... { SQLHelper.ExecuteNonQuery(Cache["ApplicationDatabase"].ToString( ), "[SetAssessmentsSatus]", new object[] { ((TextBox)answer).SkinID.Split('_')[0], Convert.ToInt16(_params[0]), _params[2], 9 }); } } if (profile == 3) // Si firma el Doble Reporte va a RRHH y le envia un email... { SQLHelper.ExecuteNonQuery(Cache["ApplicationDatabase"].ToString( ), "[SetAssessmentsSatus]", new object[] { ((TextBox)answer).SkinID.Split('_')[0], Convert.ToInt16(_params[0]), _params[2], 9 }); } if (profile == 5) // Si firma RRHH termina la evaluación y le envía un email al evaluador.... { SQLHelper.ExecuteNonQuery(Cache["ApplicationDatabase"].ToString( ), "[SetAssessmentsSatus]", new object[] { ((TextBox)answer).SkinID.Split('_')[0], Convert.ToInt16(_params[0]), _params[2], 10 }); } } else // si se rechaza una evaluacion hay que ver quien la rechaza................. { switch (profile) { case 2: SQLHelper.ExecuteNonQuery(Cache["ApplicationDatabase"].ToString( ), "[SetAssessmentsSatus]", new object[] { ((TextBox)answer).SkinID.Split('_')[0], Convert.ToInt16(_params[0]), _params[2], 5 }); break; case 3: SQLHelper.ExecuteNonQuery(Cache["ApplicationDatabase"].ToString( ), "[SetAssessmentsSatus]", new object[] { ((TextBox)answer).SkinID.Split('_')[0], Convert.ToInt16(_params[0]), _params[2], 8 }); break; case 5: SQLHelper.ExecuteNonQuery(Cache["ApplicationDatabase"].ToString( ), "[SetAssessmentsSatus]", new object[] { ((TextBox)answer).SkinID.Split('_')[0], Convert.ToInt16(_params[0]), _params[2], 11 }); break; } } } } myControl.Dispose( ); } } } } }
private void processFilterValues(Control panel, bool isSave) { if (panel.GetType() == typeof(SplitContainer)) { processFilterValues(((SplitContainer)panel).Panel1, isSave); processFilterValues(((SplitContainer)panel).Panel2, isSave); } else if (panel.GetType() == typeof(Panel)) { processFilterValues(panel, isSave); } else { foreach (Control control in panel.Controls) { if (control.GetType() == typeof(SplitContainer)) { processFilterValues(((SplitContainer)control).Panel1, isSave); processFilterValues(((SplitContainer)control).Panel2, isSave); } else if (control.GetType() == typeof(Panel)) { processFilterValues(control, isSave); } else if (!isSave && !filterValues.ContainsKey(control)) { continue; //do nothing and iterate to the next control } else if (control.GetType() == typeof(InputControl_Textbox)) { if (isSave && !filterValues.ContainsKey(control)) { filterValues.Add(control, ((InputControl_Textbox)control).FilterValues); } else { if (isSave) { filterValues[control] = ((InputControl_Textbox)control).FilterValues; } else { ((InputControl_Textbox)control).FilterValues = (FilterValues_InputControl_Textbox)filterValues[control]; } } } else if (control.GetType() == typeof(InputControl_Numeric)) { if (isSave && !filterValues.ContainsKey(control)) { filterValues.Add(control, ((InputControl_Numeric)control).FilterValues); } else { if (isSave) { filterValues[control] = ((InputControl_Numeric)control).FilterValues; } else { ((InputControl_Numeric)control).FilterValues = (FilterValues_InputControl_Numeric)filterValues[control]; } } } else if (control.GetType() == typeof(InputControl_DateTimePicker)) { if (isSave && !filterValues.ContainsKey(control)) { filterValues.Add(control, ((InputControl_DateTimePicker)control).FilterValues); } else { if (isSave) { filterValues[control] = ((InputControl_DateTimePicker)control).FilterValues; } else { ((InputControl_DateTimePicker)control).FilterValues = (FilterValues_InputControl_DateTimePicker)filterValues[control]; } } } else if (control.GetType() == typeof(InputControl_Dropdownlist)) { if (isSave && !filterValues.ContainsKey(control)) { filterValues.Add(control, ((InputControl_Dropdownlist)control).SelectedItem); } else { if (isSave) { filterValues[control] = ((InputControl_Dropdownlist)control).SelectedItem; } else { ((InputControl_Dropdownlist)control).SelectedItem = filterValues[control]; } } } } } }
private void ContainerGoster(Control c) { if (c.GetType().Name == "HtmlForm") return; if (c.GetType().Name == "HtmlGenericControl") { c.Visible = true; ContainerGoster(c.Parent); } }
internal static string Debug_GetLayoutInfo(Control control, int indents) { string lineBreak = "\r\n" + Debug_GetIndents(indents + 1); string layoutInfo = string.Format(System.Globalization.CultureInfo.CurrentCulture, "Handle {9} Name {1} Type {2} {0} Bounds {3} {0} AutoSize {4} {0} Dock [{5}] Anchor [{6}] {0} Padding [{7}] Margin [{8}]", lineBreak, control.Name, control.GetType().Name, control.Bounds, control.AutoSize, control.Dock, control.Anchor, control.Padding, control.Margin, !control.IsHandleCreated ? "[not created]" : "0x" + ((int)(control.Handle)).ToString("x")); if (control is TableLayoutPanel) { TypeConverter converter = TypeDescriptor.GetConverter(typeof(TableLayoutSettings)); layoutInfo += lineBreak + converter.ConvertTo(control as TableLayoutPanel, typeof(string)); } return layoutInfo; }
/// <summary> /// Returns the HTML markup for a control, invoking any properties on the control. /// </summary> public static string RenderControl(this HtmlHelper helper, Control control, IEnumerable<KeyValuePair<string, object>> properties) { try { if (string.IsNullOrWhiteSpace(control.ID)) { control.ID = string.Format("control_{0}", Guid.NewGuid()); } if (properties != null && properties.Count() > 0) { var type = control.GetType(); foreach (KeyValuePair<string, object> prop in properties) { var property = type.GetProperty(prop.Key); property.SetValue( control, Convert.ChangeType(prop.Value, property.PropertyType, CultureInfo.InvariantCulture), null); } } // To ensure all the events in the lifecycle fire (Init, Load, etc), put // this control into a page and run that page to get the final control markup. System.Web.UI.Page page = new System.Web.UI.Page(); page.EnableViewState = false; HtmlForm form = new HtmlForm(); PlaceHolder ph = new PlaceHolder(); const string delimiterStart = "-|-|-|-|-|-|-|-|- control start -|-|-|-|-|-|-|-|-"; const string delimiterEnd = "-|-|-|-|-|-|-|-|- control start -|-|-|-|-|-|-|-|-"; ph.Controls.Add(new LiteralControl(delimiterStart)); ph.Controls.Add(control); ph.Controls.Add(new LiteralControl(delimiterEnd)); form.Controls.Add(ph); page.Controls.Add(form); StringWriter output = new StringWriter(); HttpContext.Current.Server.Execute(page, output, false); string markup = output.ToString(); Match m = new Regex(string.Format("{0}(.*?){1}", Regex.Escape(delimiterStart), Regex.Escape(delimiterEnd)), RegexOptions.IgnoreCase | RegexOptions.Singleline).Match(markup); if (m.Success) { return m.Groups[1].Value; } return string.Empty; } catch (Exception ex) { Utils.Log(string.Format("Unable to load control: {0}", control.GetType().ToString()), ex); } return HttpUtility.HtmlEncode(string.Format("ERROR - UNABLE TO LOAD CONTROL : {0}", control.GetType().ToString())); }
private string GenerateInitializer( Control control, bool isThis ) { string output = ""; string id = isThis ? "this" : control.Id; string type = control.GetType().ToString(); if ( !isThis ) { output = string.Format( "\n\t\t{0} = new {1}();\n", id, type ); } output = string.Format( "{0}{1}", output, GenerateFieldInitializers( control, id ) ); Control c = (Control)Activator.CreateInstance( control.GetType() ); int decoratorIndex = 0; int count = 0; int builtinDecoratos = c.Decorators.Count; foreach( Decorator decorator in control.Decorators ) { count++; if ( count <= builtinDecoratos ) { continue; } string decoratorId = string.Format( "{0}_d{1}", id, decoratorIndex ); output = string.Format( "{0}\n\n\t\t{1} {2} = new {1}();", output, decorator.GetType(), decoratorId ); output = string.Format( "{0}{1}", output, GenerateFieldInitializers( decorator, decoratorId ) ); output = string.Format( "{0}\n\t\t{1}.AddDecorator({2});", output, id, decoratorId ); decoratorIndex++; } if ( !isThis ) { output = string.Format( "{0}\n\n\t\tAddChild({1});", output, id ); } return output; }
public static void LogError(this Control ctl, object ex) { ILog log = LogManager.GetLogger(ctl.GetType()); log.Error(ex); }
private void ApplyWriteRules( Control ctl, Binding binding, bool canWrite) { if (ctl is Label) return; // enable/disable writing of the value PropertyInfo propertyInfo = ctl.GetType().GetProperty("ReadOnly", BindingFlags.FlattenHierarchy | BindingFlags.Instance | BindingFlags.Public); if (propertyInfo != null) { bool couldWrite = (!(bool)propertyInfo.GetValue( ctl, new object[] { })); propertyInfo.SetValue( ctl, !canWrite, new object[] { }); if ((!couldWrite) && (canWrite)) binding.ReadValue(); } else { bool couldWrite = ctl.Enabled; ctl.Enabled = canWrite; if ((!couldWrite) && (canWrite)) binding.ReadValue(); } }
/// <summary> /// 根据对象填充属性字段 /// </summary> /// <param name="groupItem">组项目</param> /// <param name="objType">对象类型</param> private void RetrieveFields(LayoutControlGroup groupItem, Type objType) { UIPublic.ShowWaitingForm(); this.DataLayoutControl.CloseControl(); EditControls.Clear(); this.DataLayoutControl.Clear(true, true); var controller = Controller as ObjectLayoutEditController; if (objType == null) { return; } this.DataLayoutControl.SuspendLayout(); TabbedControlGroup tabbledGroup = null; foreach (PropertyDescriptor propDesc in TypeDescriptor.GetProperties(objType)) { if (!propDesc.IsBrowsable) { continue; } BaseEditController editController = null; Control editControl = null; if (controller != null) { editController = controller.GetPredefinedEditController(propDesc.PropertyType, propDesc.Name); } if (editController == null) { if (propDesc.PropertyType.IsAddon()) { var commonEditController = new CommonObjectEditController(); commonEditController.StartEditProperty(EditValue, propDesc.Name); editController = commonEditController; } else { editController = EditorPublic.GetEditController(propDesc); } } editControl = editController.CreateEditControl(propDesc.PropertyType); if (editControl.GetType().GetProperty("EditValue") == null) { throw new Exception("编辑控件必须实现EditValue属性"); } LayoutControlItem layoutControlItem = null; if (editControl is BaseObjectEditControl) { if (tabbledGroup == null) { tabbledGroup = groupItem.AddTabbedGroup(); } var layoutGroupItem = tabbledGroup.AddTabPage(); layoutGroupItem.Name = "Group_" + propDesc.Name; layoutGroupItem.Text = propDesc.DisplayName; layoutGroupItem.CustomizationFormText = "组_" + propDesc.DisplayName; layoutGroupItem.Padding = new DevExpress.XtraLayout.Utils.Padding(0); layoutControlItem = layoutGroupItem.AddItem(); layoutControlItem.TextLocation = DevExpress.Utils.Locations.Top; } else { layoutControlItem = groupItem.AddItem(); layoutControlItem.TextLocation = DevExpress.Utils.Locations.Left; } EditControls.Add(propDesc, editControl); editControl.Tag = propDesc; editControl.Name = propDesc.Name; layoutControlItem.Control = editControl; layoutControlItem.Name = propDesc.Name; layoutControlItem.Text = propDesc.DisplayName; layoutControlItem.CustomizationFormText = propDesc.DisplayName; if (editControl is BaseObjectEditControl) { layoutControlItem.TextVisible = false; } else { layoutControlItem.TextVisible = true; } } this.DataLayoutControl.ResumeLayout(); this.DataLayoutControl.SetDefaultLayout(); // 读取布局数据 if (controller != null && controller.LayoutData.IsNotNullOrEmpty()) { this.DataLayoutControl.SetLayoutData(controller.LayoutData); } UIPublic.CloseWaitingForm(); }
private void WLPaintControl(Control ctl, Graphics graphics) { // draw the control and any child controls if (ctl is Container) { foreach (Control ctl1 in (ctl as Container).Controls) { WLPaintControl(ctl1, graphics); } } else { Guid id = ThemeComponentGuid.FromControlType(ctl.GetType()); Guid stateId = ThemeComponentStateGuids.Normal; if (ctl == mvarFocusedControl) { if (ctl == mvarPressedControl) { stateId = ThemeComponentStateGuids.PressedFocused; } else if (ctl == mvarHoverControl) { stateId = ThemeComponentStateGuids.HoverFocused; } else { stateId = ThemeComponentStateGuids.NormalFocused; } } else if (ctl == mvarPressedControl) { stateId = ThemeComponentStateGuids.Pressed; } else if (ctl == mvarHoverControl) { stateId = ThemeComponentStateGuids.Hover; } Dictionary<string, object> dict = new Dictionary<string, object>(); dict.Add("Component.Text", ctl.Text); graphics.DrawThemeComponent(new ThemeComponentReference(id, stateId), ctl, dict); ctl.OnPaint(new PaintEventArgs(graphics)); } }
protected override void OnInit(EventArgs e) { try { base.OnInit(e); JavaScript.RequestRegistration(CommonJs.DnnPlugins); var folderId = Convert.ToInt32(Request.Params["FolderId"]); Folder = FolderManager.Instance.GetFolder(folderId); HasFullControl = UserInfo.IsSuperUser || FolderPermissionController.HasFolderPermission(Folder.FolderPermissions, "FULLCONTROL"); FolderViewModel rootFolder; switch (SettingsRepository.GetMode(ModuleId)) { case DigitalAssestsMode.Group: var groupId = Convert.ToInt32(Request.Params["GroupId"]); rootFolder = controller.GetGroupFolder(groupId, PortalSettings); if (rootFolder == null) { throw new Exception("Invalid group folder"); } break; case DigitalAssestsMode.User: rootFolder = controller.GetUserFolder(PortalSettings.UserInfo); break; default: rootFolder = controller.GetRootFolder(ModuleId); break; } isRootFolder = rootFolder.FolderID == folderId; folderViewModel = isRootFolder ? rootFolder : controller.GetFolder(folderId); // Setup controls CancelButton.Click += OnCancelClick; SaveButton.Click += OnSaveClick; PrepareFolderPreviewInfo(); cmdCopyPerm.Click += cmdCopyPerm_Click; var mef = new ExtensionPointManager(); var folderFieldsExtension = mef.GetUserControlExtensionPointFirstByPriority("DigitalAssets", "FolderFieldsControlExtensionPoint"); if (folderFieldsExtension != null) { folderFieldsControl = Page.LoadControl(folderFieldsExtension.UserControlSrc); folderFieldsControl.ID = folderFieldsControl.GetType().BaseType.Name; FolderDynamicFieldsContainer.Controls.Add(folderFieldsControl); var fieldsControl = folderFieldsControl as IFieldsControl; if (fieldsControl != null) { fieldsControl.SetController(controller); fieldsControl.SetItemViewModel(new ItemViewModel { ItemID = folderViewModel.FolderID, IsFolder = true, PortalID = folderViewModel.PortalID, ItemName = folderViewModel.FolderName }); } } } catch (Exception exc) { Exceptions.ProcessModuleLoadException(this, exc); } }
/// <devdoc> /// </devdoc> internal static IDictionary GetPersonalizablePropertyValues(Control control, PersonalizationScope scope, bool excludeSensitive) { IDictionary propertyBag = null; IDictionary propertyEntries = GetPersonalizablePropertyEntries(control.GetType()); if (propertyEntries.Count != 0) { foreach (DictionaryEntry entry in propertyEntries) { string name = (string)entry.Key; PersonalizablePropertyEntry propEntry = (PersonalizablePropertyEntry)entry.Value; if (excludeSensitive && propEntry.IsSensitive) { continue; } if ((scope == PersonalizationScope.User) && (propEntry.Scope == PersonalizationScope.Shared)) { continue; } if (propertyBag == null) { propertyBag = new HybridDictionary(propertyEntries.Count, /* caseInsensitive */ false); } object value = FastPropertyAccessor.GetProperty(control, name, control.DesignMode); propertyBag[name] = new Pair(propEntry.PropertyInfo, value); } } if (propertyBag == null) { propertyBag = new HybridDictionary(/* caseInsensitive */ false); } return propertyBag; }
public void AddPanels_OnGivenControl(Form parent, Control input, object sender, EventArgs e, bool checkOn, List <Song> alreadyUsed, bool justSongs, List <Song> sourceList) //parent = form that contains the control { //x = control we want to add panels in checkON = if checkOn true then multiple panels can be selected try //alreadyUsed = if not null then the items in the list will be highlighted justSongs = displaying songs (true) or playlists (false) sourceList = source list for songs to be displayed { parentForm = parent; if (input.GetType() == typeof(FlowLayoutPanel)) //If type of input is FormLayoutPanel { FlowLayoutPanel x = (FlowLayoutPanel)input; //Changing type of input to FormLayoutPanel //Clear the controls from the form List <Control> tmp = new List <Control>(); foreach (Control s in x.Controls) { tmp.Add(s); } foreach (Control s in tmp) //Clear FLowLayoutPanel { x.Controls.Remove(s); s.Dispose(); } try //Clear the songPanels list { songPanels.Clear(); } catch { } foreach (Control s in parent.Controls) //Remove button { if (s.GetType() == typeof(Button)) { parent.Controls.Remove(s); s.Dispose(); } } x.AutoScroll = true; if (parent.GetType() == typeof(Allsongs) || parent.GetType() == typeof(RemoveSongs) || parent.GetType() == typeof(PlayList) || parent.GetType() == typeof(Playlists_List)) { x.Location = new Point(1, 1); x.Size = new Size(new Point(parent.Width - 1, parent.Height - 61)); } parent.BackColor = Color.LightBlue; x.BackColor = Color.White; songList = sourceList; songPanels = new List <Panel>(); int num = 0; foreach (Song s in songList) { //Adding tooltips ToolTip tool1 = new ToolTip(); tool1.InitialDelay = 700; tool1.ReshowDelay = 400; ToolTip tool2 = new ToolTip(); tool2.InitialDelay = 700; tool2.ReshowDelay = 400; ToolTip tool3 = new ToolTip(); tool3.InitialDelay = 700; tool3.ReshowDelay = 400; ToolTip tool4 = new ToolTip(); tool4.InitialDelay = 700; tool4.ReshowDelay = 400; ToolTip tool5 = new ToolTip(); tool5.InitialDelay = 700; tool5.ReshowDelay = 400; //Creating main panel for each song Panel p = new Panel(); p.Location = new Point(10, 10 + num * 60); p.Size = new Size(x.Width - 25, (int)(x.Width * 0.15)); p.BackColor = Color.LightBlue; //Creating picture for each one PictureBox pic = new PictureBox(); pic.Image = songList[num].Image; pic.SizeMode = PictureBoxSizeMode.Zoom; pic.Location = new Point(2, 2); pic.Size = new Size(p.Size.Height - 5, p.Size.Height - 5); //Creating labels for each one //Song Name Label lab1 = new Label(); lab1.Font = new Font("Microsoft Sans Serif", 18, FontStyle.Regular); lab1.ForeColor = Color.Red; lab1.Text = "Name : " + songList[num].SongName; lab1.Location = new Point(pic.Size.Width + 7, (int)(p.Size.Height * 0.05)); lab1.Size = new Size(new Point((int)(p.Size.Width * 9 / 20), (int)(p.Size.Height * 2 / 5))); lab1.BorderStyle = BorderStyle.FixedSingle; //Length Label lab3 = new Label(); lab3.Font = new Font("Microsoft Sans Serif", 12, FontStyle.Regular); lab3.ForeColor = Color.Black; string songL; if (justSongs) { songL = (songList[num].SongLength / 60).ToString() + ":" + (songList[num].SongLength % 60).ToString(); } else { BinaryFormatter bf = new BinaryFormatter(); FileStream f = new FileStream(s.Path, FileMode.OpenOrCreate); try { List <Song> tempList = (List <Song>)bf.Deserialize(f); songL = tempList.Count().ToString(); } catch { songL = "0"; } f.Close(); } lab3.Text = "Length : " + songL; lab3.Location = new Point(pic.Size.Width + 7, lab1.Location.Y * 12); lab3.Size = new Size(new Point((int)(p.Size.Width * 2 / 9), (int)(p.Size.Height / 4))); lab3.BorderStyle = BorderStyle.FixedSingle; //Artist Name Label lab2 = new Label(); lab2.Font = new Font("Microsoft Sans Serif", 12, FontStyle.Regular); lab2.ForeColor = Color.Black; lab2.Text = "Artist : " + songList[num].ArtistName; lab2.Location = new Point((int)(p.Size.Width * 62 / 100), lab1.Location.Y * 5 / 2); lab2.Size = new Size(new Point((int)(p.Size.Width * 7 / 20), (int)(p.Size.Height / 4))); lab2.BorderStyle = BorderStyle.FixedSingle; //Music type Label lab4 = new Label(); lab4.Font = new Font("Microsoft Sans Serif", 12, FontStyle.Regular); lab4.ForeColor = Color.Black; lab4.Text = "Type : " + songList[num].MusicType; lab4.Location = new Point(lab3.Location.X + lab3.Size.Width + 7, lab1.Location.Y * 12); lab4.Size = new Size(new Point((int)(p.Size.Width * 3 / 11), (int)(p.Size.Height / 4))); lab4.BorderStyle = BorderStyle.FixedSingle; //Language Label lab5 = new Label(); lab5.Font = new Font("Microsoft Sans Serif", 12, FontStyle.Regular); lab5.ForeColor = Color.Black; lab5.Text = "Language : " + songList[num].Language; lab5.Location = new Point(lab4.Location.X + lab4.Size.Width + 7, lab1.Location.Y * 12); lab5.Size = new Size(new Point((int)(p.Size.Width * 3 / 11), (int)(p.Size.Height / 4))); lab5.BorderStyle = BorderStyle.FixedSingle; //Adding the controls to the panel int index = num; //Using different variable for num p.Click += new EventHandler((sender2, e2) => Selected(sender, e, index, checkOn)); //Call function Selected with given arguments p.DoubleClick += new EventHandler(DoubleClick); pic.Click += new EventHandler((sender2, e2) => Selected(sender, e, index, checkOn)); //so we can also send the current index / song pic.DoubleClick += new EventHandler(DoubleClick); p.Controls.Add(pic); //as an argument for the other forms to access //Song name lab1.Click += new EventHandler((sender2, e2) => Selected(sender, e, index, checkOn)); lab1.DoubleClick += new EventHandler(DoubleClick); tool1.SetToolTip(lab1, lab1.Text); p.Controls.Add(lab1); //Length lab3.Click += new EventHandler((sender2, e2) => Selected(sender, e, index, checkOn)); lab3.DoubleClick += new EventHandler(DoubleClick); tool3.SetToolTip(lab3, lab3.Text); p.Controls.Add(lab3); if (justSongs) { //Artist name tool3.SetToolTip(lab3, lab3.Text + " ( hh:mm:ss )"); lab2.Click += new EventHandler((sender2, e2) => Selected(sender, e, index, checkOn)); lab2.DoubleClick += new EventHandler(DoubleClick); tool2.SetToolTip(lab2, lab2.Text); p.Controls.Add(lab2); //Music name lab4.Click += new EventHandler((sender2, e2) => Selected(sender, e, index, checkOn)); lab4.DoubleClick += new EventHandler(DoubleClick); tool4.SetToolTip(lab4, lab4.Text); p.Controls.Add(lab4); //Language lab5.Click += new EventHandler((sender2, e2) => Selected(sender, e, index, checkOn)); lab5.DoubleClick += new EventHandler(DoubleClick); tool5.SetToolTip(lab5, lab5.Text); p.Controls.Add(lab5); } //If the song already in the playlist highlight if (!justSongs && alreadyUsed.Count() != 0) //It works so I no touch { foreach (Song t in alreadyUsed) { if (t == s) { p.BackColor = Color.LightGreen; break; } } } //Adding the panel to the flowPanel and to the songPanels songPanels.Add(p); x.Controls.Add(p); num++; } } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
/// <summary> /// Registers informationa bout a server-side control into the OakTree.Web.UI.WebControls JavaScript namespace /// </summary> /// <param name="ClientScriptManager"></param> /// <param name="Control">The control to register</param> /// <param name="Data">Any additional data you'd like to provide to the client script. This should be in JSON format</param> public static void RegisterControlInClientScript(ClientScriptManager ClientScriptManager, Control Control, string Data) { RegisterControlInClientScript(ClientScriptManager, Control, Control.GetType().Name, Data); }
public static void RegistrarScript(Control componente, string nomeScript, string script) { ScriptManager scriptManager = ScriptManager.GetCurrent(componente.Page); if (scriptManager.IsInAsyncPostBack) { ScriptManager.RegisterStartupScript(componente, componente.GetType(), nomeScript, script, true); } else { componente.Page.ClientScript.RegisterStartupScript(componente.GetType(), nomeScript, script, true); } }
/// <summary> /// This method returns the Parent UserControl that matches the parentType given. /// This method is for Web User Controls only. /// </summary> public static UserControl GetParentUserControl(UserControl sourceControl, Type parentType, int maxAttempts = 0) { // initial value UserControl parentControl = null; // locals int attempts = 0; Control tempParentControl = sourceControl.Parent; try { // if the tempParentControl exists if (tempParentControl != null) { do { // increment attempts attempts++; // if the parentControl exists tempParentControl = (Control)tempParentControl.Parent; // if the tempParentControl exists if (tempParentControl != null) { // if this is the Type being searched for if (tempParentControl.GetType() == parentType) { // set the return value parentControl = tempParentControl as UserControl; // break out of the loop break; } else { // if the max attempt has been reached and maxAttempts is greater than 0 if ((maxAttempts > 0) && (attempts >= maxAttempts)) { // break out of loop break; } } } else { // break out of loop break; } } while (true); } } catch (Exception error) { // for debugging only string err = error.ToString(); } // return value return(parentControl); }
public static void DoubleBuffered(this Control control, bool enable) { var doubleBufferPropertyInfo = control.GetType().GetProperty("DoubleBuffered", BindingFlags.Instance | BindingFlags.NonPublic); doubleBufferPropertyInfo.SetValue(control, enable, null); }
/// <summary> /// Method to find an element by its Key property value. /// </summary> /// <returns>The founded element otherwise, default value of type T, or null if type T is nullable.</returns> public UiElement <object> FindControl(Control ctrl) { if (Count == 0) { return(null); } string key = UiElement <object> .KeyFormat(ctrl); Debug.WriteLine($"{GetType().Name}.{MethodBase.GetCurrentMethod().Name} : {ctrl?.GetType()?.Name} {key}"); return(Find(x => x.HasPropertyEquals("Key", key))); }
public static void LogErrorFormat(this Control ctl, string format, params object[] args) { ILog log = LogManager.GetLogger(ctl.GetType()); log.ErrorFormat(format, args); }