Exemplo n.º 1
0
        public void AddItem(PrintItemWrapper item, ValidateSizeOn32BitSystems checkSize = ValidateSizeOn32BitSystems.Required, int indexToInsert = -1)
        {
            if (Is32Bit())
            {
                // Check if the part we are adding is BIG. If it is warn the user and
                // possibly don't add it
                bool warnAboutFileSize  = false;
                long estimatedMemoryUse = 0;
                if (File.Exists(item.FileLocation) &&
                    checkSize == ValidateSizeOn32BitSystems.Required)
                {
                    switch (Path.GetExtension(item.FileLocation).ToUpper())
                    {
                    case ".STL":
                        estimatedMemoryUse = StlProcessing.GetEstimatedMemoryUse(item.FileLocation);
                        break;

                    case ".AMF":
                        estimatedMemoryUse = AmfProcessing.GetEstimatedMemoryUse(item.FileLocation);
                        break;
                    }

                    if (OsInformation.OperatingSystem == OSType.Android)
                    {
                        if (estimatedMemoryUse > 100000000)
                        {
                            warnAboutFileSize = true;
                        }
                    }
                    else
                    {
                        if (estimatedMemoryUse > 500000000)
                        {
                            warnAboutFileSize = true;
                        }
                    }
                }

                if (warnAboutFileSize)
                {
                    partUnderConsideration = item;
                    // Show a dialog and only load the part to the queue if the user clicks yes.
                    UiThread.RunOnIdle((state) =>
                    {
                        string memoryWarningMessage = "Are you sure you want to add this part ({0}) to the Queue?\nThe 3D part you are trying to load may be too complicated and cause performance or stability problems.\n\nConsider reducing the geometry before proceeding.".Localize().FormatWith(item.Name);
                        StyledMessageBox.ShowMessageBox(UserSaidToAllowAddToQueue, memoryWarningMessage, "File May Cause Problems".Localize(), StyledMessageBox.MessageType.YES_NO, "Add To Queue", "Do Not Add");
                        // show a dialog to tell the user there is an update
                    });
                    return;
                }
                else
                {
                    DoAddItem(item, indexToInsert);
                }
            }
            else
            {
                DoAddItem(item, indexToInsert);
            }
        }
Exemplo n.º 2
0
        public void LoadMesh(string meshPathAndFileName)
        {
            backgroundWorker = new BackgroundWorker();
            backgroundWorker.WorkerReportsProgress      = true;
            backgroundWorker.WorkerSupportsCancellation = true;

            backgroundWorker.ProgressChanged    += new ProgressChangedEventHandler(backgroundWorker_ProgressChanged);
            backgroundWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(backgroundWorker_RunWorkerCompleted);

            bool loadingMeshFile = false;

            switch (Path.GetExtension(meshPathAndFileName).ToUpper())
            {
            case ".STL":
            {
                StlProcessing stlLoader = new StlProcessing();
                stlLoader.LoadInBackground(backgroundWorker, meshPathAndFileName);
                loadingMeshFile = true;
            }
            break;

            case ".AMF":
            {
                AmfProcessing amfLoader = new AmfProcessing();
                amfLoader.LoadInBackground(backgroundWorker, meshPathAndFileName);
                loadingMeshFile = true;
            }
            break;

            default:
                loadingMeshFile = false;
                break;
            }

            if (loadingMeshFile)
            {
                meshLoadingStateInfoText         = new TextWidget("Loading Mesh...");
                meshLoadingStateInfoText.HAnchor = HAnchor.ParentCenter;
                meshLoadingStateInfoText.VAnchor = VAnchor.ParentCenter;
                meshLoadingStateInfoText.AutoExpandBoundsToText = true;

                GuiWidget labelContainer = new GuiWidget();
                labelContainer.AnchorAll();
                labelContainer.AddChild(meshLoadingStateInfoText);
                labelContainer.Selectable = false;

                this.AddChild(labelContainer);
            }
            else
            {
                TextWidget no3DView = new TextWidget(string.Format("No 3D view for this file type '{0}'.", Path.GetExtension(meshPathAndFileName).ToUpper()));
                no3DView.Margin  = new BorderDouble(0, 0, 0, 0);
                no3DView.VAnchor = Agg.UI.VAnchor.ParentCenter;
                no3DView.HAnchor = Agg.UI.HAnchor.ParentCenter;
                this.AddChild(no3DView);
            }
        }