■ NetworkView 엘리먼트를 사용해 노드를 만드는 방법을 보여준다.
▶ MainApplication.xaml
1 2 3 4 5 6 7 |
<Application x:Class="TestProject.MainApplication" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" StartupUri="MainWindow.xaml"> </Application> |
▶ MainApplication.xaml.cs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
using System.Windows; using NodeNetwork; namespace TestProject { /// <summary> /// 메인 애플리케이션 /// </summary> public partial class MainApplication : Application { //////////////////////////////////////////////////////////////////////////////////////////////////// Method ////////////////////////////////////////////////////////////////////////////////////////// Protected #region 시작시 처리하기 - OnStartup(e) /// <summary> /// 시작시 처리하기 /// </summary> /// <param name="e">이벤트 인자</param> protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); NNViewRegistrar.RegisterSplat(); } #endregion } } |
▶ MainWindow.xaml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
<Window x:Class="TestProject.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:nn="clr-namespace:NodeNetwork.Views;assembly=NodeNetwork" Width="800" Height="600" Title="TestProject" FontFamily="나눔고딕코딩" FontSize="16"> <nn:NetworkView Name="networkView" Margin="10" /> </Window> |
▶ MainWindow.xaml.cs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
using System.Windows; using DynamicData; using NodeNetwork.ViewModels; namespace TestProject { /// <summary> /// 메인 윈도우 /// </summary> public partial class MainWindow : Window { //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor ////////////////////////////////////////////////////////////////////////////////////////// Public #region 생성자 - MainWindow() /// <summary> /// 생성자 /// </summary> public MainWindow() { InitializeComponent(); NodeInputViewModel nodeInputViewModel1 = new NodeInputViewModel(); nodeInputViewModel1.Name = "Node 1 input"; NodeViewModel nodeViewModel1 = new NodeViewModel(); nodeViewModel1.Name = "Node 1"; nodeViewModel1.Position = new Point(200, 200); nodeViewModel1.Inputs.Add(nodeInputViewModel1); NodeOutputViewModel nodeOutputViewModel2 = new NodeOutputViewModel(); nodeOutputViewModel2.Name = "Node 2 output"; NodeViewModel nodeViewModel2 = new NodeViewModel(); nodeViewModel2.Name = "Node 2"; nodeViewModel2.Position = new Point(400, 200); nodeViewModel2.Outputs.Add(nodeOutputViewModel2); NetworkViewModel networkViewModel = new NetworkViewModel(); networkViewModel.Nodes.Add(nodeViewModel1); networkViewModel.Nodes.Add(nodeViewModel2); this.networkView.ViewModel = networkViewModel; } #endregion } } |