๋ฐ˜์‘ํ˜•

NodeNetwork์— ๋Œ€ํ•œ ๊ธฐ์ดˆ ์„ค๋ช…์€ ์•„๋ž˜ ํฌ์ŠคํŒ…์„ ์ฐธ๊ณ ํ•˜์„ธ์š”.

[.Net] WPF NodeNetwork ๊ธฐ๋ณธ ๊ฐœ๋…๊ณผ ํŠน์ง• ์•Œ์•„๋ณด๊ธฐ

 

[.Net] WPF NodeNetwork ๊ธฐ๋ณธ ๊ฐœ๋…๊ณผ ํŠน์ง• ์•Œ์•„๋ณด๊ธฐ

์†Œ๊ฐœ ์ง€๋‚œ ํฌ์ŠคํŒ…์—์„œ Node Editor UI์— ๋Œ€ํ•ด ์†Œ๊ฐœ๋ฅผ ํ–ˆ์—ˆ์Šต๋‹ˆ๋‹ค. Node Editor๋Š” ๋ชจ๋“ˆ ๋‹จ์œ„์ธ ๋…ธ๋“œ(Node)๋ฅผ ๋“œ๋ž˜๊ทธ ์•ค ๋“œ๋กญ์œผ๋กœ ์—ฐ๊ฒฐํ•ด ์ฃผ๋Š” ํŽธ์ง‘ ๊ธฐ๋Šฅ์ž…๋‹ˆ๋‹ค. [.Net] Node Editor UI ํ”„๋ ˆ์ž„์›Œํฌ ์†Œ๊ฐœ - NodeNetwo..

luckygg.tistory.com

์†Œ๊ฐœ

๋ณดํ†ต ํ”„๋กœ๊ทธ๋ž˜๋ฐ์„ ์ฒ˜์Œ ๋ฐฐ์šฐ๋ฉด Hello world๋ถ€ํ„ฐ ์‹œ์ž‘์„ ํ•˜์ฃ . ์ด๋Š” ๋งจ ์ฒ˜์Œ ์–ด๋–ป๊ฒŒ ์‹œ์ž‘ํ•˜๋Š”์ง€ ๋ณด์—ฌ์ฃผ๋Š” ๊ฒƒ์„ ์˜๋ฏธํ•ฉ๋‹ˆ๋‹ค. ๋ณธ ํฌ์ŠคํŒ…์€ NodeNetwork ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋ฅผ ์‚ฌ์šฉํ•ด์„œ ์–ด๋–ป๊ฒŒ ํ”„๋กœ์ ํŠธ๋ฅผ ๊ตฌ์„ฑํ•˜๊ณ  ์–ด๋–ค ๋™์ž‘์„ ํ•˜๋Š”์ง€ ๋ณด์—ฌ์ฃผ๊ณ ์ž ํ•ฉ๋‹ˆ๋‹ค. ์šฐ์„  ๊ฒฐ๊ณผ๋ฌผ์€ ์•„๋ž˜์™€ ๊ฐ™์Šต๋‹ˆ๋‹ค.

Hello world ๊ฒฐ๊ณผ๋ฌผ
Hello world ๊ฒฐ๊ณผ๋ฌผ

WPF ํ™˜๊ฒฝ ๊ตฌ์„ฑํ•˜๊ธฐ

์•„๋ž˜ ๊ทธ๋ฆผ๊ณผ ๊ฐ™์ด WPF ์•ฑ(.NET Framework)์„ ์„ ํƒํ•˜๊ณ  ExamNodeUI ์ด๋ฆ„์œผ๋กœ ํ”„๋กœ์ ํŠธ๋ฅผ ์ƒ์„ฑํ•ฉ๋‹ˆ๋‹ค.

WPF ํ”„๋กœ์ ํŠธ ์ƒ์„ฑ
WPF ํ”„๋กœ์ ํŠธ ์ƒ์„ฑ

๋ˆ„๊ฒŸ ํŒจํ‚ค์ง€์—์„œ NodeNetwork๋ฅผ ์„ค์น˜ํ•˜๊ธฐ ์ „์— ํ”„๋กœ์ ํŠธ ์†์„ฑ์—์„œ ํ”„๋ ˆ์ž„์›Œํฌ๋ฅผ 4.7.2๋กœ ๋ณ€๊ฒฝํ•ฉ๋‹ˆ๋‹ค. NodeNetwork v6.0.0์€ .NET Framework 4.7.2 ์ด์ƒ์—์„œ ์‚ฌ์šฉ ๊ฐ€๋Šฅํ•ฉ๋‹ˆ๋‹ค.

ํ”„๋ ˆ์ž„์›Œํฌ ๋ฒ„์ „ ๋ณ€๊ฒฝ
ํ”„๋ ˆ์ž„์›Œํฌ ๋ฒ„์ „ ๋ณ€๊ฒฝ

๋ˆ„๊ฒŸ ํŒจํ‚ค์ง€์—์„œ NodeNetwork๋ฅผ ๊ฒ€์ƒ‰ํ•˜๊ณ  ํ”„๋กœ์ ํŠธ์— ์„ค์น˜ํ•ฉ๋‹ˆ๋‹ค.

