private void comboEditProfile_SelectedIndexChanged(object sender, EventArgs e) { // Display profile details bsed on this unique profile Name listDebugEditing.Items.Clear(); Profiles comboProfile = (Profiles)comboEditProfile.SelectedItem; listDebugEditing.Items.Add(comboProfile.ProfileNumber + " : " + comboProfile.ProfileName); // Display this info in Textboxes txtProfileID.Text = comboProfile.ProfileNumber.ToString(); txtProfileUserName.Text = comboProfile.ProfileName; // 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.Clear(); ProfileDetails = parentForm.FindaProfile(xmldoc, comboProfile.ProfileNumber); //Get the FirstName and LAst Name from XML if (ProfileDetails.ContainsKey("FirstName")) { txtProfileFirstName.Text = ProfileDetails["FirstName"]; } if (ProfileDetails.ContainsKey("LastName")) { txtProfileLastName.Text = ProfileDetails["LastName"]; } //-------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"]; } }
// 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"]; } } }
private void comboExistingProfile_SelectedIndexChanged(object sender, EventArgs e) { // Display profile details bsed on this unique profile Name listDebugLoading.Items.Clear(); Profiles comboProfile = (Profiles)comboExistingProfile.SelectedItem; listDebugLoading.Items.Add(comboProfile.ProfileNumber + " : " + comboProfile.ProfileName); // Display this info in Textboxes txtProfileID.Text = comboProfile.ProfileNumber.ToString(); txtProfileUserName.Text = comboProfile.ProfileName; // 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.Clear(); ProfileDetails = parentForm.FindaProfile(xmldoc, comboProfile.ProfileNumber); //Get the FirstName and LAst Name from XML if (ProfileDetails.ContainsKey("FirstName")) { txtProfileFirstName.Text = ProfileDetails["FirstName"]; } if (ProfileDetails.ContainsKey("LastName")) { txtProfileLastName.Text = ProfileDetails["LastName"]; } // Generate Commands for all CameraParamets // Every time all parameters will be added in a command string // Order of Command is Fixed according to values in XML // Camera Parameters to Command Mapping // Indexes of values in Command String // 0=>UserName // 1=>ProfileID // 2=>FirstName // 3=>LastName // 4=>GainLeft // 5=>GainRight // 6=>BrightnessLeft // 7=>BrightnessRight // 8=>ContrastLeft // 9=>ContrastRight // 10=>ExposureLeft // 11=>ExposureRight // 12=>SaturationLeft // 13=>SaturationRight // 14=>WhiteBalanceLeft // 15=>WhiteBalanceRight // 16=>HueLeft // 17=>HueRight // 18=>BackgroundThresholdLeft // 19=>BackgroundThresholdRight commandArray.Clear(); // 0=>UserName commandArray.Insert(commandArray.Count, txtProfileUserName.Text); // 1=>ProfileID commandArray.Insert(commandArray.Count, txtProfileID.Text); // 2=>FirstName commandArray.Insert(commandArray.Count, txtProfileFirstName.Text); // 3=>LastName commandArray.Insert(commandArray.Count, txtProfileLastName.Text); // 4=>GainLeft if (ProfileDetails.ContainsKey("GainLeft")) { commandArray.Insert(commandArray.Count, ProfileDetails["GainLeft"]); } // 5=>GainRight if (ProfileDetails.ContainsKey("GainRight")) { commandArray.Insert(commandArray.Count, ProfileDetails["GainRight"]); } // 6=>BrightnessLeft if (ProfileDetails.ContainsKey("BrightnessLeft")) { commandArray.Insert(commandArray.Count, ProfileDetails["BrightnessLeft"]); } // 7=>BrightnessRight if (ProfileDetails.ContainsKey("BrightnessRight")) { commandArray.Insert(commandArray.Count, ProfileDetails["BrightnessRight"]); } // 8=>ContrastLeft if (ProfileDetails.ContainsKey("ContrastLeft")) { commandArray.Insert(commandArray.Count, ProfileDetails["ContrastLeft"]); } // 9=>ContrastRight if (ProfileDetails.ContainsKey("ContrastRight")) { commandArray.Insert(commandArray.Count, ProfileDetails["ContrastRight"]); } // 10=>ExposureLeft if (ProfileDetails.ContainsKey("ExposureLeft")) { commandArray.Insert(commandArray.Count, ProfileDetails["ExposureLeft"]); } // 11=>ExposureRight if (ProfileDetails.ContainsKey("ExposureRight")) { commandArray.Insert(commandArray.Count, ProfileDetails["ExposureRight"]); } // 12=>SaturationLeft if (ProfileDetails.ContainsKey("SaturationLeft")) { commandArray.Insert(commandArray.Count, ProfileDetails["SaturationLeft"]); } // 13=>SaturationRight if (ProfileDetails.ContainsKey("SaturationRight")) { commandArray.Insert(commandArray.Count, ProfileDetails["SaturationRight"]); } // 14=>WhiteBalanceLeft if (ProfileDetails.ContainsKey("WhiteBalanceLeft")) { commandArray.Insert(commandArray.Count, ProfileDetails["WhiteBalanceLeft"]); } // 15=>WhiteBalanceRight if (ProfileDetails.ContainsKey("WhiteBalanceRight")) { commandArray.Insert(commandArray.Count, ProfileDetails["WhiteBalanceRight"]); } // 16=>HueLeft if (ProfileDetails.ContainsKey("HueLeft")) { commandArray.Insert(commandArray.Count, ProfileDetails["HueLeft"]); } // 17=>HueRight if (ProfileDetails.ContainsKey("HueRight")) { commandArray.Insert(commandArray.Count, ProfileDetails["HueRight"]); } // 18=>BackgroundThresholdLeft if (ProfileDetails.ContainsKey("BackgroundThresholdLeft")) { commandArray.Insert(commandArray.Count, ProfileDetails["BackgroundThresholdLeft"]); } // 19=>BackgroundThresholdRight if (ProfileDetails.ContainsKey("BackgroundThresholdRight")) { commandArray.Insert(commandArray.Count, ProfileDetails["BackgroundThresholdRight"]); } }