Example #1
0
		public override bool OpenFileDialog(OpenFileDialogParams openParams, OpenFileDialogDelegate callback)
		{
			WidgetForWindowsFormsAbstract.MainWindowsFormsWindow.ShowingSystemDialog = true;
			openParams.FileName = "";
			openParams.FileNames = null;

			OpenFileDialog openFileDialog1 = new OpenFileDialog();

			openFileDialog1.InitialDirectory = openParams.InitialDirectory;
			openFileDialog1.Filter = openParams.Filter;
			openFileDialog1.Multiselect = openParams.MultiSelect;
			openFileDialog1.Title = openParams.Title;

			openFileDialog1.FilterIndex = openParams.FilterIndex;
			openFileDialog1.RestoreDirectory = true;

			if (openFileDialog1.ShowDialog() == DialogResult.OK)
			{
				openParams.FileNames = openFileDialog1.FileNames;
				openParams.FileName = openFileDialog1.FileName;
			}

			WidgetForWindowsFormsAbstract.MainWindowsFormsWindow.ShowingSystemDialog = false;

			UiThread.RunOnIdle((state) =>
			{
				OpenFileDialogParams openParamsIn = state as OpenFileDialogParams;
				if (openParamsIn != null)
				{
					callback(openParamsIn);
				}
			}, openParams);
			return true;
		}
Example #2
0
        public override bool OpenFileDialog(OpenFileDialogParams openParams, Action <OpenFileDialogParams> callback)
        {
            ShowFileDialog((fileText) =>
            {
                if (fileText.Length > 2)
                {
                    string[] files       = fileText.Split(';', ' ').Select(f => f.Trim('\"')).ToArray();
                    openParams.FileName  = files[0];
                    openParams.FileNames = files;
                }
                UiThread.RunOnIdle(() => callback?.Invoke(openParams));
            });

            return(true);
        }
Example #3
0
 public static bool OpenFileDialog(OpenFileDialogParams openParams, FileDialogCreator.OpenFileDialogDelegate callback)
 {
     return(FileDialogCreatorPlugin.OpenFileDialog(openParams, (OpenFileDialogParams outputOpenParams) =>
     {
         try
         {
             if (outputOpenParams.FileName != "")
             {
                 string directory = Path.GetDirectoryName(outputOpenParams.FileName);
                 if (directory != null && directory != "")
                 {
                     lastDirectoryUsed = directory;
                 }
             }
         }
         catch (Exception)
         {
         }
         callback(outputOpenParams);
     }
                                                   ));
 }
Example #4
0
		public static bool OpenFileDialog(OpenFileDialogParams openParams, FileDialogCreator.OpenFileDialogDelegate callback)
		{
			return FileDialogCreatorPlugin.OpenFileDialog(openParams, (OpenFileDialogParams outputOpenParams) =>
				{
					try
					{
						if (outputOpenParams.FileName != "")
						{
							string directory = Path.GetDirectoryName(outputOpenParams.FileName);
							if (directory != null && directory != "")
							{
								lastDirectoryUsed = directory;
							}
						}
					}
					catch (Exception)
					{
					}
					callback(outputOpenParams);
				}
			);
		}
Example #5
0
        public override Stream OpenFileDialog(ref OpenFileDialogParams openParams)
        {
            WidgetForWindowsFormsAbstract.MainWindowsFormsWindow.ShowingSystemDialog = true;
            openParams.FileName = "";
            openParams.FileNames = null;
            Stream myStream = null;
            OpenFileDialog openFileDialog1 = new OpenFileDialog();

            openFileDialog1.InitialDirectory = openParams.InitialDirectory;
            openFileDialog1.Filter = openParams.Filter;
            openFileDialog1.Multiselect = openParams.MultiSelect;
            openFileDialog1.Title = openParams.Title;

            openFileDialog1.FilterIndex = openParams.FilterIndex;
            openFileDialog1.RestoreDirectory = true;

            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    openParams.FileNames = openFileDialog1.FileNames;
                    if ((myStream = openFileDialog1.OpenFile()) != null && !openParams.MultiSelect)
                    {
                        openParams.FileName = openFileDialog1.FileName;
                        WidgetForWindowsFormsAbstract.MainWindowsFormsWindow.ShowingSystemDialog = false;
                        return myStream;
                    }
                }
                catch (Exception ex)
                {
                    System.Windows.Forms.MessageBox.Show("Error: Could not read file from disk. Original error: " + ex.Message);
                }
            }

            WidgetForWindowsFormsAbstract.MainWindowsFormsWindow.ShowingSystemDialog = false;
            return null;
        }
