예제 #1
0
        /// <summary>
        /// Gets the index at which the positionBase is situated in the parent. This can be used to determine the index the item that gets moved should be inserted.
        /// </summary>
        /// <param name="parent">The legend item the moving item should be added to.</param>
        /// <param name="positionBase">The item that is used to determine the new position of the moving item.</param>
        /// <returns>The new position of the moving item.</returns>
        public static int InsertIndex(this ILegendItem parent, ILegendItem positionBase)
        {
            if (parent == null || positionBase == null)
            {
                return(-1);
            }

            ILegendItem item = positionBase;

            if (item == parent)
            {
                return(item.LegendItems.Count());
            }

            while (item != null)
            {
                var p = item.GetParentItem();

                if (p == parent)
                {
                    var items = p.LegendItems.ToList();
                    return(items.IndexOf(item));
                }

                item = p;
            }

            return(-1);
        }
예제 #2
0
 /// <summary>
 /// Creates a new instance of DrawLegendItemArgs
 /// </summary>
 /// <param name="g">A Graphics surface to draw on</param>
 /// <param name="item">The legend item to draw</param>
 /// <param name="clipRectangle">The bounds that drawing should occur within</param>
 /// <param name="topLeft">The position of the top left corner where drawing should start.</param>
 public DrawLegendItemArgs(Graphics g, ILegendItem item, Rectangle clipRectangle, PointF topLeft)
 {
     TopLeft = topLeft;
     Graphics = g;
     Item = item;
     ClipRectangle = clipRectangle;
 }
예제 #3
0
파일: Legend.cs 프로젝트: qingqibing/aa
        private Size SizeItem(int offset, ILegendItem item, Graphics g)
        {
            if (item == null)
            {
                return(new Size(0, 0));
            }
            int width  = offset + 30 + (int)g.MeasureString(item.LegendText, Font).Width;
            int height = ItemHeight;

            if (item.LegendSymbolMode == SymbolMode.Symbol)
            {
                Size s = item.GetLegendSymbolSize();
                if (s.Height > ItemHeight)
                {
                    height = s.Height;
                }
            }

            if (item.IsExpanded)
            {
                if (item.LegendItems != null)
                {
                    foreach (ILegendItem child in item.LegendItems)
                    {
                        Size cs = SizeItem(offset + _indentation, child, g);
                        height += cs.Height;
                        if (cs.Width > width)
                        {
                            width = cs.Width;
                        }
                    }
                }
            }
            return(new Size(width, height));
        }
예제 #4
0
        public void SetSymbol(ILegendItem item, ISymbol symbol)
        {
            if (item == symbol || item == null)
            {
                return;
            }

            if (item == _defaultSymbol)
            {
                if (_defaultSymbol != null)
                {
                    _defaultSymbol.Release();
                }
                _defaultSymbol = symbol;
            }
            else
            {
                foreach (QuantityClass qClass in _quantityClasses)
                {
                    if (qClass != null && qClass.Symbol == item)
                    {
                        qClass.Symbol = symbol;
                        return;
                    }
                }
            }
        }
예제 #5
0
 /// <summary>
 /// Creates a new instance of DrawLegendItemArgs
 /// </summary>
 /// <param name="g">A Graphics surface to draw on</param>
 /// <param name="item">The legend item to draw</param>
 /// <param name="clipRectangle">The bounds that drawing should occur within</param>
 /// <param name="topLeft">The position of the top left corner where drawing should start.</param>
 public DrawLegendItemArgs(Graphics g, ILegendItem item, Rectangle clipRectangle, PointF topLeft)
 {
     _topLeft = topLeft;
     _graphics = g;
     _item = item;
     _clipRectangle = clipRectangle;
 }
예제 #6
0
        /// <summary>
        /// Given the starting position, which might not be able to contain the drop item,
        /// determine the index in the valid container where this item should end up.
        /// </summary>
        /// <param name="startItem">The legend item that may not be a sibling or be able to contain the drop item</param>
        /// <param name="dropItem">The item being added to the legend</param>
        /// <returns>The integer index of the valid container where insertion should occur when dropping onto this item.</returns>
        public static int InsertIndex(this ILegendItem startItem, ILegendItem dropItem)
        {
            ILegendItem container = GetValidContainerFor(startItem, dropItem);

            if (container == null)
            {
                return(-1);
            }
            ILegendItem insertTarget = GetInsertTarget(startItem, dropItem);

            if (insertTarget == null)
            {
                return(container.LegendItems.Count());
            }
            if (insertTarget == container)
            {
                return(container.LegendItems.Count());
            }
            List <ILegendItem> items = container.LegendItems.ToList();

            if (items.Contains(insertTarget))
            {
                return(items.IndexOf(insertTarget));
            }
            return(container.LegendItems.Count());
        }
