Fix select naming violations identified by VS 2017

master
Nathan Crawford 2017-09-13 01:05:29 -04:00
rodzic 36e1668305
commit c16f3e7fb0
6 zmienionych plików z 88 dodań i 87 usunięć

1
.gitignore vendored
Wyświetl plik

@ -111,3 +111,4 @@ UpgradeLog*.XML
*.wixpdb
*.wixobj
Thumbs.db
/.vs

Wyświetl plik

@ -61,7 +61,7 @@ namespace PesFile
// Returns an Int16 representation of the 12 bit signed int contained in
// high and low bytes
private Int16 get12Bit2sComplement(byte high, byte low)
private Int16 Get12Bit2sComplement(byte high, byte low)
{
Int32 retval;
@ -88,7 +88,7 @@ namespace PesFile
// Returns a signed byte representation of the 7 bit signed int contained
// in b.
private SByte get7Bit2sComplement(byte b)
private SByte Get7Bit2sComplement(byte b)
{
SByte retval;
@ -203,7 +203,7 @@ namespace PesFile
colorNum++;
colorIndex = colorList[colorNum];
curBlock.colorIndex = colorIndex;
curBlock.color = getColorFromIndex(colorIndex);
curBlock.color = GetColorFromIndex(colorIndex);
blocks.Add(curBlock);
}
else if (val1 == 0xfe && val2 == 0xb0)
@ -217,7 +217,7 @@ namespace PesFile
colorNum++;
colorIndex = colorList[colorNum];
curBlock.colorIndex = colorIndex;
curBlock.color = getColorFromIndex(colorIndex);
curBlock.color = GetColorFromIndex(colorIndex);
//read useless(?) byte
// The value of this 'useless' byte seems to start with 2 for the first block and
// alternate between 2 and 1 for every other block after that. The only exception
@ -246,7 +246,7 @@ namespace PesFile
// This is a 12-bit int. Allows for needle movement
// of up to +2047 or -2048.
deltaX = get12Bit2sComplement(val1, val2);
deltaX = Get12Bit2sComplement(val1, val2);
xMoveBits = Stitch.MoveBitSize.TwelveBits;
@ -258,7 +258,7 @@ namespace PesFile
{
// This is a 7-bit int. Allows for needle movement
// of up to +63 or -64.
deltaX = get7Bit2sComplement(val1);
deltaX = Get7Bit2sComplement(val1);
xMoveBits = Stitch.MoveBitSize.SevenBits;
@ -279,7 +279,7 @@ namespace PesFile
// of up to +2047 or -2048.
// Read in the next byte to get the full value
val2 = fileIn.ReadByte();
deltaY = get12Bit2sComplement(val1, val2);
deltaY = Get12Bit2sComplement(val1, val2);
yMoveBits = Stitch.MoveBitSize.TwelveBits;
}
@ -287,7 +287,7 @@ namespace PesFile
{
// This is a 7-bit int. Allows for needle movement
// of up to +63 or -64.
deltaY = get7Bit2sComplement(val1);
deltaY = Get7Bit2sComplement(val1);
yMoveBits = Stitch.MoveBitSize.SevenBits;
// Finished reading data for this stitch, no more
@ -401,18 +401,18 @@ namespace PesFile
}
// Returns the path of the file it saved debug info to
public string saveDebugInfo()
public string SaveDebugInfo()
{
string retval = System.IO.Path.ChangeExtension(_filename, ".txt");
using (System.IO.StreamWriter outfile = new System.IO.StreamWriter(retval))
{
outfile.Write(getDebugInfo());
outfile.Write(GetDebugInfo());
outfile.Close();
}
return retval;
}
public string getDebugInfo()
public string GetDebugInfo()
{
System.IO.StringWriter outfile = new System.IO.StringWriter();
outfile.WriteLine(_filename);
@ -442,7 +442,7 @@ namespace PesFile
outfile.WriteLine("unknown start byte: " + thisBlock.unknownStartByte.ToString("X2"));
foreach (Stitch thisStitch in thisBlock.stitches)
{
string tempLine = thisStitch.a.ToString() + " - " + thisStitch.b.ToString() + ", length " + thisStitch.calcLength().ToString("F02");
string tempLine = thisStitch.a.ToString() + " - " + thisStitch.b.ToString() + ", length " + thisStitch.CalcLength().ToString("F02");
if (thisStitch.extraBits1 != 0x00)
{
tempLine += " (extra bits 1: " + thisStitch.extraBits1.ToString("X2") + ")";
@ -481,17 +481,17 @@ namespace PesFile
return outfile.ToString();
}
public bool getColorWarning()
public bool GetColorWarning()
{
return colorWarning;
}
public bool getFormatWarning()
public bool GetFormatWarning()
{
return formatWarning;
}
private Color getColorFromIndex(int index)
private Color GetColorFromIndex(int index)
{
if(index >= 1 && index <= 64)
{
@ -508,21 +508,21 @@ namespace PesFile
}
}
struct optimizedBlockData
struct OptimizedBlockData
{
public Color color;
public Point [] points;
public optimizedBlockData(Color color, Point [] points)
public OptimizedBlockData(Color color, Point [] points)
{
this.color = color;
this.points = points;
}
}
private List<optimizedBlockData> getOptimizedDrawData(StitchBlock block, float scale, bool filterUglyStitches, double filterUglyStitchesThreshold)
private List<OptimizedBlockData> GetOptimizedDrawData(StitchBlock block, float scale, bool filterUglyStitches, double filterUglyStitchesThreshold)
{
List<optimizedBlockData> retval = new List<optimizedBlockData>();
List<OptimizedBlockData> retval = new List<OptimizedBlockData>();
// Skip this block if it doesn't have stitches, for any reason
if (block.stitches.Length == 0)
@ -537,12 +537,12 @@ namespace PesFile
{
if (filterUglyStitches && // Check for filter ugly stitches option
!formatWarning && // Only filter stitches if we think we understand the format
thisStitch.calcLength() > filterUglyStitchesThreshold) // Check stitch length
thisStitch.CalcLength() > filterUglyStitchesThreshold) // Check stitch length
{
// This stitch is too long, so skip it and start a new block
if (currentPoints.Count != 0)
{
retval.Add(new optimizedBlockData(block.color, currentPoints.ToArray()));
retval.Add(new OptimizedBlockData(block.color, currentPoints.ToArray()));
}
currentPoints = new List<Point>();
continue;
@ -557,7 +557,7 @@ namespace PesFile
// Skip these stitch types, and start a new block
if (currentPoints.Count != 0)
{
retval.Add(new optimizedBlockData(block.color, currentPoints.ToArray()));
retval.Add(new OptimizedBlockData(block.color, currentPoints.ToArray()));
}
currentPoints = new List<Point>();
continue;
@ -573,14 +573,14 @@ namespace PesFile
if(currentPoints.Count != 0)
{
retval.Add(new optimizedBlockData(block.color, currentPoints.ToArray()));
retval.Add(new OptimizedBlockData(block.color, currentPoints.ToArray()));
}
return retval;
}
// When scale is 1.0, each pixel appears to be 0.1mm, or about 254 ppi
public Bitmap designToBitmap(Single threadThickness, bool filterUglyStitches, double filterUglyStitchesThreshold, float scale)
public Bitmap DesignToBitmap(Single threadThickness, bool filterUglyStitches, double filterUglyStitchesThreshold, float scale)
{
// Do some basic input checks
if(scale < 0.0000001f)
@ -635,16 +635,16 @@ namespace PesFile
tempPen.LineJoin = System.Drawing.Drawing2D.LineJoin.Round;
// List to build up draw-optimized data
List<optimizedBlockData> optimizedBlocks = new List<optimizedBlockData>();
List<OptimizedBlockData> optimizedBlocks = new List<OptimizedBlockData>();
// Get optimized data
foreach(StitchBlock thisBlock in blocks)
{
optimizedBlocks.AddRange(getOptimizedDrawData(thisBlock, scale, filterUglyStitches, filterUglyStitchesThreshold));
optimizedBlocks.AddRange(GetOptimizedDrawData(thisBlock, scale, filterUglyStitches, filterUglyStitchesThreshold));
}
// Draw using optimized data
foreach(optimizedBlockData optBlock in optimizedBlocks)
foreach(OptimizedBlockData optBlock in optimizedBlocks)
{
tempPen.Color = optBlock.color;
xGraph.DrawLines(tempPen, optBlock.points);

Wyświetl plik

@ -72,7 +72,7 @@ namespace PesFile
this.stitchType = stitchType;
}
public double calcLength()
public double CalcLength()
{
double diffx = Math.Abs(a.X - b.X);
double diffy = Math.Abs(a.Y - b.Y);

Wyświetl plik

@ -29,7 +29,7 @@ namespace embroideryInfo
{
class Program
{
static void printHelp()
static void PrintHelp()
{
Console.WriteLine("No input file specified.");
Console.WriteLine("To generate design debug text file:");
@ -42,12 +42,12 @@ namespace embroideryInfo
Console.WriteLine("embroideryInfo.exe --image --all");
}
static void generateDebug(string filename)
static void GenerateDebug(string filename)
{
try
{
PesFile.PesFile design = new PesFile.PesFile(filename);
design.saveDebugInfo();
design.SaveDebugInfo();
}
catch (Exception ex)
{
@ -55,12 +55,12 @@ namespace embroideryInfo
}
}
static void generateImage(string filename)
static void GenerateImage(string filename)
{
try
{
PesFile.PesFile design = new PesFile.PesFile(filename);
Bitmap DrawArea = design.designToBitmap(5.0f, false, 0.0f, 1.0f);
Bitmap DrawArea = design.DesignToBitmap(5.0f, false, 0.0f, 1.0f);
Bitmap temp = new Bitmap(DrawArea.Width, DrawArea.Height, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
using (Graphics tempGraph = Graphics.FromImage(temp))
{
@ -82,7 +82,7 @@ namespace embroideryInfo
{
if(args[0] == "--help" || args[0] == "-h" || args[0] == "/?")
{
printHelp();
PrintHelp();
}
else if (args[0] == "--image" && args.Length > 1)
{
@ -90,12 +90,12 @@ namespace embroideryInfo
{
foreach(string file in System.IO.Directory.EnumerateFiles(Environment.CurrentDirectory, "*.pes"))
{
generateImage(file);
GenerateImage(file);
}
}
else
{
generateImage(args[1]);
GenerateImage(args[1]);
}
}
else if (args[0] == "--debug" && args.Length > 1)
@ -104,18 +104,18 @@ namespace embroideryInfo
{
foreach (string file in System.IO.Directory.EnumerateFiles(Environment.CurrentDirectory, "*.pes"))
{
generateDebug(file);
GenerateDebug(file);
}
}
else
{
generateDebug(args[1]);
GenerateDebug(args[1]);
}
}
}
else
{
printHelp();
PrintHelp();
}
}
}

Wyświetl plik

@ -56,7 +56,7 @@ namespace embroideryReader
args = Environment.GetCommandLineArgs();
}
private void loadSettings(bool reload)
private void LoadSettings(bool reload)
{
if (settings.backgroundColorEnabled)
{
@ -80,7 +80,7 @@ namespace embroideryReader
this.Height = settings.windowHeight;
}
}
setDesignScaleSetting(1.0f, settings.AutoScaleDesign, false);
SetDesignScaleSetting(1.0f, settings.AutoScaleDesign, false);
}
private void Form1_Load(object sender, EventArgs e)
@ -89,15 +89,15 @@ namespace embroideryReader
this.Text = APP_TITLE;
// Load and check settings
loadSettings(false);
LoadSettings(false);
// Load translation
loadTranslatedStrings(settings.translation);
LoadTranslatedStrings(settings.translation);
// Load design, if specified
if (args.Length > 1)
{
openFile(args[1]);
OpenFile(args[1]);
}
}
@ -126,7 +126,7 @@ namespace embroideryReader
base.WndProc(ref m);
}
public static bool checkColorFromStrings(string red, string green, string blue)
public static bool CheckColorFromStrings(string red, string green, string blue)
{
byte redByte;
byte greenByte;
@ -157,9 +157,9 @@ namespace embroideryReader
return retval;
}
public static Color makeColorFromStrings(string red, string green, string blue)
public static Color MakeColorFromStrings(string red, string green, string blue)
{
if (checkColorFromStrings(red, green, blue))
if (CheckColorFromStrings(red, green, blue))
{
return Color.FromArgb(Convert.ToByte(red), Convert.ToByte(green), Convert.ToByte(blue));
}
@ -169,7 +169,7 @@ namespace embroideryReader
}
}
private void updateDesignImage()
private void UpdateDesignImage()
{
if(design == null)
{
@ -180,7 +180,7 @@ namespace embroideryReader
// Assume 96 DPI until we can come up with a better way to calculate it
float screenDPI = 96;
Bitmap tempImage = design.designToBitmap((float)settings.threadThickness, (settings.filterStiches), settings.filterStitchesThreshold, (screenDPI / design.NativeDPI));
Bitmap tempImage = design.DesignToBitmap((float)settings.threadThickness, (settings.filterStiches), settings.filterStitchesThreshold, (screenDPI / design.NativeDPI));
// Rotate image
switch (designRotation)
@ -305,7 +305,7 @@ namespace embroideryReader
this.Text = System.IO.Path.GetFileName(loadedFileName) + " (" + (designScale * 100).ToString("0") + "%) - " + APP_TITLE;
}
private void openFile(string filename)
private void OpenFile(string filename)
{
if (!System.IO.File.Exists(filename))
{
@ -334,13 +334,13 @@ namespace embroideryReader
loadedFileName = filename;
if (design != null)
{
updateDesignImage();
UpdateDesignImage();
if (design.getFormatWarning())
if (design.GetFormatWarning())
{
toolStripStatusLabel1.Text = translation.GetTranslatedString(Translation.StringID.UNSUPPORTED_FORMAT); // "The format of this file is not completely supported";
}
else if (design.getColorWarning())
else if (design.GetColorWarning())
{
toolStripStatusLabel1.Text = translation.GetTranslatedString(Translation.StringID.COLOR_WARNING); // "Colors shown for this design may be inaccurate"
}
@ -395,7 +395,7 @@ namespace embroideryReader
else
{
settings.lastOpenFileFolder = System.IO.Path.GetDirectoryName(filename);
openFile(filename);
OpenFile(filename);
}
}
}
@ -415,7 +415,7 @@ namespace embroideryReader
private void aboutToolStripMenuItem_Click(object sender, EventArgs e)
{
string message = String.Format(translation.GetTranslatedString(Translation.StringID.ABOUT_MESSAGE), currentVersion()); // "EmbroideryReader version " + currentVersion() + ". This program reads and displays embroidery designs from .PES files."
string message = String.Format(translation.GetTranslatedString(Translation.StringID.ABOUT_MESSAGE), CurrentVersion()); // "EmbroideryReader version " + currentVersion() + ". This program reads and displays embroidery designs from .PES files."
//message += Environment.NewLine;
//message += Environment.NewLine + "GUI GDI count: " + GuiResources.GetGuiResourcesGDICount();
//message += Environment.NewLine + "GUI USER count: " + GuiResources.GetGuiResourcesUserCount();
@ -436,7 +436,7 @@ namespace embroideryReader
else if (updater.IsUpdateAvailable())
{
if (MessageBox.Show(String.Format(translation.GetTranslatedString(Translation.StringID.NEW_VERSION_MESSAGE),
updater.VersionAvailable(), updater.getReleaseDate().ToShortDateString(), currentVersion()) + // "Version " + updater.VersionAvailable() + " was released on " + updater.getReleaseDate().ToShortDateString() + ". You have version " + currentVersion() + "."
updater.VersionAvailable(), updater.getReleaseDate().ToShortDateString(), CurrentVersion()) + // "Version " + updater.VersionAvailable() + " was released on " + updater.getReleaseDate().ToShortDateString() + ". You have version " + currentVersion() + "."
Environment.NewLine +
translation.GetTranslatedString(Translation.StringID.NEW_VERSION_QUESTION), // "Would you like to go to the Embroidery Reader website to download or find out more about the new version?",
translation.GetTranslatedString(Translation.StringID.NEW_VERSION_TITLE), // "New version available",
@ -458,7 +458,7 @@ namespace embroideryReader
MessageBox.Show(translation.GetTranslatedString(Translation.StringID.NO_UPDATE) + // "No updates are available right now."
Environment.NewLine +
String.Format(translation.GetTranslatedString(Translation.StringID.LATEST_VERSION),
updater.VersionAvailable(), currentVersion())); // "(Latest version is " + updater.VersionAvailable() + ", you have version " + currentVersion() + ")");
updater.VersionAvailable(), CurrentVersion())); // "(Latest version is " + updater.VersionAvailable() + ", you have version " + currentVersion() + ")");
}
}
@ -482,7 +482,7 @@ namespace embroideryReader
settings.save();
}
private string currentVersion()
private string CurrentVersion()
{
return Assembly.GetExecutingAssembly().GetName().Version.ToString();
}
@ -493,7 +493,7 @@ namespace embroideryReader
{
try
{
string debugFile = design.saveDebugInfo();
string debugFile = design.SaveDebugInfo();
MessageBox.Show(String.Format(translation.GetTranslatedString(Translation.StringID.DEBUG_INFO_SAVED), // "Saved debug info to " + debugFile
debugFile));
}
@ -517,10 +517,10 @@ namespace embroideryReader
if (tempForm.ShowDialog() == DialogResult.OK)
{
settings = tempForm.settingsToModify;
loadSettings(true);
updateDesignImage();
LoadSettings(true);
UpdateDesignImage();
}
loadTranslatedStrings(settings.translation);
LoadTranslatedStrings(settings.translation);
}
private void printToolStripMenuItem_Click(object sender, EventArgs e)
@ -558,7 +558,7 @@ namespace embroideryReader
// Set print graphics object scale and draw the image
e.Graphics.ScaleTransform((float)graphicsXScaleFactor, (float)graphicsYScaleFactor);
using (Bitmap tempDrawArea = design.designToBitmap((float)settings.threadThickness, settings.filterStiches, settings.filterStitchesThreshold, 1.0f))
using (Bitmap tempDrawArea = design.DesignToBitmap((float)settings.threadThickness, settings.filterStiches, settings.filterStitchesThreshold, 1.0f))
{
e.Graphics.DrawImage(tempDrawArea, 30, 30);
}
@ -598,7 +598,7 @@ namespace embroideryReader
private void refreshToolStripMenuItem_Click(object sender, EventArgs e)
{
designRotation = 0;
updateDesignImage();
UpdateDesignImage();
}
private void rotateLeftToolStripMenuItem_Click(object sender, EventArgs e)
@ -608,7 +608,7 @@ namespace embroideryReader
{
designRotation += 360;
}
updateDesignImage();
UpdateDesignImage();
}
private void rotateRightToolStripMenuItem_Click(object sender, EventArgs e)
@ -618,7 +618,7 @@ namespace embroideryReader
{
designRotation -= 360;
}
updateDesignImage();
UpdateDesignImage();
}
private void showDebugInfoToolStripMenuItem_Click(object sender, EventArgs e)
@ -628,7 +628,7 @@ namespace embroideryReader
try
{
frmTextbox theform = new frmTextbox();
theform.showText(design.getDebugInfo());
theform.showText(design.GetDebugInfo());
}
catch (Exception ex)
{
@ -680,14 +680,14 @@ namespace embroideryReader
default: format = System.Drawing.Imaging.ImageFormat.Bmp; break;
}
temp.Save(filename, format);
showStatus(translation.GetTranslatedString(Translation.StringID.IMAGE_SAVED), 5000); // "Image saved"
ShowStatus(translation.GetTranslatedString(Translation.StringID.IMAGE_SAVED), 5000); // "Image saved"
settings.lastSaveImageLocation = System.IO.Path.GetDirectoryName(filename);
}
}
}
}
private void showStatus(string text, int msec)
private void ShowStatus(string text, int msec)
{
toolStripStatusLabel2.Text = text;
timer1.Interval = msec;
@ -699,7 +699,7 @@ namespace embroideryReader
toolStripStatusLabel2.Text = "";
}
private void loadTranslatedStrings(String translationName)
private void LoadTranslatedStrings(String translationName)
{
translation = new Translation(translationName);
@ -732,7 +732,7 @@ namespace embroideryReader
aboutToolStripMenuItem.Text = translation.GetTranslatedString(Translation.StringID.MENU_ABOUT);
}
private void setDesignScaleSetting(float scale, bool autoSize, bool updateDesign)
private void SetDesignScaleSetting(float scale, bool autoSize, bool updateDesign)
{
if(autoSize)
{
@ -748,63 +748,63 @@ namespace embroideryReader
if (updateDesign)
{
updateDesignImage();
UpdateDesignImage();
}
}
private void scale100ToolStripMenuItem_Click(object sender, EventArgs e)
{
setDesignScaleSetting(1.0f, false, true);
SetDesignScaleSetting(1.0f, false, true);
}
private void scale90ToolStripMenuItem_Click(object sender, EventArgs e)
{
setDesignScaleSetting(0.9f, false, true);
SetDesignScaleSetting(0.9f, false, true);
}
private void scale80ToolStripMenuItem_Click(object sender, EventArgs e)
{
setDesignScaleSetting(0.8f, false, true);
SetDesignScaleSetting(0.8f, false, true);
}
private void scale70ToolStripMenuItem_Click(object sender, EventArgs e)
{
setDesignScaleSetting(0.7f, false, true);
SetDesignScaleSetting(0.7f, false, true);
}
private void scale60ToolStripMenuItem_Click(object sender, EventArgs e)
{
setDesignScaleSetting(0.6f, false, true);
SetDesignScaleSetting(0.6f, false, true);
}
private void scale50ToolStripMenuItem_Click(object sender, EventArgs e)
{
setDesignScaleSetting(0.5f, false, true);
SetDesignScaleSetting(0.5f, false, true);
}
private void scale40ToolStripMenuItem_Click(object sender, EventArgs e)
{
setDesignScaleSetting(0.4f, false, true);
SetDesignScaleSetting(0.4f, false, true);
}
private void scale30ToolStripMenuItem_Click(object sender, EventArgs e)
{
setDesignScaleSetting(0.3f, false, true);
SetDesignScaleSetting(0.3f, false, true);
}
private void scale20ToolStripMenuItem_Click(object sender, EventArgs e)
{
setDesignScaleSetting(0.2f, false, true);
SetDesignScaleSetting(0.2f, false, true);
}
private void scale10ToolStripMenuItem_Click(object sender, EventArgs e)
{
setDesignScaleSetting(0.1f, false, true);
SetDesignScaleSetting(0.1f, false, true);
}
private void scale5ToolStripMenuItem_Click(object sender, EventArgs e)
{
setDesignScaleSetting(0.05f, false, true);
SetDesignScaleSetting(0.05f, false, true);
}
private void fitToWindowToolStripMenuItem_Click(object sender, EventArgs e)
@ -812,7 +812,7 @@ namespace embroideryReader
// Toggle checked state
fitToWindowToolStripMenuItem.Checked = !fitToWindowToolStripMenuItem.Checked;
// Update design
setDesignScaleSetting(1.0f, fitToWindowToolStripMenuItem.Checked, true);
SetDesignScaleSetting(1.0f, fitToWindowToolStripMenuItem.Checked, true);
}
private void frmMain_ResizeEnd(object sender, EventArgs e)
@ -822,7 +822,7 @@ namespace embroideryReader
// of panel2 has changed to see if it's really a resize event.
if (fitToWindowToolStripMenuItem.Checked && panel2LastUpdateSize != panel2.Size)
{
updateDesignImage();
UpdateDesignImage();
}
}
@ -838,7 +838,7 @@ namespace embroideryReader
if (fitToWindowToolStripMenuItem.Checked)
{
updateDesignImage();
UpdateDesignImage();
}
}
}

Wyświetl plik

@ -174,7 +174,7 @@ namespace embroideryThumbs
logfile.WriteLine("Called Extract");
logfile.Close();
System.Drawing.Bitmap designBitmap = designFile.designToBitmap(3, false, 0, 1.0f);
System.Drawing.Bitmap designBitmap = designFile.DesignToBitmap(3, false, 0, 1.0f);
IntPtr hBmp = designBitmap.GetHbitmap();