public void UpdateEffectiveStyle() { nEffectiveStyle = null; NotifyOfPropertyChange(() => NEffectiveStyle); }
public void FromXmlBase(ref XElement res, string directoryName) { //var xmlSerializer = new XmlSerializer(typeof (PoI)); //var p = xmlSerializer.Deserialize(res.CreateReader()); try { Id = res.GetGuid("Id"); if (Id == Guid.Empty) Id = Guid.NewGuid(); var n = res.GetString("Name"); ContentId = res.GetString("PoiId", ""); if (String.IsNullOrEmpty(ContentId)) ContentId = n; Priority = res.GetInt("Priority", 2); UserId = res.GetString("UserId"); DateLong = res.GetLong("Date", DateTime.Now.ToEpoch()); UpdatedLong = res.GetLong("Updated", DateTime.Now.ToEpoch()); Layer = res.GetString("Layer"); MaxItems = res.GetNullInt("MaxItems"); var xMid = res.Element("MetaInfoData"); PoiTypeId = res.GetString("PoiTypeId", ""); IsVisibleInMenu = res.GetBool("IsVisibleInMenu", true); Orientation = res.GetDouble("Orientation", 0.0); //if (!string.IsNullOrEmpty(PoiTypeId)) //{ //} if (xMid != null) { var metaInfo = new MetaInfoCollection(); foreach (var xMi in xMid.Elements()) { var mi = new MetaInfo(); mi.FromXml(xMi); metaInfo.Add(mi); } MetaInfo = metaInfo; } if (res.Element("WKT") != null) { var xElement = res.Element("WKT"); if (xElement != null) WktText = xElement.Value; } var xlabels = res.Element("Labels"); if (xlabels != null) { Labels = new Dictionary<string, string>(); foreach (var xk in xlabels.Elements()) { var k = xk.Name.LocalName; // Restore keys starting with numbers or having % or '. k = k.Replace(LabelPercentSubst, "%"); k = k.Replace(LabelQuoteSubst, "'"); if (k.StartsWith(LabelNumPrefix)) { k = k.Substring(LabelNumPrefix.Length); } var s = xk.InnerXml(); Labels[k] = s.RestoreInvalidCharacters(); Labels[k] = Labels[k].Replace("<", "<").Replace(">", ">"); } } var xkeywords = res.Element("Keywords"); if (xkeywords != null) { Keywords = new WordHistogram(); Keywords.FromXml(xkeywords); } if (res.Element("Style") != null) { try { var newStyle = new PoIStyle(); newStyle.FromXml(res.Element("Style"), directoryName, false); //, Service.Settings); // TODO REVIEW: Settings were ignored. Style = newStyle; } catch (Exception) { // OK, keep the old style. } } var media = res.Element("AllMedia"); if (media != null) { AllMedia = new BindableCollection<Media>(); foreach (var m in media.Elements()) { var me = new Media { Content = this }; me.FromXml(m); AllMedia.Add(me); } } var xpos = res.Element("Position"); if (xpos != null) Position = new Position(xpos.GetDouble(Position.LONG_LABEL), xpos.GetDouble(Position.LAT_LABEL), xpos.GetDouble(Position.ALT_LABEL)); // TODO Remember other Position attributes. var px = res.Element("Points"); var mo = res.Element("Models"); if (mo != null) { Models = new List<Model>(); foreach (var xm in mo.Elements()) { var m = new Model(); m.FromXml(xm); Models.Add(m); } } if (px == null) return; var pp = px.Value; Points = new ObservableCollection<Point>(); var ppo = pp.Split(' '); foreach (var poss in ppo) { var split = poss.Split(','); var pt = new Point( Double.Parse(split[0], CultureInfo.InvariantCulture), Double.Parse(split[1], CultureInfo.InvariantCulture)); Points.Add(pt); } } catch (SystemException e) { Logger.Log("DataServer.BaseContent", "Error reading XML " + res + " from " + directoryName, e.Message, Logger.Level.Error, true); } }
public void TypeFromGeoJson(JProperty json) { MetaInfo = new MetaInfoCollection(); foreach (var childJ in json.Children().OfType<JObject>()) { JToken tokenS; childJ.TryGetValue("style", out tokenS); if (tokenS != null) { // First, convert the JSON to XML. var styleNode = JsonConvert.DeserializeXmlNode("{style:" + tokenS + "}"); var styleDoc = styleNode.ToXDocument(); var xElement = styleDoc.Element(XName.Get("style")); if (xElement != null) { // Convert child nodes to attributes. foreach (var el in xElement.Elements()) { xElement.Add(new XAttribute(UppercaseFirst(el.Name), (string)el)); } xElement.Elements().Remove(); // Parse the style. try { var newStyle = new PoIStyle(); newStyle.FromXml(xElement, ".", false); // Do not catch exception. Style = newStyle; } catch { // Ok, keep old style. } } } JToken tokenM; childJ.TryGetValue("propertyTypeData", out tokenM); if (tokenM != null) { var metaInfos = tokenM.Children(); foreach (var metaInfo in metaInfos) { var newMetaInfo = new MetaInfo(); newMetaInfo.FromGeoJson(metaInfo.ToString(Formatting.None), false); MetaInfo.Add(newMetaInfo); } } } }
/// <summary> /// Recalculate analysis style based on filters. Also resets the effective style. /// </summary> /// <returns></returns> public bool UpdateAnalysisStyle() { // get effective highlights var a = new AnalysisMetaInfo { Highlights = new List<Highlight>() }; GetEffectiveAnalysis(this, ref a); //var a = (PoiType != null && PoiType.Style != null && PoiType.Style.Analysis != null) // ? PoiType.Style.Analysis // : (Style!=null && Style.Analysis!=null) ? Style.Analysis : null; if (a == null || !a.Highlights.Any()) return false; NAnalysisStyle = new PoIStyle(); foreach (var hl in a.Highlights.Where(k => k.IsActive).OrderBy(k => k.Priority)) hl.CalculateResult(this); nEffectiveStyle = null; NotifyOfPropertyChange(() => NEffectiveStyle); return true; }
public object Clone() { var r = new PoIStyle { IsNotifying = false, StrokeColor = StrokeColor, StrokeWidth = StrokeWidth, DrawingMode = DrawingMode, FillColor = FillColor, CallOutFillColor = CallOutFillColor, CallOutForeground = CallOutForeground, Picture = Picture, PictureByteArray = PictureByteArray, IconHeight = IconHeight, IconWidth = IconWidth, Icon = Icon, TapMode = TapMode, Category = Category, TitleMode = TitleMode, MinResolution = MinResolution, MaxResolution = MaxResolution, NameLabel = NameLabel, AutoCallOutLabels = AutoCallOutLabels, StrokeOpacity = StrokeOpacity, FillOpacity = FillOpacity, Visible = Visible, Name = Name, BaseStyle = BaseStyle, CanRotate = CanRotate, CanEdit = CanEdit, CanDelete = CanDelete, CanMove = CanMove, CallOutOrientation = CallOutOrientation, CallOutTimeOut = CallOutTimeOut, TimelineBehaviour = TimelineBehaviour, ShowOnTimeline = ShowOnTimeline, AddMode = AddMode, MaxTitleResolution = MaxTitleResolution, CallOutMaxWidth = CallOutMaxWidth, CallOutMinHeight = CallOutMinHeight, InnerTextLabel = InnerTextLabel, InnerTextColor = InnerTextColor, Cluster = Cluster, ScalePoi = ScalePoi, ScaleStartResolution = ScaleStartResolution, ScaleUnits = ScaleUnits, MaxScale = MaxScale }; r.IsNotifying = true; return r; }
public static PoIStyle MergeStyle(IReadonlyPoIStyle s1, IReadonlyPoIStyle s2) { Count += 1; //Stopwatch sw = new Stopwatch(); //sw.Start(); var r = new PoIStyle { addMode = s2.AddMode.HasValue ? s2.AddMode : s1.AddMode, category = !string.IsNullOrEmpty(s2.Category) ? s2.Category : s1.Category, autoCallOutLabels = s2.AutoCallOutLabels.HasValue ? s2.AutoCallOutLabels : s1.AutoCallOutLabels, callOutFillColor = s2.CallOutFillColor.HasValue ? s2.CallOutFillColor : s1.CallOutFillColor, callOutForeground = s2.CallOutForeground.HasValue ? s2.CallOutForeground : s1.CallOutForeground, callOutOrientation = s2.CallOutOrientation.HasValue ? s2.CallOutOrientation : s1.CallOutOrientation, callOutTimeOut = s2.CallOutTimeOut.HasValue ? s2.CallOutTimeOut : s1.CallOutTimeOut, canDelete = s2.CanDelete.HasValue ? s2.CanDelete : s1.CanDelete, canEdit = s2.CanEdit.HasValue ? s2.CanEdit : s1.CanEdit, canMove = s2.CanMove.HasValue ? s2.CanMove : s1.CanMove, canRotate = s2.CanRotate.HasValue ? s2.CanRotate : s1.CanRotate, drawingMode = s2.DrawingMode.HasValue ? s2.DrawingMode : s1.DrawingMode, icon = (string.IsNullOrEmpty(s2.Icon)) ? s1.Icon : s2.Icon, iconHeight = s2.IconHeight.HasValue ? s2.IconHeight : s1.IconHeight, iconWidth = s2.IconWidth.HasValue ? s2.IconHeight : s1.IconHeight, maxResolution = s2.MaxResolution.HasValue ? s2.MaxResolution : s1.MaxResolution, maxTitleResolution = s2.MaxTitleResolution.HasValue ? s2.MaxTitleResolution : s1.MaxTitleResolution, minResolution = s2.MinResolution.HasValue ? s2.MinResolution : s1.MinResolution, nameLabel = (string.IsNullOrEmpty(s2.NameLabel)) ? s1.NameLabel : s2.NameLabel, innerTextLabel = (string.IsNullOrEmpty(s2.InnerTextLabel)) ? s1.InnerTextLabel : s2.InnerTextLabel, showOnTimeline = !string.IsNullOrEmpty(s2.ShowOnTimeline) ? s2.ShowOnTimeline : s1.ShowOnTimeline, strokeColor = s2.StrokeColor.HasValue ? s2.StrokeColor : s1.StrokeColor, strokeOpacity = s2.StrokeOpacity.HasValue ? s2.StrokeOpacity : s1.StrokeOpacity, strokeWidth = s2.StrokeWidth.HasValue ? s2.StrokeWidth : s1.StrokeWidth, tapMode = s2.TapMode.HasValue ? s2.TapMode : s1.TapMode, timelineBehaviour = s2.TimelineBehaviour.HasValue ? s2.TimelineBehaviour : s1.TimelineBehaviour, titleMode = s2.TitleMode.HasValue ? s2.TitleMode : s1.TitleMode, visible = s2.Visible.HasValue ? s2.Visible : s1.Visible, picture = s2.Picture ?? s1.Picture, fillColor = s2.FillColor.HasValue ? s2.FillColor : s1.FillColor, fillOpacity = s2.FillOpacity.HasValue ? s2.FillOpacity : s1.FillOpacity, callOutMaxWidth = s2.CallOutMaxWidth.HasValue ? s2.CallOutMaxWidth : s1.CallOutMaxWidth, callOutMinHeight = s2.CallOutMinHeight.HasValue ? s2.CallOutMinHeight : s1.CallOutMinHeight, innerTextColor = s2.InnerTextColor.HasValue ? s2.InnerTextColor : s1.InnerTextColor, Cluster = s2.Cluster.HasValue ? s2.Cluster : s1.Cluster, ScalePoi = s2.ScalePoi.HasValue ? s2.ScalePoi : s1.ScalePoi, ScaleStartResolution = s2.ScaleStartResolution.HasValue? s2.ScaleStartResolution : s1.ScaleStartResolution, ScaleUnits = s2.ScaleUnits.HasValue ? s2.ScaleUnits : s1.ScaleUnits, MaxScale = s2.MaxScale.HasValue ? s2.MaxScale : s1.MaxScale, SubTitles = string.IsNullOrEmpty(s2.SubTitles) ? s1.SubTitles : s2.SubTitles }; // If the name label is specified by a style, do not overwrite it. if (r.nameLabel == DefaultNameLabel && !string.IsNullOrEmpty(s1.NameLabel)) r.nameLabel = s1.NameLabel; //sw.Stop(); //Mergetime += sw.ElapsedTicks; return r; }
public static PoIStyle GetBasicStyle(string name = "Name", DrawingModes mode = DrawingModes.Point) { if (defaultStyle != null) return defaultStyle; defaultStyle = new PoIStyle { MinResolution = 0, MaxResolution = -1, DrawingMode = mode, CallOutForeground = Colors.Black, CallOutFillColor = Colors.White, StrokeOpacity = 1.0, StrokeWidth = 1.0, StrokeColor = Colors.Black, FillColor = Colors.Black, FillOpacity = 1.0, NameLabel = name, Visible = true, Category = "Other", Icon = "", CanDelete = true, CanRotate = true, CanEdit = true, CanMove = true, CallOutOrientation = DataServer.CallOutOrientation.Right, CallOutTimeOut = 5, IconHeight = 30, IconWidth = 30, ShowOnTimeline = null, TapMode = DataServer.TapMode.CallOutPopup, TitleMode = TitleModes.None, AddMode = AddModes.Silent, TimelineBehaviour = TimelineBehaviours.None, AutoCallOutLabels = false, MaxTitleResolution = -1, InnerTextColor = Colors.White, Cluster = false, ScalePoi = null, ScaleStartResolution = null, MaxScale = null, ScaleUnits = null, SubTitles = "" }; return defaultStyle; }