Skip to content

Commit 408f11f

Browse files
committed
Added a cross-platform desktop test application, using Avalonia. Updated .NET nuget package to target NET 10, no more NetStandard. Removed obsolete code.
1 parent 7c83c6b commit 408f11f

File tree

56 files changed

+875
-1914
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+875
-1914
lines changed

CSharp/OrgChart.CSharp.SharedSource/Layout/Boundary.cs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ public Step ChangeX(double newX)
103103
/// <summary>
104104
/// A temporary Boundary used for merging Boxes in, since they don't come with their own Boundary.
105105
/// </summary>
106-
private readonly Boundary m_spacerMerger;
106+
private readonly Boundary _spacerMerger;
107107

108108
/// <summary>
109109
/// Ctr.
@@ -119,7 +119,7 @@ private Boundary(bool frompublic)
119119

120120
if (frompublic)
121121
{
122-
m_spacerMerger = new Boundary(false);
122+
_spacerMerger = new Boundary(false);
123123
}
124124
}
125125

@@ -213,6 +213,7 @@ public void MergeFrom([NotNull]Boundary other)
213213
{
214214
mySteps[i] = th; // replace entire step
215215
}
216+
216217
i++;
217218
k++;
218219

@@ -227,6 +228,7 @@ public void MergeFrom([NotNull]Boundary other)
227228
{
228229
mySteps[i] = my.ChangeOwner(th.Node, th.X); // replace my with a piece of theirs
229230
}
231+
230232
theirSteps[k] = th.ChangeTop(my.Bottom); // push their top down
231233
i++;
232234

@@ -243,6 +245,7 @@ public void MergeFrom([NotNull]Boundary other)
243245
mySteps.Insert(i, th); // insert theirs before my
244246
i++;
245247
}
248+
246249
k++;
247250

248251
ValidateState();
@@ -261,6 +264,7 @@ public void MergeFrom([NotNull]Boundary other)
261264
mySteps.Insert(i + 1, th); // insert theirs after my
262265
i++;
263266
}
267+
264268
i++;
265269
k++;
266270

@@ -282,6 +286,7 @@ public void MergeFrom([NotNull]Boundary other)
282286
mySteps.Insert(i, th.ChangeBottom(my.Top));
283287
i++;
284288
}
289+
285290
i++;
286291
k++;
287292

@@ -299,6 +304,7 @@ public void MergeFrom([NotNull]Boundary other)
299304
mySteps.Insert(i + 1, new Step(th.Node, th.X, th.Top, my.Bottom)); // insert a piece of theirs after my
300305
i++;
301306
}
307+
302308
theirSteps[k] = th.ChangeTop(my.Bottom); // push theirs down
303309
i++;
304310

@@ -316,6 +322,7 @@ public void MergeFrom([NotNull]Boundary other)
316322
mySteps.Insert(i + 2, my.ChangeTop(th.Bottom)); // insert my tail after theirs
317323
i += 2;
318324
}
325+
319326
k++;
320327

321328
ValidateState();
@@ -335,6 +342,7 @@ public void MergeFrom([NotNull]Boundary other)
335342
{
336343
mySteps.Insert(i, th.ChangeBottom(my.Top));
337344
}
345+
338346
i++;
339347
k++;
340348

@@ -354,6 +362,7 @@ public void MergeFrom([NotNull]Boundary other)
354362
mySteps.Insert(i, th.ChangeBottom(my.Top));
355363
i++;
356364
}
365+
357366
theirSteps[k] = th.ChangeTop(my.Bottom); // push theirs down
358367
i++;
359368

@@ -421,8 +430,8 @@ public void MergeFrom([NotNull]BoxTree.Node node)
421430
return;
422431
}
423432

424-
m_spacerMerger.PrepareForHorizontalLayout(node);
425-
MergeFrom(m_spacerMerger);
433+
_spacerMerger.PrepareForHorizontalLayout(node);
434+
MergeFrom(_spacerMerger);
426435
}
427436

