public override bool CanAdd(Element element) {
     if (element is Line) {
         Line line = element as Line;
         if ((line.Start == null) || (line.End == null)) { return false; }
         if (!line.Start.Docked || !line.End.Docked) { return false; }
         if ((line.Start.DockedElement == null) || (line.End.DockedElement == null)) { return false; }
         if (line.Start.DockedElement.Key == line.End.DockedElement.Key) { return false; }
     }
     return base.CanAdd(element);
 }
		//Brings a Element to the front of the zorder.
		public virtual void BringToFront(Element element)
		{
			if (mSuspendCount > 0)	return;
						
			foreach (Element loop in Values)
			{
				if (loop.mZOrder < element.mZOrder) loop.mZOrder += 1;
			}

			element.mZOrder = 0;
			OnChangeOrder();
		}
Beispiel #3
0
		//Creates a new element by copying an existing element
		//Layer should be assigned by the system and should not be copied
		public Element(Element prototype)
		{
			mKey = string.Empty;
			mLayerKey = string.Empty;

			mBorderColor = prototype.BorderColor;
			mBorderStyle = prototype.BorderStyle;
			mBorderWidth = prototype.BorderWidth;
			mSmoothingMode = prototype.SmoothingMode;
			mCustomPen = prototype.CustomPen;
			mDrawShadow = prototype.DrawShadow;
			mOpacity = prototype.Opacity;
			mTooltip = prototype.Tooltip;
			mVisible = prototype.Visible;
			mCursor = prototype.Cursor;

			mPath = prototype.GetPath();
			mRectF = prototype.Rectangle;
			mContainer = prototype.Container;
			
			mTag = prototype.Tag;
		}
		protected virtual bool SelectForPrint(Element element)
		{
			//Print all elements if not selected only
			if (!SelectedOnly) return true;

			//Check lines and docked elements
			if (element is Line)
			{
				Line line = (Line) element;
				
				//Return if line selected
				if (line.Selected) return true;

				//Return if docked shape is selected
				if (line.Start.DockedElement != null && SelectForPrint(line.Start.DockedElement)) return true;
				if (line.End.DockedElement != null && SelectForPrint(line.End.DockedElement)) return true;
			}

			//Check for other Iselectable items
			if (element is ISelectable)
			{
				ISelectable select = (ISelectable) element;
				return select.Selected;
			}


			return false;
		}
        //
        // PRIVATE METHOD
        //
        private void Model_ElementMouseUp(object sender, MouseEventArgs e) {
            try {
                // Clear Context Element
                this._elementContext = null;

                // Exit if not right mouse button
                if (e.Button != MouseButtons.Right) { return; }

                // Get Element
                Element element = sender as Element;
                if (element == null) { return; }

                // Set Context Element
                this._elementContext = element;
                
                // Show Context Menu
                if (element.GetType() == typeof(DomainCodedValue)) {
                    DomainCodedValue domainCodedValue = (DomainCodedValue)element;
                    if (domainCodedValue.SelectedCodedValue != null) {
                        this.contextDomainCodedValueItem.Show(this, e.Location);
                    }
                    else {
                        this.contextDomainCodedValue.Show(this, e.Location);
                    }
                }
                else if (element.GetType() == typeof(DomainRange)) {
                    this.contextDomainRange.Show(this, e.Location);
                }
                else if (element.GetType() == typeof(FeatureClass)) {
                    FeatureClass featureClass = (FeatureClass)element;
                    if (featureClass.SelectedField != null) {
                        this.contextField.Show(this, e.Location);
                    }
                    else if (featureClass.SelectedIndex != null) {
                        this.contextIndex.Show(this, e.Location);
                    }
                    else if (featureClass.SelectedIndexField != null) {
                        this.contextIndexField.Show(this, e.Location);
                    }
                    else {
                        this.contextFeatureClass.Show(this, e.Location);
                    }
                }
                else if (element.GetType() == typeof(FeatureDataset)) {
                    this.contextFeatureDataset.Show(this, e.Location);
                }
                else if (element.GetType() == typeof(GeometricNetwork)) {
                    this.contextGeometricNetwork.Show(this, e.Location);
                }
                else if (element.GetType() == typeof(Network)) {
                    this.contextNetwork.Show(this, e.Location);
                }
                else if (element.GetType() == typeof(ObjectClass)) {
                    ObjectClass objectClass = (ObjectClass)element;
                    if (objectClass.SelectedField != null) {
                        this.contextField.Show(this, e.Location);
                    }
                    else if (objectClass.SelectedIndex != null) {
                        this.contextIndex.Show(this, e.Location);
                    }
                    else if (objectClass.SelectedIndexField != null) {
                        this.contextIndexField.Show(this, e.Location);
                    }
                    else {
                        this.contextObjectClass.Show(this, e.Location);
                    }
                }
                else if (element.GetType() == typeof(RasterCatalog)) {
                    RasterCatalog rasterCatalog = (RasterCatalog)element;
                    if (rasterCatalog.SelectedField != null) {
                        this.contextField.Show(this, e.Location);
                    }
                    else if (rasterCatalog.SelectedIndex != null) {
                        this.contextIndex.Show(this, e.Location);
                    }
                    else if (rasterCatalog.SelectedIndexField != null) {
                        this.contextIndexField.Show(this, e.Location);
                    }
                    else {
                        this.contextRasterCatalog.Show(this, e.Location);
                    }
                }
                else if (element.GetType() == typeof(RasterBand)) {
                    RasterBand rasterBand = (RasterBand)element;
                    if (rasterBand.SelectedField != null) {
                        this.contextField.Show(this, e.Location);
                    }
                    else if (rasterBand.SelectedIndex != null) {
                        this.contextIndex.Show(this, e.Location);
                    }
                    else if (rasterBand.SelectedIndexField != null) {
                        this.contextIndexField.Show(this, e.Location);
                    }
                    else {
                        this.contextRasterBand.Show(this, e.Location);
                    }
                }
                else if (element.GetType() == typeof(RasterDataset)) {
                    this.contextRasterDataset.Show(this, e.Location);
                }
                else if (element.GetType() == typeof(RelationshipClass)) {
                    RelationshipClass relationshipClass = (RelationshipClass)element;
                    if (relationshipClass.SelectedField != null) {
                        this.contextField.Show(this, e.Location);
                    }
                    else if (relationshipClass.SelectedIndex != null) {
                        this.contextIndex.Show(this, e.Location);
                    }
                    else if (relationshipClass.SelectedIndexField != null) {
                        this.contextIndexField.Show(this, e.Location);
                    }
                    else {
                        this.contextRelationship.Show(this, e.Location);
                    }
                }
                else if (element.GetType() == typeof(Subtype)) {
                    Subtype subtype = (Subtype)element;
                    if (subtype.SelectedSubtypeField != null) {
                        this.contextSubtypeField.Show(this, e.Location);
                    }
                    else {
                        this.contextSubtype.Show(this, e.Location);
                    }
                }
                else if (element.GetType() == typeof(Terrain)) {
                    this.contextTerrain.Show(this, e.Location);
                }
                else if (element.GetType() == typeof(Topology)) {
                    this.contextTopology.Show(this, e.Location);
                }
            }
            catch (Exception ex) {
                ExceptionDialog.HandleException(ex);
            }
        }
        protected override void OnElementInvalid(Element element) {
            base.OnElementInvalid(element);

            // Reset Navigator
            this.Navigate.Reset();

            // Set the dirty flag
            this._dirty = true;
        }
