public IEnumerable <RenderElement> Build(Position nodePosition, GraphConfig config) { var padding = new Position(config.ContentPadding.Left, config.ContentPadding.Top); var nextLinePosition = nodePosition + padding; var currentLinePosition = nextLinePosition; foreach (var nodeElement in config.Elements) { if (nodeElement.NextLine) { nextLinePosition += nodeElement.Offset; currentLinePosition = nextLinePosition; nextLinePosition = new Position(nextLinePosition.X, nextLinePosition.Y + nodeElement.Dimensions.Height); } else { currentLinePosition += nodeElement.Offset; } var dimensions = nodeElement.Dimensions; if (nodeElement.StretchHorizontal) { var offsetFromLeft = currentLinePosition.X - nodePosition.X; var availableWidth = config.Dimensions.Width - config.ContentPadding.Right; dimensions = new Dimensions(availableWidth - offsetFromLeft, dimensions.Height); } yield return(new RenderElement(currentLinePosition, dimensions)); currentLinePosition = new Position(currentLinePosition.X + dimensions.Width, currentLinePosition.Y); } }
public Graph RenderGraph(GraphConfig config) { _config = config; _graph = new Graph(); _edges.Clear(); _nodes.Clear(); foreach (var nodeFamily in _config.Nodes) { void NodeAddition(GraphElementFamily <INodeProperty> family, Identifier identifier) => AddNode(identifier); ProcessGraphElementFamily(nodeFamily, NodeAddition, ApplyNodeProperty); } foreach (var edgeFamily in _config.Edges) { void EdgeAddition(GraphElementFamily <IEdgeProperty> family, Identifier identifier) => AddEdge(family as EdgeFamily, identifier); ProcessGraphElementFamily(edgeFamily, EdgeAddition, ApplyEdgeProperty); } _debuggerOperations.WriteDebugOutput(); _debuggerOperations.Reset(); return(_graph); }
private void CreateConfig() { NodeFamily nodes = new NodeFamily( new List <IdentifierPartTemplate>() { new IdentifierPartTemplate("v", "0", "n") } ); EdgeFamily edges = new EdgeFamily( new List <IdentifierPartTemplate> { new IdentifierPartTemplate("a", "0", "n"), new IdentifierPartTemplate("b", "0", "n"), new IdentifierPartTemplate("x", "0", "n") }, new EdgeFamily.EdgeEnd(nodes, new List <string> { "__a__" }), new EdgeFamily.EdgeEnd(nodes, new List <string> { "__b__" }) ) { ValidationTemplate = "g[__a__][__x__] == __b__", IsDirected = true }; _config = new GraphConfig { Edges = new HashSet <EdgeFamily> { edges }, Nodes = new HashSet <NodeFamily> { nodes } }; }
public GraphRenderer(GraphConfig config, Debugger debugger) { _config = config; _debugger = debugger; _graph = new Graph(); _edges = new Dictionary <string, Edge>(); }
public Task <RenderGraph> Analyze(PlacementGraph graph, GraphConfig config) { _config = config ?? throw new ArgumentNullException(nameof(config)); var nodes = graph.Nodes.Select(CreateNode); var edges = CreateEdges(graph.Edges); return(Task.FromResult(new RenderGraph(nodes.ToList(), edges.ToList()))); }
public void DetermineNewFrequencyRange(int x, ref Int64 Low, ref Int64 High, ref int SampleCount) { Int64 nCentralFrequency; Int64 nPreviousBW; Int64 nNewStartFrequency; Int64 nNewEndFrequency; nCentralFrequency = GraphConfig.GetFrequencyFromXDisplay(x); nPreviousBW = GraphConfig.nLastDrawingHighFrequency - GraphConfig.nLastDrawingLowFrequency; if (nPreviousBW < 100) { return; } nNewStartFrequency = nCentralFrequency - (Int64)(nPreviousBW * fZoomInRatio * 0.5f); nNewEndFrequency = nCentralFrequency + (Int64)(nPreviousBW * fZoomInRatio * 0.5f); // now we correct the zoom to take acount of discrete frequency step SampleCount = Owner.GetSampleCount(); Int64 nBW = (nNewEndFrequency - nNewStartFrequency); Int64 nRealStep; if (SampleCount > nBW) { SampleCount = (int)nBW; nRealStep = 1; } else { nRealStep = ((nNewEndFrequency - nNewStartFrequency) + SampleCount / 2) / SampleCount; } nNewStartFrequency = nCentralFrequency - nRealStep * SampleCount / 2; nNewEndFrequency = nNewStartFrequency + nRealStep * SampleCount; if (nNewEndFrequency > Owner.DeviceInterface.MaxFrequency) { nNewEndFrequency = Owner.DeviceInterface.MaxFrequency; } if (nNewStartFrequency < Owner.DeviceInterface.MinFrequency) { nNewStartFrequency = Owner.DeviceInterface.MinFrequency; } Low = nNewStartFrequency; High = nNewEndFrequency; }
private async Task AnalyzeGraph() { _showingTypesSelector.BitMask = _analyzeTypesSelector.BitMask; var tasks = await TaskManager.GetAll(); var config = new GraphConfig { ReferenceTypes = _analyzeTypesSelector.BitMask }; _graph = await Analyzer.Analyze(tasks, config); await RenderGraph(); }
public void DisplayFrequencyAndLevelOnCorners(int nXMouse) { Int64 nFrequency = GraphConfig.GetFrequencyFromXDisplay(nXMouse); double dBLevel; String LevelText = null; if (CurvesList.Count > 0 && ActiveCurve != null && ActiveCurve.Visible == CCurve.YesNo.Yes) { dBLevel = Math.Round(ActiveCurve.GeDBLevelFromFrequency(nFrequency), 2); LevelDisplayLabel.ForeColor = ActiveCurve.Color_; LevelText = ActiveCurve.Name + " : "; } else { dBLevel = 0.0f; LevelDisplayLabel.ForeColor = Color.Black; LevelText = "Level : "; } double ImpedanceNorm = (100.0f / ((float)Math.Pow(10.0f, dBLevel / 20.0f)) - 100.0f) / 1.0f; FreqDisplayLabel.Text = "Frequency : " + Utility.GetStringWithSeparators(nFrequency, " ") + "Hz"; if (GraphConfig.outputMode == OutputMode.dB) { if (ImpedanceNorm >= 0) { LevelDisplayLabel.Text = LevelText + dBLevel.ToString() + "dB " + " |Z|=" + Math.Round(ImpedanceNorm, 0) + " Ohms"; } else { LevelDisplayLabel.Text = LevelText + dBLevel.ToString() + "dB "; } } else { LevelDisplayLabel.Text = LevelText + dBLevel.ToString(); } GraphConfig.DrawTopBox(CurvesList, nFrequency); }
static void Main(string[] args) { IConfiguration config = new ConfigurationBuilder().AddJsonFile("appsettings.json", true, true).Build(); var endpoint = config["GraphConnectionEndPoint"]; var primaryKey = config["GraphConnectionPrimaryKey"]; var database = config["GraphConnectionDatabase"]; var collection = config["GraphConnectionCollection"]; GraphConfig.SetGraphDataBaseConnection(endpoint, primaryKey, database, collection); CVGenerator generator = new CVGenerator(); generator.ProcessCV(args[0]); Console.WriteLine("Convertion finalisée"); Console.WriteLine("Appuyer sur un bouton pour sortir"); Console.ReadKey(); }
public void Instantiate_GraphConnectionString_GraphExecutionEngine() { var config = new GraphConfig(); var clientProvider = new ClientProvider(config); var commandProvider = new CommandProvider(config); var factory = new ExecutionEngineFactory(clientProvider, commandProvider, config); var query = Mock.Of <IQuery> ( x => x.ConnectionString == $"Endpoint=https://xyz.documents.azure.com:443;AuthKey={base64AuthKey};database=db;graph=FoF" && x.Statement == "g.V().Count()" ); var engine = factory.Instantiate(query); Assert.That(engine, Is.Not.Null); Assert.That(engine, Is.TypeOf <GraphExecutionEngine>()); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddDbContext <ApplicationDbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection"))); endpoint = Configuration.GetSection("GraphConnectionEndPoint").Value; primaryKey = Configuration.GetSection("GraphConnectionPrimaryKey").Value; database = Configuration.GetSection("GraphConnectionDatabase").Value; collection = Configuration.GetSection("GraphConnectionCollection").Value; GraphConfig.SetGraphDataBaseConnection(endpoint, primaryKey, database, collection); services = TokenConfigurations(services); services.AddIdentity <ApplicationUser, ApplicationRole>() .AddEntityFrameworkStores <ApplicationDbContext>() .AddDefaultTokenProviders(); services.ConfigureApplicationCookie(options => { options.Cookie.HttpOnly = true; options.ExpireTimeSpan = TimeSpan.FromMinutes(30); options.LoginPath = "/Account/Login"; options.AccessDeniedPath = "/Account/AccessDenied"; options.SlidingExpiration = true; }); services.AddCors(); services.AddMvc(); services.AddTransient <IEmailSender, EmailSender>(); services.AddSingleton(Configuration); services.AddSingleton <IEmailSender, EmailSender>(); services.Configure <AuthMessageSenderOptions>(Configuration); services.AddDistributedMemoryCache(); services.AddSession(options => { // Set a short timeout for easy testing. options.IdleTimeout = TimeSpan.FromSeconds(10); options.Cookie.HttpOnly = true; }); }
public Task <AbstractGraph> Analyze(IEnumerable <Todo> tasks, GraphConfig config) { _tasks = tasks ?? throw new ArgumentNullException(nameof(tasks)); _config = config ?? throw new ArgumentNullException(nameof(config)); var notVisited = tasks.ToHashSet(); if (!notVisited.Any()) { return(Task.FromResult(new AbstractGraph())); } _nodes = new HashSet <AbstractNode>(); _roots = new HashSet <AbstractNode>(); AnalyzeUnvisited(notVisited); RemoveOneNodeGraphs(); return(Task.FromResult(new AbstractGraph(_roots.ToList()))); }
public void CreateGraphConfigForDfs() { NodeFamily nodes = new NodeFamily( new List <IdentifierPartTemplate> { new IdentifierPartTemplate("v", "0", "n") }); var dfsNode = System.Tuple.Create( new Condition("\"__CURRENT_FUNCTION__\" == \"dfs\" && __ARG1__ == __v__"), (INodeProperty) new FillColorNodeProperty(Color.Red)); nodes.Properties.Add(dfsNode); EdgeFamily edges = new EdgeFamily( new List <IdentifierPartTemplate> { new IdentifierPartTemplate("a", "0", "n"), new IdentifierPartTemplate("b", "0", "n"), new IdentifierPartTemplate("x", "0", "g[__a__].size()") }, new EdgeFamily.EdgeEnd(nodes, new List <string> { "__a__" }), new EdgeFamily.EdgeEnd(nodes, new List <string> { "__b__" })) { ValidationTemplate = "__a__ < __b__ && g[__a__][__x__] == __b__" }; var dfsEdges = Tuple.Create(new Condition("p[__a__] == __b__ || p[__b__] == __a__"), (IEdgeProperty) new LineColorEdgeProperty(Color.Red)); edges.Properties.Add(dfsEdges); GraphConfig config = new GraphConfig { Edges = new HashSet <EdgeFamily> { edges }, Nodes = new HashSet <NodeFamily> { nodes } }; }
public void FromConfig(GraphConfig config) { var nodeWindows = config.Nodes.Select(n => { var w = new NodeFamilyWindow(); w.FromNodeFamily(n); return((Window)w); }).ToList(); Nodes.SetNewWindows(nodeWindows); var edgeWindows = config.Edges.Select(e => { var w = new EdgeFamilyWindow(Nodes.Windows.Cast <NodeFamilyWindow>().ToList()); w.FromEdgeFamily(e); return((Window)w); }).ToList(); Edges.SetNewWindows(edgeWindows); }
public ActionResult CreateCohortGraph(CohortGraphRequestModel userRequest) { var subForm = userRequest.SubForm; var graphConfig = new GraphConfig() { GraphName = userRequest.Title, SafeMode = userRequest.SafeMode, Type = GraphType.Cohort, Prefix = userRequest.Prefix, Subform = System.Web.Helpers.Json.Encode(userRequest.SubForm), MaxYAxis = userRequest.MaxYAxis, CohortConfig = new CohortConfig() { IntervalList = CohortHelper.GetCohortPreviousMagnitudeList(subForm.Previous, subForm.CustomDay), IntervalUnitName = IntervalHelper.GetIntervalUnitFromString(subForm.Show).ToString(), MinutesInUnit = CohortHelper.GetMinutesInIntervalUnit(IntervalHelper.GetIntervalUnitFromString(subForm.Show)) } }; var dataSources = this.GetDataSources(userRequest); foreach (var source in dataSources) { graphConfig.DataSets.Add(new DataSetConfig() { Data = source, Resolution = (int) IntervalHelper.GetResolutionFromString( (subForm.DataInterval)), Offset = 0, IntervalLength = CohortHelper.GetCohortIntervalLengthInMinutes( subForm.Previous, userRequest.SubForm.Show, subForm.CustomDay), }); } return Json(graphConfig,JsonRequestBehavior.AllowGet); }
void DisplayZoomBox(int nX) { Int64 Low = -1; Int64 High = -1; int SampleCount = -1; DetermineNewFrequencyRange(nX, ref Low, ref High, ref SampleCount); int X1 = GraphConfig.GetXFromFrequency(Low); int X2 = GraphConfig.GetXFromFrequency(High); if (X1 < GraphConfig.LeftBorder) { X1 = GraphConfig.LeftBorder; } if (X2 > Size.Width - GraphConfig.RightBorder) { X2 = Size.Width - GraphConfig.RightBorder; } int nWidh = X2 - X1; HUDGraphics.Clear(Color.Transparent); Brush brush = new SolidBrush(Color.FromArgb(10, 255, 0, 0)); //Brush brushText = new SolidBrush(Color.FromArgb(10, 255, 0, 0)); HUDGraphics.FillRectangle(brush, X1, GraphConfig.UpBorder, nWidh, Size.Height - GraphConfig.LowBorder - GraphConfig.UpBorder); Pen RecPen = new Pen(Color.FromArgb(100, 255, 0, 0), 2); HUDGraphics.DrawRectangle(RecPen, X1, GraphConfig.UpBorder, nWidh, Size.Height - GraphConfig.LowBorder - GraphConfig.UpBorder); //HUDGraphics.DrawString("F1 & F2 to ajust size", new Font(FontFamily.GenericMonospace, 10), brushText, new PointF(X1, Size.Height - GraphConfig.LowBorder-20)); //ForeGroundImageGraphics. this.Invalidate(); //ImageUpdate(); }
public GraphConfig ProcessGraph(bool withCriticalPath, Schedule upperResult, Schedule lowerResult) { GraphConfig upwardGraph = null; GraphConfig downwardGraph = null; List <Series> allSeries = new List <Series>(); if (upperResult != null) { upwardGraph = BuildConfig().AddActivities(upperResult.Activities); if (withCriticalPath) { upwardGraph.AddCriticalPath(upperResult.CriticalPath.ActivityDirections) .AddProjectBuff(upperResult.CriticalPath.ProjectBuffer) .AddFeedingBuffers(upperResult.FeedingBuffers); } allSeries = upwardGraph.series.ToList(); } if (lowerResult != null) { downwardGraph = BuildConfig().AddActivities(lowerResult.Activities); if (withCriticalPath) { downwardGraph.AddCriticalPath(lowerResult.CriticalPath.ActivityDirections) .AddProjectBuff(lowerResult.CriticalPath.ProjectBuffer) .AddFeedingBuffers(lowerResult.FeedingBuffers); } foreach (var serie in downwardGraph.series) { serie.data.ToList().ForEach(d => d[1] = d[1] * -1); allSeries.Add(serie); } } if (upwardGraph != null) { upwardGraph.series = allSeries.ToArray(); } return(upwardGraph); }
public Task <PlacementGraph> Analyze(AbstractGraph abstractGraph, GraphConfig config) { _abstractGraph = abstractGraph ?? throw new ArgumentNullException(nameof(abstractGraph)); _config = config ?? throw new ArgumentNullException(nameof(config)); if (abstractGraph.Roots.Count == 0) { return(Task.FromResult(new PlacementGraph())); } _nextGraphRow = 0; _graph = new PlacementGraph(); _placedTasks = new HashSet <Todo>(); foreach (var root in _abstractGraph.Roots) { AddGraph(root); } return(Task.FromResult(_graph)); }
void DisplayZoomBox(int nX) { Int64 Low = -1; Int64 High = -1; int SampleCount = -1; DetermineNewFrequencyRange(nX, ref Low, ref High, ref SampleCount); int X1 = GraphConfig.GetXFromFrequency(Low); int X2 = GraphConfig.GetXFromFrequency(High); if (X1 < GraphConfig.LeftBorder) { X1 = GraphConfig.LeftBorder; } if (X2 > Size.Width - GraphConfig.RightBorder) { X2 = Size.Width - GraphConfig.RightBorder; } int nWidh = X2 - X1; ForeGroundImageGraphics.Clear(Color.Transparent); Brush brush = new SolidBrush(Color.FromArgb(50, 255, 0, 0)); //Brush brushText = new SolidBrush(Color.FromArgb(50, 255, 0, 0)); ForeGroundImageGraphics.FillRectangle(brush, X1, GraphConfig.UpBorder, nWidh, Size.Height - GraphConfig.LowBorder - GraphConfig.UpBorder); //ForeGroundImageGraphics.DrawString("F1 & F2 to ajust size", new Font("Arial", 10), brushText, new PointF(X1, Size.Height - GraphConfig.LowBorder)); //ForeGroundImageGraphics. Image = ForeGroundImageBitmap; }
public void DrawCurveCollection(ArrayList Curves, bool bLoopMode = false) { CurvesList = Curves; int nUpperScale = 10; int nLowerScale = -90; GraphConfig.outputMode = OutputMode.dB; if (HUDBitmap == null) { BitmapUpdate(this.Size); ImageUpdate(); } if (CurvesList.Count > 0 && Owner != null && Owner.GetOutputMode() == OutputMode.dB) { float fMax = CurvesRetrieveMaximumScale(); if (fMax != Single.MinValue) { nUpperScale = (int)(fMax + 10.0f); nUpperScale /= 10; nUpperScale *= 10; } float fMin = CurvesRetrieveMinimumScale(); if (fMin != Single.MaxValue) { nLowerScale = (int)(fMin - 10.0f); nLowerScale /= 10; nLowerScale *= 10; } if (bLoopMode) { if (GraphConfig.fLastDrawingLevelHigh - nUpperScale <= 20 && GraphConfig.fLastDrawingLevelHigh - nUpperScale > 0) { nUpperScale = (int)GraphConfig.fLastDrawingLevelHigh; } if (nLowerScale - GraphConfig.fLastDrawingLevelLow <= 20 && nLowerScale - GraphConfig.fLastDrawingLevelLow > 0) { nLowerScale = (int)GraphConfig.fLastDrawingLevelLow; } } } else { if (Owner != null) { GraphConfig.outputMode = Owner.GetOutputMode(); switch (GraphConfig.outputMode) { case OutputMode.SWR_3: nUpperScale = 3; break; case OutputMode.SWR_6: nUpperScale = 6; break; case OutputMode.SWR_10: nUpperScale = 10; break; } nLowerScale = 1; } } GraphConfig.fLastDrawingLevelLow = nLowerScale; GraphConfig.fLastDrawingLevelHigh = nUpperScale; GraphConfig.GraphicDisplay(Curves, ActiveCurve, GraphicAndCurvesBitmap); ImageUpdate(); }
public void SpectrumPictureBox_MouseLeave(object sender, EventArgs e) { GraphConfig.DrawTopBox(CurvesList); // to redraw only curve names HUDGraphics.Clear(Color.Transparent); ImageUpdate(); }
public MessagesController(GraphConfig config) { this.config = config; }
private void SpectrumPictureBoxClass_MouseClick(object sender, MouseEventArgs e) { if (Owner.DeviceInterface.GetDevice() == null) { return; // no device } MouseEventArgs Event = (MouseEventArgs)e; { Int64 nCentralFrequency; Int64 nPreviousBW; Int64 nNewStartFrequency; Int64 nNewEndFrequency; nCentralFrequency = GraphConfig.GetFrequencyFromXDisplay(Event.X); nPreviousBW = GraphConfig.nLastDrawingHighFrequency - GraphConfig.nLastDrawingLowFrequency; if (Event.Button == MouseButtons.Left) { if (nPreviousBW < 100) { return; } nNewStartFrequency = nCentralFrequency - (Int64)(nPreviousBW * fZoomInRatio * 0.5f); nNewEndFrequency = nCentralFrequency + (Int64)(nPreviousBW * fZoomInRatio * 0.5f); } else { nNewStartFrequency = nCentralFrequency - nPreviousBW; nNewEndFrequency = nCentralFrequency + nPreviousBW; } // now we correct the zoom to take acount of discrete frequency step int nSampleCount = Owner.GetSampleCount(); Int64 nBW = (nNewEndFrequency - nNewStartFrequency); Int64 nRealStep; if (nSampleCount > nBW) { nSampleCount = (int)nBW; Owner.SetSampleCount(nSampleCount); nRealStep = 1; } else { nRealStep = ((nNewEndFrequency - nNewStartFrequency) + nSampleCount / 2) / nSampleCount; } nNewStartFrequency = nCentralFrequency - nRealStep * nSampleCount / 2; nNewEndFrequency = nNewStartFrequency + nRealStep * nSampleCount; if (nNewEndFrequency > Owner.DeviceInterface.MaxFrequency) { nNewEndFrequency = Owner.DeviceInterface.MaxFrequency; } if (nNewStartFrequency < Owner.DeviceInterface.MinFrequency) { nNewStartFrequency = Owner.DeviceInterface.MinFrequency; } GraphConfig.nLastDrawingLowFrequency = nNewStartFrequency; GraphConfig.nLastDrawingHighFrequency = nNewEndFrequency; DrawCurveCollection(CurvesList); Owner.SetSweepStartFrequency(nNewStartFrequency); Owner.SetSweepEndFrequency(nNewEndFrequency); } }
public ActionResult CreateLineGraph(LineGraphRequestModel userRequest) { var graphConfig = new GraphConfig() { GraphName = userRequest.Title, SafeMode = userRequest.SafeMode, Type = GraphType.Line, Prefix = userRequest.Prefix, Subform = System.Web.Helpers.Json.Encode(userRequest.SubForm), MaxYAxis = userRequest.MaxYAxis }; var dataSources = this.GetDataSources(userRequest); foreach (var source in dataSources) { graphConfig.DataSets.Add(new DataSetConfig() { Data = source, Offset = 0, Resolution = (int) IntervalHelper.GetResolutionFromString( userRequest.SubForm.DataInterval), IntervalLength = IntervalHelper.GetLineInterval(userRequest.SubForm.HistoricalRange) }); } return Json(graphConfig, JsonRequestBehavior.AllowGet); }
public ActionResult CreateRatioGraph(RatioGraphRequestModel userRequest) { var graphConfig = new GraphConfig() { GraphName = userRequest.Title, SafeMode = userRequest.SafeMode, Type = GraphType.Ratio, Prefix = userRequest.Prefix, Subform = System.Web.Helpers.Json.Encode(userRequest.SubForm), RatioConfig = new RatioConfig() { CompareNumber = userRequest.SubForm.CompareNumber, CompareUnit = userRequest.SubForm.CompareUnit, CustomDay = userRequest.SubForm.CustomDay, HistoricalRange = userRequest.SubForm.HistoricalRange } }; var subForm = userRequest.SubForm; var dataSources = this.GetDataSources(userRequest); foreach (var source in dataSources) { graphConfig.DataSets.AddRange(RatioHelper.GetRatioDataSets(source, subForm.HistoricalRange, subForm.CompareNumber, subForm.CompareUnit, subForm.CustomDay)); } return Json(graphConfig, JsonRequestBehavior.AllowGet); }