Exemplo n.º 1
0
        public PlotIcon(Color color, PlotIconShape shape)
        {
            this.color = color;
            this.shape = shape;

            // All icon shape coordinates target points on a 4x4 grid
            // This way, icon shapes can be mixed & matched and still look proper
            halfSize       = size / 2f;
            quartSize      = size / 4f;
            threeQuartSize = quartSize * 3;

            pen                = new Pen(Color.White, lineWidth);
            brush              = new SolidBrush(Color.White);
            bitmap             = new Bitmap(size, size);
            icon               = Graphics.FromImage(bitmap);
            icon.SmoothingMode = SmoothingMode.AntiAlias;
        }
Exemplo n.º 2
0
        // Gets a PlotIcon for a given legend group. Returns cached version if available
        public static PlotIcon GetIconForGroup(int group)
        {
            int colorTotal = SettingsPlotIcon.paletteColor.Count;
            int shapeTotal = SettingsPlotIcon.paletteShape.Count;

            if (SettingsPlot.IsTopographic())
            {
                colorTotal = 1;                 // Force a unique shape per group in topography mode, as color becomes indistinguishable
            }

            // Reduce the group number to find repeating icons
            // For example, 3 shapes and 5 colors makes 15 icons. Group 15 is therefore the same as group 0.
            group %= colorTotal * shapeTotal;

            // Return this ploticon if it has already been generated.
            if (plotIconCache.ContainsKey(group))
            {
                return(plotIconCache[group]);
            }

            // Identify which item from each palette should be used.
            // First iterate through every color, then every palette, and repeat.
            int colorIndex = group % colorTotal;
            int shapeIndex = (group / colorTotal) % shapeTotal;

            // Generate the PlotIcon
            Color         color    = SettingsPlot.IsTopographic() ? SettingsPlotTopograph.legendColor : SettingsPlotIcon.paletteColor[colorIndex];
            PlotIconShape shape    = SettingsPlotIcon.paletteShape[shapeIndex];
            PlotIcon      plotIcon = new PlotIcon(color, shape);

            // Register the icon in the cache and return it - Don't cache topography icons as they override the color
            if (!SettingsPlot.IsTopographic())
            {
                plotIconCache.Add(group, plotIcon);
            }

            return(plotIcon);
        }