Inheritance: MonoBehaviour
Exemple #1
0
        public void RotateTestImages()
        {
            string filePath       = @"..\..\RawPanelImages\";
            string outputFilePath = @"..\..\AutoRotatedImages\";

            DirectoryInfo d = new DirectoryInfo(filePath);

            Assert.IsTrue(d.GetFiles("*.jpg").Length > 5, "There are not more than 5 files to test against.");
            Assert.IsFalse(d.GetFiles("*.jpg").Length < 5, "There are more than 5 files to test against.");


            List <Double> elapsedTimes = new List <double>();

            foreach (var file in d.GetFiles("*.jpg"))
            {
                double mSecElapsedFirstRotation = 0;
                string outputFilename           = string.Format("Rotated_{0}_{1}", DateTime.Now.ToString("yyyyMMdd_hhmmss"), file.Name);
                double?rotation = AutoRotate.AutoRotateImage(filePath, file.Name, false, null, null, outputFilePath, outputFilename, out mSecElapsedFirstRotation);

                Assert.IsNotNull(rotation);

                double mSecElapsedSecondRotation = 0;
                double?secondRotation            = AutoRotate.GetRotationAngle(outputFilePath, outputFilename, false, null, null, out mSecElapsedSecondRotation);


                Assert.IsTrue(Math.Abs((double)secondRotation) < 1, "Second rotation > 1 degrees for " + file.Name);
            }
        }
Exemple #2
0
    void Start()
    {
        int oldSeed = Random.seed;

        if (useSeed)
        {
            Random.seed = seed;
        }

        AutoRotate rotater = GetComponent <AutoRotate>();

        if (rotater != null)
        {
            Vector3 v = rotater.speed;
            v.x          *= Eval(x, min.x, max.x);
            v.y          *= Eval(y, min.y, max.y);
            v.z          *= Eval(z, min.z, max.z);
            rotater.speed = v;
        }

        if (useSeed)
        {
            Random.seed = oldSeed; seed++;
        }
        Destroy(this);
    }
 private void Awake()
 {
     nBodySimManager = GetComponent <NBodySimManager>();
     freeCamera      = GetComponent <FreeCamera>();
     autoRotate      = GetComponent <AutoRotate>();
     smoothFollow    = GetComponent <SmoothFollow>();
 }
        private IEnumerator GenerateBodies(Body[] bodies, int startIndex, int endIndex)
        {
            yield return Ninja.JumpToUnity;

            for (int i = startIndex; i < endIndex; i++)
            {
                Vector3 bodyPos = bodies[i].GetPosition() * Dispersion;
                GameObject obj = Instantiate(Prefab, bodyPos, Random.rotation);
                AsteroidDeformation deform = obj.GetComponent<AsteroidDeformation>();
                
                Task task;
                yield return this.StartCoroutineAsync(deform.Deform(), out task);
                yield return StartCoroutine(task.Wait());

                AutoRotate autoRotate = obj.GetComponent<AutoRotate>();
                autoRotate.speed = new Vector3(
                    Random.Range(MinRotationForce, MaxRotationForce),
                    Random.Range(MinRotationForce, MaxRotationForce),
                    Random.Range(MinRotationForce, MaxRotationForce)
                    );

                Vector3 scaleVector = new Vector3(
                    Random.Range(MinScaleVariance, MaxScaleVariance),
                    Random.Range(MinScaleVariance, MaxScaleVariance),
                    Random.Range(MinScaleVariance, MaxScaleVariance)
                    ) * bodies[i].Size * Random.Range(MinArbitraryScaler, MaxArbitraryScaler);
                obj.transform.localScale = scaleVector;

                AsteroidDetailer detailer = obj.GetComponent<AsteroidDetailer>();
                detailer.Detail();

                obj.transform.SetParent(transform);
            }
        }
Exemple #5
0
 private void InitializeComponents()
 {
     audioManager = GameObject.FindGameObjectWithTag("AudioManager").GetComponent <AudioSource>();
     faderPanel   = GameObject.FindGameObjectWithTag("FaderPanel").GetComponent <Image>();
     autoRotator  = FindObjectOfType <AutoRotate>();
     narrator     = FindObjectOfType <Narrator>();
 }
    private AutoRotate ar;    //this will store the new AutoRotate.cs script I made

    void Start()
    {
        ar = GetComponent <AutoRotate> ();
        if (ar == null)
        {
            Debug.Log("Patay, wala kang AutoRotate script sa player mo");
        }
    }
