Beispiel #1
0
        static void CreateSlicedPartsThread()
        {
            while (!haltSlicingThread)
            {
                if (PrinterCommunication.Instance.ActivePrintItem != null && listOfSlicingItems.Count > 0)
                {
                    PrintItemWrapper itemToSlice = listOfSlicingItems[0];
                    itemToSlice.CurrentlySlicing = true;

                    string currentConfigurationFileAndPath = Path.Combine(ApplicationDataStorage.Instance.GCodeOutputPath, "config_" + ActiveSliceSettings.Instance.GetHashCode().ToString() + ".ini");
                    ActiveSliceSettings.Instance.GenerateConfigFile(currentConfigurationFileAndPath);

                    string gcodePathAndFileName = itemToSlice.GCodePathAndFileName;
                    bool   gcodeFileIsComplete  = itemToSlice.IsGCodeFileComplete(gcodePathAndFileName);

                    if (!File.Exists(gcodePathAndFileName) || !gcodeFileIsComplete)
                    {
                        slicerProcess = new Process();

                        switch (PrinterCommunication.Instance.ActiveSliceEngine)
                        {
                        case PrinterCommunication.SlicingEngine.Slic3r:
                            slicerProcess.StartInfo.Arguments = "--load \"" + currentConfigurationFileAndPath + "\" --output \"" + gcodePathAndFileName + "\" \"" + itemToSlice.PartToSlicePathAndFileName + "\"";
                            break;

                        case PrinterCommunication.SlicingEngine.CuraEngine:
                            slicerProcess.StartInfo.Arguments = "-v -o \"" + gcodePathAndFileName + "\" " + CuraEngineMappings.GetCuraCommandLineSettings() + " \"" + itemToSlice.PartToSlicePathAndFileName + "\"";
                            //Debug.Write(slicerProcess.StartInfo.Arguments);
                            break;

                        case PrinterCommunication.SlicingEngine.MatterSlice:
                            slicerProcess.StartInfo.Arguments = "--load \"" + currentConfigurationFileAndPath + "\" --output \"" + gcodePathAndFileName + "\" \"" + itemToSlice.PartToSlicePathAndFileName + "\"";
                            break;
                        }

                        string slicerFullPath = getSlicerFullPath();

                        slicerProcess.StartInfo.CreateNoWindow         = true;
                        slicerProcess.StartInfo.WindowStyle            = ProcessWindowStyle.Hidden;
                        slicerProcess.StartInfo.RedirectStandardError  = true;
                        slicerProcess.StartInfo.RedirectStandardOutput = true;

                        slicerProcess.StartInfo.FileName        = slicerFullPath;
                        slicerProcess.StartInfo.UseShellExecute = false;

                        slicerProcess.OutputDataReceived += (sender, args) =>
                        {
                            if (args.Data != null)
                            {
                                string message = args.Data;
                                message = message.Replace("=>", "").Trim();
                                if (message.Contains(".gcode"))
                                {
                                    message = "Saving intermediate file";
                                }
                                message += "...";
                                itemToSlice.OnSlicingOutputMessage(new StringEventArgs(message));
                            }
                        };

                        slicerProcess.Start();

                        slicerProcess.BeginOutputReadLine();
                        string stdError = slicerProcess.StandardError.ReadToEnd();

                        slicerProcess.WaitForExit();
                        using (TimedLock.Lock(slicerProcess, "SlicingProcess"))
                        {
                            slicerProcess = null;
                        }
                    }

                    itemToSlice.CurrentlySlicing = false;
                    itemToSlice.DoneSlicing      = true;

                    using (TimedLock.Lock(listOfSlicingItems, "CreateSlicedPartsThread()"))
                    {
                        listOfSlicingItems.RemoveAt(0);
                    }
                }

                Thread.Sleep(100);
            }
        }
        private TabControl CreateSideTabsAndPages(int minSettingNameWidth, OrganizerCategory category, UiState uiState)
        {
            TabControl groupTabs = new TabControl(Orientation.Vertical);

            groupTabs.Margin             = new BorderDouble(0, 0, 0, 5);
            groupTabs.TabBar.BorderColor = RGBA_Bytes.White;
            foreach (OrganizerGroup group in category.GroupsList)
            {
                tabIndexForItem = 0;
                string              groupTabLbl    = new LocalizedString(group.Name).Translated;
                TabPage             groupTabPage   = new TabPage(groupTabLbl);
                SimpleTextTabWidget groupTabWidget = new SimpleTextTabWidget(groupTabPage, 14,
                                                                             ActiveTheme.Instance.TabLabelSelected, new RGBA_Bytes(), ActiveTheme.Instance.TabLabelUnselected, new RGBA_Bytes());

                FlowLayoutWidget subGroupLayoutTopToBottom = new FlowLayoutWidget(FlowDirection.TopToBottom);
                subGroupLayoutTopToBottom.AnchorAll();

                bool needToAddSubGroup = false;
                foreach (OrganizerSubGroup subGroup in group.SubGroupsList)
                {
                    bool             addedSettingToSubGroup = false;
                    FlowLayoutWidget topToBottomSettings    = new FlowLayoutWidget(FlowDirection.TopToBottom);
                    topToBottomSettings.HAnchor = Agg.UI.HAnchor.Max_FitToChildren_ParentWidth;

                    foreach (OrganizerSettingsData settingInfo in subGroup.SettingDataList)
                    {
                        if (PrinterCommunication.Instance.ActiveSliceEngine == PrinterCommunication.SlicingEngine.Slic3r ||
                            CuraEngineMappings.MapContains(settingInfo.SlicerConfigName))
                        {
                            addedSettingToSubGroup = true;
                            GuiWidget controlsForThisSetting = CreateSettingInfoUIControls(settingInfo, minSettingNameWidth);
                            topToBottomSettings.AddChild(controlsForThisSetting);

                            if (showHelpBox.Checked)
                            {
                                AddInHelpText(topToBottomSettings, settingInfo);
                            }
                        }
                    }

                    if (addedSettingToSubGroup)
                    {
                        needToAddSubGroup = true;
                        string   groupBoxLbl = new LocalizedString(subGroup.Name).Translated;
                        GroupBox groupBox    = new GroupBox(groupBoxLbl);
                        groupBox.TextColor   = ActiveTheme.Instance.PrimaryTextColor;
                        groupBox.BorderColor = ActiveTheme.Instance.PrimaryTextColor;
                        groupBox.AddChild(topToBottomSettings);

                        groupBox.HAnchor = Agg.UI.HAnchor.Max_FitToChildren_ParentWidth;

                        subGroupLayoutTopToBottom.AddChild(groupBox);
                    }
                }

                if (needToAddSubGroup)
                {
                    ScrollableWidget scrollOnGroupTab = new ScrollableWidget(true);
                    scrollOnGroupTab.AnchorAll();
                    subGroupLayoutTopToBottom.HAnchor = HAnchor.Max_FitToChildren_ParentWidth;
                    subGroupLayoutTopToBottom.VAnchor = VAnchor.FitToChildren;
                    //subGroupLayoutTopToBottom.DebugShowBounds = true;
                    //scrollOnGroupTab.DebugShowBounds = true;
                    scrollOnGroupTab.AddChild(subGroupLayoutTopToBottom);
                    groupTabPage.AddChild(scrollOnGroupTab);
                    groupTabs.AddTab(groupTabWidget);
                }
            }

            if (!groupTabs.SelectTab(uiState.selectedGroup.name))
            {
                groupTabs.SelectTab(uiState.selectedGroup.index);
            }
            return(groupTabs);
        }