Пример #1
0
        [Test] public void SettingArrayTest()
        {
            for (int i = 0; i < 10; ++i)
            {
                IResource setting = Core.ResourceStore.BeginNewResource("Setting");
                setting.EndUpdate();
            }

            IResourceList resources = Core.ResourceStore.GetAllResources("Setting");
            SettingArray  settings  = SettingArray.FromResourceList(resources, _SIZE, 100);

            Assert.AreEqual(false, settings.Defined);
            Assert.AreEqual(100, settings.Value);
            Assert.AreEqual(false, settings.Different);
            for (int i = 0; i < 10; ++i)
            {
                IResource setting = Core.ResourceStore.BeginNewResource("Setting");
                setting.SetProp(_SIZE, i);
                setting.EndUpdate();
            }
            resources = Core.ResourceStore.GetAllResources("Setting");
            settings  = SettingArray.FromResourceList(resources, _SIZE, 100);
            Assert.AreEqual(false, settings.Defined);
            Assert.AreEqual(true, settings.Different);
            settings.Save(333);
            IResourceList list = Core.ResourceStore.FindResources("Setting", _SIZE, 333);

            Assert.AreEqual(20, list.Count);
            resources = Core.ResourceStore.GetAllResources("Setting");
            settings  = SettingArray.FromResourceList(resources, _SIZE, 100);
            Assert.AreEqual(true, settings.Defined);
            Assert.AreEqual(333, settings.Value);
            Assert.AreEqual(false, settings.Different);
        }
Пример #2
0
        private void RefreshSetting()
        {
            IResourceList options = Core.ResourceStore.GetAllResources(DebugOption);

            _boolSetting.SetSetting(SettingArray.FromResourceList(options, BoolDebugSetting, true));
            _intSetting.SetSetting(SettingArray.FromResourceList(options, IntDebugSetting, 100));
            _stringSetting.SetSetting(SettingArray.FromResourceList(options, StringDebugSetting, "qwerty", false));
            _stringSettingDef.SetSetting(SettingArray.FromResourceList(options, StringDebugSettingDef, "Default String", false));
            _cmbIntSetting.SetData(new object[] { 0, 1, 2 }, new object[] { "00", "11", "22" });
            _cmbIntSetting.SetSetting(SettingArray.FromResourceList(options, IntComboDebugSetting, 0));
            _radioSetting.Text = "Radio Button Setting";
            _radioSetting.SetData(new object[] { 7, 8, 9 }, new object[] { "this is 77", "this is 88", "very long description for radio button" });
            _radioSetting.SetSetting(SettingArray.FromResourceList(options, IntRadioDebugSetting, 99));
        }
Пример #3
0
        [Test] public void BoolSettingArrayTest()
        {
            IResource setting = Core.ResourceStore.BeginNewResource("Setting");

            setting.EndUpdate();
            setting = Core.ResourceStore.BeginNewResource("Setting");
            setting.SetProp(_BOOL, true);
            setting.EndUpdate();

            IResourceList resources = Core.ResourceStore.GetAllResources("Setting");
            SettingArray  settings  = SettingArray.FromResourceList(resources, _BOOL, true);

            Assert.AreEqual(true, settings.Defined);
            Assert.AreEqual(true, settings.Different);
            settings.Save(true);

            resources = Core.ResourceStore.GetAllResources("Setting");
            settings  = SettingArray.FromResourceList(resources, _BOOL, true);
            settings.Load();
            Assert.AreEqual(true, settings.Defined);
            Assert.AreEqual(true, settings.Value);
            Assert.AreEqual(false, settings.Different);
        }
Пример #4
0
        public void DisplayRSSFeeds(IResourceList feeds)
        {
            Guard.NullArgument(feeds, "feeds");
            if (feeds.Count == 0)
            {
                throw new ArgumentException("feeds should have at least one feed");
            }
            RestoreSettings();
            _feeds             = feeds;
            _feed              = feeds[0];
            _selector.Resource = feeds[0];

            SettingArray enclosurePath = SettingArray.FromResourceList(_feeds, Props.EnclosurePath, Settings.EnclosurePath, true);

            _browseForFolderControl.SetSetting(enclosurePath);
            _cmbUpdatePeriod.SetSetting(SettingArray.FromResourceList(_feeds, Props.UpdatePeriod, "daily", true));
            _udUpdateFrequency.SetSetting(SettingArray.FromResourceList(_feeds, Props.UpdateFrequency, Settings.UpdateFrequency));

            if (!_udUpdateFrequency.Setting.Defined || _udUpdateFrequency.Setting.Value == null || (int)_udUpdateFrequency.Setting.Value == -1)
            {
                _chkUpdate.Checked       = false;
                _udUpdateFrequency.Value = Settings.UpdateFrequency;
            }

            _edtUserName.SetSetting(SettingArray.FromResourceList(_feeds, Props.HttpUserName, null, true));
            _edtPassword.SetSetting(SettingArray.FromResourceList(_feeds, Props.HttpPassword, null, true));

            if (_edtUserName.Setting.Different || _edtUserName.Setting.Defined ||
                _edtPassword.Setting.Different || _edtPassword.Setting.Defined)
            {
                _chkAuthentication.Checked = true;
            }

            _chkMarkReadOnLeave.SetSetting(SettingArray.FromResourceList(_feeds, Props.MarkReadOnLeave, false));
            _chkAutoFollowLink.SetSetting(SettingArray.FromResourceList(_feeds, Props.AutoFollowLink, false));
            _chkAutoUpdateComments.SetSetting(SettingArray.FromResourceList(_feeds, Props.AutoUpdateComments, false));
            _chkAllowEqualPosts.SetSetting(SettingArray.FromResourceList(_feeds, Props.AllowEqualPosts, false));
            _chkAutoDownloadEncls.SetSetting(SettingArray.FromResourceList(_feeds, Props.AutoDownloadEnclosure, false));

            if (_feeds.Count > 1)
            {
                _edtAddress.Text           = MULTIPLE_SELECTION;
                _edtAddress.ReadOnly       = true;
                _edtTitle.Text             = MULTIPLE_SELECTION;
                _edtTitle.ReadOnly         = true;
                _lblHomepage.Text          = MULTIPLE_SELECTION;
                _lblHomepage.ClickableLink = false;
                _lblAuthor.Text            = MULTIPLE_SELECTION;
                _lblAuthor.ClickableLink   = false;
                _edtDescription.Text       = MULTIPLE_SELECTION;
                _lblLastUpdated.Text       = MULTIPLE_SELECTION;
                _edtAnnotation.Text        = MULTIPLE_SELECTION;
            }
            else
            {
                //  Fix OM-12232 - broken feeds some times return empty string
                //  for an URL. Just ignore such image specifications.
                //  Test feed (for 16.02.06) was http://www.metalfan.ro/forum/rss.php
                if (!_feed.HasProp(Props.ImageContent) && _feed.HasProp(Props.ImageURL) &&
                    !string.IsNullOrEmpty(_feed.GetStringProp(Props.ImageURL)))
                {
                    Core.NetworkAP.QueueJob(JobPriority.AboveNormal,
                                            new DownloadResourceBlobJob(_feed, Props.ImageContent, _feed.GetStringProp(Props.ImageURL),
                                                                        ImageContentDownloaded));
                }
                SetImage();
                InitSingleFeedSelection(_feed);
            }
            UpdateControls();
        }