Exemple #7
0
 void Start()
 {
     rotator = GetComponent <AutoRotate>();
     if (rotator == null)
     {
         Debug.Log("AutoRotate not found on " + name); Destroy(this);
     }
 }
Exemple #8
0
 public void Save(XmlDocument doc)
 {
     Config.SafeNodeSelect(doc, "/Settings/Display/AutoRotate", AutoRotate.ToString());
     Config.SafeNodeSelect(doc, "/Settings/Display/CheckeredPatternBackground", CheckeredPatternBackground.ToString());
     Config.SafeNodeSelect(doc, "/Settings/Display/Zoom", Zoom.ToString());
     Config.SafeNodeSelect(doc, "/Settings/Display/ZoomStep", SizeMode.ToString());
     Config.SafeNodeSelect(doc, "/Settings/Display/SizeMode", SizeMode.ToString());
     Config.SafeNodeSelect(doc, "/Settings/Display/SizeModeOnImageLoad", SizeModeOnImageLoad.ToString());
 }
Exemple #9
0
        public GraphicRotatable(GraphicRequest req, AutoRotate autoRotate = AutoRotate.None)
        {
            base.Init(req);

            if (autoRotate != AutoRotate.None)
            {
                this.autoRotate = autoRotate;
                //ProcessAutoRotate();
            }
        }
        /// <summary>
        /// Performs auto-rotation to ensure that EXIF defined rotation is reflected in
        /// the final image.
        /// </summary>
        /// <returns>
        /// The current instance of the <see cref="T:ImageProcessor.ImageFactory"/> class.
        /// </returns>
        public ImageFactory AutoRotate()
        {
            if (this.ShouldProcess)
            {
                AutoRotate autoRotate = new AutoRotate();
                this.CurrentImageFormat.ApplyProcessor(autoRotate.ProcessImage, this);
            }

            return(this);
        }
Exemple #11
0
    public override void OnInspectorGUI()
    {
        AutoRotate script = (AutoRotate)target;

        EditorGUILayout.HelpBox("This script will rotate its gameobject when selected and in game", MessageType.Info);
        //If a vlue was changed this is true

        base.OnInspectorGUI();

        if (GUILayout.Button("Adjust Rigidbody"))
        {
            script.ApplyRotation();
        }
    }
Exemple #12
0
 /*
  * void OnTriggerEnter ( Collider other ){
  *      _Engine._DK_RPG_UMA = other.gameObject.GetComponent<DK_RPG_UMA>();
  *      // verify if it is the correct collider
  *      if ( _Engine._DK_RPG_UMA != null
  *          && other.material.name == "DK_UMA_Engine._Collider_Material" )
  *      {
  *              if ( _Engine._DK_RPG_UMA.IsPlayer ){
  *                      ElementPreparations ();
  *              }
  *      }
  * }
  */
 public void AddAutoRotate()
 {
     // find the global gameobject of the mesh
     Transform[] ts = transform.GetComponentsInChildren <Transform>();
     foreach (Transform _child in ts)
     {
         if (_child.name == "Global")
         {
             _Global = _child;
         }
     }
     if (_Global && _Global.gameObject.GetComponent <AutoRotate>() == null)
     {
         AutoRotate tmpAutoRotate = _Global.gameObject.AddComponent <AutoRotate>();
         tmpAutoRotate._X          = _ElementOptions._AutoRotate._X;
         tmpAutoRotate._Y          = _ElementOptions._AutoRotate._Y;
         tmpAutoRotate._Z          = _ElementOptions._AutoRotate._Z;
         tmpAutoRotate._AutoRotate = _ElementOptions._AutoRotate.AutoRotate;
     }
 }