Example #6
0
		public static bool OpenFileDialog(OpenFileDialogParams openParams, FileDialogCreator.OpenFileDialogDelegate callback)
		{
			return FileDialogCreatorPlugin.OpenFileDialog(openParams, (OpenFileDialogParams outputOpenParams) =>
				{
					try
					{
						if (outputOpenParams.FileName != "")
						{
							string directory = Path.GetDirectoryName(outputOpenParams.FileName);
							if (directory != null && directory != "")
							{
								lastDirectoryUsed = directory;
							}
						}
					}
					catch (Exception e)
					{
						Debug.Print(e.Message);
						GuiWidget.BreakInDebugger();
					}
					callback(outputOpenParams);
				}
			);
		}
 public static bool OpenFileDialog(OpenFileDialogParams openParams, Action <OpenFileDialogParams> callback)
 {
     return(FileDialogCreatorPlugin.OpenFileDialog(openParams, (OpenFileDialogParams outputOpenParams) =>
     {
         try
         {
             if (outputOpenParams.FileName != "")
             {
                 string directory = Path.GetDirectoryName(outputOpenParams.FileName);
                 if (directory != null && directory != "")
                 {
                     lastDirectoryUsed = directory;
                 }
             }
         }
         catch (Exception e)
         {
             Debug.Print(e.Message);
             GuiWidget.BreakInDebugger();
         }
         callback(outputOpenParams);
     }
                                                   ));
 }
        void loadFile_ClickOnIdle(object state)
        {
            OpenFileDialogParams openParams = new OpenFileDialogParams("Select an STL file, Select a GCODE file|*.stl;*.gcode", multiSelect: true);
            FileDialog.OpenFileDialog(ref openParams);
            if (openParams.FileNames != null)
            {
                foreach (string loadedFileName in openParams.FileNames)
                {
                    PrintItem printItem = new PrintItem();
                    printItem.Name = Path.GetFileNameWithoutExtension(loadedFileName);
                    printItem.FileLocation = Path.GetFullPath(loadedFileName);
                    printItem.PrintItemCollectionID = LibraryData.Instance.LibraryCollection.Id;
                    printItem.Commit();

                    LibraryData.Instance.AddItem(new PrintItemWrapper(printItem));
                }
            }
        }
Example #9
0
		public abstract bool OpenFileDialog(OpenFileDialogParams openParams, OpenFileDialogDelegate callback);
        void LoadFileOnIdle(object state)
        {
            OpenFileDialogParams openParams = new OpenFileDialogParams("Select an STL file, Select a GCODE file|*.stl;*.gcode", multiSelect: true);
			openParams.ActionButtonLabel = "Add to Queue";
			openParams.Title = "MatterControl: Select A File";

            FileDialog.OpenFileDialog(ref openParams);
            if (openParams.FileNames != null)
            {
                foreach (string loadedFileName in openParams.FileNames)
                {
					PrintQueueItem queueItem = new PrintQueueItem(System.IO.Path.GetFileNameWithoutExtension(loadedFileName), System.IO.Path.GetFullPath(loadedFileName));
					PrintQueueControl.Instance.AddChild(queueItem);
                }
                if (PrintQueueControl.Instance.Count > 0)
                {
                    PrintQueueControl.Instance.SelectedIndex = PrintQueueControl.Instance.Count - 1;
                }
                //PrintQueueControl.Instance.EnsureSelection();
                PrintQueueControl.Instance.Invalidate();
            }
            PrintQueueControl.Instance.SaveDefaultQueue();
        }
		private void importToLibraryloadFile_ClickOnIdle()
		{
			OpenFileDialogParams openParams = new OpenFileDialogParams(ApplicationSettings.OpenPrintableFileParams, multiSelect: true);
			FileDialog.OpenFileDialog(openParams, onLibraryLoadFileSelected);
		}
