コード例 #1
0
ファイル: MainWindow.xaml.cs プロジェクト: AnDDen/Hydrology
 private void initNode_SettingsButtonClick(object sender, EventArgs e)
 {
     InitNodeControl node = sender as InitNodeControl;
     var initSettings = new InitSettingsWindow(FolderDialog)
     {
         Owner = this,
         InitPath = node.InitPath,
         WindowStartupLocation = System.Windows.WindowStartupLocation.CenterOwner
     };
     bool? dialogResult = initSettings.ShowDialog();
     if (dialogResult.HasValue && dialogResult.Value)
     {
         node.InitPath = initSettings.InitPath;
     }
 }
コード例 #2
0
ファイル: MainWindow.xaml.cs プロジェクト: AnDDen/Hydrology
        private void Canvas_Drop(object sender, DragEventArgs e)
        {
            if (IsDragDrop)
            {
                if (e.Data.GetDataPresent("NodeFormat"))
                {
                    BaseNodeControl node = (BaseNodeControl)e.Data.GetData("NodeFormat");
                    if (node is InitNodeControl)
                    {
                        var initSettings = new InitSettingsWindow(FolderDialog)
                        {
                            Owner = this,
                            InitPath = (node as InitNodeControl).InitPath,
                            WindowStartupLocation = System.Windows.WindowStartupLocation.CenterOwner
                        };
                        bool? dialogResult = initSettings.ShowDialog();
                        if (dialogResult.HasValue && dialogResult.Value)
                        {
                            (node as InitNodeControl).InitPath = initSettings.InitPath;
                            Canvas.Children.Add(node);
                            Point pos = e.GetPosition(Canvas);
                            Canvas.SetLeft(node, pos.X);
                            Canvas.SetTop(node, pos.Y);
                            experimentGraph.Nodes.Add(node);
                        }
                        IsDragDrop = false;
                    }
                    else if (node is RunProcessNodeControl)
                    {
                        var runProcessSettings = new RunProcessSettingsWindow(FileDialog)
                        {
                            ProcessName = (node as RunProcessNodeControl).ProcessName,
                            Owner = this,
                            WindowStartupLocation = System.Windows.WindowStartupLocation.CenterOwner
                        };
                        bool? dialogResult = runProcessSettings.ShowDialog();
                        if (dialogResult.HasValue && dialogResult.Value)
                        {
                            (node as RunProcessNodeControl).ProcessName = runProcessSettings.ProcessName;
                            Canvas.Children.Add(node);
                            Point pos = e.GetPosition(Canvas);
                            Canvas.SetLeft(node, pos.X);
                            Canvas.SetTop(node, pos.Y);
                            experimentGraph.Nodes.Add(node);
                        }
                        IsDragDrop = false;
                    }
                    else if (node is LoopControl)
                    {
                        var loopSettings = new LoopSettingsWindow()
                        {
                            Owner = this,
                            WindowStartupLocation = System.Windows.WindowStartupLocation.CenterOwner
                        };
                        bool? dialogResult = loopSettings.ShowDialog();
                        if (dialogResult.HasValue && dialogResult.Value)
                        {
                            (node as LoopControl).VarName = loopSettings.VarName;
                            (node as LoopControl).StartValue = loopSettings.StartValue;
                            (node as LoopControl).EndValue = loopSettings.EndValue;
                            (node as LoopControl).Step = loopSettings.Step;

                            Canvas.Children.Add(node);
                            Point pos = e.GetPosition(Canvas);
                            Canvas.SetLeft(node, pos.X);
                            Canvas.SetTop(node, pos.Y);
                            experimentGraph.Nodes.Add(node);
                        }
                        IsDragDrop = false;
                    }
                }

                if (e.Data.GetDataPresent("NodeNameFormat"))
                {
                    String nodeName = e.Data.GetData("NodeNameFormat").ToString();
                    Point pos = e.GetPosition(Canvas);
                    AddAlgNode(nodeName, pos.X, pos.Y);
                    IsDragDrop = false;
                }
            }
        }