public static void ShowForm(Synchy f) { if (form != null) { form.BringToFront(); } else { form = new Preferences(f); form.Show(); } }
public Grid rootGrid; // = new Grid(); #endregion // Members #region Methods /// <summary> /// Handle the GUI layout /// </summary> /// <param name="kinect_num"></param> /// <param name="rootWindow"></param> public GUIComponents(int kinect_num, MainWindow rootWindow) { kinectNUM = kinect_num; /* Set the size of the window */ rootGrid = rootWindow.rootGrid; rootGrid.Width = singleKinectW * kinectNUM + fusedDataW; rootGrid.Height = kinectH + serverH; // Setup the layout of the GUI buildRootGrid(rootGrid); /* Message Text Block */ serverMsgTxtBlock.Text = "No server message"; Grid.SetColumn(serverMsgTxtBlock, 0); Grid.SetRow(serverMsgTxtBlock, 1); rootGrid.Children.Add(serverMsgTxtBlock); int currentHeight = 0; int btnH = 40; /* Calibration Button */ calibrationBtn.VerticalAlignment = VerticalAlignment.Top; calibrationBtn.Height = btnH; calibrationBtn.Margin = new Thickness(0, currentHeight, 0, 0); currentHeight += btnH; calibrationBtn.Content = "Do Calibration"; Grid.SetColumn(calibrationBtn, 1); Grid.SetRow(calibrationBtn, 1); rootGrid.Children.Add(calibrationBtn); calibrationBtn.Click += new RoutedEventHandler(runCalibration); /* updateAllImage Button */ updateAllImageBtn.VerticalAlignment = VerticalAlignment.Top; updateAllImageBtn.Height = btnH; updateAllImageBtn.Margin = new Thickness(0, currentHeight, 0, 0); currentHeight += btnH; updateAllImageBtn.Content = "Update All Images"; Grid.SetColumn(updateAllImageBtn, 1); Grid.SetRow(updateAllImageBtn, 1); rootGrid.Children.Add(updateAllImageBtn); updateAllImageBtn.Click += new RoutedEventHandler(updateAllImagesEvent); /* addSynchy Button */ addSynchyBtn.VerticalAlignment = VerticalAlignment.Top; addSynchyBtn.Content = "Add Synchy"; addSynchyBtn.Height = btnH; addSynchyBtn.Margin = new Thickness(0, currentHeight, 0, 0); currentHeight += btnH; Grid.SetColumn(addSynchyBtn, 1); Grid.SetRow(addSynchyBtn, 1); rootGrid.Children.Add(addSynchyBtn); addSynchyBtn.Click += new RoutedEventHandler(startAddSynchy); /* clearSynchy Button */ clearSynchyBtn.VerticalAlignment = VerticalAlignment.Top; clearSynchyBtn.Content = "Delete a Synchy"; clearSynchyBtn.Height = btnH; clearSynchyBtn.Margin = new Thickness(0, currentHeight, 0, 0); currentHeight += btnH; Grid.SetColumn(clearSynchyBtn, 1); Grid.SetRow(clearSynchyBtn, 1); rootGrid.Children.Add(clearSynchyBtn); clearSynchyBtn.Click += new RoutedEventHandler(deleteASynchy); /* Build the grid to contain multi kinectComps */ kinectGrid.ShowGridLines = true; RowDefinition r0 = new RowDefinition(); r0.Height = new GridLength(kinectH); kinectGrid.RowDefinitions.Add(r0); Grid.SetColumn(kinectGrid, 0); rootGrid.Children.Add(kinectGrid); for (int i = 0; i < kinect_num; ++i) { ColumnDefinition c = new ColumnDefinition(); c.Width = new GridLength(singleKinectW); kinectGrid.ColumnDefinitions.Add(c); kinectCompList.Add(new KinectComp(kinectH, singleKinectW, this, i)); } fusedGrid.Height = kinectH; Grid.SetColumn(fusedGrid, 1); Grid.SetRow(fusedGrid, 0); rootGrid.Children.Add(fusedGrid); /* Read synchy from data */ string synchyData = System.IO.File.ReadAllText("synchyLog.txt"); string[] synchyDataList = synchyData.Split('*'); if (synchyDataList.Length > 1) { int num = Convert.ToInt32(synchyDataList[0]); for (int i = 1; i <= num; ++i) { string[] cors = synchyDataList[i].Split(' '); int index = 0; Synchy s = new Synchy(); s.Center.X = Convert.ToDouble(cors[index++]); s.Center.Y = Convert.ToDouble(cors[index++]); s.Center.Z = Convert.ToDouble(cors[index++]); s.xUnit.X = Convert.ToDouble(cors[index++]); s.xUnit.Y = Convert.ToDouble(cors[index++]); s.xUnit.Z = Convert.ToDouble(cors[index++]); s.yUnit.X = Convert.ToDouble(cors[index++]); s.yUnit.Y = Convert.ToDouble(cors[index++]); s.yUnit.Z = Convert.ToDouble(cors[index++]); s.zUnit.X = Convert.ToDouble(cors[index++]); s.zUnit.Y = Convert.ToDouble(cors[index++]); s.zUnit.Z = Convert.ToDouble(cors[index++]); s.xPar.X = Convert.ToDouble(cors[index++]); s.xPar.Y = Convert.ToDouble(cors[index++]); s.xPar.Z = Convert.ToDouble(cors[index++]); s.yPar.X = Convert.ToDouble(cors[index++]); s.yPar.Y = Convert.ToDouble(cors[index++]); s.yPar.Z = Convert.ToDouble(cors[index++]); s.zPar.X = Convert.ToDouble(cors[index++]); s.zPar.Y = Convert.ToDouble(cors[index++]); s.zPar.Z = Convert.ToDouble(cors[index++]); synchyList.Add(s); } } }
public Preferences(Synchy f) { mainform = f; InitializeComponent(); }