CrossStitchCreator.PatternEditor.UpdateColourMap C# (CSharp) Method

UpdateColourMap() public method

Associates each of the colours in the pattern list with the number of times the colour appears. Will not set if number of entries exceeds MainForm.MAX_COLOURS
public UpdateColourMap ( ) : void
return void
        public void UpdateColourMap()
        {
            patternList.Items.Clear();
            if (mParent.ColourMap.Count > MainForm.MAX_COLOURS)
            {
                MessageBox.Show("Too many colours!");
                return;
            }
            patternCreator = new PatternCreator();
            List<IColourInfo> temp = mParent.ColourMap.ToList();
            // loop through ColourMap, adding max frequency first.
            while (temp.Count > 0)
            {
                int max = int.MinValue;
                IColourInfo maxC = temp[0];
                foreach (IColourInfo col in temp)
                {
                    if (col.Frequency > max)
                    {
                        max = col.Frequency;
                        maxC = col;
                    }
                }
                AddPattern(maxC);
                temp.Remove(maxC);
            }
            patternList.Sort();
        }

Usage Example

Ejemplo n.º 1
0
 public void ShowPatternEditor()
 {
     if (mRecolouredImage != null)
     {
         this.Cursor = Cursors.WaitCursor;
         ImagingTool tool = new ImagingTool(mRecolouredImage);
         patternEditor.UpdateColourMap();
         this.Cursor = Cursors.Default;
         patternEditor.Show();
         patternEditor.Focus();
     }
 }