Example #12
0
        void openFileButton_ButtonClick(object sender, MouseEventArgs mouseEvent)
        {
            UiThread.RunOnIdle((state) =>
                {
                    OpenFileDialogParams openParams = new OpenFileDialogParams("gcode files|*.gcode");
                    Stream streamToLoadFrom = FileDialog.OpenFileDialog(ref openParams);

                    if (openParams.FileName != null && openParams.FileName != "")
                    {
                        gCodeViewWidget.Load(openParams.FileName);
                        currentLayerIndex.Value = 0;
                        currentLayerIndex.MaxValue = gCodeViewWidget.LoadedGCode.NumChangesInZ;
                    }

                    Invalidate();
                });
        }
		private void importPresets_Click(object sender, EventArgs mouseEvent)
		{
			OpenFileDialogParams openParams = new OpenFileDialogParams("Load Slice Preset|*.slice;*.ini");
			openParams.ActionButtonLabel = "Load Slice Preset";
			openParams.Title = "MatterControl: Select A File";

			FileDialog.OpenFileDialog(openParams, onLoadPreset);
		}
		private void onProjectArchiveLoad(OpenFileDialogParams openParams)
		{
			List<PrintItem> partFiles;
			if (openParams.FileNames != null)
			{
				string loadedFileName = openParams.FileName;
				partFiles = ImportFromProjectArchive(loadedFileName);
				if (partFiles != null)
				{
					foreach (PrintItem part in partFiles)
					{
						QueueData.Instance.AddItem(new PrintItemWrapper(new PrintItem(part.Name, part.FileLocation)));
					}
				}
			}
		}
Example #15
0
 public static Stream OpenFileDialog(ref OpenFileDialogParams openParams)
 {
     return FileDialogCreatorPlugin.OpenFileDialog(ref openParams);
 }
        void createDiscreteMeshesBackgroundWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            // remove the original mesh and replace it with these new meshes
            PullMeshDataFromAsynchLists();

            UnlockEditControls();

            autoArrangeButton.Visible = true;
            viewControls3D.partSelectButton.ClickButton(null);

            Invalidate();

            if (OpenAddDialogWhenDone)
            {
                OpenAddDialogWhenDone = false;
                OpenFileDialogParams openParams = new OpenFileDialogParams("Select an STL file|*.stl", multiSelect: true);

                FileDialog.OpenFileDialog(ref openParams);
                LoadAndAddPartsToPlate(openParams.FileNames);
            }

            if (pendingPartsToLoad.Count > 0)
            {
                LoadAndAddPartsToPlate(pendingPartsToLoad.ToArray());
            }
        }
		private void onManifestFileLoad(OpenFileDialogParams openParams)
		{
			if (openParams.FileName != null)
			{
				string loadedFileName = openParams.FileName;
				List<PrintItem> printItems = ImportFromJson(loadedFileName);
			}
		}
		public void OpenFromDialog()
		{
			OpenFileDialogParams openParams = new OpenFileDialogParams("Select a Project file|*.mcp");
			FileDialog.OpenFileDialog(openParams, onManifestFileLoad);
		}
		private void onPresetLoad(OpenFileDialogParams openParams)
		{
			if (openParams.FileNames != null)
			{
				SliceSettingsCollection settingsCollection;
				try
				{
					if (File.Exists(openParams.FileName))
					{
						// TODO: Review bindings to int printerID
						int printerID;
						int.TryParse(ActiveSliceSettings.Instance.Id, out printerID);

						//Create collection to hold preset settings
						settingsCollection = new SliceSettingsCollection();
						settingsCollection.Tag = windowController.filterTag;
						settingsCollection.PrinterId = printerID;
						settingsCollection.Name = System.IO.Path.GetFileNameWithoutExtension(openParams.FileName);
						settingsCollection.Commit();

						string[] lines = System.IO.File.ReadAllLines(openParams.FileName);
						foreach (string line in lines)
						{
							//Ignore commented lines
							if (!line.StartsWith("#"))
							{
								string[] settingLine = line.Split('=');
								string keyName = settingLine[0].Trim();
								string settingDefaultValue = settingLine[1].Trim();

								//To do - validate imported settings as valid (KP)
								SliceSetting sliceSetting = new SliceSetting();
								sliceSetting.Name = keyName;
								sliceSetting.Value = settingDefaultValue;
								sliceSetting.SettingsCollectionId = settingsCollection.Id;
								sliceSetting.Commit();
							}
						}
						windowController.ChangeToSlicePresetList();
					}
				}
				catch (Exception)
				{
					// Error loading configuration
				}
			}
		}
		private void importPresetDo()
		{
			OpenFileDialogParams openParams = new OpenFileDialogParams("Load Slice Preset|*.slice;*.ini");
			openParams.ActionButtonLabel = "Load Slice Preset";
			openParams.Title = "MatterControl: Select A File";

			FileDialog.OpenFileDialog(openParams, onPresetLoad);
		}
        public List<PrintItem> OpenFromDialog()
        {
            OpenFileDialogParams openParams = new OpenFileDialogParams("Select a Project file|*.mcp");

            System.IO.Stream streamToLoadFrom = FileDialog.OpenFileDialog(ref openParams);
            if (streamToLoadFrom != null)
            {
                string loadedFileName = openParams.FileName;
                return ImportFromJson(loadedFileName);
            }
            else
            {
                return null;
            }
        }
