Ejemplo n.º 1
0
        private void OpenFile(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog = CFileDialogFactory.createOpenFileDialog();

            if (openFileDialog.ShowDialog(this) == DialogResult.OK)
            {
                // Get variables needed for canvastabpage
                string fileURL = openFileDialog.FileName;

                CProjectInfo info = CFileHelper.getProject(fileURL);

                if (info == null)
                {
                    MessageBox.Show("Unable to open project", "Error in opening file");
                    return;
                }

                CanvasTabPage tabPage = CCanvasTabPageFactory.createPage(CFileHelper.getProject(fileURL), fileURL);

                // And add it to tabControl
                pageContainerControl.TabPages.Add(tabPage);
                pageContainerControl.SelectedTab = tabPage;

                // Manually cast selectindexchanged, since it doesnt fire when the first tab
                // is opened
                this.pageContainerControl_SelectedIndexChanged(null, null);

                CFormController.Instance.mainForm.setStatus("Project Opened");

                this.showToolBox();
            }
        }
Ejemplo n.º 2
0
        private void ShowNewForm(object sender, EventArgs e)
        {
            SaveFileDialog saveFileDialog = CFileDialogFactory.createNewFileDialog();

            if (saveFileDialog.ShowDialog(this) == DialogResult.OK)
            {
                // Get variables needed for canvastabpage
                string fileURL = saveFileDialog.FileName;

                // New form - new info
                CProjectInfo projectInfo = new CProjectInfo();
                projectInfo.languageID = ((CLanguageInfo)CFormController.Instance.languageBox.SelectedItem).Value;

                // Create tabpage from them
                CanvasTabPage tabPage = CCanvasTabPageFactory.createNewPage(projectInfo, fileURL);

                // And add it to tabControl
                pageContainerControl.TabPages.Add(tabPage);
                pageContainerControl.SelectedTab = tabPage;

                // Manually cast selectindexchanged, since it doesnt fire when the first tab
                // is opened
                this.pageContainerControl_SelectedIndexChanged(null, null);

                // Save it also
                CFileHelper.saveProject(tabPage.projectInfo, tabPage.url);

                CFormController.Instance.mainForm.setStatus("Project Created");

                showToolBox();
            }
        }
Ejemplo n.º 3
0
        private void SaveAsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            // Get active child and update its properties
            CanvasTabPage activeChild = (CanvasTabPage)pageContainerControl.SelectedTab;

            if (activeChild == null)
            {
                // Nothing to save as
                return;
            }

            // Invoke setter to get projectinfo if in view mode
            activeChild.projectInfo.projectXml = activeChild.activeProjectContent;

            SaveFileDialog saveFileDialog = CFileDialogFactory.createSaveFileDialog();

            if (saveFileDialog.ShowDialog(this) == DialogResult.OK)
            {
                // Get variables needed for canvastabpage
                activeChild.url  = saveFileDialog.FileName;
                activeChild.Text = System.IO.Path.GetFileName(activeChild.url);

                // And save it
                CFileHelper.saveProject(activeChild.projectInfo, activeChild.url);

                CFormController.Instance.mainForm.setStatus("Project Saved");
            }
        }
