コード例 #1
0
        /// <summary>
        /// Moves the selected line to the bottom of the pattern
        /// </summary>
        private void btnMoveDown_Click(object sender, EventArgs e)
        {
            if (dgv.SelectedRows.Count > 0)
            {
                int index = dgv.SelectedRows[0].Index;
                if (index < dgv.Rows.Count - 1)
                {
                    MapWinGIS.LineSegment segm      = _options.LinePattern.get_Line(index);
                    MapWinGIS.LineSegment segmAfter = _options.LinePattern.get_Line(index + 1);
                    _options.LinePattern.set_Line(index + 1, segm);
                    _options.LinePattern.set_Line(index, segmAfter);

                    Options2Grid();
                    DrawPreview();

                    _noEvents = true;
                    dgv.ClearSelection();
                    _noEvents = false;
                    dgv.Rows[index + 1].Selected = true;

                    btnApply.Enabled = true;
                    RefreshControlState();
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// Drawing of images in the style column
        /// </summary>
        private void dgv_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
        {
            if (_options.LinePattern == null)
            {
                return;
            }

            if (e.RowIndex >= 0 && e.RowIndex < _options.LinePattern.Count)
            {
                if (e.ColumnIndex == CMN_PICTURE)
                {
                    System.Drawing.Image img = e.Value as System.Drawing.Image;
                    if (img != null)
                    {
                        MapWinGIS.LineSegment line = _options.LinePattern.get_Line(e.RowIndex);
                        if (line != null)
                        {
                            Graphics g = Graphics.FromImage(img);
                            g.Clear(Color.White);
                            g.InterpolationMode = InterpolationMode.HighQualityBicubic;
                            g.SmoothingMode     = SmoothingMode.HighQuality;

                            IntPtr ptr       = g.GetHdc();
                            uint   backColor = Colors.ColorToUInteger(this.BackColor);
                            line.Draw(ptr.ToInt32(), 0, 0, img.Width, img.Height, backColor);
                            g.ReleaseHdc();
                            g.Dispose();

                            ((Bitmap)img).MakeTransparent(this.BackColor);
                        }
                    }
                }
            }
        }
コード例 #3
0
        /// <summary>
        /// Sets the values entered by user to the class
        /// </summary>
        private void GUI2Options(object sender, EventArgs e)
        {
            if (_noEvents)
            {
                return;
            }

            // vertices
            _options.VerticesVisible     = chkVerticesVisible.Checked;
            _options.VerticesFillVisible = chkVerticesFillVisible.Checked;
            _options.VerticesSize        = (int)udVerticesSize.Value;
            _options.VerticesColor       = Colors.ColorToUInteger(clpVerticesColor.Color);
            _options.VerticesType        = (tkVertexType)cboVerticesType.SelectedIndex;

            // transparency
            _options.LineTransparency = transparencyControl1.Value;
            if (_options.LinePattern != null)
            {
                _options.LinePattern.Transparency = (byte)_options.LineTransparency;
            }

            if (dgv.SelectedRows.Count > 0)
            {
                int index = dgv.SelectedRows[0].Index;
                MapWinGIS.LineSegment line = _options.LinePattern.get_Line(index);
                if (line != null)
                {
                    line.LineType = cboLineType.SelectedIndex == 0 ? tkLineType.lltSimple : tkLineType.lltMarker;

                    // showing the options
                    if (cboLineType.SelectedIndex == 0)
                    {
                        line.LineStyle = (tkDashStyle)icbLineType.SelectedIndex;
                        line.LineWidth = icbLineWidth.SelectedIndex + 1;
                        line.Color     = Colors.ColorToUInteger(clpOutline.Color);
                    }
                    else
                    {
                        line.Marker             = (tkDefaultPointSymbol)pointSymbolControl1.SelectedIndex;
                        line.MarkerInterval     = (float)udMarkerInterval.Value;
                        line.MarkerSize         = (float)udMarkerSize.Value;
                        line.Color              = Colors.ColorToUInteger(clpMarkerFill.Color);
                        line.MarkerOutlineColor = Colors.ColorToUInteger(clpMarkerOutline.Color);
                        line.MarkerOrientation  = (tkLineLabelOrientation)cboOrientation.SelectedIndex;
                        line.MarkerOffset       = (float)udMarkerOffset.Value;

                        if (pointSymbolControl1.ForeColor != clpMarkerFill.Color)
                        {
                            pointSymbolControl1.ForeColor = clpMarkerFill.Color;
                        }
                    }
                    dgv.Invalidate();
                }
            }

            btnApply.Enabled = true;
            DrawPreview();
        }
コード例 #4
0
        // Toggle between simaple and marker line
        void cboLineType_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (_noEvents)
            {
                return;
            }

            if (dgv.SelectedRows.Count > 0)
            {
                int index = dgv.SelectedRows[0].Index;
                MapWinGIS.LineSegment line = _options.LinePattern.get_Line(index);
                line.LineType = (tkLineType)cboLineType.SelectedIndex;
                dgv[CMN_TYPE, index].Value = line.LineType == tkLineType.lltSimple ? "line" : "marker";
                Options2GUI();
                dgv.Invalidate();
                btnApply.Enabled = true;
            }
        }
コード例 #5
0
        /// <summary>
        /// Loads the values of the class instance to the controls
        /// </summary>
        private void Options2GUI()
        {
            _noEvents = true;

            // vertices
            chkVerticesVisible.Checked     = _options.VerticesVisible;
            chkVerticesFillVisible.Checked = _options.VerticesFillVisible;
            udVerticesSize.SetValue(_options.VerticesSize);
            clpVerticesColor.Color        = Colors.UintToColor(_options.VerticesColor);
            cboVerticesType.SelectedIndex = (int)_options.VerticesType;

            // transparency
            if (_options.LinePattern != null)
            {
                transparencyControl1.Value = _options.LinePattern.Transparency;
            }

            if (dgv.SelectedRows.Count > 0)
            {
                int index = dgv.SelectedRows[0].Index;
                MapWinGIS.LineSegment line = _options.LinePattern.get_Line(index);
                if (line != null)
                {
                    cboLineType.SelectedIndex = (int)line.LineType;

                    groupLine.Visible   = false;
                    groupMarker.Visible = false;
                    if (cboLineType.SelectedIndex == 0)
                    {
                        groupLine.Visible = true;
                    }
                    else
                    {
                        groupMarker.Visible = true;
                    }

                    // showing the options
                    if (line.LineType == tkLineType.lltSimple)
                    {
                        _noEvents = true;
                        icbLineType.SelectedIndex  = (int)line.LineStyle;
                        icbLineWidth.SelectedIndex = (int)line.LineWidth - 1;
                        clpOutline.Color           = Colors.UintToColor(line.Color);
                        _noEvents = false;
                    }
                    else
                    {
                        _noEvents = true;
                        pointSymbolControl1.SelectedIndex = (int)line.Marker;
                        udMarkerInterval.SetValue(line.MarkerInterval);
                        udMarkerSize.SetValue(line.MarkerSize);
                        clpMarkerFill.Color    = Colors.UintToColor(line.Color);
                        clpMarkerOutline.Color = Colors.UintToColor(line.MarkerOutlineColor);
                        udMarkerOffset.SetValue(line.MarkerOffset);
                        cboOrientation.SelectedIndex = (int)line.MarkerOrientation;
                        if (pointSymbolControl1.ForeColor != clpMarkerFill.Color)
                        {
                            pointSymbolControl1.ForeColor = clpMarkerFill.Color;
                        }

                        _noEvents = false;
                    }
                    DrawPreview();
                }
            }
            _noEvents = false;
        }