Beispiel #7
0
		private void SetTooltip(Element element)
		{
			CancelTooltip();

			if (element.Tooltip != null && element.Tooltip != string.Empty)
			{
				mTooltip = new ToolTip();
				mTooltip.SetToolTip(this, element.Tooltip);
				mTooltip.Active = true;
			}
		}
Beispiel #8
0
		//Determines if an element is alignable
		private bool IsAlignable(Element element)
		{
			//Always true of align grid is on
			if (AlignGrid) return true;

			//If doesnt implement the IUserInteractive interface then false
			if (! (element is IUserInteractive)) return false;

			//Check the multiple flag enumeration to see if align to grid is set
			IUserInteractive interact = (IUserInteractive) element;
			return ((interact.Interaction & UserInteraction.AlignToGrid) == UserInteraction.AlignToGrid);
		}
Beispiel #9
0
		protected override void OnElementRemoved(Element element)
		{
			//Remove handler to detect if selected
			if (element is ISelectable)
			{
				ISelectable selectable = (ISelectable) element;
				selectable.SelectedChanged -=new EventHandler(selectable_SelectedChanged);
			}

			if (!UndoList.Suspended) 
			{
				SaveStatus();
				
				SetStatus(Status.UndoRedo);
				UndoList.Add(element,UndoAction.Remove);

				RestoreStatus();
			}
			
			base.OnElementRemoved (element);
		}
		public ElementsEventArgs(string key,Element value)
		{
			mKey = key;
			mValue = value;
		}
