private void button1_Click(object sender, RoutedEventArgs e) { switch (this.mode) { case Mode.Start: if (!this.tracking) { if (this.loadConfigDialog.ShowDialog() == true) { this.IMI_EXHIBITION = this.fileHandler.loadExhibition(this.TMP_PATH); this.fileHandler.writeTxt(this.IMI_EXHIBITION_PATH, this.TMP_PATH); this.TMP_PATH = null; initExhibition(); } } break; default: break; } }
private void initExhibition() { string exhibitionPath = this.fileHandler.readTxt(this.IMI_EXHIBITION_PATH); if (exhibitionPath == "") // There is no exhibition { this.mode = Mode.Start; updateLayout(); } else // There is an exhibition { // Initialize exhibition this.IMI_EXHIBITION = this.fileHandler.loadExhibition(exhibitionPath); this.IMI_INTRO = new BitmapImage(new Uri(this.IMI_INTRO_PATH)); // Initialize session handling this.sessionHandler = new SessionHandler(Fubi.getClosestUserID(), this.IMI_EXHIBITION.getUserPosition(), 300.0, this.IMI_EXHIBITION.getExhibitionPlane(), new Point3D(System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width, System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height, 0), 5); this.sessionHandler.makeLookupTable(this.IMI_EXHIBITION.getExhibits(), this.IMI_EXHIBITION.getExhibitionPlane()); initFeedbackPositions(); // Initialize data logging int x = exhibitionPath.LastIndexOf('\\'); this.dataLogger = new DataLogger(exhibitionPath.Remove(x)); // Initialize Layout loadBackground(this.IMI_EXHIBITION.getBackgroundImage().Value); this.contentLabel1 = "Standby - " + this.IMI_EXHIBITION.getName(); this.image2.MaxHeight = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height - (this.textBlock1.FontSize * 1.2) - 60; // 1.2 <- 120DPI-factor, 60 =: (4 * 10(px for Margins)) + (2 * 10(px Padding)) this.mode = Mode.Standby; updateLayout(); startTracking(); } }
public Exhibition loadExhibition(string path) { this.exhibitionFolder = path.Substring(0, (path.LastIndexOf('.'))); // Find the exhibition's folder including the exhibition's name at the end XmlReader exhibitionReader = XmlReader.Create(path); // Create XmlReader for file's path while (exhibitionReader.Read()) { if (exhibitionReader.NodeType == XmlNodeType.Element) { switch (exhibitionReader.Name) { case "Exhibition": this.TMP_EXHIBITION = new Exhibition(); while (exhibitionReader.MoveToNextAttribute()) { switch (exhibitionReader.Name) { case "Name": this.TMP_EXHIBITION.setName(exhibitionReader.Value); break; case "Path": this.TMP_EXHIBITION.setPath(exhibitionReader.Value); break; case "BackgroundImage": this.TMP_EXHIBITION.setBackgroundImage(loadImage(exhibitionReader.Value)); break; case "Overview": this.TMP_EXHIBITION.setOverview(loadImage(exhibitionReader.Value)); break; case "UserPosition": this.TMP_EXHIBITION.setUserPosition(Point3D.Parse(exhibitionReader.Value)); break; case "Threshold": this.TMP_EXHIBITION.setThreshold(double.Parse(exhibitionReader.Value)); break; case "SelectionTime": this.TMP_EXHIBITION.setSelectionTime(int.Parse(exhibitionReader.Value)); break; case "LockTime": this.TMP_EXHIBITION.setLockTime(int.Parse(exhibitionReader.Value)); break; case "SlideTime": this.TMP_EXHIBITION.setSlideTime(int.Parse(exhibitionReader.Value)); break; default: break; } } break; case "ExhibitionPlane": while (exhibitionReader.MoveToNextAttribute()) { if (exhibitionReader.Name == "Path") { this.TMP_EXHIBITION.setExhibitionPlane(loadExhibitionPlane(exhibitionReader.Value)); } } break; case "Exhibits": // There are exhibits in the exhibition (exhibtion.getExhibits() != null) this.TMP_EXHIBITION.setExhibits(new List<Exhibit>()); break; case "Exhibit": while (exhibitionReader.MoveToNextAttribute()) { if (exhibitionReader.Name == "Path") { this.TMP_EXHIBITION.addExhibit(loadExhibit(exhibitionReader.Value)); } } break; default: break; } } } exhibitionReader.Close(); return this.TMP_EXHIBITION; }
public void saveExhibition(Exhibition exhibition) { this.exhibitionFolder = exhibition.getPath().Substring(0, (exhibition.getPath().LastIndexOf('.'))); // Find the exhibition's folder including the exhibition's name at the end XmlWriter exhibitionWriter = XmlWriter.Create(exhibition.getPath(), this.xmlWriterSettings); // Create XmlWriter for file's path exhibitionWriter.WriteStartDocument(); // Start writing the file //<Exhibition> exhibitionWriter.WriteStartElement("Exhibition"); exhibitionWriter.WriteAttributeString("Name", exhibition.getName()); exhibitionWriter.WriteAttributeString("Path", exhibition.getPath()); if (exhibition.getBackgroundImage().Key != null) exhibitionWriter.WriteAttributeString("BackgroundImage", exhibition.getBackgroundImage().Key); if (exhibition.getOverview().Key != null) exhibitionWriter.WriteAttributeString("Overview", exhibition.getOverview().Key); exhibitionWriter.WriteAttributeString("UserPosition", exhibition.getUserPosition().ToString().Replace(',', '.').Replace(';', ' ')); exhibitionWriter.WriteAttributeString("Threshold", exhibition.getThreshold().ToString().Replace(',', '.')); exhibitionWriter.WriteAttributeString("SelectionTime", exhibition.getSelectionTime().ToString()); exhibitionWriter.WriteAttributeString("LockTime", exhibition.getLockTime().ToString()); exhibitionWriter.WriteAttributeString("SlideTime", exhibition.getSlideTime().ToString()); saveExhibitionPlane(exhibition.getExhibitionPlane()); //<ExhibitionPlane> exhibitionWriter.WriteStartElement("ExhibitionPlane"); exhibitionWriter.WriteAttributeString("Path", this.exhibitionFolder + "_Plane.xml"); exhibitionWriter.WriteEndElement(); //</ExhibitionPlane> if (exhibition.getExhibits() != null) // There are exhibits in the exhibition { //<Exhibits> exhibitionWriter.WriteStartElement("Exhibits"); foreach (Exhibit exhibit in exhibition.getExhibits()) { if (exhibit.getPath() == null) // No Path yet exhibit.setPath(this.exhibitionFolder + "_" + exhibit.getName() + ".xml"); saveExhibit(exhibit); //<Exhibit> exhibitionWriter.WriteStartElement("Exhibit"); exhibitionWriter.WriteAttributeString("Name", exhibit.getName()); exhibitionWriter.WriteAttributeString("Path", exhibit.getPath()); exhibitionWriter.WriteEndElement(); //</Exhibit> } exhibitionWriter.WriteEndElement(); //</Exhibits> } exhibitionWriter.WriteEndElement(); //</Exhibition> exhibitionWriter.WriteEndDocument(); // Stop writing the file exhibitionWriter.Close(); // Close the file }
private void button5_Click(object sender, RoutedEventArgs e) { switch (this.headline) { default: break; case Headline.Start: //"close the application" closeAllThreads(); break; case Headline.Exhibition: //"close the application" if (this.exhibition.getPath() == null) { if (this.saveConfigDialog.ShowDialog() == true) { this.exhibition.setPath(saveConfigDialog.FileName); } } this.fileHandler.saveExhibition(this.exhibition); closeAllThreads(); break; case Headline.LoadExhibit: //"hidden" break; case Headline.NewExhibit: //"hidden" break; case Headline.EditExhibit: //"editing done" this.TMP_EXHIBIT.setDescription(this.textBox1.Text); if (this.TMP_EXHIBIT_INDEX != -1) // Existing exhibit { this.exhibition.setExhibit(this.TMP_EXHIBIT_INDEX, this.TMP_EXHIBIT); this.fileHandler.saveExhibit(this.TMP_EXHIBIT); this.contentLabel1 = this.exhibition.getName().ToUpper(); this.contentButton4 = "Einstellungen"; this.contentButton5 = "schließen"; this.headline = Headline.Exhibition; updateLayout(); } else // New exhibit { if (this.saveConfigDialog.ShowDialog() == true) { this.TMP_EXHIBIT.setPath(this.saveConfigDialog.FileName); this.TMP_PATH = null; this.exhibition.addExhibit(this.TMP_EXHIBIT); this.fileHandler.saveExhibit(this.TMP_EXHIBIT); this.contentLabel1 = this.exhibition.getName().ToUpper(); this.contentButton4 = "Einstellungen"; this.contentButton5 = "schließen"; this.headline = Headline.Exhibition; updateLayout(); } } break; case Headline.ExhibitionPlane: //"hidden" break; case Headline.ExhibitionPlaneDef: //"start definition of exhibition plane" if (!this.calibrating) { startPlaneDefinition(); this.contentButton4 = "Abbruch"; this.contentButton5 = "Start"; this.button5.Visibility = Visibility.Hidden; updateButtons(); } break; case Headline.ExhibitionPlaneVal: //"start validation of exhibition plane" if (!this.calibrating) { startPlaneDefinition(); this.contentButton4 = "Abbruch"; this.button5.Visibility = Visibility.Hidden; updateButtons(); } break; case Headline.ExhibitionPlaneDone: //"abort validation of exhibition plane" stopTracking(); this.exhibition = new Exhibition(this.TMP_NAME, this.TMP_EXHIBITION_PLANE); MessageBox.Show("Bitte stellen Sie umgehend die Benutzerposition ein."); this.contentLabel1 = this.exhibition.getName().ToUpper(); this.contentButton4 = "Einstellungen"; this.contentButton5 = "schließen"; this.headline = Headline.Exhibition; updateLayout(); break; case Headline.NewName: //"safe name and continue to next view" if (this.exhibition == null) // New exhibition { this.TMP_NAME = this.textBox2.Text; this.contentLabel1 = this.TMP_NAME.ToUpper() + " - EBENENBESTIMMUNG"; this.contentLabel2 = this.INSTRUCTIONS_EXHIBITION_PLANE; this.contentButton1 = "laden"; this.contentButton2 = "bestimmen"; this.contentButton4 = "zurück"; this.contentButton5 = "OK"; this.headline = Headline.ExhibitionPlane; } else // New exhibit { startTracking(); this.TMP_NAME = this.textBox2.Text; this.contentLabel1 = this.TMP_NAME.ToUpper() + " - POSITIONSBESTIMMUNG"; this.contentLabel2 = this.INSTRUCTIONS_EXHIBIT; this.contentButton4 = "zurück"; this.contentButton5 = "Start"; this.headline = Headline.ExhibitDef; } updateLayout(); break; case Headline.ExhibitDef: //"start definition of an exhibit or the user position" if (!this.calibrating && this.setting == Setting.None) { startPositionDefinition(); this.contentButton4 = "Abbruch"; this.button5.Visibility = Visibility.Hidden; updateButtons(); } else if (!this.calibrating && this.setting == Setting.UserPosition) { startUserPositionDefinition(); this.contentButton4 = "Abbruch"; this.button5.Visibility = Visibility.Hidden; updateButtons(); } else if (!this.calibrating && this.setting == Setting.Position) { startPositionDefinition(); this.contentButton4 = "Abbruch"; this.button5.Visibility = Visibility.Hidden; updateButtons(); } break; case Headline.ExhibitVal: //"start validation of an exhibit or accept user position" if (!this.calibrating && this.setting == Setting.None) // Validation { startPositionDefinition(); this.contentButton4 = "Abbruch"; this.button5.Visibility = Visibility.Hidden; updateButtons(); } else if (!this.calibrating && this.setting == Setting.Position) { startPositionDefinition(); this.contentButton4 = "Abbruch"; this.button5.Visibility = Visibility.Hidden; updateButtons(); } else // Acceptance of user position { stopTracking(); this.contentLabel1 = this.exhibition.getName() + " - EINSTELLUNGEN"; this.contentButton5 = "OK"; this.headline = Headline.ExhibitionSettings; updateLayout(); } break; case Headline.ExhibitDone: //"abort validation of exhibition plane" if (this.setting == Setting.UserPosition) { //this.exhibition.setUserPosition SOMEHOW this.contentLabel1 = this.exhibition.getName() + " - EINSTELLUNGEN"; this.contentButton5 = "OK"; this.headline = Headline.ExhibitionSettings; } else if (this.setting == Setting.Position) { this.TMP_EXHIBIT.setPosition(this.geometryHandler.getCenter(this.TMP_POSITION, this.TMP_POSITION_2)); this.contentLabel1 = this.TMP_EXHIBIT.getName() + " - EINSTELLUNGEN"; this.headline = Headline.ExhibitSettings; } else //((int)this.setting == 0) //New Exhibit: Settings.None { Point3D position = this.geometryHandler.getCenter(this.TMP_POSITION, this.TMP_POSITION_2); this.TMP_EXHIBIT = new Exhibit(this.TMP_NAME, position); this.contentLabel1 = this.TMP_EXHIBIT.getName(); this.contentTextBox1 = this.TMP_EXHIBIT.getDescription(); this.headline = Headline.EditExhibit; } this.setting = Setting.None; updateLayout(); break; case Headline.ExhibitionSettings: //"safe and go back to exhibition" if (this.exhibition.getPath() != null) // Config-file already exists { this.fileHandler.saveExhibition(this.exhibition); } this.contentLabel1 = this.exhibition.getName().ToUpper(); this.contentButton4 = "Einstellungen"; this.contentButton5 = "schließen"; this.headline = Headline.Exhibition; this.setting = Setting.None; updateLayout(); break; case Headline.ExhibitSettings: //"go to exhibit" if (this.TMP_EXHIBIT.getPath() != null) // Config-file already exists { this.fileHandler.saveExhibit(this.TMP_EXHIBIT); } this.headline = Headline.EditExhibit; this.setting = Setting.None; updateLayout(); break; } }
private void showLowMedHigh() { // EMPTY INSTANCES ARE FOR DEFAULT USE ONLY ! ! ! Exhibition DEFAULT_EXHIBITION = new Exhibition(); Exhibit DEFAULT_EXHIBIT = new Exhibit(); this.comboBox2.Items.Clear(); this.comboBox2.Items.Add("niedrig"); // Low this.comboBox2.Items.Add("normal"); // Medium this.comboBox2.Items.Add("hoch"); // High switch (this.setting) { case Setting.None: break; case Setting.UserPosition: break; case Setting.BackgroundImage: break; case Setting.Overview: break; case Setting.Threshold: this.comboBox2.SelectedIndex = detLessIsMore(DEFAULT_EXHIBITION.getThreshold(), this.exhibition.getThreshold()); break; case Setting.SelectionTime: this.comboBox2.SelectedIndex = detLessIsLess(DEFAULT_EXHIBITION.getSelectionTime(), this.exhibition.getSelectionTime()); break; case Setting.LockTime: this.comboBox2.SelectedIndex = detLessIsLess(DEFAULT_EXHIBITION.getLockTime(), this.exhibition.getLockTime()); break; case Setting.SlideTime: this.comboBox2.SelectedIndex = detLessIsLess(DEFAULT_EXHIBITION.getSlideTime(), this.exhibition.getSlideTime()); break; case Setting.KernelSize: this.comboBox2.SelectedIndex = detLessIsLess(DEFAULT_EXHIBIT.getKernelSize(), this.TMP_EXHIBIT.getKernelSize()); break; case Setting.KernelWeight: this.comboBox2.SelectedIndex = detLessIsLess(DEFAULT_EXHIBIT.getKernelWeight(), this.TMP_EXHIBIT.getKernelWeight()); break; case Setting.Position: break; default: break; } this.comboBox2.Visibility = Visibility.Visible; this.button2.Visibility = Visibility.Hidden; }
private void button1_Click(object sender, RoutedEventArgs e) { switch (this.headline) { case Headline.Start: //"load existing exhibition" if (this.loadConfigDialog.ShowDialog() == true) // Temporary file path has been set { this.exhibition = this.fileHandler.loadExhibition(this.TMP_PATH); this.TMP_PATH = null; this.contentLabel1 = this.exhibition.getName().ToUpper(); this.contentButton4 = "Einstellungen"; this.contentButton5 = "schließen"; this.headline = Headline.Exhibition; updateLayout(); } break; case Headline.Exhibition: //"hidden" break; case Headline.LoadExhibit: //"edit exhibit" this.TMP_EXHIBIT = this.exhibition.getExhibit(this.TMP_EXHIBIT_INDEX); this.TMP_EXHIBIT_INDEX = this.comboBox1.SelectedIndex - 1; this.contentLabel1 = this.TMP_EXHIBIT.getName().ToUpper() + " - BEARBEITEN"; this.contentTextBox1 = this.TMP_EXHIBIT.getDescription(); this.headline = Headline.EditExhibit; updateLayout(); break; case Headline.NewExhibit: //"load existing exhibit" if (this.loadConfigDialog.ShowDialog() == true) // Temporary file path has been set { this.TMP_EXHIBIT = this.fileHandler.loadExhibit(this.TMP_PATH); this.TMP_PATH = null; this.exhibition.addExhibit(this.TMP_EXHIBIT); this.TMP_EXHIBIT_INDEX = this.exhibition.getExhibits().Count - 1; this.contentLabel1 = this.TMP_EXHIBIT.getName().ToUpper() + " - BEARBEITEN"; this.contentTextBox1 = this.TMP_EXHIBIT.getDescription(); this.headline = Headline.EditExhibit; updateLayout(); } else // Temporary file path hat not been set { } break; case Headline.EditExhibit: //"hidden" break; case Headline.ExhibitionPlane: //"load exisiting definition of the exhibition plane" if (this.loadConfigDialog.ShowDialog() == true) // Temporary file path has been set { this.TMP_EXHIBITION_PLANE = this.fileHandler.loadExhibitionPlane(this.TMP_PATH); this.TMP_PATH = null; this.exhibition = new Exhibition(this.TMP_NAME, this.TMP_EXHIBITION_PLANE); this.contentLabel1 = this.exhibition.getName().ToUpper(); this.contentButton4 = "Einstellungen"; this.contentButton5 = "schließen"; this.headline = Headline.Exhibition; updateLayout(); } break; case Headline.ExhibitionPlaneDef: //"hidden" break; case Headline.ExhibitionPlaneVal: //"hidden" break; case Headline.ExhibitionPlaneDone: //"hidden" break; case Headline.NewName: //"hidden" break; case Headline.ExhibitDef: //"hidden" break; case Headline.ExhibitVal: //"hidden" break; case Headline.ExhibitDone: //"hidden" break; case Headline.ExhibitionSettings: //"hidden" break; case Headline.ExhibitSettings: //"hidden" break; default: break; } }
private void setAttribute() { // EMPTY INSTANCES ARE FOR DEFAULT USE ONLY ! ! ! Exhibition DEFAULT_EXHIBITION = new Exhibition(); Exhibit DEFAULT_EXHIBIT = new Exhibit(); double factor = 1.0; if (this.comboBox2.SelectedIndex == 0) //Low { factor = this.LOW; } else if (this.comboBox2.SelectedIndex == 2) //High { factor = this.HIGH; } switch (this.setting) { case Setting.Threshold: if (factor != 1.0) this.exhibition.setThreshold(DEFAULT_EXHIBITION.getThreshold() * ((this.LOW + this.HIGH) - factor)); else this.exhibition.setThreshold(DEFAULT_EXHIBITION.getThreshold()); break; case Setting.SelectionTime: if (factor != 1.0) this.exhibition.setSelectionTime((int)(DEFAULT_EXHIBITION.getSelectionTime() * factor)); else this.exhibition.setSelectionTime(DEFAULT_EXHIBITION.getSelectionTime()); break; case Setting.LockTime: if (factor != 1.0) this.exhibition.setLockTime((int)(DEFAULT_EXHIBITION.getLockTime() * factor)); else this.exhibition.setLockTime(DEFAULT_EXHIBITION.getLockTime()); break; case Setting.SlideTime: if (factor != 1.0) this.exhibition.setSlideTime((int)(DEFAULT_EXHIBITION.getSlideTime() * factor)); else this.exhibition.setSlideTime(DEFAULT_EXHIBITION.getSlideTime()); break; case Setting.KernelSize: if (factor != 1.0) this.TMP_EXHIBIT.setKernelSize(DEFAULT_EXHIBIT.getKernelSize() * factor); else this.TMP_EXHIBIT.setKernelSize(DEFAULT_EXHIBIT.getKernelSize()); break; case Setting.KernelWeight: if (factor != 1.0) this.TMP_EXHIBIT.setKernelWeight(DEFAULT_EXHIBIT.getKernelWeight() * factor); else this.TMP_EXHIBIT.setKernelWeight(DEFAULT_EXHIBIT.getKernelWeight()); break; default: break; } }
private void definePlane() { int mode = 2; // 0 := pointing, 1 := aiming, 2 := both this.calibrationHandler = new CalibrationHandler(this.SAMPLING_VECTORS); // Initiate calibrator List<GeometryHandler.Vector> vectors = sampleVectors(this.SAMPLING_POINTS, this.SAMPLING_POSITIONS, this.SAMPLING_VECTORS, mode); // Sampled vectors List<Point3D> corners = this.calibrationHandler.definePlane(vectors, this.SAMPLING_POSITIONS, mode); // Calibration-points switch (this.headline) { case Headline.ExhibitionPlaneDef: this.TMP_EXHIBITION_PLANE = new GeometryHandler.Plane(corners); this.contentLabel1 = this.TMP_NAME.ToUpper() + " - EBENENVALIDIERUNG"; this.contentLabel2 = this.INSTRUCTIONS_EXHIBITION_PLANE; this.contentButton4 = "zurück"; this.contentButton5 = "Start"; this.headline = Headline.ExhibitionPlaneVal; stopCalibration(); break; case Headline.ExhibitionPlaneVal: this.TMP_EXHIBITION_PLANE_2 = new GeometryHandler.Plane(corners); this.contentLabel1 = this.TMP_NAME.ToUpper() + " - EBENENBESTIMMUNG"; if (this.calibrationHandler.validatePlane(this.TMP_EXHIBITION_PLANE, this.TMP_EXHIBITION_PLANE_2)) { this.exhibition = new Exhibition(this.TMP_NAME, this.calibrationHandler.makePlane(this.TMP_EXHIBITION_PLANE, this.TMP_EXHIBITION_PLANE_2)); this.contentLabel2 = "Eckpunkte erfolgreich validiert."; this.contentButton4 = "zurück"; this.contentButton5 = "OK"; this.headline = Headline.ExhibitionPlaneDone; stopCalibration(); stopTracking(); } else { this.contentLabel2 = "Eckpunkte konnten nicht validiert werden." + '\n' + '\n' + "Erneut definieren?"; this.contentButton4 = "zurück"; this.contentButton5 = "OK"; this.headline = Headline.ExhibitionPlaneDef; stopCalibration(); } break; default: MessageBox.Show("definePlane()-Problem!"); break; } }