Inheritance: ObservableObject
Ejemplo n.º 1
0
 public AuxiliaryApplicationViewModel(AuxiliaryApplication auxApplication, SettingsWindowViewModel context)
 {
     _context          = context;
     ValidationContext = context;
     _auxApplication   = auxApplication;
     IsExpanded        = false;
 }
 public AuxiliaryApplicationViewModel(AuxiliaryApplication auxApplication, SettingsWindowViewModel context)
 {
     _context = context;
     ValidationContext = context;
     _auxApplication = auxApplication;
     IsExpanded = false;
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Show the settings dialogue
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void settingsCommand(object sender, EventArgs e)
        {
            if (_plexService != null)
            {
                Settings settings = null;
                try
                {
                    settings = Settings.Deserialize(_plexService.GetSettings());
                }
                catch
                {
                    disconnect();
                }

                if (settings != null)
                {
                    //Save the current server port setting for reference
                    int oldPort = settings.ServerPort;
                    SettingsWindowViewModel settingsViewModel = new SettingsWindowViewModel(settings);
                    SettingsWindow          settingsWindow    = new SettingsWindow(settingsViewModel);
                    if (settingsWindow.ShowDialog() == true)
                    {
                        PlexState status = PlexState.Pending;
                        try
                        {
                            _plexService.SetSettings(settingsViewModel.WorkingSettings.Serialize());
                            status = _plexService.GetStatus();
                        }
                        catch (Exception ex)
                        {
                            disconnect();
                            MessageBox.Show("Unable to save settings" + Environment.NewLine + ex.Message);
                        }
                        //The only setting that would require a restart of the service is the listening port.
                        //If that gets changed notify the user to restart the service from the service snap in
                        if (settingsViewModel.WorkingSettings.ServerPort != oldPort)
                        {
                            MessageBox.Show("Server port changed! You will need to restart the service from the services snap in for the change to be applied", "Settings changed!", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                    }
                }
            }
        }
        /// <summary>
        /// Show the settings dialogue
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void SettingsCommand(object sender, EventArgs e)
        {
            if (_plexService != null)
            {
                Settings settings = null;
                try
                {
                    settings = Settings.Deserialize(_plexService.GetSettings());
                }
                catch
                {
                    Disconnect();
                }

                if (settings != null)
                {
                    //Save the current server port setting for reference
                    int oldPort = settings.ServerPort;
                    SettingsWindowViewModel settingsViewModel = new SettingsWindowViewModel(settings);
                    settingsViewModel.AuxAppStartRequest += (s, args) =>
                    {
                        var requester = s as AuxiliaryApplicationViewModel;
                        if (requester != null)
                        {
                            _plexService.StartAuxApp(requester.Name);
                            requester.Running = _plexService.IsAuxAppRunning(requester.Name);
                        }
                    };
                    settingsViewModel.AuxAppStopRequest += (s, args) =>
                    {
                        var requester = s as AuxiliaryApplicationViewModel;
                        if(requester != null)
                        {
                            _plexService.StopAuxApp(requester.Name);
                            requester.Running = _plexService.IsAuxAppRunning(requester.Name);
                        }
                    };
                    settingsViewModel.AuxAppCheckRunRequest += (s, args) =>
                    {
                        var requester = s as AuxiliaryApplicationViewModel;
                        if (requester != null)
                        {
                            requester.Running = _plexService.IsAuxAppRunning(requester.Name);
                        }
                    };
                    SettingsWindow settingsWindow = new SettingsWindow(settingsViewModel);
                    if (settingsWindow.ShowDialog() == true)
                    {
                        PlexState status = PlexState.Pending;
                        try
                        {
                            _plexService.SetSettings(settingsViewModel.WorkingSettings.Serialize());
                            status = _plexService.GetStatus();
                        }
                        catch(Exception ex)
                        {
                            Disconnect();
                            MessageBox.Show("Unable to save settings" + Environment.NewLine + ex.Message);
                        }
                        //The only setting that would require a restart of the service is the listening port.
                        //If that gets changed notify the user to restart the service from the service snap in
                        if (settingsViewModel.WorkingSettings.ServerPort != oldPort)
                        {
                            MessageBox.Show("Server port changed! You will need to restart the service from the services snap in for the change to be applied", "Settings changed!", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                    }
                }
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Show the settings dialogue
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void SettingsCommand(object sender, EventArgs e)
        {
            if (_plexService != null)
            {
                Settings settings = null;
                try
                {
                    settings = Settings.Deserialize(_plexService.GetSettings());
                }
                catch
                {
                    Disconnect();
                }

                if (settings != null)
                {
                    //Save the current server port setting for reference
                    int oldPort = settings.ServerPort;
                    SettingsWindowViewModel settingsViewModel = new SettingsWindowViewModel(settings);
                    settingsViewModel.AuxAppStartRequest += (s, args) =>
                    {
                        var requester = s as AuxiliaryApplicationViewModel;
                        if (requester != null)
                        {
                            _plexService.StartAuxApp(requester.Name);
                            requester.Running = _plexService.IsAuxAppRunning(requester.Name);
                        }
                    };
                    settingsViewModel.AuxAppStopRequest += (s, args) =>
                    {
                        var requester = s as AuxiliaryApplicationViewModel;
                        if (requester != null)
                        {
                            _plexService.StopAuxApp(requester.Name);
                            requester.Running = _plexService.IsAuxAppRunning(requester.Name);
                        }
                    };
                    settingsViewModel.AuxAppCheckRunRequest += (s, args) =>
                    {
                        var requester = s as AuxiliaryApplicationViewModel;
                        if (requester != null)
                        {
                            requester.Running = _plexService.IsAuxAppRunning(requester.Name);
                        }
                    };
                    _settingsWindow = new SettingsWindow(settingsViewModel);
                    if (_settingsWindow.ShowDialog() == true)
                    {
                        PlexState status = PlexState.Pending;
                        try
                        {
                            _plexService.SetSettings(settingsViewModel.WorkingSettings.Serialize());
                            status = _plexService.GetStatus();
                        }
                        catch (Exception ex)
                        {
                            Disconnect();
                            System.Windows.MessageBox.Show("Unable to save settings" + Environment.NewLine + ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                        }
                        //The only setting that would require a restart of the service is the listening port.
                        //If that gets changed notify the user to restart the service from the service snap in
                        if (settingsViewModel.WorkingSettings.ServerPort != oldPort)
                        {
                            System.Windows.MessageBox.Show("Server port changed! You will need to restart the service from the services snap in for the change to be applied", "Settings changed!", MessageBoxButton.OK, MessageBoxImage.Information);
                        }
                    }
                    _settingsWindow = null;
                }
            }
        }
Ejemplo n.º 6
0
 public SettingsWindow(SettingsWindowViewModel settingsViewModel)
 {
     InitializeComponent();
     DataContext = settingsViewModel;
 }
Ejemplo n.º 7
0
 public SettingsWindow()
 {
     InitializeComponent();
     DataContext = new SettingsWindowViewModel();
 }