Skip to content

Commit

Permalink
Run code formatter on a few files I intend to modify
Browse files Browse the repository at this point in the history
  • Loading branch information
MForster committed May 6, 2022
1 parent 083a310 commit 6b95e7b
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 68 deletions.
42 changes: 21 additions & 21 deletions Foreman/Forms/MainForm.Designer.cs

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

18 changes: 9 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 @@ -602,8 +602,8 @@ 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
76 changes: 38 additions & 38 deletions Foreman/ProductionGraphView/ProductionGraphViewer.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
using System;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Windows.Forms;
using System.Runtime.Serialization;
using Newtonsoft.Json.Linq;
using System.Diagnostics;
using Newtonsoft.Json;
using System.Text;
using System.IO;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Foreman
{
Expand All @@ -27,7 +27,7 @@ public enum LOD { Low, Medium, High } //low: only names. medium: assemblers, bea
public bool ArrowsOnLinks { get; set; }
public bool IconsOnly { get; set; }
public int IconsSize { get; set; }
public int IconsDrawSize { get { return ViewScale > ((double)IconsSize / 96)? 96 : (int)(IconsSize / ViewScale); } }
public int IconsDrawSize { get { return ViewScale > ((double)IconsSize / 96) ? 96 : (int)(IconsSize / ViewScale); } }

public int NodeCountForSimpleView { get; set; } //if the number of elements to draw is over this amount then the drawing functions will switch to simple view draws (mostly for FPS during zoomed out views)
public bool ShowRecipeToolTip { get; set; }
Expand Down Expand Up @@ -186,7 +186,7 @@ public void AddItem(Point drawOrigin, Point newLocation)

public void AddRecipe(Point drawOrigin, Item baseItem, Point newLocation, NewNodeType nNodeType, BaseNodeElement originElement = null, bool offsetLocationToItemTabLevel = false)
{
if(string.IsNullOrEmpty(DCache.PresetName))
if (string.IsNullOrEmpty(DCache.PresetName))
{
DisposeLinkDrag();
MessageBox.Show("The current preset (" + Properties.Settings.Default.CurrentPresetName + ") is corrupt.");
Expand All @@ -195,14 +195,14 @@ public void AddRecipe(Point drawOrigin, Item baseItem, Point newLocation, NewNod

if ((nNodeType != NewNodeType.Disconnected) && (originElement == null || baseItem == null))
Trace.Fail("Origin element or base item not provided for a new (linked) node");

if (Grid.ShowGrid)
newLocation = Grid.AlignToGrid(newLocation);

int lastNodeWidth = 0;
NodeDirection newNodeDirection = (originElement == null || !SmartNodeDirection) ? Graph.DefaultNodeDirection :
draggedLinkElement.Type != BaseLinkElement.LineType.UShape ? originElement.DisplayedNode.NodeDirection :
originElement.DisplayedNode.NodeDirection == NodeDirection.Up ? NodeDirection.Down : NodeDirection.Up;
draggedLinkElement.Type != BaseLinkElement.LineType.UShape ? originElement.DisplayedNode.NodeDirection :
originElement.DisplayedNode.NodeDirection == NodeDirection.Up ? NodeDirection.Down : NodeDirection.Up;

void ProcessNodeRequest(object o, RecipeRequestArgs recipeRequestArgs)
{
Expand Down Expand Up @@ -322,11 +322,11 @@ void ProcessNodeRequest(object o, RecipeRequestArgs recipeRequestArgs)
public void AddPassthroughNodesFromSelection(LinkType linkType, Size offset)
{
List<BaseNodeElement> newPassthroughNodes = new List<BaseNodeElement>();
foreach(PassthroughNodeElement passthroughNode in selectedNodes)
foreach (PassthroughNodeElement passthroughNode in selectedNodes)
{
NodeDirection newNodeDirection = !SmartNodeDirection ? Graph.DefaultNodeDirection :
draggedLinkElement.Type != BaseLinkElement.LineType.UShape ? passthroughNode.DisplayedNode.NodeDirection :
passthroughNode.DisplayedNode.NodeDirection == NodeDirection.Up ? NodeDirection.Down : NodeDirection.Up;
draggedLinkElement.Type != BaseLinkElement.LineType.UShape ? passthroughNode.DisplayedNode.NodeDirection :
passthroughNode.DisplayedNode.NodeDirection == NodeDirection.Up ? NodeDirection.Down : NodeDirection.Up;

Item passthroughItem = ((ReadOnlyPassthroughNode)passthroughNode.DisplayedNode).PassthroughItem;

Expand All @@ -339,9 +339,9 @@ public void AddPassthroughNodesFromSelection(LinkType linkType, Size offset)
controller.SetDirection(newNodeDirection);

if (linkType == LinkType.Input)
Graph.CreateLink(newNode, passthroughNode.DisplayedNode, passthroughItem );
Graph.CreateLink(newNode, passthroughNode.DisplayedNode, passthroughItem);
else
Graph.CreateLink(passthroughNode.DisplayedNode, newNode, passthroughItem );
Graph.CreateLink(passthroughNode.DisplayedNode, newNode, passthroughItem);

newPassthroughNodes.Add(nodeElementDictionary[newNode]);
}
Expand Down Expand Up @@ -395,8 +395,8 @@ public void EditNode(BaseNodeElement bNodeElement)
Point screenOriginPoint = GraphToScreen(new Point(bNodeElement.X - (bNodeElement.Width / 2), bNodeElement.Y));
screenOriginPoint = new Point(screenOriginPoint.X - editPanel.Width, screenOriginPoint.Y - (editPanel.Height / 2));
Point offset = new Point(
(int)(Math.Min(Math.Max(0, 25 - screenOriginPoint.X), this.Width - screenOriginPoint.X - editPanel.Width - bNodeElement.Width - 25)),
(int)(Math.Min(Math.Max(0, 25 - screenOriginPoint.Y), this.Height - screenOriginPoint.Y - editPanel.Height - 25)));
(int)(Math.Min(Math.Max(0, 25 - screenOriginPoint.X), this.Width - screenOriginPoint.X - editPanel.Width - bNodeElement.Width - 25)),
(int)(Math.Min(Math.Max(0, 25 - screenOriginPoint.Y), this.Height - screenOriginPoint.Y - editPanel.Height - 25)));

ViewOffset = Point.Add(ViewOffset, new Size((int)(offset.X / ViewScale), (int)(offset.Y / ViewScale)));
UpdateGraphBounds();
Expand Down Expand Up @@ -431,8 +431,8 @@ public void EditRecipeNode(RecipeNodeElement rNodeElement)
recipeEditPanelOriginPoint.Y += editPanel.Height / 2 - 125;
recipeEditPanelOriginPoint.X -= recipePanel.Width + 5;
Point offset = new Point(
(int)(Math.Min(Math.Max(0, 25 - recipeEditPanelOriginPoint.X), this.Width - recipeEditPanelOriginPoint.X - editPanel.Width)),
(int)(Math.Min(Math.Max(0, 25 - recipeEditPanelOriginPoint.Y), this.Height - recipeEditPanelOriginPoint.Y - editPanel.Height - 25)));
(int)(Math.Min(Math.Max(0, 25 - recipeEditPanelOriginPoint.X), this.Width - recipeEditPanelOriginPoint.X - editPanel.Width)),
(int)(Math.Min(Math.Max(0, 25 - recipeEditPanelOriginPoint.Y), this.Height - recipeEditPanelOriginPoint.Y - editPanel.Height - 25)));

editPanel.Location = Point.Add(recipeEditPanelOriginPoint, (Size)offset);
recipePanel.Location = new Point(editPanel.Location.X + editPanel.Width + 5, editPanel.Location.Y);
Expand Down Expand Up @@ -555,7 +555,7 @@ protected override void OnPaint(PaintEventArgs e)
selectionPen.Width = 2 / ViewScale;

//grid
if(!FullGraph)
if (!FullGraph)
Grid.Paint(graphics, ViewScale, VisibleGraphBounds, (currentDragOperation == DragOperation.Item) ? MouseDownElement as BaseNodeElement : null);

//process link element widths
Expand Down Expand Up @@ -594,7 +594,7 @@ protected override void OnPaint(PaintEventArgs e)
//paint all elements (nodes & lines)
int visibleElements = GetPaintingOrder().Count(e => e.Visible && e is BaseNodeElement);
foreach (GraphElement element in GetPaintingOrder())
element.Paint(graphics, FullGraph? NodeDrawingStyle.PrintStyle : IconsOnly? NodeDrawingStyle.IconsOnly : (visibleElements > NodeCountForSimpleView || ViewScale < 0.2)? NodeDrawingStyle.Simple : NodeDrawingStyle.Regular); //if viewscale is 0.2, then the text, images, etc being drawn are ~1/5th the size: aka: ~6x6 pixel images, etc. Use simple draw. Also simple draw if too many objects
element.Paint(graphics, FullGraph ? NodeDrawingStyle.PrintStyle : IconsOnly ? NodeDrawingStyle.IconsOnly : (visibleElements > NodeCountForSimpleView || ViewScale < 0.2) ? NodeDrawingStyle.Simple : NodeDrawingStyle.Regular); //if viewscale is 0.2, then the text, images, etc being drawn are ~1/5th the size: aka: ~6x6 pixel images, etc. Use simple draw. Also simple draw if too many objects

//selection zone
if (currentDragOperation == DragOperation.Selection && !FullGraph)
Expand Down Expand Up @@ -744,18 +744,18 @@ private void ProductionGraphViewer_MouseUp(object sender, MouseEventArgs e)

rightClickMenu.MenuItems.Clear();
rightClickMenu.MenuItems.Add(new MenuItem("Add Item",
new EventHandler((o, ee) =>
{
AddItem(screenPoint, ScreenToGraph(e.Location));
})));
new EventHandler((o, ee) =>
{
AddItem(screenPoint, ScreenToGraph(e.Location));
})));
rightClickMenu.MenuItems.Add(new MenuItem("Add Recipe",
new EventHandler((o, ee) =>
{
AddRecipe(screenPoint, null, ScreenToGraph(e.Location), NewNodeType.Disconnected);
})));
new EventHandler((o, ee) =>
{
AddRecipe(screenPoint, null, ScreenToGraph(e.Location), NewNodeType.Disconnected);
})));
rightClickMenu.Show(this, e.Location);
}
else if(currentDragOperation != DragOperation.Selection)
else if (currentDragOperation != DragOperation.Selection)
element?.MouseUp(graph_location, e.Button, (currentDragOperation == DragOperation.Item));
break;
case MouseButtons.Middle:
Expand Down Expand Up @@ -1065,10 +1065,10 @@ public void UpdateGraphBounds(bool limitView = true)
}

VisibleGraphBounds = new Rectangle(
(int)(-Width / (2 * ViewScale) - ViewOffset.X),
(int)(-Height / (2 * ViewScale) - ViewOffset.Y),
(int)(Width / ViewScale),
(int)(Height / ViewScale));
(int)(-Width / (2 * ViewScale) - ViewOffset.X),
(int)(-Height / (2 * ViewScale) - ViewOffset.Y),
(int)(Width / ViewScale),
(int)(Height / ViewScale));
}

private void ProductionGraphViewer_Resize(object sender, EventArgs e)
Expand Down Expand Up @@ -1232,7 +1232,7 @@ public async Task LoadFromJson(JObject json, bool useFirstPreset, bool setEnable
else
{
//errors found. even though the name fits, but the preset seems to be the wrong one. Proceed with searching for best-fit
if(errors != null)
if (errors != null)
presetErrors.Add(errors);
allPresets.Remove(savedWPreset);
}
Expand Down Expand Up @@ -1350,4 +1350,4 @@ protected override void Dispose(bool disposing)
base.Dispose(disposing);
}
}
}
}

0 comments on commit 6b95e7b

Please sign in to comment.