예제 #7
0
        /// <summary>
        /// This method starts with this legend item and tests to see if it can contain
        /// the specified target.  As it moves up the
        /// </summary>
        /// <param name="startItem">This legend item</param>
        /// <param name="dropItem">The target legend item to test</param>
        /// <returns>An ILegendItem that is one of the parent items of this item, but that can receive the target.</returns>
        public static ILegendItem GetValidContainerFor(this ILegendItem startItem, ILegendItem dropItem)
        {
            if (startItem == null)
            {
                return(null);
            }
            if (dropItem == null)
            {
                return(null);
            }
            if (startItem.CanReceiveItem(dropItem))
            {
                return(startItem);
            }
            ILegendItem item = startItem;

            while ((item = item.GetParentItem()) != null)
            {
                if (item.CanReceiveItem(dropItem))
                {
                    return(item);
                }
            }
            return(null);
        }
예제 #8
0
 public void SetSymbol(ILegendItem item, ISymbol symbol)
 {
     if (item == _symbol && symbol is ITextSymbol)
     {
         _symbol = symbol as ITextSymbol;
     }
 }
예제 #9
0
        private static ILegendItem GetInsertTarget(ILegendItem startItem, ILegendItem dropItem)
        {
            if (startItem == null)
            {
                return(null);
            }
            if (dropItem == null)
            {
                return(null);
            }
            if (startItem.CanReceiveItem(dropItem))
            {
                return(startItem);
            }
            ILegendItem item = startItem;

            while (item.GetParentItem() != null)
            {
                if (item.GetParentItem().CanReceiveItem(dropItem))
                {
                    return(item);
                }
                item = item.GetParentItem();
            }
            return(null);
        }
예제 #10
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DrawLegendItemArgs"/> class.
 /// </summary>
 /// <param name="g">A Graphics surface to draw on.</param>
 /// <param name="item">The legend item to draw.</param>
 /// <param name="clipRectangle">The bounds that drawing should occur within.</param>
 /// <param name="topLeft">The position of the top left corner where drawing should start.</param>
 public DrawLegendItemArgs(Graphics g, ILegendItem item, Rectangle clipRectangle, PointF topLeft)
 {
     TopLeft       = topLeft;
     Graphics      = g;
     Item          = item;
     ClipRectangle = clipRectangle;
 }
예제 #11
0
        private UIElement MakeItem(ILegendItem legendItem, Legend legend, IMapperOwner owner)
        {
            switch (legendItem.LegendItemKind)
            {
            case LegendItemKind.Point:
                return(MakePointItem(legendItem, legend, owner));

            case LegendItemKind.Line:
                return(MakeLineItem(legendItem, legend, owner));

            case LegendItemKind.KML:
            case LegendItemKind.None:
                return(null);

            case LegendItemKind.ColorSwatch:
                return(MakeColorSwatchItem(legendItem, legend, owner));

            case LegendItemKind.Text:
                return(MakeTextItem(legendItem, legend, owner));

            default:
                System.Diagnostics.Debug.Assert(false, "unknown legend item type");
                return(null);
            }
        }
예제 #12
0
 public void SetSymbol(ILegendItem item, ISymbol symbol)
 {
     if (_renderer is ILegendGroup)
     {
         ((ILegendGroup)_renderer).SetSymbol(item, symbol);
     }
 }
        public ILegendItem Create(ILegendSettings legend, object item)
        {
            if (item == null)
            {
                throw new ArgumentNullException("item");
            }
            if (!(item is LabelLayer))
            {
                throw new ArgumentException("Item is not a label layer", "item");
            }

            var vl = (LabelLayer)item;

            ILegendItem res = null;

            if (vl.Theme != null)
            {
                res       = Factory[vl.Theme].Create(legend, vl.Theme) ?? new LegendItem();
                res.Label = vl.LayerName + res.Label ?? string.Empty;
            }
            else
            {
                res       = Factory[vl.Style].Create(legend, vl.Style) ?? new LegendItem();
                res.Label = vl.LayerName;
            }

            res.LabelFont  = legend.ItemFont;
            res.LabelBrush = legend.ForeColor;
            res.Padding    = legend.Padding;
            res.Exclude    = !vl.Enabled;
            res.Expanded   = res.SubItems.Count > 0;
            res.Item       = item;

            return(res);
        }
