Exemplo n.º 1
0
        private void btnExportSettings_Click(object sender, EventArgs e)
        {
            if (Material != null && Supplier != null)
            {
                MaterialsBySupplier materialsBySupplier = new MaterialsBySupplier();
                materialsBySupplier.Supplier = Supplier;
                materialsBySupplier.Materials.Add(Material);

                using (var saveDialog = new SaveFileDialog())
                {
                    saveDialog.AddExtension = true;
                    saveDialog.FileName     = Material.Name.Replace(" ", "") + ".xml";
                    saveDialog.DefaultExt   = ".xml";
#if LOCTITE
                    saveDialog.Filter = "Material Settings File(*.xml)|*.xml";
#else
                    saveDialog.Filter = "Material Settings File(*.xml)|*.xml";
#endif
                    if (saveDialog.ShowDialog() == DialogResult.OK && !string.IsNullOrEmpty(saveDialog.FileName))
                    {
                        var _serializer = new System.Xml.Serialization.XmlSerializer(typeof(MaterialsBySupplier));
                        using (var streamWriter = new System.IO.StreamWriter(saveDialog.FileName, false))
                        {
                            _serializer.Serialize(streamWriter, materialsBySupplier);
                            streamWriter.Close();
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
        private displayMaterial PushMaterialControl(int summaryTop, int summaryleft, MaterialsBySupplier material)
        {
            var displayMaterialControl = new displayMaterial(material);

            displayMaterialControl.SelectionChanged += DisplayMaterialControl_SelectionChanged;
            displayMaterialControl.Top   = summaryTop;
            displayMaterialControl.Width = 208;
            //    displayMaterialControl.Height = 126;
            displayMaterialControl.Left = summaryleft;

            if (this.pnlMaterialDisplay.InvokeRequired)
            {
                this.pnlMaterialDisplay.Invoke(new MethodInvoker(delegate
                {
                    this.pnlMaterialDisplay.Controls.Add(displayMaterialControl);
                }));
            }
            else
            {
                this.pnlMaterialDisplay.Controls.Add(displayMaterialControl);
            }


            return(displayMaterialControl);
        }
Exemplo n.º 3
0
        private static void UpdateSupplierMaterials(string filePath)
        {
            var serializer = new System.Xml.Serialization.XmlSerializer(typeof(MaterialsBySupplier));

            if (File.Exists(filePath))
            {
                using (var materialReader = new StreamReader(filePath))
                {
                    var updatedSupplierMaterial = (MaterialsBySupplier)serializer.Deserialize(materialReader);
                    updatedSupplierMaterial.FilePath = filePath.Replace("/", "\\");
                    materialReader.Close();

                    //find current supplier
                    MaterialsBySupplier currentSupplier = _materialCatalog.FirstOrDefault(s => s.FilePath == filePath);
                    if (currentSupplier != null)
                    {
                        //check if current selectedMaterial is part of supplier materials
                        var selectedMaterialSummary = PrintJobManager.SelectedMaterialSummary;
                        if (selectedMaterialSummary != null && selectedMaterialSummary.Material != null && selectedMaterialSummary.Material.Id != Guid.Empty)
                        {
                            var selectedMaterial = updatedSupplierMaterial.FindMaterialById(selectedMaterialSummary.Material.Id);
                            if (selectedMaterial != null && selectedMaterial.ChangeId != selectedMaterialSummary.Material.ChangeId)
                            {
                                selectedMaterialSummary.Material = selectedMaterial;
                                selectedMaterialSummary.Supplier = updatedSupplierMaterial.Supplier;
                                SelectedMaterialUpdated?.Invoke(null, selectedMaterialSummary);
                            }
                        }

                        //update materials
                        foreach (var updatedMaterial in updatedSupplierMaterial.Materials)
                        {
                            var materialIdExists = false;
                            for (var currentMaterialIndex = 0; currentMaterialIndex < currentSupplier.Materials.Count; currentMaterialIndex++)
                            {
                                if (currentSupplier.Materials[currentMaterialIndex].Id == updatedMaterial.Id)
                                {
                                    currentSupplier.Materials[currentMaterialIndex] = updatedMaterial;
                                    materialIdExists = true;
                                    break;
                                }
                            }

                            if (!materialIdExists)
                            {
                                currentSupplier.Materials.Add(updatedMaterial);
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 4
0
        public displayMaterial(MaterialsBySupplier material)
        {
            InitializeComponent();

            this.lblSupplierName.Font        = FontManager.Montserrat14Bold;
            this.lblMaterialDisplayName.Font = FontManager.Montserrat16Regular;
            this.plmain.BorderThickness      = 2;
            this.plmain.SingleBorder         = true;


            Material = material;
            UpdateControl();
        }
Exemplo n.º 5
0
        public static void RemoveSupplier(MaterialsBySupplier selectedSupplier)
        {
            foreach (var supplier in Catalog)
            {
                if (selectedSupplier.Supplier == supplier.Supplier)
                {
                    if (selectedSupplier.FilePath != null && File.Exists(selectedSupplier.FilePath))
                    {
                        File.Delete(selectedSupplier.FilePath);
                    }

                    Catalog.Remove(supplier);

                    break;
                }
            }
        }
Exemplo n.º 6
0
        private void btnManufacturerAdd_Click(object sender, EventArgs e)
        {
            var newSupplier = new MaterialsBySupplier()
            {
                Supplier = "New manufacturer"
            };
            var catalogNode     = this.trCatalog.Nodes;
            var newSupplierNode = new TreeNode()
            {
                Text = newSupplier.Supplier, Tag = newSupplier
            };

            MaterialManager.Catalog.Add(newSupplier);
            catalogNode.Add(newSupplierNode);

            //add new node to treeview
            this.trCatalog.HideSelection = false;
            this.trCatalog.SelectedNode  = newSupplierNode;

            this.btnManufacturerSave.Enabled = true;
        }
Exemplo n.º 7
0
        private void ShowAdvancedCalibration()
        {
            this.tbPrinterSettings.TabPages.Remove(this.Calibration);

            if (!this.tbPrinterSettings.TabPages.Contains(this.AdvancedCalibration))
            {
                this.tbPrinterSettings.TabPages.Add(this.AdvancedCalibration);
            }

            this.tbPrinterSettings.SelectedTab = this.AdvancedCalibration;
            this.lensWarpCorrectionItemsBindingSource.DataSource = LensWarpCorrectionItems.FromPrinterSettings(this._dataSource);

            this._dataSource.LensWarpingCorrection.Enabled = true;

            var materialCatalog = new MaterialsCatalog();

            foreach (var supplier in MaterialManager.Catalog)
            {
                var materialSupplier = new MaterialsBySupplier();
                //filter on printer type

                //un filtered
                foreach (var material in supplier.Materials.Where(m => string.IsNullOrEmpty(m.PrinterHardwareType)))
                {
                    materialSupplier.Materials.Add(material);
                }

                if (materialSupplier.Materials.Count > 0)
                {
                    materialSupplier.Supplier = supplier.Supplier;
                    materialCatalog.Add(materialSupplier);
                }
            }

            this.cbAdvancedCalibrationMaterialSupplier.DataSource = materialCatalog;

            cbMaterialManufacturer_SelectedIndexChanged(null, null);
        }
Exemplo n.º 8
0
        public static void SaveMaterial(MaterialsBySupplier selectedSupplier)
        {
            var serializer = new System.Xml.Serialization.XmlSerializer(typeof(MaterialsBySupplier));

            //if no material catalog is found then save default items
            try
            {
                if (!Directory.Exists(Settings.RoamingMaterialsPath))
                {
                    LoggingManager.WriteToLog("Material Manager", "Creating materials path", Settings.RoamingMaterialsPath);

                    Directory.CreateDirectory(Settings.RoamingMaterialsPath);

                    LoggingManager.WriteToLog("Material Manager", "Created materials path", Settings.RoamingMaterialsPath);
                }


                var hasLocalWriteAccess = FileSystemManager.HasWriteAccess(Settings.BasePath);
                if (hasLocalWriteAccess)
                {
                    if (!Directory.Exists(Settings.MaterialsPath))
                    {
                        LoggingManager.WriteToLog("Material Manager", "Creating materials path", Settings.MaterialsPath);

                        Directory.CreateDirectory(Settings.MaterialsPath);

                        LoggingManager.WriteToLog("Material Manager", "Created materials path", Settings.MaterialsPath);
                    }

                    var supplierMaterialFilePath = Path.Combine(Settings.MaterialsPath, selectedSupplier.Supplier + ".xml");
                    using (var streamWriter = new StreamWriter(supplierMaterialFilePath))
                    {
                        try
                        {
                            foreach (var material in selectedSupplier.Materials)
                            {
                                if (string.IsNullOrEmpty(material.DisplayName))
                                {
                                    material.DisplayName = material.Name;
                                }
                            }

                            LoggingManager.WriteToLog("Material Manager", "Saving material settings file", supplierMaterialFilePath);

                            serializer.Serialize(streamWriter, selectedSupplier);

                            LoggingManager.WriteToLog("Material Manager", "Saved material settings file", supplierMaterialFilePath);
                        }
                        catch (Exception exc)
                        {
                            LoggingManager.WriteToLog("Material Manager", "Removing previous material settings file (exception)", exc);
                        }

                        streamWriter.Close();
                    }
                }
                else
                {
                    var supplierMaterialFilePath = Path.Combine(Settings.RoamingMaterialsPath, selectedSupplier.Supplier + ".xml");
                    using (var streamWriter = new StreamWriter(supplierMaterialFilePath, false))
                    {
                        try
                        {
                            foreach (var material in selectedSupplier.Materials)
                            {
                                if (string.IsNullOrEmpty(material.DisplayName))
                                {
                                    material.DisplayName = material.Name;
                                }
                            }

                            LoggingManager.WriteToLog("Material Manager", "Saving material settings file", supplierMaterialFilePath);

                            serializer.Serialize(streamWriter, selectedSupplier);

                            LoggingManager.WriteToLog("Material Manager", "Saved material settings file", supplierMaterialFilePath);
                        }
                        catch (Exception exc)
                        {
                            LoggingManager.WriteToLog("Material Manager", "Removing previous material settings file (exception)", exc);
                        }

                        streamWriter.Close();
                    }
                }
            }
            catch
            {
            }
        }
Exemplo n.º 9
0
        public static void Start(bool addHandlers)
        {
            //bind manufacturer comboxbox
            var serializer = new System.Xml.Serialization.XmlSerializer(typeof(MaterialsBySupplier));

            _materialCatalog = new MaterialsCatalog();

            //if no material catalog is found then save default items
            try
            {
                //                var hasLocalWriteAccess = FileSystemManager.HasWriteAccess(Settings.BasePath);
                //                if (hasLocalWriteAccess)
                //                {
                //                    LoggingManager.WriteToLog("Material Manager", "Base Path", Settings.MaterialsPath);

                //                    if (!Directory.Exists(Settings.MaterialsPath))
                //                    {
                //                        LoggingManager.WriteToLog("Material Manager", "Creating Base Path", Settings.MaterialsPath);

                //                        Directory.CreateDirectory(Settings.MaterialsPath);

                //                        LoggingManager.WriteToLog("Material Manager", "Created Base Path", Settings.MaterialsPath);

                //                        //add default materials
                //                        LoggingManager.WriteToLog("Material Manager", "Saving default materials", Settings.MaterialsPath);

                //#if LOCTITE
                //                        var defaultMaterialFilePath = Path.Combine(Settings.MaterialsPath, "Henkel.xml");
                //                        File.WriteAllBytes(defaultMaterialFilePath, Properties.Resources.Material_Henkel_xml);
                //#else
                //                        var defaultMaterialFilePath = Path.Combine(Settings.MaterialsPath, "3DMaterials.xml");
                //                        File.WriteAllBytes(defaultMaterialFilePath, Properties.Resources.Material_3DMaterials_xml);
                //#endif

                //                        LoggingManager.WriteToLog("Material Manager", "Saved default materials", Settings.MaterialsPath);
                //                    }
                //                }
                //                else
                {
                    LoggingManager.WriteToLog("Material Manager", "Base Path", Settings.RoamingMaterialsPath);

                    if (!Directory.Exists(Settings.RoamingMaterialsPath))
                    {
                        LoggingManager.WriteToLog("Material Manager", "Creating Base Path", Settings.RoamingMaterialsPath);

                        Directory.CreateDirectory(Settings.RoamingMaterialsPath);

                        LoggingManager.WriteToLog("Material Manager", "Created Base Path", Settings.RoamingMaterialsPath);
                    }
                    //add default materials
                    if ((!Directory.Exists(Settings.MaterialsPath) && Directory.GetFiles(Settings.RoamingMaterialsPath).Length == 0))
                    {
                        LoggingManager.WriteToLog("Material Manager", "Saving default materials", Settings.RoamingMaterialsPath);

#if LOCTITE
                        File.WriteAllBytes(Path.Combine(Settings.RoamingMaterialsPath, "Henkel.xml"), Properties.Resources.Material_Henkel_xml);
#else
                        File.WriteAllBytes(Path.Combine(Settings.RoamingMaterialsPath, "3D-Materials.xml"), Properties.Resources.Material_3DMaterials_xml);
#endif


                        LoggingManager.WriteToLog("Material Manager", "Saved default materials", Settings.RoamingMaterialsPath);
                    }
                    else if ((Directory.Exists(Settings.MaterialsPath) && Directory.GetFiles(Settings.MaterialsPath).Length == 0))
                    {
                        try
                        {
                            LoggingManager.WriteToLog("Material Manager", "Saving default materials", Settings.MaterialsPath);

#if LOCTITE
                            File.WriteAllBytes(Path.Combine(Settings.MaterialsPath, "Henkel.xml"), Properties.Resources.Material_Henkel_xml);
#else
                            File.WriteAllBytes(Path.Combine(Settings.MaterialsPath, "3D-Materials.xml"), Properties.Resources.Material_3DMaterials_xml);
#endif

                            LoggingManager.WriteToLog("Material Manager", "Saved default materials", Settings.RoamingMaterialsPath);
                        }
                        catch
                        {
                        }
                    }
                }

                if (Directory.Exists(Settings.MaterialsPath))
                {
                    foreach (var supplierXML in Directory.GetFiles(Settings.MaterialsPath))
                    {
                        LoggingManager.WriteToLog("Material Manager", "Loading material", supplierXML);

                        var updateMaterialFile = false;
                        MaterialsBySupplier updateSupplierMaterials = null;
                        using (var materialReader = new StreamReader(supplierXML))
                        {
                            var supplierMaterials = (MaterialsBySupplier)serializer.Deserialize(materialReader);
                            supplierMaterials.FilePath = supplierXML.Replace("/", "\\");

                            LoggingManager.WriteToLog("Material Manager", "Loaded material", supplierXML);
                            _materialCatalog.Add(supplierMaterials);

                            foreach (var material in supplierMaterials.Materials)
                            {
                                if (material.Id == Guid.Empty)
                                {
                                    material.Id        = Guid.NewGuid();
                                    updateMaterialFile = true;
                                }

                                //material.TransitionLayers.Add(new DAL.Catalogs.MaterialTransitionLayer() { CT = 100, LI = 15 });

                                if (material.SupportProfiles == null || material.SupportProfiles.Count == 0)
                                {
                                    material.SupportProfiles.Add(new SupportProfile());
                                    material.SupportProfiles[0].Selected = true;
                                    material.SupportProfiles[0].Default  = true;
                                }
                            }

                            updateSupplierMaterials = supplierMaterials;

                            materialReader.Close();
                        }

                        if (updateMaterialFile)
                        {
                            updateSupplierMaterials.SaveToFile();
                        }
                    }

                    if (addHandlers)
                    {
                        AddMaterialWatcher(Settings.MaterialsPath.Replace("/", "\\"));
                    }
                }

                else if (Directory.Exists(Settings.RoamingMaterialsPath))
                {
                    foreach (var supplierXML in Directory.GetFiles(Settings.RoamingMaterialsPath))
                    {
                        LoggingManager.WriteToLog("Material Manager", "Loading material", supplierXML);

                        var updateMaterialFile = false;
                        MaterialsBySupplier updateSupplierMaterials = null;
                        using (var materialReader = new StreamReader(supplierXML))
                        {
                            var supplierMaterials = (MaterialsBySupplier)serializer.Deserialize(materialReader);
                            supplierMaterials.FilePath = supplierXML.Replace("/", "\\");;

                            LoggingManager.WriteToLog("Material Manager", "Loaded material", supplierXML);

                            var supplierNameFound = false;
                            foreach (var supplier in _materialCatalog)
                            {
                                if (!string.IsNullOrEmpty(supplier.Supplier))
                                {
                                    if (supplier.Supplier.ToLower().Trim() == supplierMaterials.Supplier.ToLower().Trim())
                                    {
                                        supplierNameFound = true;
                                        break;
                                    }
                                }
                            }

                            if (!supplierNameFound)
                            {
                                foreach (var material in supplierMaterials.Materials)
                                {
                                    if (material.Id == Guid.Empty)
                                    {
                                        material.Id        = Guid.NewGuid();
                                        updateMaterialFile = true;
                                    }
                                    // material.TransitionLayers.Add(new DAL.Catalogs.MaterialTransitionLayer() { CT = 100, LI = 15 });

                                    if (material.SupportProfiles == null || material.SupportProfiles.Count == 0)
                                    {
                                        material.SupportProfiles.Add(SupportProfile.CreateDefault());
                                    }
                                }
                                _materialCatalog.Add(supplierMaterials);
                            }

                            updateSupplierMaterials = supplierMaterials;

                            materialReader.Close();

                            if (updateMaterialFile)
                            {
                                updateSupplierMaterials.SaveToFile();
                            }
                        }
                    }

                    if (addHandlers)
                    {
                        AddMaterialWatcher(Settings.RoamingMaterialsPath.Replace("/", "\\"));
                    }
                }
            }
            catch (Exception exc)
            {
                new frmMessageBox("Material Manager", exc.ToString(), MessageBoxButtons.OK, MessageBoxDefaultButton.Button2).ShowDialog();
                LoggingManager.WriteToLog("Material Manager", "Exception", exc);
            }
        }
Exemplo n.º 10
0
        internal void LoadSelectedMaterial(Material selectedMaterial, MaterialsBySupplier selectedSupplier)
        {
            this._selectedMaterial = selectedMaterial;
            this._selectedSupplier = selectedSupplier;
            //resin properties
            try
            {
                this.btnResinModelColor.BackColor = selectedMaterial.ModelColor;
                this.txtResinName.Text            = selectedMaterial.Name;
                this.txtDisplayName.Text          = selectedMaterial.DisplayName;

                this.txtResinInitialLayers.Value        = selectedMaterial.InitialLayers;
                this.txtResinPreparationMovements.Value = selectedMaterial.PreparationLayersCount;
                this.txtResinShrinkFactor.Value         = (decimal)selectedMaterial.ShrinkFactor - 1;
                this.txtResinZBleedingOffset.Value      = (decimal)selectedMaterial.BleedingOffset;

                this.txtResinArticle.Text     = selectedMaterial.ArticleNumber;
                this.txtResinArticleURL.Text  = selectedMaterial.ArticleHTTP;
                this.txtResinBatch.Text       = selectedMaterial.BatchNumber;
                this.txtResinPrice.Text       = selectedMaterial.Price.ToString("0.00");
                this.txtResinDescription.Text = selectedMaterial.Description;


                //material properties
                this.txtLayerThickness1.Value              = (decimal)selectedMaterial.LT1;
                this.txtLayerThickness2.Value              = (decimal)selectedMaterial.LT2;
                this.txtLayerRehabTime1.Value              = (decimal)selectedMaterial.RT1;
                this.txtLayerRehabTime2.Value              = (decimal)selectedMaterial.RT2;
                this.txtLayerCurringTime1.Value            = (decimal)selectedMaterial.CT1;
                this.txtLayerCurringTime2.Value            = (decimal)selectedMaterial.CT2;
                this.txtLayerRehabTimeAfterCuring1.Value   = (decimal)selectedMaterial.RTAC1;
                this.txtLayerRehabTimeAfterCuring2.Value   = (decimal)selectedMaterial.RTAC2;
                this.txtLayerRetractionHeight1.Value       = (decimal)selectedMaterial.RH1;
                this.txtLayerRetractionHeight2.Value       = (decimal)selectedMaterial.RH2;
                this.txtLayerRetractionSpeedUp1.Value      = (decimal)selectedMaterial.RSU1;
                this.txtLayerRetractionSpeedUp2.Value      = (decimal)selectedMaterial.RSU2;
                this.txtLayerTimeAtTop1.Value              = (decimal)selectedMaterial.TAT1;
                this.txtLayerTimeAtTop2.Value              = (decimal)selectedMaterial.TAT2;
                this.txtLayerRetractionSpeedDown1.Value    = (decimal)selectedMaterial.RSD1;
                this.txtLayerRetractionSpeedDown2.Value    = (decimal)selectedMaterial.RSD2;
                this.txtLayerLightIntensityStrength1.Value = (decimal)selectedMaterial.LightIntensityPercentage1;
                this.txtLayerLightIntensityStrength2.Value = (decimal)selectedMaterial.LightIntensityPercentage2;

                this.txtLayerTransitionLayer1CT.Value   = 0;
                this.txtLayerTransitionLayer1LI.Value   = 0;
                this.txtLayerTransitionLayer1RTAC.Value = 0;
                this.txtLayerTransitionLayer2CT.Value   = 0;
                this.txtLayerTransitionLayer2LI.Value   = 0;
                this.txtLayerTransitionLayer2RTAC.Value = 0;
                this.txtLayerTransitionLayer3CT.Value   = 0;
                this.txtLayerTransitionLayer3LI.Value   = 0;
                this.txtLayerTransitionLayer3RTAC.Value = 0;
                this.txtLayerTransitionLayer4CT.Value   = 0;
                this.txtLayerTransitionLayer4LI.Value   = 0;
                this.txtLayerTransitionLayer4RTAC.Value = 0;
                this.txtLayerTransitionLayer5CT.Value   = 0;
                this.txtLayerTransitionLayer5LI.Value   = 0;
                this.txtLayerTransitionLayer5RTAC.Value = 0;

                if (selectedMaterial.TransitionLayers != null && selectedMaterial.TransitionLayers.Count > 0)
                {
                    if (selectedMaterial.TransitionLayers.Count > 4)
                    {
                        this.txtLayerTransitionLayer5CT.Value   = (decimal)selectedMaterial.TransitionLayers[4].CT;
                        this.txtLayerTransitionLayer5LI.Value   = (decimal)selectedMaterial.TransitionLayers[4].LI;
                        this.txtLayerTransitionLayer5RTAC.Value = (decimal)selectedMaterial.TransitionLayers[4].RTAC;
                    }
                    if (selectedMaterial.TransitionLayers.Count > 3)
                    {
                        this.txtLayerTransitionLayer4CT.Value   = (decimal)selectedMaterial.TransitionLayers[3].CT;
                        this.txtLayerTransitionLayer4LI.Value   = (decimal)selectedMaterial.TransitionLayers[3].LI;
                        this.txtLayerTransitionLayer4RTAC.Value = (decimal)selectedMaterial.TransitionLayers[3].RTAC;
                    }
                    if (selectedMaterial.TransitionLayers.Count > 2)
                    {
                        this.txtLayerTransitionLayer3CT.Value   = (decimal)selectedMaterial.TransitionLayers[2].CT;
                        this.txtLayerTransitionLayer3LI.Value   = (decimal)selectedMaterial.TransitionLayers[2].LI;
                        this.txtLayerTransitionLayer3RTAC.Value = (decimal)selectedMaterial.TransitionLayers[2].RTAC;
                    }
                    if (selectedMaterial.TransitionLayers.Count > 1)
                    {
                        this.txtLayerTransitionLayer2CT.Value   = (decimal)selectedMaterial.TransitionLayers[1].CT;
                        this.txtLayerTransitionLayer2LI.Value   = (decimal)selectedMaterial.TransitionLayers[1].LI;
                        this.txtLayerTransitionLayer2RTAC.Value = (decimal)selectedMaterial.TransitionLayers[1].RTAC;
                    }
                    if (selectedMaterial.TransitionLayers.Count > 0)
                    {
                        this.txtLayerTransitionLayer1CT.Value   = (decimal)selectedMaterial.TransitionLayers[0].CT;
                        this.txtLayerTransitionLayer1LI.Value   = (decimal)selectedMaterial.TransitionLayers[0].LI;
                        this.txtLayerTransitionLayer1RTAC.Value = (decimal)selectedMaterial.TransitionLayers[0].RTAC;
                    }
                }

                //support cone properties
                if (selectedMaterial.SupportProfiles == null || selectedMaterial.SupportProfiles.Count == 0)
                {
                    selectedMaterial.SupportProfiles = new List <SupportProfile>();
                    selectedMaterial.SupportProfiles.Add(SupportProfile.CreateDefault());
                }
                if (selectedMaterial.SupportProfiles.First().SupportTopRadius == 0 && selectedMaterial.SupportProfiles.First().SupportTopHeight == 0)
                {
                    selectedMaterial.SupportProfiles.Clear();
                    selectedMaterial.SupportProfiles.Add(SupportProfile.CreateDefault());
                }


                var defaultSupportProfile = selectedMaterial.SupportProfiles.First();
                this.txtSupportConeTopRadius.Value             = (decimal)defaultSupportProfile.SupportTopRadius;
                this.txtSupportConeTopHeight.Value             = (decimal)defaultSupportProfile.SupportTopHeight;
                this.txtSupportConeMiddleRadius.Value          = (decimal)defaultSupportProfile.SupportMiddleRadius;
                this.txtSupportConeBottomRadius.Value          = (decimal)defaultSupportProfile.SupportBottomRadius;
                this.txtSupportConeBottomHeight.Value          = (decimal)defaultSupportProfile.SupportBottomHeight;
                this.txtSupportConeBottomWidthCorrection.Value = (decimal)defaultSupportProfile.SupportBottomWidthCorrection;

                this.txtMAGSAIInfillDistance.Value   = (decimal)defaultSupportProfile.SupportInfillDistance <= 0 ? (decimal)2.1 : (decimal)defaultSupportProfile.SupportInfillDistance;
                this.txtMAGSAIOverhangDistance.Value = (decimal)defaultSupportProfile.SupportOverhangDistance <= 0 ? (decimal)2.1 : (decimal)defaultSupportProfile.SupportOverhangDistance;
                this.txtMAGSAIOutlineDistance.Value  = (decimal)defaultSupportProfile.SupportLowestPointsDistance <= 0 ? (decimal)2.1 : (decimal)defaultSupportProfile.SupportLowestPointsDistance;

                this.txtMAGSAILowestPointOffset1CenterDistanceFactor1.Value  = 0;
                this.txtMAGSAILowestPointOffset1OutlineDistanceFactor1.Value = 0;
                this.txtMAGSAILowestPointOffset1CenterDistanceFactor2.Value  = 0;
                this.txtMAGSAILowestPointOffset1OutlineDistanceFactor2.Value = 0;
                this.txtMAGSAILowestPointOffset1CenterDistanceFactor3.Value  = 0;
                this.txtMAGSAILowestPointOffset1OutlineDistanceFactor3.Value = 0;
                this.txtMAGSAILowestPointOffset1CenterDistanceFactor4.Value  = 0;
                this.txtMAGSAILowestPointOffset1OutlineDistanceFactor4.Value = 0;

                if (defaultSupportProfile.SupportLowestPointsOffset.Count > 0 && defaultSupportProfile.SupportLowestPointsDistanceOffset.Count > 0)
                {
                    this.txtMAGSAILowestPointOffset1CenterDistanceFactor1.Value  = (decimal)defaultSupportProfile.SupportLowestPointsOffset[0];
                    this.txtMAGSAILowestPointOffset1OutlineDistanceFactor1.Value = (decimal)defaultSupportProfile.SupportLowestPointsDistanceOffset[0];

                    if (defaultSupportProfile.SupportLowestPointsOffset.Count > 1 && defaultSupportProfile.SupportLowestPointsDistanceOffset.Count > 1)
                    {
                        this.txtMAGSAILowestPointOffset1CenterDistanceFactor2.Value  = (decimal)defaultSupportProfile.SupportLowestPointsOffset[1];
                        this.txtMAGSAILowestPointOffset1OutlineDistanceFactor2.Value = (decimal)defaultSupportProfile.SupportLowestPointsDistanceOffset[1];

                        if (defaultSupportProfile.SupportLowestPointsOffset.Count > 2 && defaultSupportProfile.SupportLowestPointsDistanceOffset.Count > 2)
                        {
                            this.txtMAGSAILowestPointOffset1CenterDistanceFactor3.Value  = (decimal)defaultSupportProfile.SupportLowestPointsOffset[2];
                            this.txtMAGSAILowestPointOffset1OutlineDistanceFactor3.Value = (decimal)defaultSupportProfile.SupportLowestPointsDistanceOffset[2];

                            if (defaultSupportProfile.SupportLowestPointsOffset.Count > 3 && defaultSupportProfile.SupportLowestPointsDistanceOffset.Count > 3)
                            {
                                this.txtMAGSAILowestPointOffset1CenterDistanceFactor4.Value  = (decimal)defaultSupportProfile.SupportLowestPointsOffset[3];
                                this.txtMAGSAILowestPointOffset1OutlineDistanceFactor4.Value = (decimal)defaultSupportProfile.SupportLowestPointsDistanceOffset[3];
                            }
                        }
                    }
                }

                this.txtMAGSAIAngledSurfaceDistance1.Value = this.txtMAGSAIAngledSurfaceDistance1.Minimum;
                this.txtMAGSAIAngledSurfaceDistance2.Value = this.txtMAGSAIAngledSurfaceDistance2.Minimum;

                if (defaultSupportProfile.SurfaceAngles.Count > 0 && defaultSupportProfile.SurfaceAngleDistanceFactors.Count > 0)
                {
                    this.txtMAGSAIAngledSurfaceDistance1.Value = (decimal)defaultSupportProfile.SurfaceAngleDistanceFactors[0];

                    if (defaultSupportProfile.SurfaceAngles.Count > 1 && defaultSupportProfile.SurfaceAngleDistanceFactors.Count > 1)
                    {
                        this.txtMAGSAIAngledSurfaceDistance2.Value = (decimal)defaultSupportProfile.SurfaceAngleDistanceFactors[1];
                    }
                }

                if (_magsAITabHidden)
                {
                    this.tbMaterialSettings.TabPages.Remove(this.tbMAGSAI);
                }
            }
            catch (Exception exc)
            {
                MessageBox.Show(exc.Message);
            }

            this.txtSupportConeTopHeight.ValueChanged             += UpdateSupportConeDrawing;
            this.txtSupportConeBottomHeight.ValueChanged          += UpdateSupportConeDrawing;
            this.txtSupportConeTopRadius.ValueChanged             += UpdateSupportConeDrawing;
            this.txtSupportConeMiddleRadius.ValueChanged          += UpdateSupportConeDrawing;
            this.txtSupportConeBottomRadius.ValueChanged          += UpdateSupportConeDrawing;
            this.txtSupportConeBottomWidthCorrection.ValueChanged += UpdateSupportConeDrawing;

            if (this.tbMaterialSettings.SelectedTab == this.tbSupportProperties)
            {
                this.tbMaterialSettings.Update();
                DrawSupportCone();
            }
        }
Exemplo n.º 11
0
        internal void RefreshMaterials()
        {
            this.cbMaterialManufacturer.Items.Clear();

            var selectedPrinter = this.cbDefaultPrinter.SelectedItem as AtumPrinter;

            if (MaterialManager.Catalog != null)
            {
                if (!(selectedPrinter is AtumDLPStation5) && !(selectedPrinter is LoctiteV10))
                {
                    //filter on hardwaretype and resolution
                    foreach (var supplier in MaterialManager.Catalog)
                    {
                        var filteredSupplier = new MaterialsBySupplier();
                        filteredSupplier.Supplier = supplier.Supplier;
                        var filteredMaterials = supplier.Materials.Where(m => string.IsNullOrEmpty(m.PrinterHardwareType));
                        foreach (var filteredMaterial in filteredMaterials)
                        {
                            filteredSupplier.Materials.Add(filteredMaterial);
                            if (filteredMaterial.IsDefault)
                            {
                                if (!filteredMaterial.DisplayName.Contains("(*)"))
                                {
                                    filteredMaterial.DisplayName += " (*)";
                                }
                            }
                        }

                        if (filteredSupplier.Materials.Count > 0)
                        {
                            this.cbMaterialManufacturer.Items.Add(filteredSupplier);
                        }
                    }
                }
                else
                {
                    //filter on hardwaretype and resolution
                    foreach (var supplier in MaterialManager.Catalog)
                    {
                        var filteredSupplier = new MaterialsBySupplier();
                        filteredSupplier.Supplier = supplier.Supplier;
                        var filteredMaterials = supplier.Materials.Where(m => m.XYResolution == selectedPrinter.PrinterXYResolutionAsInt && m.PrinterHardwareType == selectedPrinter.PrinterHardwareType);
                        foreach (var filteredMaterial in filteredMaterials)
                        {
                            filteredSupplier.Materials.Add(filteredMaterial);
                            if (filteredMaterial.IsDefault)
                            {
                                if (filteredMaterial.DisplayName.Contains("(*)"))
                                {
                                    filteredMaterial.DisplayName = filteredMaterial.DisplayName.Replace("(*)", string.Empty).Trim();
                                }
                            }
                        }

                        if (filteredSupplier.Materials.Count > 0)
                        {
                            this.cbMaterialManufacturer.Items.Add(filteredSupplier);
                        }
                    }
                }

                var supplierIndex = 0;
                foreach (var supplierItem in this.cbMaterialManufacturer.Items)
                {
                    var supplier = supplierItem as MaterialsBySupplier;
                    if (supplier.Materials.Any(m => m.IsDefault))
                    {
                        break;
                    }

                    supplierIndex++;
                }

                if (supplierIndex >= this.cbMaterialManufacturer.Items.Count)
                {
                    supplierIndex = 0;
                }
                if (this.cbMaterialManufacturer.Items.Count > 0)
                {
                    this.cbMaterialManufacturer.SelectedIndex = supplierIndex;
                }

                //this.cbMaterialManufacturer_SelectedIndexChanged(null, null);
            }
        }
Exemplo n.º 12
0
        private void FillAvailableMaterials()
        {
            SelectedMaterials = new List <MaterialsBySupplier>();
            UpdateControls();

            var summaryTop  = 24;
            var summaryleft = 24;

            var i = 0;

            foreach (var catalog in this._allOnlineMaterials)
            {
                List <MaterialsBySupplier> materialListBySupplier = new List <MaterialsBySupplier>();
                materialListBySupplier = catalog.Value.OrderBy(x => x.Supplier).ToList();

                foreach (var materialBySupplier in materialListBySupplier)
                {
                    foreach (var material in materialBySupplier.Materials)
                    {
                        i += 1;
                        var materialWithSupplier = new MaterialsBySupplier();
                        materialWithSupplier.Supplier = materialBySupplier.Supplier;
                        materialWithSupplier.Materials.Add(material);

                        displayMaterial displayMaterialControl = PushMaterialControl(summaryTop, summaryleft, materialWithSupplier);
                        if (i % 3 == 0)
                        {
                            summaryTop += (displayMaterialControl.Height + 24);
                            summaryleft = 24;
                        }
                        else
                        {
                            summaryleft += (displayMaterialControl.Width + 24);
                        }
                    }
                }
                if (this.pnlMaterialDisplay.InvokeRequired)
                {
                    this.pnlMaterialDisplay.Invoke(new MethodInvoker(delegate
                    {
                        this.pnlMaterialDisplay.AutoScroll = true;
                    }));
                }
                else
                {
                    this.pnlMaterialDisplay.AutoScroll = true;
                }
            }

            #region Testing Data
            //foreach (var materialBySupplier in MaterialManager.Catalog)
            //{
            //    foreach (var material in materialBySupplier.Materials)
            //    {
            //        i += 1;
            //        if (i % 3 == 0)
            //        {
            //            var displayMaterialControl = new displayMaterial(material);
            //            displayMaterialControl.SelectionChanged += DisplayMaterialControl_SelectionChanged;
            //            displayMaterialControl.Top = summaryTop;
            //            displayMaterialControl.Width = 208;
            //            displayMaterialControl.Height = 126;
            //            displayMaterialControl.Left = summaryleft;
            //            this.pnlMaterialDisplay.Controls.Add(displayMaterialControl);
            //            summaryTop += (displayMaterialControl.Height + 24);
            //            summaryleft = 24;
            //        }
            //        else
            //        {
            //            var displayMaterialControl = new displayMaterial(material);
            //            displayMaterialControl.SelectionChanged += DisplayMaterialControl_SelectionChanged;
            //            displayMaterialControl.Top = summaryTop;
            //            displayMaterialControl.Width = 208;
            //            displayMaterialControl.Height = 126;
            //            displayMaterialControl.Left = summaryleft;
            //            this.pnlMaterialDisplay.Controls.Add(displayMaterialControl);
            //            summaryleft += (displayMaterialControl.Width + 24);
            //        }
            //    }
            //}
            //this.pnlMaterialDisplay.AutoScroll = true;
            #endregion
        }