Beispiel #11
0
		public virtual void MoveElement(Element element, Layer source, Layer target)
		{
            target.Elements.SetModifiable(true);
            source.Elements.SetModifiable(true);

			target.Elements.Add(element.Key,element);
			source.Elements.Remove(element.Key);
            element.SetLayer(target);

            target.Elements.SetModifiable(false);
            source.Elements.SetModifiable(false);
		}
		public virtual void SetOrder(Element element, int order)
		{
			//Get existing zorder of element
			int existingOrder = element.ZOrder;

			//Check that zorder is within bounds of collection
			if (order >= this.Count) throw new ArgumentException("Order value must be less than the number of elements.","order");
			if (order < 0) throw new ArgumentException("Order value cannot be less than zero.","value");
			if (existingOrder == order) return;
			
			//Loop through internal collection
			foreach (Element loop in this.Values)
			{
				if (loop == element)
				{
					loop.mZOrder = order;
				}
				else
				{
					if (existingOrder < order)
					{
						if (loop.mZOrder <= order && loop.mZOrder > existingOrder)
						{
							loop.mZOrder -= 1;
						}
					}
					else
					{
						if (loop.mZOrder >=order && loop.ZOrder < existingOrder)
						{
							loop.mZOrder += 1;
						}
					}
				}
			}
			OnChangeOrder();
		}
Beispiel #13
0
		protected internal void SetParent(Element parent)
		{
			mParent = parent;
		}
Beispiel #14
0
		protected virtual void OnElementRemoved(Element element)
		{
			if (! SuspendEvents && ElementRemoved != null) ElementRemoved(this,new ElementsEventArgs(element.Key,element));
		}
		protected virtual void RenderElement(Graphics graphics,Element element)
		{
			GraphicsPath path = element.GetPathInternal();
			if (path  == null) return;

			//Create a brush if no custom brush defined
			if (element is SolidElement)
			{
				SolidElement solid = (SolidElement) element;
				if (solid.DrawBackground)
				{
					if (solid.CustomBrush == null)
					{
						//Use a linear gradient brush if gradient requested
						if (solid.DrawGradient)
						{
							LinearGradientBrush brush;
							brush = new LinearGradientBrush(new RectangleF(0,0,solid.Rectangle.Width,solid.Rectangle.Height),AdjustColor(solid.BackColor,0,solid.Opacity),AdjustColor(solid.GradientColor,0,solid.Opacity),solid.GradientMode);
							if (solid.Blend != null) brush.Blend = solid.Blend;
							graphics.FillPath(brush, path);
						}
							//Draw normal solid brush
						else
						{
							SolidBrush brush;
							brush = new SolidBrush(solid.BackColor);
						
							//Check if winforms renderer and adjust color as required
							brush.Color = AdjustColor(solid.BackColor,0,solid.Opacity);
							graphics.FillPath(brush,path);
						}
					}
					else	
					{
						graphics.FillPath(solid.CustomBrush, path);
					}
				}
			}

			Pen pen = null;

			if (element.CustomPen == null)
			{
				pen = new Pen(element.BorderColor,element.BorderWidth);
				pen.DashStyle = element.BorderStyle;
	
				//Check if winforms renderer and adjust color as required
				pen.Color = AdjustColor(element.BorderColor,element.BorderWidth,element.Opacity);
			}
			else	
			{
				pen = element.CustomPen;
			}
			
			graphics.DrawPath(pen,path);
		}
Beispiel #16
0
		//Determines if an element can be added interactively
		public virtual bool CanAdd(Element element)
		{
			return true;
		}
Beispiel #17
0
		public virtual bool CanDelete(Element element)
		{
			return true;
		}
		public ElementEventArgs(Element value)
		{
			mValue = value;
		}
Beispiel #19
0
		protected override void OnElementInserted(Element element)
		{
			//Add a new undo point
			if (!UndoList.Suspended) 
			{
				SaveStatus();
				
				SetStatus(Status.UndoRedo);
				UndoList.Add(element,UndoAction.Add);
				
				RestoreStatus();
			}

			//Attach handler to detect if selected
			if (element is ISelectable)
			{
				ISelectable selectable = (ISelectable) element;
				selectable.SelectedChanged +=new EventHandler(selectable_SelectedChanged);
			}

			base.OnElementInserted (element);
		}
		protected internal virtual void OnAnimateElement(Element e)
		{
			if (AnimateElement != null) AnimateElement(this, e);
		}
Beispiel #21
0
		private bool CheckBounds(Element element, IContainer container)
		{
			if (element.Visible)
			{
				Element action = element.ActionElement;

				//If the original (action) is contained in the container
				if (container.Contains(new PointF(action.Rectangle.X + container.Offset.X, action.Rectangle.Y + container.Offset.Y),container.Margin) && container.Contains(new PointF(action.Rectangle.Right + container.Offset.X,action.Rectangle.Bottom + container.Offset.Y),container.Margin))
				{
					//Check top left
					if (!container.Contains(new PointF(element.Rectangle.X + container.Offset.X, element.Rectangle.Y + container.Offset.Y),container.Margin)) return false;
						
					//Check bottom right
					if (! container.Contains(new PointF(element.Rectangle.Right + container.Offset.X, element.Rectangle.Bottom + container.Offset.Y),container.Margin)) return false;
				}
			}

			return true;
		}
		//Adds an elemnt to the list 
		public virtual int Add(Element value)  
		{
			return List.Add(value);
		}
