public ErrorsForm(GraphControl graph) { // // Required for Windows Form Designer support // InitializeComponent(); this.graph = graph; }
public LibraryForm(GraphControl graph, MainForm main) { // // Required for Windows Form Designer support // InitializeComponent(); this.graph = graph; this.main = main; errForm = new ErrorsForm(graph); }
public CompilerOptionsForm(GraphControl graph) { // // Required for Windows Form Designer support // InitializeComponent(); this.graph = graph; importForm = new ImportForm(graph); warnings.DropDownStyle = ComboBoxStyle.DropDownList; }
/// <summary> /// This method is called to print an individual page. /// </summary> protected override void OnPrintPage(System.Drawing.Printing.PrintPageEventArgs e) { GraphControl printControl = new GraphControl(); Rectangle b = e.MarginBounds, clip; Graphics g = e.Graphics; g.TranslateTransform(b.X, b.Y, MatrixOrder.Append); clip = new Rectangle(0, 0, b.Width, b.Height); g.SetClip(clip); printControl.Bounds = b; printControl.SetRange(printControl.x0, printControl.x1, printControl.y0, printControl.y1); printControl.Model = model; printControl.AsyncDraw = false; g.SmoothingMode = SmoothingMode.HighQuality; printControl.PaintGraph(g); printControl.Dispose(); }
public RangeForm(GraphControl graph) { // // Required for Windows Form Designer support // InitializeComponent(); this.graph = graph; x0TextBox.KeyPress += new KeyPressEventHandler(numberKeyPress); y0TextBox.KeyPress += new KeyPressEventHandler(numberKeyPress); x1TextBox.KeyPress += new KeyPressEventHandler(numberKeyPress); y1TextBox.KeyPress += new KeyPressEventHandler(numberKeyPress); z0TextBox.KeyPress += new KeyPressEventHandler(numberKeyPress); z1TextBox.KeyPress += new KeyPressEventHandler(numberKeyPress); }
public FitForm(GraphControl graph) { // // Required for Windows Form Designer support // InitializeComponent(); this.graph = graph; parForm = new ParForm(); covarForm = new CovarianceForm(); data.DropDownStyle = ComboBoxStyle.DropDownList; function.DropDownStyle = ComboBoxStyle.DropDownList; fit = new FPlotFit.Fit(); fit.Step += new FPlotFit.StepEventHandler(Step); invoke = new StepInvokeHandler(StepInvoke); }
public ImageForm(GraphControl graph) { // // Required for Windows Form Designer support // InitializeComponent(); this.graph = graph; this.picture = new ImageControl(); this.picture.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.picture.Location = new System.Drawing.Point(0, 35); this.picture.Name = "picture"; this.picture.Size = new System.Drawing.Size(440, 210); this.picture.TabIndex = 3; this.picture.TabStop = false; this.Controls.Add(this.picture); }
public SourceForm(GraphControl graph, FunctionItem old, MainForm mainform) { // // Required for Windows Form Designer support // InitializeComponent(); this.graph = graph; parForm = new ParForm(); paritem = new FunctionItem(); oldItem = old; this.mainform = mainform; lineStyle.DropDownStyle = ComboBoxStyle.DropDownList; for (DashStyle s = DashStyle.Solid; s < DashStyle.Custom; s++) { lineStyle.Items.Add(s.ToString()); } lineStyle.SelectedIndex = 0; }
/// <summary> /// Automatically generated by Visual Studio. /// Wires up the UI components and adds a /// <see cref="GraphControl"/> to the form. /// </summary> public GraphClipboardForm() { InitializeComponent(); description.LoadFile(new MemoryStream(Resources.description), RichTextBoxStreamType.RichText); // set focusedGraphControl to currently focused graphcontrol tabControl.SelectedIndexChanged += delegate(object sender, EventArgs args) { focusedGraphControl = tabControl.SelectedIndex == 0 ? graphControl : graphControl2; focusedGraphControl.Select(); }; // initialize the focuesed control focusedGraphControl = tabControl.SelectedIndex == 0 ? graphControl : graphControl2; // Enable loading and saving graphControl.FileOperationsEnabled = true; graphControl2.FileOperationsEnabled = true; // register edit commands on (focused) graphcontrol cutButton.Click += (sender, args) => Commands.Cut.Execute(null, FocusedGraphControl); copyButton.Click += (s, args) => Commands.Copy.Execute(null, FocusedGraphControl); pasteButton.Click += (s, args) => Commands.Paste.Execute(null, FocusedGraphControl); pasteSpecialButton.Click += (s, args) => PasteSpecialCommand.Execute(null, FocusedGraphControl); cutToolStripMenuItem.Click += (sender, args) => Commands.Cut.Execute(null, FocusedGraphControl); copyToolStripMenuItem.Click += (s, args) => Commands.Copy.Execute(null, FocusedGraphControl); pasteToolStripMenuItem.Click += (s, args) => Commands.Paste.Execute(null, FocusedGraphControl); pasteSpecialToolStripMenuItem.Click += (s, args) => PasteSpecialCommand.Execute(null, FocusedGraphControl); OpenMenuItem.Click += (sender, args) => Commands.Open.Execute(null, FocusedGraphControl); SaveMenuItem.Click += (sender, args) => Commands.Save.Execute(null, FocusedGraphControl); // switch on navigation commands graphControl.NavigationCommandsEnabled = true; graphControl2.NavigationCommandsEnabled = true; // register navigation commands on (focused) graphcontrol zoomInButton.Click += (sender, args) => Commands.IncreaseZoom.Execute(null, FocusedGraphControl); zoomOutButton.Click += (sender, args) => Commands.DecreaseZoom.Execute(null, FocusedGraphControl); fitContentButton.Click += (sender, args) => Commands.FitContent.Execute(null, FocusedGraphControl); }
public IEnumerable <CurveItem> SetErrorGraphItems(IEnumerable <IMSGraphItemInfo> errorItems) { var curveItems = new List <CurveItem>(); SetDisplayState(new ErrorDisplayState()); var pane = _displayState.GetOrCreateGraphPane(GraphControl, PaneKey.DEFAULT); pane.Legend.IsVisible = false; foreach (var msGraphItem in errorItems) { var curveItem = GraphControl.AddGraphItem(pane, msGraphItem); curveItem.Label.IsVisible = false; curveItems.Add(curveItem); pane.Title.Text = msGraphItem.Title; } GraphControl.AxisChange(); GraphControl.Invalidate(); return(curveItems); }
private void LegendRedraw(bool showLegend) { var myPane = GraphControl.GraphPane; foreach (var curve in myPane.CurveList) { if (curve.Label.FontSpec == null) { FontSpec font = new FontSpec("Arial", GraphSettings.AxisFontSize, System.Drawing.Color.Black, false, false, false); curve.Label.FontSpec = font; } else { curve.Label.FontSpec.Angle = GraphSettings.AxisFontSize; } curve.Label.IsVisible = showLegend; } GraphControl.Invalidate(); }
/// <inheritdoc /> protected override ILayoutAlgorithm CreateConfiguredLayout(GraphControl graphControl) { var layout = new OrganicLayout(); layout.PreferredEdgeLength = PreferredEdgeLengthItem; layout.ConsiderNodeLabels = ConsiderNodeLabelsItem; layout.NodeOverlapsAllowed = AllowNodeOverlapsItem; layout.MinimumNodeDistance = MinimumNodeDistanceItem; layout.Scope = ScopeItem; layout.CompactnessFactor = CompactnessItem; layout.ConsiderNodeSizes = true; layout.ClusteringPolicy = ClusteringPolicyItem; layout.ClusteringQuality = ClusteringQualityItem; layout.NodeEdgeOverlapAvoided = AvoidNodeEdgeOverlapsItem; layout.Deterministic = ActivateDeterministicModeItem; layout.MaximumDuration = 1000 * MaximumDurationItem; layout.QualityTimeRatio = QualityTimeRatioItem; if (EdgeLabelingItem) { var genericLabeling = new GenericLabeling { PlaceEdgeLabels = true, PlaceNodeLabels = false, ReduceAmbiguity = ReduceAmbiguityItem }; layout.LabelingEnabled = true; layout.Labeling = genericLabeling; } ((ComponentLayout)layout.ComponentLayout).Style = ComponentArrangementStyles.MultiRows; ConfigureOutputRestrictions(graphControl, layout); layout.ChainSubstructureStyle = ChainSubstructureStyleItem; layout.CycleSubstructureSize = CycleSubstructureSizeItem; layout.CycleSubstructureStyle = CycleSubstructureStyleItem; layout.ChainSubstructureSize = ChainSubstructureSizeItem; layout.StarSubstructureStyle = StarSubstructureStyleItem; layout.StarSubstructureSize = StarSubstructureSizeItem; layout.ParallelSubstructureStyle = ParallelSubstructureStyleItem; layout.ParallelSubstructureSize = ParallelSubstructureSizeItem; return(layout); }
protected override LayoutData CreateConfiguredLayoutData(GraphControl graphControl, ILayoutAlgorithm layout) { var layoutData = new RadialLayoutData(); if (CenterStrategyItem == CenterNodesPolicy.Custom) { layoutData.CenterNodes.Source = graphControl.Selection.SelectedNodes; } return(layoutData.CombineWith( CreateLabelingLayoutData( graphControl.Graph, LabelPlacementAlongEdgeItem, LabelPlacementSideOfEdgeItem, LabelPlacementOrientationItem, LabelPlacementDistanceItem ) )); }
public SnapLinesForm() { InitializeComponent(); description.LoadFile(new MemoryStream(Resources.description), RichTextBoxStreamType.RichText); SetupOptions(); snapContext = new GraphSnapContext(); // intialize input mode graphEditorInputMode = new GraphEditorInputMode() { AllowGroupingOperations = true, OrthogonalEdgeEditingContext = new OrthogonalEdgeEditingContext(), SnapContext = snapContext }; GraphControl.InputMode = graphEditorInputMode; GraphControl.Graph.GetDecorator().EdgeDecorator.EdgeReconnectionPortCandidateProviderDecorator.SetImplementation( edge => true, EdgeReconnectionPortCandidateProviders.AllNodeCandidates); // initialize grid this.gridInfo = new GridInfo { HorizontalSpacing = 30, VerticalSpacing = 30 }; grid = new GridVisualCreator(gridInfo); GraphControl.BackgroundGroup.AddChild(grid); snapContext.NodeGridConstraintProvider = new GridConstraintProvider <INode>(gridInfo); snapContext.BendGridConstraintProvider = new GridConstraintProvider <IBend>(gridInfo); // initialize current values OnSnappingChanged(this, null); OnGridHorizontalWidthChanged(this, null); OnGridVerticalWidthChanged(this, null); GraphControl.Invalidate(); GraphControl.ZoomChanged += delegate { UpdateGrid(); }; GraphControl.ViewportChanged += delegate { UpdateGrid(); }; InitializeGraph(); }
private void printButton_Click(object sender, EventArgs e) { GraphControl control = graphControl; // check if the rectangular region or the whole viewport should be printed bool useRect = (bool)handler.GetValue(OUTPUT, EXPORT_RECTANGLE); RectD bounds = useRect ? exportRect.ToRectD() : control.Viewport; // check whether decorations (selection, handles, ...) should be hidden bool hide = (bool)handler.GetValue(OUTPUT, HIDE_DECORATIONS); if (hide) { // if so, create a new graphcontrol with the same graph control = new GraphControl { Graph = graphControl.Graph, Projection = graphControl.Projection }; } // read CanvasPrintDocument options printDocument.Scale = (double)Handler.GetValue(DOCUMENT_SETTINGS, SCALE); printDocument.CenterContent = (bool)Handler.GetValue(DOCUMENT_SETTINGS, CENTER_CONTENT); printDocument.PageMarkPrinting = (bool)Handler.GetValue(DOCUMENT_SETTINGS, PAGE_MARK_PRINTING); printDocument.ScaleDownToFitPage = (bool)Handler.GetValue(DOCUMENT_SETTINGS, SCALE_DOWN_TO_FIT_PAGE); printDocument.ScaleUpToFitPage = (bool)Handler.GetValue(DOCUMENT_SETTINGS, SCALE_UP_TO_FIT_PAGE); // set GraphControl printDocument.Canvas = control; // set print area printDocument.PrintRectangle = bounds; printDocument.Projection = graphControl.Projection; // show new PrintPreviewDialog PrintPreviewDialog dialog = new PrintPreviewDialog { Document = printDocument }; DialogResult result = dialog.ShowDialog(this); if (result == DialogResult.Cancel || result == DialogResult.Abort || result == DialogResult.No) { return; } // print printDocument.Print(); }
/// <summary> /// Paint <see cref="IGraph">component</see> as elements of the palette. /// </summary> private static void OnDrawItem(object sender, DrawItemEventArgs e) { if (sender is ListBox listBox && listBox.Items[e.Index] is IGraph component) { var bounds = e.Bounds; InsetsD insets = new InsetsD(10); // create a GraphControl that shows the component var componentControl = new GraphControl { Size = new Size(bounds.Width - (int)insets.HorizontalInsets, bounds.Height - (int)insets.VerticalInsets), HorizontalScrollBarPolicy = ScrollBarVisibility.Never, VerticalScrollBarPolicy = ScrollBarVisibility.Never, Graph = component }; componentControl.FitGraphBounds(); // create a bitmap with the same size as the GraphControl Bitmap bm = new Bitmap(componentControl.Size.Width, componentControl.Size.Height); Graphics g = Graphics.FromImage(bm); e.DrawBackground(); g.SmoothingMode = SmoothingMode.HighQuality; g.Clear(Color.White); // render the content of the GraphControl into the bitmap ContextConfigurator cc = new ContextConfigurator(componentControl.ContentRect); var renderContext = cc.CreateRenderContext(componentControl, g); componentControl.RenderContent(renderContext, g); // render the image as an element of the palette var listGraphics = e.Graphics; var oldClip = listGraphics.Clip; listGraphics.IntersectClip(bounds); listGraphics.Clear(listBox.BackColor); listGraphics.DrawImage(bm, bounds.X + (int)insets.Left, bounds.Y + (int)insets.Top, bm.Width, bm.Height); listGraphics.Clip = oldClip; e.DrawFocusRectangle(); componentControl.Dispose(); g.Dispose(); bm.Dispose(); } }
private void RandomizeGraph() { // Remove all bends var bends = CurrentIGraph.Edges.SelectMany(e => e.Bends).ToList(); foreach (var bend in bends) { CurrentIGraph.Remove(bend); } var r = new Random(); // Place nodes in random locations foreach (var node in CurrentIGraph.Nodes) { CurrentIGraph.SetNodeCenter(node, new PointD(r.Next((int)GraphControl.Viewport.MinX, (int)GraphControl.Viewport.MaxX), r.Next((int)GraphControl.Viewport.MinY, (int)GraphControl.Viewport.MaxY))); } GraphControl.UpdateContentRect(); }
protected override async Task RunModule() { TreeGenerator rg = new TreeGenerator(); rg.NodeCount = (int)Handler[NumberOfNodes].Value; rg.MaxDepth = (int)Handler[MaxDepth].Value; rg.MaxChildCount = (int)Handler[MaxChildCount].Value; rg.Generate(CurrentIGraph); int i = 0; foreach (INode node in CurrentIGraph.Nodes) { CurrentIGraph.AddLabel(node, "" + ++i); } GraphControl.Invalidate(); await new TreeLayoutModule { RunInBackground = false }.Start(Context); }
protected override LayoutData CreateConfiguredLayoutData(GraphControl graphControl, ILayoutAlgorithm layout) { var layoutData = new ChannelEdgeRouterData(); var selection = graphControl.Selection; if (ScopeItem == Scope.RouteEdgesAtAffectedNodes) { layoutData.AffectedEdges.Delegate = edge => selection.IsSelected(edge.GetSourceNode()) || selection.IsSelected(edge.GetTargetNode()); } else if (ScopeItem == Scope.RouteAffectedEdges) { layoutData.AffectedEdges.Source = selection.SelectedEdges; } else { layoutData.AffectedEdges.Source = graphControl.Graph.Edges; } return(layoutData); }
/// <summary> /// Adds a certain amount of random nodes /// </summary> /// <param name="amount"></param> public void AddRandomNodes(int amount) { if (amount < 1) { return; } GL.Shape shape1, shape2; if (GraphControl.Shapes.Count == 0) { shape1 = GraphControl.AddBasicShape("Root", new Point(100, 100)); amount--; } for (int k = 0; k < amount; k++) { shape1 = GraphControl.Shapes[rnd.Next(0, GraphControl.Shapes.Count - 1)]; shape2 = GraphControl.AddBasicShape("Random " + k, new Point(rnd.Next(20, GraphControl.Width - 70), rnd.Next(20, GraphControl.Height - 30))); Connect(shape1, shape2); } }
private MultiStageLayout ConfigureCompactLayout(GraphControl graphControl) { var layout = new TreeLayout(); var aspectRatioNodePlacer = new AspectRatioNodePlacer(); if (graphControl != null && ArUseViewAspectRatioItem) { var size = graphControl.InnerSize; aspectRatioNodePlacer.AspectRatio = size.Width / size.Height; } else { aspectRatioNodePlacer.AspectRatio = CompactPreferredAspectRatioItem; } aspectRatioNodePlacer.HorizontalDistance = ArHorizontalSpaceItem; aspectRatioNodePlacer.VerticalDistance = ArVerticalSpaceItem; layout.DefaultNodePlacer = aspectRatioNodePlacer; return(layout); }
private void showModelToolStripMenuItem_Click(object sender, EventArgs e) { // Create the form Form form = new Form(); GraphControl control = new GraphControl(); form.Load += delegate { control.FitGraphBounds(); }; // show the master graph control.Graph = foldingManager.MasterGraph; control.InputMode = CreateEditorMode(); control.Dock = DockStyle.Fill; form.ClientSize = new Size(300, 300); form.Text = "Model"; form.SuspendLayout(); form.Controls.Add(control); form.ResumeLayout(); form.Owner = this; form.Visible = true; }
public AnalogTeensyToolbar(AnalogTeensy osc, GraphControl gc) { oscillo = osc; graphControl = gc; this.toolStrip = new System.Windows.Forms.ToolStrip(); this.sampleCountLabel = new System.Windows.Forms.ToolStripLabel(); this.sampleCount = new OnlyNumbersToolStripTextBox(); // // toolStrip2 // this.toolStrip.Dock = System.Windows.Forms.DockStyle.None; this.toolStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.sampleCountLabel, this.sampleCount }); this.toolStrip.Location = new System.Drawing.Point(3, 0); this.toolStrip.Name = "toolStrip2"; this.toolStrip.Size = new System.Drawing.Size(243, 25); this.toolStrip.TabIndex = 1; this.toolStrip.Text = "toolStrip2"; // // sampleCountLabel // this.sampleCountLabel.Size = new System.Drawing.Size(54, 22); this.sampleCountLabel.Text = "time(ms)"; // // sampleCountLabel // this.sampleCount.Size = new System.Drawing.Size(54, 22); this.sampleCount.Text = "100"; this.sampleCount.textReady += new EventHandler(sampleCount_textReady); //set values oscillo.SetMeasuringTime(int.Parse(sampleCount.Text)); }
/// <summary> /// Creates the sample graph of this demo. /// </summary> private void CreateSampleGraph(GraphControl graphControl) { var graph = graphControl.Graph; var blackPortStyle = new NodeStylePortStyleAdapter(new ShapeNodeStyle { Shape = ShapeNodeShape.Ellipse, Brush = Brushes.Black, Pen = null }) { RenderSize = new SizeD(3, 3) }; graph.SetUndoEngineEnabled(true); CreateSubgraph(graph, Colors.Firebrick, 0); CreateSubgraph(graph, Colors.Orange, 200); CreateSubgraph(graph, Colors.Green, 600); // the blue nodes have some additional ports besides the ones used by the edge var nodes = CreateSubgraph(graph, Colors.RoyalBlue, 400); graph.AddPort(nodes[0], FreeNodePortLocationModel.Instance.CreateParameter(new PointD(1, 0.2)), blackPortStyle); graph.AddPort(nodes[0], FreeNodePortLocationModel.Instance.CreateParameter(new PointD(1, 0.8)), blackPortStyle); var candidateProvider = PortCandidateProviders.FromShapeGeometry(nodes[2], 0, 0.25, 0.5, 0.75); candidateProvider.Style = blackPortStyle; IEnumerable <IPortCandidate> candidates = candidateProvider.GetSourcePortCandidates(graphControl.InputModeContext); foreach (IPortCandidate portCandidate in candidates) { if (portCandidate.Validity != PortCandidateValidity.Dynamic) { portCandidate.CreatePort(graphControl.InputModeContext); } } graph.GetUndoEngine().Clear(); }
/// <inheritdoc /> protected override ILayoutAlgorithm CreateConfiguredLayout(GraphControl graphControl) { var layout = new RadialLayout(); layout.MinimumNodeToNodeDistance = MinimumNodeToNodeDistanceItem; if (EdgeRoutingStrategyItem != EdgeRoutingStyle.Bundled) { layout.EdgeRoutingStrategy = (EdgeRoutingStrategy)EdgeRoutingStrategyItem; } var minimumBendAngle = 1 + (MaximumSmoothness - EdgeSmoothnessItem) * SmoothnessAngleFactor; layout.MinimumBendAngle = minimumBendAngle; layout.MinimumLayerDistance = MinimumLayerDistanceItem; layout.MaximumChildSectorAngle = MaximumChildSectorSizeItem; layout.CenterNodesPolicy = CenterStrategyItem; layout.LayeringStrategy = LayeringStrategyItem; layout.ConsiderNodeLabels = ConsiderNodeLabelsItem; var ebc = layout.EdgeBundling; ebc.BundlingStrength = EdgeBundlingStrengthItem; ebc.DefaultBundleDescriptor = new EdgeBundleDescriptor { Bundled = EdgeRoutingStrategyItem == EdgeRoutingStyle.Bundled }; if (EdgeLabelingItem) { var labeling = new GenericLabeling { PlaceEdgeLabels = true, PlaceNodeLabels = false }; layout.LabelingEnabled = true; layout.Labeling = labeling; } AddPreferredPlacementDescriptor(graphControl.Graph, LabelPlacementAlongEdgeItem, LabelPlacementSideOfEdgeItem, LabelPlacementOrientationItem, LabelPlacementDistanceItem); return(layout); }
public static void Main(String[] args) { Form form = new MainForm(); form.ClientSize = new Size(400, 330); form.Text = "Graphs app"; GraphItem[] data=new GraphItem[] { new GraphItem(0,0), new GraphItem(10,10), new GraphItem(20,35), new GraphItem(30,40), new GraphItem(60,80), new GraphItem(70,30), new GraphItem(75,50), new GraphItem(100,90) }; Control ctrl = new GraphControl(data,0,0,320,320); ctrl.Show(); ctrl.Location = new Point(10,10); form.Controls.Add(ctrl); Application.Run(form); }
private static void CommitValuesToForm(OptionHandler handler, GraphEditorForm form) { GraphControl gc = form.GraphControl; IGraph g = form.Graph; GraphEditorInputMode geim = form.GraphEditorInputMode; OptionGroup controlGroup = handler.GetGroupByName(UI_DEFAULTS); OptionGroup graphGroup = handler.GetGroupByName(GRAPH_SETTINGS); OptionGroup sharingGroup = graphGroup.GetGroupByName(SHARING_SETTINGS); OptionGroup miscGroup = handler.GetGroupByName(MISC_SETTINGS); gc.HitTestRadius = (double)controlGroup[HitTestRadius].Value; geim.AutoRemoveEmptyLabels = (bool)controlGroup[AutoRemoveEmptyLabels].Value; form.GridWidth = (int)controlGroup[GridWidth].Value; form.GridSnapType = (GridSnapTypes)controlGroup[GridSnapeType].Value; form.GridVisible = (bool)controlGroup[GridVisible].Value; if (g != null) { g.NodeDefaults.Labels.AutoAdjustPreferredSize = g.EdgeDefaults.Labels.AutoAdjustPreferredSize = (bool)graphGroup[AutoAdjustPreferredLabelSize].Value; g.NodeDefaults.Ports.AutoCleanUp = g.EdgeDefaults.Ports.AutoCleanUp = (bool)graphGroup[AutoCleanupPorts].Value; g.NodeDefaults.ShareStyleInstance = (bool)sharingGroup[ShareDefaultNodeStyleInstance].Value; g.EdgeDefaults.ShareStyleInstance = (bool)sharingGroup[ShareDefaultEdgeStyleInstance].Value; g.NodeDefaults.Labels.ShareStyleInstance = (bool)sharingGroup[ShareDefaultNodeLabelStyleInstance].Value; g.EdgeDefaults.Labels.ShareStyleInstance = (bool)sharingGroup[ShareDefaultEdgeLabelStyleInstance].Value; g.NodeDefaults.Ports.ShareStyleInstance = g.EdgeDefaults.Ports.ShareStyleInstance = (bool)sharingGroup[ShareDefaultPortStyleInstance].Value; g.NodeDefaults.Labels.ShareLayoutParameterInstance = (bool)sharingGroup[ShareDefaultNodeLabelModelParameter].Value; g.EdgeDefaults.Labels.ShareLayoutParameterInstance = (bool)sharingGroup[ShareDefaultEdgeLabelModelParameter].Value; } UndoEngine undoEngine = form.Graph.GetUndoEngine(); if (undoEngine != null) { undoEngine.Size = (int)miscGroup[UndoEngine_Size].Value; } }
public void Initialize(GraphControl ctrl, CLog log) { m_graphCtrl = ctrl; m_log = log; String homeFolder = @Path.GetFullPath(Environment.GetFolderPath(Environment.SpecialFolder.Personal)); m_iniPath = homeFolder + @"\Roostertail Games\T3DConvoEditor\"; String iniFile = m_iniPath + "TSWriterPlugin.ini"; m_log.WriteLine("Attempting to load " + iniFile); if (File.Exists(iniFile)) m_settings = new CSettings(m_iniPath + "TSWriterPlugin.ini"); else { m_iniPath = Path.GetFullPath(".\\"); iniFile = m_iniPath + @"Plugins\TSWriterPlugin.ini"; m_log.WriteLine("Attempting to load " + iniFile); m_settings = new CSettings(iniFile); } if (!m_settings.LoadSettings()) m_log.WriteLine("Failed to locate TSWriterPlugin.ini"); else m_log.WriteLine("TSWriterPlugin settings loaded"); }
private void AxisTitleRedraw(bool showAxis) { var myPane = GraphControl.GraphPane; myPane.XAxis.Title.IsVisible = showAxis; myPane.XAxis.Title.FontSpec.Size = GraphSettings.AxisFontSize; myPane.XAxis.Scale.FontSpec.Size = GraphSettings.AxisFontSize; int i = 0; foreach (var axis in myPane.YAxisList) { axis.Title.IsVisible = showAxis; axis.Title.FontSpec.Size = GraphSettings.AxisFontSize; axis.Scale.FontSpec.Size = GraphSettings.AxisFontSize; if (GraphSettings.AxisColorAsCurve) { axis.Color = GraphSettings.CurveLines[i++].LineColor; } } GraphControl.Invalidate(); }
protected MyNodeView(MyNodeConfig nodeConfig, GraphControl owner) : base("") { Owner = owner; Config = nodeConfig; m_icon = nodeConfig.BigImage; m_iconItem = new NodeImageItem(m_icon, 48, 48, false, false) { IsPassive = true, Tag = 0 }; m_descItem = new NodeLabelItem("") { IsPassive = true }; AddItem(m_iconItem); AddItem(m_descItem); }
/// <summary> /// Create a new layout instance and start it in a new thread /// </summary> /// <returns></returns> private InteractiveOrganicLayout StartLayout() { // create the layout InteractiveOrganicLayout organicLayout = new InteractiveOrganicLayout { MaximumDuration = 2000 }; // use an animator that animates an infinite animation var animator = new Animator(GraphControl) { AutoInvalidation = false, AnimationPriority = DispatcherPriority.Input }; animator.Animate(delegate { if (!organicLayout.Running) { animator.Stop(); return; } if (organicLayout.CommitPositionsSmoothly(50, 0.05) > 0) { GraphControl.UpdateVisual(); } }, TimeSpan.MaxValue); // run the layout in a separate thread Thread thread = new Thread(new ThreadStart(delegate { // we run the real interactive version of the organic layout // previously we only calculated the initial layout using OrganicLayout organicLayout.ApplyLayout(copiedLayoutGraph); // stop the animator when the layout returns (does not normally happen at all) graphControl.Dispatcher.Invoke(new Action <Animator>(animator1 => animator1.Stop()), animator); })); thread.IsBackground = true; thread.Start(); return(organicLayout); }
protected override Task RunModule() { RandomGraphGenerator rg = new RandomGraphGenerator { NodeCount = (int)Handler[NumberOfNodes].Value, EdgeCount = (int)Handler[NumberOfEdges].Value, AllowCycles = (bool)Handler[AllowCycles].Value, AllowMultipleEdges = (bool)Handler[AllowMultipleEdges].Value, AllowSelfLoops = (bool)Handler[AllowSelfloops].Value }; rg.Generate(CurrentIGraph); int i = 0; foreach (INode node in CurrentIGraph.Nodes) { CurrentIGraph.AddLabel(node, "" + ++i); } RandomizeGraph(); GraphControl.Invalidate(); return(Task.FromResult <object>(null)); }
public CustomControlForm() { SetStyle(ControlStyles.ResizeRedraw, true); Size = new Size(400, 350); Text = "Graphs app"; GraphItem[] data = new GraphItem[] { new GraphItem(0, 0), new GraphItem(10, 10), new GraphItem(20, 35), new GraphItem(30, 40), new GraphItem(60, 80), new GraphItem(70, 30), new GraphItem(75, 50), new GraphItem(100, 90) }; Control ctrl = new GraphControl(data, 0, 0, 320, 320); ctrl.Show(); ctrl.Location = new Point(10, 10); Controls.Add(ctrl); }
/// <inheritdoc /> protected override ILayoutAlgorithm CreateConfiguredLayout(GraphControl graphControl) { var layout = new PartialLayout(); layout.ConsiderNodeAlignment = AlignNodesItem; layout.MinimumNodeDistance = MinimumNodeDistanceItem; layout.SubgraphPlacement = SubgraphPlacementItem; layout.ComponentAssignmentStrategy = ComponentAssignmentStrategyItem; layout.LayoutOrientation = OrientationItem; layout.EdgeRoutingStrategy = RoutingToSubgraphItem; layout.AllowMovingFixedElements = MoveFixedElementsItem; ILayoutAlgorithm subgraphLayout = null; if (ComponentAssignmentStrategyItem != ComponentAssignmentStrategy.Single) { switch (SubgraphLayoutItem) { case EnumSubgraphLayouts.Hierarchic: subgraphLayout = new HierarchicLayout(); break; case EnumSubgraphLayouts.Organic: subgraphLayout = new OrganicLayout(); break; case EnumSubgraphLayouts.Circular: subgraphLayout = new CircularLayout(); break; case EnumSubgraphLayouts.Orthogonal: subgraphLayout = new OrthogonalLayout(); break; } } layout.CoreLayout = subgraphLayout; return(layout); }
public DemoForm() { InitializeComponent(); GraphConfiguration configuration = new GraphConfiguration(); configuration.AxisXConfiguration.MajorGrid.LineColor = Color.FromArgb(200, 111, 135); configuration.Palette.Add(new PaletteItem() { Color = Color.Firebrick, HatchStyle = ChartHatchStyle.BackwardDiagonal }); configuration.Palette.Add(new PaletteItem() { Color = Color.Black, HatchStyle = ChartHatchStyle.SolidDiamond }); configuration.GraphSource = new XmlFileGraphSource() { DateTag = "aaa" }; configuration.SaveToXml("qwe.xml"); Stopwatch sw = new Stopwatch(); sw.Start(); GraphControl gc = graphControl; // new GraphControl(); gc.SetConfiguration("graphConfig.xml", Size, null); sw.Stop(); #if STOPWATCH MessageBox.Show("Time spent for data extraction: " + sw.ElapsedMilliseconds); #endif sw.Reset(); sw.Start(); gc.SaveImage("temp.jpg", ChartImageFormat.Jpeg); sw.Stop(); #if STOPWATCH MessageBox.Show("Time spent for data render by Chart control: " + sw.ElapsedMilliseconds); #endif }
private void ShowContents(INode localRoot) { Window window = new Window(); window.Title = "Contents of " + localRoot; // we create a new control GraphControl groupContentsGraphControl = new GraphControl(); // now obtain a view for the given node from the manager IFoldingView foldingView = foldingManager.CreateFoldingView(localRoot); // instead of switching to the ancestor if the localRoot is removed from the graph, // we want to dispose the window, instead. foldingView.AutoSwitchToAncestor = false; // assign the graph and input mode groupContentsGraphControl.Graph = foldingView.Graph; groupContentsGraphControl.InputMode = CreateEditorMode(); // share the clipboard so that we can cut and copy between the windows groupContentsGraphControl.Clipboard = this.graphControl.Clipboard; // show the window window.Content = groupContentsGraphControl; window.Width = window.Height = 300; window.Owner = this; window.Show(); // and fit the bounds window.Dispatcher.BeginInvoke(new Action(() => groupContentsGraphControl.FitGraphBounds())); // register a delegate that will dispose the window when the view gets invalid foldingView.PropertyChanged += delegate(object sender, PropertyChangedEventArgs e) { if (e.PropertyName == "Invalid" && foldingView.Invalid) { window.Close(); } }; }
private void LoadSampleGraph() { //Always use shared references for the sample graphs GraphControl.GraphMLIOHandler.ResolveReference += delegate(object sender, ResolveReferenceEventArgs args) { switch (args.ReferenceId) { case "bezierPathLabelModel": args.Value = bezierPathLabelModel; break; case "bezierSegmentLabelModel": args.Value = bezierEdgeSegmentLabelModel; break; default: break; } }; GraphControl.ImportFromGraphML("Resources\\SampleCircle.graphml"); GraphControl.FitGraphBounds(); }
/// <summary> /// The constructor of the CalcThread. /// </summary> public CalcThread(GraphControl graph) { Graph = graph; w = -1; h = -1; stop = true; done = true; }
/// <summary> /// Creates a deep copy of the CalcThread. /// </summary> public CalcThread Clone(GraphControl graph) { CalcThread t = new CalcThread(graph); t.CopyFrom(this); return t; }
public static void LoadFile(GraphControl graph, string filename) { Header h; using (FileStream stream = new FileStream(filename, FileMode.Open, FileAccess.Read)) { using (BinaryReader r = new BinaryReader(stream)) { //Read WAV header h.ChunkID = r.ReadUInt32(); h.ChunkSize = r.ReadUInt32(); h.Format = r.ReadUInt32(); h.Subchunk1ID = r.ReadUInt32(); h.Subchunk1Size = r.ReadUInt32(); h.AudioFormat = r.ReadUInt16(); h.Channels = r.ReadUInt16(); h.SampleRate = r.ReadUInt32(); h.ByteRate = r.ReadUInt32(); h.BlockAlign = r.ReadUInt16(); h.BitsPerSample = r.ReadUInt16(); h.Subchunk2ID = r.ReadUInt32(); h.Subchunk2Size = r.ReadUInt32(); int channels = h.Channels; int bytes = h.BitsPerSample / 8; int samples = (int)(h.Subchunk2Size / channels / bytes); int m, n; byte[] d; DataItem[] items = new DataItem[channels]; for (m = 0; m < channels; m++) { items[m] = new DataItem(); items[m].lines = true; // join points with a line. items[m].marks = false; // draw no error marks. items[m].Length = samples; // Set the length of the arrays. // set formula for x-array items[m].x.source = "n/((float)Length)*" + (samples / (float)h.SampleRate).ToString(); items[m].dx.source = "0"; // set formula for dx-array items[m].dy.source = "0"; // set formula for dy-array items[m].name = "channel " + m.ToString(); // set the name of the DataItem. items[m].Compile(true); switch (m % 3) { case 0: items[m].Color = Color.Blue; break; case 1: items[m].Color = Color.Red; break; case 2: items[m].Color = Color.Green; break; } graph.Model.Items.Add(items[m]); } for (n = 0; n < samples; n++) { for (m = 0; m < channels; m++) { // Set y.AutoResize to true, so the size of the y-array will be adapted automatically. items[m].y.AutoResize = true; d = r.ReadBytes(bytes); switch (bytes) { case 1: items[m].y[n] = (double)((int)d[0])/0x100; break; case 2: items[m].y[n] = (double)BitConverter.ToInt16(d, 0)/0x10000; break; case 3: items[m].y[n] = (double)(d[0]*0x10000 + d[1]*0x100 + d[3])/0x1000000; break; case 4: items[m].y[n] = (double)BitConverter.ToInt32(d, 0)/0x100000000; break; } items[m].y.AutoResize = false; } } } } }
public OptionsForm(GraphControl graph) { // // Required for Windows Form Designer support // this.graph = graph; InitializeComponent(); xDigits.KeyPress += new KeyPressEventHandler(intKeyPress); yDigits.KeyPress += new KeyPressEventHandler(intKeyPress); xFormat.DropDownStyle = ComboBoxStyle.DropDownList; yFormat.DropDownStyle = ComboBoxStyle.DropDownList; }
/// <summary> /// The default constructor. /// </summary> public GraphPrintDocument(GraphControl graph) { this.graph = graph; }
public GraphConsumer(GraphControl gc) { graphControl = gc; }
public CustomControlForm() { SetStyle(ControlStyles.ResizeRedraw, true); Size = new Size(400, 350); Text = "Graphs app"; GraphItem[] data=new GraphItem[] { new GraphItem(0,0), new GraphItem(10,10), new GraphItem(20,35), new GraphItem(30,40), new GraphItem(60,80), new GraphItem(70,30), new GraphItem(75,50), new GraphItem(100,90) }; Control ctrl = new GraphControl(data,0,0,320,320); ctrl.Show(); ctrl.Location = new Point(10,10); Controls.Add(ctrl); }
public CommonToolStrip(VizForm vf, Acquirer acq, GraphControl gc, Oscillo os) { vizForm = vf; m_acquirer = acq; graphControl = gc; m_Oscillo = os; this.timeLabel = new System.Windows.Forms.ToolStripLabel(); this.clone = new System.Windows.Forms.ToolStripButton(); this.play = new System.Windows.Forms.ToolStripButton(); this.time = new System.Windows.Forms.ToolStripComboBox(); this.toolStrip.Dock = System.Windows.Forms.DockStyle.None; this.toolStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.timeLabel, this.time, this.clone, this.play}); this.toolStrip.Location = new System.Drawing.Point(0, 0); this.toolStrip.Name = "toolStrip2"; this.toolStrip.Size = new System.Drawing.Size(497, 25); this.toolStrip.TabIndex = 1; this.toolStrip.Text = "toolStrip2"; // // time // this.time.Name = "time"; this.time.Size = new System.Drawing.Size(50, 25); this.time.SelectedIndexChanged += new System.EventHandler(this.time_SelectedIndexChanged); // // clone // this.clone.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text; this.clone.Image = null;// ((System.Drawing.Image)(resources.GetObject("clone.Image"))); this.clone.ImageTransparentColor = System.Drawing.Color.Magenta; this.clone.Name = "clone"; this.clone.Size = new System.Drawing.Size(42, 22); this.clone.Text = "Clone"; this.clone.Click += new System.EventHandler(this.clone_Click); // // play // if (m_acquirer != null) { this.play.CheckOnClick = true; this.play.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; this.play.Image = global::XOscillo.Properties.Resources.play; this.play.ImageTransparentColor = System.Drawing.Color.Magenta; this.play.Margin = new System.Windows.Forms.Padding(1); this.play.Name = "play"; this.play.Size = new System.Drawing.Size(23, 23); this.play.Text = "toolStripButton2"; this.play.CheckedChanged += new System.EventHandler(this.play_CheckedChanged); this.play.Checked = true; } this.toolStrip.Items.Add(new System.Windows.Forms.ToolStripSeparator()); // // Channels // if (m_Oscillo != null) { for (int i = 0; i < m_Oscillo.GetNumberOfSupportedChannels(); i++) { CheckBox cb = new CheckBox(); cb.Text = "Ch" + i; cb.Tag = i; cb.Appearance = Appearance.Button; cb.CheckStateChanged += ((s, ex) => { m_Oscillo.SetChannel((int)cb.Tag, cb.CheckState == CheckState.Checked); SetAcquirerStatus(); // since the above doesnt fire a CheckStateChanged }); ToolStripControlHost host = new ToolStripControlHost(cb); if (i == 0) { cb.Checked = true; } this.toolStrip.Items.Add(host); } } }