public void Consecutive_horizontal_cells_should_be_at_colOffset() { var gridBehaviourMock = Substitute.For <IGridSpawnBeaviour>(); gridBehaviourMock.RowOffset.Returns(URandom.value * 100); gridBehaviourMock.ColOffset.Returns(URandom.value * 100); GridPattern pattern = Build_a.GridPattern .With_a_row_count_of(3) .Has_pattern(1, 1, 1, 1, 1, 1, 1, 1, 1); var gridSpawner = new GridSpawnLocations(gridBehaviourMock); var spawnLocations = gridSpawner.GenerateSpawnLocationsFor(pattern); for (int r = 0; r < spawnLocations.GetLength(0); r++) { var c0 = (Vector3)spawnLocations[r, 0]; var c1 = (Vector3)spawnLocations[r, 1]; var c2 = (Vector3)spawnLocations[r, 2]; Assert.AreEqual(gridBehaviourMock.ColOffset, Vector3.Distance(c0, c1)); Assert.AreEqual(gridBehaviourMock.ColOffset, Vector3.Distance(c1, c2)); Assert.AreEqual(gridBehaviourMock.ColOffset * 2, Vector3.Distance(c0, c2)); } }
public void Should_have_same_size_as_of_number_of_true_cells() { var gridBehaviourMock = Substitute.For <IGridSpawnBeaviour>(); GridPattern pattern = Build_a.GridPattern .With_a_row_count_of(3) .Has_pattern(0, 0, 1, 1, 0, 0, 1, 1, 0); var gridSpawner = new GridSpawnLocations(gridBehaviourMock); var spawnLocations = gridSpawner.GenerateSpawnLocationsFor(pattern); var nonNullPositions = 0; for (int r = 0; r < spawnLocations.GetLength(0); r++) { for (int c = 0; c < spawnLocations.GetLength(1); c++) { if (spawnLocations[r, c] != null) { nonNullPositions++; } } } Assert.IsNotNull(spawnLocations); Assert.AreEqual(nonNullPositions, pattern.GetNumberOfCellsWhichHaveCarInIt()); }
public void Consecutive_vertical_cells_should_be_at_rowOffset() { var gridBehaviourMock = Substitute.For <IGridSpawnBeaviour>(); gridBehaviourMock.RowOffset.Returns(URandom.value * 100); gridBehaviourMock.ColOffset.Returns(URandom.value * 100); GridPattern pattern = Build_a.GridPattern .With_a_row_count_of(3) .With_a_col_count_of(3) .Has_pattern(1, 1, 1, 1, 1, 1, 1, 1, 1); var gridSpawner = new GridSpawnLocations(gridBehaviourMock); var spawnLocations = gridSpawner.GenerateSpawnLocationsFor(pattern); for (int c = 0; c < spawnLocations.GetLength(1); c++) { var r0 = (Vector3)spawnLocations[0, c]; var r1 = (Vector3)spawnLocations[1, c]; var r2 = (Vector3)spawnLocations[2, c]; Assert.AreEqual(gridBehaviourMock.RowOffset, Vector3.Distance(r0, r1)); Assert.AreEqual(gridBehaviourMock.RowOffset, Vector3.Distance(r1, r2)); Assert.AreEqual(gridBehaviourMock.RowOffset * 2, Vector3.Distance(r0, r2)); } }
public GridPatternBuilder Has_pattern(params int[] pattern) { if (rowCount < 1 && colCount > 0) { rowCount = pattern.Length / colCount; } else if (colCount < 1 && rowCount > 0) { colCount = pattern.Length / rowCount; } else if (rowCount < 1 && colCount < 1) { throw new Exception("Set either rowCount or colCount before setting a pattern"); } gridPattern = new GridPattern(); gridPattern.rows = new GridPattern.rowData[rowCount]; for (int r = 0; r < rowCount; r++) { gridPattern.rows[r] = new GridPattern.rowData { cells = new ACarType[colCount] }; for (int c = 0; c < colCount; c++) { gridPattern.rows[r].cells[c] = GetCarTypeFor(pattern[r * colCount + c]); } } return(this); }
private void FillWaitingCarsList(GridPattern pattern) { var spawnLocations = gridSpawn.GenerateSpawnLocationsFor(pattern); for (int r = 0; r < spawnLocations.GetLength(0); r++) { for (int c = 0; c < spawnLocations.GetLength(1); c++) { if (spawnLocations[r, c] == null) { continue; } var car = (ACarType)enemyCarsPool.LockObjectForRecycling(pattern.rows[r].cells[c].Id); if (car == null) { //Debug.Log("No more cars left in the pool"); continue; } car.transform.position = new Vector3( spawnLocations[r, c].Value.x, spawnLocations[r, c].Value.y, 0); carsWaitingToMove.Add(car); } } }
public static void AssertSilverLightEmployeeCurrentProjects() { AutomationElement employeesListGrid = UICompositionPage <TApp> .EmployeesListGrid; AutomationElementCollection aeEmployeesList = UICompositionPage <TApp> .EmployeesGridItems; aeEmployeesList[1].Click(); Thread.Sleep(2000); for (int count = 0; count < aeEmployeesList.Count; count++) { aeEmployeesList[count].Select(); Thread.Sleep(2000); AutomationElement employeeTabControl = UICompositionPage <TApp> .EmployeeSummaryTabControl; AutomationElementCollection employeeTabItems = UICompositionPage <TApp> .EmployeeTabItems; employeeTabItems[1].Select(); Thread.Sleep(2000); //Check if the current projects grid is loaded. AutomationElement currentProjectsGrid = UICompositionPage <TApp> .SilverLightProjectsGrid; GridPattern projectPattern = currentProjectsGrid.GetCurrentPattern(GridPattern.Pattern) as GridPattern; Assert.AreEqual(TestDataInfrastructure.GetTestInputData("ProjectsRowCount" + (count + 1).ToString()), projectPattern.Current.RowCount.ToString()); } }
public static AutomationElement OpenAppributeFromList(AutomationElement ae, string name) { var datagrid = ae.FindByTypeExt(ControlType.DataGrid)[0]; GridPattern gridPattern = datagrid.GetCurrentPattern(GridPattern.Pattern) as GridPattern; int rowCount = gridPattern.Current.RowCount; List <string> names = new List <string>(); foreach (int i in Enumerable.Range(0, rowCount)) { var item = gridPattern.GetItem(i, 1); if (Regex.IsMatch(item.Current.Name, name)) { AutomationElement row = datagrid.FindFirst(TreeScope.Children, new PropertyCondition(AutomationElement.NameProperty, (i + 1).ToString())); SelectionItemPattern itemPattern = row.GetCurrentPattern(SelectionItemPattern.Pattern) as SelectionItemPattern; itemPattern.Select(); } } ae.FindByNameExt("Modify").PressButtonExt(); var handle = WinApi.Window.FindWindowFromCaptationRegex($".*GD&T.*{name}.*"); AutomationElement newDialog = AutomationElement.FromHandle(handle); return(newDialog); }
public GridRow GetRowByIndex(int rowIndex) { PreCheckRow(rowIndex); var gridCell = GridPattern.GetItem(rowIndex, 0).AsGridCell(); return(gridCell.ContainingRow); }
public Vector3?[,] GenerateSpawnLocationsFor(GridPattern pattern) { if (pattern == null) { return(null); } var spawnLocations = new Vector3?[pattern.rowCount, pattern.colCount]; var basePosition = gridSpawnBeaviour.SpawnPosition; for (int r = 0; r < pattern.rowCount; r++) { for (int c = 0; c < pattern.colCount; c++) { if (pattern.rows[r].cells[c] == null) { spawnLocations[r, c] = null; continue; } var colPos = basePosition.x + (gridSpawnBeaviour.ColOffset * c); var rowPos = basePosition.y + ((pattern.rowCount - r - 1) * gridSpawnBeaviour.RowOffset); spawnLocations[r, c] = new Vector3(colPos, rowPos, 0); } } return(spawnLocations); }
public static void WaitForPopulatedDatagrid(GridPattern grid, TimeSpan timeout) { var stableTimeToConsiderPopulated = TimeSpan.FromSeconds(1); int lastRowCount = 0; Stopwatch swStable = new Stopwatch(); var sw = Stopwatch.StartNew(); do { if (grid.Current.RowCount > 0) { if (swStable.IsRunning) { if (grid.Current.RowCount != lastRowCount) { swStable.Restart(); } else if (swStable.Elapsed >= stableTimeToConsiderPopulated) { return; } } else { swStable.Start(); } lastRowCount = grid.Current.RowCount; } Thread.Sleep(TimeSpan.FromMilliseconds(100)); //be cpu-friendly }while (sw.Elapsed < timeout); throw new TimeoutException("Timed out waiting for populated datagrid after " + timeout.TotalSeconds + "sec"); }
public void GridPatternCachedTest() { CacheRequest req = new CacheRequest(); req.Add(GridItemPattern.Pattern); req.Add(GridPattern.Pattern); req.Add(GridPattern.RowCountProperty); req.Add(GridPattern.ColumnCountProperty); req.Add(GridItemPattern.RowProperty); req.Add(GridItemPattern.ColumnProperty); req.Add(GridItemPattern.ContainingGridProperty); using (req.Activate()) { AutomationElement itemsView = ExplorerTargetTests.explorerHost.Element.FindFirst(TreeScope.Subtree, new PropertyCondition(AutomationElement.ClassNameProperty, "UIItemsView")); Assert.IsNotNull(itemsView); // Try out the Grid Pattern GridPattern grid = (GridPattern)itemsView.GetCachedPattern(GridPattern.Pattern); Assert.IsTrue(grid.Cached.ColumnCount > 0); Assert.IsTrue(grid.Cached.RowCount > 0); // GridItem AutomationElement gridItemElement = grid.GetItem(0, 0); Assert.IsNotNull(gridItemElement); GridItemPattern gridItem = (GridItemPattern)gridItemElement.GetCachedPattern(GridItemPattern.Pattern); Assert.AreEqual(gridItem.Cached.Row, 0); Assert.AreEqual(gridItem.Cached.Column, 0); Assert.AreEqual(gridItem.Cached.ContainingGrid, itemsView); } }
// </Snippet102> // <Snippet103> ///-------------------------------------------------------------------- /// <summary> /// Event handler for grid structure change. /// </summary> /// <param name="src">Object that raised the event.</param> /// <param name="e">Event arguments.</param> ///-------------------------------------------------------------------- private void OnGridStructureChange( object src, StructureChangedEventArgs e) { // Make sure the element still exists. Elements such as tooltips // can disappear before the event is processed. AutomationElement sourceElement; try { sourceElement = src as AutomationElement; } catch (ElementNotAvailableException) { return; } GridPattern gridPattern = GetGridPattern(sourceElement); if (gridPattern == null) { return; } if (gridPattern.Current.ColumnCount != columnCount) { // Column item added. } else if (gridPattern.Current.RowCount != rowCount) { // Row item added. } }
public static void AssertStockRemovedfromWatchListTextBox() { AutomationElement aeRemoveButton = StockTraderRIPage <TApp> .ActionsRemoveButton; aeRemoveButton.Click(); GridPattern gridPattern = GetGridPatternWatchList(); Assert.AreEqual(new ResXConfigHandler(ConfigHandler.GetValue("TestDataInputFile")).GetValue("DefaultValue"), gridPattern.Current.RowCount.ToString()); }
public static void AssertPositionSummaryRowCount() { GridPattern gridPattern = GetGridPattern(); //read number of account positions from the AccountPosition.xml data file string positionRowCount = new ResXConfigHandler(ConfigHandler.GetValue("TestDataInputFile")).GetValue("PositionSummaryRowCount"); //testDataInfrastructure.GetCount<AccountPositionDataProvider, AccountPosition>(); Assert.AreEqual(positionRowCount, gridPattern.Current.RowCount.ToString()); }
/// <summary> /// Get grid cell element /// </summary> /// <param name="element">AutomationElement instance</param> /// <param name="row">Grid row index</param> /// <param name="column">Grid column index</param> /// <returns>Target grid cell element</returns> public AutomationElement GetGridItem(AutomationElement element, int row, int column) { GridPattern pattern = GetGridPattern(element); if (pattern != null) { return(pattern.GetItem(row, column)); } return(null); }
public static bool TryGetGridPattern(this AutomationElement element, out GridPattern result) { if (element.TryGetCurrentPattern(System.Windows.Automation.GridPattern.Pattern, out var pattern)) { result = (GridPattern)pattern; return(true); } result = null; return(false); }
public AutomationElement GetItem(int row, int column, bool log) { if (log) { procedureLogger.Action(string.Format("Get element from row {0}, col {1} from {2}.", row, column, this.NameAndType)); } GridPattern gp = (GridPattern)element.GetCurrentPattern(GridPattern.Pattern); return(gp.GetItem(row, column)); }
// Update the position and size and CellSize of the GridPattern // in the Node whose Id is "PrintGrid". public void UpdatePrintGrid() { if (!this.IsPreviewEnabled) { return; } Diagram diagram = this.Diagram; if (diagram == null) { return; } if (diagram.Panel == null) { return; } double pw = this.PrintableArea.Width; double ph = this.PrintableArea.Height; Thickness m = this.Margin; pw -= m.Left + m.Right; ph -= m.Top + m.Bottom; if (pw <= 0 || Double.IsNaN(pw) || ph <= 0 || Double.IsNaN(ph)) { return; // can't update PrintGrid if we don't know printable area } Node printGrid = diagram.PartsModel.FindNodeByKey("PrintGrid"); if (printGrid != null) { Rect db = diagram.Panel.DiagramBounds; double scale = this.Scale; if (Double.IsNaN(scale) || scale <= 0 || Double.IsInfinity(scale)) { scale = Math.Min(1, Math.Min(pw / db.Width, ph / db.Height)); } Size eps = new Size(pw / scale, ph / scale); GridPattern gp = printGrid.FindDescendant(e => e is GridPattern) as GridPattern; if (gp != null) { // update the PrintGrid's position and size to cover the DiagramBounds printGrid.Location = new Point(db.X, db.Y); gp.Width = Math.Ceiling(Math.Ceiling(db.Width / eps.Width) * eps.Width); gp.Height = Math.Ceiling(Math.Ceiling(db.Height / eps.Height) * eps.Height); gp.Margin = this.Margin; // update the PrintGrid's GridPattern's CellSize gp.CellSize = eps; } } }
private void GridPatternTestInternal(GridPattern pattern) { Assert.AreEqual(3, pattern.Current.ColumnCount, "ColumnCount"); //Besides the 2 data rows, there is an additional new data row. Assert.AreEqual(3, pattern.Current.RowCount, "RowCount"); var child = pattern.GetItem(0, 1); Assert.AreEqual("Alice", child.Current.Name, "Item [1,1].Name"); child = pattern.GetItem(1, 0); Assert.AreEqual(ControlType.CheckBox, child.Current.ControlType, "Item [0,0].ControlType"); var toggle = (TogglePattern )child.GetCurrentPattern(TogglePattern.Pattern); Assert.AreEqual(ToggleState.On, toggle.Current.ToggleState, "Item [0,0].ToggleState"); }
public static void AssertSilverLightEmployeeCurrentProjects() { AutomationElement employeeTab = UICompositionPage <TApp> .EmployeeDetailsTabControl; // Select Current Projects Tab AutomationElement aeTabPage = employeeTab.FindFirst(TreeScope.Descendants, new PropertyCondition(AutomationElement.NameProperty, "Current Projects")); Core.InputDevices.Mouse.Instance.Location = new System.Drawing.Point((int)Math.Floor(aeTabPage.Current.BoundingRectangle.X), (int)Math.Floor(aeTabPage.Current.BoundingRectangle.Y)); Core.InputDevices.Mouse.Instance.Click(); //Check if the current projects grid is loaded. AutomationElement currentProjectsGrid = UICompositionPage <TApp> .SilverLightProjectsGrid; GridPattern projectPattern = currentProjectsGrid.GetCurrentPattern(GridPattern.Pattern) as GridPattern; Assert.AreEqual(TestDataInfrastructure.GetTestInputData("ProjectsRowCount"), projectPattern.Current.RowCount.ToString()); }
// </Snippet100> // <Snippet101> ///-------------------------------------------------------------------- /// <summary> /// Obtains a GridPattern control pattern from an /// automation element. /// </summary> /// <param name="targetControl"> /// The automation element of interest. /// </param> /// <returns> /// A GridPattern object. /// </returns> ///-------------------------------------------------------------------- private GridPattern GetGridPattern( AutomationElement targetControl) { GridPattern gridPattern = null; try { gridPattern = targetControl.GetCurrentPattern( GridPattern.Pattern) as GridPattern; } // Object doesn't support the // GridPattern control pattern catch (InvalidOperationException) { return null; } return gridPattern; }
public static List <string> GetAppributeList(AutomationElement ae) { var datagrids = ae.FindByTypeExt(ControlType.DataGrid); GridPattern gridPattern = datagrids[0].GetCurrentPattern(GridPattern.Pattern) as GridPattern; int rowCount = gridPattern.Current.RowCount; List <string> names = new List <string>(); foreach (int i in Enumerable.Range(0, rowCount)) { var item = gridPattern.GetItem(i, 1); string name = item.Current.Name.Split(' ').First(); names.Add(name); } return(names); }
public void GridPatternTest() { AutomationElement itemsView = ExplorerTargetTests.explorerHost.Element.FindFirst(TreeScope.Subtree, new PropertyCondition(AutomationElement.ClassNameProperty, "UIItemsView")); Assert.IsNotNull(itemsView); // Try out the Grid Pattern GridPattern grid = (GridPattern)itemsView.GetCurrentPattern(GridPattern.Pattern); Assert.IsTrue(grid.Current.ColumnCount > 0); Assert.IsTrue(grid.Current.RowCount > 0); // GridItem AutomationElement gridItemElement = grid.GetItem(0, 0); Assert.IsNotNull(gridItemElement); GridItemPattern gridItem = (GridItemPattern)gridItemElement.GetCurrentPattern(GridItemPattern.Pattern); Assert.AreEqual(gridItem.Current.Row, 0); Assert.AreEqual(gridItem.Current.Column, 0); Assert.AreEqual(gridItem.Current.ContainingGrid, itemsView); }
public static void AssertPositionSummaryValuesForSymbol() { //For each row, get the column values and test it the new value GridPattern gridPattern = GetGridPattern(); string share; string lastPrice; string marketPrice; string gainLoss; string costBasis; string symbol; //Test for the number of rows displayed in the Position summary table in the UI for (int rowCountIndex = 0; rowCountIndex < gridPattern.Current.RowCount; rowCountIndex++) { // Get the Stock name symbol = gridPattern.GetItem(rowCountIndex, 0).Current.Name; // Column 0 is for Stock //input columns share = double.Parse(gridPattern.GetItem(rowCountIndex, 1).Current.Name, NumberStyles.Currency).ToString(); // Column 1 is for number of share lastPrice = double.Parse(gridPattern.GetItem(rowCountIndex, 2).Current.Name, NumberStyles.Currency).ToString(); // Column 2 is for last price costBasis = double.Parse(gridPattern.GetItem(rowCountIndex, 3).Current.Name, NumberStyles.Currency).ToString(); // Column 3 is for cost //computed columns marketPrice = double.Parse(gridPattern.GetItem(rowCountIndex, 4).Current.Name, NumberStyles.Currency).ToString(); // Column 3 is for cost //marketPrice = gridPattern.GetItem(rowCountIndex, 4).Current.Name.Replace('$', '0'); // Column 4 is for market price for symbol gainLoss = gridPattern.GetItem(rowCountIndex, 5).Current.Name; // Column 5 is for Gain Loss % for symbol gainLoss = gainLoss.Remove(gainLoss.Length - 1); double tempValue; Assert.IsTrue(Double.TryParse(share, out tempValue), String.Format(CultureInfo.CurrentCulture, "Number of shares {0} is not numeric", symbol)); Assert.IsTrue(Double.TryParse(lastPrice, out tempValue), String.Format(CultureInfo.CurrentCulture, "Lastprice for {0} is not numeric", symbol)); Assert.IsTrue(Double.TryParse(costBasis, out tempValue), String.Format(CultureInfo.CurrentCulture, "Cost basis Value for {0} is not numeric", symbol)); Assert.IsTrue(Double.TryParse(marketPrice, out tempValue), String.Format(CultureInfo.CurrentCulture, "Market price for {0} is not numeric", symbol)); Assert.IsTrue(Double.TryParse(gainLoss, out tempValue), String.Format(CultureInfo.CurrentCulture, "Gainloss % Value for {0} is not numeric", symbol)); } }
public static void AssertWatchListRowCount() { GridPattern gridPattern = GetGridPatternWatchList(); Assert.AreEqual(new ResXConfigHandler(ConfigHandler.GetValue("TestDataInputFile")).GetValue("WatchListRowCount"), gridPattern.Current.RowCount.ToString()); }
public void AddJahresbetrachtung( MeteoGtzYear meteoGtzYear) { this.CreateHeading("1. Jahresbetrachtung der heizwirksamen Temperatur des aktuellen Jahres im Vergleich zu den Vorjahren und Langzeitmittel²"); // Add grid IGrid grid = this.currentBand.AddGrid(); IText text; Style textStyle = new Style(this.pdfFonts[PdfFont.DefaultNormalReg], Brushes.Black); Style headerStyle = new Style(this.pdfFonts[PdfFont.DefaultNormalBold], Brushes.Black); // Grid pattern for borders around block var gridPattern = new GridPattern { Borders = new Borders(new Pen(Colors.Black)), Paddings = { All = 10 } }; gridPattern.Apply(grid); var column = grid.AddColumn(); var gridRow = grid.AddRow(); var gridCell = gridRow.AddCell(); GridCellPattern cellPattern = new GridCellPattern { Alignment = new ContentAlignment(Alignment.Center, Alignment.Middle), Paddings = { Left = 10, Bottom = 0 } }; //cellPattern.Apply(gridCell); //text = gridCell.AddText(); //text.Style.Font = pdfFonts[PdfFont.DefaultNormalReg]; //text.AddContent("Alle Angaben sind immer konkret bezogen auf die getroffene Auswahl hinsichtlich Abrech-nungszeitraum (Stichtag) " + "und die ausgewählte Region. Basis sind dabei immer die Tages-mitteltemperaturen. Betrachtet werden immer " + "ganzjährige Abrechnungszeiträume."); //text.AddLineBreak(); //text.AddLineBreak(); //Add Chart gridRow = grid.AddRow(); gridCell = gridRow.AddCell(); ICanvas canvas = gridCell.AddCanvas(); canvas.Width = new FixedWidth(440); canvas.Height = new FixedHeight(190); using (System.Drawing.Graphics g = canvas.CreateGraphics()) { UltraChart myChart = JahresbetrachtungChart.GetChart(meteoGtzYear, 440, 190, true); //myChart.ColumnChart.ChartText(0).Visible = True myChart.Legend.Visible = false; myChart.RenderPdfFriendlyGraphics(g); } gridRow = grid.AddRow(); gridCell = gridRow.AddCell(); cellPattern.Apply(gridCell); text = gridCell.AddText(); text.Style.Font = this.pdfFonts[PdfFont.DefaultNormalReg]; //text.Paddings.Top = 5; var relativeData = meteoGtzYear.ToRelativeData(); double vorjahrBedarf = relativeData.Period2; double lgtzBedarf = relativeData.Lgtz; var vorjahrBedarfText = string.Format( @"In der gewählten Region war es im gleichen Zeitraum des Vorjahres {0}% {1} als im betrachteten Zeiraum des aktuellen Jahres. Entsprechend ist im aktuellen Jahr im Vergleich zum Vorjahreszeitraum mit einem Heiz{2}bedarf zu rechnen.", Math.Abs(Math.Round(vorjahrBedarf, 2)), (vorjahrBedarf > 0 ? "wärmer" : "kälter"), (vorjahrBedarf > 0 ? "mehr" : "minder")); var lgtzBedarfText = string.Format("In der gewählten Region ist das Langzeitmittel {0}% {1} als das aktuelle Jahr.", Math.Abs(Math.Round(lgtzBedarf, 2)), (lgtzBedarf > 0 ? "wärmer" : "kälter")); //text.AddLineBreak(); text.AddContent(vorjahrBedarfText); text.AddLineBreak(); text.AddLineBreak(); text.AddContent(lgtzBedarfText); }
public void AddMonatsbetrachtung(DataTable chartData, List<Zeitraum> zeitraums) { if ((chartData == null)) { return; } //Dummy Column für Legende Langzeitmittel var columnDummy = new DataColumn { DataType = typeof(double) }; chartData.Columns.Add(columnDummy); var periods = zeitraums.OrderByDescending(p => p.Start).GetFormatted(true); this.CreateHeading("2. Monatsbetrachtung der Temperatur des aktuellen Jahres im Vergleich zum Vorjahr und Langzeitmittel²"); //Dim flow As Infragistics.Documents.Report.Flow.IFlow = currentBand.AddFlow() //flow.Borders.All = New Border(New Pen(Colors.Black)) IText text ; ICanvas legendCanvas; // Add grid IGrid grid = this.currentBand.AddGrid(); // Grid pattern for borders around block GridPattern gridPattern = new GridPattern { Borders = new Borders(new Pen(Colors.Black)), Paddings = { All = 10 } }; gridPattern.Apply(grid); IGridColumn column = grid.AddColumn(); IGridRow gridRow = grid.AddRow(); IGridCell gridCell = gridRow.AddCell(); GridCellPattern cellPattern = new GridCellPattern { Alignment = new ContentAlignment(Alignment.Left, Alignment.Middle) }; //cellPattern.Borders = New Borders(New Pen(New Color(0, 0, 0))) //cellPattern.Paddings.All = 0 //Add Legend gridCell.Alignment = new ContentAlignment(Alignment.Center, Alignment.Middle); IGrid legendGrid = gridCell.AddGrid(); IGridCell legendCell; legendGrid.Width = new FixedWidth(450); column = legendGrid.AddColumn(); column.Width = new FixedWidth(7); column = legendGrid.AddColumn(); column = legendGrid.AddColumn(); column.Width = new FixedWidth(7); column = legendGrid.AddColumn(); column = legendGrid.AddColumn(); column.Width = new FixedWidth(7); column = legendGrid.AddColumn(); gridRow = legendGrid.AddRow(); //Vorjahr legendCell = gridRow.AddCell(); cellPattern.Apply(legendCell); legendCanvas = legendCell.AddCanvas(); legendCanvas.Width = new FixedWidth(5); legendCanvas.Paddings.All = 0; legendCanvas.Margins.All = 0; legendCanvas.Height = new FixedHeight(5); legendCanvas.Brush = new SolidColorBrush(new Color(0, 76, 148)); legendCanvas.DrawRectangle(0, 0, 5, 5, PaintMode.FillStroke); legendCell = gridRow.AddCell(); cellPattern.Apply(legendCell); text = legendCell.AddText(); text.Style.Font = this.pdfFonts[PdfFont.DefaultNormalReg]; text.AddContent(periods[0]); //Langzeitmittel legendCell = gridRow.AddCell(); cellPattern.Apply(legendCell); legendCanvas = legendCell.AddCanvas(); legendCanvas.Width = new FixedWidth(5); legendCanvas.Height = new FixedHeight(5); legendCanvas.Brush = new SolidColorBrush(new Color(236, 98, 42)); legendCanvas.DrawRectangle(0, 0, 5, 5, PaintMode.FillStroke); legendCell = gridRow.AddCell(); cellPattern.Apply(legendCell); text = legendCell.AddText(); text.Style.Font = this.pdfFonts[PdfFont.DefaultNormalReg]; text.AddContent(periods[1]); //Ausgangbasis legendCell = gridRow.AddCell(); cellPattern.Apply(legendCell); legendCanvas = legendCell.AddCanvas(); legendCanvas.Width = new FixedWidth(5); legendCanvas.Height = new FixedHeight(5); legendCanvas.Pen = new Pen(Colors.Green, 2); legendCanvas.DrawLine(0, 2.5f, 5, 2.5f); legendCell = gridRow.AddCell(); cellPattern.Apply(legendCell); text = legendCell.AddText(); text.Style.Font = this.pdfFonts[PdfFont.DefaultNormalReg]; text.AddContent("Langzeitmittel (Nulllinie)"); //Add Chart gridRow = grid.AddRow(); gridCell = gridRow.AddCell(); ICanvas canvas = gridCell.AddCanvas(); //Me.currentBand.AddCanvas() canvas.Width = new FixedWidth(500); canvas.Height = new FixedHeight(250); using (System.Drawing.Graphics g = canvas.CreateGraphics()) { UltraChart myChart = MonatsRelativeVerteilungJahrChart.GetChart(chartData, 500, 250, periods.ToArray()); //myChart.ColumnChart.ChartText(0).Visible = True myChart.Legend.Visible = false; myChart.RenderPdfFriendlyGraphics(g); } //gridCell.AddStretcher() //Add Info GridCellPattern cellPattern2 = new GridCellPattern { Paddings = { Left = 10, Bottom = 0 } }; gridRow = grid.AddRow(); gridCell = gridRow.AddCell(); cellPattern2.Apply(gridCell); DataRow row = chartData.Rows[chartData.Rows.Count - 1]; try { string monat = Utils.GetMonthName(row["Monat"].ConvertTo<int>(), "MMMM"); double VorjahrBedarf = row.Field<double>("Vorjahr"); double aktuellJqahr = row.Field<double>("Aktuelljahr"); text = gridCell.AddText(); text.Style.Font = this.pdfFonts[PdfFont.DefaultNormalReg]; //text.Paddings.Top = 10 text.AddLineBreak(); text.AddContent("Das Langzeitmittel stellt die Nulllinie dar."); text.AddLineBreak(); text.AddLineBreak(); text.AddContent("Negativer Prozentwert (Balken zeigt nach unten): in dem jeweiligen Monat des Vorjahres / aktuellen Jahres war es kälter als im gleichen Monat des Langzeitmittels."); text.AddLineBreak(); text.AddLineBreak(); text.AddContent("Positiver Prozentwert (Balken zeigt nach oben): in dem jeweiligen Monat des Vorjahres / aktuellen Jahres war es wärmer als im gleichen Monat des Langzeitmittels."); text.AddLineBreak(); text.AddLineBreak(); text.AddContent(string.Format("Für die gewählte Region war es - bezogen auf das Langzeitmittel im Monat {0}", monat)); IQuickList list = gridCell.AddQuickList(); list.Margins.Bottom = 0; list.Font = this.pdfFonts[PdfFont.DefaultNormalReg]; list.Interval = 1; list.AddItem(string.Format("des Vorjahres ca. {0}% {1}", Math.Abs(Math.Round(VorjahrBedarf, 2)), (VorjahrBedarf > 0 ? "wärmer" : "kälter"))); list.AddItem(string.Format("des aktuellen Jahres ca. {0}% {1}", Math.Abs(Math.Round(aktuellJqahr, 2)), (aktuellJqahr > 0 ? "wärmer" : "kälter"))); //gridCell.AddStretcher(); } catch (Exception ex) { } this.currentBand.AddStretcher(); }
// </Snippet102> // <Snippet103> ///-------------------------------------------------------------------- /// <summary> /// Event handler for grid item focus change. /// Can be used to track traversal of individual grid items /// within a grid. /// </summary> /// <param name="src">Object that raised the event.</param> /// <param name="e">Event arguments.</param> ///-------------------------------------------------------------------- private void OnGridItemFocusChange( object src, AutomationFocusChangedEventArgs e) { // Make sure the element still exists. Elements such as tooltips // can disappear before the event is processed. AutomationElement sourceElement; try { sourceElement = src as AutomationElement; } catch (ElementNotAvailableException) { return; } // Gets a GridItemPattern from the source of the event. GridItemPattern gridItemPattern = GetGridItemPattern(sourceElement); if (gridItemPattern == null) { return; } // Gets a GridPattern from the grid container. GridPattern gridPattern = GetGridPattern(gridItemPattern.Current.ContainingGrid); if (gridPattern == null) { return; } AutomationElement gridItem = null; try { gridItem = gridPattern.GetItem( gridItemPattern.Current.Row, gridItemPattern.Current.Column); } catch (ArgumentOutOfRangeException) { // If the requested row coordinate is larger than the RowCount // or the column coordinate is larger than the ColumnCount. // -- OR -- // If either of the requested row or column coordinates // are less than zero. // TO DO: error handling. } // Further event processing can be done at this point. // For the purposes of this sample we just report item properties. StringBuilder gridItemReport = new StringBuilder(); gridItemReport.AppendLine( gridItemPattern.Current.Row.ToString()).AppendLine( gridItemPattern.Current.Column.ToString()).AppendLine( gridItemPattern.Current.RowSpan.ToString()).AppendLine( gridItemPattern.Current.ColumnSpan.ToString()).AppendLine( gridItem.Current.AutomationId.ToString()); Console.WriteLine(gridItemReport.ToString()); }
public Table(AutomationElement element) : base(element) { _pattern = (GridPattern)element.GetCurrentPattern(GridPattern.Pattern); }
public void AddTagesmitteltemperaturen(object chartData, List<Zeitraum> zeitraums ) { var periods = zeitraums.OrderByDescending(p => p.Start).GetFormatted(true); this.CreateHeading("3. Tagesmitteltemperaturen³ des gewählten Abrechnungszeitraumes und des Vorjahres"); ICanvas legendCanvas = default(ICanvas); IText text = default(IText); // Add grid IGrid grid = this.currentBand.AddGrid(); GridCellPattern cellPattern = new GridCellPattern(); cellPattern.Alignment = new ContentAlignment(Alignment.Left, Alignment.Middle); // Grid pattern for borders around block GridPattern gridPattern = new GridPattern(); gridPattern.Borders = new Borders(new Pen(new Color(0, 0, 0))); gridPattern.Paddings.All = 10; gridPattern.Apply(grid); IGridColumn column = grid.AddColumn(); IGridRow gridRow = grid.AddRow(); IGridCell gridCell = gridRow.AddCell(); //Add Legend gridCell.Alignment = new ContentAlignment(Alignment.Center, Alignment.Middle); IGrid legendGrid = gridCell.AddGrid(); IGridCell legendCell; legendGrid.Width = new FixedWidth(450); column = legendGrid.AddColumn(); column.Width = new FixedWidth(7); column = legendGrid.AddColumn(); column = legendGrid.AddColumn(); column.Width = new FixedWidth(7); column = legendGrid.AddColumn(); column = legendGrid.AddColumn(); column.Width = new FixedWidth(7); column = legendGrid.AddColumn(); gridRow = legendGrid.AddRow(); //1 Period legendCell = gridRow.AddCell(); cellPattern.Apply(legendCell); legendCanvas = legendCell.AddCanvas(); legendCanvas.Width = new FixedWidth(5); legendCanvas.Paddings.All = 0; legendCanvas.Margins.All = 0; legendCanvas.Height = new FixedHeight(5); legendCanvas.Pen = new Pen(new Color(65, 69, 120), 2); legendCanvas.DrawLine(0, 2.5f, 5, 2.5f); legendCell = gridRow.AddCell(); cellPattern.Apply(legendCell); text = legendCell.AddText(); text.Style.Font = this.pdfFonts[PdfFont.DefaultNormalReg]; text.AddContent(periods[0]); //2 Period legendCell = gridRow.AddCell(); cellPattern.Apply(legendCell); legendCanvas = legendCell.AddCanvas(); legendCanvas.Width = new FixedWidth(5); legendCanvas.Height = new FixedHeight(5); legendCanvas.Pen = new Pen(new Color(204, 76, 24), 2); legendCanvas.DrawLine(0, 2.5f, 5, 2.5f); legendCell = gridRow.AddCell(); cellPattern.Apply(legendCell); text = legendCell.AddText(); text.Style.Font = this.pdfFonts[PdfFont.DefaultNormalReg]; text.AddContent(periods[1]); //Ausgangbasis legendCell = gridRow.AddCell(); cellPattern.Apply(legendCell); legendCanvas = legendCell.AddCanvas(); legendCanvas.Width = new FixedWidth(5); legendCanvas.Height = new FixedHeight(5); legendCanvas.Pen = new Pen(Colors.Green, 2); legendCanvas.DrawLine(0, 2.5f, 5, 2.5f); legendCell = gridRow.AddCell(); cellPattern.Apply(legendCell); text = legendCell.AddText(); text.Style.Font = this.pdfFonts[PdfFont.DefaultNormalReg]; text.AddContent("Heizgrenztemperatur"); //text.AddContent("Heizgrenztemperatur⁴"); //Add Chart //chartData.Columns("Heizgrenztemperatur").ColumnName = "Heizgrenztemperatur³" gridRow = grid.AddRow(); gridCell = gridRow.AddCell(); ICanvas canvas = gridCell.AddCanvas(); //Me.currentBand.AddCanvas() canvas.Width = new FixedWidth(530); canvas.Height = new FixedHeight(300); using (System.Drawing.Graphics g = canvas.CreateGraphics()) { using (UltraChart myChart = new UltraChart()) { TemperaturChart.GetChart(myChart, chartData, 530, 300); myChart.Legend.Visible = false; myChart.RenderPdfFriendlyGraphics(g); } } //this.currentBand.AddStretcher(); }
public static void AssertPositionSummaryColumnCount() { GridPattern gridPattern = GetGridPattern(); Assert.AreEqual(new ResXConfigHandler(ConfigHandler.GetValue("TestDataInputFile")).GetValue("PositionSummaryColumnCount"), gridPattern.Current.ColumnCount.ToString()); }
public void PatternController(AutomationPattern pat, AutomationElement selectedItem, ListView listView2) { if (pat == ScrollPattern.Pattern) { ScrollPattern scrollPattern = selectedItem.GetCurrentPattern(ScrollPattern.Pattern) as ScrollPattern; ListViewItem lvi = new ListViewItem(); lvi.Content = "Scroll - not implemented"; lvi.Tag = new PatternInfo(1, 1, selectedItem, scrollPattern); listView2.Items.Add(lvi); } else if (pat == DockPattern.Pattern) { DockPattern dockPattern = selectedItem.GetCurrentPattern(DockPattern.Pattern) as DockPattern; ListViewItem lvi = new ListViewItem(); lvi.Content = "SetDockPosition - not implemented"; lvi.Tag = new PatternInfo(2, 1, selectedItem, dockPattern); listView2.Items.Add(lvi); } else if (pat == ExpandCollapsePattern.Pattern) { ExpandCollapsePattern expandCollapsePattern = selectedItem.GetCurrentPattern(ExpandCollapsePattern.Pattern) as ExpandCollapsePattern; ListViewItem lvi1 = new ListViewItem(); lvi1.Content = "Expand"; lvi1.Tag = new PatternInfo(3, 1, selectedItem, expandCollapsePattern); listView2.Items.Add(lvi1); ListViewItem lvi2 = new ListViewItem(); lvi2.Content = "Collapse"; lvi2.Tag = new PatternInfo(3, 2, selectedItem, expandCollapsePattern); listView2.Items.Add(lvi2); } else if (pat == GridPattern.Pattern) { GridPattern gridPattern = selectedItem.GetCurrentPattern(GridPattern.Pattern) as GridPattern; ListViewItem lvi = new ListViewItem(); lvi.Content = "GetItem - not implemented"; lvi.Tag = new PatternInfo(4, 1, selectedItem, gridPattern); listView2.Items.Add(lvi); } else if (pat == GridItemPattern.Pattern) { } else if (pat == InvokePattern.Pattern) { InvokePattern invokePattern = selectedItem.GetCurrentPattern(InvokePattern.Pattern) as InvokePattern; ListViewItem lvi = new ListViewItem(); lvi.Content = "Invoke"; lvi.Tag = new PatternInfo(6, 1, selectedItem, invokePattern); listView2.Items.Add(lvi); } else if (pat == ItemContainerPattern.Pattern) { } else if (pat == MultipleViewPattern.Pattern) { } else if (pat == RangeValuePattern.Pattern) { RangeValuePattern rangeValuePattern = selectedItem.GetCurrentPattern(RangeValuePattern.Pattern) as RangeValuePattern; ListViewItem lvi = new ListViewItem(); lvi.Content = "SetValue - not implemented"; lvi.Tag = new PatternInfo(9, 1, selectedItem, rangeValuePattern); listView2.Items.Add(lvi); } else if (pat == ScrollItemPattern.Pattern) { } else if (pat == SelectionItemPattern.Pattern) { } else if (pat == SelectionPattern.Pattern) { } else if (pat == SynchronizedInputPattern.Pattern) { } else if (pat == TextPattern.Pattern) { } else if (pat == TogglePattern.Pattern) { TogglePattern togglePattern = selectedItem.GetCurrentPattern(TogglePattern.Pattern) as TogglePattern; ListViewItem lvi = new ListViewItem(); lvi.Content = "Toggle"; lvi.Tag = new PatternInfo(15, 1, selectedItem, togglePattern); listView2.Items.Add(lvi); } else if (pat == TransformPattern.Pattern) { TransformPattern transformPattern = selectedItem.GetCurrentPattern(TransformPattern.Pattern) as TransformPattern; ListViewItem lvi = new ListViewItem(); lvi.Content = "Move - not implemented"; lvi.Tag = new PatternInfo(16, 1, selectedItem, transformPattern); listView2.Items.Add(lvi); ListViewItem lvi2 = new ListViewItem(); lvi2.Content = "Resize - not implemented"; lvi2.Tag = new PatternInfo(16, 2, selectedItem, transformPattern); listView2.Items.Add(lvi2); ListViewItem lvi3 = new ListViewItem(); lvi3.Content = "Rotate - not implemented"; lvi3.Tag = new PatternInfo(16, 3, selectedItem, transformPattern); listView2.Items.Add(lvi3); } else if (pat == ValuePattern.Pattern) { ValuePattern valuePattern = selectedItem.GetCurrentPattern(ValuePattern.Pattern) as ValuePattern; ListViewItem lvi = new ListViewItem(); lvi.Content = "setValue"; lvi.Tag = new PatternInfo(17, 1, selectedItem, valuePattern); listView2.Items.Add(lvi); } else if (pat == VirtualizedItemPattern.Pattern) { } else if (pat == WindowPattern.Pattern) { WindowPattern windowPattern = selectedItem.GetCurrentPattern(WindowPattern.Pattern) as WindowPattern; ListViewItem lvi = new ListViewItem(); lvi.Content = "SetWindowVisualState - not implemented"; lvi.Tag = new PatternInfo(19, 1, selectedItem, windowPattern); listView2.Items.Add(lvi); } else { listView2.Items.Add("else"); } }
public static void DesktopAssertPositionSummaryColumnCount() { GridPattern gridPattern = GetGridPattern(); Assert.AreEqual("7", gridPattern.Current.ColumnCount.ToString()); }