Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a graph layout algorithm #37

Open
wants to merge 2 commits into
base: Main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Foreman/Foreman.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@
<Reference Include="System.IO.Compression.ZipFile, Version=4.0.2.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
<HintPath>..\packages\System.IO.Compression.ZipFile.4.3.0\lib\net46\System.IO.Compression.ZipFile.dll</HintPath>
</Reference>
<Reference Include="System.ValueTuple, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.ValueTuple.4.5.0\lib\net461\System.ValueTuple.dll</HintPath>
</Reference>
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
Expand Down Expand Up @@ -210,6 +213,8 @@
</Compile>
<Compile Include="Models\AssemblerSelector.cs" />
<Compile Include="Models\FuelSelector.cs" />
<Compile Include="Models\Layout\GraphLayout.cs" />
<Compile Include="Models\Layout\CoordinateAssignment.cs" />
<Compile Include="Models\LinkChecker.cs" />
<Compile Include="Models\ModuleSelector.cs" />
<Compile Include="Models\Nodes\ConsumerNode.cs" />
Expand Down
124 changes: 99 additions & 25 deletions Foreman/Forms/MainForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 21 additions & 9 deletions Foreman/Forms/MainForm.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
using System;
using System.Windows.Forms;
using System.IO;
using System.Collections.Generic;
using Newtonsoft.Json;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Foreman
{
Expand Down Expand Up @@ -402,7 +402,7 @@ private async void SettingsButton_Click(object sender, EventArgs e)
beacon.Enabled = options.EnabledObjects.Contains(beacon);
foreach (Module module in GraphViewer.DCache.Modules.Values)
module.Enabled = options.EnabledObjects.Contains(module);
GraphViewer.DCache.RocketAssembler.Enabled = GraphViewer.DCache.Assemblers["rocket-silo"]?.Enabled?? false;
GraphViewer.DCache.RocketAssembler.Enabled = GraphViewer.DCache.Assemblers["rocket-silo"]?.Enabled ?? false;
}

GraphViewer.LevelOfDetail = options.LevelOfDetail;
Expand Down Expand Up @@ -490,7 +490,7 @@ private void AddItemButton_Click(object sender, EventArgs e)

private void MainForm_KeyDown(object sender, KeyEventArgs e)
{
if(e.KeyCode == Keys.S && (Control.ModifierKeys & Keys.Control) == Keys.Control)
if (e.KeyCode == Keys.S && (Control.ModifierKeys & Keys.Control) == Keys.Control)
if (savefilePath == null || !SaveGraph(savefilePath))
SaveGraphAs();
}
Expand Down Expand Up @@ -595,15 +595,27 @@ private void GraphViewer_KeyDown(object sender, KeyEventArgs e)
}
}

//---------------------------------------------------------Graph layout

private void LayoutGraphButton_Click(object sender, EventArgs e)
{
GraphViewer.LayoutGraph();
}

private void ReduceCrossingsCheckBox_CheckedChanged(object sender, EventArgs e)
{
GraphViewer.ReduceCrossings = ReduceCrossingsCheckBox.Checked;
}

//---------------------------------------------------------double buffering commands

public static void SetDoubleBuffered(Control c)
{
if (SystemInformation.TerminalServerSession)
return;
System.Reflection.PropertyInfo aProp = typeof(Control).GetProperty("DoubleBuffered",
System.Reflection.BindingFlags.NonPublic |
System.Reflection.BindingFlags.Instance);
System.Reflection.BindingFlags.NonPublic |
System.Reflection.BindingFlags.Instance);
aProp.SetValue(c, true, null);
}

Expand Down
Loading