private void _btnLegend_Click(object sender, EventArgs e)
        {
            LayoutLegend         lsb         = _layoutControl.CreateLegendElement() as LayoutLegend;
            List <LayoutElement> mapElements = _layoutControl.LayoutElements.FindAll(delegate(LayoutElement o) { return(o is LayoutMap); });

            if (mapElements.Count > 0)
            {
                lsb.Map = mapElements[0] as LayoutMap;
            }
            lsb.LayoutControl = _layoutControl;
            _layoutControl.AddElementWithMouse(lsb);
        }
Example #2
0
        /// <summary>
        /// Edits a value based on some user input which is collected from a character control.
        /// </summary>
        /// <param name="context"></param>
        /// <param name="provider"></param>
        /// <param name="value"></param>
        /// <returns></returns>
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            _dialogProvider = provider.GetService(typeof(IWindowsFormsEditorService)) as IWindowsFormsEditorService;
            List <int>   layerList = new List <int>();
            LayoutLegend legend    = context.Instance as LayoutLegend;
            LayoutMap    map       = null;

            if (legend != null)
            {
                map = legend.Map;
            }
            if (map == null)
            {
                return(layerList);
            }

            CheckedListBox lb = new CheckedListBox();

            List <int> originalList = value as List <int>;

            if (originalList != null)
            {
                for (int i = map.MapControl.Layers.Count - 1; i >= 0; i--)
                {
                    lb.Items.Add(map.MapControl.Layers[i].LegendText, originalList.Contains(i));
                }
            }

            if (_dialogProvider != null)
            {
                _dialogProvider.DropDownControl(lb);
            }

            for (int i = 0; i < lb.Items.Count; i++)
            {
                if (lb.GetItemChecked(i))
                {
                    layerList.Add(lb.Items.Count - 1 - i);
                }
            }

            return(layerList);
        }
Example #3
0
        /// <summary>
        /// Edits a value based on some user input which is collected from a character control.
        /// </summary>
        /// <param name="context">Contains the scalebar and legend.</param>
        /// <param name="provider">The service provider.</param>
        /// <param name="value">The selected item.</param>
        /// <returns>Returns the selected item.</returns>
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            _dialogProvider = provider?.GetService(typeof(IWindowsFormsEditorService)) as IWindowsFormsEditorService;
            if (context == null)
            {
                return(null);
            }

            LayoutScaleBar scaleBar = context.Instance as LayoutScaleBar;
            LayoutLegend   legend   = context.Instance as LayoutLegend;
            LayoutControl  lc       = null;

            if (scaleBar?.LayoutControl != null)
            {
                lc = scaleBar.LayoutControl;
            }
            else if (legend?.LayoutControl != null)
            {
                lc = legend.LayoutControl;
            }

            ListBox lb = new();

            if (lc == null)
            {
                return(null);
            }

            foreach (LayoutElement le in lc.LayoutElements.FindAll(o => o is LayoutMap))
            {
                lb.Items.Add(le);
            }

            lb.SelectedItem          = value;
            lb.SelectedValueChanged += LbSelectedValueChanged;
            _dialogProvider?.DropDownControl(lb);
            return(lb.SelectedItem);
        }