private void SetMaximumClones()
        {
            if (ObjectView.Objects3D.Count > 1)
            {
                _packModelsRequest             = PackingHelper.CreatePackModelsRequest(null);
                _packModelsRequest.PackingType = TypeOfPacking.MaxAmountOfClones;
                var solutions = PackingHelper.CalculatePackingSolutions(_packModelsRequest);

                Dictionary <ModelFootprint, int> modelFootprints = new Dictionary <ModelFootprint, int>();

                foreach (var footprint in solutions.BestSolution.Footprints)
                {
                    var duplicateControl = this.spcModelControls.Panel1.Controls.OfType <DuplicateModelControl>().First(s => s.ModelFootprint.Model == footprint.Model);
                    modelFootprints.Add(footprint, duplicateControl.TotalAmount);
                    duplicateControl.TotalAmount = footprint.CloneCount;
                }


                var cloneModelsEventArtgs = new CloneModelsEventArgs()
                {
                    PackModelsRequest  = _packModelsRequest,
                    PackagingSolutions = solutions,
                    ModelFootprints    = modelFootprints
                };
                this.ValueChanged?.Invoke(null, cloneModelsEventArtgs);
            }
            else
            {
                this.Visible = false;
            }

            //
            FillBuildPlateCompleted?.Invoke(null, null);
        }
        private void SceneControlModelDuplicate_Load(object sender, EventArgs e)
        {
            var font = FontManager.Montserrat14Regular;

            this.lblErrorMessage.Font = font;

            this.btnDuplicatesFillPlate.Font = FontManager.Montserrat14Regular;

            if (ObjectView.Objects3D.Count > 1)
            {
                this._packModelsRequest = PackingHelper.CreatePackModelsRequest(null);
            }
        }
        internal void RefreshCurrentDuplicates()
        {
            if (ObjectView.Objects3D.Count > 1)
            {
                _packModelsRequest = PackingHelper.CreatePackModelsRequest(null);
                var solutions = PackingHelper.CalculatePackingSolutions(_packModelsRequest);
                this.spcModelControls.Panel1.Controls.Clear();
                int i             = 0;
                var summaryHeight = 0;
                this.Height = 215;
                foreach (var model in ObjectView.Objects3D)
                {
                    if (model != null && (!(model is GroundPane)))
                    {
                        var stlModel = model as STLModel3D;

                        ModelFootprint modelFootprint = null;
                        if (solutions.BestSolution == null)
                        {
                            modelFootprint       = new ModelFootprint(stlModel.RightPoint - stlModel.LeftPoint, stlModel.FrontPoint - stlModel.BackPoint);
                            modelFootprint.Model = stlModel;
                        }
                        else
                        {
                            modelFootprint = solutions.BestSolution.Footprints.First(f => f.Model == stlModel);
                        }

                        if (i > 0)
                        {
                            this.Height += defaultItemHeight;
                        }

                        DuplicateModelControl duplicateModelControl = new DuplicateModelControl(modelFootprint);
                        if (i % 2 != 0)
                        {
                            duplicateModelControl.BackgroundColor = Color.FromArgb(237, 237, 237);
                        }
                        else
                        {
                            duplicateModelControl.BackgroundColor = Color.FromArgb(224, 224, 224);
                        }

                        duplicateModelControl.Left = 0;
                        duplicateModelControl.Top  = summaryHeight;
                        duplicateModelControl.DuplicatesCount_KeyUp += DuplicateModelControl_DuplicatesCount_KeyPress;
                        duplicateModelControl.DuplicatesMinus_Click += DuplicateModelControl_DuplicatesMinus_Click;
                        duplicateModelControl.DuplicatesPlus_Click  += DuplicateModelControl_DuplicatesPlus_Click;
                        this.spcModelControls.Panel1.Controls.Add(duplicateModelControl);
                        summaryHeight += defaultItemHeight;
                        i++;
                    }
                }
            }
            else
            {
                this.Visible = false;

                //show message
                var tt = new SceneControlManualToolTip();
                tt.SetText("No models available");

                var modelActionsToolbar    = SceneControlToolbarManager.ModelActionsToolbar;
                var btnDuplicationButton   = modelActionsToolbar.ModelDuplicateButton;
                var duplicationButtonPoint = new Point(btnDuplicationButton.Left + btnDuplicationButton.Width + modelActionsToolbar.Left + 16, btnDuplicationButton.Top + modelActionsToolbar.Top);
                duplicationButtonPoint.Y += (btnDuplicationButton.Height / 2) - (tt.Height / 2);
                tt.ShowToolTip(duplicationButtonPoint);

                ToolbarActionsManager.Update(Core.Enums.MainFormToolStripActionType.btnSelectPressed, frmStudioMain.SceneControl, null);
            }
        }