Exemple #1
0
        private void _okButton_Click(object sender, EventArgs e)
        {
            try
            {
                _serverSettings.ServerName = _serverTextBox.Text.Trim();
                ServiceTransport transport = ServiceTransport.Http;
                if (_transportComboBox.SelectedIndex == 1)
                {
                    transport = ServiceTransport.Https;
                }
                _serverSettings.Transport                = transport;
                _serverSettings.Port                     = (int)_portNumericUpDown.Value;
                _serverSettings.WakeOnLan.Enabled        = _useWolCheckBox.Checked;
                _serverSettings.WakeOnLan.TimeoutSeconds = (int)_wolSecondsNumericUpDown.Value;

                bool doConnect = true;

                if (_serverSettings.Transport == ServiceTransport.Https)
                {
                    using (LogonForm logonForm = new LogonForm())
                    {
                        logonForm.UserName       = _serverSettings.UserName;
                        logonForm.Password       = _serverSettings.Password;
                        doConnect                = (DialogResult.OK == logonForm.ShowDialog(this));
                        _savePassword            = logonForm.SavePassword;
                        _serverSettings.UserName = logonForm.UserName;
                        _serverSettings.Password = logonForm.Password;
                    }
                }

                if (doConnect)
                {
                    try
                    {
                        Cursor.Current = Cursors.WaitCursor;
                        Proxies.Initialize(_serverSettings, true);

                        if (_saveAsProfileCheckBox.Checked)
                        {
                            _profileName = _profileNameTextBox.Text.Trim();
                        }
                        else
                        {
                            _profileName = null;
                        }
                        this.DialogResult = DialogResult.OK;
                        this.Close();
                    }
                    finally
                    {
                        Cursor.Current = Cursors.Default;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, ex.Message, null, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemple #2
0
        private void _okButton_Click(object sender, EventArgs e)
        {
            try
            {
                _serverSettings.ServerName = _serverTextBox.Text.Trim();
                ServiceTransport transport = ServiceTransport.Http;
                if (_transportComboBox.SelectedIndex == 1)
                {
                    transport = ServiceTransport.Https;
                }
                _serverSettings.Transport = transport;
                _serverSettings.Port = (int)_portNumericUpDown.Value;
                _serverSettings.WakeOnLan.Enabled = _useWolCheckBox.Checked;
                _serverSettings.WakeOnLan.TimeoutSeconds = (int)_wolSecondsNumericUpDown.Value;

                bool doConnect = true;

                if (_serverSettings.Transport == ServiceTransport.Https)
                {
                    using (LogonForm logonForm = new LogonForm())
                    {
                        logonForm.UserName = _serverSettings.UserName;
                        logonForm.Password = _serverSettings.Password;
                        doConnect = (DialogResult.OK == logonForm.ShowDialog(this));
                        _savePassword = logonForm.SavePassword;
                        _serverSettings.UserName = logonForm.UserName;
                        _serverSettings.Password = logonForm.Password;
                    }
                }

                if (doConnect)
                {
                    try
                    {
                        Cursor.Current = Cursors.WaitCursor;
                        Proxies.Initialize(_serverSettings, true);

                        if (_saveAsProfileCheckBox.Checked)
                        {
                            _profileName = _profileNameTextBox.Text.Trim();
                        }
                        else
                        {
                            _profileName = null;
                        }
                        this.DialogResult = DialogResult.OK;
                        this.Close();
                    }
                    finally
                    {
                        Cursor.Current = Cursors.Default;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, ex.Message, null, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemple #3
0
        public bool ConnectToArgusTVService(string currentProfileName, bool reconnect)
        {
            bool result                 = false;
            bool abortConnection        = false;
            bool tryConnectionWithoutUI = !reconnect;
            bool skipSelectionForm      = false;

            IList <ConnectionProfile> profiles = ConnectionProfiles.GetList();

            if (!reconnect &&
                !String.IsNullOrEmpty(currentProfileName))
            {
                _connectionProfile = FindConnectionProfileByName(profiles, currentProfileName);
                skipSelectionForm  = (_connectionProfile != null);
            }

            if (_connectionProfile != null)
            {
                currentProfileName = _connectionProfile.Name;
            }
            else
            {
                currentProfileName = Properties.Settings.Default.LastUsedConnectionProfile;
            }

            if (profiles.Count == 1)
            {
                _connectionProfile = profiles[0];
            }
            else if (profiles.Count > 1 &&
                     !skipSelectionForm)
            {
                if (!reconnect)
                {
                    Program.App.HideSplash();
                }
                SelectProfileForm selectProfileForm = new SelectProfileForm();
                selectProfileForm.SetSelectedProfileName(currentProfileName);
                if (selectProfileForm.ShowDialog(this) == DialogResult.OK)
                {
                    _connectionProfile = selectProfileForm.SelectedProfile;
                    if (_connectionProfile != null)
                    {
                        tryConnectionWithoutUI = !selectProfileForm.EditSelectedProfile;
                        if (tryConnectionWithoutUI &&
                            !reconnect)
                        {
                            Program.App.ShowSplash();
                        }
                    }
                }
                else
                {
                    result          = false;
                    abortConnection = true;
                }
            }

            if (!abortConnection)
            {
                if (tryConnectionWithoutUI &&
                    _connectionProfile != null)
                {
                    bool saveProfiles = false;

                    if (_connectionProfile.ServerSettings.Transport == ServiceProxy.ServiceTransport.Https &&
                        String.IsNullOrEmpty(_connectionProfile.ServerSettings.Password))
                    {
                        using (LogonForm logonForm = new LogonForm())
                        {
                            logonForm.UserName = _connectionProfile.ServerSettings.UserName;
                            Program.App.HideSplash();
                            if (DialogResult.OK == logonForm.ShowDialog(this))
                            {
                                _connectionProfile.ServerSettings.UserName = logonForm.UserName;
                                _connectionProfile.ServerSettings.Password = logonForm.Password;
                                _connectionProfile.SavePassword            = logonForm.SavePassword;
                                saveProfiles = _connectionProfile.SavePassword;
                            }
                        }
                    }

                    try
                    {
                        Cursor.Current = Cursors.WaitCursor;

                        string macAddresses = _connectionProfile.ServerSettings.WakeOnLan.MacAddresses;
                        string ipAddress    = _connectionProfile.ServerSettings.WakeOnLan.IPAddress;

                        if (!Proxies.Initialize(_connectionProfile.ServerSettings, false))
                        {
                            Program.App.HideSplash();
                            result = ConnectWithForm();
                        }
                        else
                        {
                            if (saveProfiles ||
                                !String.Equals(macAddresses, _connectionProfile.ServerSettings.WakeOnLan.MacAddresses) ||
                                !String.Equals(ipAddress, _connectionProfile.ServerSettings.WakeOnLan.IPAddress))
                            {
                                ConnectionProfiles.Save();
                            }
                            RefreshFormTitle();
                            result = true;
                        }
                    }
                    finally
                    {
                        Cursor.Current = Cursors.Default;
                    }
                }
                else
                {
                    if (!reconnect)
                    {
                        Program.App.HideSplash();
                    }
                    result = ConnectWithForm();
                }
            }

            if (result &&
                Properties.Settings.Default.LastUsedConnectionProfile != _connectionProfile.Name)
            {
                Properties.Settings.Default.LastUsedConnectionProfile = _connectionProfile.Name;
                Properties.Settings.Default.Save();
            }

            return(result);
        }
Exemple #4
0
        public bool ConnectToArgusTVService(string currentProfileName, bool reconnect)
        {
            bool result = false;
            bool abortConnection = false;
            bool tryConnectionWithoutUI = !reconnect;
            bool skipSelectionForm = false;

            IList<ConnectionProfile> profiles = ConnectionProfiles.GetList();
            if (!reconnect
                && !String.IsNullOrEmpty(currentProfileName))
            {
                _connectionProfile = FindConnectionProfileByName(profiles, currentProfileName);
                skipSelectionForm = (_connectionProfile != null);
            }

            if (_connectionProfile != null)
            {
                currentProfileName = _connectionProfile.Name;
            }
            else
            {
                currentProfileName = Properties.Settings.Default.LastUsedConnectionProfile;
            }

            if (profiles.Count == 1)
            {
                _connectionProfile = profiles[0];
            }
            else if (profiles.Count > 1
                && !skipSelectionForm)
            {
                if (!reconnect)
                {
                    Program.App.HideSplash();
                }
                SelectProfileForm selectProfileForm = new SelectProfileForm();
                selectProfileForm.SetSelectedProfileName(currentProfileName);
                if (selectProfileForm.ShowDialog(this) == DialogResult.OK)
                {
                    _connectionProfile = selectProfileForm.SelectedProfile;
                    if (_connectionProfile != null)
                    {
                        tryConnectionWithoutUI = !selectProfileForm.EditSelectedProfile;
                        if (tryConnectionWithoutUI
                            && !reconnect)
                        {
                            Program.App.ShowSplash();
                        }
                    }
                }
                else
                {
                    result = false;
                    abortConnection = true;
                }
            }

            if (!abortConnection)
            {
                if (tryConnectionWithoutUI
                    && _connectionProfile != null)
                {
                    bool saveProfiles = false;

                    if (_connectionProfile.ServerSettings.Transport == ServiceProxy.ServiceTransport.Https
                        && String.IsNullOrEmpty(_connectionProfile.ServerSettings.Password))
                    {
                        using (LogonForm logonForm = new LogonForm())
                        {
                            logonForm.UserName = _connectionProfile.ServerSettings.UserName;
                            Program.App.HideSplash();
                            if (DialogResult.OK == logonForm.ShowDialog(this))
                            {
                                _connectionProfile.ServerSettings.UserName = logonForm.UserName;
                                _connectionProfile.ServerSettings.Password = logonForm.Password;
                                _connectionProfile.SavePassword = logonForm.SavePassword;
                                saveProfiles = _connectionProfile.SavePassword;
                            }
                        }
                    }

                    try
                    {
                        Cursor.Current = Cursors.WaitCursor;

                        string macAddresses = _connectionProfile.ServerSettings.WakeOnLan.MacAddresses;
                        string ipAddress = _connectionProfile.ServerSettings.WakeOnLan.IPAddress;

                        if (!Proxies.Initialize(_connectionProfile.ServerSettings, false))
                        {
                            Program.App.HideSplash();
                            result = ConnectWithForm();
                        }
                        else
                        {
                            if (saveProfiles
                                || !String.Equals(macAddresses, _connectionProfile.ServerSettings.WakeOnLan.MacAddresses)
                                || !String.Equals(ipAddress, _connectionProfile.ServerSettings.WakeOnLan.IPAddress))
                            {
                                ConnectionProfiles.Save();
                            }
                            RefreshFormTitle();
                            result = true;
                        }
                    }
                    finally
                    {
                        Cursor.Current = Cursors.Default;
                    }
                }
                else
                {
                    if (!reconnect)
                    {
                        Program.App.HideSplash();
                    }
                    result = ConnectWithForm();
                }
            }

            if (result
                && Properties.Settings.Default.LastUsedConnectionProfile != _connectionProfile.Name)
            {
                Properties.Settings.Default.LastUsedConnectionProfile = _connectionProfile.Name;
                Properties.Settings.Default.Save();
            }

            return result;
        }