/// <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 } }
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; }
/// <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; } } }
/// <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; }
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 } } } } }
/// <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; }
protected EntityRepo(ICoreApplication <C> app, string flag, IServiceUser?user = null) : base(app, flag, user) { }
public IntEntityRepository(ICoreApplication <SqlConnection> app, string flag) : base(app, flag, null) { }
/// <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);
public ServiceTest(ICoreApplication <SqlConnection> app, IntEntityRepository repo, ILogger logger) : base(app, repo, logger) { }
public RepositoryBaseTest(ICoreApplication <SqliteConnection> app) : base(app, "test") { }
/// <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) { }
/// <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; }
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(); } }
public new void Dispose() { // cleanup resorces _app = null; }