diff --git a/AboutPage/UpdateControlData.cs b/AboutPage/UpdateControlData.cs index 15ce3dc6a..4220405bf 100644 --- a/AboutPage/UpdateControlData.cs +++ b/AboutPage/UpdateControlData.cs @@ -168,7 +168,7 @@ namespace MatterHackers.MatterControl if (!WaitingToCompleteTransaction()) { SetUpdateStatus(UpdateStatusStates.CheckingForUpdate); - RequestLatestVersion request = new RequestLatestVersion(); + LatestVersionRequest request = new LatestVersionRequest(); request.RequestSucceeded += new EventHandler(onVersionRequestSucceeded); request.RequestFailed += onVersionRequestFailed; request.Request(); diff --git a/Library/LibraryDataView.cs b/Library/LibraryDataView.cs index 5ac0ef131..3a2776968 100644 --- a/Library/LibraryDataView.cs +++ b/Library/LibraryDataView.cs @@ -400,17 +400,8 @@ namespace MatterHackers.MatterControl.PrintLibrary } } - protected GuiWidget GetThumbnailWidget(bool upFolder, LibraryProvider parentProvider, PrintItemCollection printItemCollection) + protected GuiWidget GetThumbnailWidget(LibraryProvider parentProvider, PrintItemCollection printItemCollection, ImageBuffer imageBuffer) { - string path = Path.Combine("Icons", "FileDialog", "folder.png"); - if (upFolder) - { - path = Path.Combine("Icons", "FileDialog", "upfolder.png"); - } - - ImageBuffer imageBuffer = new ImageBuffer(); - StaticData.Instance.LoadImage(path, imageBuffer); - Vector2 expectedSize = new Vector2((int)(50 * TextWidget.GlobalPointSizeScaleRatio), (int)(50 * TextWidget.GlobalPointSizeScaleRatio)); if (imageBuffer.Width != expectedSize.x) { @@ -451,14 +442,14 @@ namespace MatterHackers.MatterControl.PrintLibrary if (provider != null && provider.ProviderKey != "ProviderSelectorKey") { PrintItemCollection parent = new PrintItemCollection("..", provider.ProviderKey); - LibraryRowItem queueItem = new LibraryRowItemCollection(parent, -1, this, provider.ParentLibraryProvider, GetThumbnailWidget(true, provider.ParentLibraryProvider, parent)); + LibraryRowItem queueItem = new LibraryRowItemCollection(parent, -1, this, provider.ParentLibraryProvider, GetThumbnailWidget(provider.ParentLibraryProvider, parent, LibraryProvider.UpFolderImage)); AddListItemToTopToBottom(queueItem); } for (int i = 0; i < provider.CollectionCount; i++) { PrintItemCollection item = provider.GetCollectionItem(i); - LibraryRowItem queueItem = new LibraryRowItemCollection(item, i, this, null, GetThumbnailWidget(false, null, item)); + LibraryRowItem queueItem = new LibraryRowItemCollection(item, i, this, null, GetThumbnailWidget(null, item, provider.GetCollectionFolderImage(i))); AddListItemToTopToBottom(queueItem); } diff --git a/Library/Provider/LibraryProvider.cs b/Library/Provider/LibraryProvider.cs index 87d3ec49b..716935133 100644 --- a/Library/Provider/LibraryProvider.cs +++ b/Library/Provider/LibraryProvider.cs @@ -28,13 +28,13 @@ either expressed or implied, of the FreeBSD Project. */ using MatterHackers.Agg; +using MatterHackers.Agg.Image; +using MatterHackers.Agg.PlatformAbstract; using MatterHackers.Agg.UI; using MatterHackers.MatterControl.DataStorage; using MatterHackers.MatterControl.PrintQueue; -using MatterHackers.PolygonMesh; using System; using System.Collections.Generic; -using System.ComponentModel; using System.IO; using System.Threading.Tasks; @@ -54,8 +54,6 @@ namespace MatterHackers.MatterControl.PrintLibrary.Provider #region Member Methods - public abstract bool Visible { get; } - public bool HasParent { get @@ -69,6 +67,42 @@ namespace MatterHackers.MatterControl.PrintLibrary.Provider } } + public abstract bool Visible { get; } + + static ImageBuffer normalFolderImage = null; + public static ImageBuffer NormalFolderImage + { + get + { + if (normalFolderImage == null) + { + string path = Path.Combine("Icons", "FileDialog", "folder.png"); + + normalFolderImage = new ImageBuffer(); + StaticData.Instance.LoadImage(path, normalFolderImage); + } + + return normalFolderImage; + } + } + + static ImageBuffer upFolderImage = null; + public static ImageBuffer UpFolderImage + { + get + { + if (upFolderImage == null) + { + string path = Path.Combine("Icons", "FileDialog", "up_folder.png"); + + upFolderImage = new ImageBuffer(); + StaticData.Instance.LoadImage(path, upFolderImage); + } + + return upFolderImage; + } + } + public void AddFilesToLibrary(IList files, ReportProgressRatio reportProgress = null) { foreach (string file in files) @@ -95,10 +129,6 @@ namespace MatterHackers.MatterControl.PrintLibrary.Provider #region Abstract Methods - public abstract void AddItem(PrintItemWrapper itemToAdd); - - public abstract void Dispose(); - public abstract int CollectionCount { get; } public abstract int ItemCount { get; } @@ -113,6 +143,10 @@ namespace MatterHackers.MatterControl.PrintLibrary.Provider public abstract void AddCollectionToLibrary(string collectionName); + public abstract void AddItem(PrintItemWrapper itemToAdd); + + public abstract void Dispose(); + public abstract PrintItemCollection GetCollectionItem(int collectionIndex); public abstract Task GetPrintItemWrapperAsync(int itemIndex, ReportProgressRatio reportProgress = null); @@ -136,6 +170,27 @@ namespace MatterHackers.MatterControl.PrintLibrary.Provider #endregion Static Methods + public virtual int GetCollectionChildCollectionCount(int collectionIndex) + { + return GetProviderForCollection(GetCollectionItem(collectionIndex)).CollectionCount; + } + + public virtual int GetCollectionItemCount(int collectionIndex) + { + return GetProviderForCollection(GetCollectionItem(collectionIndex)).ItemCount; + } + + public virtual ImageBuffer GetCollectionFolderImage(int collectionIndex) + { + return NormalFolderImage; + } + + public virtual GuiWidget GetItemThumbnail(int printItemIndex) + { + var printItemWrapper = GetPrintItemWrapperAsync(printItemIndex).Result; + return new PartThumbnailWidget(printItemWrapper, "part_icon_transparent_40x40.png", "building_thumbnail_40x40.png", PartThumbnailWidget.ImageSizes.Size50x50); + } + public virtual string GetPrintItemName(int itemIndex) { return ""; @@ -150,22 +205,6 @@ namespace MatterHackers.MatterControl.PrintLibrary.Provider { return false; } - - public virtual GuiWidget GetItemThumbnail(int printItemIndex) - { - var printItemWrapper = GetPrintItemWrapperAsync(printItemIndex).Result; - return new PartThumbnailWidget(printItemWrapper, "part_icon_transparent_40x40.png", "building_thumbnail_40x40.png", PartThumbnailWidget.ImageSizes.Size50x50); - } - - public virtual int GetCollectionChildCollectionCount(int collectionIndex) - { - return GetProviderForCollection(GetCollectionItem(collectionIndex)).CollectionCount; - } - - public virtual int GetCollectionItemCount(int collectionIndex) - { - return GetProviderForCollection(GetCollectionItem(collectionIndex)).ItemCount; - } } public class ProviderLocatorNode diff --git a/Library/Provider/LibraryProviderFileSystem.cs b/Library/Provider/LibraryProviderFileSystem.cs index 23e96be57..d93388207 100644 --- a/Library/Provider/LibraryProviderFileSystem.cs +++ b/Library/Provider/LibraryProviderFileSystem.cs @@ -31,11 +31,8 @@ using MatterHackers.Agg; using MatterHackers.Agg.UI; using MatterHackers.MatterControl.DataStorage; using MatterHackers.MatterControl.PrintQueue; -using MatterHackers.PolygonMesh; -using Newtonsoft.Json; using System; using System.Collections.Generic; -using System.ComponentModel; using System.Diagnostics; using System.IO; using System.Threading; @@ -79,21 +76,6 @@ namespace MatterHackers.MatterControl.PrintLibrary.Provider GetFilesAndCollectionsInCurrentDirectory(); } - public override bool Visible - { - get { return true; } - } - - public override void Dispose() - { - directoryWatcher.EnableRaisingEvents = false; - - directoryWatcher.Changed -= DiretoryContentsChanged; - directoryWatcher.Created -= DiretoryContentsChanged; - directoryWatcher.Deleted -= DiretoryContentsChanged; - directoryWatcher.Renamed -= DiretoryContentsChanged; - } - public override int CollectionCount { get @@ -142,6 +124,11 @@ namespace MatterHackers.MatterControl.PrintLibrary.Provider } } + public override bool Visible + { + get { return true; } + } + public override void AddCollectionToLibrary(string collectionName) { string directoryPath = Path.Combine(rootPath, currentDirectory, collectionName); @@ -161,6 +148,16 @@ namespace MatterHackers.MatterControl.PrintLibrary.Provider GetFilesAndCollectionsInCurrentDirectory(); } + public override void Dispose() + { + directoryWatcher.EnableRaisingEvents = false; + + directoryWatcher.Changed -= DiretoryContentsChanged; + directoryWatcher.Created -= DiretoryContentsChanged; + directoryWatcher.Deleted -= DiretoryContentsChanged; + directoryWatcher.Renamed -= DiretoryContentsChanged; + } + public override PrintItemCollection GetCollectionItem(int collectionIndex) { string directoryName = currentDirectoryDirectories[collectionIndex]; @@ -175,7 +172,7 @@ namespace MatterHackers.MatterControl.PrintLibrary.Provider public async override Task GetPrintItemWrapperAsync(int itemIndex, ReportProgressRatio reportProgress = null) { string fileName = currentDirectoryFiles[itemIndex]; - + return new PrintItemWrapper(new DataStorage.PrintItem(Path.GetFileNameWithoutExtension(fileName), fileName), this); } @@ -192,7 +189,7 @@ namespace MatterHackers.MatterControl.PrintLibrary.Provider Stopwatch time = Stopwatch.StartNew(); Directory.Delete(directoryPath, true); // Wait for up to some amount of time for the directory to be gone. - while (Directory.Exists(directoryPath) + while (Directory.Exists(directoryPath) && time.ElapsedMilliseconds < 100) { Thread.Sleep(1); // make sure we are not eating all the cpu time. diff --git a/Library/Provider/LibraryProviderPlugin.cs b/Library/Provider/LibraryProviderPlugin.cs index 86f707bba..b26ff3008 100644 --- a/Library/Provider/LibraryProviderPlugin.cs +++ b/Library/Provider/LibraryProviderPlugin.cs @@ -28,6 +28,7 @@ either expressed or implied, of the FreeBSD Project. */ using MatterHackers.Agg; +using MatterHackers.Agg.Image; using MatterHackers.MatterControl.DataStorage; using MatterHackers.MatterControl.PrintQueue; using System; @@ -38,9 +39,14 @@ namespace MatterHackers.MatterControl.PrintLibrary.Provider { public class LibraryProviderPlugin { - virtual public LibraryProvider CreateLibraryProvider(LibraryProvider parentLibraryProvider) + public virtual LibraryProvider CreateLibraryProvider(LibraryProvider parentLibraryProvider) { throw new NotImplementedException(); } + + public virtual ImageBuffer GetFolderImage() + { + return LibraryProvider.NormalFolderImage; + } } } \ No newline at end of file diff --git a/Library/Provider/LibraryProviderSelector.cs b/Library/Provider/LibraryProviderSelector.cs index f70c39102..d3a174fc9 100644 --- a/Library/Provider/LibraryProviderSelector.cs +++ b/Library/Provider/LibraryProviderSelector.cs @@ -39,6 +39,8 @@ using System.IO; using System.Linq; using MatterHackers.Agg.UI; using System.Threading.Tasks; +using MatterHackers.Agg.Image; +using MatterHackers.Agg.PlatformAbstract; namespace MatterHackers.MatterControl.PrintLibrary.Provider { @@ -53,6 +55,8 @@ namespace MatterHackers.MatterControl.PrintLibrary.Provider private event EventHandler unregisterEvents; + List folderImagesForChildren = new List(); + private LibraryProviderSelector() : base(null) { @@ -62,8 +66,7 @@ namespace MatterHackers.MatterControl.PrintLibrary.Provider // put in the sqlite provider libraryProviders.Add(new LibraryProviderSQLite(null, this)); - //#if __ANDROID__ - //libraryProviders.Add(new LibraryProviderFileSystem(ApplicationDataStorage.Instance.PublicDataStoragePath, "Downloads", this.ProviderKey)); + AddFolderImage("library_folder.png"); // Check for LibraryProvider factories and put them in the list too. PluginFinder libraryProviderPlugins = new PluginFinder(); @@ -77,6 +80,7 @@ namespace MatterHackers.MatterControl.PrintLibrary.Provider } libraryProviders.Add(pluginProvider); + folderImagesForChildren.Add(libraryProviderPlugin.GetFolderImage()); } // and any directory providers (sd card provider, etc...) @@ -85,11 +89,24 @@ namespace MatterHackers.MatterControl.PrintLibrary.Provider if (Directory.Exists(downloadsDirectory)) { libraryProviders.Add(new LibraryProviderFileSystem(downloadsDirectory, "Downloads", this)); + AddFolderImage("download_folder.png"); } this.FilterProviders(); } + private void AddFolderImage(string iconFileName) + { + string libraryIconPath = Path.Combine("Icons", "FileDialog", iconFileName); + ImageBuffer libraryFolderImage = new ImageBuffer(); + StaticData.Instance.LoadImage(libraryIconPath, libraryFolderImage); + folderImagesForChildren.Add(libraryFolderImage); + } + + public override ImageBuffer GetCollectionFolderImage(int collectionIndex) + { + return folderImagesForChildren[collectionIndex]; + } private void FilterProviders() { diff --git a/MatterControl.csproj b/MatterControl.csproj index 91667e4d3..5039b57ca 100644 --- a/MatterControl.csproj +++ b/MatterControl.csproj @@ -325,6 +325,9 @@ + + + diff --git a/StaticData/Icons/FileDialog/cloud_folder.png b/StaticData/Icons/FileDialog/cloud_folder.png new file mode 100644 index 000000000..8ed114993 Binary files /dev/null and b/StaticData/Icons/FileDialog/cloud_folder.png differ diff --git a/StaticData/Icons/FileDialog/download_folder.png b/StaticData/Icons/FileDialog/download_folder.png new file mode 100644 index 000000000..735b476ca Binary files /dev/null and b/StaticData/Icons/FileDialog/download_folder.png differ diff --git a/StaticData/Icons/FileDialog/folder.png b/StaticData/Icons/FileDialog/folder.png index eb893ce7f..de65ae6f3 100644 Binary files a/StaticData/Icons/FileDialog/folder.png and b/StaticData/Icons/FileDialog/folder.png differ diff --git a/StaticData/Icons/FileDialog/library_folder.png b/StaticData/Icons/FileDialog/library_folder.png new file mode 100644 index 000000000..7de97db09 Binary files /dev/null and b/StaticData/Icons/FileDialog/library_folder.png differ diff --git a/StaticData/Icons/FileDialog/purchased_folder.png b/StaticData/Icons/FileDialog/purchased_folder.png new file mode 100644 index 000000000..d9c534df5 Binary files /dev/null and b/StaticData/Icons/FileDialog/purchased_folder.png differ diff --git a/StaticData/Icons/FileDialog/sd_folder.png b/StaticData/Icons/FileDialog/sd_folder.png new file mode 100644 index 000000000..861e473bb Binary files /dev/null and b/StaticData/Icons/FileDialog/sd_folder.png differ diff --git a/StaticData/Icons/FileDialog/up_folder.png b/StaticData/Icons/FileDialog/up_folder.png new file mode 100644 index 000000000..cf4f6086d Binary files /dev/null and b/StaticData/Icons/FileDialog/up_folder.png differ diff --git a/StaticData/Icons/FileDialog/upfolder.png b/StaticData/Icons/FileDialog/upfolder.png deleted file mode 100644 index da990da59..000000000 Binary files a/StaticData/Icons/FileDialog/upfolder.png and /dev/null differ diff --git a/StaticData/OEMSettings/ReleaseNotes.html b/StaticData/OEMSettings/ReleaseNotes.html new file mode 100644 index 000000000..d525d34b3 --- /dev/null +++ b/StaticData/OEMSettings/ReleaseNotes.html @@ -0,0 +1,193 @@ +
+

On this page you can find a brief description about what is new in each release of MatterControl.  The version number shown is for the official MatterHackers release - the release numbers for specific manufacturers may vary.

+

1.3.0 (June, 23, 2015)

+
    +
  • + New Features:
      +
    • Auto arrange has been improved
    • +
    • Added profiles for MakerGear, PrintSpace, Huxley
    • +
    • Adding TouchScreen mode for tablets
    • +
    • Support for ATX power hardware
    • +
    • Improved Basic and Standard UI settings
    • +
    • Perimeters, Bottom and Top layers can all be set in millimeters.
    • +
    • Perimeters can now be printed outer layer first or last.
    • +
    +
  • +
  • + Minor Changes:
      +
    • Updated Lulzbot settings
    • +
    • Added tool change g-code
    • +
    • Added crash reporting to alpha and beta channels
    • +
    • Better default printer naming
    • +
    • Fixed slicing problems with very complex models during top and bottom layer creation.
    • +
    +
  • +
+

1.2.2 (March, 6, 2015)

+
    +
  • PC Download
  • +
  • Mac Download
  • +
  • + New Features:
      +
    • Improved printer connection stability
    • +
    • Updated Serial Driver for RAMPS
    • +
    • Added profiles for Revolution 3D, Solidoodle
    • +
    • Added hexagon infill
    • +
    • Added the ability to turn on 'Reset Connection' works as an e-stop
    • +
    +
  • +
  • + Minor Changes:
      +
    • Bug fixes
    • +
    • Better memory reporting and stability
    • +
    • Fixed a bug with temp being set repeatedly
    • +
    • Using sub-modules (easier to build from GitHub)
    • +
    +
  • +
+

1.2.1 (January, 28, 2015)

+
    +
  • PC Download
  • +
  • Mac Download
  • +
  • + New Features:
      +
    • Pop Out Windows - now you can show settings and controls all the time
    • +
    • Ability to send parts to other computers and MatterControl Touch
    • +
    • We now display a big 3D view on startup
    • +
    • Better connection handling
    • +
    • Support for many more printers
    • +
    • Added a Simple mode to slice settings
    • +
    +
  • +
  • + Minor Changes:
      +
    • External Perimeter First slice setting
    • +
    • Improved edge detection during slicing
    • +
    • Select Raft Extruder
    • +
    • Vertical offsets in edit mode
    • +
    • Faster editing of models
    • +
    • More accurate gcode generation
    • +
    • More accurate support angles
    • +
    • Better slice settings help and defaults
    • +
    • Fixed some very obscure errors with Print Leveling being too high sometimes
    • +
    • Better detection of co-linear edges (highly tessellated round things work better)
    • +
    +
  • +
+

1.2 (November, 19, 2014)

+
    +
  • PC Download
  • +
  • Mac Download
  • +
  • + New Features:
      +
    • Dual-Extrusion Support
    • +
    • Simple Multi-Material Workflow
    • +
    • Advanced Support Material Generation
    • +
    • New Touch-Friendly UI
    • +
    • Signed Windows Drivers (no more Windows 8 pain)
    • +
    • AMF support
    • +
    +
  • +
  • + Minor Changes:
      +
    • Improved Pausing (remembers and returns to pause position)
    • +
    • Support for @pause and M226 (user requested pause from gcode)
    • +
    • + MatterSlice
        +
      • Skirt always draws from the outside
      • +
      +
    • +
    +
  • +
+

1.1.3 (August 8, 2014)

+
    +
  • PC Download, last XP compatible build
  • +
  • Mac Download
  • +
  • + New Features:
      +
    • Updated to Slic3r 1.1.7
    • +
    • + MatterSlice significantly improved
        +
      • Support can now have interface layers
      • +
      • Many bugs and performance improvements
      • +
      +
    • +
    • New 3D Display options (outline view)
    • +
    • MakerBot X3G support now available (beta)
    • +
    • Added Turkish translation
    • +
    +
  • +
  • + Minor Changes:
      +
    • Make sure the 3D views always match the current printer size and shape
    • +
    • Improved 3D GCode view (more display options)
    • +
    • Faster Mesh and GCode loading
    • +
    • New driver for RoBo3D
    • +
    • Made smoothie boards work better
    • +
    +
  • +
+

1.1.2 (July 22, 2014)

+
    +
  • + New Features:
      +
    • 3D GCode View
    • +
    • Cloud Monitoring: While logged in, printer status viewable from the web
    • +
    • SD Card Support: Allows you to print from and view/edit the contents of the on-board SD Card
    • +
    • Triangle infill in MatterSlice, for incredibly strong parts
    • +
    +
  • +
  • + Minor Changes
    +
      +
    • Minor UI fixes (ex. added scrollbars to slice presets)
    • +
    • Added 'Preheat' temperature preset - sets temp to current slice settings
    • +
    • Fixed slice implementation of Raft settings. It was not putting in correct spacing
    • +
    • Fixed issue with update download not starting.
    • +
    • Fixed issue with auto-connect causing start-up crash (on printrboards specifically)
    • +
    +
  • +
+

1.1.1 (May 27, 2014)

+
    +
  • + New Features:
      +
    • New Advanced Raft in MatterSlice
    • +
    • GCode playback during printing
    • +
    +
  • +
  • + Minor Changes
      +
    • Independent Axis Scaling Improved
    • +
    • Fixed a bug in Macros being sent in reverse order
    • +
    • Better international support (
    • +
    • Bug fixes and performance improvements
    • +
    +
  • +
+

1.1.0 (May 14, 2014)

+
    +
  • + New Features:
      +
    • MatterSlice : A new high quality, high speed slicing engine by MatterHackers
    • +
    • Material/Quality Presets : Layers settings to that modify the base settings
    • +
    • Widescreen Mode
    • +
    • Expanded Themes
    • +
    • Image Converter : A new tool that lets you change images into printable models
    • +
    • Print History updates and improvements
    • +
    +
  • +
  • + Minor Changes
      +
    • Pause, cancel, resume functionality can now be assigned custom gcode.
    • +
    • Added visualization for retraction and partial path viewing to gcode view.
    • +
    • When parts are repositioned in the plate editor, the offsets are now preserved.
    • +
    • Localization support has been added. We'll be integrating translations as they become available.
    • +
    • Saving part file edits is now significantly faster.
    • +
    • Loading images is now faster (uses caching).
    • +
    • Many bug fixes and performance improvements
    • +
    +
  • +
+
diff --git a/StaticData/Translations/Master.txt b/StaticData/Translations/Master.txt index 930b733ff..89307ce50 100644 --- a/StaticData/Translations/Master.txt +++ b/StaticData/Translations/Master.txt @@ -3424,3 +3424,6 @@ Translated:The folder '{0}' is not empty.\n\nWould you like to delete it anyway? English:Delete folder? Translated:Delete folder? +English:Cloud Library +Translated:Cloud Library + diff --git a/VersionManagement/ClientTokenRequest.cs b/VersionManagement/ClientTokenRequest.cs new file mode 100644 index 000000000..7b3ba4f9c --- /dev/null +++ b/VersionManagement/ClientTokenRequest.cs @@ -0,0 +1,57 @@ +/* +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 MatterHackers.Localizations; +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Threading.Tasks; + +namespace MatterHackers.MatterControl.VersionManagement +{ + public class ClientTokenRequest : WebRequestBase + { + public ClientTokenRequest() + { + requestValues["RequestToken"] = "ekshdsd5d5ssss5kels"; + requestValues["ProjectToken"] = VersionInfo.Instance.ProjectToken; + uri = "https://mattercontrol.appspot.com/api/1/get-client-consumer-token"; + } + + public override void ProcessSuccessResponse(JsonResponseDictionary responseValues) + { + string clientToken = responseValues.get("ClientToken"); + if (clientToken != null) + { + ApplicationSettings.Instance.set("ClientToken", clientToken); + } + } + } +} \ No newline at end of file diff --git a/VersionManagement/ContactFormRequest.cs b/VersionManagement/ContactFormRequest.cs new file mode 100644 index 000000000..61d1a67a7 --- /dev/null +++ b/VersionManagement/ContactFormRequest.cs @@ -0,0 +1,87 @@ +/* +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 MatterHackers.Localizations; +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Threading.Tasks; + +namespace MatterHackers.MatterControl.VersionManagement +{ + //To do - move this + internal class ContactFormRequest : WebRequestBase + { + 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); + uri = "https://mattercontrol.appspot.com/api/1/submit-feedback"; + } + + public override void ProcessSuccessResponse(JsonResponseDictionary responseValues) + { + JsonResponseDictionary response = responseValues; + } + + public override void Request() + { + //If the client token exists, use it, otherwise wait for client token before making request + if (ApplicationSettings.Instance.get("ClientToken") == null) + { + ClientTokenRequest request = new ClientTokenRequest(); + request.RequestSucceeded += new EventHandler(onClientTokenRequestSucceeded); + request.Request(); + } + else + { + onClientTokenReady(); + } + } + + private void onClientTokenRequestSucceeded(object sender, EventArgs e) + { + onClientTokenReady(); + } + + public void onClientTokenReady() + { + string clientToken = ApplicationSettings.Instance.get("ClientToken"); + requestValues["ClientToken"] = clientToken; + if (clientToken != null) + { + base.Request(); + } + } + } +} \ No newline at end of file diff --git a/VersionManagement/LatestVersionRequest.cs b/VersionManagement/LatestVersionRequest.cs new file mode 100644 index 000000000..85d3a8e0e --- /dev/null +++ b/VersionManagement/LatestVersionRequest.cs @@ -0,0 +1,102 @@ +/* +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 MatterHackers.Localizations; +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Threading.Tasks; + +namespace MatterHackers.MatterControl.VersionManagement +{ + internal class LatestVersionRequest : WebRequestBase + { + public LatestVersionRequest() + { + string feedType = UserSettings.Instance.get("UpdateFeedType"); + if (feedType == null) + { + feedType = "release"; + UserSettings.Instance.set("UpdateFeedType", feedType); + } + requestValues["ProjectToken"] = VersionInfo.Instance.ProjectToken; + requestValues["UpdateFeedType"] = feedType; + uri = "https://mattercontrol.appspot.com/api/1/get-current-release-version"; + } + + public override void Request() + { + //If the client token exists, use it, otherwise wait for client token before making request + if (ApplicationSettings.Instance.get("ClientToken") == null) + { + ClientTokenRequest request = new ClientTokenRequest(); + request.RequestSucceeded += new EventHandler(onRequestSucceeded); + request.Request(); + } + else + { + onClientTokenReady(); + } + } + + private void onRequestSucceeded(object sender, EventArgs e) + { + onClientTokenReady(); + } + + public void onClientTokenReady() + { + string clientToken = ApplicationSettings.Instance.get("ClientToken"); + requestValues["ClientToken"] = clientToken; + if (clientToken != null) + { + base.Request(); + } + } + + public override void ProcessSuccessResponse(JsonResponseDictionary responseValues) + { + List responseKeys = new List { "CurrentBuildToken", "CurrentBuildNumber", "CurrentBuildUrl", "CurrentReleaseVersion", "CurrentReleaseDate" }; + foreach (string key in responseKeys) + { + saveResponse(key, responseValues); + } + } + + private void saveResponse(string key, JsonResponseDictionary responseValues) + { + string value = responseValues.get(key); + if (value != null) + { + ApplicationSettings.Instance.set(key, value); + } + } + } +} \ No newline at end of file diff --git a/VersionManagement/VersionFileHandler.cs b/VersionManagement/VersionFileHandler.cs index c6e98b561..f79f7281d 100644 --- a/VersionManagement/VersionFileHandler.cs +++ b/VersionManagement/VersionFileHandler.cs @@ -1,4 +1,33 @@ -using MatterHackers.Agg.PlatformAbstract; +/* +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 MatterHackers.Agg.PlatformAbstract; using System.IO; namespace MatterHackers.MatterControl diff --git a/VersionManagement/WebRequestHandler.cs b/VersionManagement/WebRequestHandler.cs index 0490902f2..f88c78df1 100644 --- a/VersionManagement/WebRequestHandler.cs +++ b/VersionManagement/WebRequestHandler.cs @@ -46,7 +46,7 @@ namespace MatterHackers.MatterControl.VersionManagement public ResponseType ResponseItem { get; set; } } - public class WebRequestBase where ResponseType : class + public class WebRequestBase where ResponseType : class { protected string uri; protected Dictionary requestValues; @@ -142,7 +142,6 @@ namespace MatterHackers.MatterControl.VersionManagement } } - public class WebRequestBase { protected string uri; @@ -304,136 +303,4 @@ namespace MatterHackers.MatterControl.VersionManagement tempRequest.Request(); } } - - //To do - move this - internal class ContactFormRequest : WebRequestBase - { - 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); - uri = "https://mattercontrol.appspot.com/api/1/submit-feedback"; - } - - public override void ProcessSuccessResponse(JsonResponseDictionary responseValues) - { - JsonResponseDictionary response = responseValues; - } - - public override void Request() - { - //If the client token exists, use it, otherwise wait for client token before making request - if (ApplicationSettings.Instance.get("ClientToken") == null) - { - RequestClientToken request = new RequestClientToken(); - request.RequestSucceeded += new EventHandler(onClientTokenRequestSucceeded); - request.Request(); - } - else - { - onClientTokenReady(); - } - } - - private void onClientTokenRequestSucceeded(object sender, EventArgs e) - { - onClientTokenReady(); - } - - public void onClientTokenReady() - { - string clientToken = ApplicationSettings.Instance.get("ClientToken"); - requestValues["ClientToken"] = clientToken; - if (clientToken != null) - { - base.Request(); - } - } - } - - public class RequestClientToken : WebRequestBase - { - public RequestClientToken() - { - requestValues["RequestToken"] = "ekshdsd5d5ssss5kels"; - requestValues["ProjectToken"] = VersionInfo.Instance.ProjectToken; - uri = "https://mattercontrol.appspot.com/api/1/get-client-consumer-token"; - } - - public override void ProcessSuccessResponse(JsonResponseDictionary responseValues) - { - string clientToken = responseValues.get("ClientToken"); - if (clientToken != null) - { - ApplicationSettings.Instance.set("ClientToken", clientToken); - } - } - } - - internal class RequestLatestVersion : WebRequestBase - { - public RequestLatestVersion() - { - string feedType = UserSettings.Instance.get("UpdateFeedType"); - if (feedType == null) - { - feedType = "release"; - UserSettings.Instance.set("UpdateFeedType", feedType); - } - requestValues["ProjectToken"] = VersionInfo.Instance.ProjectToken; - requestValues["UpdateFeedType"] = feedType; - uri = "https://mattercontrol.appspot.com/api/1/get-current-release-version"; - } - - public override void Request() - { - //If the client token exists, use it, otherwise wait for client token before making request - if (ApplicationSettings.Instance.get("ClientToken") == null) - { - RequestClientToken request = new RequestClientToken(); - request.RequestSucceeded += new EventHandler(onRequestSucceeded); - request.Request(); - } - else - { - onClientTokenReady(); - } - } - - private void onRequestSucceeded(object sender, EventArgs e) - { - onClientTokenReady(); - } - - public void onClientTokenReady() - { - string clientToken = ApplicationSettings.Instance.get("ClientToken"); - requestValues["ClientToken"] = clientToken; - if (clientToken != null) - { - base.Request(); - } - } - - public override void ProcessSuccessResponse(JsonResponseDictionary responseValues) - { - List responseKeys = new List { "CurrentBuildToken", "CurrentBuildNumber", "CurrentBuildUrl", "CurrentReleaseVersion", "CurrentReleaseDate" }; - foreach (string key in responseKeys) - { - saveResponse(key, responseValues); - } - } - - private void saveResponse(string key, JsonResponseDictionary responseValues) - { - string value = responseValues.get(key); - if (value != null) - { - ApplicationSettings.Instance.set(key, value); - } - } - } } \ No newline at end of file