Ejemplo n.º 1
0
            public void SerializeLayout(StoredAnnotationLayout layout)
            {
                string     xPath       = "annotation-configuration/annotation-layouts";
                XmlElement layoutsNode = (XmlElement)this.Document.SelectSingleNode(xPath);

                if (layoutsNode == null)
                {
                    throw new InvalidDataException(String.Format(SR.ExceptionInvalidAnnotationLayoutXml, "'annotation-layouts' node does not exist"));
                }

                XmlElement newLayoutNode = this.Document.CreateElement("annotation-layout");

                newLayoutNode.SetAttribute("id", layout.Identifier);

                XmlElement groupsNode = this.Document.CreateElement("annotation-box-groups");

                newLayoutNode.AppendChild(groupsNode);

                SerializeAnnotationBoxGroups(groupsNode, layout.AnnotationBoxGroups);

                xPath = String.Format("annotation-layout[@id='{0}']", layout.Identifier);
                XmlElement existingLayoutNode = (XmlElement)layoutsNode.SelectSingleNode(xPath);

                if (existingLayoutNode != null)
                {
                    layoutsNode.ReplaceChild(newLayoutNode, existingLayoutNode);
                }
                else
                {
                    layoutsNode.AppendChild(newLayoutNode);
                }
            }
Ejemplo n.º 2
0
        private static IAnnotationLayout CreateRealLayout(string storedLayoutId)
        {
            try
            {
                StoredAnnotationLayout storedLayout = GetStoredLayout(storedLayoutId);
                if (storedLayout != null)
                {
                    return(storedLayout.Clone());
                }

                //just return an empty layout.
                return(new AnnotationLayout());
            }
            catch (Exception e)
            {
                Platform.Log(LogLevel.Error, e);

                var layout = new AnnotationLayout();
                var item   = new BasicTextAnnotationItem("errorbox", "errorbox", @"LabelError",
                                                         SR.MessageErrorLoadingAnnotationLayout);
                var box = new AnnotationBox(new RectangleF(0.5F, 0.90F, 0.5F, 0.10F), item)
                {
                    Bold              = true,
                    Color             = "Red",
                    Justification     = AnnotationBox.JustificationBehaviour.Right,
                    NumberOfLines     = 5,
                    VerticalAlignment = AnnotationBox.VerticalAlignmentBehaviour.Bottom
                };

                layout.AnnotationBoxes.Add(box);
                return(layout);
            }
        }
Ejemplo n.º 3
0
		/// <summary>
		/// Cloning constructor.
		/// </summary>
		/// <param name="source">The source object from which to clone.</param>
		/// <param name="context">This parameter is unused.</param>
		private StoredAnnotationLayout(StoredAnnotationLayout source, ICloningContext context)
		{
			this._identifier = source._identifier;
			this._visible = source._visible;
			foreach (StoredAnnotationBoxGroup group in source._annotationBoxGroups)
			{
				if (group == null)
					continue;
				this._annotationBoxGroups.Add(group.Clone());
			}
		}
Ejemplo n.º 4
0
 /// <summary>
 /// Cloning constructor.
 /// </summary>
 /// <param name="source">The source object from which to clone.</param>
 /// <param name="context">This parameter is unused.</param>
 private StoredAnnotationLayout(StoredAnnotationLayout source, ICloningContext context)
 {
     this._identifier = source._identifier;
     this._visible    = source._visible;
     foreach (StoredAnnotationBoxGroup group in source._annotationBoxGroups)
     {
         if (group == null)
         {
             continue;
         }
         this._annotationBoxGroups.Add(group.Clone());
     }
 }
Ejemplo n.º 5
0
            public StoredAnnotationLayout DeserializeLayout(XmlElement layoutNode)
            {
                Platform.CheckForNullReference(layoutNode, "layoutNode");

                StoredAnnotationLayout layout = new StoredAnnotationLayout(layoutNode.GetAttribute("id"));
                XmlNodeList            annotationBoxGroupNodes = layoutNode.SelectNodes("annotation-box-groups/annotation-box-group");

                if (annotationBoxGroupNodes != null)
                {
                    DeserializeAnnotationBoxGroups(layout, annotationBoxGroupNodes);
                }

                return(layout);
            }
Ejemplo n.º 6
0
        private static StoredAnnotationLayout GetStoredLayout(string layoutId)
        {
            lock (_syncLock)
            {
                if (_layoutCache.ContainsKey(layoutId))
                {
                    return(_layoutCache[layoutId]);
                }

                StoredAnnotationLayout layout = AnnotationLayoutStore.Instance.GetLayout(layoutId, AvailableAnnotationItems);
                if (layout != null)
                {
                    _layoutCache[layoutId] = layout;
                }

                return(layout);
            }
        }
