private void LoadStyleItems() { ICollection styles = _styleSheet.Styles; foreach (String key in styles) { Style style = (Style)_styleSheet[key]; Style newStyle = (Style)Activator.CreateInstance(style.GetType()); PropertyDescriptorCollection propDescs = TypeDescriptor.GetProperties(style); for (int i = 0; i < propDescs.Count; i++) { if (propDescs[i].Name.Equals("Font")) { foreach (PropertyDescriptor desc in TypeDescriptor.GetProperties(style.Font)) { desc.SetValue(newStyle.Font, desc.GetValue(style.Font)); } } else if (!propDescs[i].IsReadOnly) { propDescs[i].SetValue(newStyle, propDescs[i].GetValue(style)); } } _tempStyleSheet[newStyle.Name] = newStyle; newStyle.SetControl(_tempStyleSheet); StyleNode newStyleItem = new StyleNode(newStyle); _tvDefinedStyles.Nodes.Add(newStyleItem); } }
protected object ResolveCurrentStyle(SceneElement targetElement, PropertyReference propertyReference, bool allowDefaultStyle) { ReferenceStep referenceStep = propertyReference[0]; object computedValue = targetElement.GetComputedValue(propertyReference); StyleNode styleNode = targetElement.GetLocalOrDefaultValue(propertyReference) as StyleNode; bool flag = computedValue == null || styleNode != null && styleNode.IsDefaultStyle; if (!allowDefaultStyle && flag && referenceStep.Equals((object)BaseFrameworkElement.StyleProperty)) { return((object)null); } if (computedValue != null) { Style style = computedValue as Style; if (style != null) { foreach (SetterBase setterBase in (Collection <SetterBase>)style.Setters) { Setter setter = setterBase as Setter; FrameworkTemplate frameworkTemplate; if (setter != null && (frameworkTemplate = setter.Value as FrameworkTemplate) != null && frameworkTemplate.VisualTree != null) { return((object)null); } } } } return(computedValue); }
protected bool DoesStyleOrTemplateApply(IPropertyId styleOrTemplateProperty, DocumentNode value) { if (PlatformTypes.FrameworkElement.IsAssignableFrom((ITypeId)this.Type)) { IType templateTargetType1 = DocumentNodeUtilities.GetStyleOrTemplateTargetType(value); Type type = templateTargetType1 != null ? templateTargetType1.RuntimeType : (Type)null; Type c = this.TargetElement.ProjectContext.MetadataFactory.GetMetadata(this.Type.RuntimeType).GetStylePropertyTargetType(styleOrTemplateProperty); if (type == (Type)null) { return(true); } if (StyleNode.BasedOnProperty.Equals((object)styleOrTemplateProperty)) { StyleNode styleNode = this.TargetElement as StyleNode; if (styleNode != null) { IType templateTargetType2 = DocumentNodeUtilities.GetStyleOrTemplateTargetType(styleNode.DocumentNode); c = templateTargetType2 != null ? templateTargetType2.RuntimeType : (Type)null; } } if (c == (Type)null && ControlStylingOperations.DoesPropertyAffectRoot((IPropertyId)this.TargetProperty)) { c = this.Type.RuntimeType; } if (c != (Type)null && !type.IsAssignableFrom(c)) { return(false); } } return(true); }
protected void Forward(GameObject obj) { NodePort target = GetOutputPort("target"); int c = target.ConnectionCount; for (int i = 0; i < c; i++) { NodePort port = target.GetConnection(i); if (port == null) { continue; } StyleNode styleNode = port.node as StyleNode; if (styleNode == null) { continue; } styleNode.Apply(obj); } }
public override Node VisitDefault_style([NotNull] Default_styleContext context) { var defaultStyle = new StyleNode(context.Start, context.type().GetText()); defaultStyle.AddChild(Visit(context.style())); return(defaultStyle); }
private void OnKeyDown(Object sender, KeyEventArgs e) { switch (e.KeyData) { case Keys.F2: { if (SelectedStyle != null) { SelectedStyle.BeginEdit(); } break; } case (Keys.Control | Keys.Home): { if (_tvDefinedStyles.Nodes.Count > 0) { SelectedStyle = (StyleNode)_tvDefinedStyles.Nodes[0]; } break; } case (Keys.Control | Keys.End): { int numNodes = _tvDefinedStyles.Nodes.Count; if (numNodes > 0) { SelectedStyle = (StyleNode)_tvDefinedStyles.Nodes[numNodes - 1]; } break; } } }
public StyleTimelineItem(TimelineItemManager timelineItemManager, StyleNode styleNode) : base(timelineItemManager) { this.isShown = true; this.IsExpanded = true; this.styleNode = styleNode; this.TimelineItemManager.RegisterTimelineItem((TimelineItem)this); }
private static void InitStyles(WorkbookNode workbook) { StyleNode styleDateTime = new StyleNode(); styleDateTime.ID = "NormalDateTime"; styleDateTime.NumberFormat.Format = "yyyy-mm-dd hh:mm:ss"; workbook.Styles.Add(styleDateTime); }
public override Node Visit(StyleNode node) { if (_styleNodeExpectations.Count > 0) { _styleNodeExpectations.Dequeue().Invoke(node); } return(VisitChildren(node)); }
private static IType GetStyleTargetTypeId(SceneNode node) { StyleNode styleNode = node as StyleNode; if (styleNode == null) { return(node.Type); } return(styleNode.StyleTargetTypeId); }
private void SetTextPropertiesOnStyle(SceneViewModel viewModel, StyleNode styleElement, TextBlockElement textBlockSceneNode, Dictionary <IPropertyId, IPropertyId> properties) { foreach (KeyValuePair <IPropertyId, IPropertyId> keyValuePair in properties) { IProperty propertyKey = viewModel.ProjectContext.ResolveProperty(keyValuePair.Key); if (((DocumentCompositeNode)textBlockSceneNode.DocumentNode).Properties.Contains(propertyKey)) { styleElement.SetValue(keyValuePair.Value, textBlockSceneNode.GetLocalOrDefaultValue(keyValuePair.Key)); } } }
protected override bool OnClickEnd(Point pointerPosition, int clickCount) { if (clickCount > 1) { this.actionString = StringTable.UndoUnitResetRadialGradient; Point point = new Point(0.5, 0.5); double num1 = 1.0; double num2 = 1.0; if (this.ActiveAdorner.IsStretchedToFitBoundingBox) { point = new Point(0.5, 0.5); num1 = num2 = 0.5; } else { BaseFrameworkElement frameworkElement = this.EditingElement as BaseFrameworkElement; if (frameworkElement == null) { StyleNode styleNode = this.EditingElement as StyleNode; if (styleNode != null) { frameworkElement = styleNode.TargetElement; } } if (frameworkElement != null) { Rect computedTightBounds = frameworkElement.GetComputedTightBounds(); num1 = RoundingHelper.RoundLength(computedTightBounds.Width / 2.0); num2 = RoundingHelper.RoundLength(computedTightBounds.Height / 2.0); point = RoundingHelper.RoundPosition(new Point(computedTightBounds.X + num1, computedTightBounds.Y + num2)); } } this.CopyPrimaryBrushToSelection(); this.ClearBrushTransform(); if ((Point)this.GetBrushValue(RadialGradientBrushNode.GradientOriginProperty) != point) { this.SetBrushValue(RadialGradientBrushNode.GradientOriginProperty, (object)point); } if ((Point)this.GetBrushValue(RadialGradientBrushNode.CenterProperty) != point) { this.SetBrushValue(RadialGradientBrushNode.CenterProperty, (object)point); } if ((double)this.GetBrushValue(RadialGradientBrushNode.RadiusXProperty) != num1) { this.SetBrushValue(RadialGradientBrushNode.RadiusXProperty, (object)num1); } if ((double)this.GetBrushValue(RadialGradientBrushNode.RadiusYProperty) != num2) { this.SetBrushValue(RadialGradientBrushNode.RadiusYProperty, (object)num2); } } this.CommitEditTransaction(); return(base.OnClickEnd(pointerPosition, clickCount)); }
protected override DocumentNode ProvideValue(out IList <DocumentCompositeNode> auxillaryResources) { auxillaryResources = (IList <DocumentCompositeNode>)null; StyleNode emptyStyle = StyleNode.CreateEmptyStyle(this.SceneViewModel, (IPropertyId)this.TargetProperty, (ITypeId)this.Type); ControlTemplateElement controlTemplateElement = (ControlTemplateElement)this.SceneViewModel.CreateSceneNode(PlatformTypes.ControlTemplate); controlTemplateElement.ControlTemplateTargetTypeId = (ITypeId)emptyStyle.StyleTargetTypeId; BaseFrameworkElement frameworkElement = (BaseFrameworkElement)this.SceneViewModel.CreateSceneNode(PlatformTypes.Grid); controlTemplateElement.DefaultInsertionPoint.Insert((SceneNode)frameworkElement); emptyStyle.SetValue(ControlElement.TemplateProperty, (object)controlTemplateElement.DocumentNode); return(emptyStyle.DocumentNode); }
private void MoveSelectedNode(int direction) { Debug.Assert(direction == 1 || direction == -1); StyleNode node = SelectedStyle; Debug.Assert(node != null); int index = node.Index; _tvDefinedStyles.Nodes.RemoveAt(index); _tvDefinedStyles.Nodes.Insert(index + direction, node); SelectedStyle = node; }
internal static IType GetTypeOfElement(SceneElement element) { IType type = (IType)null; StyleNode styleNode = element as StyleNode; if (styleNode != null) { type = styleNode.StyleTargetTypeId; } else if (element != null) { type = element.Type; } return(type); }
public static DocumentNodePath ProvideStyleOrTemplateNodePath(SceneElement targetElement, PropertyReference targetPropertyReference) { DocumentNodePath documentNodePath = (DocumentNodePath)null; ReferenceStep targetProperty = targetPropertyReference[0]; StyleNode styleNode = targetElement as StyleNode; if (targetPropertyReference.TargetType.IsAssignableFrom(targetElement.TargetType) || styleNode != null && targetPropertyReference.TargetType.IsAssignableFrom(styleNode.StyleTargetType)) { IViewObjectFactory viewObjectFactory = targetElement.Platform.ViewObjectFactory; object computedValue = targetElement.GetComputedValue(targetPropertyReference); DocumentNodePath valuePath = (DocumentNodePath)null; if (computedValue != null) { IViewObject instance = viewObjectFactory.Instantiate(computedValue); valuePath = targetElement.ViewModel.DefaultView.GetCorrespondingNodePath(instance, true); } if (valuePath == null && !BaseFrameworkElement.StyleProperty.Equals((object)targetProperty)) { BaseFrameworkElement frameworkElement = targetElement as BaseFrameworkElement; if (frameworkElement != null) { frameworkElement.FindMissingImplicitStyle(); } if (computedValue != null) { IViewObject instance = viewObjectFactory.Instantiate(computedValue); DocumentNodePath correspondingNodePath = targetElement.ViewModel.DefaultView.GetCorrespondingNodePath(instance, true); if (correspondingNodePath != null) { valuePath = ControlStylingOperations.FindTemplateWithinStyle(correspondingNodePath, targetElement, (IPropertyId)targetProperty, (IPropertyId)targetProperty); } } } if (ControlStylingOperations.ShouldSetEditingContextToNodePath(valuePath, targetElement, targetProperty)) { documentNodePath = valuePath; } } if (documentNodePath == null && styleNode != null && targetElement.IsSet(targetPropertyReference) == PropertyState.Set) { DocumentNodePath valueAsDocumentNode = targetElement.GetLocalValueAsDocumentNode(targetPropertyReference); if (ControlStylingOperations.ShouldSetEditingContextToNodePath(valueAsDocumentNode, targetElement, targetProperty)) { documentNodePath = valueAsDocumentNode; } } return(documentNodePath); }
public override Node VisitStyle([NotNull] StyleContext context) { var styleNode = new StyleNode(context.Start, string.Empty); foreach (PropertyContext property in context.property()) { styleNode.AddChild(Visit(property)); } if (context.widget() != null) { styleNode.AddChild(Visit(context.widget())); } return(styleNode); }
public override Node VisitStyle(StyleNode style) { return(style.Style switch { Style.Bold => VisitTag("strong"), Style.Italic => VisitTag("em"), Style.Mono => VisitTag("code"), Style.MultiMono => VisitTag("pre"), Style.Strikethru => VisitTag("del"), Style.Underline => VisitTag("u"), Style.BlockQuote => VisitTag("pre"), Style.InlineCode => VisitTag("code"), Style.Spoiler => VisitSpoiler(style), _ => throw new ArgumentException($"Unknown style: {style}"), });
protected override bool OnClickEnd(Point pointerPosition, int clickCount) { if (clickCount > 1) { this.CancelEditTransaction(); this.actionString = StringTable.UndoUnitResetLinearGradient; Point point1 = new Point(); Point point2 = new Point(); if (this.ActiveAdorner.IsStretchedToFitBoundingBox) { point1 = new Point(0.5, 0.0); point2 = new Point(0.5, 1.0); } else { BaseFrameworkElement frameworkElement = this.EditingElement as BaseFrameworkElement; if (frameworkElement == null) { StyleNode styleNode = this.EditingElement as StyleNode; if (styleNode != null) { frameworkElement = styleNode.TargetElement; } } if (frameworkElement != null) { Rect computedTightBounds = frameworkElement.GetComputedTightBounds(); point1 = RoundingHelper.RoundPosition(new Point((computedTightBounds.Left + computedTightBounds.Right) / 2.0, computedTightBounds.Top)); point2 = RoundingHelper.RoundPosition(new Point((computedTightBounds.Left + computedTightBounds.Right) / 2.0, computedTightBounds.Bottom)); } } this.CopyPrimaryBrushToSelection(); this.ClearBrushTransform(); if ((Point)this.GetBrushValue(LinearGradientBrushNode.StartPointProperty) != point1) { this.SetBrushValue(LinearGradientBrushNode.StartPointProperty, (object)point1); } if ((Point)this.GetBrushValue(LinearGradientBrushNode.EndPointProperty) != point2) { this.SetBrushValue(LinearGradientBrushNode.EndPointProperty, (object)point2); } this.UpdateEditTransaction(); } this.CommitEditTransaction(); return(base.OnClickEnd(pointerPosition, clickCount)); }
public static bool IsInsideDefaultStyleOrTemplate(DocumentNodePath styleOrTemplate) { DocumentNodePath documentNodePath = styleOrTemplate; while (documentNodePath != null) { if (StyleNode.IsDefaultValue(documentNodePath.Node)) { return(true); } documentNodePath = documentNodePath.GetContainerOwnerPath(); if (documentNodePath != null) { documentNodePath = documentNodePath.GetContainerNodePath(); } } return(false); }
internal static ReferenceStep FilterProperty(SceneNode node, ReferenceStep referenceStep) { if (node is RichTextBoxRangeElement) { return(referenceStep); } RichTextBoxElement richTextBoxElement = node as RichTextBoxElement; if (richTextBoxElement != null) { foreach (IPropertyId propertyId in !node.ProjectContext.IsCapabilitySet(PlatformCapability.IsWpf) ? RichTextBoxParagraphsRangeElement.SilverlightTextParagraphProperties : RichTextBoxParagraphsRangeElement.WpfTextParagraphProperties) { if (referenceStep.Equals((object)richTextBoxElement.ProjectContext.ResolveProperty(propertyId))) { return(referenceStep); } } } StyleNode styleNode = node as StyleNode; IType typeId = styleNode == null || styleNode.Platform.Metadata.IsNullType((ITypeId)styleNode.StyleTargetTypeId) ? node.Type : styleNode.StyleTargetTypeId; Type runtimeType = typeId.NearestResolvedType.RuntimeType; if (referenceStep.TargetType.IsAssignableFrom(runtimeType) && (PlatformTypeHelper.GetDeclaringType((IMember)referenceStep) == runtimeType || referenceStep.MemberType == MemberType.DesignTimeProperty)) { return(referenceStep); } ReferenceStep referenceStep1; if (typeId == SceneNodeObjectSet.FilteredPropertiesType) { if (SceneNodeObjectSet.FilteredProperties.TryGetValue(referenceStep, out referenceStep1)) { return(referenceStep1); } } else { SceneNodeObjectSet.FilteredPropertiesType = (ITypeId)typeId; SceneNodeObjectSet.FilteredProperties.Clear(); } referenceStep1 = SceneNodeObjectSet.FilterPropertyInternal((ITypeResolver)node.ProjectContext, typeId, referenceStep); SceneNodeObjectSet.FilteredProperties.Add(referenceStep, referenceStep1); return(referenceStep1); }
/// <summary> /// Create a new StylesEditorDialog instance /// </summary> /// <internalonly/> internal StylesEditorDialog(StyleSheet stylesheet, StyleSheetDesigner styleSheetDesigner, String initialStyleName) { if (stylesheet.DuplicateStyles.Count > 0) { GenericUI.ShowErrorMessage( SR.GetString(SR.StylesEditorDialog_Title), SR.GetString(SR.StylesEditorDialog_DuplicateStyleNames) ); throw new ArgumentException( SR.GetString(SR.StylesEditorDialog_DuplicateStyleException) ); } _tempStyleSheet = new StyleSheet(); _previewStyle = new Style(); _styleSheet = stylesheet; _styleSheetDesigner = styleSheetDesigner; _tempStyleSheet.Site = _styleSheet.Site; InitializeComponent(); InitAvailableStyles(); LoadStyleItems(); if (_tvDefinedStyles.Nodes.Count > 0) { int initialIndex = 0; if (initialStyleName != null) { initialIndex = StyleIndex(initialStyleName); } SelectedStyle = (StyleNode)_tvDefinedStyles.Nodes[initialIndex]; _tvDefinedStyles.Enabled = true; UpdateTypeText(); UpdatePropertyGrid(); } UpdateButtonsEnabling(); UpdateFieldsEnabling(); }
public virtual void OnSelectionChanged(SceneNode[] selectedObjects) { bool flag = true; foreach (SceneNode sceneNode in selectedObjects) { if (!(sceneNode is BaseFrameworkElement)) { StyleNode styleNode = sceneNode as StyleNode; if (styleNode == null || !PlatformTypes.FrameworkElement.IsAssignableFrom((ITypeId)styleNode.StyleTargetTypeId)) { flag = false; break; } } } this.RefreshPropertyCategorization(); this.IsTargetingFrameworkElement = flag; }
public DomainId <IAstNode> CreateStyle( string definition, IWidget widget, int?width, decimal?fontSize, string font, string color) { var styleNode = new StyleNode( m_ids.Next, definition, widget, width, font, fontSize, color); return(DomainItemRegistration <IStyleNode>(styleNode)); }
public override object Visit(StyleNode node) { var properties = new List <PropertyData>(); foreach (var property in node.ChildNodes.OfType <PropertyNode>()) { properties.Add(property.Accept(this) as PropertyData); } var widgetNode = node.ChildNodes.OfType <WidgetNode>().FirstOrDefault(); WidgetData widgetData = new WidgetData(new Undefined(), Resources.Yes, Resources.No); if (widgetNode != null) { widgetData = widgetNode.Accept(this) as WidgetData; } return(new StyleData(properties, widgetData, node.TargetType)); }
public void Apply(GameObject obj) { nodes.ForEach(node => { StyleNode styleNode = node as StyleNode; if (styleNode == null) { return; } if (styleNode.GetPort("origin").ConnectionCount > 0) { return; } styleNode.Apply(obj); }); }
private void OnClickRemoveButton(Object source, EventArgs e) { Debug.Assert(SelectedStyle != null); String message = SR.GetString(SR.StylesEditorDialog_DeleteStyleMessage); String caption = SR.GetString(SR.StylesEditorDialog_DeleteStyleCaption); if (System.Windows.Forms.MessageBox.Show(message, caption, MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.No) { return; } String deletedStyle = ((StyleNode)SelectedStyle).RuntimeStyle.Name; // Remove this style from temporary StyleSheet _tempStyleSheet.Remove(deletedStyle); ((StyleNode)SelectedStyle).Dispose(); int selectedIndex = SelectedStyle.Index; int stylesCount = _tvDefinedStyles.Nodes.Count; _tvDefinedStyles.Nodes.RemoveAt(selectedIndex); OnStyleDeleted(new StyleDeletedEventArgs(deletedStyle)); if (selectedIndex < stylesCount - 1) { SelectedStyle = (StyleNode)_tvDefinedStyles.Nodes[selectedIndex]; } else if (selectedIndex >= 1) { SelectedStyle = (StyleNode)_tvDefinedStyles.Nodes[selectedIndex - 1]; } else if (stylesCount == 1) { SelectedStyle = null; UpdateTypeText(); UpdatePropertyGrid(); UpdateSamplePreview(); UpdateButtonsEnabling(); UpdateFieldsEnabling(); } }
private string ScribeHtml(BaseNode node, string directory) { if (!Directory.Exists(directory)) { Directory.CreateDirectory(directory); } string fileName = node.Key + ".html"; using (StreamWriter sw = new StreamWriter(Path.Combine(directory, fileName), false, Encoding.UTF8)) { sw.WriteLine(@"<html><head><meta http-equiv=""Content-Type"" content=""text/html; charset=""utf-8"" /><title>" + node.Title + "</title>"); sw.WriteLine("<style type='text/css'>"); sw.WriteLine(StyleNode.InnerText()); sw.WriteLine("</style></head><body>"); sw.WriteLine(node.ToHtml()); sw.WriteLine("</body></html>"); } return(fileName); }
private void OnCreateNewStyle() { String newStyleAutoID = AutoIDStyle(); Style newStyle = (Style)Activator.CreateInstance(_currentNewStyleType); Debug.Assert(newStyle != null); newStyle.Name = newStyleAutoID; // Add this style to StyleSheet _tempStyleSheet[newStyle.Name] = newStyle; newStyle.SetControl(_tempStyleSheet); StyleNode newStyleItem = new StyleNode(newStyle); _tvDefinedStyles.Enabled = true; _propertyBrowser.Enabled = true; _tvDefinedStyles.Nodes.Add(newStyleItem); SelectedStyle = newStyleItem; UpdateSamplePreview(); UpdateButtonsEnabling(); }
public void CreateNewPropertyTrigger() { if (this.CurrentContainer == null) { return; } ITriggerContainer currentContainer = this.CurrentContainer; SceneViewModel activeSceneViewModel = this.ActiveSceneViewModel; SceneDocument document = activeSceneViewModel.Document; StyleNode styleNode = currentContainer as StyleNode; FrameworkTemplateElement frameworkTemplateElement = currentContainer as FrameworkTemplateElement; using (SceneEditTransaction editTransaction = document.CreateEditTransaction(StringTable.TriggerChangeUndoUnit)) { TriggerSourceInformation triggerSource = (TriggerSourceInformation)null; if (styleNode != null || frameworkTemplateElement != null) { triggerSource = (TriggerSourceInformation)TriggersHelper.GetDefaultProperty(currentContainer.TargetElementType, document.DocumentContext); } if (triggerSource != (TriggerSourceInformation)null) { TriggerBaseNode trigger = TriggersHelper.CreateTrigger(triggerSource, activeSceneViewModel); if (trigger != null) { int index = currentContainer.VisualTriggers.Count; if (this.selectedItem != null) { index = this.selectedItem != this.noneTrigger ? currentContainer.VisualTriggers.IndexOf(this.selectedItem.SceneNode) + 1 : 0; } currentContainer.VisualTriggers.Insert(index, trigger); activeSceneViewModel.SetActiveTrigger(trigger); } } editTransaction.Commit(); } }
/// <summary> /// This method call will activate resp. create the header or footer /// for a master page. There is no need of call it directly. /// Activation for footer and header will be done through /// the TextMasterPage object. /// </summary> public void Activate() { string typeName = (this is TextPageHeader) ? "header" : "footer"; // only if the content node doesn't exist if (ContentNode == null) { ContentNode = new XElement(Ns.Style + typeName); _textMasterPage.Node.Add(ContentNode); } // only if the property node doesn't exist if (PropertyNode == null) { PropertyNode = new XElement(Ns.Style + "header-footer-properties"); // Set defaults MarginLeft = "0cm"; MarginRight = "0cm"; MinHeight = "0cm"; MarginBottom = (typeName.Equals("header")) ? "0.499cm" : "0cm"; MarginTop = (typeName.Equals("footer")) ? "0.499cm" : "0cm"; StyleNode.Add(PropertyNode); } }
private bool ReferencesContainCycle(StyleNode startingStyleItem) { StyleNode node = startingStyleItem; string strB = node.RuntimeStyle.get_StyleReference(); bool flag = true; bool flag2 = false; foreach (StyleNode node2 in this._tvDefinedStyles.Nodes) { node2.Referenced = false; } node.Referenced = true; Label_00E7: while (((strB != null) && (strB.Length > 0)) && (flag && !flag2)) { flag = false; foreach (StyleNode node3 in this._tvDefinedStyles.Nodes) { Style runtimeStyle = node3.RuntimeStyle; if (string.Compare(runtimeStyle.get_Name(), strB, true) == 0) { strB = runtimeStyle.get_StyleReference(); flag = true; if (node3.Referenced) { flag2 = true; } else { node3.Referenced = true; } goto Label_00E7; } } } return flag2; }
/* * END EVENT HANDLING */ private bool ReferencesContainCycle(StyleNode startingStyleItem) { StyleNode currentStyleItem = startingStyleItem; Style currentStyle = currentStyleItem.RuntimeStyle; String reference = currentStyle.StyleReference; bool found = true; bool cycle = false; // Clear referenced boolean foreach (StyleNode styleNode in _tvDefinedStyles.Nodes) { styleNode.Referenced = false; } // Set current style as referenced. currentStyleItem.Referenced = true; while ((reference != null && reference.Length > 0) && found && !cycle) { found = false; foreach (StyleNode styleNode in _tvDefinedStyles.Nodes) { Style style = styleNode.RuntimeStyle; if (0 == String.Compare(style.Name, reference, StringComparison.OrdinalIgnoreCase)) { reference = style.StyleReference; found = true; if (styleNode.Referenced) { cycle = true; } else { styleNode.Referenced = true; } break; } } // keep on looking. // It depends on whether a style defined in web.config can have a reference or not. /* if we do need to keep on looking we need to store the Referenced flag // for those styles as well. // If not found, check default styles if (!found) { if (null != StyleSheet.Default[reference]) { Style style = StyleSheet.Default[reference]; reference = style.Reference; found = true; // get styleNode from other list if (styleNode.Referenced) { cycle = true; } else { styleNode.Referenced = true; } break; } } */ } return cycle; }
private void LoadStyleItems() { ICollection styles = _styleSheet.Styles; foreach (String key in styles) { Style style = (Style) _styleSheet[key]; Style newStyle = (Style) Activator.CreateInstance(style.GetType()); PropertyDescriptorCollection propDescs = TypeDescriptor.GetProperties(style); for (int i = 0; i < propDescs.Count; i++) { if (propDescs[i].Name.Equals("Font")) { foreach (PropertyDescriptor desc in TypeDescriptor.GetProperties(style.Font)) { desc.SetValue(newStyle.Font, desc.GetValue(style.Font)); } } else if (!propDescs[i].IsReadOnly) { propDescs[i].SetValue(newStyle, propDescs[i].GetValue(style)); } } _tempStyleSheet[newStyle.Name] = newStyle; newStyle.SetControl(_tempStyleSheet); StyleNode newStyleItem = new StyleNode(newStyle); _tvDefinedStyles.Nodes.Add(newStyleItem); } }
private void OnCreateNewStyle() { string str = this.AutoIDStyle(); Style style = (Style) Activator.CreateInstance(this._currentNewStyleType); style.set_Name(str); this._tempStyleSheet.set_Item(style.get_Name(), style); Utils.InvokeSetControl(style, this._tempStyleSheet); StyleNode node = new StyleNode(style); this._tvDefinedStyles.Enabled = true; this._propertyBrowser.Enabled = true; this._tvDefinedStyles.Nodes.Add(node); this.SelectedStyle = node; this.UpdateSamplePreview(); this.UpdateButtonsEnabling(); }
private void OnClickRemoveButton(object source, EventArgs e) { string text = MobileResource.GetString("StylesEditorDialog_DeleteStyleMessage"); string caption = MobileResource.GetString("StylesEditorDialog_DeleteStyleCaption"); if (MessageBox.Show(text, caption, MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) != DialogResult.No) { string name = this.SelectedStyle.RuntimeStyle.get_Name(); this._tempStyleSheet.Remove(name); this.SelectedStyle.Dispose(); int index = this.SelectedStyle.Index; int count = this._tvDefinedStyles.Nodes.Count; this._tvDefinedStyles.Nodes.RemoveAt(index); this.OnStyleDeleted(new StyleDeletedEventArgs(name)); if (index < (count - 1)) { this.SelectedStyle = (StyleNode) this._tvDefinedStyles.Nodes[index]; } else if (index >= 1) { this.SelectedStyle = (StyleNode) this._tvDefinedStyles.Nodes[index - 1]; } else if (count == 1) { this.SelectedStyle = null; this.UpdateTypeText(); this.UpdatePropertyGrid(); this.UpdateSamplePreview(); this.UpdateButtonsEnabling(); this.UpdateFieldsEnabling(); } } }
private void MoveSelectedNode(int direction) { StyleNode selectedStyle = this.SelectedStyle; int index = selectedStyle.Index; this._tvDefinedStyles.Nodes.RemoveAt(index); this._tvDefinedStyles.Nodes.Insert(index + direction, selectedStyle); this.SelectedStyle = selectedStyle; }
private void LoadStyleItems() { foreach (string str in this._styleSheet.get_Styles()) { Style component = this._styleSheet.get_Item(str); Style style2 = (Style) Activator.CreateInstance(component.GetType()); PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(component); for (int i = 0; i < properties.Count; i++) { if (properties[i].Name.Equals("Font")) { foreach (PropertyDescriptor descriptor in TypeDescriptor.GetProperties(component.get_Font())) { descriptor.SetValue(style2.get_Font(), descriptor.GetValue(component.get_Font())); } } else if (!properties[i].IsReadOnly) { properties[i].SetValue(style2, properties[i].GetValue(component)); } } this._tempStyleSheet.set_Item(style2.get_Name(), style2); Utils.InvokeSetControl(style2, this._tempStyleSheet); StyleNode node = new StyleNode(style2); this._tvDefinedStyles.Nodes.Add(node); } }
private void OnKeyDown(object sender, KeyEventArgs e) { switch (e.KeyData) { case (Keys.Control | Keys.End): { int count = this._tvDefinedStyles.Nodes.Count; if (count <= 0) { break; } this.SelectedStyle = (StyleNode) this._tvDefinedStyles.Nodes[count - 1]; return; } case (Keys.Control | Keys.Home): if (this._tvDefinedStyles.Nodes.Count <= 0) { break; } this.SelectedStyle = (StyleNode) this._tvDefinedStyles.Nodes[0]; return; case Keys.F2: if (this.SelectedStyle != null) { this.SelectedStyle.BeginEdit(); return; } break; default: return; } }