Example #22
0
 public abstract bool OpenFileDialog(OpenFileDialogParams openParams, OpenFileDialogDelegate callback);
Example #23
0
 public abstract Stream OpenFileDialog(ref OpenFileDialogParams openParams);
        bool importFile_Click()
        {
            UiThread.RunOnIdle((state) =>
            {  
                OpenFileDialogParams openParams = new OpenFileDialogParams("Select an STL file, Select a GCODE file|*.stl;*.gcode", multiSelect: true);
                openParams.ActionButtonLabel = "Add to Queue";
                openParams.Title = "MatterControl: Select A File";

                FileDialog.OpenFileDialog(ref openParams);
                if (openParams.FileNames != null)
                {
                    foreach (string loadedFileName in openParams.FileNames)
                    {
                        QueueData.Instance.AddItem(new PrintItemWrapper(new PrintItem(Path.GetFileNameWithoutExtension(loadedFileName), Path.GetFullPath(loadedFileName))));
                    }
                }
            });
            return true;
        }
 public abstract bool OpenFileDialog(OpenFileDialogParams openParams, Action <OpenFileDialogParams> callback);
		private void onLoadPreset(OpenFileDialogParams openParams)
		{
			if (openParams.FileNames != null)
			{
				Dictionary<string, DataStorage.SliceSetting> settingsDictionary = new Dictionary<string, DataStorage.SliceSetting>();
				try
				{
					if (File.Exists(openParams.FileName))
					{
						string[] lines = System.IO.File.ReadAllLines(openParams.FileName);
						foreach (string line in lines)
						{
							//Ignore commented lines
							if (!line.StartsWith("#"))
							{
								string[] settingLine = line.Split('=');
								string keyName = settingLine[0].Trim();
								string settingDefaultValue = settingLine[1].Trim();

								DataStorage.SliceSetting sliceSetting = new DataStorage.SliceSetting();
								sliceSetting.Name = keyName;
								sliceSetting.Value = settingDefaultValue;
								sliceSetting.SettingsCollectionId = windowController.ActivePresetLayer.settingsCollectionData.Id;

								settingsDictionary.Add(keyName, sliceSetting);
							}
						}
						windowController.ActivePresetLayer.settingsDictionary = settingsDictionary;
						LoadSettingsRows();
					}
				}
				catch (Exception)
				{
					// Error loading configuration
				}
			}
		}
		public void LoadSettingsFromIni()
		{
			OpenFileDialogParams openParams = new OpenFileDialogParams("Load Slice Configuration|*.slice;*.ini");
			openParams.ActionButtonLabel = "Load Configuration";
			openParams.Title = "MatterControl: Select A File";

			FileDialog.OpenFileDialog(openParams, onSettingsFileSelected);
		}
		private static void onLibraryLoadFileSelected(OpenFileDialogParams openParams)
		{
			if (openParams.FileNames != null)
			{
				currentPrintLibraryWidget.libraryDataView.CurrentLibraryProvider.AddFilesToLibrary(openParams.FileNames, null);
			}
		}
        public View3DTransformPart(PrintItemWrapper printItemWrapper, Vector3 viewerVolume, Vector2 bedCenter, MeshViewerWidget.BedShape bedShape, WindowType windowType, AutoRotate autoRotate)
        {
            this.windowType = windowType;
            autoRotateEnabled = (autoRotate == AutoRotate.Enabled);
            MeshExtraData = new List<PlatingMeshData>();
            MeshExtraData.Add(new PlatingMeshData());

            this.printItemWrapper = printItemWrapper;

            FlowLayoutWidget mainContainerTopToBottom = new FlowLayoutWidget(FlowDirection.TopToBottom);
            mainContainerTopToBottom.HAnchor = Agg.UI.HAnchor.Max_FitToChildren_ParentWidth;
            mainContainerTopToBottom.VAnchor = Agg.UI.VAnchor.Max_FitToChildren_ParentHeight;

            FlowLayoutWidget centerPartPreviewAndControls = new FlowLayoutWidget(FlowDirection.LeftToRight);
            centerPartPreviewAndControls.AnchorAll();

            GuiWidget viewArea = new GuiWidget();
            viewArea.AnchorAll();
            {
                meshViewerWidget = new MeshViewerWidget(viewerVolume, bedCenter, bedShape, "Press 'Add' to select an item.".Localize());
                
                // this is to add an image to the bed
                string imagePathAndFile = Path.Combine(ApplicationDataStorage.Instance.ApplicationStaticDataPath, "OEMSettings", "bedimage.png");
                if (autoRotateEnabled && File.Exists(imagePathAndFile))
                {
                    ImageBuffer wattermarkImage = new ImageBuffer();
                    ImageIO.LoadImageData(imagePathAndFile, wattermarkImage);

                    ImageBuffer bedImage = meshViewerWidget.BedImage;
                    Graphics2D bedGraphics = bedImage.NewGraphics2D();
                    bedGraphics.Render(wattermarkImage, 
                        new Vector2((bedImage.Width - wattermarkImage.Width) / 2, (bedImage.Height - wattermarkImage.Height)/2));
                }

                meshViewerWidget.AnchorAll();
            }
            viewArea.AddChild(meshViewerWidget);

            centerPartPreviewAndControls.AddChild(viewArea);
            mainContainerTopToBottom.AddChild(centerPartPreviewAndControls);

            FlowLayoutWidget buttonBottomPanel = new FlowLayoutWidget(FlowDirection.LeftToRight);
            buttonBottomPanel.HAnchor = HAnchor.ParentLeftRight;
            buttonBottomPanel.Padding = new BorderDouble(3, 3);
            buttonBottomPanel.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor;

            buttonRightPanel = CreateRightButtonPanel(viewerVolume.y);

            CreateOptionsContent();

            // add in the plater tools
            {
                FlowLayoutWidget editToolBar = new FlowLayoutWidget();

                string progressFindPartsLabel = LocalizedString.Get("Finding Parts");
                string progressFindPartsLabelFull = "{0}:".FormatWith(progressFindPartsLabel);

                processingProgressControl = new ProgressControl(progressFindPartsLabelFull, ActiveTheme.Instance.PrimaryTextColor, ActiveTheme.Instance.PrimaryAccentColor);
                processingProgressControl.VAnchor = Agg.UI.VAnchor.ParentCenter;
                editToolBar.AddChild(processingProgressControl);
                editToolBar.VAnchor |= Agg.UI.VAnchor.ParentCenter;
                processingProgressControl.Visible = false;

                // If the window is embeded (in the center pannel) and there is no item loaded then don't show the add button
                enterEditButtonsContainer = new FlowLayoutWidget();
                {
                    Button addButton = textImageButtonFactory.Generate(LocalizedString.Get("Add"), "icon_circle_plus.png");
                    addButton.Margin = new BorderDouble(right: 10);
                    enterEditButtonsContainer.AddChild(addButton);
                    addButton.Click += (sender, e) =>
                    {
                        UiThread.RunOnIdle((state) =>
                        {
                            EnterEditAndSplitIntoMeshes();
                            OpenAddDialogWhenDone = true;
                        });
                    };

                    Button enterEdittingButton = textImageButtonFactory.Generate(LocalizedString.Get("Edit"));
                    enterEdittingButton.Click += (sender, e) =>
                    {
                        EnterEditAndSplitIntoMeshes();
                    };

                    enterEditButtonsContainer.AddChild(enterEdittingButton);
                }
                editToolBar.AddChild(enterEditButtonsContainer);

                doEdittingButtonsContainer = new FlowLayoutWidget();
                doEdittingButtonsContainer.Visible = false;

                {
                    Button addButton = textImageButtonFactory.Generate(LocalizedString.Get("Add"), "icon_circle_plus.png");
                    addButton.Margin = new BorderDouble(right: 10);
                    doEdittingButtonsContainer.AddChild(addButton);
                    addButton.Click += (sender, e) =>
                    {
                        UiThread.RunOnIdle((state) =>
                        {
                            OpenFileDialogParams openParams = new OpenFileDialogParams("Select an STL file|*.stl", multiSelect: true);

                            FileDialog.OpenFileDialog(ref openParams);
                            LoadAndAddPartsToPlate(openParams.FileNames);
                        });
                    };

                    Button copyButton = textImageButtonFactory.Generate(LocalizedString.Get("Copy"));
                    doEdittingButtonsContainer.AddChild(copyButton);
                    copyButton.Click += (sender, e) =>
                    {
                        MakeCopyOfMesh();
                    };

                    Button deleteButton = textImageButtonFactory.Generate(LocalizedString.Get("Delete"));
                    deleteButton.Margin = new BorderDouble(left: 20);
                    doEdittingButtonsContainer.AddChild(deleteButton);
                    deleteButton.Click += (sender, e) =>
                    {
                        DeleteSelectedMesh();
                    };
                }

                KeyDown += (sender, e) =>
                {
                    KeyEventArgs keyEvent = e as KeyEventArgs;
                    if (keyEvent != null && !keyEvent.Handled)
                    {
                        if (keyEvent.KeyCode == Keys.Delete || keyEvent.KeyCode == Keys.Back)
                        {
                            DeleteSelectedMesh();
                        }

                        if (keyEvent.KeyCode == Keys.Escape)
                        {
                            if (meshSelectInfo.downOnPart)
                            {
                                meshSelectInfo.downOnPart = false;
                                
                                ScaleRotateTranslate translated = SelectedMeshTransform;
                                translated.translation *= transformOnMouseDown;
                                SelectedMeshTransform = translated;

                                Invalidate();
                            }
                        }
                    }
                };

                editToolBar.AddChild(doEdittingButtonsContainer);
                buttonBottomPanel.AddChild(editToolBar);
            }

            autoArrangeButton.Click += (sender, e) =>
            {
                AutoArangePartsInBackground();
            };

            GuiWidget buttonRightPanelHolder = new GuiWidget(HAnchor.FitToChildren, VAnchor.ParentBottomTop);
            centerPartPreviewAndControls.AddChild(buttonRightPanelHolder);
            buttonRightPanelHolder.AddChild(buttonRightPanel);

            viewControls3D = new ViewControls3D(meshViewerWidget);

            buttonRightPanelDisabledCover = new Cover(HAnchor.ParentLeftRight, VAnchor.ParentBottomTop);
            buttonRightPanelDisabledCover.BackgroundColor = new RGBA_Bytes(ActiveTheme.Instance.PrimaryBackgroundColor, 150);
            buttonRightPanelHolder.AddChild(buttonRightPanelDisabledCover);
            LockEditControls();

            GuiWidget leftRightSpacer = new GuiWidget();
            leftRightSpacer.HAnchor = HAnchor.ParentLeftRight;
            buttonBottomPanel.AddChild(leftRightSpacer);

            if (windowType == WindowType.StandAlone)
            {
                Button closeButton = textImageButtonFactory.Generate(LocalizedString.Get("Close"));
                buttonBottomPanel.AddChild(closeButton);
                closeButton.Click += (sender, e) =>
                {
                    CloseOnIdle();
                };
            }

            mainContainerTopToBottom.AddChild(buttonBottomPanel);

            this.AddChild(mainContainerTopToBottom);
            this.AnchorAll();

            meshViewerWidget.TrackballTumbleWidget.TransformState = TrackBallController.MouseDownType.Rotation;
            AddChild(viewControls3D);
            viewControls3D.PartSelectVisible = false;

            AddHandlers();

            if (printItemWrapper != null)
            {
                // don't load the mesh until we get all the rest of the interface built
                meshViewerWidget.LoadMesh(printItemWrapper.FileLocation);
                meshViewerWidget.LoadDone += new EventHandler(meshViewerWidget_LoadDone);
            }

            UiThread.RunOnIdle(AutoSpin);

            if (printItemWrapper == null && windowType == WindowType.Embeded)
            {
                enterEditButtonsContainer.Visible = false;
            }

            if (windowType == WindowType.Embeded)
            {
                PrinterConnectionAndCommunication.Instance.CommunicationStateChanged.RegisterEvent(SetEditControlsBasedOnPrinterState, ref unregisterEvents);
                if (windowType == WindowType.Embeded)
                {
                    // make sure we lock the controls if we are printing or paused
                    switch (PrinterConnectionAndCommunication.Instance.CommunicationState)
                    {
                        case PrinterConnectionAndCommunication.CommunicationStates.Printing:
                        case PrinterConnectionAndCommunication.CommunicationStates.Paused:
                            LockEditControls();
                            break;
                    }
                }
            }

            ActiveTheme.Instance.ThemeChanged.RegisterEvent(ThemeChanged, ref unregisterEvents);
        }
		private void onLibraryLoadFileSelected(OpenFileDialogParams openParams)
		{
			if (openParams.FileNames != null)
			{
				this.libraryDataView.CurrentLibraryProvider.AddFilesToLibrary(openParams.FileNames, null);
			}
		}