예제 #14
0
파일: Legend.cs 프로젝트: qingqibing/aa
        // Draw the plus or minus visible for controlling expansion
        private void DrawPlusMinus(Graphics g, ref PointF topLeft, LegendBox itemBox)
        {
            ILegendItem item = itemBox.Item;

            if (item == null)
            {
                return;
            }
            if (item.LegendSymbolMode == SymbolMode.Symbol)
            {
                return;                                             // don't allow symbols to expand
            }
            Point tl = new Point((int)topLeft.X, (int)topLeft.Y);

            tl.Y += (ItemHeight - 8) / 2;
            tl.X += 3;
            Rectangle box = new Rectangle(tl.X, tl.Y, 8, 8);

            itemBox.ExpandBox = box;
            Point center = new Point(tl.X + 4, (int)topLeft.Y + ItemHeight / 2);

            g.FillRectangle(Brushes.White, box);
            g.DrawRectangle(Pens.Gray, box);
            if (item.IsExpanded)
            {
                g.DrawRectangle(Pens.Gray, box);
            }
            else if (item.LegendItems != null && item.LegendItems.Any())
            {
                g.DrawLine(Pens.Black, center.X, center.Y - 2, center.X, center.Y + 2);
            }
            g.DrawLine(Pens.Black, center.X - 2, center.Y, center.X + 2, center.Y);
            topLeft.X += 13;
        }
예제 #15
0
파일: Legend.cs 프로젝트: qingqibing/aa
        private void DoItemMouseDown(ItemMouseEventArgs e)
        {
            Point loc = new Point(e.X + ControlRectangle.X, e.Location.Y + ControlRectangle.Top);

            // Toggle expansion
            if (e.ItemBox.ExpandBox.Contains(loc))
            {
                e.ItemBox.Item.IsExpanded = !e.ItemBox.Item.IsExpanded;
                if (ExpandBoxMouseDown != null)
                {
                    ExpandBoxMouseDown(this, e);
                }

                ResetLegend();
                return;
            }

            if (e.ItemBox.Item.IsSelected)
            {
                // if we are already selected, prepare to edit in textbox
                _previousMouseDown = e.ItemBox;

                // Start dragging
                if (e.Button == MouseButtons.Left)
                {
                    _isDragging = true;
                    ILegendItem li = e.ItemBox.Item;
                    while (li != null && li as ILayer == null)
                    {
                        li = li.GetParentItem();
                    }
                    ILayer lyr = li as ILayer;
                    if (lyr != null)
                    {
                        _dragItem = BoxFromItem(lyr);
                    }
                    else
                    {
                        _isDragging = false;
                    }
                }
            }
            else
            {
                // Check for textbox clicking
                if (e.ItemBox.Textbox.Contains(loc))
                {
                    if (ModifierKeys != Keys.Shift)
                    {
                        ClearSelection();
                    }
                    e.ItemBox.Item.IsSelected = true;

                    //_selection.Add(e.ItemBox);
                    //IsInitialized = false;
                    //Invalidate();
                    //return;
                }
            }
        }
예제 #16
0
파일: Legend.cs 프로젝트: qingqibing/aa
        // Draw the checkbox for an item
        private void DrawCheckBoxes(Graphics g, ref PointF topLeft, LegendBox itemBox)
        {
            ILegendItem item = itemBox.Item;

            if (item == null)
            {
                return;
            }
            if (item.LegendSymbolMode != SymbolMode.Checkbox)
            {
                return;
            }

            if (item.Checked)
            {
                int top  = (int)topLeft.Y + (ItemHeight - _icoChecked.Height) / 2;
                int left = (int)topLeft.X + 6;
                g.DrawIcon(_icoChecked, left, top);
                Rectangle box = new Rectangle(left, top, _icoChecked.Width, _icoChecked.Height);
                itemBox.CheckBox = box;
            }
            else
            {
                int top  = (int)topLeft.Y + (ItemHeight - _icoUnchecked.Height) / 2;
                int left = (int)topLeft.X + 6;
                g.DrawIcon(_icoUnchecked, left, top);
                Rectangle box = new Rectangle(left, top, _icoChecked.Width, _icoChecked.Height);
                itemBox.CheckBox = box;
            }
            topLeft.X += 22;
        }
예제 #17
0
 /// <summary>
 /// Creates a new instance of DrawLegendItemArgs
 /// </summary>
 /// <param name="g">A Graphics surface to draw on</param>
 /// <param name="item">The legend item to draw</param>
 /// <param name="clipRectangle">The bounds that drawing should occur within</param>
 /// <param name="topLeft">The position of the top left corner where drawing should start.</param>
 public DrawLegendItemArgs(Graphics g, ILegendItem item, Rectangle clipRectangle, PointF topLeft)
 {
     _topLeft       = topLeft;
     _graphics      = g;
     _item          = item;
     _clipRectangle = clipRectangle;
 }
