public static GraphPage MoveMouseToAward(GraphPage page, IWebDriver driver, IWebElement element) { Actions action = new Actions(driver); action.MoveToElement(element).Perform(); return(page); }
/// <summary> /// Processes the pages in the queue. /// </summary> private void ProcessQueue() { while (true) { if (this.queue.Count > 1) { this.queue.Dequeue(); } else { break; } } GraphPage page1 = this.queue.Dequeue(); if (this.layoutInProgress) { if (this.panel1 != null) { this.panel1.AbortLayout = true; } if (this.panel2 != null) { this.panel2.AbortLayout = true; } } this.LayoutPanels(page1, false); }
public static string TextFromTspan(GraphPage page, IWebDriver driver, string word) { WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10)); wait.Until(ExpectedConditions.ElementIsVisible(By.CssSelector("g.highcharts-tooltip > text "))); return(page.TextOfTspan.FindElement(By.XPath(".//*[contains(text(),'" + word + "')]")).Text); }
public void EnsureNoLegend() { PlotModel graphModel = new PlotModel(); graphModel.Series.Add(new OxyPlot.Series.LineSeries()); graphModel.Axes.Add(new OxyPlot.Axes.LinearAxis()); graphModel.Legends.Add(new OxyPlot.Legends.Legend()); Mock <IGraphExporter> mockExporter = new Mock <IGraphExporter>(); mockExporter.Setup <IPlotModel>(e => e.ToPlotModel(graph)).Returns(() => graphModel); mockExporter.Setup(e => e.Export(It.IsAny <IPlotModel>(), It.IsAny <double>(), It.IsAny <double>())).Returns((IPlotModel plot, double width, double height) => { PlotModel model = plot as PlotModel; Assert.AreEqual(0, model.Legends.Count); return(image); }); IGraphExporter exporter = mockExporter.Object; renderer = new GraphPageTagRenderer(exporter); GraphPage page = new GraphPage(new[] { graph }); renderer.Render(page, pdfBuilder); // (Sanity check, just to make sure that the above plumbing actually worked.) Assert.AreEqual(1, TestContext.CurrentContext.AssertCount); }
/// <summary>Writes documentation for this function by adding to the list of documentation tags.</summary> /// <param name="tags">The list of tags to add to.</param> /// <param name="headingLevel">The level (e.g. H2) of the headings.</param> /// <param name="indent">The level of indentation 1, 2, 3 etc.</param> public override void Document(List <AutoDocumentation.ITag> tags, int headingLevel, int indent) { // add a heading. tags.Add(new AutoDocumentation.Heading(Name, headingLevel)); if (ShowPageOfGraphs) { foreach (Memo memo in Apsim.Children(this, typeof(Memo))) { memo.Document(tags, headingLevel, indent); } int pageNumber = 1; int i = 0; List <IModel> children = Apsim.Children(this, typeof(Graph.Graph)); while (i < children.Count) { GraphPage page = new GraphPage(); page.name = Name + pageNumber; for (int j = i; j < i + 6 && j < children.Count; j++) { page.graphs.Add(children[j] as Graph.Graph); } tags.Add(page); i += 6; pageNumber++; } } }
public void TestGraphElementSizing() { PlotModel graphModel = new PlotModel(); graphModel.Series.Add(new OxyPlot.Series.LineSeries()); graphModel.Axes.Add(new OxyPlot.Axes.LinearAxis()); Mock <IGraphExporter> mockExporter = new Mock <IGraphExporter>(); mockExporter.Setup <IPlotModel>(e => e.ToPlotModel(graph)).Returns(() => graphModel); mockExporter.Setup(e => e.Export(It.IsAny <IPlotModel>(), It.IsAny <double>(), It.IsAny <double>())).Returns((IPlotModel plot, double width, double height) => { PlotModel model = plot as PlotModel; Assert.AreEqual(2, ((OxyPlot.Series.LineSeries)model.Series[0]).MarkerSize); Assert.AreEqual(10, model.DefaultFontSize); Assert.AreEqual(10, model.Axes[0].FontSize); Assert.AreEqual(10, model.TitleFontSize); return(image); }); IGraphExporter exporter = mockExporter.Object; renderer = new GraphPageTagRenderer(exporter); GraphPage page = new GraphPage(new[] { graph }); renderer.Render(page, pdfBuilder); }
public void TestLocation() { GraphPage graph = new GraphPage(); graph.setLocation(); Assert.AreEqual(graph.Chart.Location, new Point(100, 100)); }
public void TestInitColor() { GraphPage graph = new GraphPage(); graph.Initialization(); Assert.AreEqual(graph.BackColor, Color.White); }
public void BVT_Graph_S01_TC09_CanLoadGraphPageImages() { //Currently ignore Graph explorer and Documentation, since these pages don't have banner image //Graph branding image string[] navOptions = new string[] { "Home", "Get started", //"Documentation", //"Graph explorer", "App registration", "Samples & SDKs", "Changelog" }; foreach (string navPage in navOptions) { GraphPages.Navigation.Select(navPage); if (navPage == "Home") { foreach (GraphPageImages item in Enum.GetValues(typeof(GraphPageImages))) { Assert.IsTrue(GraphPages.HomePage.CanLoadImages(item)); } } else { var graphPage = new GraphPage(); foreach (GraphPageImages item in Enum.GetValues(typeof(GraphPageImages))) { Assert.IsTrue(graphPage.CanLoadImages(item)); } } } }
/// <summary> /// Attach the specified Model and View. /// </summary> /// <param name="model">The axis model</param> /// <param name="view">The axis view</param> /// <param name="explorerPresenter">The parent explorer presenter</param> public void Attach(object model, object view, ExplorerPresenter explorerPresenter) { IModel folder = model as IModel; List <GraphView> views = new List <GraphView>(); var storage = folder.FindInScope <IDataStore>(); var graphPage = new GraphPage(); graphPage.Graphs.AddRange(folder.FindAllChildren <Graph>().Where(g => g.Enabled)); foreach (var graphSeries in graphPage.GetAllSeriesDefinitions(folder, storage.Reader)) { GraphView graphView = new GraphView(); GraphPresenter presenter = new GraphPresenter(); explorerPresenter.ApsimXFile.Links.Resolve(presenter); presenter.Attach(graphSeries.Graph, graphView, explorerPresenter, graphSeries.SeriesDefinitions); presenters.Add(presenter); views.Add(graphView); } if (views.Count > 0) { (view as IFolderView).SetContols(views); } }
public void DrawGraph() { graphView.Clear(); if (storage == null) { storage = graph.FindInScope <IDataStore>(); } // Get a list of series definitions. try { var page = new GraphPage(); page.Graphs.Add(graph); SeriesDefinitions = page.GetAllSeriesDefinitions(graph, storage?.Reader, SimulationFilter)[0].SeriesDefinitions; } catch (SQLiteException e) { explorerPresenter.MainPresenter.ShowError(new Exception("Error obtaining data from database: ", e)); } catch (FirebirdException e) { explorerPresenter.MainPresenter.ShowError(new Exception("Error obtaining data from database: ", e)); } DrawGraph(SeriesDefinitions); }
static void Main() { Handle.GET("/Graph", () => { MasterPage master; if (Session.Current != null && Session.Current.Data != null) { master = (MasterPage)Session.Current.Data; } else { master = new MasterPage(); if (Session.Current != null) { master.Html = "/Graph/viewmodels/LauncherWrapperPage.html"; master.Session = Session.Current; } else { master.Html = "/Graph/viewmodels/MasterPage.html"; master.Session = new Session(SessionOptions.PatchVersioning); } master.RecentGraphs = new GraphsPage() { Html = "/Graph/viewmodels/GraphsPage.html" }; } ((GraphsPage)master.RecentGraphs).RefreshData(); master.FocusedGraph = null; return master; }); //The bug! /Graph/Graphs/{?} returns Not found exception Handle.GET("/Graph/Details/{?}", (string Key) => { FillTestData(); MasterPage master = Self.GET<MasterPage>("/Graph"); master.FocusedGraph = Self.GET<GraphPage>("/Graph/Only/" + Key); return master; }); Handle.GET("/Graph/Only/{?}", (string Key) => { GraphPage page = new GraphPage() { Html = "/Graph/viewmodels/GraphPage.html", Data = Db.SQL<Simplified.Ring6.Graph>(@"SELECT i FROM Simplified.Ring6.Graph i WHERE i.Key = ?", Key).First }; return page; }); Handle.GET("/Graph/menu", () => { return new Page() { Html = "/Graph/viewmodels/AppMenuPage.html" }; }); Handle.GET("/Graph/app-name", () => { return new AppName(); }); UriMapping.Map("/Graph/app-name", UriMapping.MappingUriPrefix + "/app-name"); UriMapping.Map("/Graph/menu", UriMapping.MappingUriPrefix + "/menu"); UriMapping.OntologyMap<Simplified.Ring6.Graph>("/Graph/Only/{?}"); }
public void TestResize() { GraphPage graph = new GraphPage(); graph.setSize(); Assert.AreEqual(graph.Chart.Size, new Size(graph.Width - 100 * 2, graph.Height - 100 * 2)); }
/// <summary>Creates the graph page.</summary> /// <param name="section">The section to write to.</param> /// <param name="graphPage">The graph and table to convert to html.</param> private void CreateGraphPage(Section section, GraphPage graphPage) { int numGraphsToPrint = graphPage.graphs.FindAll(g => g.IncludeInDocumentation).Count; if (numGraphsToPrint > 0) { int numColumns = 2; int numRows = (numGraphsToPrint + 1) / numColumns; // Export graph to bitmap file. Bitmap image = new Bitmap(1800, numRows * 600); using (Graphics gfx = Graphics.FromImage(image)) using (SolidBrush brush = new SolidBrush(System.Drawing.Color.White)) { gfx.FillRectangle(brush, 0, 0, image.Width, image.Height); } GraphPresenter graphPresenter = new GraphPresenter(); explorerPresenter.ApsimXFile.Links.Resolve(graphPresenter); GraphView graphView = new GraphView(); graphView.BackColor = OxyPlot.OxyColors.White; graphView.ForegroundColour = OxyPlot.OxyColors.Black; graphView.FontSize = 22; graphView.MarkerSize = MarkerSizeType.Normal; graphView.Width = image.Width / numColumns; graphView.Height = image.Height / numRows; graphView.LeftRightPadding = 0; int col = 0; int row = 0; for (int i = 0; i < graphPage.graphs.Count; i++) { if (graphPage.graphs[i].IncludeInDocumentation) { graphPresenter.Attach(graphPage.graphs[i], graphView, explorerPresenter); Rectangle r = new Rectangle(col * graphView.Width, row * graphView.Height, graphView.Width, graphView.Height); graphView.Export(ref image, r, false); graphPresenter.Detach(); col++; if (col >= numColumns) { col = 0; row++; } } } string basePngFileName = Apsim.FullPath(graphPage.graphs[0].Parent) + "." + graphPage.name + ".png"; basePngFileName = basePngFileName.TrimStart('.'); string pngFileName = Path.Combine(WorkingDirectory, basePngFileName); image.Save(pngFileName, System.Drawing.Imaging.ImageFormat.Png); MigraDoc.DocumentObjectModel.Shapes.Image sectionImage = section.AddImage(pngFileName); sectionImage.LockAspectRatio = true; sectionImage.Width = "19cm"; } }
private void CreatePageOfGraphs(string sim, Graph[] graphs) { if (!panel.Cache.ContainsKey(sim)) { panel.Cache.Add(sim, new Dictionary <int, List <SeriesDefinition> >()); } IStorageReader storage = GetStorage(); GraphPage graphPage = new GraphPage(); // Configure graphs by applying user overrides. for (int i = 0; i < graphs.Length; i++) { if (graphs[i] != null && graphs[i].Enabled) { graphPage.Graphs.Add(ConfigureGraph(graphs[i], sim)); } if (cts.Token.IsCancellationRequested) { return; } } // If any sims in this tab are missing from the cache, then populate // the cache via the GraphPage instance. if (panel.Cache[sim].Count != graphs.Length) { // Read data from storage. IReadOnlyList <GraphPage.GraphDefinitionMap> definitions = graphPage.GetAllSeriesDefinitions(panel, storage, new List <string>() { sim }).ToList(); // Now populate the cache for this simulation. The definitions // should - in theory - be the same length as the graphs array. for (int i = 0; i < graphs.Length; i++) { GraphPage.GraphDefinitionMap definition = definitions[i]; panel.Cache[sim][i] = definition.SeriesDefinitions; if (cts.Token.IsCancellationRequested) { return; } } } // Finally, add the graphs to the tab. GraphTab tab = new GraphTab(sim, this.presenter); for (int i = 0; i < graphPage.Graphs.Count; i++) { tab.AddGraph(graphPage.Graphs[i], panel.Cache[sim][i]); } this.graphs.Add(tab); view.AddTab(tab, panel.NumCols); }
public void TestAwardsAndReleasesIsShownInformation() { GraphPage page = new GraphPage(driver); foreach (var element in page.AwardsAndReleases) { GraphActions.MoveMouseToAward(page, driver, element); GraphStates.InformationIsDisplayed(page, page.TextInformation, driver); } }
/// <summary> /// Layouts the panels. /// </summary> /// <param name="page">The page which needs to be positioned.</param> /// <param name="forceRedraw">Indicates whether to force redraw.</param> private void LayoutPanels(GraphPage page, bool forceRedraw) { this.layoutInProgress = true; if (this.dynamicMainLayerViewport.ActualWidth == 0 || this.dynamicMainLayerViewport.ActualHeight == 0) { return; } this.UpdateNonDynamicLayers(); double panelId = page.Key / this.dynamicMainLayerViewport.ActualWidth; this.panel1Id = (int)panelId; this.panel2Id = (int)this.panel1Id + 1; double percentageScroll = (panelId % 1); if (percentageScroll == 0) { // we only need show this.panel1Id as if fits exactly this.amountToOffsetPanel1 = 0; } else { this.amountToOffsetPanel1 = (int)(this.dynamicMainLayerViewport.ActualWidth * percentageScroll); } if (this.currentPanel1Id == -1 || true == forceRedraw) { // first draw this.PanelAnimation5(); } else if (this.panel1Id == this.currentPanel1Id) { // we are not changing panels just adjusting positions this.PanelAnimation1(); } else if (this.panel1Id == this.currentPanel2Id) { // we are replacing panel2 with a new panel and making panel1 the current panel2 this.PanelAnimation2(); } else if (this.panel2Id == this.currentPanel1Id) { // we are replacing panel1 with a new panel and making panel2 the current panel1 this.PanelAnimation3(); } else { // I am replacing both the panel 1 and panel 2 this.PanelAnimation4(); } this.OnLayoutPanelsComplete(); }
public GraphTableRows QueryN1(int n1) { GraphPage page = LoadGraphPage(NetworkObjectSerializer.Page(n1)); if (page == null) { return(new GraphTableRows()); } return(page.QueryN1(n1)); }
/// <summary>Creates the graph page.</summary> /// <param name="section">The section to write to.</param> /// <param name="graphPage">The graph and table to convert to html.</param> /// <param name="workingDirectory">The working directory.</param> private void CreateGraphPage(Section section, GraphPage graphPage, string workingDirectory) { int numGraphsToPrint = graphPage.graphs.FindAll(g => g.IncludeInDocumentation).Count; if (numGraphsToPrint > 0) { int numColumns = 2; int numRows = (numGraphsToPrint + 1) / numColumns; // Export graph to bitmap file. Bitmap image = new Bitmap(1800, numRows * 600); using (Graphics gfx = Graphics.FromImage(image)) using (SolidBrush brush = new SolidBrush(System.Drawing.Color.White)) { gfx.FillRectangle(brush, 0, 0, image.Width, image.Height); } GraphPresenter graphPresenter = new GraphPresenter(); GraphView graphView = new GraphView(); graphView.BackColor = System.Drawing.Color.White; graphView.FontSize = 22; graphView.MarkerSize = 8; graphView.Width = image.Width / numColumns; graphView.Height = image.Height / numRows; graphView.LeftRightPadding = 0; int col = 0; int row = 0; for (int i = 0; i < graphPage.graphs.Count; i++) { if (graphPage.graphs[i].IncludeInDocumentation) { graphPresenter.Attach(graphPage.graphs[i], graphView, ExplorerPresenter); Rectangle r = new Rectangle(col * graphView.Width, row * graphView.Height, graphView.Width, graphView.Height); graphView.Export(image, r, false); graphPresenter.Detach(); col++; if (col >= numColumns) { col = 0; row++; } } } string PNGFileName = Path.Combine(workingDirectory, graphPage.name + ".png"); image.Save(PNGFileName, System.Drawing.Imaging.ImageFormat.Png); MigraDoc.DocumentObjectModel.Shapes.Image sectionImage = section.AddImage(PNGFileName); sectionImage.LockAspectRatio = true; sectionImage.Width = "19cm"; } }
public static string TextFromElement(GraphPage page, IList <IWebElement> list, IWebDriver driver) { WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10)); wait.Until(ExpectedConditions.ElementIsVisible(By.CssSelector("g.highcharts-tooltip > text "))); StringBuilder sb = new StringBuilder(""); foreach (var element in list) { sb.Append(element.Text + "\n"); } return(sb.ToString()); }
public void EnsureAllGraphsAreWritten(int numGraphs) { List <IGraph> graphs = new List <IGraph>(numGraphs); Mock <IGraphExporter> mockExporter = new Mock <IGraphExporter>(); List <Image> images = new List <Image>(); for (int i = 0; i < numGraphs; i++) { // This is a little tricky because I want to have each graph // generate a unique image, so we need to mock out the graph, // the intermediary plot model, and the graph exporter as well. Mock <IGraph> mockGraph = new Mock <IGraph>(); IGraph graph = mockGraph.Object; Image graphImage = CreateImage(i + 1); Mock <IPlotModel> mockModel = new Mock <IPlotModel>(); IPlotModel graphModel = mockModel.Object; mockExporter.Setup <IPlotModel>(e => e.ToPlotModel(graph)).Returns(() => graphModel); mockExporter.Setup <Image>(e => e.Export(graphModel, It.IsAny <double>(), It.IsAny <double>())).Returns(() => graphImage); graphs.Add(graph); images.Add(graphImage); } GraphPage page = new GraphPage(graphs); renderer = new GraphPageTagRenderer(mockExporter.Object); renderer.Render(page, pdfBuilder); if (numGraphs < 1) { // No child graphs - document should be empty. Assert.AreEqual(0, document.LastSection.Elements.Count); } else { // There should be a single paragraph, containing all graphs. Assert.AreEqual(1, document.LastSection.Elements.Count); Paragraph paragraph = document.LastSection.Elements[0] as Paragraph; Assert.NotNull(paragraph); // The paragraph should contain n images. Assert.AreEqual(numGraphs, paragraph.Elements.Count); // Ensure that all images have been renderered correctly. for (int i = 0; i < numGraphs; i++) { MigraDocImage actual = paragraph.Elements[i] as MigraDocImage; AssertEqual(images[i], actual); images[i].Dispose(); } images.Clear(); } }
public static void CheckPositionOfPoints(GraphPage page, string employees, int yposition) { List <int> list = new List <int>(); foreach (var element in page.YaxisLabels) { list.Add(Convert.ToInt32(element.GetAttribute("y"))); } int GraphSize = list.First() - list.Last(); string counts = Regex.Match(employees, "\\d+").Value; int count = Convert.ToInt32(counts); double OneEmployeeSize = (double)GraphSize / 15; int EmployeeSize = Convert.ToInt32(OneEmployeeSize * (15 - count)); Assert.IsTrue(EmployeeSize == yposition); }
public static GraphPage DeserializeGraph(byte[] bytes) { BinaryReader r = new BinaryReader(new MemoryStream()); r.BaseStream.Write(bytes, 0, (bytes.Length)); r.BaseStream.Position = 0; GraphPage page = new GraphPage(); while (r.BaseStream.Position < r.BaseStream.Length) { page.Add( r.ReadInt32(), r.ReadInt32(), r.ReadInt32(), r.ReadDouble()); } return(page); }
public static List <int> CoordinatesOfPointss(GraphPage page, IWebElement element, int step) { var exactpoints = element.GetAttribute("d"); exactpoints = Regex.Replace(exactpoints, "\\.", ","); exactpoints = Regex.Replace(exactpoints, "\\s[A-Z]\\s", " "); exactpoints = Regex.Replace(exactpoints, "[A-Z]\\s", ""); var arr = exactpoints.Split(' '); List <int> list = new List <int>(); for (int i = 0; i < arr.Length; i += 2) { double result; Double.TryParse(arr[i], out result); list.Add(Convert.ToInt32(result)); } return(list); }
/// <summary>Creates the graph page.</summary> /// <param name="section">The section to write to.</param> /// <param name="graphPage">The graph and table to convert to html.</param> /// <param name="workingDirectory">The working directory.</param> private void CreateGraphPage(Section section, GraphPage graphPage, string workingDirectory) { int numColumns = 2; int numRows = 3; // Export graph to bitmap file. Bitmap image = new Bitmap(700, 850); GraphPresenter graphPresenter = new GraphPresenter(); GraphView graphView = new GraphView(); graphView.BackColor = System.Drawing.Color.White; graphView.FontSize = 10; graphView.MarkerSize = 4; graphView.Width = image.Width / numColumns; graphView.Height = image.Height / numRows; int col = 0; int row = 0; for (int i = 0; i < graphPage.graphs.Count; i++) { if (graphPage.graphs[i].IncludeInDocumentation) { graphPresenter.Attach(graphPage.graphs[i], graphView, ExplorerPresenter); Rectangle r = new Rectangle(col * graphView.Width, row * graphView.Height, graphView.Width, graphView.Height); graphView.Export(image, r, false); graphPresenter.Detach(); col++; if (col >= numColumns) { col = 0; row++; } } } string PNGFileName = Path.Combine(workingDirectory, graphPage.name + ".png"); image.Save(PNGFileName, System.Drawing.Imaging.ImageFormat.Png); section.AddImage(PNGFileName); }
public void EnsureGraphsAreWrittenToNewParagraph() { // Create a paragraph with some text. document.LastSection.AddParagraph("paragraph content"); // Render the graph page - should not go into previous paragraph. GraphPage page = new GraphPage(new[] { graph }); renderer.Render(page, pdfBuilder); // There should be two paragraphs. Assert.AreEqual(2, document.LastSection.Elements.Count); // Let's also double check that the image was added correctly. Paragraph graphsParagraph = (Paragraph)document.LastSection.Elements[1]; MigraDocImage actual = (MigraDocImage)graphsParagraph.Elements[0]; AssertEqual(image, actual); }
public void EnsureSubsequentContentGoesToNewParagraph() { // Render the graph page. GraphPage page = new GraphPage(new[] { graph }); renderer.Render(page, pdfBuilder); // Create a paragraph with some text. pdfBuilder.AppendText("paragraph content", TextStyle.Normal); // There should be two paragraphs. Assert.AreEqual(2, document.LastSection.Elements.Count); // Let's also double check that the image was added correctly. Paragraph graphsParagraph = (Paragraph)document.LastSection.Elements[0]; MigraDocImage actual = (MigraDocImage)graphsParagraph.Elements[0]; AssertEqual(image, actual); }
public void TestGraphOfEmployees() { GraphPage page = new GraphPage(driver); List <int[]> list = GraphActions.CoordinatesOfPoints(page, page.PointsOfGraphEmployees, 4); page.OpenCloseGraphs[2].Click(); page.OpenCloseGraphs[0].Click(); GraphActions.MoveToPosition(page.Graphs, driver); GraphActions.MoveToPosition(0, list[0][1], driver); GraphActions.MoveToPosition(list[0][0], 0, driver); for (int i = 0; i < list.Count - 1; i++) { int offsetx = list[i + 1][0] - list[i][0]; int offsety = list[i + 1][1] - list[i][1]; GraphActions.MoveToPosition(0, offsety, driver); var CountOfEmployees = GraphActions.TextFromTspan(page, driver, "employees"); GraphActions.MoveToPosition(offsetx, 0, driver); GraphStates.CheckPositionOfPoints(page, CountOfEmployees, list[i][1]); } }
public void TestGraphSizing() { Mock <IGraphExporter> mockExporter = new Mock <IGraphExporter>(); mockExporter.Setup(e => e.Export(It.IsAny <IPlotModel>(), It.IsAny <double>(), It.IsAny <double>())).Returns((IPlotModel plot, double width, double height) => { // This should be 1/2 page width and 1/3 page height in px. // fixme: this isn't really the best way to verify this but it'll do for now. Assert.AreEqual(302.362204724, width, 1e-2); Assert.AreEqual(317.4803405921916, height, 1e-2); return(image); }); IGraphExporter exporter = mockExporter.Object; renderer = new GraphPageTagRenderer(exporter); GraphPage page = new GraphPage(new[] { graph }); renderer.Render(page, pdfBuilder); }
private GraphPage LoadGraphPage(int page) { lock (_thisLock) { if (_graphPages.ContainsKey(page)) { return(_graphPages[page]); } if (_dbfactory != null) { try { using (DbConnection connection = _dbfactory.CreateConnection()) { connection.ConnectionString = _connectionString; DbCommand command = _dbfactory.CreateCommand(); command.Connection = connection; command.CommandText = "SELECT " + _dbNames.DbColName("Data") + " FROM " + _graphTableName + " WHERE " + _dbNames.DbColName("Page") + "=" + page; connection.Open(); DbDataReader reader = command.ExecuteReader(); if (reader.Read()) { object obj = reader.GetValue(0); GraphPage newGraphPage = NetworkObjectSerializer.DeserializeGraph((byte[])obj); _graphPages.Add(page, newGraphPage); connection.Close(); return(newGraphPage); } connection.Close(); } } catch { } } return(null); } }
public void BVT_Graph_S01_TC08_CanLoadGraphPageImages() { //Currently ignore Graph explorer and Documentation, since these pages don't have banner image //Graph branding image string[] navOptions = new string[] { "Home", "Get started", "Documentation", //"Graph explorer", //"App registration", "Samples & SDKs"}; foreach (string navPage in navOptions) { GraphPages.Navigation.Select(navPage); if (GraphUtility.BrowserType == "IE32") { GraphBrowser.Wait(TimeSpan.FromSeconds(3)); } if (navPage == "Home") { foreach (GraphPageImages item in Enum.GetValues(typeof(GraphPageImages))) { Assert.IsTrue(GraphPages.HomePage.CanLoadImages(item)); } } else { var graphPage = new GraphPage(); foreach (GraphPageImages item in Enum.GetValues(typeof(GraphPageImages))) { //No pages except Home have a banner image anymore if (!item.ToString().Equals("MainBanner")) { Assert.IsTrue(graphPage.CanLoadImages(item)); } } } } }
static void Main() { Handle.GET("/ProcurementStats", () => { MasterPage master; if (Session.Current != null && Session.Current.Data != null) { master = (MasterPage)Session.Current.Data; } else { master = new MasterPage(); if (Session.Current != null) { master.Html = "/ProcurementStats/viewmodels/LauncherWrapperPage.html"; master.Session = Session.Current; } else { master.Html = "/ProcurementStats/viewmodels/MasterPage.html"; master.Session = new Session(SessionOptions.PatchVersioning); } master.RecentGraphs = new GraphsPage() { Html = "/ProcurementStats/viewmodels/GraphsPage.html" }; } ((GraphsPage)master.RecentGraphs).RefreshData(); master.FocusedGraph = null; return master; }); Handle.GET("/ProcurementStats/NewGraph", () => { MasterPage master = Self.GET<MasterPage>("/ProcurementStats"); master.FocusedGraph = Db.Scope<GraphPage>(() => { GraphPage page = new GraphPage() { Html = "/ProcurementStats/viewmodels/GraphPage.html", Data = new Simplified.Ring6.ProcurementGraph() { DateTo = DateTime.Now.Date, DateFrom = DateTime.Now.AddMonths(-1).Date } }; page.Saved += (s, a) => { ((GraphsPage)master.RecentGraphs).RefreshData(); }; page.Deleted += (s, a) => { ((GraphsPage)master.RecentGraphs).RefreshData(); }; return page; }); return master; }); Handle.GET("/ProcurementStats/Details/{?}", (string Key) => { MasterPage master = Self.GET<MasterPage>("/ProcurementStats"); master.FocusedGraph = Db.Scope<GraphPage>(() => { var page = new GraphPage() { Html = "/ProcurementStats/viewmodels/GraphPage.html", Data = Db.SQL<Simplified.Ring6.ProcurementGraph>(@"SELECT i FROM Simplified.Ring6.ProcurementGraph i WHERE Key = ?", Key).First }; page.Saved += (s, a) => { ((GraphsPage)master.RecentGraphs).RefreshData(); }; page.Deleted += (s, a) => { ((GraphsPage)master.RecentGraphs).RefreshData(); }; page.RequestGraph(); return page; }); return master; }); //Handle.GET("/ProcurementStats/Only/{?}", (string Key) => { // GraphPage page = new GraphPage() { // Html = "/ProcurementStats/viewmodels/GraphPage.html", // Data = Db.SQL<Simplified.Ring6.ProcurementGraph>(@"SELECT i FROM Simplified.Ring6.ProcurementGraph i WHERE i.Key = ?", Key).First // }; // return page; //}); Handle.GET("/ProcurementStats/menu", () => { return new Page() { Html = "/ProcurementStats/viewmodels/AppMenuPage.html" }; }); Handle.GET("/ProcurementStats/app-name", () => { return new AppName(); }); UriMapping.Map("/ProcurementStats/app-name", UriMapping.MappingUriPrefix + "/app-name"); UriMapping.Map("/ProcurementStats/menu", UriMapping.MappingUriPrefix + "/menu"); }