Ejemplo n.º 7
0
        public void Update(StoredAnnotationLayout layout)
        {
            Platform.CheckForNullReference(layout, "layout");
            Platform.CheckForEmptyString(layout.Identifier, "layout.Identifier");

            lock (_syncLock)
            {
                Initialize(false);

                try
                {
                    new StoredAnnotationLayoutSerializer().SerializeLayout(layout);
                    SaveSettings();
                }
                catch (Exception e)
                {
                    Platform.Log(LogLevel.Debug, e);
                    Initialize(true);
                }
            }
        }
Ejemplo n.º 8
0
            private void DeserializeAnnotationBoxGroups(StoredAnnotationLayout layout, XmlNodeList groupNodes)
            {
                foreach (XmlElement groupNode in groupNodes)
                {
                    string newGroupId = groupNode.GetAttribute("id");
                    StoredAnnotationBoxGroup newGroup = new StoredAnnotationBoxGroup(newGroupId);

                    XmlElement defaultBoxSettingsNode = (XmlElement)groupNode.SelectSingleNode("default-box-settings");

                    if (defaultBoxSettingsNode != null)
                    {
                        DeserializeBoxSettings(newGroup.DefaultBoxSettings, defaultBoxSettingsNode);
                    }

                    XmlNodeList annotationBoxNodes = groupNode.SelectNodes("annotation-boxes/annotation-box");
                    if (annotationBoxNodes != null)
                    {
                        DeserializeAnnotationBoxes(newGroup, annotationBoxNodes);
                    }

                    layout.AnnotationBoxGroups.Add(newGroup);
                }
            }
Ejemplo n.º 9
0
			public void SerializeLayout(StoredAnnotationLayout layout)
			{
				string xPath = "annotation-configuration/annotation-layouts";
				XmlElement layoutsNode = (XmlElement)this.Document.SelectSingleNode(xPath);
				if (layoutsNode == null)
					throw new InvalidDataException(String.Format(SR.ExceptionInvalidAnnotationLayoutXml, "'annotation-layouts' node does not exist"));

				XmlElement newLayoutNode = this.Document.CreateElement("annotation-layout");
				newLayoutNode.SetAttribute("id", layout.Identifier);

				XmlElement groupsNode = this.Document.CreateElement("annotation-box-groups");
				newLayoutNode.AppendChild(groupsNode);

				SerializeAnnotationBoxGroups(groupsNode, layout.AnnotationBoxGroups);

				xPath = String.Format("annotation-layout[@id='{0}']", layout.Identifier);
				XmlElement existingLayoutNode = (XmlElement)layoutsNode.SelectSingleNode(xPath);

				if (existingLayoutNode != null)
					layoutsNode.ReplaceChild(newLayoutNode, existingLayoutNode);
				else
					layoutsNode.AppendChild(newLayoutNode);
			}
Ejemplo n.º 10
0
			private void DeserializeAnnotationBoxGroups(StoredAnnotationLayout layout, XmlNodeList groupNodes)
			{
				foreach (XmlElement groupNode in groupNodes)
				{
					string newGroupId = groupNode.GetAttribute("id");
					StoredAnnotationBoxGroup newGroup = new StoredAnnotationBoxGroup(newGroupId);

					XmlElement defaultBoxSettingsNode = (XmlElement)groupNode.SelectSingleNode("default-box-settings");

					if (defaultBoxSettingsNode != null)
						DeserializeBoxSettings(newGroup.DefaultBoxSettings, defaultBoxSettingsNode);

					XmlNodeList annotationBoxNodes = groupNode.SelectNodes("annotation-boxes/annotation-box");
					if (annotationBoxNodes != null)
						DeserializeAnnotationBoxes(newGroup, annotationBoxNodes);

					layout.AnnotationBoxGroups.Add(newGroup);
				}
			}
Ejemplo n.º 11
0
			public StoredAnnotationLayout DeserializeLayout(XmlElement layoutNode)
			{
				Platform.CheckForNullReference(layoutNode, "layoutNode");

				StoredAnnotationLayout layout = new StoredAnnotationLayout(layoutNode.GetAttribute("id"));
				XmlNodeList annotationBoxGroupNodes = layoutNode.SelectNodes("annotation-box-groups/annotation-box-group");
				if (annotationBoxGroupNodes != null)
					DeserializeAnnotationBoxGroups(layout, annotationBoxGroupNodes);

				return layout;
			}
Ejemplo n.º 12
0
		public void Update(StoredAnnotationLayout layout)
		{
			Platform.CheckForNullReference(layout, "layout");
			Platform.CheckForEmptyString(layout.Identifier, "layout.Identifier");

			lock (_syncLock)
			{
				Initialize(false);

				try
				{
					new StoredAnnotationLayoutSerializer().SerializeLayout(layout);
					SaveSettings();
				}
				catch(Exception e)
				{
					Platform.Log(LogLevel.Debug, e);
					Initialize(true);
				}
			}
		}