예제 #18
0
        private UIElement MakeColorSwatchItem(ILegendItem mapperItem, Legend mapLegend, IMapperOwner owner)
        {
            System.Diagnostics.Debug.Assert(mapperItem.LegendItemKind == LegendItemKind.ColorSwatch);
            double padding;
            var    tb = MakeItemText(mapperItem, mapLegend, owner, out padding);

            padding = 0; // todo: allow override

            // graphics:
            Path p      = new Path();
            var  stroke = GetStrokeColor(mapLegend, mapperItem);

            p.Stroke = Util.BrushFromGdiColor(stroke);
            var fill = mapperItem.LegendItemFillColor;

            p.Fill = Util.BrushFromGdiColor(fill);

            double   size = tb.FontSize; // / 3; // a "heuristic" ...
            Geometry eg   = Util.MarkerShapeToGeometry(MarkerShape.Square, size);

            p.Data = eg;
            p.VerticalAlignment   = System.Windows.VerticalAlignment.Center;
            p.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;
            p.Margin = new Thickness(size + padding, size + padding, padding, padding);

            // combine:
            StackPanel sp = new StackPanel();

            sp.Orientation = Orientation.Horizontal;
            sp.Children.Add(p);
            sp.Children.Add(tb);

            return(sp);
        }
예제 #19
0
        public void SetSymbol(ILegendItem item, ISymbol symbol)
        {
            if (item == symbol)
            {
                return;
            }

            //if (item == _defaultSymbol)
            //{
            //    _defaultSymbol.Release();
            //    _defaultSymbol = symbol;
            //}
            //else
            {
                foreach (string key in _symbolTable.Keys)
                {
                    if (!(_symbolTable[key] is ILegendItem))
                    {
                        continue;
                    }

                    if (_symbolTable[key] == item)
                    {
                        if (symbol is ILegendItem)
                        {
                            ((ILegendItem)symbol).LegendLabel = item.LegendLabel;
                        }

                        _symbolTable[key] = symbol;
                        return;
                    }
                }
            }
        }
예제 #20
0
        public void SetSymbol(ILegendItem item, ISymbol symbol)
        {
            if (item == symbol)
            {
                return;
            }

            foreach (string key in _symbolTable.Keys)
            {
                if (!(_symbolTable[key] is ILegendItem))
                {
                    continue;
                }

                if (_symbolTable[key] == item)
                {
                    if (symbol is ILegendItem)
                    {
                        ((ILegendItem)symbol).LegendLabel = item.LegendLabel;
                    }

                    _symbolTable[key] = symbol;
                    return;
                }
            }
        }
예제 #21
0
 private void listLegendLayers_SelectedIndexChanged(object sender, EventArgs e)
 {
     this.bool_0        = false;
     this.ilegendItem_0 =
         (this.listLegendLayers.Items[this.listLegendLayers.SelectedIndex] as LegendItemWrap).LegendItem;
     if (this.ilegendItem_0 != null)
     {
         ILegendClassFormat legendClassFormat = this.ilegendItem_0.LegendClassFormat;
         if (legendClassFormat.AreaPatch == null)
         {
             ILegendFormat format = this.ilegend_0.Format;
             legendClassFormat.AreaPatch   = format.DefaultAreaPatch;
             legendClassFormat.LinePatch   = format.DefaultLinePatch;
             legendClassFormat.PatchWidth  = format.DefaultPatchWidth;
             legendClassFormat.PatchHeight = format.DefaultPatchHeight;
         }
         if (this.定制 == null)
         {
             this.定制      = new ServerStyleGalleryItemClass();
             this.定制.Name = "定制";
             this.定制.Item = legendClassFormat.LinePatch;
         }
         if (this.定制_1 == null)
         {
             this.定制_1      = new ServerStyleGalleryItemClass();
             this.定制_1.Name = "定制";
             this.定制_1.Item = legendClassFormat.AreaPatch;
         }
         this.cboLinePatches.SelectStyleGalleryItem(this.定制);
         this.cboAreaPatches.SelectStyleGalleryItem(this.定制_1);
         this.txtWidth.Text  = legendClassFormat.PatchWidth.ToString("#.##");
         this.txtHeight.Text = legendClassFormat.PatchHeight.ToString("#.##");
         this.bool_0         = true;
     }
 }
예제 #22
0
        public override void Run()
        {
            ILegendItem selectedItem = (GIS.FrameWork.Application.App.Legend as GIS.Common.Dialogs.Legend).SelectedLegendMenuItem;

            if (selectedItem != null)
            {
                if (selectedItem != null)
                {
                    if (selectedItem is FeatureLayer)
                    {
                        FeatureLayerActions fla = new FeatureLayerActions();
                        if (fla != null && selectedItem != null)
                        {
                            fla.ShowProperties(selectedItem as IFeatureLayer);
                        }
                    }
                    else if (selectedItem is RasterLayer)
                    {
                        RasterLayerActions rla = new RasterLayerActions();
                        if (rla != null && selectedItem != null)
                        {
                            rla.ShowProperties(selectedItem as IRasterLayer);
                        }
                    }
                    else if (selectedItem is ImageLayer)
                    {
                        ImageLayerActions ila = new ImageLayerActions();
                        if (ila != null && selectedItem != null)
                        {
                            ila.ShowProperties(selectedItem as IImageLayer);
                        }
                    }
                }
            }
        }
