Ejemplo n.º 1
0
 private void _okButton_Click(object sender, EventArgs e)
 {
     _selectedProfile = null;
     if (_profilesDataGridView.SelectedRows.Count > 0)
     {
         ConnectionProfile profile = _profilesDataGridView.SelectedRows[0].DataBoundItem as ConnectionProfile;
         if (profile.ServerSettings != null)
         {
             _selectedProfile = profile;
         }
     }
     this.DialogResult = DialogResult.OK;
     this.Close();
 }
Ejemplo n.º 2
0
 public static void Add(ConnectionProfile profile)
 {
     Instance.InternalAdd(profile);
 }
Ejemplo n.º 3
0
 private void InternalAdd(ConnectionProfile profile)
 {
     _profiles[profile.Name] = profile;
     SaveProfiles();
 }
Ejemplo n.º 4
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            try
            {
                if (Properties.Settings.Default.ConsoleWindowPosition != Point.Empty
                    || Properties.Settings.Default.ConsoleWindowSize != Size.Empty)
                {
                    Point consolePosition = Properties.Settings.Default.ConsoleWindowPosition;
                    Size consoleWindowSize = Properties.Settings.Default.ConsoleWindowSize;

                    // Leave defaults, when screenresolution was changed to a lower resolution
                    if (consolePosition.X < Screen.PrimaryScreen.Bounds.Width - 50 &&
                        consolePosition.Y < Screen.PrimaryScreen.Bounds.Height - 50 &&
                        consoleWindowSize.Height < Screen.PrimaryScreen.Bounds.Size.Height &&
                        consoleWindowSize.Width < Screen.PrimaryScreen.Bounds.Size.Width)
                    {
                        this.Location = consolePosition;
                        this.Size = consoleWindowSize;
                    }
                }

                SetMenuMode(MainMenuMode.Normal);

                // Add some default plugin services.
                // Could put these in a config file later on perhaps...?
                _pluginServiceSettings.Add(new PluginServiceSetting("ARGUS", "ARGUS TV Recorder", 49953));
                _pluginServiceSettings.Add(new PluginServiceSetting("TVE", "MediaPortal TV Server", 49842));
#if DEBUG
                _pluginServiceSettings.Add(new PluginServiceSetting("Test", "Test", 49840));
#endif
                _pluginServiceSettings.Add(new PluginServiceSetting("Other", "Other", 0));

                _baseFormTitle = this.Text + " " + Constants.ProductVersion;
                _formTitle = _baseFormTitle;
                this.Text = _baseFormTitle;

                _connectionProfile = null;
                if (!ConnectToArgusTVService(this.CommandLineArgs.Count == 1 ? this.CommandLineArgs[0] : null, false))
                {
                    this.Close();
                }
                else
                {
                    if (DateTime.Now >= Properties.Settings.Default.NextVersionCheck)
                    {
                        NewVersionInfo versionInfo = Proxies.CoreService.IsNewerVersionAvailable().Result;
                        if (versionInfo != null)
                        {
                            Program.App.HideSplash();
                            if (!this.IsDisposed)
                            {
                                if (MessageBox.Show(this, versionInfo.Name + " is available for download." + Environment.NewLine + Environment.NewLine
                                    + "Would you like to see what's new?", "New version", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.Yes)
                                {
                                    System.Diagnostics.Process.Start(new ProcessStartInfo(versionInfo.Url));
                                }
                                Properties.Settings.Default.NextVersionCheck = DateTime.Now.AddDays(7);
                                Properties.Settings.Default.Save();
                            }
                        }
                    }
                }

                _tvGuideLinkLabel_LinkClicked(this, null);
            }
            catch (Exception ex)
            {
                Program.App.HideSplash();
                MessageBox.Show(null, ex.Message, null, MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.Close();
            }
            finally
            {
                Program.App.HideSplash();
            }
        }
Ejemplo n.º 5
0
 private bool ConnectWithForm()
 {
     ConnectForm form = new ConnectForm();
     if (_connectionProfile == null)
     {
         form.ServerSettings = new ServerSettings();
     }
     else
     {
         form.ProfileName = _connectionProfile.Name;
         form.ServerSettings = new ServerSettings()
         {
             ServerName = _connectionProfile.ServerSettings.ServerName,
             Port = ServerSettings.DefaultHttpPort,
             Transport = ServiceTransport.Http
         };
     }
     if (form.ShowDialog(this) == DialogResult.OK)
     {
         _connectionProfile = new ConnectionProfile()
         {
             ServerSettings = form.ServerSettings,
             SavePassword = form.SavePassword
         };
         if (!String.IsNullOrEmpty(form.ProfileName))
         {
             _connectionProfile.Name = form.ProfileName;
             ConnectionProfiles.Add(_connectionProfile);
         }
         RefreshFormTitle();
         return true;
     }
     return false;
 }
Ejemplo n.º 6
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;
        }