コード例 #1
0
 public void ChangeToMacroDetail(CustomCommands macro = null)
 {
     this.ActiveMacro = macro;
     UiThread.RunOnIdle(DoChangeToMacroDetail);
 }
コード例 #2
0
        public MacroListWidget(EditMacrosWindow windowController)
        {
            this.windowController = windowController;

            linkButtonFactory.fontSize = 10;
            FlowLayoutWidget topToBottom = new FlowLayoutWidget(FlowDirection.TopToBottom);

            topToBottom.AnchorAll();
            topToBottom.Padding = new BorderDouble(3, 0, 3, 5);

            FlowLayoutWidget headerRow = new FlowLayoutWidget(FlowDirection.LeftToRight);

            headerRow.HAnchor = HAnchor.ParentLeftRight;
            headerRow.Margin  = new BorderDouble(0, 3, 0, 0);
            headerRow.Padding = new BorderDouble(0, 3, 0, 3);

            {
                string     macroPresetsLabel     = LocalizedString.Get("Macro Presets");
                string     macroPresetsLabelFull = string.Format("{0}:", macroPresetsLabel);
                TextWidget elementHeader         = new TextWidget(macroPresetsLabelFull, pointSize: 14);
                elementHeader.TextColor = ActiveTheme.Instance.PrimaryTextColor;
                elementHeader.HAnchor   = HAnchor.ParentLeftRight;
                elementHeader.VAnchor   = Agg.UI.VAnchor.ParentBottom;
                headerRow.AddChild(elementHeader);
            }


            topToBottom.AddChild(headerRow);

            FlowLayoutWidget presetsFormContainer = new FlowLayoutWidget(FlowDirection.TopToBottom);

            {
                presetsFormContainer.HAnchor         = HAnchor.ParentLeftRight;
                presetsFormContainer.VAnchor         = VAnchor.ParentBottomTop;
                presetsFormContainer.Padding         = new BorderDouble(3);
                presetsFormContainer.BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor;
            }

            topToBottom.AddChild(presetsFormContainer);

            IEnumerable <DataStorage.CustomCommands> macroList = GetMacros();

            foreach (DataStorage.CustomCommands currentCommand in macroList)
            {
                FlowLayoutWidget macroRow = new FlowLayoutWidget();
                macroRow.Margin          = new BorderDouble(3, 0, 3, 3);
                macroRow.HAnchor         = Agg.UI.HAnchor.ParentLeftRight;
                macroRow.Padding         = new BorderDouble(3);
                macroRow.BackgroundColor = RGBA_Bytes.White;

                TextWidget buttonLabel = new TextWidget(currentCommand.Name);
                macroRow.AddChild(buttonLabel);

                FlowLayoutWidget hSpacer = new FlowLayoutWidget();
                hSpacer.HAnchor = Agg.UI.HAnchor.ParentLeftRight;
                macroRow.AddChild(hSpacer);

                Button editLink = linkButtonFactory.Generate(LocalizedString.Get("edit"));
                editLink.Margin = new BorderDouble(right: 5);
                // You can't pass a foreach variable into a link function or it wall always be the last item.
                // So we make a local variable copy of it and pass that. This will get the right one.
                DataStorage.CustomCommands currentCommandForLinkFunction = currentCommand;
                editLink.Click += (sender, e) =>
                {
                    windowController.ChangeToMacroDetail(currentCommandForLinkFunction);
                };
                macroRow.AddChild(editLink);

                Button removeLink = linkButtonFactory.Generate(LocalizedString.Get("remove"));
                removeLink.Click += (sender, e) =>
                {
                    currentCommandForLinkFunction.Delete();
                    windowController.functionToCallOnSave(this, null);
                    windowController.ChangeToMacroList();
                };
                macroRow.AddChild(removeLink);

                presetsFormContainer.AddChild(macroRow);
            }


            Button addMacroButton = textImageButtonFactory.Generate(LocalizedString.Get("Add"), "icon_circle_plus.png");

            addMacroButton.Click += new ButtonBase.ButtonEventHandler(addMacro_Click);

            Button cancelPresetsButton = textImageButtonFactory.Generate(LocalizedString.Get("Close"));

            cancelPresetsButton.Click += (sender, e) => {
                UiThread.RunOnIdle((state) =>
                {
                    this.windowController.Close();
                });
            };

            FlowLayoutWidget buttonRow = new FlowLayoutWidget();

            buttonRow.HAnchor = HAnchor.ParentLeftRight;
            buttonRow.Padding = new BorderDouble(0, 3);

            GuiWidget hButtonSpacer = new GuiWidget();

            hButtonSpacer.HAnchor = HAnchor.ParentLeftRight;

            buttonRow.AddChild(addMacroButton);
            buttonRow.AddChild(hButtonSpacer);
            buttonRow.AddChild(cancelPresetsButton);

            topToBottom.AddChild(buttonRow);
            AddChild(topToBottom);
            this.AnchorAll();
        }