예제 #23
0
        /// <summary>
        /// Tests the specified legend item.  If the item is another layer or a group or a map-frame, then this
        /// will return false.  Furthermore, if the parent of the item is not also this object, then it will
        /// also return false.  The idea is that layers can have sub-nodes move around, but not transport from
        /// place to place.
        /// </summary>
        /// <param name="item">the legend item to test</param>
        /// <returns>Boolean that if true means that it is ok to insert the specified item into this layer.</returns>
        public override bool CanReceiveItem(ILegendItem item)
        {
            if (item.GetParentItem() != this)
            {
                return(false);
            }
            ILayer lyr = item as ILayer;

            if (lyr != null)
            {
                return(false);
            }
            IFrame mf = item as IFrame;

            if (mf != null)
            {
                return(false);
            }
            IGroup gr = item as IGroup;

            if (gr != null)
            {
                return(false);
            }
            return(true);
        }
예제 #24
0
        private void RendererBox_DrawItem(object sender, DrawItemEventArgs e)
        {
            if (e.Index >= RendererBox.Items.Count || e.Index < 0)
            {
                return;
            }

            object item = RendererBox.Items[e.Index];

            if (item is RendererItem)
            {
                SolidBrush b, f;
                if ((e.State & DrawItemState.Selected) != 0)
                {
                    b = (SolidBrush)Brushes.DarkBlue;
                    f = (SolidBrush)Brushes.White;
                }
                else
                {
                    b = (SolidBrush)Brushes.White;
                    f = (SolidBrush)Brushes.Black;
                }
                using (System.Drawing.Font font = new Font("Arial", 10))
                {
                    e.Graphics.FillRectangle(b, e.Bounds);
                    Rectangle rect = new Rectangle(e.Bounds.X + 20, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height);
                    e.Graphics.DrawString(item.ToString(), font, f, rect);

                    rect = new Rectangle(5, e.Bounds.Y + 2, 11, 11);
                    e.Graphics.DrawImage(
                        (((RendererItem)item).ShowLegend ?
                         global::gView.Win.Carto.Rendering.UI.Properties.Resources.CollapseIcon :
                         global::gView.Win.Carto.Rendering.UI.Properties.Resources.ExpandIcon),
                        rect);
                }
            }
            else if (item is LegendItem)
            {
                Rectangle rect = new Rectangle(20, e.Bounds.Top, 30, 20);

                ILegendItem legendItem = ((LegendItem)item).Item;
                if (legendItem != null)
                {
                    if (legendItem is ISymbol)
                    {
                        e.Graphics.DrawSymbol((ISymbol)legendItem, rect);
                    }
                    if (legendItem.LegendLabel != String.Empty)
                    {
                        using (Font font = new Font("Arial", 9))
                        {
                            e.Graphics.DrawString(legendItem.LegendLabel, font, Brushes.Black, 52, e.Bounds.Top + e.Bounds.Height / 2 - font.Height / 2);
                            SizeF stringSize = e.Graphics.MeasureString(legendItem.LegendLabel, font);
                            RendererBox.HorizontalExtent = (int)Math.Max(RendererBox.HorizontalExtent, 52 + stringSize.Width);
                        }
                    }
                }
            }
        }
예제 #25
0
 /// <summary>
 /// Gets the index of the specified item in this collection if it is a layer.
 /// </summary>
 /// <param name="item">Item whose index should be returned.</param>
 /// <returns>-1 if the item is no ILayer or not found, otherwise the index.</returns>
 public int IndexOf(ILegendItem item)
 {
     if (item is not ILayer layer)
     {
         return(-1);
     }
     return(base.IndexOf(layer));
 }
 public void SetObjects(object @object)
 {
     m_pOldLegendItem = @object as ILegendItem;
     if (m_pOldLegendItem != null)
     {
         m_pLegendItem = (m_pOldLegendItem as IClone).Clone() as ILegendItem;
     }
 }
예제 #27
0
 /// <summary>
 /// Inserts the specified item into this collection if it is a layer.
 /// </summary>
 /// <param name="index">Index where the item should be added.</param>
 /// <param name="item">Item that should be added.</param>
 public void Insert(int index, ILegendItem item)
 {
     if (item is not ILayer layer)
     {
         return;
     }
     base.Insert(index, layer);
 }
예제 #28
0
        /// <summary>
        /// Handles the special case of not copying the parent during an on copy properties operation.
        /// </summary>
        /// <param name="source">The source to copy the properties from.</param>
        protected override void OnCopyProperties(object source)
        {
            base.OnCopyProperties(source);
            ILegendItem   parent = GetParentItem();
            IFeatureLayer p      = parent as IFeatureLayer;

            p?.ApplyScheme(this);
        }
