Пример #1
0
        private void Configuration_Load(object sender, EventArgs e)
        {
            toolTip1.SetToolTip(txtDBInstance, "Specifiy the database instance used");
            toolTip1.SetToolTip(txtServerName, "Machine name or IP address where the My Movies database resides");
            toolTip1.SetToolTip(txtUserName, "Leave blank to use trusted connection");
            toolTip1.SetToolTip(txtPassword, "Leave blank to use trusted connection");

            try
            {
                using (MediaPortal.Profile.Settings xmlreader = new MediaPortal.Profile.Settings(Config.GetFile(Config.Dir.Config, "MediaPortal.xml")))
                {
                    DriveReplacements pathReplacements;

                    txtProgramDataPath.Text         = xmlreader.GetValueAsString("MyMovies", "txtProgramDataPath", @"C:\ProgramData\My Movies");
                    txtServerName.Text              = xmlreader.GetValueAsString("MyMovies", "txtServerName", "localhost");
                    txtDBInstance.Text              = xmlreader.GetValueAsString("MyMovies", "txtDBInstance", "MYMOVIES");
                    txtUserName.Text                = xmlreader.GetValueAsString("MyMovies", "txtUserName", string.Empty);
                    txtPassword.Text                = xmlreader.GetValueAsString("MyMovies", "txtPassword", string.Empty);
                    txtPINCode.Text                 = xmlreader.GetValueAsString("MyMovies", "txtPINCode", "4321");
                    chkEnableRemoteWakeup.Checked   = xmlreader.GetValueAsBool("MyMovies", "chkRemoteWakeup", false);

                    string xml = xmlreader.GetValueAsString("MyMovies", "xmlPathReplacement", string.Empty);
                    pathReplacements = new DriveReplacements(xml);
                    LoadGrid(pathReplacements);

                    Users users = new Users(xmlreader.GetValueAsString("MyMovies", "xmlUsers", string.Empty));
                    foreach (string user in users.Collection)
                    {
                        gridUsers.Rows.Add(new string[] { user });
                    }

                    MacAddress macAddress = MacAddress.Parse(xmlreader.GetValueAsString("MyMovies", "MACAddress", "00-00-00-00-00-00"));
                    numUDMac1.Value = macAddress[0];
                    numUDMac2.Value = macAddress[1];
                    numUDMac3.Value = macAddress[2];
                    numUDMac4.Value = macAddress[3];
                    numUDMac5.Value = macAddress[4];
                    numUDMac6.Value = macAddress[5];

                    IPAddress ipAddress = IPAddress.Parse(xmlreader.GetValueAsString("MyMovies", "IPAddress", "0.0.0.0"));
                    numUDIP1.Value = ipAddress.GetAddressBytes()[0];
                    numUDIP2.Value = ipAddress.GetAddressBytes()[1];
                    numUDIP3.Value = ipAddress.GetAddressBytes()[2];
                    numUDIP4.Value = ipAddress.GetAddressBytes()[3];

                    numRetries.Value = xmlreader.GetValueAsInt("MyMovies", "wakeupRetries", 3);
                    numRetryTimeout.Value = xmlreader.GetValueAsInt("MyMovies", "wakeupRetryTimeout", 3000);

                    numMaxRating.Value = xmlreader.GetValueAsInt("MyMovies", "maximumViewableRating", 4);

                }
            }
            catch (Exception ex)
            {
                Log.Error("MyMovies::Init - Cannot load settings");
                Log.Error(ex);
            }
        }
Пример #2
0
        public override bool Init()
        {
            bool result = Load(GUIGraphicsContext.Skin + @"\MyMovies.xml");

            try
            {
                using (MediaPortal.Profile.Settings xmlreader = new MediaPortal.Profile.Settings(Config.GetFile(Config.Dir.Config, "MediaPortal.xml")))
                {
                    _currentLayout      = (LayoutOptions)xmlreader.GetValueAsInt("MyMovies", "layout", (int)LayoutOptions.List);
                    _currentView        = (Views)xmlreader.GetValueAsInt("MyMovies", "view", (int)_currentView);
                    _currentSorting     = (Sorting.Options)xmlreader.GetValueAsInt("MyMovies", "sorting", (int)_currentSorting);
                    CurrentUser         = xmlreader.GetValueAsInt("MyMovies", "currentUser", CurrentUser);
                    _sortAscending      = xmlreader.GetValueAsBool("MyMovies", "sortDirection", _sortAscending);
                    _programDataPath    = xmlreader.GetValueAsString("MyMovies", "txtProgramDataPath", @"C:\ProgramData\My Movies\FileStorage");
                    _serverName         = xmlreader.GetValueAsString("MyMovies", "txtServerName", "localhost");
                    _dbInstance         = xmlreader.GetValueAsString("MyMovies", "txtDBInstance", "MYMOVIES");
                    _userName           = xmlreader.GetValueAsString("MyMovies", "txtUserName", string.Empty);
                    _password           = xmlreader.GetValueAsString("MyMovies", "txtPassword", string.Empty);
                    _storedPIN          = xmlreader.GetValueAsString("MyMovies", "txtPINCode", "4321");
                    _chkRemoteWakeup    = xmlreader.GetValueAsBool("MyMovies", "chkRemoteWakeup", false);
                    _macAddress         = MacAddress.Parse(xmlreader.GetValueAsString("MyMovies", "MACAddress", "00-00-00-00-00-00"));
                    _ipAddress          = IPAddress.Parse(xmlreader.GetValueAsString("MyMovies", "IPAddress", "0.0.0.0"));
                    _wakeupRetries      = xmlreader.GetValueAsInt("MyMovies", "wakeupRetries", 3);
                    _wakeupRetryTimeout = xmlreader.GetValueAsInt("MyMovies", "wakeupRetryTimeout", 3000);
                    _maxConfiguredRating= xmlreader.GetValueAsInt("MyMovies", "maximumViewableRating", 4);

                    string xml = xmlreader.GetValueAsString("MyMovies", "xmlPathReplacement", string.Empty);
                    _driveReplacements  = new DriveReplacements(xml);

                    string xmlUsers = xmlreader.GetValueAsString("MyMovies", "xmlUsers", string.Empty);
                    _availableUsers = new Users(xmlUsers);
                }

                Log.Info(string.Format("MyMovies::Init - RemoteWakeup {0}, MAC {1}, IP {2}", _chkRemoteWakeup, _macAddress, _ipAddress));
            }
            catch (Exception ex)
            {
                Log.Error("MyMovies::Init - Cannot load settings");
                Log.Error(ex);
            }

            // Determine the maximum assigned rating within the DB.
            _maxRating = GetMaximumRating();

            g_Player.PlayBackStopped += new g_Player.StoppedHandler(OnPlayBackStopped);
            g_Player.PlayBackChanged += new g_Player.ChangedHandler(OnPlayBackChanged);
            g_Player.PlayBackEnded += new g_Player.EndedHandler(OnPlayBackEnded);

            return result;
        }