コード例 #3
0
 public void ChangeToMacroList()
 {
     this.ActiveMacro = null;
     UiThread.RunOnIdle(DoChangeToMacroList);
 }
コード例 #4
0
		public void LoadSetupSettings(string make, string model)
		{
			Dictionary<string, string> settingsDict = LoadPrinterSetupFromFile(make, model);
			Dictionary<string, string> macroDict = new Dictionary<string, string>();
			macroDict["Lights On"] = "M42 P6 S255";
			macroDict["Lights Off"] = "M42 P6 S0";
			macroDict["Offset 0.8"] = "M565 Z0.8;\nM500";
			macroDict["Offset 0.9"] = "M565 Z0.9;\nM500";
			macroDict["Offset 1"] = "M565 Z1;\nM500";
			macroDict["Offset 1.1"] = "M565 Z1.1;\nM500";
			macroDict["Offset 1.2"] = "M565 Z1.2;\nM500";
			macroDict["Z Offset"] = "G1 Z10;\nG28;\nG29;\nG1 Z10;\nG1 X5 Y5 F4000;\nM117;";

			//Determine if baud rate is needed and show controls if required
			string baudRate;
			if (settingsDict.TryGetValue("baud_rate", out baudRate))
			{
				ActivePrinter.BaudRate = baudRate;
			}

			string defaultSliceEngine;
			if (settingsDict.TryGetValue("default_slice_engine", out defaultSliceEngine))
			{
				if (Enum.IsDefined(typeof(ActivePrinterProfile.SlicingEngineTypes), defaultSliceEngine))
				{
					ActivePrinter.CurrentSlicingEngine = defaultSliceEngine;
				}
			}

			string defaultPrinterDriver;
			if (settingsDict.TryGetValue("driver_type", out defaultPrinterDriver))
			{
				ActivePrinter.DriverType = defaultPrinterDriver;
			}

			settingsDict.TryGetValue("default_material_presets", out defaultMaterialPreset);
			settingsDict.TryGetValue("default_quality_preset", out defaultQualityPreset);
			settingsDict.TryGetValue("default_movement_speeds", out defaultMovementSpeeds);

			string defaultMacros;
			printerCustomCommands = new List<CustomCommands>();
			if (settingsDict.TryGetValue("default_macros", out defaultMacros))
			{
				string[] macroList = defaultMacros.Split(',');
				foreach (string macroName in macroList)
				{
					string macroValue;
					if (macroDict.TryGetValue(macroName.Trim(), out macroValue))
					{
						CustomCommands customMacro = new CustomCommands();
						customMacro.Name = macroName.Trim();
						customMacro.Value = macroValue;

						printerCustomCommands.Add(customMacro);
					}
				}
			}

			//Determine what if any drivers are needed
			string infFileNames;
			if (settingsDict.TryGetValue("windows_driver", out infFileNames))
			{
				string[] fileNames = infFileNames.Split(',');
				foreach (string fileName in fileNames)
				{
					switch (OsInformation.OperatingSystem)
					{
						case OSType.Windows:

							string pathForInf = Path.GetFileNameWithoutExtension(fileName);

							// TODO: It's really unexpected that the driver gets copied to the temp folder everytime a printer is setup. I'd think this only needs
							// to happen when the infinstaller is run (More specifically - move this to *after* the user clicks Install Driver)

							string infPath = Path.Combine("Drivers", pathForInf);
							string infPathAndFileToInstall = Path.Combine(infPath, fileName);

							if (StaticData.Instance.FileExists(infPathAndFileToInstall))
							{
								// Ensure the output directory exists
								string destTempPath = Path.GetFullPath(Path.Combine(ApplicationDataStorage.ApplicationUserDataPath, "data", "temp", "inf", pathForInf));
								if (!Directory.Exists(destTempPath))
								{
									Directory.CreateDirectory(destTempPath);
								}

								string destTempInf = Path.GetFullPath(Path.Combine(destTempPath, fileName));

								// Sync each file from StaticData to the location on disk for serial drivers
								foreach (string file in StaticData.Instance.GetFiles(infPath))
								{
									using (Stream outstream = File.OpenWrite(Path.Combine(destTempPath, Path.GetFileName(file))))
									using (Stream instream = StaticData.Instance.OpenSteam(file))
									{
										instream.CopyTo(outstream);
									}
								}

								DriversToInstall.Add(destTempInf);
							}
							break;

						default:
							break;
					}
				}
			}
		}
コード例 #5
0
		public void ChangeToMacroDetail(CustomCommands macro = null)
		{
			this.ActiveMacro = macro;
			UiThread.RunOnIdle(DoChangeToMacroDetail);
		}
コード例 #6
0
		public void ChangeToMacroList()
		{
			this.ActiveMacro = null;
			UiThread.RunOnIdle(DoChangeToMacroList);
		}
