예제 #1
0
        /// <summary>
        /// Called on loading an AddInPackage.
        /// </summary>
        /// <param name="serviceProvider">IServiceProvider</param>
        public void Load(IServiceProvider serviceProvider)
        {
            string path          = GetConfigLocation();
            string blackListFile = Path.Combine(path, "ads.blacklist.txt");
            string whiteListFile = Path.Combine(path, "ads.whitelist.txt");

            if (File.Exists(blackListFile))
            {
                using (Stream s = File.OpenRead(blackListFile)) {
                    using (StreamReader r = new StreamReader(s, Encoding.UTF8)) {
                        BlackWhiteListFactory.AddBlacklist(new UserAdsBlacklist(), ParseContent(r));
                    }
                }
            }

            if (File.Exists(whiteListFile))
            {
                using (Stream s = File.OpenRead(whiteListFile)) {
                    using (StreamReader r = new StreamReader(s, Encoding.UTF8)) {
                        BlackWhiteListFactory.AddWhitelist(new UserAdsWhitelist(), ParseContent(r));
                    }
                }
            }

            if (BlackWhiteListFactory.HasBlacklists)
            {
                // register displaying channel processor:
                _app = (ICoreApplication)serviceProvider.GetService(typeof(ICoreApplication));
                _app.RegisterDisplayingNewsChannelProcessor(_adsBlocker);
                //TODO: add menu(s) to manage blocklist, or how the ads are visualized
            }
        }
예제 #2
0
        private void OnFeedSourceNameValidating(object sender, System.ComponentModel.CancelEventArgs e)
        {
            if (txtFeedSourceName.Text.Trim().Length == 0)
            {
                errorProvider.SetError(txtFeedSourceName, SR.ExceptionNoFeedSourceName);
                e.Cancel = true;
            }
            else
            {
                ICoreApplication coreApp = IoC.Resolve <ICoreApplication>();
                if (coreApp.FeedSources.Contains(txtFeedSourceName.Text.Trim()))
                {
                    errorProvider.SetError(txtFeedSourceName, SR.ExceptionDuplicateFeedSourceName
                                           .FormatWith(txtFeedSourceName.Text.Trim()));
                    e.Cancel = true;
                }
            }

            if (!e.Cancel)
            {
                errorProvider.SetError((Control)sender, null);
            }

            btnSubmit.Enabled = !e.Cancel;
        }
예제 #3
0
        /// <summary>
        /// called on every control
        /// </summary>
        /// <param name="sender">Which control is validated?</param>
        /// <param name="e">EventArgs with cancel parameter</param>
        private void OnControlValidating(object sender, System.ComponentModel.CancelEventArgs e)
        {
            if (ReferenceEquals(wizard.SelectedPage, pageSourceName) && sender == textFeedSourceName)
            {
                if (textFeedSourceName.Text.Trim().Length == 0)
                {
                    errorProvider1.SetError(textFeedSourceName, SR.ExceptionNoFeedSourceName);
                    this.pageSourceName.AllowMoveNext = false;
                    this.pageSourceName.AllowCancel   = true;
                    e.Cancel = true;
                }
                else
                {
                    ICoreApplication coreApp = IoC.Resolve <ICoreApplication>();
                    if (coreApp.FeedSources.Contains(textFeedSourceName.Text.Trim()))
                    {
                        errorProvider1.SetError(textFeedSourceName, SR.ExceptionDuplicateFeedSourceName
                                                .FormatWith(textFeedSourceName.Text.Trim()));

                        this.pageSourceName.AllowMoveNext = false;
                        this.pageSourceName.AllowCancel   = true;
                        e.Cancel = true;
                    }
                }
            }
            else if (ReferenceEquals(wizard.SelectedPage, pageFeedCredentials) && sender == textUser)
            {
                textUser.Text = textUser.Text.Trim();
                if (textUser.Text.Trim().Length == 0)
                {
                    errorProvider1.SetError(textUser, SR.ExceptionNoUserName);
                    e.Cancel = true;
                }
            }
            else if (ReferenceEquals(wizard.SelectedPage, pageFeedCredentials) && sender == textPassword)
            {
                textPassword.Text = textPassword.Text.Trim();
                if (textPassword.Text.Trim().Length == 0)
                {
                    errorProvider1.SetError(textPassword, SR.ExceptionNoPassword);
                    e.Cancel = true;
                }
            }

            if (!e.Cancel)
            {
                errorProvider1.SetError((Control)sender, null);

                if (sender == textFeedSourceName)
                {
                    this.pageSourceName.AllowMoveNext = true;
                }

                if (textUser.Text.Length > 0 && textPassword.Text.Length > 0)
                {
                    this.pageFeedCredentials.AllowMoveNext = true;
                }
            }
        }