예제 #29
0
 /// <summary>
 /// Searches through the LegendItems recursively, looking for the 0 index
 /// member of the deepest part of the tree.
 /// </summary>
 /// <param name="self"></param>
 /// <returns></returns>
 public static ILegendItem BottomMember(this ILegendItem self)
 {
     if (self.LegendItems != null && self.LegendItems.Count() > 0)
     {
         return(BottomMember(self.LegendItems.First()));
     }
     return(self);
 }
예제 #30
0
 public FrmLegendStyle(ILegendItem legenditem, ILegend legend, int index)
 {
     InitializeComponent();
     this.EnableGlass = false;
     pLegendItem      = legenditem;
     pLegend          = legend;
     lineindex        = index;
 }
예제 #31
0
        private void TabColorDialogChangesApplied(object sender, EventArgs e)
        {
            _editCategory.LowColor  = _tabColorDialog.StartColor;
            _editCategory.HighColor = _tabColorDialog.EndColor;
            ILegendItem  test = _editCategory.GetParentItem();
            IRasterLayer rl   = test as IRasterLayer;

            rl?.WriteBitmap();
        }
예제 #32
0
        private void WriteUniversalGeometryRenderer(UniversalGeometryRenderer renderer)
        {
            for (int i = 0; i < renderer.LegendItemCount; i++)
            {
                ILegendItem lItem = renderer.LegendItem(i);

                WriteSymbol(lItem as ISymbol);
            }
        }
예제 #33
0
 /// <summary>
 /// This method starts with this legend item and tests to see if it can contain
 /// the specified target.  As it moves up the
 /// </summary>
 /// <param name="startItem">This legend item</param>
 /// <param name="dropItem">The target legend item to test</param>
 /// <returns>An ILegendItem that is one of the parent items of this item, but that can receive the target.</returns>
 public static ILegendItem GetValidContainerFor(this ILegendItem startItem, ILegendItem dropItem)
 {
     if (startItem == null) return null;
     if (dropItem == null) return null;
     if (startItem.CanReceiveItem(dropItem)) return startItem;
     ILegendItem item = startItem;
     while ((item = item.GetParentItem()) != null)
     {
         if (item.CanReceiveItem(dropItem))
         {
             return item;
         }
     }
     return null;
 }
예제 #34
0
 private static ILegendItem GetInsertTarget(ILegendItem startItem, ILegendItem dropItem)
 {
     if (startItem == null) return null;
     if (dropItem == null) return null;
     if (startItem.CanReceiveItem(dropItem)) return startItem;
     ILegendItem item = startItem;
     while (item.GetParentItem() != null)
     {
         if (item.GetParentItem().CanReceiveItem(dropItem))
         {
             return item;
         }
         item = item.GetParentItem();
     }
     return null;
 }
예제 #35
0
 /// <summary>
 /// Given the starting position, which might not be able to contain the drop item,
 /// determine the index in the valid container where this item should end up.
 /// </summary>
 /// <param name="startItem">The legend item that may not be a sibling or be able to contain the drop item</param>
 /// <param name="dropItem">The item being added to the legend</param>
 /// <returns>The integer index of the valid container where insertion should occur when dropping onto this item.</returns>
 public static int InsertIndex(this ILegendItem startItem, ILegendItem dropItem)
 {
     ILegendItem container = GetValidContainerFor(startItem, dropItem);
     if (container == null) return -1;
     ILegendItem insertTarget = GetInsertTarget(startItem, dropItem);
     if (insertTarget == null) return container.LegendItems.Count();
     if (insertTarget == container)
     {
         return container.LegendItems.Count();
     }
     List<ILegendItem> items = container.LegendItems.ToList();
     if (items.Contains(insertTarget))
     {
         return items.IndexOf(insertTarget);
     }
     return container.LegendItems.Count();
 }
예제 #36
0
 /// <summary>
 /// This can be used by derivative classes to create a new, empty instance of a ColorRampBuilder
 /// where Minimum and Maximum are overridden.
 /// </summary>
 protected ColorRampBuilder(ILegendItem parent)
 {
     _parent = parent;
     _colorBreaks = new ColorBreakList(parent);
     Configure();
 }
예제 #37
0
 /// <summary>
 /// Sorts out what the parent item is and removes this legend item from that parents collection.
 /// </summary>
 /// <param name="item"></param>
 /// <param name="parent"></param>
 private void RemoveItem(ILegendItem item, ILegendItem parent)
 {
     IGroup grp = parent as IGroup;
     if(grp != null)
     {
         ILayer lyr = item as ILayer;
         if(lyr != null) grp.Remove(lyr);
     }
 }
