コード例 #1
0
        /// <summary>
        /// Takes place when the control is initialized or invalidated.
        /// </summary>
        /// <param name="e">The event args.</param>
        protected override void OnInitialize(PaintEventArgs e)
        {
            if (_cellSize.Width == 0)
            {
                _cellSize.Width  = 50;
                _cellSize.Height = 50;
            }

            if (TextFont == null)
            {
                TextFont = new Font("Arial", 9);
            }

            DocumentRectangle = new Rectangle(0, 0, (NumColumns * _cellSize.Width) + 1, (NumRows * _cellSize.Height) + 1);

            if (DynamicColumns)
            {
                int newColumns = (Width - 20) / _cellSize.Width;
                if (newColumns != NumColumns)
                {
                    e.Graphics.FillRectangle(Brushes.White, e.ClipRectangle);
                    NumColumns = newColumns;
                    Invalidate();
                    return;
                }
            }

            if (NumColumns == 0)
            {
                NumColumns = 1;
            }

            for (int i = 0; i < SymbolizerList.Count; i++)
            {
                int row = i / NumColumns;
                int col = i % NumColumns;

                CustomSymbolizer sym           = SymbolizerList[i];
                Point            pointLocation = new(col * _cellSize.Width, row *_cellSize.Height);
                Rectangle        rect          = new(pointLocation, _cellSize);
                DrawSymbolizer(e.Graphics, rect, sym);
            }

            Brush backBrush = new SolidBrush(SelectionBackColor);
            Brush foreBrush = new SolidBrush(SelectionForeColor);

            if (_isSelected)
            {
                Rectangle sRect = GetSelectedRectangle();
                e.Graphics.FillRectangle(backBrush, sRect);
                if (SelectedSymbolizer != null)
                {
                    DrawSymbolizer(e.Graphics, sRect, SelectedSymbolizer);
                    OnSymbolSelected();
                }
            }

            backBrush.Dispose();
            foreBrush.Dispose();
        }
コード例 #2
0
        /// <summary>
        /// Creates the new custom symbolizer with the specified name and category
        /// </summary>
        /// <returns>the custom symbolizer</returns>
        private CustomSymbolizer CreateCustomSymbolizer()
        {
            CustomSymbolizer custSym = null;

            if (_symbolizer is PointSymbolizer)
            {
                custSym = new CustomPointSymbolizer();
            }
            else if (_symbolizer is LineSymbolizer)
            {
                custSym = new CustomLineSymbolizer();
            }
            else if (_symbolizer is PolygonSymbolizer)
            {
                custSym = new CustomPolygonSymbolizer();
            }
            if (custSym != null)
            {
                custSym.Symbolizer = _symbolizer;
                custSym.Name       = _txtSymbolName.Text;
                custSym.Category   = _cmbSymbolCategory.Text;
                return(custSym);
            }
            return(null);
        }
コード例 #3
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            //creates the new custom symbolizer
            CustomSymbolizer newCustSym = CreateCustomSymbolizer();

            if (newCustSym != null)
            {
                _customSymbolizer = newCustSym;
            }

            Close();
        }
コード例 #4
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            //creates the new custom symbolizer
            CustomSymbolizer newCustSym = CreateCustomSymbolizer();
            if (newCustSym != null)
            {
                _customSymbolizer = newCustSym;
            }

            Close();
        }