Example #31
0
        void DoOpenFileButton_ButtonClick(object state)
        {
            OpenFileDialogParams openParams = new OpenFileDialogParams("3D Mesh Files|*.stl;*.amf");
            Stream streamToLoadFrom = FileDialog.OpenFileDialog(ref openParams);

            meshViewerWidget.LoadMesh(openParams.FileName);

            Invalidate();
        }
        void loadFile_Click(object sender, MouseEventArgs mouseEvent)
        {
            OpenFileDialogParams openParams = new OpenFileDialogParams("Select an STL file, Select a GCODE file|*.stl;*.gcode", multiSelect: true);
            FileDialog.OpenFileDialog(ref openParams);
            if (openParams.FileNames != null)
            {
                foreach (string loadedFileName in openParams.FileNames)
                {
                    PrintItem printItem = new PrintItem();
                    printItem.Name = System.IO.Path.GetFileNameWithoutExtension(loadedFileName);
                    printItem.FileLocation = System.IO.Path.GetFullPath(loadedFileName);
                    printItem.PrintItemCollectionID = PrintLibraryListControl.Instance.LibraryCollection.Id;
                    printItem.Commit();

                    PrintLibraryListItem queueItem = new PrintLibraryListItem(new PrintItemWrapper(printItem));
                    PrintLibraryListControl.Instance.AddChild(queueItem);
                }
                PrintLibraryListControl.Instance.Invalidate();
            }
            PrintLibraryListControl.Instance.SaveLibraryItems();
        }
        public List<PrintItem> OpenFromDialog()
        {
            OpenFileDialogParams openParams = new OpenFileDialogParams("Zip file|*.zip");

            FileDialog.OpenFileDialog(ref openParams);
			if (openParams.FileNames != null)
            {
                string loadedFileName = openParams.FileName;
                return ImportFromProjectArchive(loadedFileName);
            }
            else
            {
                return null;
            }
        }
		private void onSettingsFileSelected(OpenFileDialogParams openParams)
		{
			if (openParams.FileNames != null)
			{
				LoadConfigurationSettingsFromFileAsUnsaved(openParams.FileName);
				ApplicationController.Instance.ReloadAdvancedControlsPanel();
			}
		}
        public View3DTransformPart(PrintItemWrapper printItemWrapper, Vector3 viewerVolume, MeshViewerWidget.BedShape bedShape)
        {
            MeshExtraData = new List<PlatingMeshData>();
            MeshExtraData.Add(new PlatingMeshData());

            this.printItemWrapper = printItemWrapper;

            FlowLayoutWidget mainContainerTopToBottom = new FlowLayoutWidget(FlowDirection.TopToBottom);
            mainContainerTopToBottom.HAnchor = Agg.UI.HAnchor.Max_FitToChildren_ParentWidth;
            mainContainerTopToBottom.VAnchor = Agg.UI.VAnchor.Max_FitToChildren_ParentHeight;

            FlowLayoutWidget centerPartPreviewAndControls = new FlowLayoutWidget(FlowDirection.LeftToRight);
            centerPartPreviewAndControls.AnchorAll();

            GuiWidget viewArea = new GuiWidget();
            viewArea.AnchorAll();
            {
                meshViewerWidget = new MeshViewerWidget(viewerVolume, 1, bedShape);
                SetMeshViewerDisplayTheme();
                meshViewerWidget.AnchorAll();
            }
            viewArea.AddChild(meshViewerWidget);

            centerPartPreviewAndControls.AddChild(viewArea);
            mainContainerTopToBottom.AddChild(centerPartPreviewAndControls);

            meshViewerWidget.LoadMesh(printItemWrapper.FileLocation);
            meshViewerWidget.LoadDone += new EventHandler(meshViewerWidget_LoadDone);

            FlowLayoutWidget buttonBottomPanel = new FlowLayoutWidget(FlowDirection.LeftToRight);
            buttonBottomPanel.HAnchor = HAnchor.ParentLeftRight;
            buttonBottomPanel.Padding = new BorderDouble(3, 3);
            buttonBottomPanel.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor;

            buttonRightPanel = CreateRightButtonPannel(viewerVolume.y);

            CreateOptionsContent();

            // add in the plater tools
            {
                FlowLayoutWidget editToolBar = new FlowLayoutWidget();

				string progressFindPartsLbl = new LocalizedString ("Finding Parts").Translated;
				string progressFindPartsLblFull = string.Format ("{0}:", progressFindPartsLbl);

				processingProgressControl = new ProgressControl(progressFindPartsLblFull);
                processingProgressControl.VAnchor = Agg.UI.VAnchor.ParentCenter;
                editToolBar.AddChild(processingProgressControl);
                editToolBar.VAnchor |= Agg.UI.VAnchor.ParentCenter;
                processingProgressControl.Visible = false;

				editPlateButton = textImageButtonFactory.Generate(new LocalizedString("Edit").Translated);
                editToolBar.AddChild(editPlateButton);

                editPlateButtonsContainer = new FlowLayoutWidget();
                editPlateButtonsContainer.Visible = false;

				Button addButton = textImageButtonFactory.Generate(new LocalizedString("Add").Translated, "icon_circle_plus.png");
                addButton.Margin = new BorderDouble(right: 10);
                editPlateButtonsContainer.AddChild(addButton);
                addButton.Click += (sender, e) =>
                {
                    UiThread.RunOnIdle((state) =>
                    {
                        OpenFileDialogParams openParams = new OpenFileDialogParams("Select an STL file|*.stl", multiSelect: true);

                        FileDialog.OpenFileDialog(ref openParams);
                        LoadAndAddPartsToPlate(openParams.FileNames);
                    });
                };

				Button copyButton = textImageButtonFactory.Generate(new LocalizedString("Copy").Translated);
                editPlateButtonsContainer.AddChild(copyButton);
                copyButton.Click += (sender, e) =>
                {
                    MakeCopyOfMesh();
                };

				Button deleteButton = textImageButtonFactory.Generate(new LocalizedString("Delete").Translated);
                deleteButton.Margin = new BorderDouble(left: 20);
                editPlateButtonsContainer.AddChild(deleteButton);
                deleteButton.Click += (sender, e) =>
                {
                    DeleteSelectedMesh();
                };

                KeyDown += (sender, e) =>
                {
                    KeyEventArgs keyEvent = e as KeyEventArgs;
                    if (keyEvent != null && !keyEvent.Handled)
                    {
                        if (keyEvent.KeyCode == Keys.Delete || keyEvent.KeyCode == Keys.Back)
                        {
                            DeleteSelectedMesh();
                        }

                        if (keyEvent.KeyCode == Keys.Escape)
                        {
                            if (meshSelectInfo.downOnPart)
                            {
                                meshSelectInfo.downOnPart = false;
                                SelectedMeshTransform = transformOnMouseDown;
                                Invalidate();
                            }
                        }
                    }
                };

                editToolBar.AddChild(editPlateButtonsContainer);
                buttonBottomPanel.AddChild(editToolBar);

                editPlateButton.Click += (sender, e) =>
                {
                    editPlateButton.Visible = false;

                    EnterEditAndSplitIntoMeshes();
                };
            }

            autoArrangeButton.Click += (sender, e) =>
            {
                AutoArangePartsInBackground();
            };

            GuiWidget buttonRightPanelHolder = new GuiWidget(HAnchor.FitToChildren, VAnchor.ParentBottomTop);
            centerPartPreviewAndControls.AddChild(buttonRightPanelHolder);
            buttonRightPanelHolder.AddChild(buttonRightPanel);

            buttonRightPanelDisabledCover = new Cover(HAnchor.ParentLeftRight, VAnchor.ParentBottomTop);
            buttonRightPanelDisabledCover.BackgroundColor = new RGBA_Bytes(ActiveTheme.Instance.PrimaryBackgroundColor, 150);
            buttonRightPanelHolder.AddChild(buttonRightPanelDisabledCover);
            LockEditControls();

            GuiWidget leftRightSpacer = new GuiWidget();
            leftRightSpacer.HAnchor = HAnchor.ParentLeftRight;
            buttonBottomPanel.AddChild(leftRightSpacer);

			closeButton = textImageButtonFactory.Generate(new LocalizedString("Close").Translated);
            buttonBottomPanel.AddChild(closeButton);

            mainContainerTopToBottom.AddChild(buttonBottomPanel);

            this.AddChild(mainContainerTopToBottom);
            this.AnchorAll();

            meshViewerWidget.TrackballTumbleWidget.TransformState = TrackBallController.MouseDownType.Rotation;
            AddViewControls();

            AddHandlers();
        }