private void btNewProfile_Click(object sender, EventArgs e)
        {
            try{
                wndAskForProfileName askwnd = new wndAskForProfileName();
                askwnd.ShowDialog();
                if ((!askwnd.Cancel) && (!String.IsNullOrEmpty(askwnd.ProfileName)))
                {
                    ProfileData newProfile = new ProfileData();
                    newProfile.Name = askwnd.ProfileName;

                    int port = 0;
                    if (int.TryParse(tbServerPort.Text, out port))
                    {
                        newProfile.DataPort = port;
                    }
                    else
                    {
                        newProfile.DataPort = 0;
                    }

                    newProfile.ProcessName               = this.tbProcess.Text;
                    newProfile.ShowCursor                = this.cbShowCursor.Checked;
                    newProfile.ShowCursor3D              = this.cbShowCursor3D.Checked;
                    newProfile.CursorCorrection          = this.cbCursorCorrection.Checked;
                    newProfile.BorderCorrection.top      = this.hScrollTop.Value;
                    newProfile.BorderCorrection.bottom   = this.hScrollBottom.Value;
                    newProfile.BorderCorrection.left     = this.hScrollLeft.Value;
                    newProfile.BorderCorrection.right    = this.hScrollRight.Value;
                    newProfile.ShowCrosshair             = this.cbCrosshair.Checked;
                    newProfile.ShowCrosshair3D           = this.cbCrosshair3D.Checked;
                    newProfile.CorsorColorName           = this.cbCursorColors.SelectedItem.ToString();
                    newProfile.CursorSize                = this.hScrollCursorSize.Value;
                    newProfile.CursorCorrectionAdjWidth  = this.hScrollAdjWidth.Value;
                    newProfile.CursorCorrectionAdjHeight = this.hScrollAdjHeight.Value;
                    newProfile.UseGDICapture             = this.cbUseGDI.Checked;
                    newProfile.ImageQuality              = this.hScrollImageQuality.Value;
                    newProfile.CustomWindow              = this.cbCustomWindow.Checked;
                    newProfile.CustomWindowSize.x        = (int)this.nCustomWindowX.Value;
                    newProfile.CustomWindowSize.y        = (int)this.nCustomWindowY.Value;
                    newProfile.CustomWindowSize.width    = (int)this.nCustomWindowWidth.Value;
                    newProfile.CustomWindowSize.height   = (int)this.nCustomWindowHeight.Value;


                    // save
                    Profiles.Add(newProfile);

                    RefreshProfileData();
                    //cbProfiles.SelectedIndex=cbProfiles.Items.Count - 1;
                    cbProfiles.SelectedItem = newProfile;

                    SaveProfileData();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("btNewProfile_Click::Error on creating new profile data. \r\n" + ex.Message);
            }
        }
        private void btNewProfile_Click(object sender, EventArgs e)
        {
            try{
                wndAskForProfileName askwnd = new wndAskForProfileName();
                askwnd.ShowDialog();
                if ((!askwnd.Cancel) && (!String.IsNullOrEmpty(askwnd.ProfileName)))
                {
                    ProfileData newProfile = new ProfileData();
                    newProfile.Name = askwnd.ProfileName;

                    int port=0;
                    if (int.TryParse(tbServerPort.Text, out port))
                    {
                        newProfile.DataPort = port;
                    }
                    else
                    {
                        newProfile.DataPort = 0;
                    }

                    newProfile.ProcessName = this.tbProcess.Text;
                    newProfile.ShowCursor = this.cbShowCursor.Checked;
                    newProfile.CursorCorrection = this.cbCursorCorrection.Checked;
                    newProfile.BorderCorrection.top = this.hScrollTop.Value;
                    newProfile.BorderCorrection.bottom = this.hScrollBottom.Value;
                    newProfile.BorderCorrection.left = this.hScrollLeft.Value;
                    newProfile.BorderCorrection.right = this.hScrollRight.Value;
                    newProfile.ShowCrosshair = this.cbCrosshair.Checked;
                    newProfile.CorsorColorName = this.cbCursorColors.SelectedItem.ToString();
                    newProfile.CursorSize = this.hScrollCursorSize.Value;
                    newProfile.CursorCorrectionAdjWidth = this.hScrollAdjWidth.Value;
                    newProfile.CursorCorrectionAdjHeight = this.hScrollAdjHeight.Value;
                    newProfile.UseGDICapture = this.cbUseGDI.Checked;
                    newProfile.ImageQuality = this.hScrollImageQuality.Value;
                    newProfile.CustomWindow = this.cbCustomWindow.Checked;
                    newProfile.CustomWindowSize.x = (int) this.nCustomWindowX.Value;
                    newProfile.CustomWindowSize.y = (int)this.nCustomWindowY.Value;
                    newProfile.CustomWindowSize.width = (int)this.nCustomWindowWidth.Value;
                    newProfile.CustomWindowSize.height = (int)this.nCustomWindowHeight.Value;

                    // save
                    Profiles.Add(newProfile);

                    RefreshProfileData();
                    //cbProfiles.SelectedIndex=cbProfiles.Items.Count - 1;
                    cbProfiles.SelectedItem = newProfile;

                    SaveProfileData();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("btNewProfile_Click::Error on creating new profile data. \r\n" + ex.Message);
            }
        }