public LoadProfile(Form parentCaller) { this.parentForm = parentCaller as FrmProfileHandler; // Obtain input profiles file name InputFileName = parentForm.InputFileName; // initialize all controls first InitializeComponent(); // Finally Populate All profiles IDs and their Names in ComboBox xmldoc = XDocument.Load(InputFileName); // Traverse through all Profile Names and fill them in a Dropdown menu String profName; int pID = 0; foreach (XElement el in xmldoc.Root.Elements()) { //Profile ProfileItem = new Profile(); profName = el.Attribute("UserName").Value; pID = Convert.ToInt32(el.Attribute("ID").Value); comboExistingProfile.Items.Add(new Profiles(profName, pID)); } comboExistingProfile.Sorted = true; comboExistingProfile.AutoCompleteMode = AutoCompleteMode.Suggest; // Also Socket commumnication for sending packets try { // Connect to the server running in Unity int port = 1234; clientSocket = new TcpClient("127.0.0.1", port); string text = "Connected to server on port " + port; listDebugLoading.Items.Add(text); } catch (Exception ex) { listDebugLoading.Items.Add("No Server to connect to.."); } }
public LoadProfile(Form parentCaller) { this.parentForm = parentCaller as FrmProfileHandler; // Obtain input profiles file name InputFileName = parentForm.InputFileName; // initialize all controls first InitializeComponent(); // Finally Populate All profiles IDs and their Names in ComboBox xmldoc = XDocument.Load(InputFileName); // Traverse through all Profile Names and fill them in a Dropdown menu String profName; int pID = 0; foreach (XElement el in xmldoc.Root.Elements()) { //Profile ProfileItem = new Profile(); profName = el.Attribute("UserName").Value; pID = Convert.ToInt32(el.Attribute("ID").Value); comboExistingProfile.Items.Add(new Profiles(profName, pID)); } comboExistingProfile.Sorted = true; comboExistingProfile.AutoCompleteMode = AutoCompleteMode.Suggest; // Also Socket commumnication for sending packets try { // Connect to the server running in Unity int port = 1234; clientSocket = new TcpClient("127.0.0.1", port); string text = "Connected to server on port " + port; listDebugLoading.Items.Add(text); } catch (Exception ex) { listDebugLoading.Items.Add("No Server to connect to.."); } }
// Constructure Called when this Form is being created public NewOrEditProfile(Form parentCaller) { this.parentForm = parentCaller as FrmProfileHandler; // Obtain input profiles file name InputFileName = parentForm.InputFileName; // initialize all controls first InitializeComponent(); if (parentForm.ButtonPressed == "Edit") { //UN-Hide Combo Box,delete, Update Button comboEditProfile.Visible = true; btnAdvCameraOptions.Visible = true; btnDeleteProfile.Visible = true; btnUpdateProfile.Visible = true; lblProfileNotFound.Visible = true; txtProfileUserName.ReadOnly = true; // Set Label accordingly lblCreateEdit.Text = "Please choose a profile to edit"; lblProfileNotFound.Text = "*Not listed? Did you create this profile first?"; //Hide Create button btnCreateProfile.Visible = false; // Finally Populate All profiles IDs and their Names in ComboBox xmldoc = XDocument.Load(InputFileName); // Traverse through all Profile Names and fill them in a Dropdown menu String profName; int pID = 0; foreach (XElement el in xmldoc.Root.Elements()) { //Profile ProfileItem = new Profile(); profName = el.Attribute("UserName").Value; pID = Convert.ToInt32(el.Attribute("ID").Value); comboEditProfile.Items.Add(new Profiles(profName, pID)); } comboEditProfile.Sorted = true; comboEditProfile.AutoCompleteMode = AutoCompleteMode.Suggest; } else if (parentForm.ButtonPressed == "New") { //Hide Combo Box,delete, Update Button comboEditProfile.Visible = false; btnAdvCameraOptions.Visible = false; btnDeleteProfile.Visible = false; btnUpdateProfile.Visible = false; lblProfileNotFound.Visible = false; // Set Label accordingly lblCreateEdit.Text = "Please fill profile details.\nDefault camera options are already filled:"; // Enable controls to make them editable txtProfileUserName.Enabled = true; txtProfileUserName.ReadOnly = false; btnAdvCameraOptions.Enabled = true; btnAdvCameraOptions.Visible = true; // Now Load values from Default Profile into the text fields // Read All profiles // Find profile with ID=1 which is Default Profile xmldoc = XDocument.Load(InputFileName); ProfileDetails = parentForm.FindaProfile(xmldoc, 1); // Now ProfileDetails contains TextFields Names as Keys and their values to fill in //--------New Profile ID will be assigned automatically by looking at all previous IDs and find ing the latest one--------// int MaxID = parentForm.FindMaximumProfileID(xmldoc); txtProfileID.Text = (MaxID + 1).ToString(); //-------Left Camera Options ------------// if (ProfileDetails.ContainsKey("GainLeft")) { txtProfileGainLeft.Text = ProfileDetails["GainLeft"]; } if (ProfileDetails.ContainsKey("BrightnessLeft")) { txtProfileBrightnessLeft.Text = ProfileDetails["BrightnessLeft"]; } if (ProfileDetails.ContainsKey("ContrastLeft")) { txtProfileContrastLeft.Text = ProfileDetails["ContrastLeft"]; } if (ProfileDetails.ContainsKey("ExposureLeft")) { txtProfileExposureLeft.Text = ProfileDetails["ExposureLeft"]; } if (ProfileDetails.ContainsKey("SaturationLeft")) { txtProfileSaturationLeft.Text = ProfileDetails["SaturationLeft"]; } if (ProfileDetails.ContainsKey("WhiteBalanceLeft")) { txtProfileWhiteBalLeft.Text = ProfileDetails["WhiteBalanceLeft"]; } if (ProfileDetails.ContainsKey("HueLeft")) { txtProfileHueLeft.Text = ProfileDetails["HueLeft"]; } if (ProfileDetails.ContainsKey("BackgroundThresholdLeft")) { txtProfileBackgroundThresholdLeft.Text = ProfileDetails["BackgroundThresholdLeft"]; } //-------Right Camera Options ------------// if (ProfileDetails.ContainsKey("GainRight")) { txtProfileGainRight.Text = ProfileDetails["GainRight"]; } if (ProfileDetails.ContainsKey("BrightnessRight")) { txtProfileBrightnessRight.Text = ProfileDetails["BrightnessRight"]; } if (ProfileDetails.ContainsKey("ContrastRight")) { txtProfileContrastRight.Text = ProfileDetails["ContrastRight"]; } if (ProfileDetails.ContainsKey("ExposureRight")) { txtProfileExposureRight.Text = ProfileDetails["ExposureRight"]; } if (ProfileDetails.ContainsKey("SaturationRight")) { txtProfileSaturationRight.Text = ProfileDetails["SaturationRight"]; } if (ProfileDetails.ContainsKey("WhiteBalanceRight")) { txtProfileWhiteBalRight.Text = ProfileDetails["WhiteBalanceRight"]; } if (ProfileDetails.ContainsKey("HueRight")) { txtProfileHueRight.Text = ProfileDetails["HueRight"]; } if (ProfileDetails.ContainsKey("BackgroundThresholdRight")) { txtProfileBackgroundThresholdRight.Text = ProfileDetails["BackgroundThresholdRight"]; } } }