Beispiel #23
0
		private bool IsOrderable(Element element)
		{
			//If doesnt implement the IUserInteractive interface then false
			if (! (element is IUserInteractive)) return false;

			//Check the multiple flag enumeration to see if alibring to front is set
			IUserInteractive interact = (IUserInteractive) element;
			return ((interact.Interaction & UserInteraction.BringToFront) == UserInteraction.BringToFront);
		}
		//Returns the index of an element
		public virtual int IndexOf(Element value)  
		{
			return List.IndexOf(value);
		}
        protected override void OnElementInserted(Element element) {
            // Call base method
            base.OnElementInserted(element);

            // Fix: Force newly added table to have a Maximum size of 1000x1000. Model resets size to 320x320.
            if (!this.SuspendEvents) {
                if (element is EsriTable) {
                    EsriTable table = (EsriTable)element;
                    if (table.MaximumSize.Width != 1000f || table.MaximumSize.Height != 100000f) {
                        table.MaximumSize = new SizeF(1000f, 100000f);
                    }

                    // Select newly added element
                    if (!table.Selected) {
                        // Clear Model Selection
                        this.SelectElements(false);
                        table.Selected = true;
                    }
                }
            }

            // Add dependant objects. For example, annotation featureclass require domains.
            if (!this.SuspendEvents) {
                if (element.GetType() == typeof(FeatureClass)) {
                    FeatureClass featureClass = (FeatureClass)element;
                    List<Domain> domains = Factory.RequiredDomains(featureClass);
                    float y = 0;
                    foreach (Domain domain in domains) {
                        // Check if domain already added
                        if (this.FindDomain(domain.Name) != null) { continue; }

                        // Add domain with vertical offset
                        y += featureClass.Height;
                        domain.Location = new PointF(
                            featureClass.Location.X,
                            featureClass.Location.Y + y);
                        this.Shapes.Add(this.Shapes.CreateKey(), domain);
                    }
                }
            }

            // Reset Navigator
            this.Navigate.Reset();
        }
		//Inserts an elelemnt into the list
		public virtual void Insert(int index, Element value)  
		{
			List.Insert(index, value);
		}
        protected override void OnElementRemoved(Element element) {
            base.OnElementRemoved(element);

            // Reset Navigator
            this.Navigate.Reset();
        }
		//Removes an element from the list
		public virtual void Remove(Element value )  
		{
			List.Remove(value);
		}
 private void Model_ElementDoubleClick(object sender, EventArgs e) {
     try {
         // Get Element
         Element element = sender as Element;
         if (element == null) { return; }
         this._elementContext = element;
         //
         if (element.GetType() == typeof(DomainCodedValue)){
             this.Invoke(new EventHandler(this.MenuItem_Activate), new object[] { this.menuItemDomainCodedValue_OpenDiagram, EventArgs.Empty });
         }
         else if (element.GetType() == typeof(DomainRange)) {
             this.Invoke(new EventHandler(this.MenuItem_Activate), new object[] { this.menuItemDomainRange_OpenDiagram, EventArgs.Empty });
         }
         else if (element.GetType() == typeof(RelationshipClass)) {
             this.Invoke(new EventHandler(this.MenuItem_Activate), new object[] { this.menuItemRelationship_OpenDiagram, EventArgs.Empty });
         }
         else if (element.GetType() == typeof(GeometricNetwork)) {
             this.Invoke(new EventHandler(this.MenuItem_Activate), new object[] { this.menuItemGeometricNetwork_OpenDiagram, EventArgs.Empty });
         }
         else if (element.GetType() == typeof(Topology)) {
             this.Invoke(new EventHandler(this.MenuItem_Activate), new object[] { this.menuItemTopology_OpenDiagram, EventArgs.Empty });
         }
         else if (element.GetType() == typeof(Terrain)) {
             this.Invoke(new EventHandler(this.MenuItem_Activate), new object[] { this.menuItemTerrain_OpenDiagram, EventArgs.Empty });
         }
     }
     catch (Exception ex) {
         ExceptionDialog.HandleException(ex);
     }
 }
		//Returns true if list contains element
		public virtual bool Contains(Element value)  
		{
			return List.Contains(value);
		}