예제 #1
0
        private void aliasAndColorMappingListBox_DrawItem(object sender, DrawItemEventArgs e)
        {
            e.DrawBackground();
            LabelToAliasAndColorListItem item = (LabelToAliasAndColorListItem)aliasAndColorMappingListBox.Items[e.Index];

            e.Graphics.DrawString(item.ListBoxView,
                                  aliasAndColorMappingListBox.Font,
                                  new SolidBrush(aliasAndColorMappingListBox.ForeColor),
                                  new PointF((float)e.Bounds.X, (float)e.Bounds.Y));
            Rectangle colorSampleBox = new Rectangle(e.Bounds.Location, e.Bounds.Size);

            colorSampleBox.X = e.Bounds.Right - e.Bounds.Height * 2;
            colorSampleBox.Location.Offset(-5, 0);
            e.Graphics.FillRectangle(new SolidBrush(ownerGraphForm.ZedGraphControl.GraphPane.Chart.Fill.Color), colorSampleBox);
            int middle = colorSampleBox.Y + colorSampleBox.Height / 2;

            e.Graphics.DrawLine(new Pen(item.mapPair.Value.second, 2), colorSampleBox.Left, middle, colorSampleBox.Right, middle);
            e.DrawFocusRectangle();
        }
예제 #2
0
        private void editAliasAndColorMappingButton_Click(object sender, EventArgs e)
        {
            LabelToAliasAndColorListItem    item   = (LabelToAliasAndColorListItem)aliasAndColorMappingListBox.SelectedItem;
            AnnotationSettingsAddEditDialog dialog = new AnnotationSettingsAddEditDialog(ownerGraphForm.ZedGraphControl.GraphPane.Chart.Fill.Color, item.mapPair.Key, item.mapPair.Value.first, item.mapPair.Value.second);

            if (dialog.ShowDialog() == DialogResult.OK)
            {
                if (item.mapPair.Key == dialog.label)
                {
                    item.mapPair.Value.first  = dialog.alias;
                    item.mapPair.Value.second = dialog.color;
                }
                else
                {
                    aliasAndColorMappingListBox.Items.RemoveAt(aliasAndColorMappingListBox.SelectedIndex);
                    aliasAndColorMappingListBox.Items.Add(
                        new LabelToAliasAndColorListItem(
                            new Map <string, Pair <string, Color> > .MapPair(dialog.label,
                                                                             new Pair <string, Color>(dialog.alias, dialog.color))));
                }
                aliasAndColorMappingListBox.Refresh();
            }
        }