예제 #4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PodcastOptionsDialog"/> class.
        /// </summary>
        /// <param name="prefs">The prefs.</param>
        /// <param name="coreApp">The core app.</param>
        public PodcastOptionsDialog(RssBanditPreferences prefs, ICoreApplication coreApp) :
            this()
        {
            this.textPodcastFilesExtensions.Text = coreApp.PodcastFileExtensions;
            this.txtCopyPodcastToFolder.Text     = coreApp.PodcastFolder;

            this.chkCopyPodcastToFolder.Checked         = !coreApp.PodcastFolder.Equals(coreApp.EnclosureFolder);
            this.chkCopyPodcastToITunesPlaylist.Checked = prefs.AddPodcasts2ITunes;
            this.chkCopyPodcastToWMPlaylist.Checked     = prefs.AddPodcasts2WMP;

            this.textSinglePlaylistName.Text       = prefs.SinglePlaylistName;
            this.optFeedNameAsPlaylistName.Checked = !prefs.SinglePodcastPlaylist;
            this.optSinglePlaylistName.Checked     = prefs.SinglePodcastPlaylist;
        }
예제 #5
0
        private void DoSubscribe()
        {
            if (listOfGroups.SelectedItems.Count > 0)
            {
                ListViewItem         lv = listOfGroups.SelectedItems[0];
                NntpServerDefinition sd = GetSelectedNntpServerDefinition();
                if (sd != null)
                {
                    ICoreApplication coreApp = IoC.Resolve <ICoreApplication>();

                    if (coreApp != null)
                    {
                        if (coreApp.SubscribeToFeed(
                                IdentityNewsServerManager.BuildNntpRequestUri(sd, lv.Text).ToString(),
                                null, lv.Text))
                        {
                            //TODO set icon
                        }
                    }
                }
            }
        }
예제 #6
0
 /// <summary>
 /// Constructor
 /// 构造函数
 /// </summary>
 /// <param name="app">Application</param>
 /// <param name="repo">Repository</param>
 /// <param name="logger">Logger</param>
 public ServiceBase(ICoreApplication <C> app, R repo, ILogger logger)
 {
     App    = app;
     Repo   = repo;
     Logger = logger;
 }
예제 #7
0
 protected EntityRepo(ICoreApplication <C> app, string flag, IServiceUser?user = null) : base(app, flag, user)
 {
 }
예제 #8
0
 public IntEntityRepository(ICoreApplication <SqlConnection> app, string flag) : base(app, flag, null)
 {
 }
예제 #9
0
 /// <summary>
 /// Constructor
 /// 构造函数
 /// </summary>
 /// <param name="app">Application</param>
 /// <param name="flag">Flag</param>
 /// <param name="user">Current user</param>
 protected RepoBase(ICoreApplication <C> app, string flag, IServiceUser?user = null) => (App, Flag, User) = (app, flag, user);
예제 #10
0
 public ServiceTest(ICoreApplication <SqlConnection> app, IntEntityRepository repo, ILogger logger) : base(app, repo, logger)
 {
 }