Ejemplo n.º 4
0
    //--------------------------------------------------------------------------------------------------------------------------
    // Collision Detection / Force Feedback

    // Called when this object enters the collider of another object
    protected virtual void OnTriggerEnter(Collider col)
    {
        SenseGlove_Interactable interact = col.attachedRigidbody != null?col.attachedRigidbody.GetComponent <SenseGlove_Interactable>()
                                               : col.GetComponent <SenseGlove_Interactable>();

        if (interact != null)
        {
            interact.TouchedBy(this);
            if (this.touchedObject == null)
            {
                //if (!this.IsTouching(col.gameObject))
                //{
                //    //touching a new object!
                //}
                this.touchedObject = interact.gameObject;
                this.touchedScript = interact;
                if (this.touchedObject.transform.parent != null)
                {
                    if (this.touchedObject.transform.parent.name == "Tastatur" && this.name == "indexPickupCollider")
                    {
                        this.transform.root.GetComponent <SenseGlove_Object>().SendBuzzCmd(new bool[5] {
                            false, true, false, false, false
                        }, 100, 50);
                        GlobalCtrl text = this.transform.root.GetComponent <GlobalCtrl>();
                        text.textChange(this.touchedObject);
                    }
                    else if (this.touchedObject.transform.parent.name == "GUILoad" && this.name == "indexPickupCollider")
                    {
                        this.transform.root.GetComponent <SenseGlove_Object>().SendBuzzCmd(new bool[5] {
                            false, true, false, false, false
                        }, 100, 50);

                        if (this.touchedObject.name == "Down")
                        {
                            GlobalCtrl.updown += 1;
                        }
                        else if (this.touchedObject.name == "Up" && GlobalCtrl.updown >= 1)
                        {
                            GlobalCtrl.updown -= 1;
                        }
                        else if (this.touchedObject.name.StartsWith("Platz"))
                        {
                            List <atomData> loadFile = new List <atomData>();
                            loadFile = (List <atomData>)CFileHelper.LoadData(Application.dataPath + "/MoleculeFiles/" + touchedObject.transform.GetChild(0).GetComponent <Text>().text, typeof(List <atomData>));
                            this.transform.root.GetComponent <GlobalCtrl>().loadMolecule(loadFile);
                        }
                        else if (this.touchedObject.name == "ExitLoadGui")
                        {
                            GlobalCtrl.loadGUI = false;
                            GameObject.Find("GUILoad").SetActive(false);
                            molecule.SetActive(true);
                        }
                    }
                }
            }
        }
    }
Ejemplo n.º 5
0
 private void generateButton_Click(object sender, EventArgs e)
 {
     if (!CFileHelper.generatePage(page.projectInfo, this.pathTextBox.Text))
     {
         MessageBox.Show("Error generating output");
     }
     else
     {
         MessageBox.Show("Code generated successfully");
         this.Close();
     }
 }
    public void textChange(GameObject key)
    {
        //text typed on the virtual keyboard by the user is put together to one string here
        //different special cases with the standard case, just adding the character, below
        changingText.text = GameObject.Find("GUISave").transform.GetChild(0).GetComponent <Text>().text;
        string s = key.name;

        if (changingText.text == "Name eingeben")
        {
            changingText.text = "";
        }
        if (s == "Delete")
        {
            if (changingText.text.Length > 1)
            {
                changingText.text = changingText.text.Substring(0, changingText.text.Length - 1);
            }
            else
            {
                changingText.text = "Name eingeben";
            }
        }
        else if (s == "Space")
        {
            changingText.text = changingText.text + " ";
        }
        else if (s == "Exit")
        {
            changingText.text = "Name eingeben";
            GameObject.Find("GUISave").SetActive(false);
            molecule.SetActive(true);
        }
        else if (s == "OK")
        {
            list_atomData.Clear();
            saveMolecule();
            CFileHelper.SaveData(Application.dataPath + "/MoleculeFiles/" + changingText.text + ".xml", list_atomData);

            changingText.text = "Name eingeben";
            GameObject.Find("GUISave").SetActive(false);
            molecule.SetActive(true);
        }
        else
        {
            changingText.text = changingText.text + s;
        }
    }
Ejemplo n.º 7
0
        private void saveToolStripButton_Click(object sender, EventArgs e)
        {
            CanvasTabPage activeChild = (CanvasTabPage)pageContainerControl.SelectedTab;

            if (activeChild == null)
            {
                // Nothing to save
                return;
            }

            // Invoke setter to get projectinfo if in view mode
            activeChild.projectInfo.projectXml = activeChild.activeProjectContent;

            CFileHelper.saveProject(activeChild.projectInfo, activeChild.url);

            CFormController.Instance.mainForm.setStatus("Project Saved");
        }