428437
/// <summary>
@@ -467,6 +476,7 @@ public double ComputeOverlap([NotNull]Boundary other, double siblingSpacing, dou
467476
{
468477
k++;
469478
}
479+
470480
if (th.Bottom >= my.Bottom)
471481
{
472482
i++;

CSharp/OrgChart.CSharp.SharedSource/Layout/BoxContainer.cs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,19 @@ namespace OrgChart.Layout
1313
/// </summary>
1414
public class BoxContainer
1515
{
16-
private int m_lastBoxId;
17-
private readonly Dictionary<int, Box> m_boxesById = new Dictionary<int, Box>();
18-
private readonly Dictionary<string, Box> m_boxesByDataId = new Dictionary<string, Box>();
16+
private int _lastBoxId;
17+
private readonly Dictionary<int, Box> _boxesById = new Dictionary<int, Box>();
18+
private readonly Dictionary<string, Box> _boxesByDataId = new Dictionary<string, Box>();
1919

2020
/// <summary>
2121
/// Access to internal collection of boxes.
2222
/// </summary>
23-
public IDictionary<int, Box> BoxesById => m_boxesById;
23+
public IDictionary<int, Box> BoxesById => _boxesById;
2424

2525
/// <summary>
2626
/// Access to internal collection of boxes.
2727
/// </summary>
28-
public IDictionary<string, Box> BoxesByDataId => m_boxesByDataId;
28+
public IDictionary<string, Box> BoxesByDataId => _boxesByDataId;
2929

3030
/// <summary>
3131
/// Auto-generated system root box. Added to guarantee a single-root hierarchy.
@@ -53,13 +53,13 @@ public BoxContainer([NotNull]IChartDataSource source)
5353
/// </summary>
5454
public void ReloadBoxes([NotNull]IChartDataSource source)
5555
{
56-
m_boxesByDataId.Clear();
57-
m_boxesById.Clear();
58-
m_lastBoxId = 0;
56+
_boxesByDataId.Clear();
57+
_boxesById.Clear();
58+
_lastBoxId = 0;
5959

6060
// generate system root box
61-
SystemRoot = Box.Special(++m_lastBoxId, Box.None, true);
62-
m_boxesById.Add(SystemRoot.Id, SystemRoot);
61+
SystemRoot = Box.Special(++_lastBoxId, Box.None, true);
62+
_boxesById.Add(SystemRoot.Id, SystemRoot);
6363

6464
var map = new Dictionary<string, int>();
6565

@@ -92,10 +92,10 @@ public Box AddBox([CanBeNull]string dataId, int visualParentId, bool isAssistant
9292
private Box AddBox([CanBeNull]string dataId, int id, int visualParentId, bool isAssistant)
9393
{
9494
var box = new Box(dataId, id, visualParentId, isAssistant);
95-
m_boxesById.Add(box.Id, box);
95+
_boxesById.Add(box.Id, box);
9696
if (!string.IsNullOrEmpty(dataId))
9797
{
98-
m_boxesByDataId.Add(box.DataId, box);
98+
_boxesByDataId.Add(box.DataId, box);
9999
}
100100

101101
return box;
@@ -106,8 +106,8 @@ private Box AddBox([CanBeNull]string dataId, int id, int visualParentId, bool is
106106
/// </summary>
107107
public int NextBoxId()
108108
{
109-
m_lastBoxId++;
110-
return m_lastBoxId;
109+
_lastBoxId++;
110+
return _lastBoxId;
111111
}
112112
}
113113
}

CSharp/OrgChart.CSharp.SharedSource/Layout/BoxTree.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ public Node AddAssistantChild([NotNull] Node child)
8282
Level = Level + 1
8383
};
8484
}
85+
8586
AssistantsRoot.AddRegularChild(child);
8687
return this;
8788
}
@@ -213,6 +214,7 @@ public void SuppressAssistants()
213214
{
214215
AddRegularChild(child);
215216
}
217+
216218
AssistantsRoot = null;
217219
}
218220
}
@@ -274,15 +276,17 @@ public void UpdateHierarchyStats()
274276
x.Level = x.ParentNode.Level;
275277
if (!x.ParentNode.IsAssistantRoot)
276278
{
277-
x.Level = x.Level + 1;
279+
x.Level++;
278280
}
281+
279282
Depth = Math.Max(1 + x.Level, Depth);
280283
}
281284
else
282285
{
283286
x.Level = 0;
284287
Depth = 1;
285288
}
289+
286290
return true;
287291
});
288292
}
@@ -314,8 +318,7 @@ public static BoxTree Build([NotNull] LayoutState state)
314318
{
315319
var parentKey = node.Element.ParentId;
316320

317-
Node parentNode;
318-
if (result.Nodes.TryGetValue(parentKey, out parentNode))
321+
if (result.Nodes.TryGetValue(parentKey, out Node parentNode))
319322
{
320323
if (node.Element.IsAssistant && parentNode.Element.ParentId != Box.None)
321324
{

CSharp/OrgChart.CSharp.SharedSource/Layout/Connector.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ public Connector([NotNull]Edge[] segments)
2121
{
2222
throw new ArgumentException("Need at least one segment", nameof(Segments));
2323
}
24+
2425
Segments = segments;
2526
}
2627

CSharp/OrgChart.CSharp.SharedSource/Layout/Diagram.cs

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ namespace OrgChart.Layout
1111
/// </summary>
1212
public class Diagram
1313
{
14-
private BoxTree m_visualTree;
15-
private BoxContainer m_boxes;
14+
private BoxContainer _boxes;
1615

1716
/// <summary>
1817
/// Diagram layout styles.
@@ -24,26 +23,19 @@ public class Diagram
2423
/// </summary>
2524
public BoxContainer Boxes
2625
{
27-
get { return m_boxes; }
26+
get { return _boxes; }
2827
set
2928
{
30-
m_visualTree = null;
31-
m_boxes = value;
29+
VisualTree = null;
30+
_boxes = value;
3231
}
3332
}
3433

3534
/// <summary>
3635
/// Visual tree of boxes.
3736
/// </summary>
3837
[CanBeNull]
39-
public BoxTree VisualTree
40-
{
41-
get { return m_visualTree; }
42-
set
43-
{
44-
m_visualTree = value;
45-
}
46-
}
38+
public BoxTree VisualTree { get; set; }
4739

4840
/// <summary>
4941
/// Ctr.

CSharp/OrgChart.CSharp.SharedSource/Layout/DiagramLayoutSettings.cs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ namespace OrgChart.Layout
1313
/// </summary>
1414
public class DiagramLayoutSettings
1515
{
16-
private double m_branchSpacing;
16+
private double _branchSpacing;
1717

1818
/// <summary>
1919
/// All unique layout strategies (semantically similar to CSS style sheets) referenced by sub-trees in the diagram.
@@ -37,14 +37,15 @@ public class DiagramLayoutSettings
3737
/// </summary>
3838
public double BranchSpacing
3939
{
40-
get { return m_branchSpacing; }
40+
get { return _branchSpacing; }
4141
set
4242
{
4343
if (value < 0)
4444
{
4545
throw new ArgumentOutOfRangeException(nameof(value), value, "Cannot be negative");
4646
}
47-
m_branchSpacing = value;
47+
48+
_branchSpacing = value;
4849
}
4950
}
5051

@@ -63,9 +64,8 @@ public DiagramLayoutSettings()
6364
/// <exception cref="InvalidOperationException"><see cref="DefaultLayoutStrategyId"/> is null or not valid</exception>
6465
public LayoutStrategyBase RequireDefaultLayoutStrategy()
6566
{
66-
LayoutStrategyBase result;
6767
if (string.IsNullOrEmpty(DefaultLayoutStrategyId)
68-
|| !LayoutStrategies.TryGetValue(DefaultLayoutStrategyId, out result))
68+
|| !LayoutStrategies.TryGetValue(DefaultLayoutStrategyId, out LayoutStrategyBase result))
6969
{
7070
throw new InvalidOperationException(nameof(DefaultLayoutStrategyId) + " is null or not valid");
7171
}
@@ -79,9 +79,8 @@ public LayoutStrategyBase RequireDefaultLayoutStrategy()
7979
/// <exception cref="InvalidOperationException"><see cref="DefaultAssistantLayoutStrategyId"/> is null or not valid</exception>
8080
public LayoutStrategyBase RequireDefaultAssistantLayoutStrategy()
8181
{
82-
LayoutStrategyBase result;
8382
if (string.IsNullOrEmpty(DefaultAssistantLayoutStrategyId)
84-
|| !LayoutStrategies.TryGetValue(DefaultAssistantLayoutStrategyId, out result))
83+
|| !LayoutStrategies.TryGetValue(DefaultAssistantLayoutStrategyId, out LayoutStrategyBase result))
8584
{
8685
throw new InvalidOperationException(nameof(DefaultAssistantLayoutStrategyId) + " is null or not valid");
8786
}

CSharp/OrgChart.CSharp.SharedSource/Layout/LayoutAlgorithm.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ private static void PreprocessVisualTree([NotNull]LayoutState state, [NotNull]Bo
187187
node.ParentNode.Element.AssistantLayoutStrategyId]
188188
: assistants.Peek();
189189
}
190+
190191
assistants.Push(strategy);
191192
}
192193
else
@@ -197,6 +198,7 @@ private static void PreprocessVisualTree([NotNull]LayoutState state, [NotNull]Bo
197198
? state.Diagram.LayoutSettings.LayoutStrategies[node.Element.LayoutStrategyId]
198199
: regular.Peek();
199200
}
201+
200202
regular.Push(strategy);
201203

202204
if (!strategy.SupportsAssistants)
@@ -323,6 +325,7 @@ public static void MoveChildrenOnly([NotNull]LayoutState state, LayoutState.Layo
323325
node.State.TopLeft = node.State.TopLeft.MoveH(offset);
324326
node.State.BranchExterior = node.State.BranchExterior.MoveH(offset);
325327
}
328+
326329
return true;
327330
};
328331

@@ -350,6 +353,7 @@ private static void MoveOneChild([NotNull]LayoutState state, [NotNull]BoxTree.No
350353
node.State.TopLeft = node.State.TopLeft.MoveH(offset);
351354
node.State.BranchExterior = node.State.BranchExterior.MoveH(offset);
352355
}
356+
353357
return true;
354358
});
355359
}
@@ -399,6 +403,7 @@ public static Dimensions AlignHorizontalCenters(
399403
var diff = center - c;
400404
MoveOneChild(state, child, diff);
401405
}
406+
402407
leftmost = Math.Min(leftmost, child.State.BranchExterior.Left);
403408
rightmost = Math.Max(rightmost, child.State.BranchExterior.Right);
404409
}

0 commit comments

Comments
 (0)