コード例 #1
0
        private void btnPal_Click(object sender, EventArgs e)
        {
            SwatchPick dlg = new SwatchPick();

            dlg.StartPosition = FormStartPosition.CenterParent;
            dlg.SwatchIndex   = _paletteIndex;
            DialogResult res = dlg.ShowDialog(this);

            if (res == DialogResult.Cancel)
            {
                return;
            }
            _paletteIndex  = dlg.SwatchIndex;
            drawer.Palette = _paletteIndex;
            DoAncTree(); // TODO the 'control' should redraw itself
        }
コード例 #2
0
ファイル: DrawCirc.cs プロジェクト: zhifu10001/YAGP
        private void DrawAncCirc(Graphics gr)
        {
            Color[] genColors = SwatchPick.Swatch(Palette);

            // 16-31
            //  8-15
            //  4-7
            //  2-3
            //  1

            for (int gen = 4; gen >= 0; gen--)
            {
                int dataOffset   = 1 << gen;
                int segmentCount = 1 << gen;

                int       left = OUTER_MARGIN + (4 - gen) * RADIUS_STEP;
                int       top  = left;
                int       wide = (gen + 1) * RADIUS_STEP * 2;
                int       high = wide;
                Rectangle rect = new Rectangle(left, top, wide, high);

                float fDegAngle = 360.0f / segmentCount;
                float fDegStart = 0.0f;
                using (Pen pen = new Pen(Color.Black))
                    using (Brush brush = new SolidBrush(genColors[gen]))
                        if (gen == 0)
                        {
                            gr.FillEllipse(brush, rect);
                            gr.DrawEllipse(pen, rect);
                            drawText(gr, 1, 0, 0, RADIUS_STEP);
                        }
                        else
                        {
                            for (int i = 0; i < segmentCount; i++)
                            {
                                if (AncData[dataOffset + i] != null)
                                {
                                    gr.FillPie(brush, rect, fDegStart, fDegAngle);
                                    gr.DrawPie(pen, rect, fDegStart, fDegAngle);
                                    drawText(gr, dataOffset + i, fDegStart, fDegAngle, gen * RADIUS_STEP);
                                }
                                fDegStart += fDegAngle;
                            }
                        }
            }
        }