public WindowMain() { InitializeComponent(); fAppSettings = new AppSettings(); fLastScanned = PageTypeEnum.Letter; fScanner = new Scanner(); fPrinter = new Printer(); fPdfExporter = new PdfExporter(); fPdfImporter = new PdfImporter(); fImageLoader = new ImageLoader(); fImageSaver = new ImageSaver(); fDocument = new Document(); fDocument.OnPageAdded += fDocument_OnPageAdded; fDocument.OnPageRemoved += fDocument_OnPageRemoved; fDocument.OnPageUpdated += fDocument_OnPageUpdated; fDocument.OnPageMoved += fDocument_OnPageMoved; fInsertionMark = new InsertionMark(); fDragStartItem = null; fScrollTimer = new System.Timers.Timer(150); fScrollTimer.Elapsed += fScrollTimer_Elapsed; fScrollTimer.AutoReset = false; this.KeyUp += WindowMain_KeyUp; fClosing = false; fDeleting = false; }
public PageTypeEnum MatchURL(string urlstring) { if (string.IsNullOrEmpty(urlstring) || _urlCharacters == null) { return(PageTypeEnum.NONE); } float value = 0; PageTypeEnum pagetype = PageTypeEnum.NONE; foreach (var urlcharacter in _urlCharacters) { float temp = ParserUtil.GetMatchingValueByCharacters(urlstring, urlcharacter.Value); if (temp > value) { value = temp; pagetype = urlcharacter.Key; } if (temp == 1) { return(pagetype); } } return(pagetype); }
public static OutputViewModel CreatePageTypeOutputViewModel(PageTypeEnum pageType, string priority, string description, List <PageLinkModel> links, string title) { if (priority == null) { throw new ArgumentNullException("priority"); } if (description == null) { throw new ArgumentNullException("description"); } if (title == null) { throw new ArgumentNullException("title"); } var model = new OutputViewModel(true) { JumboTitle = title, PageTitle = title, Action = pageType, MetaDescription = description.SeoMetaDescriptionTruncate(), ArticleDescription = description, Filename = pageType.ToString(), Priority = priority, PageLinks = links, Total = links != null?links.Count() : 0 }; return(model); }
public OutputViewModel PreparePageTypeModel(PageTypeEnum pageType, string priority, string description, List <PageLinkModel> links, string title) { if (priority == null) { throw new ArgumentNullException("priority"); } if (description == null) { throw new ArgumentNullException("description"); } if (links == null) { throw new ArgumentNullException("links"); } if (title == null) { title = pageType.ToString().CamelCaseToWords(); } var model = OutputViewModel.CreatePageTypeOutputViewModel(pageType, priority, description, links, title); return(model); }
public static bool IsGeo(this PageTypeEnum pageTypeEnum) { var isGeo = pageTypeEnum == PageTypeEnum.Country || pageTypeEnum == PageTypeEnum.Region || pageTypeEnum == PageTypeEnum.Authority || pageTypeEnum == PageTypeEnum.Locality || pageTypeEnum == PageTypeEnum.Pub; return(isGeo); }
public void CreatePageTypeFile(PageTypeEnum pageType, string priority, string description, List <PageLinkModel> links = null, string title = null) { if (links == null) { links = new List <PageLinkModel>(); } var model = _queryManager.PreparePageTypeModel(pageType, priority, description, links, title); var pathOverride = string.Format("{0}{1}", _currentRoot, "uk\\"); FileSystemHelper.CreateFolders(pathOverride, false); WriteFile(model, pathOverride); }
public void CreatePageTypeFile(PageTypeEnum pageType, string priority, string description, List<PageLinkModel> links = null, string title = null) { if (links == null) { links = new List<PageLinkModel>(); } var model = _queryManager.PreparePageTypeModel(pageType, priority, description, links, title); var pathOverride = string.Format("{0}{1}", _currentRoot, "uk\\"); FileSystemHelper.CreateFolders(pathOverride, false); WriteFile(model, pathOverride); }
public void InjectHtmlRule(PageTypeEnum page, params string[] rules) { if (_htmlCharacters == null) { _htmlCharacters = new Dictionary <PageTypeEnum, List <string> >(); } if (!_htmlCharacters.ContainsKey(page)) { _htmlCharacters[page] = new List <string>(); } foreach (string rule in rules) { if (_htmlCharacters[page].IndexOf(rule) == -1) { _htmlCharacters[page].Add(rule); } } }
public PageTypeEnum MatchHtml(string htmlstring) { if (_htmlCharacters == null) { return(PageTypeEnum.NONE); } float value = 0; PageTypeEnum pagetype = PageTypeEnum.NONE; foreach (var htmlcharacter in _htmlCharacters) { float temp = ParserUtil.GetMatchingValueByCharacters(htmlstring, htmlcharacter.Value); if (temp > value) { value = temp; pagetype = htmlcharacter.Key; } } return(pagetype); }
/************************************/ public virtual void Load(bool isUTF8, int bookId = 0) { Regex reg = new Regex(@"POST:\[(.+?)\]"); Match m = reg.Match(InternalUrl); if (m.Success) { SetPostBody(reg.Replace(m.Value, "$1")); } InternalRealUrl = getRealUrl(InternalUrl); if (string.IsNullOrEmpty(InternalRealUrl)) { throw new Exception("没有初始化Url设置"); } if (UrlLoader == null) { UrlLoader = new URLLoader(); } string result = string.Empty; Log.ShowLine("请求:" + InternalRealUrl, ConsoleColor.DarkGray); if (isUTF8) { result = UrlLoader.RequestByUTF8(InternalRealUrl); } else { result = UrlLoader.RequestByGBK(InternalRealUrl); } if (!string.IsNullOrEmpty(result)) { if (PageType == PageTypeEnum.NONE) { PageType = PageFeature.MatchHtml(result); } if (PluginGeneral.DEBUG_MODE) { parseHtmlString(result, bookId); } else { try { parseHtmlString(result, bookId); } catch (Exception exp) { FinalData = null; Log.ShowLine(exp, ConsoleColor.Red); _logger.FatalFormat("访问网页:{0}。出错{1}。返回内容为空", InternalRealUrl, exp.Message); } } } else { FinalData = null; Log.ShowLine(InternalRealUrl + " 错误~!", ConsoleColor.Red); _logger.FatalFormat("访问网页:{0}。出错。返回内容为空", InternalRealUrl); } }
private void Scan(PageTypeEnum pageType) { ScanSettings settings = new ScanSettings(); SizeInches size; switch(pageType) { case PageTypeEnum.Letter: { size = SizeInches.Letter; } break; case PageTypeEnum.Legal: { size = SizeInches.Legal; } break; default: case PageTypeEnum.Custom: { size = new SizeInches(fAppSettings.ScannerCustomPageSize.Width, fAppSettings.ScannerCustomPageSize.Height); } break; } settings.ScanArea = new BoundsInches(0, 0, size); settings.EnableFeeder = fAppSettings.ScannerEnableFeeder; settings.ColorMode = fAppSettings.ScannerColorMode; settings.Resolution = fAppSettings.ScannerResolution; settings.Threshold = fAppSettings.ScannerThreshold; settings.Brightness = fAppSettings.ScannerBrightness; settings.Contrast = fAppSettings.ScannerContrast; settings.ShowSettingsUI = fAppSettings.ScannerUseNativeUI; settings.ShowTransferUI = true; fScanner.Acquire(fDocument, settings, fScanner_AcquireCallback); if(fLastScanned != pageType) { fLastScanned = pageType; RefreshButtonScanLabel(); } }
public OutputViewModel PreparePageTypeModel(PageTypeEnum pageType, string priority, string description, List<PageLinkModel> links, string title) { if (priority == null) throw new ArgumentNullException("priority"); if (description == null) throw new ArgumentNullException("description"); if (links == null) throw new ArgumentNullException("links"); if (title == null) { title = pageType.ToString().CamelCaseToWords(); } var model = OutputViewModel.CreatePageTypeOutputViewModel(pageType, priority, description, links, title); return model; }
private void Scan(PageTypeEnum pageType, double resolution) { if(RefreshScannerActiveDataSource()) { ScanSettings settings = new ScanSettings(); settings.EnableFeeder = true; settings.ColorMode = ColorModeEnum.RGB; settings.PageType = pageType; settings.Resolution = (int)resolution; settings.Threshold = 0.75; settings.Brightness = 0.5; settings.Contrast = 0.5; if(fScanner.Acquire(fDocument, settings, fAppSettings.UseScannerNativeUI, true) == false) { UtilDialogs.ShowError("Scanner failed to start"); } RefreshControls(); } }
public static OutputViewModel CreatePageTypeOutputViewModel(PageTypeEnum pageType, string priority, string description, List<PageLinkModel> links, string title) { if (priority == null) throw new ArgumentNullException("priority"); if (description == null) throw new ArgumentNullException("description"); if (title == null) throw new ArgumentNullException("title"); var model = new OutputViewModel(true) { JumboTitle = title, PageTitle = title, Action = pageType, MetaDescription = description.SeoMetaDescriptionTruncate(), ArticleDescription = description, Filename = pageType.ToString(), Priority = priority, PageLinks = links, Total = links != null ? links.Count() : 0 }; return model; }
public static OutputViewModel CreateOrgOutputViewModel( Org org, PageLinkModel next, String descriptionPattern ) { if (org == null) { throw new ArgumentNullException("org"); } if (next == null) { throw new ArgumentNullException("next"); } //var notes = org.Notes.Select(note => new PageLinkModel //{ // Id = note.Id, // Text = note.Text, // Title = note.Text //}).ToList(); const PageTypeEnum action = PageTypeEnum.Pub; var lineage = new Breadcrumb { Region = new PageLinkModel { Filename = org.Authority.ParentAuthority.CleanQualifiedName, Id = org.Id, Text = org.Authority.ParentAuthority.Name, Title = org.Authority.ParentAuthority.Name, Total = org.Authority.ParentAuthority.HauntedPubCount }, Authority = new PageLinkModel { Filename = org.Authority.CleanQualifiedName, Id = org.Id, Text = org.Authority.Name, Title = org.Authority.Name, Total = org.Authority.HauntedPubCount }, Locality = new PageLinkModel { Filename = org.QualifiedLocalityDashified .Clean(), Id = org.Id, Text = org.Locality, Title = org.Locality }, Organisation = new PageLinkModel { Filename = org.Filename, Id = org.Id, Text = org.TradingName, Title = org.TradingName } }; var adjusted = new Breadcrumb(); if (org.IsOutsideUnitedKingdom) { lineage = adjusted.Swap(lineage); } var model = new OutputViewModel { IsMapAvailable = !org.IsOutsideUnitedKingdom, Filename = org.Filename, JumboTitle = org.JumboTitle, PageTitle = org.Title, Action = action, PageLinks = new List <PageLinkModel>(), MetaDescription = org.SeoDescription, Description = org.Description, ArticleDescription = string.Format(descriptionPattern, org.Address, org.PostcodePrimaryPart), Tags = org.Sections, Priority = PageTypePriority.Pub, Next = next, Lat = org.Lat.ToString(), Lon = org.Lon.ToString(), OtherNames = org.Authority.Orgs .Where(o => o.Address == org.Address && o.Postcode == org.Postcode && o.Id != org.Id) .Select( o => new PageLinkModel { Id = o.Id, Text = o.TradingName, Title = o.TradingName, Filename = o.Filename } ).ToList(), Lineage = lineage }; return(model); }