internal void UpdateSlots(IEnumerable <Slot> slots) { this.RecycleSlots(slots); foreach (var slot in slots) { if (!this.bufferedViewPortArea.IntersectsWith(slot.layoutSlot)) { continue; } Border slotVisual = this.GetDefaultSlotVisual(slot); if (slotVisual != null) { MultiDayViewSettings settings = this.Owner.MultiDayViewSettings; StyleSelector specialSlotStyleSelector = settings.SpecialSlotStyleSelector ?? settings.defaultSpecialSlotStyleSelector; if (specialSlotStyleSelector != null) { var style = specialSlotStyleSelector.SelectStyle(slot, slotVisual); if (style != null) { slotVisual.Style = style; } } XamlContentLayer.ArrangeUIElement(slotVisual, slot.layoutSlot, true); Canvas.SetZIndex(slotVisual, XamlMultiDayViewLayer.DefaultSlotZIndex); Canvas.SetLeft(slotVisual, slot.layoutSlot.X - this.leftOffset + this.leftHeaderPanel.Width); } } foreach (Border slot in this.recycledSlots) { slot.Visibility = Visibility.Collapsed; } }
private void ApplyVerticalAppointmentStyle() { StyleSelector styleSelector = (StyleSelector)FindResource("VerticalAppointmentStyleSelector"); scheduler.DayView.VerticalAppointmentStyleSelector = styleSelector; scheduler.WorkWeekView.VerticalAppointmentStyleSelector = styleSelector; }
protected virtual bool MatchSelectorPart(VisualElement element, StyleSelector selector, StyleSelectorPart part) { bool match = true; switch (part.type) { case StyleSelectorType.Wildcard: break; case StyleSelectorType.Class: match = element.ClassListContains(part.value); break; case StyleSelectorType.ID: match = (element.name == part.value); break; case StyleSelectorType.Type: //TODO: This tests fails to capture instances of sub-classes match = element.typeName == part.value; break; case StyleSelectorType.PseudoClass: int pseudoStates = (int)element.pseudoStates; match = (selector.pseudoStateMask & pseudoStates) == selector.pseudoStateMask; match &= (selector.negatedPseudoStateMask & ~pseudoStates) == selector.negatedPseudoStateMask; break; default: // ignore, all errors should have been warned before hand match = false; break; } return(match); }
private Placemark WrapPlacemark(Geometry kmlGeometry, StyleSelector style, FeatureDataRow feature) { var placemark = new Placemark(); if (!string.IsNullOrEmpty(NameColumn)) { placemark.Name = Get(feature, NameColumn); } placemark.Description = new Description { Text = CreateDescription(feature) }; placemark.Geometry = kmlGeometry; if (GetFeatureSnippet != null) { placemark.Snippet = new Snippet { Text = GetFeatureSnippet(new ExportContext(this, _additionalFiles, feature)) }; } if (style != null) { placemark.StyleUrl = new Uri("#" + style.Id, UriKind.Relative); } return(placemark); }
/// <summary> /// Updates the inspector. /// </summary> public void UpdateInspector() { // Update fields with the current shape information if (SelectedStyle.StyleType == KimonoStyleType.Custom || SelectedStyle.StyleType == KimonoStyleType.CustomText) { EditButton.Image = NSImage.ImageNamed("IconStyleAdd"); EditButton.ToolTip = "Create new style"; } else { EditButton.Image = NSImage.ImageNamed("IconEdit"); EditButton.ToolTip = "Edit attached style"; } // Populate the list of colors StyleSelector.RemoveAllItems(); StyleSelector.AddItem("Custom"); var n = 0; foreach (KimonoStyle style in Portfolio.Styles) { // Add color StyleSelector.AddItem(style.Name); ++n; // Currently selected color? if (SelectedStyle == style) { // Yes, highlight it StyleSelector.SelectItem(n); } } }
public void LoadStyle(string content) { var matches = SelectorRegex.Matches(content); foreach (Match match in matches) { var selector = new StyleSelector(match.Groups[1].Value); foreach (var rule in match.Groups[2].Value.Replace("\n", "").Split(';')) { if (rule.Length < 1) { continue; } var ruleMatches = RuleRegex.Match(rule); var ruleName = ruleMatches.Groups[1].Value; var ruleValue = ruleMatches.Groups[2].Value; selector.AddRule(new StyleRule(ruleName, ruleValue)); } if (_selectors.ContainsKey(selector.Name)) { _selectors[selector.Name] = selector; } else { _selectors.Add(selector.Name, selector); } } }
private void Restyle(object sender, NotifyCollectionChangedEventArgs args) { StyleSelector selector = lv.ItemContainerStyleSelector; lv.ItemContainerStyleSelector = null; lv.ItemContainerStyleSelector = selector; }
protected override Style SelectStyleCore(object item, DependencyObject container) { if (item is IGroupHeader) { return(_gridView.GroupHeaderContainerStyle); } else if (item is IGroupFooter) { return(_gridView.GroupFooterContainerStyle); } else { StyleSelector itemSelector = _gridView.ItemContainerStyleSelector; if (itemSelector != null) { return(itemSelector.SelectStyle(item, container)); } else if (_gridView.ItemContainerStyle != null) { return(_gridView.ItemContainerStyle); } return(base.SelectStyleCore(item, container)); } }
protected virtual bool MatchSelectorPart(VisualElement element, StyleSelector selector, StyleSelectorPart part) { bool flag = true; switch (part.type) { case StyleSelectorType.Wildcard: return(flag); case StyleSelectorType.Type: flag = (element.typeName == part.value); return(flag); case StyleSelectorType.Class: flag = element.ClassListContains(part.value); return(flag); case StyleSelectorType.PseudoClass: { int pseudoStates = (int)element.pseudoStates; flag = ((selector.pseudoStateMask & pseudoStates) == selector.pseudoStateMask); flag &= ((selector.negatedPseudoStateMask & ~pseudoStates) == selector.negatedPseudoStateMask); return(flag); } case StyleSelectorType.ID: flag = (element.name == part.value); return(flag); } flag = false; return(flag); }
public void TestItemContainerStyleSelector() { var lb = ListBox(); var selector = new StyleSelector(); lb.ItemContainerStyleSelector(selector).ItemContainerStyleSelector.Should().Be(selector); }
public static void Run() { KmlFile file = Program.OpenFile("Enter a file to show the styles of:"); if (file == null) { return; } Console.WriteLine("Style names:"); // We're going to extend the first style later StyleSelector firstStyle = null; foreach (StyleSelector style in file.Styles.OrderBy(s => s.Id)) { if (firstStyle == null) { firstStyle = style; } Console.WriteLine(style.Id); } // If there was a style display it's Xml if (firstStyle != null) { Console.WriteLine("\nExpanding '{0}':", firstStyle.Id); var serializer = new Serializer(); serializer.Serialize(firstStyle); Console.WriteLine(serializer.Xml); } }
private void UpdateAllDayAppointments(List <CalendarAppointmentInfo> allDayAppointmentInfos) { int index = 0; RadCalendar calendar = this.Owner; foreach (var appInfo in allDayAppointmentInfos) { if (!this.allDayClipArea.IntersectsWith(appInfo.layoutSlot)) { continue; } AppointmentControl appointmentControl = this.GetDefaultAllDayAppointmentVisual(index); if (appointmentControl != null) { RadRect layoutSlot = appInfo.layoutSlot; appointmentControl.Header = appInfo.Subject; if (appInfo.Brush != null) { appointmentControl.Background = appInfo.Brush; } appointmentControl.appointmentInfo = appInfo; StyleSelector styleSelector = calendar.AppointmentStyleSelector; if (styleSelector != null) { var style = styleSelector.SelectStyle(appInfo, appointmentControl); if (style != null) { appointmentControl.Style = style; } } else if (appointmentControl.Style != null) { appointmentControl.ClearValue(AppointmentControl.StyleProperty); } AppointmentTemplateSelector headerTemplateSelector = calendar.AppointmentHeaderTemplateSelector; if (headerTemplateSelector != null) { DataTemplate template = headerTemplateSelector.SelectTemplate(appInfo, appInfo.cell); if (template != null) { appointmentControl.HeaderTemplate = template; } } XamlContentLayer.ArrangeUIElement(appointmentControl, layoutSlot, true); index++; } } while (index < this.realizedAllDayAppointmentDefaultPresenters.Count) { this.realizedAllDayAppointmentDefaultPresenters[index].Visibility = Visibility.Collapsed; index++; } }
public virtual MatchResultInfo Match(VisualElement element, ref RuleMatcher matcher, int selectorIndex) { if (element == null) { return(default(MatchResultInfo)); } bool match = true; StyleSelector selector = matcher.complexSelector.selectors[selectorIndex]; int count = selector.parts.Length; int triggerPseudoStateMask = 0; int dependencyPseudoMask = 0; bool failedOnlyOnPseudoStates = true; for (int i = 0; i < count; i++) { bool isPartMatch = MatchSelectorPart(element, selector, selector.parts[i]); if (!isPartMatch) { if (selector.parts[i].type == StyleSelectorType.PseudoClass) { // if the element had those flags defined, it would match this selector triggerPseudoStateMask |= selector.pseudoStateMask; // if the element didnt' have those flags, it would match this selector dependencyPseudoMask |= selector.negatedPseudoStateMask; } else { failedOnlyOnPseudoStates = false; } } else { if (selector.parts[i].type == StyleSelectorType.PseudoClass) { // the element matches this selector because it has those flags dependencyPseudoMask |= selector.pseudoStateMask; // the element matches this selector because it does not have those flags triggerPseudoStateMask |= selector.negatedPseudoStateMask; } } match &= isPartMatch; } var result = new MatchResultInfo() { success = match }; if (match || failedOnlyOnPseudoStates) { result.triggerPseudoMask = (PseudoStates)triggerPseudoStateMask; result.dependencyPseudoMask = (PseudoStates)dependencyPseudoMask; } return(result); }
private void cmdApplyChange_Click(object sender, RoutedEventArgs e) { ((ObservableCollection <Product>)products)[1].CategoryName = "Travel"; StyleSelector selector = lstProducts.ItemContainerStyleSelector; lstProducts.ItemContainerStyleSelector = null; lstProducts.ItemContainerStyleSelector = selector; }
private void Merge(Uri url, StyleSelector selector) { // If there's a url to a shared style merge that in first. this.Merge(url); // If there's an inline style that takes priority so merge that over. this.Merge(selector); }
internal static bool InitializeSelector(StyleComplexSelector complexSelector, string complexSelectorStr) { // Set specificity. int fullSpecificity = CSSSpecCopy.GetSelectorSpecificity(complexSelectorStr); if (fullSpecificity == 0) { Debug.LogError("Failed to calculate selector specificity: " + complexSelectorStr); return(false); } complexSelector.specificity = fullSpecificity; // Remove extra whitespace. var selectorSplit = complexSelectorStr.Split(' '); complexSelectorStr = String.Join(" ", selectorSplit); var simpleSelectors = new List <StyleSelector>(); var previousRelationsip = StyleSelectorRelationship.None; foreach (var simpleSelectorStr in selectorSplit) { if (simpleSelectorStr == s_DecendantSymbol) { previousRelationsip = StyleSelectorRelationship.Child; continue; } StyleSelectorPart[] parts; if (!CSSSpecCopy.ParseSelector(simpleSelectorStr, out parts)) { Debug.LogError(StyleSheetImportErrorCode.UnsupportedSelectorFormat + ": " + complexSelectorStr); return(false); } if (parts.Any(p => p.type == StyleSelectorType.Unknown)) { Debug.LogError(StyleSheetImportErrorCode.UnsupportedSelectorFormat + ": " + complexSelectorStr); return(false); } if (parts.Any(p => p.type == StyleSelectorType.RecursivePseudoClass)) { Debug.LogError(StyleSheetImportErrorCode.RecursiveSelectorDetected + ": " + complexSelectorStr); return(false); } var simpleSelector = new StyleSelector(); simpleSelector.parts = parts; simpleSelector.previousRelationship = previousRelationsip; simpleSelectors.Add(simpleSelector); // This is the default (if no > came before). previousRelationsip = StyleSelectorRelationship.Descendent; } complexSelector.selectors = simpleSelectors.ToArray(); return(true); }
public void AddSimpleSelector(StyleSelectorPart[] parts, StyleSelectorRelationship previousRelationsip) { StyleSelector styleSelector = new StyleSelector(); styleSelector.parts = parts; styleSelector.previousRelationship = previousRelationsip; StyleSheetBuilder.Log("Add simple selector " + styleSelector); this.m_CurrentSelectors.Add(styleSelector); }
private void ApplyHorizontalAppointmentStyle() { StyleSelector styleSelector = (StyleSelector)Resources["HorizontalAppointmentStyleSelector"]; foreach (SchedulerViewBase view in Views) { view.HorizontalAppointmentStyleSelector = styleSelector; } }
public static void CachePseudoStateMasks(this StyleComplexSelector complexSelector) { // If we have already cached data on this selector, skip it if (complexSelector.selectors[0].pseudoStateMask != -1) { return; } // lazily build a cache of pseudo state names if (s_PseudoStates == null) { s_PseudoStates = new Dictionary <string, PseudoStateData>(); s_PseudoStates["active"] = new PseudoStateData(PseudoStates.Active, false); s_PseudoStates["hover"] = new PseudoStateData(PseudoStates.Hover, false); s_PseudoStates["checked"] = new PseudoStateData(PseudoStates.Checked, false); s_PseudoStates["selected"] = new PseudoStateData(PseudoStates.Selected, false); s_PseudoStates["disabled"] = new PseudoStateData(PseudoStates.Disabled, false); s_PseudoStates["focus"] = new PseudoStateData(PseudoStates.Focus, false); // A few substates can be negated, meaning them match if the flag is not set s_PseudoStates["inactive"] = new PseudoStateData(PseudoStates.Active, true); s_PseudoStates["enabled"] = new PseudoStateData(PseudoStates.Disabled, true); } for (int j = 0, subCount = complexSelector.selectors.Length; j < subCount; j++) { StyleSelector selector = complexSelector.selectors[j]; StyleSelectorPart[] parts = selector.parts; PseudoStates pseudoClassMask = 0; PseudoStates negatedPseudoClassMask = 0; for (int i = 0; i < selector.parts.Length; i++) { if (selector.parts[i].type == StyleSelectorType.PseudoClass) { PseudoStateData data; if (s_PseudoStates.TryGetValue(parts[i].value, out data)) { if (!data.negate) { pseudoClassMask |= data.state; } else { negatedPseudoClassMask |= data.state; } } else { Debug.LogWarningFormat("Unknown pseudo class \"{0}\"", parts[i].value); } } } selector.pseudoStateMask = (int)pseudoClassMask; selector.negatedPseudoStateMask = (int)negatedPseudoClassMask; } }
/// <summary> /// Generates an container element for the specified input data object. /// </summary> /// <param name="item">The data object for which to generate container.</param> /// <returns>The container element for the <paramref name="item"/>.</returns> private DependencyObject GetContainer(object item) { DataTemplate template = ItemTemplate; DataTemplateSelector templateSelector = template == null ? ItemTemplateSelector : null; Style style = ItemContainerStyle; StyleSelector styleSelector = style == null ? ItemContainerStyleSelector : null; return(GetContainer(item, template, templateSelector, style, styleSelector)); }
protected override bool MatchSelectorPart(VisualElement element, StyleSelector selector, StyleSelectorPart part) { if (part.type == StyleSelectorType.Predicate) { IVisualPredicateWrapper w = part.tempData as IVisualPredicateWrapper; return(w != null && w.Predicate(element)); } return(base.MatchSelectorPart(element, selector, part)); }
/// <summary> /// Renders the object as KML, and calls upon any children to do the same /// </summary> /// <param name="kml"></param> public override void ToKML(XmlTextWriter kml) { if (Name.Length > 0) { kml.WriteElementString("name", this.Name); } if (!Visibility) { kml.WriteElementString("visibility", Convert.ToInt16(this.Visibility).ToString()); } if (!Open) { kml.WriteElementString("open", Convert.ToInt16(this.Open).ToString()); } if (Address.Length > 0) { kml.WriteElementString("address", this.Address); } if (AddressDetails.Length > 0) { kml.WriteElementString("AddressDetails", this.AddressDetails); } if (PhoneNumber.Length > 0) { kml.WriteElementString("phoneNumber", this.PhoneNumber); } if (Snippet.Length > 0) { kml.WriteElementString("Snippet", this.Snippet); } if (Description.Length > 0) { kml.WriteElementString("description", this.Description); } if (LookAt != null) { LookAt.ToKML(kml); } if (TimePrimitive != null) { TimePrimitive.ToKML(kml); } if (StyleUrl.Length > 0) { kml.WriteElementString("styleUrl", this.StyleUrl); } foreach (geStyleSelector StyleSelector in StyleSelectors) { StyleSelector.ToKML(kml); } if (Region != null) { Region.ToKML(kml); } }
public static void CachePseudoStateMasks(this StyleComplexSelector complexSelector) { if (complexSelector.selectors[0].pseudoStateMask == -1) { if (StyleComplexSelectorExtensions.s_PseudoStates == null) { StyleComplexSelectorExtensions.s_PseudoStates = new Dictionary <string, StyleComplexSelectorExtensions.PseudoStateData>(); StyleComplexSelectorExtensions.s_PseudoStates["active"] = new StyleComplexSelectorExtensions.PseudoStateData(PseudoStates.Active, false); StyleComplexSelectorExtensions.s_PseudoStates["hover"] = new StyleComplexSelectorExtensions.PseudoStateData(PseudoStates.Hover, false); StyleComplexSelectorExtensions.s_PseudoStates["checked"] = new StyleComplexSelectorExtensions.PseudoStateData(PseudoStates.Checked, false); StyleComplexSelectorExtensions.s_PseudoStates["selected"] = new StyleComplexSelectorExtensions.PseudoStateData(PseudoStates.Selected, false); StyleComplexSelectorExtensions.s_PseudoStates["disabled"] = new StyleComplexSelectorExtensions.PseudoStateData(PseudoStates.Disabled, false); StyleComplexSelectorExtensions.s_PseudoStates["focus"] = new StyleComplexSelectorExtensions.PseudoStateData(PseudoStates.Focus, false); StyleComplexSelectorExtensions.s_PseudoStates["inactive"] = new StyleComplexSelectorExtensions.PseudoStateData(PseudoStates.Active, true); StyleComplexSelectorExtensions.s_PseudoStates["enabled"] = new StyleComplexSelectorExtensions.PseudoStateData(PseudoStates.Disabled, true); } int i = 0; int num = complexSelector.selectors.Length; while (i < num) { StyleSelector styleSelector = complexSelector.selectors[i]; StyleSelectorPart[] parts = styleSelector.parts; PseudoStates pseudoStates = (PseudoStates)0; PseudoStates pseudoStates2 = (PseudoStates)0; for (int j = 0; j < styleSelector.parts.Length; j++) { if (styleSelector.parts[j].type == StyleSelectorType.PseudoClass) { StyleComplexSelectorExtensions.PseudoStateData pseudoStateData; if (StyleComplexSelectorExtensions.s_PseudoStates.TryGetValue(parts[j].value, out pseudoStateData)) { if (!pseudoStateData.negate) { pseudoStates |= pseudoStateData.state; } else { pseudoStates2 |= pseudoStateData.state; } } else { Debug.LogWarningFormat("Unknown pseudo class \"{0}\"", new object[] { parts[j].value }); } } } styleSelector.pseudoStateMask = (int)pseudoStates; styleSelector.negatedPseudoStateMask = (int)pseudoStates2; i++; } } }
/// <summary> /// 业务功能:实现更新所选项的CategoryName属性 /// 并通过强制刷新方式来更新ItemContainerStyleSelector /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void cmdApplyChange_Click(object sender, RoutedEventArgs e) { Product product = lstProducts.SelectedItem as Product; product.CategoryName = "Travel"; StyleSelector styleSelector = lstProducts.ItemContainerStyleSelector; lstProducts.ItemContainerStyleSelector = null; lstProducts.ItemContainerStyleSelector = styleSelector; }
public Dictionary <string, string> this[StyleSelector selector, string key] { get { return(base[GetKey(selector, key)]); } set { base[GetKey(selector, key)] = value; } }
internal void SetDefaultStyleValues() { ResourceDictionary dictionary = RadCalendar.MultiDayViewResources; this.defaultTimeRulerItemStyleSelector = this.defaultTimeRulerItemStyleSelector ?? (CalendarTimeRulerItemStyleSelector)dictionary["CalendarTimeRulerItemStyleSelector"]; this.defaultCurrentTimeIndicatorStyle = this.defaultCurrentTimeIndicatorStyle ?? (Style)dictionary["CurrentTimeIndicatorStyle"]; this.defaultAllDayAreaBorderStyle = this.defaultAllDayAreaBorderStyle ?? (Style)dictionary["AllDayAreaBorderStyle"]; this.defaultAllDayAreaTextStyle = this.defaultAllDayAreaTextStyle ?? (Style)dictionary["DefaultAllDayTextBlockStyle"]; this.defaulTodaySlotStyle = this.defaulTodaySlotStyle ?? (Style)dictionary["TodaySlotStyle"]; this.defaultSpecialSlotStyleSelector = this.defaultSpecialSlotStyleSelector ?? (SpecialSlotStyleSelector)dictionary["SpecialSlotStyleSelector"]; MultiDayViewSettings.DefaultBackground = (SolidColorBrush)dictionary["TelerikCalendarBackgroundBrush"]; }
public static StyleComplexSelector CreateSimpleSelector(string styleName) { var cs = new StyleComplexSelector(); StyleSelectorPart[] parts; CSSSpec.ParseSelector(styleName, out parts); var selector = new StyleSelector(); selector.parts = parts; cs.selectors = new[] { selector }; return(cs); }
public void AddSimpleSelector(StyleSelectorPart[] parts, StyleSelectorRelationship previousRelationsip) { Debug.Assert(m_BuilderState == BuilderState.ComplexSelector); var selector = new StyleSelector(); selector.parts = parts; selector.previousRelationship = previousRelationsip; Log("Add simple selector " + selector); m_CurrentSelectors.Add(selector); }
public void Load(Stream stream) { string styleSheet = ReadStream(stream); string[] expressions = styleSheet.Split('}'); foreach (string expD in expressions) { string exp = expD.Trim(); if (!string.IsNullOrEmpty(exp)) { string[] arr = exp.Split('{'); if (arr.Length != 2) { throw new Exception(string.Format("Css error: {0}", exp)); } var selector = new StyleSelector(arr[0].Trim().ToLower()); foreach (string styleD in arr[1].Split(';')) { string style = styleD.Trim(); if (!string.IsNullOrEmpty(style)) { string[] styleSplit = style.Split(':'); if (styleSplit.Length != 2) { throw new Exception(string.Format("Css error: {0}", style)); } string attr = styleSplit[0].Trim(); string value = styleSplit[1].Trim(); if (!StyleSheetCache.StyleNames.ContainsKey(attr)) { throw new Exception(string.Format("Style {0} is not found", attr)); } Type attrType = StyleSheetCache.StyleNames[attr]; // ReSharper disable once PossibleNullReferenceException var s = (IStyle)attrType.GetConstructor(new[] { typeof(long) }) .Invoke(new object[] { _stylesCount++ }); s.FromString(value); if (!_styles.ContainsKey(selector)) { _styles.Add(selector, new List <IStyle>()); } _styles[selector].Add(s); } } } } }
/// <summary> /// Generates a sequence of container elements for the specified <see cref="IList"/> of input data objects. /// </summary> /// <param name="items">The data objects for which to generate containers.</param> /// <returns>The sequence of generated container elements.</returns> private IEnumerable <DependencyObject> GetContainers(IList items) { DataTemplate template = ItemTemplate; DataTemplateSelector templateSelector = template == null ? ItemTemplateSelector : null; Style style = ItemContainerStyle; StyleSelector styleSelector = style == null ? ItemContainerStyleSelector : null; for (int i = 0; i < items.Count; i++) { yield return(GetContainer(items[i], template, templateSelector, style, styleSelector)); } }
protected Style GetDocumentContainerStyle(DependencyObject documentContainer, object view, Style style, StyleSelector styleSelector) { return style ?? styleSelector.With(s => s.SelectStyle(ViewHelper.GetViewModelFromView(view), documentContainer)); }
protected virtual Feature CreateKmlFeature(FeatureDataRow feature, StyleSelector style) { var geometry = feature.Geometry; geometry = ToTarget(geometry); switch (geometry.OgcGeometryType) { case OgcGeometryType.Point: { var location = geometry.Coordinate; var p = new Point { Coordinate = new Vector(location.Y, location.X) }; return WrapPlacemark(p, style, feature); } case OgcGeometryType.MultiPoint: { var multiGeometry = new MultipleGeometry(); foreach (var coordinate in geometry.Coordinates) { var p = new Point { Coordinate = new Vector(coordinate.Y, coordinate.X) }; multiGeometry.AddGeometry(p); } return WrapPlacemark(multiGeometry, style, feature); } case OgcGeometryType.LineString: { var lineString = CreateLineString(geometry); return WrapPlacemark(lineString, style, feature); } case OgcGeometryType.Polygon: { var polygon = (IPolygon)geometry; var kmlPolygon = CreateKmlPolygon(polygon); return WrapPlacemark(kmlPolygon, style, feature); } case OgcGeometryType.MultiLineString: { var multiGeometry = new MultipleGeometry(); var multiLineString = (IMultiLineString)geometry; foreach (var innerGeometry in multiLineString.Geometries) { var lineString = CreateLineString(innerGeometry); multiGeometry.AddGeometry(lineString); } return WrapPlacemark(multiGeometry, style, feature); } case OgcGeometryType.MultiPolygon: { var multiGeometry = new MultipleGeometry(); var multiPoly = (IMultiPolygon)geometry; foreach (var innerGeometry in multiPoly.Geometries.Cast<IPolygon>()) { var polygon = CreateKmlPolygon(innerGeometry); multiGeometry.AddGeometry(polygon); } return WrapPlacemark(multiGeometry, style, feature); } default: throw new InvalidOperationException("Geometry not supported"); } }
private Placemark WrapPlacemark(Geometry kmlGeometry, StyleSelector style, FeatureDataRow feature) { var placemark = new Placemark(); if (!string.IsNullOrEmpty(NameColumn)) placemark.Name = Get(feature, NameColumn); placemark.Description = new Description { Text = CreateDescription(feature) }; placemark.Geometry = kmlGeometry; if (GetFeatureSnippet != null) { placemark.Snippet = new Snippet { Text = GetFeatureSnippet(new ExportContext(this, _additionalFiles, feature)) }; } if (style != null) { placemark.StyleUrl = new Uri("#" + style.Id, UriKind.Relative); } return placemark; }
/// <summary> /// Adds the specified <see cref="StyleSelector"/> to this instance. /// </summary> /// <param name="style">The <c>StyleSelector</c> to add to this instance. /// </param> /// <exception cref="System.ArgumentNullException">style is null.</exception> /// <exception cref="System.InvalidOperationException"> /// style belongs to another <see cref="Element"/>. /// </exception> public void AddStyle(StyleSelector style) { this.AddChild(style); }
/// <summary> /// Adds the specified <see cref="StyleSelector"/> to this instance. /// </summary> /// <param name="selector"> /// The <c>StyleSelector</c> to add to this instance. /// </param> /// <exception cref="ArgumentNullException"> /// <c>selector</c> is null. /// </exception> /// <exception cref="InvalidOperationException"> /// <c>selector></c> belongs to another <see cref="Element"/>. /// </exception> public void AddStyle(StyleSelector selector) { this.AddChild(selector); }
/// <summary> /// Removes the specified <see cref="StyleSelector"/> from this instance. /// </summary> /// <param name="selector"> /// The <c>StyleSelector</c> to add to this instance. /// </param> /// <returns> /// true if <c>selector</c> is successfully removed; otherwise, false. /// </returns> /// <exception cref="ArgumentNullException"> /// <c>selector</c> is null. /// </exception> public bool RemoveStyle(StyleSelector selector) { return this.RemoveChild(selector); }