Put in more copy write notices

Took out Iconic.Zip.dll
Put in ICSharpCode.SharpZipLib.dll
put the add button next to the edit button in the 3d view controls.
Made web request handler work on a background task rather than a thread
This commit is contained in:
larsbrubaker 2014-03-07 09:50:41 -08:00
parent db8ff174c2
commit 041bd7f599
11 changed files with 273 additions and 143 deletions

View file

@ -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;

BIN
ICSharpCode.SharpZipLib.dll Normal file

Binary file not shown.

Binary file not shown.

View file

@ -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;

View file

@ -191,8 +191,8 @@
<Compile Include="EeProm\EePromRepetierStorage.cs" />
</ItemGroup>
<ItemGroup>
<Reference Include="Ionic.Zip">
<HintPath>Ionic.Zip.dll</HintPath>
<Reference Include="ICSharpCode.SharpZipLib">
<HintPath>.\ICSharpCode.SharpZipLib.dll</HintPath>
</Reference>
<Reference Include="PdfSharp">
<HintPath>PdfSharp.dll</HintPath>

View file

@ -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);
}
}

View file

@ -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<string, List<GuiWidget>> transformControls = new Dictionary<string, List<GuiWidget>>();
@ -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)

View file

@ -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);

View file

@ -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<string, ManifestItem> 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<PrintItem> 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<PrintItem> printItemList = new List<PrintItem>();
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();
}
}
}

View file

@ -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<string, string> requestValues;
public event EventHandler RequestSucceeded;
public event EventHandler RequestFailed;
@ -47,48 +62,54 @@ namespace MatterHackers.MatterControl.VersionManagement
requestValues = new Dictionary<string, string>();
}
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<JsonResponseDictionary>(requestManager.LastResponse);
}
ProcessResponse();
if (requestManager.LastResponse == null)
{
responseValues = new JsonResponseDictionary();
responseValues["Status"] = "error";
responseValues["ErrorMessage"] = "Unable to connect to server";
}
else
{
responseValues = JsonConvert.DeserializeObject<JsonResponseDictionary>(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<string> responseKeys = new List<string> { "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);
}
}
}
}
}

View file

@ -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