NuGet Package ์„ค์น˜
NuGet Package ์„ค์น˜

Hello world ํ”„๋กœ์ ํŠธ ๋งŒ๋“ค๊ธฐ

ํ”„๋กœ์ ํŠธ์˜ App.xaml.cs ํŒŒ์ผ์— ์•„๋ž˜์— ํ‘œ์‹œํ•œ ์ฝ”๋“œ๋ฅผ ์ถ”๊ฐ€ํ•ฉ๋‹ˆ๋‹ค.

using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
using NodeNetwork; //namespace ์ถ”๊ฐ€
namespace ExamNodeUI
{
/// <summary>
/// App.xaml์— ๋Œ€ํ•œ ์ƒํ˜ธ ์ž‘์šฉ ๋…ผ๋ฆฌ
/// </summary>
public partial class App : Application
{
//OnStartup ์ถ”๊ฐ€
protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
NNViewRegistrar.RegisterSplat();
}
}
}

ํ”„๋กœ์ ํŠธ์˜ MainWindow.xaml ํŒŒ์ผ์— ์•„๋ž˜์— ํ‘œ์‹œํ•œ ์ฝ”๋“œ๋ฅผ ์ถ”๊ฐ€ํ•ฉ๋‹ˆ๋‹ค.

<Window x:Class="ExamNodeUI.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:ExamNodeUI"
xmlns:nodenetwork="clr-namespace:NodeNetwork.Views;assembly=NodeNetwork" //์ถ”๊ฐ€
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
<Grid>
<nodenetwork:NetworkView x:Name="networkView" /> //์ถ”๊ฐ€
</Grid>
</Window>

NetworkView๋ฅผ ์ถ”๊ฐ€ํ•˜๋ฉด MainWindow๊ฐ€ ์•„๋ž˜์™€ ๊ฐ™์ด ๋ณ€๊ฒฝ๋ฉ๋‹ˆ๋‹ค.

NetworkView๊ฐ€ ์ถ”๊ฐ€๋œ ๋ชจ์Šต
NetworkView๊ฐ€ ์ถ”๊ฐ€๋œ ๋ชจ์Šต

์ด๋ฒˆ์—๋Š” ํ”„๋กœ์ ํŠธ์˜ MainWindow.xaml.cs ํŒŒ์ผ์—์„œ ์•„๋ž˜์˜ ๋„ค์ž„์ŠคํŽ˜์ด์Šค๋ฅผ ์ถ”๊ฐ€ํ•ฉ๋‹ˆ๋‹ค.

using NodeNetwork.ViewModels;
using DynamicData;

๊ทธ๋ฆฌ๊ณ  MainWindow() ํ•จ์ˆ˜์— ์•„๋ž˜์˜ ์ฝ”๋“œ๋ฅผ ์ถ”๊ฐ€ํ•ฉ๋‹ˆ๋‹ค.

public MainWindow()
{
InitializeComponent();
//Create a new viewmodel for the NetworkView
var network = new NetworkViewModel();
//Create the node for the first node, set its name and add it to the network.
var node1 = new NodeViewModel();
node1.Name = "Node 1";
network.Nodes.Add(node1);
//Create the viewmodel for the input on the first node, set its name and add it to the node.
var node1Input = new NodeInputViewModel();
node1Input.Name = "Node 1 input";
node1.Inputs.Add(node1Input);
//Create the second node viewmodel, set its name, add it to the network and add an output in a similar fashion.
var node2 = new NodeViewModel();
node2.Name = "Node 2";
network.Nodes.Add(node2);
var node2Output = new NodeOutputViewModel();
node2Output.Name = "Node 2 output";
node2.Outputs.Add(node2Output);
//Assign the viewmodel to the view.
networkView.ViewModel = network;
}

์ด์ œ ๋นŒ๋“œํ•˜๊ณ  ์‹คํ–‰ํ•˜๋ฉด ์•„๋ž˜์™€ ๊ฐ™์€ ๊ฒฐ๊ณผ๋ฅผ ๋ณด์—ฌ์ค๋‹ˆ๋‹ค.

์‹คํ–‰ ํ™”๋ฉด
์‹คํ–‰ ํ™”๋ฉด

์•„์ฃผ ๊ฐ„๋‹จํ•œ ์˜ˆ์ œ์˜€์Šต๋‹ˆ๋‹ค. ํ”„๋กœ๊ทธ๋žจ์€ ์•„๋ž˜ ์ฒจ๋ถ€ ํŒŒ์ผ์„ ์ฐธ๊ณ ํ•˜์„ธ์š”. ์ฒจ๋ถ€ ํŒŒ์ผ ์šฉ๋Ÿ‰ ๋ฌธ์ œ๋กœ ํŒจํ‚ค์ง€ ํŒŒ์ผ์€ ์ œ๊ฑฐํ–ˆ์Šต๋‹ˆ๋‹ค.

ExamNodeUI.zip
0.01MB

๋ฐ˜์‘ํ˜•