Exemple #1
0
        /// <summary>
        /// A passed ExchangeService can be displayed for editing or a new
        /// service will be returned after created using this dialog.
        /// </summary>
        /// <param name="service">ExchangeService to be returned or displayed</param>
        /// <returns>DialogResult indicating the user action which closed the dialog</returns>
        public static DialogResult ShowDialog(ref ExchangeService service, ref EwsEditorAppSettings oAppSettings)
        {
            ServiceDialog dialog = new ServiceDialog();

            if (service != null)
            {
                dialog.CurrentService = service;
            }

            if (oAppSettings != null)
            {
                dialog.CurrentAppSettings = oAppSettings;
            }

            DialogResult res = dialog.ShowDialog();

            if (res == DialogResult.OK)
            {
                service = dialog.CurrentService;

                oAppSettings = dialog.CurrentAppSettings;
            }

            return(res);
        }
        private void btnAddService_Click(object sender, EventArgs e)
        {
            var service      = new ExchangeService();
            var app_settinsg = new EwsEditorAppSettings();

            using (var dlg = new ServiceDialog())
            {
                dlg.CurrentService     = new ExchangeService();
                dlg.CurrentAppSettings = new EwsEditorAppSettings();
                dlg.CheckOnOkay        = false;

                if (dlg.ShowDialog() != DialogResult.OK)
                {
                    return;
                }

                StoredServices.Add(new StoredService
                {
                    Name        = txtServiceName.Text,
                    Service     = dlg.CurrentService,
                    AppSettings = dlg.CurrentAppSettings
                });

                UpdateList();
            }
        }
        private void btnEditService_Click(object sender, EventArgs e)
        {
            var stored_service = StoredServices[lsbStoredServices.SelectedIndex];

            using (var dlg = new ServiceDialog())
            {
                dlg.CurrentService     = stored_service.Service;
                dlg.CurrentAppSettings = stored_service.AppSettings;
                dlg.CheckOnOkay        = false;

                if (dlg.ShowDialog() != DialogResult.OK)
                {
                    return;
                }

                stored_service.Service     = dlg.CurrentService;
                stored_service.AppSettings = dlg.CurrentAppSettings;
            }
        }