private void MaskedEnable_FireAction(DynamicFormActionTrigger trigger, DynamicFormAction action, object sender, ModelPropertyChangedEventArgs e) { // find all controls and set enabled / disabled state using proper mask Type enumType = trigger.Param as Type; if (enumType == null) { // wrong settings _logger.Error(string.Format("MaskedEnable_FireAction: Wrong mask enum type!")); return; } int mask = 0; try { mask = ExtendedEnum.ToInt(enumType, e.Value); //e.Value != null && e.Value.ToString() != "" ? (int)System.Enum.Parse(enumType, e.Value.ToString(), true) : 0; } catch (Exception) { //_logger.Error(string.Format("MaskedEnable_FireAction: Wrong mask enum value [{0}]!", e.Value.ToString())); } // get control if (ReferenceEquals(null, action.Control)) { action.Control = FindControlByPropertyName(action.FieldName); } if (!ReferenceEquals(null, action.Control)) { // reset data using binding source of this action FilterObjectbase fo = action.BindingSource?.Current as FilterObjectbase; if (!ReferenceEquals(fo, null)) { action.Control.DataBindings[0].DataSourceUpdateMode = DataSourceUpdateMode.Never; // reset field fo.ResetFieldByName(action.FieldName); // turn back DS update mode action.Control.DataBindings[0].DataSourceUpdateMode = DataSourceUpdateMode.OnPropertyChanged; } // confront field bits with enable mask arrived from trigger // control remain enable only if all mask (trigger) bits are present allow bitset of field (action target) if ((((int)(object)action.Param & (int)(object)mask) > 0)) { action.Control.Enabled = true; } else { action.Control.Enabled = false; } // set back default style if (action.Control is TextEdit) { (action.Control as TextEdit).StyleController = DefaultStyles.ContainsKey((action.Control as TextEdit)) ? DefaultStyles[(action.Control as TextEdit)] : null; } } }
/// <summary> /// Fill a set of default styles into a given stylesheet. /// </summary> /// <param name="sheet">StyleSheet to fill.</param> /// <param name="state">State to fill values for.</param> /// <param name="styles">Default styles, as loaded from xml file.</param> private static void FillDefaultStyles(StyleSheet sheet, EntityState state, DefaultStyles styles) { if (styles.FillColor != null) { sheet[$"{state}.FillColor"] = new StyleProperty((Color)styles.FillColor); } if (styles.FontStyle != null) { sheet[$"{state}.FontStyle"] = new StyleProperty((int)styles.FontStyle); } if (styles.ForceAlignCenter != null) { sheet[$"{state}.ForceAlignCenter"] = new StyleProperty((bool)styles.ForceAlignCenter); } if (styles.OutlineColor != null) { sheet[$"{state}.OutlineColor"] = new StyleProperty((Color)styles.OutlineColor); } if (styles.OutlineWidth != null) { sheet[$"{state}.OutlineWidth"] = new StyleProperty((int)styles.OutlineWidth); } if (styles.Scale != null) { sheet[$"{state}.Scale"] = new StyleProperty((float)styles.Scale); } if (styles.SelectedHighlightColor != null) { sheet[$"{state}.SelectedHighlightColor"] = new StyleProperty((Color)styles.SelectedHighlightColor); } if (styles.ShadowColor != null) { sheet[$"{state}.ShadowColor"] = new StyleProperty((Color)styles.ShadowColor); } if (styles.ShadowOffset != null) { sheet[$"{state}.ShadowOffset"] = new StyleProperty((Vector2)styles.ShadowOffset); } if (styles.Padding != null) { sheet[$"{state}.Padding"] = new StyleProperty((Vector2)styles.Padding); } if (styles.SpaceBefore != null) { sheet[$"{state}.SpaceBefore"] = new StyleProperty((Vector2)styles.SpaceBefore); } if (styles.SpaceAfter != null) { sheet[$"{state}.SpaceAfter"] = new StyleProperty((Vector2)styles.SpaceAfter); } if (styles.ShadowScale != null) { sheet[$"{state}.ShadowScale"] = new StyleProperty((float)styles.ShadowScale); } if (styles.DefaultSize != null) { sheet[$"{state}.DefaultSize"] = new StyleProperty((Vector2)styles.DefaultSize); } }
public override Dictionary <string, string> SaveState() { Dictionary <string, string> resultXml = base.SaveState(); resultXml["UseRandomColors"] = UseRandomColors.ToString(); XElement xElement = new XElement("DefaultStyles", DefaultStyles.Select(d => XElement.Parse(GisEditor.Serializer.Serialize(d)))); resultXml["DefaultStyles"] = xElement.ToString(); return(resultXml); }
/// <summary> /// Initializes the <see cref="Manager"/> class with the given values. /// </summary> /// <param name="device"> /// A <see cref="GraphicsDevice"/> used to create default objects. /// </param> /// <param name="font"> /// A <see cref="SpriteFont"/> used as default <see cref="SpriteFont"/>. /// </param> public static void Initialize(GraphicsDevice device, SpriteFont font) { Manager.graphicsDevice = device; Manager.spriteBatch = new ComponentSpriteBatch(device); Texture2D texture = new Texture2D(device, 1, 1); texture.SetData(new[] { Color.White }); FormsKeyboard.Initialize(); DefaultStyles.Initialize(device, font); Manager.IsInitialized = true; }
void RemoveDefaultStyles(HtmlNode node) { var attrStyle = node.Attributes["style"]; if (null == attrStyle) { return; } var strStyle = attrStyle.Value; if (string.IsNullOrWhiteSpace(strStyle)) { return; } var parts = strStyle.Split(';'); var allowedStyleParts = new List <string>(); var removedStylePartsCounter = 0; foreach (var part in parts) { allowedStyleParts.Add(part); var subParts = part.Split(':'); if (2 != subParts.Length) { continue; } var key = subParts[0]; string defaultValue; if (!DefaultStyles.TryGetValue(key, out defaultValue)) { continue; } var styleValue = subParts[1]; defaultValue = defaultValue.Trim(); if (0 != string.Compare(styleValue, defaultValue, StringComparison.InvariantCultureIgnoreCase)) { continue; } allowedStyleParts.Remove(part); removedStylePartsCounter++; } if (removedStylePartsCounter > 0) { var newStyleValue = string.Join(";", allowedStyleParts); node.SetAttributeValue("style", newStyleValue); } }
/// <summary> /// Initializes the <see cref="Manager"/> class with the given values. /// </summary> /// <param name="device"> /// A <see cref="GraphicsDevice"/> used to create default objects. /// </param> /// <param name="font"> /// A <see cref="SpriteFont"/> used as default <see cref="SpriteFont"/>. /// </param> /// <param name="window"> /// An instance of <see cref="GameWindow"/> used by XnaForms. /// </param> public static void Initialize(GraphicsDevice device, SpriteFont font, GameWindow window) { Manager.graphicsDevice = device; Manager.spriteBatch = new ComponentSpriteBatch(device); Manager.window = window; Manager.keyboardDispatcher = new KeyboardDispatcher(window); Texture2D texture = new Texture2D(device, 1, 1); texture.SetData <Color>(new[] { Color.White }); DefaultStyles.Initialize(device, font); Manager.IsInitialized = true; }
public Workspace GenerateAndSaveWorkspace() { _workspace = _persistenceStrategy.GetWorkspace(); WorkspaceManager.BindWorkspace(_workspace); _workspace.Model.Enterprise = new Enterprise(ContextBoundName); DefaultStyles = WorkspaceManager.CreateDefaultStyles(); WorkspaceManager.CreateModel(); ApplyDefaultStyles(_workspace.Views.Configuration.Styles); _persistenceStrategy.PersistWorkspace(_workspace); return(_workspace); }
/// <summary> /// Adds a cell to the current row in the current worksheet. /// </summary> /// <param name="type">A CellType enumeration. The values can be String and Number.</param> /// <param name="style">A DefaultStyle value that sets the style of the new row.</param> /// <param name="value">A string with the contents for the cell.</param> /// <param name="mergeAcrossCells"></param> public void AddCell(CellType type, DefaultStyles style, string value, int mergeAcrossCells) { AddCell(type, style.ToString(), value, mergeAcrossCells); }
/// <summary> /// Adds a cell to the current row in the current worksheet. /// </summary> /// <param name="type">A CellType enumeration. The values can be String and Number.</param> /// <param name="style">A DefaultStyle value that sets the style of the new row.</param> /// <param name="value">A string with the contents for the cell.</param> public void AddCell(CellType type, DefaultStyles style, string value) { AddCell(type, style.ToString(), value, 0); }
/// <summary> /// Adds a new row to the current worksheet with the Default style. /// </summary> /// <param name="style">A DefaultStyle value that sets the style of the new row.</param> public void AddRow(DefaultStyles style) { AddRow(style.ToString()); }