diff --git a/CustomWidgets/PartThumbnailWidget.cs b/CustomWidgets/PartThumbnailWidget.cs
index c74b88754..0dec8b49e 100644
--- a/CustomWidgets/PartThumbnailWidget.cs
+++ b/CustomWidgets/PartThumbnailWidget.cs
@@ -1,4 +1,33 @@
-using System;
+/*
+Copyright (c) 2014, Lars Brubaker
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+1. Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+The views and conclusions contained in the software and documentation are those
+of the authors and should not be interpreted as representing official policies,
+either expressed or implied, of the FreeBSD Project.
+*/
+
+using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
diff --git a/ICSharpCode.SharpZipLib.dll b/ICSharpCode.SharpZipLib.dll
new file mode 100644
index 000000000..fe643ebc6
Binary files /dev/null and b/ICSharpCode.SharpZipLib.dll differ
diff --git a/Ionic.Zip.dll b/Ionic.Zip.dll
deleted file mode 100644
index 95fa92885..000000000
Binary files a/Ionic.Zip.dll and /dev/null differ
diff --git a/MainSlidePanel.cs b/MainSlidePanel.cs
index 054285c46..dd53190bb 100644
--- a/MainSlidePanel.cs
+++ b/MainSlidePanel.cs
@@ -1,4 +1,3 @@
-
/*
Copyright (c) 2014, Lars Brubaker
All rights reserved.
@@ -28,7 +27,6 @@ of the authors and should not be interpreted as representing official policies,
either expressed or implied, of the FreeBSD Project.
*/
-
using System;
using System.Collections.Generic;
using System.Linq;
diff --git a/MatterControl.csproj b/MatterControl.csproj
index 525b3aa80..4a945a51b 100644
--- a/MatterControl.csproj
+++ b/MatterControl.csproj
@@ -191,8 +191,8 @@
-
- Ionic.Zip.dll
+
+ .\ICSharpCode.SharpZipLib.dll
PdfSharp.dll
diff --git a/PartPreviewWindow/GcodeViewBasic.cs b/PartPreviewWindow/GcodeViewBasic.cs
index 43cc3796b..b0b524ca6 100644
--- a/PartPreviewWindow/GcodeViewBasic.cs
+++ b/PartPreviewWindow/GcodeViewBasic.cs
@@ -129,26 +129,33 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
}
else
{
- string gcodePathAndFileName = printItem.GCodePathAndFileName;
- bool gcodeFileIsComplete = printItem.IsGCodeFileComplete(gcodePathAndFileName);
-
- if (gcodeProcessingStateInfoText != null && gcodeProcessingStateInfoText.Text == "Slicing Error")
+ if (File.Exists(printItem.FileLocation))
{
- startingMessage = "Slicing Error. Please review your slice settings.";
+ string gcodePathAndFileName = printItem.GCodePathAndFileName;
+ bool gcodeFileIsComplete = printItem.IsGCodeFileComplete(gcodePathAndFileName);
+
+ if (gcodeProcessingStateInfoText != null && gcodeProcessingStateInfoText.Text == "Slicing Error")
+ {
+ startingMessage = new LocalizedString("Slicing Error. Please review your slice settings.").Translated;
+ }
+ else
+ {
+ startingMessage = new LocalizedString("Press 'generate' to view layers").Translated;
+ }
+
+ if (File.Exists(gcodePathAndFileName) && gcodeFileIsComplete)
+ {
+ gcodeDispalyWidget.AddChild(CreateGCodeViewWidget(gcodePathAndFileName));
+ }
+
+ // we only hook these up to make sure we can regenerate the gcode when we want
+ printItem.SlicingOutputMessage += sliceItem_SlicingOutputMessage;
+ printItem.Done += new EventHandler(sliceItem_Done);
}
else
{
- startingMessage = new LocalizedString("Press 'generate' to view layers").Translated;
+ startingMessage = string.Format("{0}\n'{1}'", new LocalizedString("File not found on disk.").Translated, printItem.Name);
}
-
- if (File.Exists(gcodePathAndFileName) && gcodeFileIsComplete)
- {
- gcodeDispalyWidget.AddChild(CreateGCodeViewWidget(gcodePathAndFileName));
- }
-
- // we only hook these up to make sure we can regenerate the gcode when we want
- printItem.SlicingOutputMessage += sliceItem_SlicingOutputMessage;
- printItem.Done += new EventHandler(sliceItem_Done);
}
}
diff --git a/PartPreviewWindow/View3DTransfromPart.cs b/PartPreviewWindow/View3DTransfromPart.cs
index c6e91fdf0..c9f93a420 100644
--- a/PartPreviewWindow/View3DTransfromPart.cs
+++ b/PartPreviewWindow/View3DTransfromPart.cs
@@ -82,11 +82,12 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
FlowLayoutWidget scaleOptionContainer;
ProgressControl processingProgressControl;
- FlowLayoutWidget editPlateButtonsContainer;
+ FlowLayoutWidget enterEditButtonsContainer;
+ FlowLayoutWidget doEdittingButtonsContainer;
RadioButton rotateViewButton;
- Button editPlateButton;
GuiWidget viewControlsSeparator;
RadioButton partSelectButton;
+ bool OpenAddDialogWhenDone = false;
Dictionary> transformControls = new Dictionary>();
@@ -295,49 +296,75 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
{
FlowLayoutWidget editToolBar = new FlowLayoutWidget();
- string progressFindPartsLbl = new LocalizedString ("Finding Parts").Translated;
- string progressFindPartsLblFull = string.Format ("{0}:", progressFindPartsLbl);
+ string progressFindPartsLbl = new LocalizedString("Finding Parts").Translated;
+ string progressFindPartsLblFull = string.Format("{0}:", progressFindPartsLbl);
- processingProgressControl = new ProgressControl(progressFindPartsLblFull);
+ processingProgressControl = new ProgressControl(progressFindPartsLblFull);
processingProgressControl.VAnchor = Agg.UI.VAnchor.ParentCenter;
editToolBar.AddChild(processingProgressControl);
editToolBar.VAnchor |= Agg.UI.VAnchor.ParentCenter;
processingProgressControl.Visible = false;
- editPlateButton = textImageButtonFactory.Generate(new LocalizedString("Edit").Translated);
- editToolBar.AddChild(editPlateButton);
-
- editPlateButtonsContainer = new FlowLayoutWidget();
- editPlateButtonsContainer.Visible = false;
-
- Button addButton = textImageButtonFactory.Generate(new LocalizedString("Add").Translated, "icon_circle_plus.png");
- addButton.Margin = new BorderDouble(right: 10);
- editPlateButtonsContainer.AddChild(addButton);
- addButton.Click += (sender, e) =>
+ enterEditButtonsContainer = new FlowLayoutWidget();
{
- UiThread.RunOnIdle((state) =>
+ Button addButton = textImageButtonFactory.Generate(new LocalizedString("Add").Translated, "icon_circle_plus.png");
+ addButton.Margin = new BorderDouble(right: 10);
+ enterEditButtonsContainer.AddChild(addButton);
+ addButton.Click += (sender, e) =>
{
- OpenFileDialogParams openParams = new OpenFileDialogParams("Select an STL file|*.stl", multiSelect: true);
+ UiThread.RunOnIdle((state) =>
+ {
+ enterEditButtonsContainer.Visible = false;
+ EnterEditAndSplitIntoMeshes();
+ OpenAddDialogWhenDone = true;
+ });
+ };
- FileDialog.OpenFileDialog(ref openParams);
- LoadAndAddPartsToPlate(openParams.FileNames);
- });
- };
+ Button enterEdittingButton = textImageButtonFactory.Generate(new LocalizedString("Edit").Translated);
+ enterEdittingButton.Click += (sender, e) =>
+ {
+ enterEditButtonsContainer.Visible = false;
+
+ EnterEditAndSplitIntoMeshes();
+ };
+
+ enterEditButtonsContainer.AddChild(enterEdittingButton);
+ }
+ editToolBar.AddChild(enterEditButtonsContainer);
+
+ doEdittingButtonsContainer = new FlowLayoutWidget();
+ doEdittingButtonsContainer.Visible = false;
- Button copyButton = textImageButtonFactory.Generate(new LocalizedString("Copy").Translated);
- editPlateButtonsContainer.AddChild(copyButton);
- copyButton.Click += (sender, e) =>
{
- MakeCopyOfMesh();
- };
+ Button addButton = textImageButtonFactory.Generate(new LocalizedString("Add").Translated, "icon_circle_plus.png");
+ addButton.Margin = new BorderDouble(right: 10);
+ doEdittingButtonsContainer.AddChild(addButton);
+ addButton.Click += (sender, e) =>
+ {
+ UiThread.RunOnIdle((state) =>
+ {
+ OpenFileDialogParams openParams = new OpenFileDialogParams("Select an STL file|*.stl", multiSelect: true);
- Button deleteButton = textImageButtonFactory.Generate(new LocalizedString("Delete").Translated);
- deleteButton.Margin = new BorderDouble(left: 20);
- editPlateButtonsContainer.AddChild(deleteButton);
- deleteButton.Click += (sender, e) =>
- {
- DeleteSelectedMesh();
- };
+ FileDialog.OpenFileDialog(ref openParams);
+ LoadAndAddPartsToPlate(openParams.FileNames);
+ });
+ };
+
+ Button copyButton = textImageButtonFactory.Generate(new LocalizedString("Copy").Translated);
+ doEdittingButtonsContainer.AddChild(copyButton);
+ copyButton.Click += (sender, e) =>
+ {
+ MakeCopyOfMesh();
+ };
+
+ Button deleteButton = textImageButtonFactory.Generate(new LocalizedString("Delete").Translated);
+ deleteButton.Margin = new BorderDouble(left: 20);
+ doEdittingButtonsContainer.AddChild(deleteButton);
+ deleteButton.Click += (sender, e) =>
+ {
+ DeleteSelectedMesh();
+ };
+ }
KeyDown += (sender, e) =>
{
@@ -361,15 +388,8 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
}
};
- editToolBar.AddChild(editPlateButtonsContainer);
+ editToolBar.AddChild(doEdittingButtonsContainer);
buttonBottomPanel.AddChild(editToolBar);
-
- editPlateButton.Click += (sender, e) =>
- {
- editPlateButton.Visible = false;
-
- EnterEditAndSplitIntoMeshes();
- };
}
autoArrangeButton.Click += (sender, e) =>
@@ -720,7 +740,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
void LockEditControls()
{
- editPlateButtonsContainer.Visible = false;
+ doEdittingButtonsContainer.Visible = false;
buttonRightPanelDisabledCover.Visible = true;
if (viewControlsSeparator != null)
{
@@ -738,11 +758,11 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
buttonRightPanelDisabledCover.Visible = false;
processingProgressControl.Visible = false;
- if (!editPlateButton.Visible)
+ if (!enterEditButtonsContainer.Visible)
{
viewControlsSeparator.Visible = true;
partSelectButton.Visible = true;
- editPlateButtonsContainer.Visible = true;
+ doEdittingButtonsContainer.Visible = true;
}
}
@@ -822,6 +842,15 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
partSelectButton.ClickButton(null);
Invalidate();
+
+ if (OpenAddDialogWhenDone)
+ {
+ OpenAddDialogWhenDone = false;
+ OpenFileDialogParams openParams = new OpenFileDialogParams("Select an STL file|*.stl", multiSelect: true);
+
+ FileDialog.OpenFileDialog(ref openParams);
+ LoadAndAddPartsToPlate(openParams.FileNames);
+ }
}
void BackgroundWorker_ProgressChanged(object sender, ProgressChangedEventArgs e)
diff --git a/PrintQueue/PrintQueueControl.cs b/PrintQueue/PrintQueueControl.cs
index 3055d2415..bf01c41ab 100644
--- a/PrintQueue/PrintQueueControl.cs
+++ b/PrintQueue/PrintQueueControl.cs
@@ -424,6 +424,7 @@ namespace MatterHackers.MatterControl.PrintQueue
AutoScroll = true;
topToBottomItemList = new FlowLayoutWidget(FlowDirection.TopToBottom);
+ topToBottomItemList.Name = "PrintQueueControl TopToBottom";
topToBottomItemList.HAnchor = Agg.UI.HAnchor.Max_FitToChildren_ParentWidth;
base.AddChild(topToBottomItemList);
}
@@ -431,7 +432,7 @@ namespace MatterHackers.MatterControl.PrintQueue
public override void AddChild(GuiWidget childToAdd, int indexInChildrenList = -1)
{
FlowLayoutWidget itemHolder = new FlowLayoutWidget();
- itemHolder.Name = "LB item holder";
+ itemHolder.Name = "PrintQueueControl itemHolder";
itemHolder.Margin = new BorderDouble(0, 0, 0, 0);
itemHolder.HAnchor = Agg.UI.HAnchor.Max_FitToChildren_ParentWidth;
itemHolder.AddChild(childToAdd);
diff --git a/Utilities/ProjectFileHandler.cs b/Utilities/ProjectFileHandler.cs
index 9cbd92c5a..7f3ae90a2 100644
--- a/Utilities/ProjectFileHandler.cs
+++ b/Utilities/ProjectFileHandler.cs
@@ -37,7 +37,7 @@ using System.IO;
using System.Diagnostics;
using System.Collections.Generic;
-using Ionic.Zip;
+using ICSharpCode.SharpZipLib.Zip;
using MatterHackers.Agg.UI;
using MatterHackers.MatterControl.DataStorage;
@@ -173,7 +173,6 @@ namespace MatterHackers.MatterControl
public void ExportToProjectArchive(string savedFileName = null)
{
-
if (savedFileName == null)
{
savedFileName = defaultProjectPathAndFileName;
@@ -197,16 +196,46 @@ namespace MatterHackers.MatterControl
StreamWriter sw = new System.IO.StreamWriter(fs);
sw.Write(jsonString);
sw.Close();
-
- ZipFile zip = new ZipFile();
- zip.AddFile(defaultManifestPathAndFileName).FileName = Path.GetFileName(defaultManifestPathAndFileName);
+
+ FileStream outputFileStream = File.Create(savedFileName);
+ ZipOutputStream zipStream = new ZipOutputStream(outputFileStream);
+ zipStream.SetLevel(3);
+ CopyFileToZip(zipStream, defaultManifestPathAndFileName);
{
foreach (KeyValuePair item in this.sourceFiles)
{
- zip.AddFile(item.Key).FileName = Path.GetFileName(item.Key);
+ CopyFileToZip(zipStream, item.Key);
}
}
- zip.Save(savedFileName);
+ zipStream.IsStreamOwner = true; // Makes the Close also Close the underlying stream
+ zipStream.Close();
+ }
+
+ private static void CopyFileToZip(ZipOutputStream zipStream, string sourceFile)
+ {
+ if (File.Exists(sourceFile))
+ {
+ ZipEntry newEntry = new ZipEntry(Path.GetFileName(sourceFile));
+ FileInfo fi = new FileInfo(sourceFile);
+ newEntry.DateTime = fi.LastWriteTime;
+ newEntry.Size = fi.Length;
+ zipStream.PutNextEntry(newEntry);
+ using (FileStream streamReader = File.OpenRead(sourceFile))
+ {
+ CopyStream(streamReader, zipStream);
+ }
+ zipStream.CloseEntry();
+ }
+ }
+
+ public static void CopyStream(Stream input, Stream output)
+ {
+ byte[] buffer = new byte[4096];
+ int read;
+ while ((read = input.Read(buffer, 0, buffer.Length)) > 0)
+ {
+ output.Write(buffer, 0, read);
+ }
}
public List OpenFromDialog()
@@ -233,9 +262,9 @@ namespace MatterHackers.MatterControl
}
if (System.IO.File.Exists(loadedFileName))
- {
-
- ZipFile zip = ZipFile.Read(loadedFileName);
+ {
+ FileStream fs = File.OpenRead(loadedFileName);
+ ZipFile zip = new ZipFile(fs);
int projectHashCode = zip.GetHashCode();
//If the temp folder doesn't exist - create it, otherwise clear it
@@ -253,20 +282,37 @@ namespace MatterHackers.MatterControl
List printItemList = new List();
Project projectManifest = null;
- foreach (ZipEntry e in zip)
- {
- e.Extract(stagingFolder, ExtractExistingFileAction.OverwriteSilently);
- if (e.FileName == "manifest.json")
+ foreach (ZipEntry zipEntry in zip)
+ {
+ if (!zipEntry.IsFile)
{
- e.Extract(stagingFolder, ExtractExistingFileAction.OverwriteSilently);
- string extractedFileName = Path.Combine(stagingFolder, e.FileName);
- StreamReader sr = new System.IO.StreamReader(extractedFileName);
- projectManifest = (Project)Newtonsoft.Json.JsonConvert.DeserializeObject(sr.ReadToEnd(), typeof(Project));
- sr.Close();
+ continue; // Ignore directories
}
- else if (System.IO.Path.GetExtension(e.FileName).ToUpper() == ".STL" || System.IO.Path.GetExtension(e.FileName).ToUpper() == ".GCODE")
+
+ if (zipEntry.Name == "manifest.json"
+ || System.IO.Path.GetExtension(zipEntry.Name).ToUpper() == ".STL"
+ || System.IO.Path.GetExtension(zipEntry.Name).ToUpper() == ".GCODE")
{
- e.Extract(stagingFolder, ExtractExistingFileAction.OverwriteSilently);
+ string extractedFileName = Path.Combine(stagingFolder, zipEntry.Name);
+
+ string neededPathForZip = Path.GetDirectoryName(extractedFileName);
+ if (!Directory.Exists(neededPathForZip))
+ {
+ Directory.CreateDirectory(neededPathForZip);
+ }
+
+ Stream zipStream = zip.GetInputStream(zipEntry);
+ using (FileStream streamWriter = File.Create(extractedFileName))
+ {
+ CopyStream(zipStream, streamWriter);
+ }
+
+ if (zipEntry.Name == "manifest.json")
+ {
+ StreamReader sr = new System.IO.StreamReader(extractedFileName);
+ projectManifest = (Project)Newtonsoft.Json.JsonConvert.DeserializeObject(sr.ReadToEnd(), typeof(Project));
+ sr.Close();
+ }
}
}
diff --git a/VersionManagement/WebRequestHandler.cs b/VersionManagement/WebRequestHandler.cs
index 153b567e2..35f54681f 100644
--- a/VersionManagement/WebRequestHandler.cs
+++ b/VersionManagement/WebRequestHandler.cs
@@ -1,27 +1,42 @@
-using System;
+/*
+Copyright (c) 2014, Kevin Pope
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+1. Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+The views and conclusions contained in the software and documentation are those
+of the authors and should not be interpreted as representing official policies,
+either expressed or implied, of the FreeBSD Project.
+*/
+
+using System;
using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-
-using MatterHackers.Agg;
-using MatterHackers.Agg.UI;
-
-using System.Threading;
-
+using System.ComponentModel;
using Newtonsoft.Json;
-using Newtonsoft.Json.Converters;
-using Newtonsoft.Json.Serialization;
-using Newtonsoft.Json.Utilities;
-
-using System.Net;
namespace MatterHackers.MatterControl.VersionManagement
{
-
public class WebRequestBase
{
protected string uri;
- protected JsonResponseDictionary responseValues;
protected Dictionary requestValues;
public event EventHandler RequestSucceeded;
public event EventHandler RequestFailed;
@@ -47,48 +62,54 @@ namespace MatterHackers.MatterControl.VersionManagement
requestValues = new Dictionary();
}
- protected void SendRequest()
+ protected void SendRequest(object sender, DoWorkEventArgs e)
{
+ JsonResponseDictionary responseValues;
+
RequestManager requestManager = new RequestManager();
string jsonToSend = Newtonsoft.Json.JsonConvert.SerializeObject(requestValues);
requestManager.SendPOSTRequest(uri, jsonToSend, "", "", false);
- if (requestManager.LastResponse == null)
- {
- responseValues = new JsonResponseDictionary();
- responseValues["Status"] = "error";
- responseValues["ErrorMessage"] = "Unable to connect to server";
- } else {
- responseValues = JsonConvert.DeserializeObject(requestManager.LastResponse);
- }
- ProcessResponse();
+ if (requestManager.LastResponse == null)
+ {
+ responseValues = new JsonResponseDictionary();
+ responseValues["Status"] = "error";
+ responseValues["ErrorMessage"] = "Unable to connect to server";
+ }
+ else
+ {
+ responseValues = JsonConvert.DeserializeObject(requestManager.LastResponse);
+ }
+
+ e.Result = responseValues;
}
- protected void ProcessResponse()
+ protected void ProcessResponse(object sender, RunWorkerCompletedEventArgs e)
{
- string requestSuccessStatus = this.responseValues.get("Status");
+ JsonResponseDictionary responseValues = e.Result as JsonResponseDictionary;
+
+ string requestSuccessStatus = responseValues.get("Status");
if (responseValues != null && requestSuccessStatus != null && requestSuccessStatus == "success")
{
- ProcessSuccessResponse();
+ ProcessSuccessResponse(responseValues);
OnRequestSuceeded();
}
else
{
- ProcessErrorResponse();
+ ProcessErrorResponse(responseValues);
OnRequestFailed();
}
-
}
- public virtual void ProcessSuccessResponse()
+ public virtual void ProcessSuccessResponse(JsonResponseDictionary responseValues)
{
//Do Stuff
}
- public virtual void ProcessErrorResponse()
+ public virtual void ProcessErrorResponse(JsonResponseDictionary responseValues)
{
- string errorMessage = this.responseValues.get("ErrorMessage");
+ string errorMessage = responseValues.get("ErrorMessage");
if (errorMessage != null)
{
Console.WriteLine(string.Format("Request Failed: {0}", errorMessage));
@@ -100,11 +121,11 @@ namespace MatterHackers.MatterControl.VersionManagement
}
public virtual void Request()
- {
- Thread saveThread = new Thread(SendRequest);
- saveThread.Name = "Check Version";
- saveThread.IsBackground = true;
- saveThread.Start();
+ {
+ BackgroundWorker doRequestWorker = new BackgroundWorker();
+ doRequestWorker.DoWork += new DoWorkEventHandler(SendRequest);
+ doRequestWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(ProcessResponse);
+ doRequestWorker.RunWorkerAsync();
}
}
@@ -128,9 +149,9 @@ namespace MatterHackers.MatterControl.VersionManagement
uri = "https://mattercontrol.appspot.com/api/1/send-print-notification";
}
- public override void ProcessSuccessResponse()
+ public override void ProcessSuccessResponse(JsonResponseDictionary responseValues)
{
- JsonResponseDictionary response = this.responseValues;
+ JsonResponseDictionary response = responseValues;
}
public override void Request()
@@ -167,19 +188,19 @@ namespace MatterHackers.MatterControl.VersionManagement
//To do - move this
class ContactFormRequest : WebRequestBase
{
- public ContactFormRequest(string question,string details,string email, string firstName, string lastName)
+ public ContactFormRequest(string question, string details, string email, string firstName, string lastName)
{
requestValues["FirstName"] = firstName;
requestValues["LastName"] = lastName;
requestValues["Email"] = email;
requestValues["FeedbackType"] = "Question";
- requestValues["Comment"] = string.Format("{0}\n{1}", question,details);
+ requestValues["Comment"] = string.Format("{0}\n{1}", question, details);
uri = "https://mattercontrol.appspot.com/api/1/submit-feedback";
}
- public override void ProcessSuccessResponse()
+ public override void ProcessSuccessResponse(JsonResponseDictionary responseValues)
{
- JsonResponseDictionary response = this.responseValues;
+ JsonResponseDictionary response = responseValues;
}
public override void Request()
@@ -223,21 +244,20 @@ namespace MatterHackers.MatterControl.VersionManagement
uri = "https://mattercontrol.appspot.com/api/1/get-client-consumer-token";
}
- public override void ProcessSuccessResponse()
+ public override void ProcessSuccessResponse(JsonResponseDictionary responseValues)
{
- string clientToken = this.responseValues.get("ClientToken");
+ string clientToken = responseValues.get("ClientToken");
if (clientToken != null)
{
ApplicationSettings.Instance.set("ClientToken", clientToken);
}
}
-
}
class RequestLatestVersion : WebRequestBase
- {
+ {
public RequestLatestVersion()
- {
+ {
requestValues["ProjectToken"] = VersionInfo.Instance.ProjectToken;
requestValues["FeedType"] = "pre-release";
uri = "https://mattercontrol.appspot.com/api/1/get-current-release-version";
@@ -256,7 +276,7 @@ namespace MatterHackers.MatterControl.VersionManagement
{
onClientTokenReady();
}
-
+
}
private void onRequestSucceeded(object sender, EventArgs e)
@@ -274,22 +294,22 @@ namespace MatterHackers.MatterControl.VersionManagement
}
}
- public override void ProcessSuccessResponse()
+ public override void ProcessSuccessResponse(JsonResponseDictionary responseValues)
{
List responseKeys = new List { "CurrentBuildToken", "CurrentBuildNumber", "CurrentBuildUrl", "CurrentReleaseVersion", "CurrentReleaseDate" };
foreach (string key in responseKeys)
{
- saveResponse(key);
+ saveResponse(key, responseValues);
}
}
- private void saveResponse(string key)
+ private void saveResponse(string key, JsonResponseDictionary responseValues)
{
- string value = this.responseValues.get(key);
+ string value = responseValues.get(key);
if (value != null)
{
ApplicationSettings.Instance.set(key, value);
}
}
- }
+ }
}
diff --git a/WidescreenPanel.cs b/WidescreenPanel.cs
index 3658f4d71..650ed7012 100644
--- a/WidescreenPanel.cs
+++ b/WidescreenPanel.cs
@@ -1,5 +1,5 @@
/*
-Copyright (c) 2014, Lars Brubaker
+Copyright (c) 2014, Kevin Pope
All rights reserved.
Redistribution and use in source and binary forms, with or without