Exemple #13
0
    public override void OnInspectorGUI()
    {
        m_AutoRotate = target as AutoRotate;
        m_AutoRotate.m_AutoHideType = (AutoHideType)EditorGUILayout.EnumPopup("AutoHideType", m_AutoRotate.m_AutoHideType);

        switch (m_AutoRotate.m_AutoHideType)
        {
        case AutoHideType.H:
            if (GUILayout.Button("保存横屏数据"))
            {
                m_AutoRotate.SaveH();
            }
            break;

        case AutoHideType.V:
            if (GUILayout.Button("保存竖屏数据"))
            {
                m_AutoRotate.SaveV();
            }
            break;
        }
    }
		public View3DWidget(PrintItemWrapper printItemWrapper, Vector3 viewerVolume, Vector2 bedCenter, MeshViewerWidget.BedShape bedShape, WindowMode windowType, AutoRotate autoRotate, OpenMode openMode = OpenMode.Viewing)
		{
			this.openMode = openMode;
			this.windowType = windowType;
			allowAutoRotate = (autoRotate == AutoRotate.Enabled);
			autoRotating = allowAutoRotate;
			MeshGroupExtraData = new List<PlatingMeshGroupData>();
			MeshGroupExtraData.Add(new PlatingMeshGroupData());

			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.Name = "centerPartPreviewAndControls";
			centerPartPreviewAndControls.AnchorAll();

			GuiWidget viewArea = new GuiWidget();
			viewArea.AnchorAll();
			{
				meshViewerWidget = new MeshViewerWidget(viewerVolume, bedCenter, bedShape, "Press 'Add' to select an item.".Localize());

				PutOemImageOnBed();

				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);
			buttonRightPanel.Name = "buttonRightPanel";
			buttonRightPanel.Visible = false;

			CreateOptionsContent();

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

				string progressFindPartsLabel = "Entering Editor".Localize();
				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("Insert".Localize(), "icon_insert_32x32.png");
					addButton.ToolTipText = "Insert an .stl, .amf or .zip file".Localize();
					addButton.Margin = new BorderDouble(right: 0);
					enterEditButtonsContainer.AddChild(addButton);
					addButton.Click += (sender, e) =>
					{
						UiThread.RunOnIdle(() =>
						{
							DoAddFileAfterCreatingEditData = true;
							EnterEditAndCreateSelectionData();
						});
					};
					if (printItemWrapper != null 
						&& printItemWrapper.PrintItem.ReadOnly)
					{
						addButton.Enabled = false;
					}

					Button enterEdittingButton = textImageButtonFactory.Generate("Edit".Localize(), "icon_edit_32x32.png");
					enterEdittingButton.Margin = new BorderDouble(right: 4);
					enterEdittingButton.Click += (sender, e) =>
					{
						EnterEditAndCreateSelectionData();
					};
					
					if (printItemWrapper != null 
						&& printItemWrapper.PrintItem.ReadOnly)
					{
						enterEdittingButton.Enabled = false;
					}

					Button exportButton = textImageButtonFactory.Generate("Export...".Localize());
					if (printItemWrapper != null && 
						(printItemWrapper.PrintItem.Protected || printItemWrapper.PrintItem.ReadOnly))
					{
						exportButton.Enabled = false;
					}

					exportButton.Margin = new BorderDouble(right: 10);
					exportButton.Click += (sender, e) =>
					{
						UiThread.RunOnIdle(() =>
						{
							OpenExportWindow();
						});
					};

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

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

				{
					Button addButton = textImageButtonFactory.Generate("Insert".Localize(), "icon_insert_32x32.png");
					addButton.Margin = new BorderDouble(right: 10);
					doEdittingButtonsContainer.AddChild(addButton);
					addButton.Click += (sender, e) =>
					{
						UiThread.RunOnIdle(() =>
						{
							FileDialog.OpenFileDialog(
								new OpenFileDialogParams(ApplicationSettings.OpenDesignFileParams, multiSelect: true),
								(openParams) =>
								{
									LoadAndAddPartsToPlate(openParams.FileNames);
								});
						});
					};

					GuiWidget separator = new GuiWidget(1, 2);
					separator.BackgroundColor = ActiveTheme.Instance.PrimaryTextColor;
					separator.Margin = new BorderDouble(4, 2);
					separator.VAnchor = VAnchor.ParentBottomTop;
					doEdittingButtonsContainer.AddChild(separator);

					Button ungroupButton = textImageButtonFactory.Generate("Ungroup".Localize());
					doEdittingButtonsContainer.AddChild(ungroupButton);
					ungroupButton.Click += (sender, e) =>
					{
						UngroupSelectedMeshGroup();
					};

					Button groupButton = textImageButtonFactory.Generate("Group".Localize());
					doEdittingButtonsContainer.AddChild(groupButton);
					groupButton.Click += (sender, e) =>
					{
						GroupSelectedMeshs();
					};

					Button alignButton = textImageButtonFactory.Generate("Align".Localize());
					doEdittingButtonsContainer.AddChild(alignButton);
					alignButton.Click += (sender, e) =>
					{
						AlignToSelectedMeshGroup();
					};

					Button arrangeButton = textImageButtonFactory.Generate("Arrange".Localize());
					doEdittingButtonsContainer.AddChild(arrangeButton);
					arrangeButton.Click += (sender, e) =>
					{
						AutoArrangePartsInBackground();
					};

					GuiWidget separatorTwo = new GuiWidget(1, 2);
					separatorTwo.BackgroundColor = ActiveTheme.Instance.PrimaryTextColor;
					separatorTwo.Margin = new BorderDouble(4, 2);
					separatorTwo.VAnchor = VAnchor.ParentBottomTop;
					doEdittingButtonsContainer.AddChild(separatorTwo);

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

					Button deleteButton = textImageButtonFactory.Generate("Remove".Localize());
					doEdittingButtonsContainer.AddChild(deleteButton);
					deleteButton.Click += (sender, e) =>
					{
						DeleteSelectedMesh();
					};

					GuiWidget separatorThree = new GuiWidget(1, 2);
					separatorThree.BackgroundColor = ActiveTheme.Instance.PrimaryTextColor;
					separatorThree.Margin = new BorderDouble(4, 1);
					separatorThree.VAnchor = VAnchor.ParentBottomTop;
					doEdittingButtonsContainer.AddChild(separatorThree);

					Button leaveEditModeButton = textImageButtonFactory.Generate("Cancel".Localize(), centerText: true);
					leaveEditModeButton.Click += (sender, e) =>
					{
						UiThread.RunOnIdle(() =>
						{
							if (saveButtons.Visible)
							{
								StyledMessageBox.ShowMessageBox(ExitEditingAndSaveIfRequired, "Would you like to save your changes before exiting the editor?", "Save Changes", StyledMessageBox.MessageType.YES_NO);
							}
							else
							{
								if (partHasBeenEdited)
								{
									ExitEditingAndSaveIfRequired(false);
								}
								else
								{
									SwitchStateToNotEditing();
								}
							}
						});
					};
					doEdittingButtonsContainer.AddChild(leaveEditModeButton);

					// put in the save button
					AddSaveAndSaveAs(doEdittingButtonsContainer);
				}

				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 = SelectedMeshGroupTransform;
								translated.translation = transformOnMouseDown;
								SelectedMeshGroupTransform = translated;

								Invalidate();
							}
						}
					}
				};

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

			GuiWidget buttonRightPanelHolder = new GuiWidget(HAnchor.FitToChildren, VAnchor.ParentBottomTop);
			buttonRightPanelHolder.Name = "buttonRightPanelHolder";
			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);

			viewControls3D.PartSelectVisible = false;
			LockEditControls();

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

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

			mainContainerTopToBottom.AddChild(buttonBottomPanel);

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

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

			AddHandlers();

			UiThread.RunOnIdle(AutoSpin);

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

			if (windowType == WindowMode.Embeded)
			{
				PrinterConnectionAndCommunication.Instance.CommunicationStateChanged.RegisterEvent(SetEditControlsBasedOnPrinterState, ref unregisterEvents);
				if (windowType == WindowMode.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);

			upArrow = new UpArrow3D(this);
			heightDisplay = new HeightValueDisplay(this);
			heightDisplay.Visible = false;
			meshViewerWidget.interactionVolumes.Add(upArrow);

			// make sure the colors are set correctl
			ThemeChanged(this, null);

			saveButtons.VisibleChanged += (sender, e) =>
			{
				partHasBeenEdited = true;
			};
		}
        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);
        }
Exemple #16
0
 // Use this for initialization
 void Start()
 {
     _landSensor                     = GetComponent <LandingSensor>();
     _tardisContinueRotation         = GetComponentInChildren <AutoRotate>();
     _tardisContinueRotation.enabled = true;
 }
Exemple #17
0
 void OnEnable()
 {
     kCachedTraget             = (AutoRotate)target;
     kCached                   = (kCachedTraget).transform;
     EditorApplication.update += Sample;
 }
	// Use this for initialization
	void Start () {
		_landSensor = GetComponent<LandingSensor>();
		_tardisContinueRotation = GetComponentInChildren<AutoRotate>();
		_tardisContinueRotation.enabled = true;
	}
	void Start() {
		rotator = GetComponent<AutoRotate>();
		if (rotator == null) { Debug.Log("AutoRotate not found on " + name); Destroy(this); }
	}