コード例 #7
0
        private void LoadSetupSettings(string make, string model)
        {
            Dictionary<string, string> settingsDict = LoadPrinterSetupFromFile(make, model);
            Dictionary<string, string> macroDict = new Dictionary<string, string>();
            macroDict["Lights On"] = "M42 P6 S255";
            macroDict["Lights Off"] = "M42 P6 S0";
            
            //Determine if baud rate is needed and show controls if required
            string baudRate;
            if (settingsDict.TryGetValue("baud_rate", out baudRate))
            {
                ActivePrinter.BaudRate = baudRate;
            }

            string defaultSliceEngine;
            if (settingsDict.TryGetValue("default_slice_engine", out defaultSliceEngine))
            {
                if (Enum.IsDefined(typeof(ActivePrinterProfile.SlicingEngineTypes), defaultSliceEngine))
                {
                    ActivePrinter.CurrentSlicingEngine = defaultSliceEngine;
                }
            }

            string defaultMacros;
            printerCustomCommands = new List<CustomCommands>();
            if (settingsDict.TryGetValue("default_macros", out defaultMacros))
            {
                string[] macroList = defaultMacros.Split(',');
                foreach (string macroName in macroList)
                {
                    string macroValue;
                    if (macroDict.TryGetValue(macroName.Trim(), out macroValue))
                    {
                        CustomCommands customMacro = new CustomCommands();
                        customMacro.Name = macroName.Trim();
                        customMacro.Value = macroValue;

                        printerCustomCommands.Add(customMacro);
                        
                    }
                }
            }

            //Determine what if any drivers are needed
            if (settingsDict.TryGetValue("windows_driver", out driverFile))
            {
                string infPathAndFileToInstall = Path.Combine(ApplicationDataStorage.Instance.ApplicationStaticDataPath, "Drivers", driverFile);
                switch (MatterHackers.Agg.UI.WindowsFormsAbstract.GetOSType())
                {
                    case Agg.UI.WindowsFormsAbstract.OSType.Windows:
                        if (File.Exists(infPathAndFileToInstall))
                        {
                            PrinterSetupStatus.DriverNeedsToBeInstalled = true;
                            PrinterSetupStatus.DriverFilePath = infPathAndFileToInstall;
                        }
                        break;

                    default:
                        break;
                }
            }
        }
コード例 #8
0
        private void LoadSetupSettings(string make, string model)
        {
            Dictionary<string, string> settingsDict = LoadPrinterSetupFromFile(make, model);
            Dictionary<string, string> macroDict = new Dictionary<string, string>();
            macroDict["Lights On"] = "M42 P6 S255";
            macroDict["Lights Off"] = "M42 P6 S0";
            
            //Determine if baud rate is needed and show controls if required
            string baudRate;
            if (settingsDict.TryGetValue("baud_rate", out baudRate))
            {
                ActivePrinter.BaudRate = baudRate;
            }

            // Check if we need to run the print level wizard before printing
            PrintLevelingData levelingData = PrintLevelingData.GetForPrinter(ActivePrinter);
            string needsPrintLeveling;
            if (settingsDict.TryGetValue("needs_print_leveling", out needsPrintLeveling))
            {
                levelingData.needsPrintLeveling = true;
            }

            string printLevelingType;
            if (settingsDict.TryGetValue("print_leveling_type", out printLevelingType))
            {
                levelingData.levelingSystem = PrintLevelingData.LevelingSystem.Probe2Points;
            }

            string defaultSliceEngine;
            if (settingsDict.TryGetValue("default_slice_engine", out defaultSliceEngine))
            {
                if (Enum.IsDefined(typeof(ActivePrinterProfile.SlicingEngineTypes), defaultSliceEngine))
                {
                    ActivePrinter.CurrentSlicingEngine = defaultSliceEngine;
                }
            }

            settingsDict.TryGetValue("default_material_presets", out defaultMaterialPreset);
            settingsDict.TryGetValue("default_quality_preset", out defaultQualityPreset);
            settingsDict.TryGetValue("default_movement_speeds", out defaultMovementSpeeds);

            string defaultMacros;
            printerCustomCommands = new List<CustomCommands>();
            if (settingsDict.TryGetValue("default_macros", out defaultMacros))
            {
                string[] macroList = defaultMacros.Split(',');
                foreach (string macroName in macroList)
                {
                    string macroValue;
                    if (macroDict.TryGetValue(macroName.Trim(), out macroValue))
                    {
                        CustomCommands customMacro = new CustomCommands();
                        customMacro.Name = macroName.Trim();
                        customMacro.Value = macroValue;

                        printerCustomCommands.Add(customMacro);
                        
                    }
                }
            }

            //Determine what if any drivers are needed
            if (settingsDict.TryGetValue("windows_driver", out driverFile))
            {
                string infPathAndFileToInstall = Path.Combine(ApplicationDataStorage.Instance.ApplicationStaticDataPath, "Drivers", driverFile);
                switch (OsInformation.OperatingSystem)
                {
                    case OSType.Windows:
                        if (File.Exists(infPathAndFileToInstall))
                        {
                            PrinterSetupStatus.DriverNeedsToBeInstalled = true;
                            PrinterSetupStatus.DriverFilePath = infPathAndFileToInstall;
                        }
                        break;

                    default:
                        break;
                }
            }
        }