예제 #11
0
 public RepositoryBaseTest(ICoreApplication <SqliteConnection> app) : base(app, "test")
 {
 }
예제 #12
0
 /// <summary>
 /// Constructor
 /// 构造函数
 /// </summary>
 /// <param name="app">App</param>
 /// <param name="user">User</param>
 /// <param name="repo">Repository</param>
 /// <param name="logger">Logger</param>
 public EntityServiceBase(ICoreApplication <C> app, IServiceUser user, R repo, ILogger logger) : base(app, user, repo, logger)
 {
 }
예제 #13
0
 /// <summary>
 /// Constructor
 /// 构造函数
 /// </summary>
 /// <param name="app">Application</param>
 /// <param name="user">Current user</param>
 /// <param name="repo">Repository</param>
 /// <param name="logger">Logger</param>
 public LoginedServiceBase(ICoreApplication <C> app, IServiceUser user, R repo, ILogger logger) : base(app, repo, logger)
 {
     User = user;
 }
예제 #14
0
        public void Run(ICoreApplication application, IServicesProvider servicesProvider = null)
        {
            FormsApplication.SetHighDpiMode(HighDpiMode.SystemAware);
            FormsApplication.SetCompatibleTextRenderingDefault(false);

            Sequence.CreateSequenceFunc = SequenceImpl.Create;
            Sequence.NextFrameSequence  = SequenceImpl.Create(0, 0, null, null);

            dispatcher.DispatcherThread = Thread.CurrentThread;

            using (var graphics = System.Drawing.Graphics.FromHwnd(IntPtr.Zero))
            {
                UiUnit.PixelsPerUnit = graphics.DpiX / 96f;
            }

            var scopeBuilder = new ScopeBuilder(servicesProvider);

            scopeBuilder.WithSkia()
            .WithInstance(gamePads).As <IGamePads>()
            .WithInstance(keyboard).As <IKeyboard>()
            .WithType <UiInput>().As <IUiInput>().AsSingleton()
            .WithCrossTypes()
            .WithInstance(dispatcher).As <ISystemDispatcher>().As <IDispatcher>()
            .WithInstance(sequencer).As <ISequencer>()
            .WithType <SelectFileServiceWinForms>().As <ISelectFileService>().AsSingleton();


            var services = scopeBuilder.Build();

            application.AfterInitServices += (s, b) =>
            {
                b.WithType <WindowServiceWinForms>().AsSelf().As <IWindowsService>().AsSingleton()
                .WithType <AppColorTable>().AsSelf().AsSingleton();
            };

            services = application.Initialize(services);
            application.Load();

            var windowsService = services.GetService <WindowServiceWinForms>();

            var stopwatch = new Stopwatch();

            stopwatch.Start();

            TimeSpan lastUpdateTimeSpan = stopwatch.Elapsed;

            while (windowsService.MainWindow != null)
            {
                TimeSpan currentTimeSpan = stopwatch.Elapsed;
                TimeSpan timeDelta       = currentTimeSpan - lastUpdateTimeSpan;
                lastUpdateTimeSpan = currentTimeSpan;

                gamePads.Update();
                keyboard.Update();
                dispatcher.Process();
                sequencer.Update(timeDelta);

                for (var idx = 0; idx < windowsService.Windows.Count; ++idx)
                {
                    var hostWindow = windowsService.Windows[idx];

                    hostWindow.Window.Update((float)timeDelta.TotalSeconds);
                    if (hostWindow.Window.IsDirty)
                    {
                        hostWindow.Redraw();
                    }
                }

                FormsApplication.DoEvents();
                Thread.Sleep(1);
            }

            foreach (var wnd in windowsService.Windows)
            {
                wnd.Window.Close();
            }
        }
예제 #15
0
 public new void Dispose()
 {
     // cleanup resorces
     _app = null;
 }