예제 #38
0
 // Given a legend item, it searches the list of LegendBoxes until it finds it.
 private LegendBox BoxFromItem(ILegendItem item)
 {
     foreach (LegendBox box in _legendBoxes)
     {
         if (box.Item == item) return box;
     }
     return null;
 }
예제 #39
0
 private Size SizeItem(int offset, ILegendItem item, Graphics g)
 {
     if (item == null) return new Size(0, 0);
     int width = offset + 30 + (int)g.MeasureString(item.LegendText, Font).Width;
     int height = ItemHeight;
     if(item.LegendSymbolMode == SymbolModes.Symbol)
     {
         Size s = item.GetLegendSymbolSize();
         if (s.Height > ItemHeight) height = s.Height;
     }
    
     if (item.IsExpanded)
     {
         if (item.LegendItems != null)
         {
             foreach (ILegendItem child in item.LegendItems)
             {
                 Size cs = SizeItem(offset + _indentation, child, g);
                 height += cs.Height;
                 if (cs.Width > width) width = cs.Width;
             }
         }
     }
     return new Size(width, height);
 }
예제 #40
0
 /// <summary>
 /// Allows for the set behavior for the parent item to be overridden in child classes
 /// </summary>
 /// <param name="value"></param>
 protected virtual void OnSetParentItem(ILegendItem value)
 {
     _parentLegendItem = value;
 }
예제 #41
0
 /// <summary>
 /// As a group, MapFrames can either receive layers or groups, but not
 /// sub-members like symbolizers or icons.
 /// </summary>
 /// <param name="item">The ILegendItem to receive</param>
 /// <returns>Boolean that is true if the item can be received</returns>
 public override bool CanReceiveItem(ILegendItem item)
 {
     ILayer lyr = item as ILayer;
     if (lyr != null)
     {
         if(lyr != this) return true; // don't allow groups to add to themselves
     }
     return false;
 }
예제 #42
0
 /// <summary>
 /// Occurs when setting the parent item and updates the parent item pointers
 /// </summary>
 /// <param name="value"></param>
 protected override void OnSetParentItem(ILegendItem value)
 {
     base.OnSetParentItem(value);
     _categories.UpdateItemParentPointers();
 }
예제 #43
0
 /// <summary>
 /// Returns a boolean indicating whether or not this item can have other items dropped on it.
 /// By default this is false.  This can be overridden for more customized behaviors.
 /// </summary>
 /// <param name="item">The item to test for dropping.</param>
 /// <returns></returns>
 public virtual bool CanReceiveItem(ILegendItem item)
 {
     if (LegendType == LegendType.Scheme)
     {
         if (item.LegendType == LegendType.Symbol) return true;
         return false;
     }
     if (LegendType == LegendType.Group)
     {
         if (item.LegendType == LegendType.Symbol) return false;
         if (item.LegendType == LegendType.Scheme) return false;
         return true;
     }
     if (LegendType == LegendType.Layer)
     {
         if (item.LegendType == LegendType.Symbol) return true;
         if (item.LegendType == LegendType.Scheme) return true;
         return false;
     }
     if (LegendType == LegendType.Symbol)
     {
         return false;
     }
     return false;
 }
예제 #44
0
        private void DrawLegendItem(Graphics g, ILegendItem item, SizeF itemSize, ref int col, ref int row, ref int maxCol, ref int maxRow)
        {
            if (row >= maxRow)
            {
                row = 0;
                col++;
                if (col > maxCol)
                    return;
            }

            g.TranslateTransform(LocationF.X + (col * itemSize.Width), LocationF.Y + (row * itemSize.Height));
            item.PrintLegendItem(g, _font, _color, itemSize);
            g.TranslateTransform(-(LocationF.X + (col * itemSize.Width)), -(LocationF.Y + (row * itemSize.Height)));
            row++;
        }
예제 #45
0
 // Given a legend item, it searches the list of LegendBoxes until it finds it.
 private LegendBox BoxFromItem(ILegendItem item)
 {
     return _legendBoxes.FirstOrDefault(box => box.Item == item);
 }
예제 #46
0
 /// <summary>
 /// Creates a new instance of ColorRampBuilder
 /// </summary>
 /// <param name="minimum">The minimum value</param>
 /// <param name="maximum">The maximum value</param>
 /// <param name="parent">The legend item to use as a parent</param>
 public ColorRampBuilder(double minimum, double maximum, ILegendItem parent)
 {
     _parent = parent;
     _colorBreaks = new ColorBreakList(parent);
     _minimum = minimum;
     _maximum = maximum;
     Configure();
 }
 protected virtual bool CheckExpanded(ILegendItem item)
 {
     return item.SubItems.Count > 0;
 }
예제 #48
0
 /// <summary>
 /// Sets teh parent legend item for this item
 /// </summary>
 /// <param name="value"></param>
 public void SetParentItem(ILegendItem value)
 {
     _parentItem = value;
 }
