internal void ProcessRequest(PageRequest request) { var domainSelector = request.ParentDomain == null ? null : new DomainSelector(request.ParentDomain, request.SiteId); AddOrUpdateCounter(_siteCounter, new Site { Id = request.SiteId }, request); if (domainSelector != null) { AddOrUpdateCounter(_domainCounter, domainSelector, request); } if (request.PageId != null) { var page = new Page { Id = request.PageId.Value }; var totalDomainSelector = new DomainSelector(DomainSelector.TotalDomain, request.SiteId); var totalPageSelector = new PageSelector(page, totalDomainSelector); AddOrUpdateCounter(_pageCounter, totalPageSelector, request); if (domainSelector != null) { var pageSelector = new PageSelector(page, domainSelector); AddOrUpdateCounter(_pagePerDomainCounter, pageSelector, request); } } }
/// <summary> /// Initialises a new instance of the <see cref="ReportsViewModel"/> class. /// </summary> /// <param name="dataModel"> /// The model object containing data set. /// </param> /// <param name="logger">the logger</param> public ReportsViewModel( IDataManager dataModel, IAsLogger logger) { this.PageSelector = new List <IPageSelector>(); this.calendarViewModel = new CalendarViewModel( logger, this.OpenEvent); this.eventReportViewModel = new EventReportViewModel( dataModel.FindBeastie); this.CurrentWorkspace = this.calendarViewModel; IPageSelector calendarSelector = new PageSelector( ReportsViewModel.CalendarSelector, this.NewPage); IPageSelector eventSelector = new PageSelector( ReportsViewModel.EventSelector, this.NewPage); this.PageSelector.Add(calendarSelector); this.PageSelector.Add(eventSelector); this.NewPage(ReportsViewModel.CalendarSelector); }
/// <summary> /// Initialises a new instance of the <see cref="Ribbon"/> class. /// </summary> public RibbonViewModel() { this.PageSelector = new List <IPageSelector>(); IPageSelector dataEntry = new PageSelector( "Data Entry", this.DisplayDataEntryView); IPageSelector reports = new PageSelector( "Reports", this.DisplayReportsView); IPageSelector configurationEntry = new PageSelector( "Configuration", this.DisplayConfigurationView); IPageSelector consistencyEntry = new PageSelector( "Consistency", this.DisplayConsistencyView); this.PageSelector.Add(dataEntry); this.PageSelector.Add(reports); this.PageSelector.Add(configurationEntry); this.PageSelector.Add(consistencyEntry); this.DisplayDataEntryView(dataEntry.Name); }
public void PageSelector_Throws_When_Given_Negative_Index() { //Arrange var selector = new PageSelector <int>(list, Constants.PAGE_RecordCount); //Assert Assert.Throws <IndexOutOfRangeException>(() => selector.GetPage(Constants.PAGE_NegativeIndex)); }
private void GatewayReadSecondPage(object val) { PageSelector <Order> ps = gateway.GetPageSelector <Order>(Order._.OrderID > 10, OrderByClip.Default, 100); ps.PageSize = 100; Order[] orders = ps.FindPage(2); orders = null; ps = null; }
private object GatewayReadFirstPage() { PageSelector <Order> ps = gateway.GetPageSelector <Order>(Order._.OrderID > 10, OrderByClip.Default, 100); ps.PageSize = 100; Order[] orders = ps.FindPage(1); orders = null; ps = null; return(null); }
public void PageSelector_Returns_Correct_RecordCount_When_Given_Valid_Index(int pageSize) { //Arrange var selector = new PageSelector<int>(list, pageSize); //Act IPagedList<int> pagedList = selector.GetPage(Constants.PAGE_First); //Assert Assert.AreEqual(pageSize, pagedList.PageSize); }
public void PageSelector_Returns_CorrectPage_When_Given_Valid_Index(int index) { //Arrange var selector = new PageSelector <int>(list, Constants.PAGE_RecordCount); //Act IPagedList <int> pagedList = selector.GetPage(index); //Assert Assert.AreEqual(index, pagedList.PageIndex); }
public void PageSelector_Returns_CorrectPage_When_Given_Valid_Index(int index) { //Arrange var selector = new PageSelector<int>(list, Constants.PAGE_RecordCount); //Act IPagedList<int> pagedList = selector.GetPage(index); //Assert Assert.AreEqual(index, pagedList.PageIndex); }
public void PagingExtensions_InPagesOf_Returns_PageSelector() { //Arrange IQueryable <int> queryable = Util.CreateIntegerList(Constants.PAGE_TotalCount).AsQueryable(); //Act PageSelector <int> pageSelector = queryable.InPagesOf(Constants.PAGE_RecordCount); //Assert Assert.IsInstanceOf <PageSelector <int> >(pageSelector); }
public void PageSelector_Returns_Correct_RecordCount_When_Given_Valid_Index(int pageSize) { //Arrange var selector = new PageSelector <int>(list, pageSize); //Act IPagedList <int> pagedList = selector.GetPage(Constants.PAGE_First); //Assert Assert.AreEqual(pageSize, pagedList.PageSize); }
public void PageSelector_Ctor_Argument_MaxPagesForRandomSelection_Zero() { try { var pg = new PageSelector(new PagesCollectionStub(), new RandomSelector(), null, 0); Assert.Fail("Очікувалося ArgumentException"); } catch (ArgumentException ex) { Assert.IsTrue(ex.ParamName == "maxPagesForRandomSelection"); } }
public void PageSelector_Ctor_Argument_RandomSelector_Null() { try { var pg = new PageSelector(new PagesCollectionStub(), null, null, _MAX_PAGES_FOR_RANDOM); Assert.Fail("Очікувалося ArgumentNullException"); } catch (ArgumentNullException ex) { Assert.IsTrue(ex.ParamName == "randomSelector"); } }
private void Footer_Button_Settings_Tapped(object sender, EventArgs e) { try { PageSelector.SelectPage(3); } catch (Exception ex) { Device.BeginInvokeOnMainThread(async() => { await App.Current.MainPage.DisplayAlert("Exception", ex.Message, "OK"); }); } }
/// <summary> /// Add a new command to the collection of page selector commands. /// </summary> /// <param name="pageName"> /// Name of the page the new command represents. /// </param> private void PopulatePageSelector(string pageName) { if (this.PageSelector == null) { this.PageSelector = new List <IPageSelector>(); } IPageSelector showEventDetails = new PageSelector( pageName, this.NewPage); this.PageSelector.Add(showEventDetails); }
public void PageSelector_Returns_Correct_Values_When_Given_Valid_Index_And_PageSize(int index, int pageSize) { //Arrange var selector = new PageSelector <int>(list, pageSize); //Act IPagedList <int> pagedList = selector.GetPage(index); //Assert for (int i = 0; i < pageSize; i++) { Assert.AreEqual(index * pageSize + i, pagedList[i]); } }
public void PageSelector_Select_NoPagesForResult() { var pages = _PrepareSitePagesEmptyCollection(); //Здесь нам нужен особенный (не рандомный) селектор, который будет давать те индексы которые нужно для граничных условий var rndStub = new RandomSelectorStub { Result = 0 //он будет выдавать индекс 0 для выбора }; var pg = new PageSelector(pages, rndStub, null, _MAX_PAGES_FOR_RANDOM); var resultPage = pg.GetPageForTwitting().Result; Assert.IsNull(resultPage, "Очікувався null"); }
public void PageSelector_Normal_Select_2() { var pages = _PrepareSitePagesCollection(); //Здесь нам нужен особенный (не рандомный) селектор, который будет давать те индексы которые нужно для граничных условий var rndStub = new RandomSelectorStub { Result = 2 //он будет выдавать индекс 0 для выбора }; var pg = new PageSelector(pages, rndStub, null, _MAX_PAGES_FOR_RANDOM); var resultPage = pg.GetPageForTwitting().Result; Assert.IsNotNull(resultPage); //должно найти страницу HameFura Assert.IsTrue(resultPage.URL == SamplePages.PageSpeedGrapher.URL, "Очукувалася сторінка SpeedGrapher"); }
public void PageSelector_Halloween_Normal_2019() { var pages = _PrepareSitePagesCollection(); //Здесь нам нужен особенный (не рандомный) селектор, который будет давать те индексы которые нужно для граничных условий var rndStub = new RandomSelectorStub { Result = 3 //он будет выдавать индекс 3 для выбора }; var pg = new PageSelector(pages, rndStub, kawaii.twitter.db.SpecialDays.HALLOWEEN, _MAX_PAGES_FOR_RANDOM); var resultPage = pg.GetPageForTwitting().Result; Assert.IsNotNull(resultPage); //должно найти страницу SamplePages.PageHalloween2013 - см.порядок в ф-ции _PrepareSitePagesCollection Assert.IsTrue(resultPage.URL == SamplePages.PageHalloween2019.URL, "Очукувалася сторінка PageHalloween2019"); }
/// <summary> /// Initialises a new instance of the <see cref="CalendarViewModel"/> class. /// </summary> /// <param name="logger">the logger</param> /// <param name="openEventCommand"> /// Command used to open an event. /// </param> public CalendarViewModel( IAsLogger logger, Action <string> openEventCommand) { this.logger = logger; this.openEventCommand = openEventCommand; this.Years = YearSearcher.FindRawYears(); this.MonthSelector = new ObservableCollection <IPageSelector>(); this.Events = new ObservableCollection <ICalendarItem>(); this.monthDictionary = new Dictionary <string, int>() { { "Jan", 1 }, { "Feb", 2 }, { "Mar", 3 }, { "Apr", 4 }, { "May", 5 }, { "Jun", 6 }, { "Jul", 7 }, { "Aug", 8 }, { "Sept", 9 }, { "Oct", 10 }, { "Nov", 11 }, { "Dev", 12 }, }; foreach (KeyValuePair <string, int> month in this.monthDictionary) { IPageSelector selector = new PageSelector( month.Key, this.NewPage); this.MonthSelector.Add(selector); } this.yearsIndex = this.Years.Count - 1; string monthName = this.monthDictionary.FirstOrDefault(x => x.Value == DateTime.Now.Month).Key; this.NewPage(monthName); }
public void PageSelector_Throws_When_Given_Negative_Index() { //Arrange var selector = new PageSelector<int>(list, Constants.PAGE_RecordCount); //Assert Assert.Throws<IndexOutOfRangeException>(() => selector.GetPage(Constants.PAGE_NegativeIndex)); }
public void Awake() { Instance = this; }
public void RegisterCounting() { int timeout = config.CoreDelay; var domainStats = from e in _pingInputStream group e by new { e.ParentDomain, e.SiteId } into domainGroups from win in domainGroups.HoppingWindow( TimeSpan.FromSeconds(timeout), TimeSpan.FromSeconds(timeout / 5), HoppingWindowOutputPolicy.ClipToWindowEnd) select new DomainStatistics { ParentId = domainGroups.Key.SiteId, Id = DomainSelector.GetDomainId(domainGroups.Key.ParentDomain, domainGroups.Key.SiteId), SelectorType = (int)PageSelectorType.DomainString, Count = (int)win.Count(), Pattern = domainGroups.Key.ParentDomain }; var domainPatternStats = from e in _pingInputStream group e by new { e.SiteId } into domainGroups from win in domainGroups.HoppingWindow( TimeSpan.FromSeconds(timeout), TimeSpan.FromSeconds(timeout / 5), HoppingWindowOutputPolicy.ClipToWindowEnd) select new DomainStatistics { Id = domainGroups.Key.SiteId, ParentId = null, SelectorType = (int)PageSelectorType.DomainPattern, Pattern = null, Count = (int)win.Count() }; var domainStatsTotal = from e in domainPatternStats select new DomainStatistics { ParentId = e.Id, Id = DomainSelector.GetDomainId(DomainSelector.TotalDomain, e.Id), //Domain = string.Empty, SelectorType = (int)PageSelectorType.DomainString, //UserId = Guid.Empty, Pattern = DomainSelector.TotalDomain, Count = e.Count //PageId = null }; var pageStats = from e in _pingInputStream where e.PageId != null group e by new { e.PageId, e.ParentDomain, e.SiteId } into domainGroups from win in domainGroups.HoppingWindow( TimeSpan.FromSeconds(timeout), TimeSpan.FromSeconds(timeout / 5), HoppingWindowOutputPolicy.ClipToWindowEnd) select new DomainStatistics { ParentId = DomainSelector.GetDomainId(domainGroups.Key.ParentDomain, domainGroups.Key.SiteId), Id = PageSelector.GetPageId(domainGroups.Key.PageId.Value, domainGroups.Key.ParentDomain, domainGroups.Key.SiteId), Pattern = null, SelectorType = (int)PageSelectorType.PagePattern, Count = (int)win.Count() }; var totalPageStats = from e in _pingInputStream where e.PageId != null group e by new { e.PageId, e.SiteId } into domainGroups from win in domainGroups.HoppingWindow( TimeSpan.FromSeconds(timeout), TimeSpan.FromSeconds(timeout / 5), HoppingWindowOutputPolicy.ClipToWindowEnd) select new DomainStatistics { ParentId = DomainSelector.GetDomainId(DomainSelector.TotalDomain, domainGroups.Key.SiteId), Id = PageSelector.GetPageId(domainGroups.Key.PageId.Value, DomainSelector.TotalDomain, domainGroups.Key.SiteId), Pattern = null, SelectorType = (int)PageSelectorType.PagePattern, Count = (int)win.Count() }; var totalStats = domainPatternStats.Union(domainStats).Union(domainStatsTotal).Union(totalPageStats).Union(pageStats); _domainStatSource = totalStats.ToObservable(); _statsOutputService = new CepObserver <DomainStatistics>(); _eventsOutputService = new CepDataCollector <PageRequest>(); _subscription = _domainStatSource.Subscribe(_statsOutputService); }
private void OnConfigureUI() { Font defaultFont = Control.DefaultFont; if (this.component.Site != null) { IUIService service = (IUIService)this.component.Site.GetService(typeof(IUIService)); if (service != null) { defaultFont = (Font)service.Styles["DialogFont"]; } } this.Font = defaultFont; this.okButton = new Button(); this.cancelButton = new Button(); this.applyButton = new Button(); this.helpButton = new Button(); this.selectorImageList = new ImageList(); this.selectorImageList.ImageSize = new Size(0x10, 0x10); this.selector = new PageSelector(); this.selector.ImageList = this.selectorImageList; this.selector.AfterSelect += new TreeViewEventHandler(this.OnSelChangeSelector); Label label = new Label { BackColor = SystemColors.ControlDark }; int width = 90; if (this.pageSites != null) { for (int i = 0; i < this.pageSites.Length; i++) { ComponentEditorPage pageControl = this.pageSites[i].GetPageControl(); string title = pageControl.Title; Graphics graphics = base.CreateGraphicsInternal(); int num3 = (int)graphics.MeasureString(title, this.Font).Width; graphics.Dispose(); this.selectorImageList.Images.Add(pageControl.Icon.ToBitmap()); this.selector.Nodes.Add(new TreeNode(title, i, i)); if (num3 > width) { width = num3; } } } width += 10; string str2 = string.Empty; ISite site = this.component.Site; if (site != null) { str2 = System.Windows.Forms.SR.GetString("ComponentEditorFormProperties", new object[] { site.Name }); } else { str2 = System.Windows.Forms.SR.GetString("ComponentEditorFormPropertiesNoName"); } this.Text = str2; Rectangle rectangle = new Rectangle(12 + width, 0x10, this.maxSize.Width, this.maxSize.Height); this.pageHost.Bounds = rectangle; label.Bounds = new Rectangle(rectangle.X, 6, rectangle.Width, 4); if (this.pageSites != null) { Rectangle rectangle2 = new Rectangle(0, 0, rectangle.Width, rectangle.Height); for (int j = 0; j < this.pageSites.Length; j++) { this.pageSites[j].GetPageControl().GetControl().Bounds = rectangle2; } } int num5 = SystemInformation.FixedFrameBorderSize.Width; Rectangle rectangle3 = rectangle; Size size = new Size((rectangle3.Width + (3 * (6 + num5))) + width, ((((rectangle3.Height + 4) + 0x18) + 0x17) + (2 * num5)) + SystemInformation.CaptionHeight); base.Size = size; this.selector.Bounds = new Rectangle(6, 6, width, ((rectangle3.Height + 4) + 12) + 0x17); rectangle3.X = (rectangle3.Width + rectangle3.X) - 80; rectangle3.Y = (rectangle3.Height + rectangle3.Y) + 6; rectangle3.Width = 80; rectangle3.Height = 0x17; this.helpButton.Bounds = rectangle3; this.helpButton.Text = System.Windows.Forms.SR.GetString("HelpCaption"); this.helpButton.Click += new EventHandler(this.OnButtonClick); this.helpButton.Enabled = false; this.helpButton.FlatStyle = FlatStyle.System; rectangle3.X -= 0x56; this.applyButton.Bounds = rectangle3; this.applyButton.Text = System.Windows.Forms.SR.GetString("ApplyCaption"); this.applyButton.Click += new EventHandler(this.OnButtonClick); this.applyButton.Enabled = false; this.applyButton.FlatStyle = FlatStyle.System; rectangle3.X -= 0x56; this.cancelButton.Bounds = rectangle3; this.cancelButton.Text = System.Windows.Forms.SR.GetString("CancelCaption"); this.cancelButton.Click += new EventHandler(this.OnButtonClick); this.cancelButton.FlatStyle = FlatStyle.System; base.CancelButton = this.cancelButton; rectangle3.X -= 0x56; this.okButton.Bounds = rectangle3; this.okButton.Text = System.Windows.Forms.SR.GetString("OKCaption"); this.okButton.Click += new EventHandler(this.OnButtonClick); this.okButton.FlatStyle = FlatStyle.System; base.AcceptButton = this.okButton; base.Controls.Clear(); base.Controls.AddRange(new Control[] { this.selector, label, this.pageHost, this.okButton, this.cancelButton, this.applyButton, this.helpButton }); this.AutoScaleBaseSize = new Size(5, 14); base.ApplyAutoScaling(); }
public void Create_Credit_App_Firefox() { browser_.Navigate().GoToUrl(HOME_PAGE); //1st step is to select get started button try { HomePage homePage = new HomePage(browser_); homePage.GetStartedButton.Click(); } catch (Exception ex) { Trace.TraceError(ex.Message); Assert.Fail("Fail at Home page"); } //2nd step is to randomly "Select Make" string newUsedText = ""; try { MakePage makePage = new MakePage(rng_, browser_); IWebElement randomButton = makePage.SelectRandomNewUsedButton(); randomButton.Click(); newUsedText = randomButton.Text; Trace.WriteLine("New/Used: " + randomButton.Text); Trace.WriteLine("MakesCollection Count: " + makePage.MakesCollection.Count); IWebElement randomMakeType = makePage.SelectRandomMakeType(); Trace.WriteLine("Make Type Selected: " + makePage.RandomMakeTypeTitle); randomMakeType.Click(); } catch (Exception ex) { Trace.TraceError(ex.Message); Assert.Fail("Fail at Select Make page"); } try { //3rd step is to randomly select a car PageSelector modelPageSelector = new PageSelector(rng_, browser_); BasePage nextPage = modelPageSelector.GetNewOrUsedModelPage(newUsedText); if (nextPage is ModelPage) { ModelPage modelPage = (ModelPage)nextPage; Trace.WriteLine("ModelsCollection Count: " + modelPage.ModelsCollection.Count); IWebElement randomModelType = modelPage.SelectRandomModelType(); Trace.WriteLine("Car Model Selected: " + modelPage.RandomModelTypeTitle); randomModelType.Click(); } else if (nextPage is UsedPage) { UsedPage usedModelPage = (UsedPage)nextPage; Trace.WriteLine("Used ModelsCollection Count: " + usedModelPage.UsedCollection.Count); IWebElement randomUsedModelType = usedModelPage.SelectRandomUsedItem(); Trace.WriteLine("Used Car Model Selected: " + randomUsedModelType.Text); randomUsedModelType.Click(); } //4th step LocationPage location = new LocationPage(browser_); if (!location.IsLocationSpecified) { Trace.WriteLine("Location Modal is Displayed"); location.UseMyLocationButton.Click(); //alternate way of inputting location information //location.LocationInputField.SendKeys(ZIP_CODE); //location.FindLocationButton.Click(); } } catch (Exception ex) { Trace.TraceError(ex.Message); Assert.Fail("Fail at Model Selection page"); } //5th step determine if the new page has a inventory list or a trim list bool wasTrimPageVisited = false; try { PageSelector pageSelector = new PageSelector(rng_, browser_); BasePage newPage = pageSelector.GetNewPage(); if (newPage is TrimPage) { TrimPage trimPage = (TrimPage)newPage; IWebElement trimCard = trimPage.SelectRandomTrimCard(); Trace.WriteLine("Trim selected: " + trimPage.TrimCardTitle.Text); trimCard.Click(); wasTrimPageVisited = true; } else if (newPage is InventoryPage) { InventoryPage inventoryPage = (InventoryPage)newPage; IWebElement inventoryCard = inventoryPage.SelectRandomInventoryCard(); Trace.WriteLine("Inventory selected: " + inventoryPage.InventoryCardTitle.Text); string dealerName = inventoryPage.DealerName.Text; inventoryCard.Click(); //Review Vehicle Page ReviewVehiclePage reviewVehiclePage = new ReviewVehiclePage(browser_); Trace.WriteLine("Dealership Name: " + reviewVehiclePage.DealerName.Text); Assert.AreEqual(dealerName, reviewVehiclePage.DealerName.Text); reviewVehiclePage.NextButton.Click(); } else if (newPage is UsedPage) { UsedPage usedYearPage = new UsedPage(rng_, browser_); IWebElement yearElement = usedYearPage.SelectRandomUsedItem(); Trace.WriteLine("Used Year: " + yearElement.Text); yearElement.Click(); UsedPage usedTrimPage = new UsedPage(rng_, browser_); IWebElement trimElement = usedTrimPage.SelectRandomUsedItem(); Trace.WriteLine("Used Trim: " + trimElement.Text); trimElement.Click(); wasTrimPageVisited = true; } } catch (Exception ex) { Trace.TraceError(ex.Message); Assert.Fail("Fail at PageSelector"); } //6th step ~ no trade-in try { ReviewDetailsPage reviewDetailsPage = new ReviewDetailsPage(rng_, browser_); if (newUsedText.Equals("used", StringComparison.InvariantCultureIgnoreCase)) { reviewDetailsPage.UsedVehiclePriceInput.SendKeys(MIN_USED_VEHICLE_PRICE); reviewDetailsPage.OdomoterReadingInput.SendKeys(USED_ODOMETER_VALUE); IWebElement financeType = browser_.FindElement(By.ClassName("sectionTitleBar___1cVBK")); Trace.WriteLine("used finance type: " + financeType.Text); } else //new car { Trace.WriteLine("Finance Toggle Count: " + reviewDetailsPage.FinanceToggles.Count); reviewDetailsPage.SelectRandomFinanceToggle().Click(); Trace.WriteLine("finance type: " + reviewDetailsPage.FinanceType.Text); } reviewDetailsPage.NoTradeInButton.Click(); reviewDetailsPage.NextButton.Click(); } catch (Exception ex) { Trace.TraceError(ex.Message); Assert.Fail("Fail at Review Details page"); } //7th step ~ pick a random dealership if TrimPage was visited instead of inventory page if (wasTrimPageVisited) { try { DealershipPage dealershipPage = new DealershipPage(rng_, browser_); dealershipPage.SelectRandomDealer(); Trace.WriteLine("Dealership name selected: " + dealershipPage.DealerName.Text); if (!dealershipPage.SelectDealerButton.Displayed) { dealershipPage.ToggleDropdown.Click(); } foreach (IWebElement button in dealershipPage.DealerButtons) { Trace.WriteLine("display: " + button.Displayed); } dealershipPage.SelectDealerButton.Click(); } catch (Exception ex) { Trace.WriteLine(ex.Message); Assert.Fail("Fail at Dealership Page"); } } //8th step is to stop at "Search For Financing" Personal Information Page try { PersonalInformationPage personalInfoPage = new PersonalInformationPage(browser_); Assert.AreEqual("Personal Information", personalInfoPage.PersonalInformation.Text); Trace.WriteLine("Test Succeeded!"); } catch (Exception ex) { Trace.WriteLine(ex.Message); Trace.WriteLine("Test Failed!"); Assert.Fail("Fail at Personal Information page"); } }
/// <include file='doc\ComponentEditorForm.uex' path='docs/doc[@for="ComponentEditorForm.OnConfigureUI"]/*' /> /// <devdoc> /// Lays out the UI of the form. /// </devdoc> /// <internalonly/> private void OnConfigureUI() { Font uiFont = Control.DefaultFont; if (component.Site != null) { IUIService uiService = (IUIService)component.Site.GetService(typeof(IUIService)); if (uiService != null) { uiFont = (Font)uiService.Styles["DialogFont"]; } } this.Font = uiFont; okButton = new Button(); cancelButton = new Button(); applyButton = new Button(); helpButton = new Button(); selectorImageList = new ImageList(); selectorImageList.ImageSize = new Size(16, 16); selector = new PageSelector(); selector.ImageList = selectorImageList; selector.AfterSelect += new TreeViewEventHandler(this.OnSelChangeSelector); Label grayStrip = new Label(); grayStrip.BackColor = SystemColors.ControlDark; int selectorWidth = MIN_SELECTOR_WIDTH; if (pageSites != null) { // Add the nodes corresponding to the pages for (int n = 0; n < pageSites.Length; n++) { ComponentEditorPage page = pageSites[n].GetPageControl(); string title = page.Title; Graphics graphics = CreateGraphicsInternal(); int titleWidth = (int) graphics.MeasureString(title, Font).Width; graphics.Dispose(); selectorImageList.Images.Add(page.Icon.ToBitmap()); selector.Nodes.Add(new TreeNode(title, n, n)); if (titleWidth > selectorWidth) selectorWidth = titleWidth; } } selectorWidth += SELECTOR_PADDING; string caption = String.Empty; ISite site = component.Site; if (site != null) { caption = SR.GetString(SR.ComponentEditorFormProperties, site.Name); } else { caption = SR.GetString(SR.ComponentEditorFormPropertiesNoName); } this.Text = caption; Rectangle pageHostBounds = new Rectangle(2 * BUTTON_PAD + selectorWidth, 2 * BUTTON_PAD + STRIP_HEIGHT, maxSize.Width, maxSize.Height); pageHost.Bounds = pageHostBounds; grayStrip.Bounds = new Rectangle(pageHostBounds.X, BUTTON_PAD, pageHostBounds.Width, STRIP_HEIGHT); if (pageSites != null) { Rectangle pageBounds = new Rectangle(0, 0, pageHostBounds.Width, pageHostBounds.Height); for (int n = 0; n < pageSites.Length; n++) { ComponentEditorPage page = pageSites[n].GetPageControl(); page.GetControl().Bounds = pageBounds; } } int xFrame = SystemInformation.FixedFrameBorderSize.Width; Rectangle bounds = pageHostBounds; Size size = new Size(bounds.Width + 3 * (BUTTON_PAD + xFrame) + selectorWidth, bounds.Height + STRIP_HEIGHT + 4 * BUTTON_PAD + BUTTON_HEIGHT + 2 * xFrame + SystemInformation.CaptionHeight); this.Size = size; selector.Bounds = new Rectangle(BUTTON_PAD, BUTTON_PAD, selectorWidth, bounds.Height + STRIP_HEIGHT + 2 * BUTTON_PAD + BUTTON_HEIGHT); bounds.X = bounds.Width + bounds.X - BUTTON_WIDTH; bounds.Y = bounds.Height + bounds.Y + BUTTON_PAD; bounds.Width = BUTTON_WIDTH; bounds.Height = BUTTON_HEIGHT; helpButton.Bounds = bounds; helpButton.Text = SR.GetString(SR.HelpCaption); helpButton.Click += new EventHandler(this.OnButtonClick); helpButton.Enabled = false; helpButton.FlatStyle = FlatStyle.System; bounds.X -= (BUTTON_WIDTH + BUTTON_PAD); applyButton.Bounds = bounds; applyButton.Text = SR.GetString(SR.ApplyCaption); applyButton.Click += new EventHandler(this.OnButtonClick); applyButton.Enabled = false; applyButton.FlatStyle = FlatStyle.System; bounds.X -= (BUTTON_WIDTH + BUTTON_PAD); cancelButton.Bounds = bounds; cancelButton.Text = SR.GetString(SR.CancelCaption); cancelButton.Click += new EventHandler(this.OnButtonClick); cancelButton.FlatStyle = FlatStyle.System; this.CancelButton = cancelButton; bounds.X -= (BUTTON_WIDTH + BUTTON_PAD); okButton.Bounds = bounds; okButton.Text = SR.GetString(SR.OKCaption); okButton.Click += new EventHandler(this.OnButtonClick); okButton.FlatStyle = FlatStyle.System; this.AcceptButton = okButton; this.Controls.Clear(); this.Controls.AddRange(new Control[] { selector, grayStrip, pageHost, okButton, cancelButton, applyButton, helpButton }); #pragma warning disable 618 // continuing with the old autoscale base size stuff, it works, // and is currently set to a non-standard height AutoScaleBaseSize = new Size(5, 14); ApplyAutoScaling(); #pragma warning restore 618 }
/// <include file='doc\StyleBuilderForm.uex' path='docs/doc[@for="StyleBuilderForm.InitForm"]/*' /> /// <devdoc> /// <para>[To be supplied.]</para> /// </devdoc> protected void InitForm() { pageImageList = new ImageList(); pageImageList.ImageSize = new Size(16, 16); defaultImageIndex = pageImageList.Images.Count; using (Icon defaultIcon = new Icon(typeof(StyleBuilderForm), "Empty.ico")) { pageImageList.Images.Add(defaultIcon); } pageSelector = new PageSelector(); pageSelector.TabIndex = 0; pageSelector.ImageList = pageImageList; pageSelector.AfterSelect += new TreeViewEventHandler(this.OnSelChangePageSelector); grayStrip = new Label(); grayStrip.BackColor = SystemColors.ControlDark; grayStrip.TabIndex = 1; grayStrip.TabStop = false; mshtmlControl = new MSHTMLHost(); mshtmlControl.Visible = false; mshtmlControl.TabIndex = 3; mshtmlControl.TabStop = false; mshtmlControl.HandleDestroyed += new EventHandler(this.OnHandleDestroyedMSHTMLControl); Size buttonSize = new Size(UI_BTN_WIDTH, UI_BTN_HEIGHT); okButton = new Button(); okButton.TabIndex = 4; okButton.Text = SR.GetString(SR.SB_OK); okButton.Size = buttonSize; okButton.FlatStyle = FlatStyle.System; okButton.Click += new EventHandler(this.OnClickBtnOK); cancelButton = new Button(); cancelButton.TabIndex = 5; cancelButton.Text = SR.GetString(SR.SB_Cancel); cancelButton.Size = buttonSize; cancelButton.FlatStyle = FlatStyle.System; cancelButton.Click += new EventHandler(this.OnClickBtnCancel); helpButton = new Button(); helpButton.TabIndex = 6; helpButton.Text = SR.GetString(SR.SB_Help); helpButton.Size = buttonSize; helpButton.FlatStyle = FlatStyle.System; helpButton.Click += new EventHandler(this.OnClickBtnHelp); this.Text = SR.GetString(SR.SB_Caption); this.AcceptButton = okButton; this.CancelButton = cancelButton; this.AutoScale = false; this.AutoScaleBaseSize = new Size(5, 14); this.FormBorderStyle = FormBorderStyle.FixedDialog; this.ClientSize = new Size(UI_DEFSIZE_WIDTH, UI_DEFSIZE_HEIGHT); this.MaximizeBox = false; this.MinimizeBox = false; this.ShowInTaskbar = false; this.Font = builderSite.GetUIFont(); this.Icon = null; this.StartPosition = FormStartPosition.CenterParent; this.Controls.Clear(); this.Controls.AddRange(new Control[] { helpButton, cancelButton, okButton, mshtmlControl, grayStrip, pageSelector }); }
private void OnConfigureUI() { Font defaultFont = Control.DefaultFont; if (this.component.Site != null) { IUIService service = (IUIService) this.component.Site.GetService(typeof(IUIService)); if (service != null) { defaultFont = (Font) service.Styles["DialogFont"]; } } this.Font = defaultFont; this.okButton = new Button(); this.cancelButton = new Button(); this.applyButton = new Button(); this.helpButton = new Button(); this.selectorImageList = new ImageList(); this.selectorImageList.ImageSize = new Size(0x10, 0x10); this.selector = new PageSelector(); this.selector.ImageList = this.selectorImageList; this.selector.AfterSelect += new TreeViewEventHandler(this.OnSelChangeSelector); Label label = new Label { BackColor = SystemColors.ControlDark }; int width = 90; if (this.pageSites != null) { for (int i = 0; i < this.pageSites.Length; i++) { ComponentEditorPage pageControl = this.pageSites[i].GetPageControl(); string title = pageControl.Title; Graphics graphics = base.CreateGraphicsInternal(); int num3 = (int) graphics.MeasureString(title, this.Font).Width; graphics.Dispose(); this.selectorImageList.Images.Add(pageControl.Icon.ToBitmap()); this.selector.Nodes.Add(new TreeNode(title, i, i)); if (num3 > width) { width = num3; } } } width += 10; string str2 = string.Empty; ISite site = this.component.Site; if (site != null) { str2 = System.Windows.Forms.SR.GetString("ComponentEditorFormProperties", new object[] { site.Name }); } else { str2 = System.Windows.Forms.SR.GetString("ComponentEditorFormPropertiesNoName"); } this.Text = str2; Rectangle rectangle = new Rectangle(12 + width, 0x10, this.maxSize.Width, this.maxSize.Height); this.pageHost.Bounds = rectangle; label.Bounds = new Rectangle(rectangle.X, 6, rectangle.Width, 4); if (this.pageSites != null) { Rectangle rectangle2 = new Rectangle(0, 0, rectangle.Width, rectangle.Height); for (int j = 0; j < this.pageSites.Length; j++) { this.pageSites[j].GetPageControl().GetControl().Bounds = rectangle2; } } int num5 = SystemInformation.FixedFrameBorderSize.Width; Rectangle rectangle3 = rectangle; Size size = new Size((rectangle3.Width + (3 * (6 + num5))) + width, ((((rectangle3.Height + 4) + 0x18) + 0x17) + (2 * num5)) + SystemInformation.CaptionHeight); base.Size = size; this.selector.Bounds = new Rectangle(6, 6, width, ((rectangle3.Height + 4) + 12) + 0x17); rectangle3.X = (rectangle3.Width + rectangle3.X) - 80; rectangle3.Y = (rectangle3.Height + rectangle3.Y) + 6; rectangle3.Width = 80; rectangle3.Height = 0x17; this.helpButton.Bounds = rectangle3; this.helpButton.Text = System.Windows.Forms.SR.GetString("HelpCaption"); this.helpButton.Click += new EventHandler(this.OnButtonClick); this.helpButton.Enabled = false; this.helpButton.FlatStyle = FlatStyle.System; rectangle3.X -= 0x56; this.applyButton.Bounds = rectangle3; this.applyButton.Text = System.Windows.Forms.SR.GetString("ApplyCaption"); this.applyButton.Click += new EventHandler(this.OnButtonClick); this.applyButton.Enabled = false; this.applyButton.FlatStyle = FlatStyle.System; rectangle3.X -= 0x56; this.cancelButton.Bounds = rectangle3; this.cancelButton.Text = System.Windows.Forms.SR.GetString("CancelCaption"); this.cancelButton.Click += new EventHandler(this.OnButtonClick); this.cancelButton.FlatStyle = FlatStyle.System; base.CancelButton = this.cancelButton; rectangle3.X -= 0x56; this.okButton.Bounds = rectangle3; this.okButton.Text = System.Windows.Forms.SR.GetString("OKCaption"); this.okButton.Click += new EventHandler(this.OnButtonClick); this.okButton.FlatStyle = FlatStyle.System; base.AcceptButton = this.okButton; base.Controls.Clear(); base.Controls.AddRange(new Control[] { this.selector, label, this.pageHost, this.okButton, this.cancelButton, this.applyButton, this.helpButton }); this.AutoScaleBaseSize = new Size(5, 14); base.ApplyAutoScaling(); }
static void OnStartup() { Debug.LogFormat("#KEYMASTER# initializing keymaster"); pageSelector = new PageSelector(); }
public void PageSelector_Returns_Correct_Values_When_Given_Valid_Index_And_PageSize(int index, int pageSize) { //Arrange var selector = new PageSelector<int>(list, pageSize); //Act IPagedList<int> pagedList = selector.GetPage(index); //Assert for (int i = 0; i < pageSize; i++) { Assert.AreEqual(index*pageSize + i, pagedList[i]); } }
/// <include file='doc\ComponentEditorForm.uex' path='docs/doc[@for="ComponentEditorForm.OnConfigureUI"]/*' /> /// <devdoc> /// Lays out the UI of the form. /// </devdoc> /// <internalonly/> private void OnConfigureUI() { Font uiFont = Control.DefaultFont; if (component.Site != null) { IUIService uiService = (IUIService)component.Site.GetService(typeof(IUIService)); if (uiService != null) { uiFont = (Font)uiService.Styles["DialogFont"]; } } this.Font = uiFont; okButton = new Button(); cancelButton = new Button(); applyButton = new Button(); helpButton = new Button(); selectorImageList = new ImageList(); selectorImageList.ImageSize = new Size(16, 16); selector = new PageSelector(); selector.ImageList = selectorImageList; selector.AfterSelect += new TreeViewEventHandler(this.OnSelChangeSelector); Label grayStrip = new Label(); grayStrip.BackColor = SystemColors.ControlDark; int selectorWidth = MIN_SELECTOR_WIDTH; if (pageSites != null) { // Add the nodes corresponding to the pages for (int n = 0; n < pageSites.Length; n++) { ComponentEditorPage page = pageSites[n].GetPageControl(); string title = page.Title; Graphics graphics = CreateGraphicsInternal(); int titleWidth = (int)graphics.MeasureString(title, Font).Width; graphics.Dispose(); selectorImageList.Images.Add(page.Icon.ToBitmap()); selector.Nodes.Add(new TreeNode(title, n, n)); if (titleWidth > selectorWidth) { selectorWidth = titleWidth; } } } selectorWidth += SELECTOR_PADDING; string caption = string.Empty; ISite site = component.Site; if (site != null) { caption = string.Format(SR.ComponentEditorFormProperties, site.Name); } else { caption = SR.ComponentEditorFormPropertiesNoName; } this.Text = caption; Rectangle pageHostBounds = new Rectangle(2 * BUTTON_PAD + selectorWidth, 2 * BUTTON_PAD + STRIP_HEIGHT, maxSize.Width, maxSize.Height); pageHost.Bounds = pageHostBounds; grayStrip.Bounds = new Rectangle(pageHostBounds.X, BUTTON_PAD, pageHostBounds.Width, STRIP_HEIGHT); if (pageSites != null) { Rectangle pageBounds = new Rectangle(0, 0, pageHostBounds.Width, pageHostBounds.Height); for (int n = 0; n < pageSites.Length; n++) { ComponentEditorPage page = pageSites[n].GetPageControl(); page.GetControl().Bounds = pageBounds; } } int xFrame = SystemInformation.FixedFrameBorderSize.Width; Rectangle bounds = pageHostBounds; Size size = new Size(bounds.Width + 3 * (BUTTON_PAD + xFrame) + selectorWidth, bounds.Height + STRIP_HEIGHT + 4 * BUTTON_PAD + BUTTON_HEIGHT + 2 * xFrame + SystemInformation.CaptionHeight); this.Size = size; selector.Bounds = new Rectangle(BUTTON_PAD, BUTTON_PAD, selectorWidth, bounds.Height + STRIP_HEIGHT + 2 * BUTTON_PAD + BUTTON_HEIGHT); bounds.X = bounds.Width + bounds.X - BUTTON_WIDTH; bounds.Y = bounds.Height + bounds.Y + BUTTON_PAD; bounds.Width = BUTTON_WIDTH; bounds.Height = BUTTON_HEIGHT; helpButton.Bounds = bounds; helpButton.Text = SR.HelpCaption; helpButton.Click += new EventHandler(this.OnButtonClick); helpButton.Enabled = false; helpButton.FlatStyle = FlatStyle.System; bounds.X -= (BUTTON_WIDTH + BUTTON_PAD); applyButton.Bounds = bounds; applyButton.Text = SR.ApplyCaption; applyButton.Click += new EventHandler(this.OnButtonClick); applyButton.Enabled = false; applyButton.FlatStyle = FlatStyle.System; bounds.X -= (BUTTON_WIDTH + BUTTON_PAD); cancelButton.Bounds = bounds; cancelButton.Text = SR.CancelCaption; cancelButton.Click += new EventHandler(this.OnButtonClick); cancelButton.FlatStyle = FlatStyle.System; this.CancelButton = cancelButton; bounds.X -= (BUTTON_WIDTH + BUTTON_PAD); okButton.Bounds = bounds; okButton.Text = SR.OKCaption; okButton.Click += new EventHandler(this.OnButtonClick); okButton.FlatStyle = FlatStyle.System; this.AcceptButton = okButton; this.Controls.Clear(); this.Controls.AddRange(new Control[] { selector, grayStrip, pageHost, okButton, cancelButton, applyButton, helpButton }); #pragma warning disable 618 // continuing with the old autoscale base size stuff, it works, // and is currently set to a non-standard height AutoScaleBaseSize = new Size(5, 14); ApplyAutoScaling(); #pragma warning restore 618 }
public void OnEnable() { _target = (PageSelector)base.target; }