From 405b8be6bcdcb717f07e20e68cc31600274d8449 Mon Sep 17 00:00:00 2001 From: larsbrubaker Date: Fri, 4 Apr 2014 18:52:51 -0700 Subject: [PATCH] Making for of the 3d view reusable for all places that are implementing redundant stuff. Getting rid of dead code. Getting rid of warnings --- AboutPage/AboutPage.cs | 21 --- ActionBar/PrintActionRow.cs | 2 +- ApplicationView/CompactSlidePanel.cs | 1 - ConfigurationPage/ConfigurationPage.cs | 4 - ControlElements/TextImageButtonFactory.cs | 25 ++- CustomWidgets/PartThumbnailWidget.cs | 1 - EeProm/EePromMarlinWidget.cs | 3 - MatterControl.csproj | 6 +- .../BaseClasses/PartPreview3DWidget.cs | 113 ++++++++++++ .../PartPreviewWidget.cs} | 40 ++++- PartPreviewWindow/GcodeViewBasic.cs | 34 +--- PartPreviewWindow/PartPreviewMainWindow.cs | 1 - PartPreviewWindow/View3DTransfromPart.cs | 75 +------- PrintHistory/PrintHistoryListControl.cs | 2 - PrintLibrary/PrintLibraryListItem.cs | 1 - PrintQueue/ExportToSdCardProcess.cs | 168 ------------------ PrinterCommunication/PrinterCommunication.cs | 2 +- PrinterControls/EditLevelingSettingsWindow.cs | 2 - PrinterControls/EditMacrosWindow.cs | 1 - 19 files changed, 175 insertions(+), 327 deletions(-) create mode 100644 PartPreviewWindow/BaseClasses/PartPreview3DWidget.cs rename PartPreviewWindow/{PartPreviewBaseWidget.cs => BaseClasses/PartPreviewWidget.cs} (72%) delete mode 100644 PrintQueue/ExportToSdCardProcess.cs diff --git a/AboutPage/AboutPage.cs b/AboutPage/AboutPage.cs index 495882bb8..5986cd5de 100644 --- a/AboutPage/AboutPage.cs +++ b/AboutPage/AboutPage.cs @@ -584,29 +584,8 @@ namespace MatterHackers.MatterControl } - bool firstDraw = true; public override void OnDraw(Graphics2D graphics2D) { -#if false - if (firstDraw) - { - firstDraw = false; - SystemWindow testAbout = new SystemWindow(600, 300); - - string path = Path.Combine(ApplicationDataStorage.Instance.ApplicationStaticDataPath, "OEMSettings", "AboutPage.html"); - string htmlText = File.ReadAllText(path); - HTMLCanvas canvas = new HTMLCanvas(htmlText); - canvas.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor; - - canvas.AddReplacementString("textColor", RGBA_Bytes.White.GetAsHTMLString()); - - canvas.AnchorAll(); - testAbout.AddChild(canvas); - - testAbout.ShowAsSystemWindow(); - } -#endif - graphics2D.FillRectangle(new RectangleDouble(0, this.Height - 1, this.Width, this.Height), ActiveTheme.Instance.PrimaryTextColor); base.OnDraw(graphics2D); } diff --git a/ActionBar/PrintActionRow.cs b/ActionBar/PrintActionRow.cs index da88e5850..483e0f6a9 100644 --- a/ActionBar/PrintActionRow.cs +++ b/ActionBar/PrintActionRow.cs @@ -48,7 +48,7 @@ namespace MatterHackers.MatterControl.ActionBar textImageButtonFactory.disabledTextColor = RGBA_Bytes.LightGray; textImageButtonFactory.hoverTextColor = RGBA_Bytes.White; textImageButtonFactory.pressedTextColor = RGBA_Bytes.White; - textImageButtonFactory.invertImageColor = false; + textImageButtonFactory.AllowThemeToAdjustImage = false; textImageButtonFactory.borderWidth = -1; textImageButtonFactory.disabledFillColor = ActiveTheme.Instance.PrimaryAccentColor; diff --git a/ApplicationView/CompactSlidePanel.cs b/ApplicationView/CompactSlidePanel.cs index 12ee1392b..42ca2c4d6 100644 --- a/ApplicationView/CompactSlidePanel.cs +++ b/ApplicationView/CompactSlidePanel.cs @@ -52,7 +52,6 @@ namespace MatterHackers.MatterControl { public class CompactSlidePanel : SlidePanel { - SimpleTextTabWidget aboutTabView; TabControl advancedControlsTabControl; TabControl mainControlsTabControl; SliceSettingsWidget sliceSettingsWidget; diff --git a/ConfigurationPage/ConfigurationPage.cs b/ConfigurationPage/ConfigurationPage.cs index 9a55b7ef0..215405fcd 100644 --- a/ConfigurationPage/ConfigurationPage.cs +++ b/ConfigurationPage/ConfigurationPage.cs @@ -282,10 +282,6 @@ namespace MatterHackers.MatterControl return topLine; } - NumberEdit feedRateValue; - Slider feedRateRatioSlider; - Slider extrusionRatioSlider; - NumberEdit extrusionValue; PrintLevelWizardWindow printLevelWizardWindow; public override void OnClosed(EventArgs e) diff --git a/ControlElements/TextImageButtonFactory.cs b/ControlElements/TextImageButtonFactory.cs index 43b4e906b..0a540d6c5 100644 --- a/ControlElements/TextImageButtonFactory.cs +++ b/ControlElements/TextImageButtonFactory.cs @@ -154,7 +154,7 @@ namespace MatterHackers.MatterControl public int fontSize = 12; public double borderWidth = 1; public bool invertImageLocation = false; - public bool invertImageColor = true; + public bool AllowThemeToAdjustImage = true; FlowDirection flowDirection; public int FixedWidth = 0; public int FixedHeight = 40; @@ -288,7 +288,7 @@ namespace MatterHackers.MatterControl if (normalImageName != null) { ImageIO.LoadImageData(this.GetImageLocation(normalImageName), normalImage); - if (!ActiveTheme.Instance.IsDarkTheme && invertImageColor) + if (!ActiveTheme.Instance.IsDarkTheme && AllowThemeToAdjustImage) { InvertLightness.DoInvertLightness(normalImage); } @@ -297,7 +297,7 @@ namespace MatterHackers.MatterControl if (hoverImageName != null) { ImageIO.LoadImageData(this.GetImageLocation(pressedImageName), pressedImage); - if (!ActiveTheme.Instance.IsDarkTheme && invertImageColor) + if (!ActiveTheme.Instance.IsDarkTheme && AllowThemeToAdjustImage) { InvertLightness.DoInvertLightness(pressedImage); } @@ -306,7 +306,7 @@ namespace MatterHackers.MatterControl if (pressedImageName != null) { ImageIO.LoadImageData(this.GetImageLocation(hoverImageName), hoverImage); - if (!ActiveTheme.Instance.IsDarkTheme && invertImageColor) + if (!ActiveTheme.Instance.IsDarkTheme && AllowThemeToAdjustImage) { InvertLightness.DoInvertLightness(hoverImage); } @@ -315,7 +315,7 @@ namespace MatterHackers.MatterControl if (disabledImageName != null) { ImageIO.LoadImageData(this.GetImageLocation(disabledImageName), disabledImage); - if (!ActiveTheme.Instance.IsDarkTheme && invertImageColor) + if (!ActiveTheme.Instance.IsDarkTheme && AllowThemeToAdjustImage) { InvertLightness.DoInvertLightness(disabledImage); } @@ -368,16 +368,11 @@ namespace MatterHackers.MatterControl pressedToNormalImageName = normalImageName; } - if (normalImageName == "icon_arrow_right_no_border_32x32.png") - { - int a = 0; - } - if (normalImageName != null) { ImageIO.LoadImageData(this.GetImageLocation(normalImageName), normalImage); - if (!ActiveTheme.Instance.IsDarkTheme && invertImageColor) + if (!ActiveTheme.Instance.IsDarkTheme && AllowThemeToAdjustImage) { InvertLightness.DoInvertLightness(normalImage); } @@ -386,7 +381,7 @@ namespace MatterHackers.MatterControl if (pressedImageName != null) { ImageIO.LoadImageData(this.GetImageLocation(pressedImageName), pressedImage); - if (!ActiveTheme.Instance.IsDarkTheme && invertImageColor) + if (!ActiveTheme.Instance.IsDarkTheme && AllowThemeToAdjustImage) { InvertLightness.DoInvertLightness(pressedImage); } @@ -396,7 +391,7 @@ namespace MatterHackers.MatterControl if (normalToPressedImageName != null) { ImageIO.LoadImageData(this.GetImageLocation(normalToPressedImageName), normalToPressedImage); - if (!ActiveTheme.Instance.IsDarkTheme && invertImageColor) + if (!ActiveTheme.Instance.IsDarkTheme && AllowThemeToAdjustImage) { InvertLightness.DoInvertLightness(normalToPressedImage); } @@ -405,7 +400,7 @@ namespace MatterHackers.MatterControl if (pressedToNormalImageName != null) { ImageIO.LoadImageData(this.GetImageLocation(pressedToNormalImageName), pressedToNormalImage); - if (!ActiveTheme.Instance.IsDarkTheme && invertImageColor) + if (!ActiveTheme.Instance.IsDarkTheme && AllowThemeToAdjustImage) { InvertLightness.DoInvertLightness(pressedToNormalImage); } @@ -443,7 +438,7 @@ namespace MatterHackers.MatterControl { iconImage = new ImageBuffer(); ImageIO.LoadImageData(this.GetImageLocation(iconImageName), iconImage); - if (!ActiveTheme.Instance.IsDarkTheme && invertImageColor) + if (!ActiveTheme.Instance.IsDarkTheme && AllowThemeToAdjustImage) { InvertLightness.DoInvertLightness(iconImage); } diff --git a/CustomWidgets/PartThumbnailWidget.cs b/CustomWidgets/PartThumbnailWidget.cs index a2ba455c8..d9a4a83b7 100644 --- a/CustomWidgets/PartThumbnailWidget.cs +++ b/CustomWidgets/PartThumbnailWidget.cs @@ -78,7 +78,6 @@ namespace MatterHackers.MatterControl ImageBuffer image = new Agg.Image.ImageBuffer(); // all te color stuff - public double BorderWidth = 0; protected double borderRadius = 0; protected RGBA_Bytes HoverBorderColor = new RGBA_Bytes(); diff --git a/EeProm/EePromMarlinWidget.cs b/EeProm/EePromMarlinWidget.cs index ffeb2149a..edee6bcdd 100644 --- a/EeProm/EePromMarlinWidget.cs +++ b/EeProm/EePromMarlinWidget.cs @@ -41,7 +41,6 @@ namespace MatterHackers.MatterControl.EeProm public partial class EePromMarlinWidget : SystemWindow { EePromMarlinSettings currentEePromSettings; - bool reinit = true; MHNumberEdit stepsPerMmX; MHNumberEdit stepsPerMmY; @@ -307,13 +306,11 @@ namespace MatterHackers.MatterControl.EeProm private void buttonReLoadSettings_Click(object sender, EventArgs e) { - reinit = false; currentEePromSettings.Update(); } private void SetToFactorySettings(object sender, EventArgs e) { - reinit = true; currentEePromSettings.SetPrinterToFactorySettings(); currentEePromSettings.Update(); } diff --git a/MatterControl.csproj b/MatterControl.csproj index e04c0367c..9620344ed 100644 --- a/MatterControl.csproj +++ b/MatterControl.csproj @@ -57,7 +57,7 @@ TRACE prompt 4 - x86 + AnyCPU true @@ -77,6 +77,7 @@ + @@ -93,7 +94,7 @@ - + @@ -107,7 +108,6 @@ - diff --git a/PartPreviewWindow/BaseClasses/PartPreview3DWidget.cs b/PartPreviewWindow/BaseClasses/PartPreview3DWidget.cs new file mode 100644 index 000000000..be40e2ee7 --- /dev/null +++ b/PartPreviewWindow/BaseClasses/PartPreview3DWidget.cs @@ -0,0 +1,113 @@ +/* +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; +using System.IO; + +using MatterHackers.Agg; +using MatterHackers.Agg.Image; +using MatterHackers.Agg.UI; +using MatterHackers.Agg.OpenGlGui; +using MatterHackers.PolygonMesh; +using MatterHackers.RenderOpenGl; +using MatterHackers.VectorMath; +using MatterHackers.MatterControl.DataStorage; +using MatterHackers.MatterControl.PrintQueue; +using MatterHackers.MeshVisualizer; + +namespace MatterHackers.MatterControl.PartPreviewWindow +{ + public class PartPreview3DWidget : PartPreviewWidget + { + protected MeshViewerWidget meshViewerWidget; + + public PartPreview3DWidget() + { + } + + protected void Add3DViewControls() + { + FlowLayoutWidget transformTypeSelector = new FlowLayoutWidget(); + transformTypeSelector.BackgroundColor = new RGBA_Bytes(0, 0, 0, 120); + textImageButtonFactory.FixedHeight = 20; + textImageButtonFactory.FixedWidth = 20; + textImageButtonFactory.AllowThemeToAdjustImage = false; + + string rotateIconPath = Path.Combine("Icons", "ViewTransformControls", "rotate.png"); + rotateViewButton = textImageButtonFactory.GenerateRadioButton("", rotateIconPath); + rotateViewButton.Margin = new BorderDouble(3); + transformTypeSelector.AddChild(rotateViewButton); + rotateViewButton.Click += (sender, e) => + { + meshViewerWidget.TrackballTumbleWidget.TransformState = TrackBallController.MouseDownType.Rotation; + }; + + string translateIconPath = Path.Combine("Icons", "ViewTransformControls", "translate.png"); + RadioButton translateButton = textImageButtonFactory.GenerateRadioButton("", translateIconPath); + translateButton.Margin = new BorderDouble(3); + transformTypeSelector.AddChild(translateButton); + translateButton.Click += (sender, e) => + { + meshViewerWidget.TrackballTumbleWidget.TransformState = TrackBallController.MouseDownType.Translation; + }; + + string scaleIconPath = Path.Combine("Icons", "ViewTransformControls", "scale.png"); + RadioButton scaleButton = textImageButtonFactory.GenerateRadioButton("", scaleIconPath); + scaleButton.Margin = new BorderDouble(3); + transformTypeSelector.AddChild(scaleButton); + scaleButton.Click += (sender, e) => + { + meshViewerWidget.TrackballTumbleWidget.TransformState = TrackBallController.MouseDownType.Scale; + }; + + viewControlsSeparator = new GuiWidget(2, 32); + viewControlsSeparator.BackgroundColor = RGBA_Bytes.White; + viewControlsSeparator.Margin = new BorderDouble(3); + transformTypeSelector.AddChild(viewControlsSeparator); + + string partSelectIconPath = Path.Combine("Icons", "ViewTransformControls", "partSelect.png"); + partSelectButton = textImageButtonFactory.GenerateRadioButton("", partSelectIconPath); + partSelectButton.Margin = new BorderDouble(3); + transformTypeSelector.AddChild(partSelectButton); + partSelectButton.Click += (sender, e) => + { + meshViewerWidget.TrackballTumbleWidget.TransformState = TrackBallController.MouseDownType.None; + }; + + transformTypeSelector.Margin = new BorderDouble(5); + transformTypeSelector.HAnchor |= Agg.UI.HAnchor.ParentLeft; + transformTypeSelector.VAnchor = Agg.UI.VAnchor.ParentTop; + AddChild(transformTypeSelector); + rotateViewButton.Checked = true; + } + } +} diff --git a/PartPreviewWindow/PartPreviewBaseWidget.cs b/PartPreviewWindow/BaseClasses/PartPreviewWidget.cs similarity index 72% rename from PartPreviewWindow/PartPreviewBaseWidget.cs rename to PartPreviewWindow/BaseClasses/PartPreviewWidget.cs index bff396e17..c344d7845 100644 --- a/PartPreviewWindow/PartPreviewBaseWidget.cs +++ b/PartPreviewWindow/BaseClasses/PartPreviewWidget.cs @@ -45,14 +45,23 @@ using MatterHackers.MatterControl.PrintQueue; namespace MatterHackers.MatterControl.PartPreviewWindow { - public class PartPreviewBaseWidget : GuiWidget + public class PartPreviewWidget : GuiWidget { protected TextImageButtonFactory textImageButtonFactory = new TextImageButtonFactory(); protected TextImageButtonFactory checkboxButtonFactory = new TextImageButtonFactory(); protected TextImageButtonFactory expandMenuOptionFactory = new TextImageButtonFactory(); protected TextImageButtonFactory whiteButtonFactory = new TextImageButtonFactory(); - public PartPreviewBaseWidget() + protected RadioButton partSelectButton; + protected RadioButton translateButton; + protected RadioButton rotateViewButton; + protected RadioButton scaleButton; + protected GuiWidget viewControlsSeparator; + + protected Cover buttonRightPanelDisabledCover; + protected FlowLayoutWidget buttonRightPanel; + + public PartPreviewWidget() { textImageButtonFactory.normalTextColor = ActiveTheme.Instance.PrimaryTextColor; textImageButtonFactory.hoverTextColor = ActiveTheme.Instance.PrimaryTextColor; @@ -94,5 +103,32 @@ namespace MatterHackers.MatterControl.PartPreviewWindow BackgroundColor = RGBA_Bytes.White; } + + protected void Add2DViewControls() + { + TextImageButtonFactory iconTextImageButtonFactory = new TextImageButtonFactory(); + iconTextImageButtonFactory.AllowThemeToAdjustImage = false; + + FlowLayoutWidget transformTypeSelector = new FlowLayoutWidget(); + transformTypeSelector.BackgroundColor = new RGBA_Bytes(0, 0, 0, 120); + iconTextImageButtonFactory.FixedHeight = 20; + iconTextImageButtonFactory.FixedWidth = 20; + + string translateIconPath = Path.Combine("Icons", "ViewTransformControls", "translate.png"); + translateButton = iconTextImageButtonFactory.GenerateRadioButton("", translateIconPath); + translateButton.Margin = new BorderDouble(3); + transformTypeSelector.AddChild(translateButton); + + string scaleIconPath = Path.Combine("Icons", "ViewTransformControls", "scale.png"); + scaleButton = iconTextImageButtonFactory.GenerateRadioButton("", scaleIconPath); + scaleButton.Margin = new BorderDouble(3); + transformTypeSelector.AddChild(scaleButton); + + transformTypeSelector.Margin = new BorderDouble(5); + transformTypeSelector.HAnchor |= Agg.UI.HAnchor.ParentLeft; + transformTypeSelector.VAnchor = Agg.UI.VAnchor.ParentTop; + AddChild(transformTypeSelector); + translateButton.Checked = true; + } } } diff --git a/PartPreviewWindow/GcodeViewBasic.cs b/PartPreviewWindow/GcodeViewBasic.cs index 45000f832..f960709d8 100644 --- a/PartPreviewWindow/GcodeViewBasic.cs +++ b/PartPreviewWindow/GcodeViewBasic.cs @@ -51,7 +51,7 @@ using MatterHackers.Localizations; namespace MatterHackers.MatterControl.PartPreviewWindow { - public class GcodeViewBasic : PartPreviewBaseWidget + public class GcodeViewBasic : PartPreviewWidget { public Slider selectLayerSlider; public Slider layerStartRenderRatioSlider; @@ -64,7 +64,6 @@ namespace MatterHackers.MatterControl.PartPreviewWindow Button generateGCodeButton; FlowLayoutWidget buttonBottomPanel; FlowLayoutWidget layerSelectionButtonsPannel; - FlowLayoutWidget buttonRightPanel; FlowLayoutWidget modelOptionsContainer; FlowLayoutWidget layerOptionsContainer; @@ -176,44 +175,17 @@ namespace MatterHackers.MatterControl.PartPreviewWindow AddProcessingMessage(startingMessage); - AddViewControls(); - - AddHandlers(); - } - - void AddViewControls() - { - TextImageButtonFactory iconTextImageButtonFactory = new TextImageButtonFactory(); - iconTextImageButtonFactory.invertImageColor = false; - - FlowLayoutWidget transformTypeSelector = new FlowLayoutWidget(); - transformTypeSelector.BackgroundColor = new RGBA_Bytes(0, 0, 0, 120); - iconTextImageButtonFactory.FixedHeight = 20; - iconTextImageButtonFactory.FixedWidth = 20; - - string translateIconPath = Path.Combine("Icons", "ViewTransformControls", "translate.png"); - RadioButton translateButton = iconTextImageButtonFactory.GenerateRadioButton("", translateIconPath); - translateButton.Margin = new BorderDouble(3); - transformTypeSelector.AddChild(translateButton); + Add2DViewControls(); translateButton.Click += (sender, e) => { gcodeViewWidget.TransformState = GCodeViewWidget.ETransformState.Move; }; - - string scaleIconPath = Path.Combine("Icons", "ViewTransformControls", "scale.png"); - RadioButton scaleButton = iconTextImageButtonFactory.GenerateRadioButton("", scaleIconPath); - scaleButton.Margin = new BorderDouble(3); - transformTypeSelector.AddChild(scaleButton); scaleButton.Click += (sender, e) => { gcodeViewWidget.TransformState = GCodeViewWidget.ETransformState.Scale; }; - transformTypeSelector.Margin = new BorderDouble(5); - transformTypeSelector.HAnchor |= Agg.UI.HAnchor.ParentLeft; - transformTypeSelector.VAnchor = Agg.UI.VAnchor.ParentTop; - AddChild(transformTypeSelector); - translateButton.Checked = true; + AddHandlers(); } private FlowLayoutWidget CreateRightButtonPannel() diff --git a/PartPreviewWindow/PartPreviewMainWindow.cs b/PartPreviewWindow/PartPreviewMainWindow.cs index b872e6d4e..95b8dacb9 100644 --- a/PartPreviewWindow/PartPreviewMainWindow.cs +++ b/PartPreviewWindow/PartPreviewMainWindow.cs @@ -38,7 +38,6 @@ using MatterHackers.MatterControl.DataStorage; using MatterHackers.MatterControl.PrintQueue; using MatterHackers.MatterControl.SlicerConfiguration; using MatterHackers.VectorMath; -using MatterHackers.Localizations; namespace MatterHackers.MatterControl.PartPreviewWindow { diff --git a/PartPreviewWindow/View3DTransfromPart.cs b/PartPreviewWindow/View3DTransfromPart.cs index 289307c68..523244c68 100644 --- a/PartPreviewWindow/View3DTransfromPart.cs +++ b/PartPreviewWindow/View3DTransfromPart.cs @@ -71,12 +71,8 @@ namespace MatterHackers.MatterControl.PartPreviewWindow } } - public class View3DTransformPart : PartPreviewBaseWidget + public class View3DTransformPart : PartPreview3DWidget { - MeshViewerWidget meshViewerWidget; - Cover buttonRightPanelDisabledCover; - FlowLayoutWidget buttonRightPanel; - FlowLayoutWidget viewOptionContainer; FlowLayoutWidget rotateOptionContainer; FlowLayoutWidget scaleOptionContainer; @@ -84,9 +80,6 @@ namespace MatterHackers.MatterControl.PartPreviewWindow ProgressControl processingProgressControl; FlowLayoutWidget enterEditButtonsContainer; FlowLayoutWidget doEdittingButtonsContainer; - RadioButton rotateViewButton; - GuiWidget viewControlsSeparator; - RadioButton partSelectButton; bool OpenAddDialogWhenDone = false; Dictionary> transformControls = new Dictionary>(); @@ -101,8 +94,6 @@ namespace MatterHackers.MatterControl.PartPreviewWindow Button closeButton; Button applyScaleButton; - SaveAsWindow saveAs; - PrintItemWrapper printItemWrapper; List asynchMeshesList = new List(); @@ -422,7 +413,9 @@ namespace MatterHackers.MatterControl.PartPreviewWindow this.AnchorAll(); meshViewerWidget.TrackballTumbleWidget.TransformState = TrackBallController.MouseDownType.Rotation; - AddViewControls(); + Add3DViewControls(); + viewControlsSeparator.Visible = false; + partSelectButton.Visible = false; AddHandlers(); @@ -890,64 +883,6 @@ namespace MatterHackers.MatterControl.PartPreviewWindow processingProgressControl.PercentComplete = e.ProgressPercentage; } - void AddViewControls() - { - FlowLayoutWidget transformTypeSelector = new FlowLayoutWidget(); - transformTypeSelector.BackgroundColor = new RGBA_Bytes(0, 0, 0, 120); - textImageButtonFactory.FixedHeight = 20; - textImageButtonFactory.FixedWidth = 20; - textImageButtonFactory.invertImageColor = false; - - string rotateIconPath = Path.Combine("Icons", "ViewTransformControls", "rotate.png"); - rotateViewButton = textImageButtonFactory.GenerateRadioButton("", rotateIconPath); - rotateViewButton.Margin = new BorderDouble(3); - transformTypeSelector.AddChild(rotateViewButton); - rotateViewButton.Click += (sender, e) => - { - meshViewerWidget.TrackballTumbleWidget.TransformState = TrackBallController.MouseDownType.Rotation; - }; - - string translateIconPath = Path.Combine("Icons", "ViewTransformControls", "translate.png"); - RadioButton translateButton = textImageButtonFactory.GenerateRadioButton("", translateIconPath); - translateButton.Margin = new BorderDouble(3); - transformTypeSelector.AddChild(translateButton); - translateButton.Click += (sender, e) => - { - meshViewerWidget.TrackballTumbleWidget.TransformState = TrackBallController.MouseDownType.Translation; - }; - - string scaleIconPath = Path.Combine("Icons", "ViewTransformControls", "scale.png"); - RadioButton scaleButton = textImageButtonFactory.GenerateRadioButton("", scaleIconPath); - scaleButton.Margin = new BorderDouble(3); - transformTypeSelector.AddChild(scaleButton); - scaleButton.Click += (sender, e) => - { - meshViewerWidget.TrackballTumbleWidget.TransformState = TrackBallController.MouseDownType.Scale; - }; - - viewControlsSeparator = new GuiWidget(2, 32); - viewControlsSeparator.Visible = false; - viewControlsSeparator.BackgroundColor = RGBA_Bytes.White; - viewControlsSeparator.Margin = new BorderDouble(3); - transformTypeSelector.AddChild(viewControlsSeparator); - - string partSelectIconPath = Path.Combine("Icons", "ViewTransformControls", "partSelect.png"); - partSelectButton = textImageButtonFactory.GenerateRadioButton("", partSelectIconPath); - partSelectButton.Visible = false; - partSelectButton.Margin = new BorderDouble(3); - transformTypeSelector.AddChild(partSelectButton); - partSelectButton.Click += (sender, e) => - { - meshViewerWidget.TrackballTumbleWidget.TransformState = TrackBallController.MouseDownType.None; - }; - - transformTypeSelector.Margin = new BorderDouble(5); - transformTypeSelector.HAnchor |= Agg.UI.HAnchor.ParentLeft; - transformTypeSelector.VAnchor = Agg.UI.VAnchor.ParentTop; - AddChild(transformTypeSelector); - rotateViewButton.Checked = true; - } - private void CreateOptionsContent() { AddRotateControls(rotateOptionContainer); @@ -998,6 +933,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow AddMirrorControls(mirrorOptionContainer); } +#if false // this is not finished yet so it is in here for reference in case we do finish it. LBB 2014/04/04 // put in the part info display if(false) { @@ -1032,6 +968,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow zSizeInfo.AutoExpandBoundsToText = true; PartInfoOptionContainer.AddChild(zSizeInfo); } +#endif // put in the view options { diff --git a/PrintHistory/PrintHistoryListControl.cs b/PrintHistory/PrintHistoryListControl.cs index 9763d9017..0d00730e1 100644 --- a/PrintHistory/PrintHistoryListControl.cs +++ b/PrintHistory/PrintHistoryListControl.cs @@ -70,7 +70,6 @@ namespace MatterHackers.MatterControl.PrintHistory public class PrintHistoryListControl : ScrollableWidget { static PrintHistoryListControl instance; - private DataStorage.PrintItemCollection libraryCollection; public bool ShowTimestamp; public static PrintHistoryListControl Instance @@ -138,7 +137,6 @@ namespace MatterHackers.MatterControl.PrintHistory { query = string.Format("SELECT * FROM PrintTask ORDER BY PrintStart DESC LIMIT {0};", recordCount); } - //query = string.Format("SELECT * FROM PrintItem WHERE PrintItemCollectionID = {0} ORDER BY Name DESC;", libraryCollection.Id); IEnumerable result = (IEnumerable)DataStorage.Datastore.Instance.dbSQLite.Query(query); return result; } diff --git a/PrintLibrary/PrintLibraryListItem.cs b/PrintLibrary/PrintLibraryListItem.cs index a202c0682..13a2070e4 100644 --- a/PrintLibrary/PrintLibraryListItem.cs +++ b/PrintLibrary/PrintLibraryListItem.cs @@ -49,7 +49,6 @@ namespace MatterHackers.MatterControl.PrintLibrary ImageBuffer image = new Agg.Image.ImageBuffer(); // all te color stuff - public double BorderWidth = 0; protected double borderRadius = 0; protected RGBA_Bytes HoverBorderColor = new RGBA_Bytes(); diff --git a/PrintQueue/ExportToSdCardProcess.cs b/PrintQueue/ExportToSdCardProcess.cs deleted file mode 100644 index 504bd744d..000000000 --- a/PrintQueue/ExportToSdCardProcess.cs +++ /dev/null @@ -1,168 +0,0 @@ -using System; -using System.Threading; -using System.Collections.Generic; -using System.IO; - -using MatterHackers.MatterControl.DataStorage; -using MatterHackers.MatterControl.PrintQueue; -using MatterHackers.MatterControl.SlicerConfiguration; -using MatterHackers.Agg.UI; -using MatterHackers.GCodeVisualizer; - -namespace MatterHackers.MatterControl.PrintQueue -{ - public class ExportToSdCardProcess - { - List allFilesToExport; - List savedGCodeFileNames; - public event EventHandler UpdatePartStatus; - public event EventHandler StartingNextPart; - public event EventHandler DoneSaving; - - int itemCountBeingWorkedOn; - public int ItemCountBeingWorkedOn - { - get - { - return itemCountBeingWorkedOn; - } - } - - public string ItemNameBeingWorkedOn - { - get - { - if (ItemCountBeingWorkedOn < allFilesToExport.Count) - { - return allFilesToExport[ItemCountBeingWorkedOn].Name; - } - - return ""; - } - } - - public int CountOfParts - { - get - { - return allFilesToExport.Count; - } - } - - public ExportToSdCardProcess(List list) - { - // TODO: Complete member initialization - this.allFilesToExport = list; - - itemCountBeingWorkedOn = 0; - } - - public void Start() - { - if (PrintQueueControl.Instance.Count > 0) - { - if (StartingNextPart != null) - { - StartingNextPart(this, new StringEventArgs(ItemNameBeingWorkedOn)); - } - - savedGCodeFileNames = new List(); - allFilesToExport = PrintQueueControl.Instance.CreateReadOnlyPartList(); - foreach (PrintItem part in allFilesToExport) - { - PrintItemWrapper printItemWrapper = new PrintItemWrapper(part); - if (System.IO.Path.GetExtension(part.FileLocation).ToUpper() == ".STL") - { - SlicingQueue.Instance.QueuePartForSlicing(printItemWrapper); - printItemWrapper.Done += new EventHandler(sliceItem_Done); - printItemWrapper.SlicingOutputMessage += printItemWrapper_SlicingOutputMessage; - } - else if (System.IO.Path.GetExtension(part.FileLocation).ToUpper() == ".GCODE") - { - sliceItem_Done(printItemWrapper, null); - } - } - } - } - - void printItemWrapper_SlicingOutputMessage(object sender, EventArgs e) - { - StringEventArgs message = (StringEventArgs)e; - if (UpdatePartStatus != null) - { - UpdatePartStatus(this, message); - } - } - - void sliceItem_Done(object sender, EventArgs e) - { - PrintItemWrapper sliceItem = (PrintItemWrapper)sender; - - sliceItem.Done -= new EventHandler(sliceItem_Done); - savedGCodeFileNames.Add(sliceItem.GCodePathAndFileName); - - itemCountBeingWorkedOn++; - if (itemCountBeingWorkedOn < allFilesToExport.Count) - { - if (StartingNextPart != null) - { - StartingNextPart(this, new StringEventArgs(ItemNameBeingWorkedOn)); - } - } - else - { - UpdatePartStatus(this, new StringEventArgs("Calculating Total cm3...")); - - if (savedGCodeFileNames.Count > 0) - { - double total = 0; - foreach (string gcodeFileName in savedGCodeFileNames) - { - string[] lines = File.ReadAllLines(gcodeFileName); - string filamentAmountLine = lines[lines.Length - 1]; - int startPos = filamentAmountLine.IndexOf("("); - int endPos = filamentAmountLine.IndexOf("cm3)"); - string value = filamentAmountLine.Substring(startPos + 1, endPos - (startPos + 1)); - double amountForThisFile; - if (double.TryParse(value, out amountForThisFile)) - { - total += amountForThisFile; - } - else - { - GCodeFile gcodeFile = new GCodeFile(gcodeFileName); - total += gcodeFile.GetFilamentCubicMm(ActiveSliceSettings.Instance.FilamentDiameter) / 1000; - } - } - - // now copy all the gcode to the path given - for (int i = 0; i < savedGCodeFileNames.Count; i++) - { - string savedGcodeFileName = savedGCodeFileNames[i]; - string originalFileName = Path.GetFileName(allFilesToExport[i].Name); - string outputFileName = Path.ChangeExtension(originalFileName, ".gcode"); - throw new NotImplementedException(); - //string outputPathAndName = Path.Combine(exportPath, outputFileName); - - if (ActivePrinterProfile.Instance.DoPrintLeveling) - { - GCodeFile unleveledGCode = new GCodeFile(savedGcodeFileName); - PrintLeveling.Instance.ApplyLeveling(unleveledGCode); - //unleveledGCode.Save(outputPathAndName); - } - else - { - //File.Copy(savedGcodeFileName, outputPathAndName, true); - } - } - - if (DoneSaving != null) - { - DoneSaving(this, new StringEventArgs(string.Format("{0:0.0}", total))); - } - } - } - } - } -} - diff --git a/PrinterCommunication/PrinterCommunication.cs b/PrinterCommunication/PrinterCommunication.cs index f4d694f6b..2d4394ad6 100644 --- a/PrinterCommunication/PrinterCommunication.cs +++ b/PrinterCommunication/PrinterCommunication.cs @@ -1267,7 +1267,7 @@ namespace MatterHackers.MatterControl OnConnectionFailed(null); } - catch (Exception e) + catch (Exception) { OnConnectionFailed(null); } diff --git a/PrinterControls/EditLevelingSettingsWindow.cs b/PrinterControls/EditLevelingSettingsWindow.cs index cf0ba8cf9..a840baddd 100644 --- a/PrinterControls/EditLevelingSettingsWindow.cs +++ b/PrinterControls/EditLevelingSettingsWindow.cs @@ -46,7 +46,6 @@ namespace MatterHackers.MatterControl public class EditLevelingSettingsWindow : SystemWindow { protected TextImageButtonFactory textImageButtonFactory = new TextImageButtonFactory(); - EventHandler functionToCallOnSave; List listWithValues = new List(); public EditLevelingSettingsWindow() @@ -219,7 +218,6 @@ namespace MatterHackers.MatterControl settingString.Append(valueToAdd.Text); first = false; } - functionToCallOnSave(this, new StringEventArgs(settingString.ToString())); Close(); } } diff --git a/PrinterControls/EditMacrosWindow.cs b/PrinterControls/EditMacrosWindow.cs index 971979772..c0ee73eb4 100644 --- a/PrinterControls/EditMacrosWindow.cs +++ b/PrinterControls/EditMacrosWindow.cs @@ -293,7 +293,6 @@ namespace MatterHackers.MatterControl topToBottom.AddChild(presetsFormContainer); IEnumerable macroList = GetMacros(); - int buttonCount = 0; foreach (DataStorage.CustomCommands m in macroList) { FlowLayoutWidget macroRow = new FlowLayoutWidget();