Another step in adding seperate VS 2008 project files, merged some changes from 1.3 branch

Branch_1.5.0
Nathan Crawford 2010-01-23 02:59:33 +00:00
rodzic e0311a4fec
commit 8ec5e02992
6 zmienionych plików z 265 dodań i 149 usunięć

Wyświetl plik

@ -250,7 +250,7 @@ namespace PesFile
}
catch (Exception ex)
{
readyStatus = statusEnum.ReadError;
readyStatus = statusEnum.ParseError;
lastError = ex.Message;
if (fileIn != null)
{

Wyświetl plik

@ -0,0 +1,221 @@
/*
Embroidery Reader - an application to view .pes embroidery designs
Copyright (C) 2010 Nathan Crawford
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA.
A copy of the full GPL 2 license can be found in the docs directory.
You can contact me at http://www.njcrawford.com/contact
*/
using System;
using System.Collections.Generic;
using System.Text;
namespace embroideryReader
{
public class EmbroideryReaderSettings
{
private nc_settings.IniFile settings;
private const String SETTING_UPDATE_LOCATION = "update location";
private const String SECTION_BACKGROUND_COLOR = "background color";
private const String SETTING_BACKGROUND_COLOR_ENABLED = "enabled";
private const String SETTING_BACKGROUND_COLOR_RED = "red";
private const String SETTING_BACKGROUND_COLOR_GREEN = "green";
private const String SETTING_BACKGROUND_COLOR_BLUE = "blue";
private const String SETTING_FILTER_STITCHES = "filter stitches";
private const String SETTING_FILTER_STITCHES_THRESHOLD = "filter stitches threshold";
private const String SETTING_THREAD_THICKNESS = "thread thickness";
private const String SETTING_LAST_OPEN_FILE_FOLDER = "last open file folder";
private const String SETTING_LAST_SAVE_IMAGE_LOCATION = "last save image location";
private const String VALUE_YES = "yes";
private const String VALUE_NO = "no";
private const String VALUE_TRUE = "true";
private const String VALUE_FALSE = "false";
public EmbroideryReaderSettings()
{
settings = new nc_settings.IniFile("embroideryreader.ini");
if (String.IsNullOrEmpty(updateLocation))
{
updateLocation = "http://www.njcrawford.com/updates/embroidery-reader.ini";
}
}
public String updateLocation
{
get
{
return settings.getValue(SETTING_UPDATE_LOCATION);
}
set
{
settings.setValue(SETTING_UPDATE_LOCATION, value);
}
}
public bool backgroundColorEnabled
{
get
{
return (settings.getValue(SECTION_BACKGROUND_COLOR, SETTING_BACKGROUND_COLOR_ENABLED) == VALUE_YES);
}
set
{
String output = VALUE_NO;
if (value)
{
output = VALUE_YES;
}
settings.setValue(SECTION_BACKGROUND_COLOR, SETTING_BACKGROUND_COLOR_ENABLED, output);
}
}
public System.Drawing.Color backgroundColor
{
get
{
if (backgroundColorEnabled)
{
if (frmMain.checkColorFromStrings(settings.getValue(SECTION_BACKGROUND_COLOR, SETTING_BACKGROUND_COLOR_RED),
settings.getValue(SECTION_BACKGROUND_COLOR, SETTING_BACKGROUND_COLOR_GREEN),
settings.getValue(SECTION_BACKGROUND_COLOR, SETTING_BACKGROUND_COLOR_BLUE)))
{
return frmMain.makeColorFromStrings(settings.getValue(SECTION_BACKGROUND_COLOR, SETTING_BACKGROUND_COLOR_RED),
settings.getValue(SECTION_BACKGROUND_COLOR, SETTING_BACKGROUND_COLOR_GREEN),
settings.getValue(SECTION_BACKGROUND_COLOR, SETTING_BACKGROUND_COLOR_BLUE));
}
else
{
return System.Drawing.Color.FromKnownColor(System.Drawing.KnownColor.Control);
}
}
else
{
return System.Drawing.Color.FromKnownColor(System.Drawing.KnownColor.Control);
}
}
set
{
settings.setValue(SECTION_BACKGROUND_COLOR, SETTING_BACKGROUND_COLOR_RED, value.R.ToString());
settings.setValue(SECTION_BACKGROUND_COLOR, SETTING_BACKGROUND_COLOR_GREEN, value.G.ToString());
settings.setValue(SECTION_BACKGROUND_COLOR, SETTING_BACKGROUND_COLOR_BLUE, value.B.ToString());
}
}
public bool filterStiches
{
get
{
return (settings.getValue(SETTING_FILTER_STITCHES) == VALUE_TRUE);
}
set
{
String output = VALUE_FALSE;
if (value)
{
output = VALUE_TRUE;
}
settings.setValue(SETTING_FILTER_STITCHES, output);
}
}
public double threadThickness
{
get
{
double thickness = 5;
if (settings.getValue(SETTING_THREAD_THICKNESS) != null)
{
if (Double.TryParse(settings.getValue(SETTING_THREAD_THICKNESS), out thickness))
{
if (thickness < 1)
{
thickness = 1;
}
}
}
return thickness;
}
set
{
settings.setValue(SETTING_THREAD_THICKNESS, value.ToString());
}
}
public double filterStitchesThreshold
{
get
{
int threshold = 120;
if (settings.getValue(SETTING_FILTER_STITCHES_THRESHOLD) != null)
{
if (Int32.TryParse(settings.getValue(SETTING_FILTER_STITCHES_THRESHOLD), out threshold))
{
if (threshold < 10)
{
threshold = 10;
}
}
}
return threshold;
}
set
{
settings.setValue(SETTING_FILTER_STITCHES_THRESHOLD, value.ToString());
}
}
public String lastOpenFileFolder
{
get
{
return settings.getValue(SETTING_LAST_OPEN_FILE_FOLDER);
}
set
{
settings.setValue(SETTING_LAST_OPEN_FILE_FOLDER, value);
}
}
public void save()
{
settings.save();
}
public String lastSaveImageLocation
{
get
{
return settings.getValue(SETTING_LAST_SAVE_IMAGE_LOCATION);
}
set
{
settings.setValue(SETTING_LAST_SAVE_IMAGE_LOCATION, value);
}
}
}
}

Wyświetl plik

@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA.
A copy of the full GPL 2 license can be found in the docs directory.
You can contact me at http://www.njcrawford.com/contact/.
You can contact me at http://www.njcrawford.com/contact
*/

Wyświetl plik

@ -1,7 +1,7 @@
/*
Embroidery Reader - an application to view .pes embroidery designs
Copyright (C) 2009 Nathan Crawford
Copyright (C) 2010 Nathan Crawford
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA.
A copy of the full GPL 2 license can be found in the docs directory.
You can contact me at http://www.njcrawford.com/contact/.
You can contact me at http://www.njcrawford.com/contact
*/
@ -41,19 +41,9 @@ namespace embroideryReader
private Pen drawPen = Pens.Black;
private Bitmap DrawArea;
private PesFile.PesFile design;
private NJCrawford.IniFile settings = new NJCrawford.IniFile("embroideryreader.ini");
private EmbroideryReaderSettings settings = new EmbroideryReaderSettings();
private const string SETTING_LAST_FOLDER = "last open file folder";
private const string SETTING_BG_COLOR_SECTION = "background color";
private const string SETTING_BG_COLOR_RED = "red";
private const string SETTING_BG_COLOR_GREEN = "green";
private const string SETTING_BG_COLOR_BLUE = "blue";
private const string SETTING_THREAD_THICKNESS = "thread thickness";
private const string SETTING_FILTER_STITCHES_THRESHOLD = "filter stitches threshold";
private const string SETTING_LAST_SAVE_IMAGE_LOCATION = "last save image location";
private const string SETTING_FILTER_STITCHES = "filter stitches";
private const string UPDATE_URL = "http://www.njcrawford.com/embroidery-reader/update.ini";
private const String APP_TITLE = "Embroidery Reader";
public frmMain()
@ -64,35 +54,13 @@ namespace embroideryReader
private void checkSettings()
{
if (settings.getValue("update location") != null)
{
settings.setValue("update location", null); //remove the update location value from the file
}
if (settings.getValue(SETTING_BG_COLOR_SECTION, "enabled") == "yes")
{
if (checkColorFromStrings(settings.getValue(SETTING_BG_COLOR_SECTION, SETTING_BG_COLOR_RED),
settings.getValue(SETTING_BG_COLOR_SECTION, SETTING_BG_COLOR_GREEN),
settings.getValue(SETTING_BG_COLOR_SECTION, SETTING_BG_COLOR_BLUE)))
{
this.BackColor = makeColorFromStrings(settings.getValue(SETTING_BG_COLOR_SECTION, SETTING_BG_COLOR_RED),
settings.getValue(SETTING_BG_COLOR_SECTION, SETTING_BG_COLOR_GREEN),
settings.getValue(SETTING_BG_COLOR_SECTION, SETTING_BG_COLOR_BLUE));
}
else
{
this.BackColor = Color.FromKnownColor(KnownColor.Control);
}
}
else
{
this.BackColor = Color.FromKnownColor(KnownColor.Control);
}
this.BackColor = settings.backgroundColor;
}
private void Form1_Load(object sender, EventArgs e)
{
checkSettings();
this.Text = "Embroidery Reader";
this.Text = APP_TITLE;
if (args.Length > 1)
{
openFile(args[1]);
@ -150,23 +118,11 @@ namespace embroideryReader
design = new PesFile.PesFile(filename);
if (design.getStatus() == PesFile.statusEnum.Ready)
{
this.Text = System.IO.Path.GetFileName(filename) + " - Embroidery Reader";
//sizePanel2();
this.Text = System.IO.Path.GetFileName(filename) + " - " + APP_TITLE;
double threadThickness = 5;
if (!Double.TryParse(settings.getValue(SETTING_THREAD_THICKNESS), out threadThickness))
{
threadThickness = 5;
}
double threshold = 10;
if (!Double.TryParse(settings.getValue(SETTING_FILTER_STITCHES_THRESHOLD), out threshold))
{
threshold = 120;
}
DrawArea = design.designToBitmap((float)threadThickness, (settings.getValue(SETTING_FILTER_STITCHES) == "true"), (int)threshold);
panel1.Width = design.GetWidth() + (int)(threadThickness * 2);
panel1.Height = design.GetHeight() + (int)(threadThickness * 2);
DrawArea = design.designToBitmap((float)settings.threadThickness, (settings.filterStiches), (int)settings.filterStitchesThreshold);
panel1.Width = design.GetWidth() + (int)(settings.threadThickness * 2);
panel1.Height = design.GetHeight() + (int)(settings.threadThickness * 2);
panel1.Invalidate();
if (design.getFormatWarning())
@ -215,9 +171,9 @@ namespace embroideryReader
private void openToolStripMenuItem_Click(object sender, EventArgs e)
{
string filename;
if (settings.getValue(SETTING_LAST_FOLDER) != null)
if (settings.lastOpenFileFolder != null)
{
openFileDialog1.InitialDirectory = settings.getValue(SETTING_LAST_FOLDER);
openFileDialog1.InitialDirectory = settings.lastOpenFileFolder;
}
openFileDialog1.FileName = "";
openFileDialog1.Filter = "Embroidery Files (*.pes)|*.pes|All Files (*.*)|*.*";
@ -230,7 +186,7 @@ namespace embroideryReader
}
else
{
settings.setValue(SETTING_LAST_FOLDER, System.IO.Path.GetDirectoryName(filename));
settings.lastOpenFileFolder = System.IO.Path.GetDirectoryName(filename);
openFile(filename);
}
}
@ -316,10 +272,10 @@ namespace embroideryReader
private void preferencesToolStripMenuItem_Click(object sender, EventArgs e)
{
frmSettingsDialog tempForm = new frmSettingsDialog();
tempForm.settings = settings;
tempForm.settingsToModify = settings;
if (tempForm.ShowDialog() == DialogResult.OK)
{
settings = tempForm.settings;
settings = tempForm.settingsToModify;
checkSettings();
}
}
@ -369,15 +325,9 @@ namespace embroideryReader
{
if (design != null && design.getStatus() == PesFile.statusEnum.Ready)
{
double threadThickness = 5;
if (!Double.TryParse(settings.getValue(SETTING_THREAD_THICKNESS), out threadThickness))
{
threadThickness = 5;
}
int threshold = Convert.ToInt32(settings.getValue(SETTING_FILTER_STITCHES_THRESHOLD));
DrawArea = design.designToBitmap((float)threadThickness, (settings.getValue(SETTING_FILTER_STITCHES) == "true"), (int)threshold);
panel1.Width = design.GetWidth() + (int)(threadThickness * 2);
panel1.Height = design.GetHeight() + (int)(threadThickness * 2);
DrawArea = design.designToBitmap((float)settings.threadThickness, (settings.filterStiches), (int)settings.filterStitchesThreshold);
panel1.Width = design.GetWidth() + (int)(settings.threadThickness * 2);
panel1.Height = design.GetHeight() + (int)(settings.threadThickness * 2);
panel1.Invalidate();
if (design.getClassWarning())
@ -459,9 +409,9 @@ namespace embroideryReader
tempGraph.Dispose();
saveFileDialog1.FileName = "";
saveFileDialog1.Filter = "Bitmap (*.bmp)|*.bmp|PNG (*.png)|*.png|JPEG (*.jpg)|*.jpg|GIF (*.gif)|*.gif|TIFF (*.tif)|*.tif|All Files (*.*)|*.*";
if (settings.getValue(SETTING_LAST_SAVE_IMAGE_LOCATION) != null)
if (settings.lastSaveImageLocation != null)
{
saveFileDialog1.InitialDirectory = settings.getValue(SETTING_LAST_SAVE_IMAGE_LOCATION);
saveFileDialog1.InitialDirectory = settings.lastSaveImageLocation;
}
if (saveFileDialog1.ShowDialog() == DialogResult.OK)
{
@ -479,7 +429,7 @@ namespace embroideryReader
}
temp.Save(filename, format);
showStatus("Image saved", 5000);
settings.setValue(SETTING_LAST_SAVE_IMAGE_LOCATION, System.IO.Path.GetDirectoryName(filename));
settings.lastSaveImageLocation = System.IO.Path.GetDirectoryName(filename);
}
}
}

Wyświetl plik

@ -1,7 +1,7 @@
/*
Embroidery Reader - an application to view .pes embroidery designs
Copyright (C) 2009 Nathan Crawford
Copyright (C) 2010 Nathan Crawford
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA.
A copy of the full GPL 2 license can be found in the docs directory.
You can contact me at http://www.njcrawford.com/contact/.
You can contact me at http://www.njcrawford.com/contact
*/
@ -36,63 +36,26 @@ namespace embroideryReader
public partial class frmSettingsDialog : Form
{
private bool colorChanged = false;
private NJCrawford.IniFile _settings;
public NJCrawford.IniFile settings
private EmbroideryReaderSettings settings;
public EmbroideryReaderSettings settingsToModify
{
get
{
return _settings;
return settings;
}
set
{
_settings = value;
if (settings.getValue("background color", "enabled") == "yes" &&
frmMain.checkColorFromStrings(
settings.getValue("background color", "red"),
settings.getValue("background color", "green"),
settings.getValue("background color", "blue")))
settings = value;
if (settings.backgroundColorEnabled)
{
lblColor.BackColor = frmMain.makeColorFromStrings(
settings.getValue("background color", "red"),
settings.getValue("background color", "green"),
settings.getValue("background color", "blue"));
}
if (settings.getValue("thread thickness") != null)
{
double threadThickness = 1;
if (!Double.TryParse(settings.getValue("thread thickness"), out threadThickness))
{
threadThickness = 5;
}
if (threadThickness < 1)
{
threadThickness = 1;
}
txtThreadThickness.Text = threadThickness.ToString();
}
else
{
txtThreadThickness.Text = "5";
lblColor.BackColor = settings.backgroundColor;
}
if (settings.getValue("filter stitches") == "true")
{
chkUglyStitches.Checked = true;
}
else
{
chkUglyStitches.Checked = false;
}
txtThreadThickness.Text = settings.threadThickness.ToString();
if (settings.getValue("filter stitches threshold") != null)
{
txtThreshold.Text= settings.getValue("filter stitches threshold");
}
else
{
txtThreshold.Text = "120";
}
chkUglyStitches.Checked = settings.filterStiches;
txtThreshold.Text = settings.filterStitchesThreshold.ToString();
}
}
@ -131,44 +94,26 @@ namespace embroideryReader
{
if (lblColor.BackColor != Color.FromKnownColor(KnownColor.Control))
{
settings.setValue("background color", "enabled", "yes");
settings.setValue("background color", "red", lblColor.BackColor.R.ToString());
settings.setValue("background color", "green", lblColor.BackColor.G.ToString());
settings.setValue("background color", "blue", lblColor.BackColor.B.ToString());
settings.backgroundColorEnabled = true;
settings.backgroundColor = lblColor.BackColor;
}
else
{
settings.setValue("background color", "enabled", "no");
settings.backgroundColorEnabled = false;
}
}
double threadThickness = 5;
double threadThickness;
if (Double.TryParse(txtThreadThickness.Text, out threadThickness))
{
if (threadThickness < 1)
{
threadThickness = 1;
}
settings.setValue("thread thickness", threadThickness.ToString());
settings.threadThickness = threadThickness;
}
if (chkUglyStitches.Checked)
{
settings.setValue("filter stitches", "true");
}
else
{
settings.setValue("filter stitches", "false");
}
settings.filterStiches = chkUglyStitches.Checked;
double threshold = 120;
double threshold;
if (Double.TryParse(txtThreshold.Text, out threshold))
{
if (threshold < 10)
{
threshold = 10;
}
settings.setValue("filter stitches threshold", threshold.ToString());
settings.filterStitchesThreshold = threshold;
}
}
}

Wyświetl plik

@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA.
A copy of the full GPL 2 license can be found in the docs directory.
You can contact me at http://www.njcrawford.com/contact/.
You can contact me at http://www.njcrawford.com/contact
*/