Ejemplo n.º 8
0
        private void Update()
        {
            if (!isActive)
            {
                isActive = true;
                this.transform.GetChild(0).gameObject.SetActive(true);
            }
            //IF Trackpad is touched in the front mittle of the trackpad, the laserpointer appears
            Vector2 touchPos = trackpadtouch.GetAxis(SteamVR_Input_Sources.Any);

            if (touchPos.y >= 0.5)
            {
                var device = trackpadtouch.GetActiveDevice(SteamVR_Input_Sources.Any);
                if (device == transform.GetComponent <SteamVR_Behaviour_Pose>().inputSource)
                {
                    transform.GetChild(1).GetChild(0).gameObject.SetActive(true);
                }
            }
            else
            {
                this.transform.GetChild(1).GetChild(0).gameObject.SetActive(false);
            }
            Transform rayTrans = transform.GetChild(1).transform;

            rayTrans.localRotation = Quaternion.Euler(30, 0, 0);
            Ray        raycast = new Ray(transform.position, rayTrans.forward);
            RaycastHit hit;
            bool       bHit = Physics.Raycast(raycast, out hit);

            //Klick on the trackpad confirms the selection, target gets executed
            if (trackpadklicked.stateDown && bHit && touchPos.y >= 0.5)
            {
                //Open an already saved molecule
                if (false && hit.collider.name == "Öffnen" && (guiSave.activeInHierarchy == false) && (guiLoad.activeInHierarchy == false))
                {
                    vibration.Execute(0, 0.2f, 1, 1, this.pose.inputSource);
                    GameObject.Find("Molekül").GetComponent <EditMode>().editMode = false;
                    GameObject.Find("UI0").transform.position = new Vector3(0, 0, 0);
                    GameObject.Find("UI1").transform.position = new Vector3(0, 0, 0);
                    GameObject.Find("UI2").transform.position = new Vector3(0, 0, 0);
                    GameObject.Find("UI3").transform.position = new Vector3(0, 0, 0);
                    GameObject.Find("Molekül").SetActive(false);
                    this.GetComponentInParent <GlobalCtrl>().loadGUILoad();
                    guiLoad.SetActive(true);
                }
                //Save created molecule
                else if (false && hit.collider.name == "Speichern" && guiSave.activeInHierarchy == false && (guiLoad.activeInHierarchy == false))
                {
                    vibration.Execute(0, 0.2f, 1, 1, this.pose.inputSource);
                    guiSave.SetActive(true);
                    GameObject.Find("Molekül").GetComponent <EditMode>().editMode = false;
                    GameObject.Find("UI0").transform.position = new Vector3(0, 0, 0);
                    GameObject.Find("UI1").transform.position = new Vector3(0, 0, 0);
                    GameObject.Find("UI2").transform.position = new Vector3(0, 0, 0);
                    GameObject.Find("UI3").transform.position = new Vector3(0, 0, 0);
                    GameObject.Find("Molekül").SetActive(false);
                }
                //Create new carbon atom
                else if (hit.collider.name == "PeriodensystemC" && (guiSave.activeInHierarchy == false) && (guiLoad.activeInHierarchy == false))
                {
                    vibration.Execute(0, 0.2f, 1, 1, this.pose.inputSource);
                    this.GetComponentInParent <GlobalCtrl>().createCarbon(this.transform.position);
                }
                //Create new hydrogen atom
                else if (hit.collider.name == "PeriodensystemH" && (guiSave.activeInHierarchy == false) && (guiLoad.activeInHierarchy == false))
                {
                    vibration.Execute(0, 0.2f, 1, 1, this.pose.inputSource);
                    this.GetComponentInParent <GlobalCtrl>().createHydrogen(this.transform.position);
                }
                //Delete atoms or whole molecule
                else if (hit.collider.name == "recycle bin" && (guiSave.activeInHierarchy == false) && (guiLoad.activeInHierarchy == false))
                {
                    vibration.Execute(0, 0.2f, 1, 1, this.pose.inputSource);
                    this.GetComponentInParent <GlobalCtrl>().recycle();
                }
                //Mark an existing atom to edit / delete it
                else if (false && hit.collider.name.StartsWith("atom") && (guiSave.activeInHierarchy == false) && (guiLoad.activeInHierarchy == false))
                {
                    vibration.Execute(0, 0.2f, 1, 1, this.pose.inputSource);
                    //if it isn't selected before,start edit mode
                    if (GameObject.Find("Molekül").GetComponent <EditMode>().editMode == false)
                    {
                        GameObject.Find("Molekül").GetComponent <EditMode>().editMode           = true;
                        GameObject.Find("Molekül").GetComponent <EditMode>().fixedAtom          = hit.collider.gameObject.GetComponent <Atom>();
                        hit.collider.gameObject.GetComponent <Renderer>().material.color        = new Color32(255, 0, 0, 255);
                        hit.collider.gameObject.GetComponent <SenseGlove_Grabable>().editMarker = true;
                    }
                    //if it already was selected before, close edit mode
                    else if (GameObject.Find("Molekül").GetComponent <EditMode>().editMode == true && hit.collider.gameObject.GetComponent <Atom>()._id == GameObject.Find("Molekül").GetComponent <EditMode>().fixedAtom._id)
                    {
                        hit.collider.gameObject.GetComponent <SenseGlove_Grabable>().editMarker = false;
                        GameObject.Find("Molekül").GetComponent <EditMode>().editMode           = false;
                        GameObject.Find("Molekül").GetComponent <EditMode>().fixedAtom          = null;
                        hit.collider.transform.GetComponent <Atom>().setOriginalColor();
                    }
                }
                //Select the whole molecule -- moves as a solid structure
                else if ((hit.collider.name == "AllAtoms") && (guiSave.activeInHierarchy == false) && (guiLoad.activeInHierarchy == false))
                {
                    GameObject.Find("AllAtoms").transform.localScale   = new Vector3(0.1f, 0.1f, 0.1f);
                    GameObject.Find("SingleAtom").transform.localScale = new Vector3(0.07f, 0.1f, 0.07f);
                    this.GetComponentInParent <GlobalCtrl>().allAtom   = true;
                }
                //Select single atom -- moves independent from the molecule
                else if ((hit.collider.name == "SingleAtom") && (guiSave.activeInHierarchy == false) && (guiLoad.activeInHierarchy == false))
                {
                    GameObject.Find("AllAtoms").transform.localScale   = new Vector3(0.07f, 0.1f, 0.07f);
                    GameObject.Find("SingleAtom").transform.localScale = new Vector3(0.1f, 0.1f, 0.1f);
                    this.GetComponentInParent <GlobalCtrl>().allAtom   = false;
                }
                //Turn off the forcefield, no forces are calculated
                else if ((hit.collider.name == "ButtonOFF") && (guiSave.activeInHierarchy == false) && (guiLoad.activeInHierarchy == false))
                {
                    GameObject.Find("ButtonON").transform.localPosition  = new Vector3(4.75f, 1.6f, 6.5f);
                    GameObject.Find("ButtonOFF").transform.localPosition = new Vector3(4.775f, 1.6f, 6.53f);
                    this.GetComponentInParent <GlobalCtrl>().forceField  = true;
                }
                //Turn on the forcefiled, forces are calculated, atoms are going to move if forces are big enough
                else if ((hit.collider.name == "ButtonON") && (guiSave.activeInHierarchy == false) && (guiLoad.activeInHierarchy == false))
                {
                    GameObject.Find("ButtonOFF").transform.localPosition = new Vector3(4.75f, 1.6f, 6.5f);
                    GameObject.Find("ButtonON").transform.localPosition  = new Vector3(4.775f, 1.6f, 6.53f);
                    this.GetComponentInParent <GlobalCtrl>().forceField  = false;
                }
                //Typing on virtual keyboard
                else if (hit.collider.transform.parent != null && hit.collider.transform.parent.name == "Tastatur")
                {
                    GlobalCtrl text = this.transform.root.GetComponent <GlobalCtrl>();
                    text.textChange(hit.collider.gameObject);
                }
                //Scrollbar and update in GUI, if "open created molecule" is active
                else if (hit.collider.transform.parent != null && hit.collider.transform.parent.name == "GUILoad")
                {
                    if (hit.collider.name == "Down")
                    {
                        GlobalCtrl.updown += 1;
                    }
                    else if (hit.collider.name == "Up" && GlobalCtrl.updown >= 1)
                    {
                        GlobalCtrl.updown -= 1;
                    }
                    else if (hit.collider.name.StartsWith("Platz"))
                    {
                        List <atomData> loadFile = new List <atomData>();
                        loadFile = (List <atomData>)CFileHelper.LoadData(Application.dataPath + "/MoleculeFiles/" + hit.collider.transform.GetChild(0).GetComponent <Text>().text, typeof(List <atomData>));
                        this.transform.root.GetComponent <GlobalCtrl>().loadMolecule(loadFile);
                    }
                    else if (hit.collider.name == "ExitLoadGui")
                    {
                        GlobalCtrl.loadGUI = false;
                        GameObject.Find("GUILoad").SetActive(false);
                        molecule.SetActive(true);
                    }
                }
            }
        }