예제 #49
0
        private void UpdateActions(ILegendItem mapLayer)
        {
            var manager = SharedEventHandlers;
            
            var layer = mapLayer as Layer;
            if (layer != null)
            {
                layer.LayerActions = manager == null ? null : manager.LayerActions;
            }

            var cc = mapLayer as ColorCategory;
            if (cc != null)
            {
                cc.ColorCategoryActions = manager == null ? null : manager.ColorCategoryActions;
            }

            var fl = mapLayer as FeatureLayer;
            if (fl != null)
            {
                fl.FeatureLayerActions = manager == null? null : manager.FeatureLayerActions;
            }

            var il = mapLayer as ImageLayer;
            if (il != null)
            {
                il.ImageLayerActions = manager == null ? null : manager.ImageLayerActions;
            }

            var rl = mapLayer as RasterLayer;
            if (rl != null)
            {
                rl.RasterLayerActions = manager == null ? null : manager.RasterLayerActions;
            }
        }
예제 #50
0
 void _Legend_OnLabelHilighted(ILegendItem graph)
 {
     _HighlightedGraph = null;
     if (graph != null)
     foreach (DisplayedGraph gr in _Graphs)
         if (gr.Hint == graph.Hint)
             _HighlightedGraph = gr;
     Invalidate();
 }
예제 #51
0
 /// <summary>
 /// Specifies tht 
 /// </summary>
 /// <param name="item"></param>
 /// <returns></returns>
 public override bool CanReceiveItem(ILegendItem item)
 {
     base.CanReceiveItem(item);
     return false;
 }
예제 #52
0
 void _Legend_OnLabelGrayed(ILegendItem graph, bool grayed)
 {
     foreach(DisplayedGraph gr in _Graphs)
         if (gr.Hint == graph.Hint)
             gr.Hidden = grayed;
 }
예제 #53
0
 /// <summary>
 /// Tests the specified legend item.  If the item is another layer or a group or a map-frame, then this
 /// will return false.  Furthermore, if the parent of the item is not also this object, then it will
 /// also return false.  The idea is that layers can have sub-nodes move around, but not transport from
 /// place to place.
 /// </summary>
 /// <param name="item">the legend item to test</param>
 /// <returns>Boolean that if true means that it is ok to insert the specified item into this layer.</returns>
 public override bool CanReceiveItem(ILegendItem item)
 {
     if (item.GetParentItem() != this) return false;
     var lyr = item as ILayer;
     if (lyr != null) return false;
     return true;
 }
예제 #54
0
 /// <summary>
 /// Ensures that the parentage gets set properly in the event that
 /// this scheme is not appearing in the legend.
 /// </summary>
 /// <param name="value"></param>
 protected override void OnSetParentItem(ILegendItem value)
 {
     base.OnSetParentItem(value);
     if (_appearsInLegend) return;
     IEnumerable<IFeatureCategory> categories = GetCategories();
     foreach (IFeatureCategory category in categories)
     {
         category.SetParentItem(value);
     }
 }
예제 #55
0
 /// <summary>
 /// Sets the parent legend item for this category.
 /// </summary>
 /// <param name="value"></param>
 public void SetParentItem(ILegendItem value)
 {
     OnSetParentItem(value);
 }
        /// <summary>
        /// Instantiates new LegendItem object and binds it to the original chart items.
        /// </summary>
        /// <param name="originalItem"></param>
        public LegendItem(ILegendItem originalItem)
        {
            OriginalItem = originalItem;

            SetBindings();
        }
예제 #57
0
 /// <summary>
 /// Tests the specified legend item.  If the item is another layer or a group or a map-frame, then this
 /// will return false.  Furthermore, if the parent of the item is not also this object, then it will
 /// also return false.  The idea is that layers can have sub-nodes move around, but not transport from
 /// place to place.
 /// </summary>
 /// <param name="item">the legend item to test</param>
 /// <returns>Boolean that if true means that it is ok to insert the specified item into this layer.</returns>
 public override bool CanReceiveItem(ILegendItem item)
 {
     if (item.GetParentItem() != this) return false;
     ILayer lyr = item as ILayer;
     if (lyr != null) return false;
     IFrame mf = item as IFrame;
     if (mf != null) return false;
     IGroup gr = item as IGroup;
     if (gr != null) return false;
     return true;
 }
예제 #58
0
 /// <summary>
 /// Tests the specified legend item to determine whether or not
 /// it can be dropped into the current item.
 /// </summary>
 /// <param name="item">Any object that implements ILegendItem</param>
 /// <returns>Boolean that is true if a drag-drop of the specified item will be allowed.</returns>
 public bool CanReceiveItem(ILegendItem item)
 {
     return false;
 }