Пример #1
0
        /// <summary>
        /// Set all fields to default values.
        /// </summary>
        public void SetDefaults()
        {
            NameTB.Text                  = null;
            ActiveCB.Checked             = true;
            UpdateRateCTRL.Value         = 1000;
            KeepAliveRateCTRL.Value      = 0;
            KeepAliveSpecifiedCB.Checked = false;
            DeadbandCTRL.Value           = 0;
            DeadbandSpecifiedCB.Checked  = false;
            LocaleCTRL.Locale            = "";
            LocaleSpecifiedCB.Checked    = false;

            if (m_server != null)
            {
                LocaleCTRL.Locale         = m_server.Locale;
                LocaleSpecifiedCB.Checked = m_server.Locale != null;
                LocaleCTRL.SetSupportedLocales(m_server.SupportedLocales);
            }
        }
        /// <summary>
        /// Prompts user to edit request option parameters in a modal dialog.
        /// </summary>
        private void ShowDialog(TsCDaServer server, TsCDaSubscription subscription)
        {
            if (server == null)
            {
                throw new ArgumentNullException("server");
            }

            // get supported locales.
            LocaleCTRL.SetSupportedLocales(server.SupportedLocales);

            // set locale.
            string locale = (subscription == null)?server.Locale:subscription.Locale;

            LocaleCTRL.Locale         = locale;
            LocaleSpecifiedCB.Checked = locale != null;

            // get filters.
            int filters = (subscription == null)?server.Filters:subscription.Filters;

            ItemNameCB.Checked       = ((filters & (int)TsCDaResultFilter.ItemName) != 0);
            ItemPathCB.Checked       = ((filters & (int)TsCDaResultFilter.ItemPath) != 0);
            ClientHandleCB.Checked   = ((filters & (int)TsCDaResultFilter.ClientHandle) != 0);
            ItemTimeCB.Checked       = ((filters & (int)TsCDaResultFilter.ItemTime) != 0);
            ErrorTextCB.Checked      = ((filters & (int)TsCDaResultFilter.ErrorText) != 0);
            DiagnosticInfoCB.Checked = ((filters & (int)TsCDaResultFilter.DiagnosticInfo) != 0);

            // show dialog.
            while (ShowDialog() == DialogResult.OK)
            {
                // update locale.
                try
                {
                    locale = null;

                    if (LocaleSpecifiedCB.Checked)
                    {
                        locale = LocaleCTRL.Locale;
                    }

                    if (subscription == null)
                    {
                        server.SetLocale(locale);
                    }
                    else
                    {
                        TsCDaSubscriptionState state = new TsCDaSubscriptionState();
                        state.Locale = locale;
                        subscription.ModifyState((int)TsCDaStateMask.Locale, state);
                    }
                }
                catch (Exception e)
                {
                    MessageBox.Show(e.Message);
                    continue;
                }

                // update filters.
                filters = 0;

                filters |= (ItemNameCB.Checked)?(int)TsCDaResultFilter.ItemName:0;
                filters |= (ItemPathCB.Checked)?(int)TsCDaResultFilter.ItemPath:0;
                filters |= (ClientHandleCB.Checked)?(int)TsCDaResultFilter.ClientHandle:0;
                filters |= (ItemTimeCB.Checked)?(int)TsCDaResultFilter.ItemTime:0;
                filters |= (ErrorTextCB.Checked)?(int)TsCDaResultFilter.ErrorText:0;
                filters |= (DiagnosticInfoCB.Checked)?(int)TsCDaResultFilter.DiagnosticInfo:0;

                try
                {
                    if (subscription == null)
                    {
                        server.SetResultFilters(filters);
                    }
                    else
                    {
                        subscription.SetResultFilters(filters);
                    }
                }
                catch (Exception e)
                {
                    MessageBox.Show(e.Message);
                    continue;
                }

                // break out of loop if no error.
                break;
            }
        }