Ejemplo n.º 1
0
        /// <summary>
        /// Method called on add new client event.
        /// </summary>
        /// <param name="sender">The <see cref="object"/> sender of the event.</param>
        /// <param name="e">The routed event arguments <see cref="RoutedEventArgs"/>.</param>
        public void AddClient_Click(object sender, RoutedEventArgs e)
        {
            var    tag    = ((FrameworkElement)sender).Tag;
            Client client = new Client();

            if (tag != null && tag.GetType() == typeof(Client))
            {
                client = tag as Client;
            }

            using (WindowFormClientLayout dlg = new WindowFormClientLayout(client))
            {
                bool?result = dlg.ShowDialog();

                if (result == true)
                {
                    MessageBoxs.IsBusy = true;

                    ApplicationBase.Options.Remote.Clients.AddKeySingle(dlg.NewForm);
                    ApplicationBase.SaveOptions();
                    RaiseClientAdded(this, e.RoutedEvent);

                    MessageBoxs.IsBusy = false;
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Method called on sever edit settings event click.
        /// </summary>
        /// <param name="sender">The <see cref="object"/> sender of the event.</param>
        /// <param name="e">The routed event arguments <see cref="RoutedEventArgs"/>.</param>
        private void ServerSettings_Click(object sender, RoutedEventArgs e)
        {
            using (WindowFormServerLayout dlg = new WindowFormServerLayout(ApplicationBase.Options.Remote.Servers.FindDefaultFirst()))
            {
                try
                {
                    bool?result = dlg.ShowDialog();

                    if (result == true)
                    {
                        dlg.NewFormData.IsDefault = true;

                        var def = ApplicationBase.Options.Remote.Servers.FindDefaultFirst();
                        if (def == null)
                        {
                            ApplicationBase.Options.Remote.Servers.Add(dlg.NewFormData);
                        }
                        else
                        {
                            ApplicationBase.Options.Remote.Servers.ReplaceDefault(dlg.NewFormData);
                        }


                        var eee = ApplicationBase.Options.Remote.Servers;

                        ApplicationBase.SaveOptions();
                        if (HttpWebServerApplication.IsStarted)
                        {
                            ServerRestart_Click(sender, e);
                        }
                    }
                    else
                    {
                        var def = ApplicationBase.Options.Remote.Servers.FindDefaultFirst();
                        def.Bind(dlg.OldFormData);
                    }
                }
                catch (Exception ex)
                {
                    log.Error(ex.Output(), ex);
                    MessageBoxs.Error(ex);
                }
            }
        }