예제 #1
0
        // 编辑节点信息
        private void EditNode(object parameter)
        {
            int index = (int)parameter;

            if (index < 0)
            {
                return;
            }

            if (CurrentNodeIndex != index)
            {
                CurrentNodeIndex = index;
            }

            NodeInfoDlg          dlg       = new NodeInfoDlg();
            NodeInfoDlgViewModel viewModel = new NodeInfoDlgViewModel()
            {
                Title = "编辑节点" + index.ToString(), X = Record.Nodes[index].X, Y = Record.Nodes[index].Y, Demand = Record.Nodes[index].Demand
            };

            dlg.DataContext = viewModel;
            dlg.ShowDialog();

            if (!viewModel.IsCancel)
            {
                Record.Segments.Clear();
                Record.Nodes[index].X      = viewModel.X;
                Record.Nodes[index].Y      = viewModel.Y;
                Record.Nodes[index].Demand = viewModel.Demand;
            }
        }
예제 #2
0
        public bool Begin()
        {
            NodeInfoDlg          dlg = new NodeInfoDlg();
            NodeInfoDlgViewModel vm  = new NodeInfoDlgViewModel();

            vm.Title        = "添加节点";
            dlg.DataContext = vm;
            dlg.ShowDialog();
            if (vm.Result)
            {
                X      = vm.X;
                Y      = vm.Y;
                Demand = vm.Demand;
                return(true);
            }
            return(false);
        }
예제 #3
0
        // 添加节点
        private void AddNode(object parameter)
        {
            NodeInfoDlg          dlg       = new NodeInfoDlg();
            NodeInfoDlgViewModel viewModel = new NodeInfoDlgViewModel()
            {
                Title = "添加节点" + Record.Nodes.Count.ToString()
            };

            dlg.DataContext = viewModel;
            dlg.ShowDialog();

            if (!viewModel.IsCancel)
            {
                Record.Nodes.Add(new Node {
                    X = viewModel.X, Y = viewModel.Y, Demand = viewModel.Demand
                });
                CurrentNodeIndex = Record.Nodes.Count - 1;
            }
        }
예제 #4
0
        public bool Begin(Node currentNode)
        {
            NodeInfoDlg          dlg = new NodeInfoDlg();
            NodeInfoDlgViewModel vm  = new NodeInfoDlgViewModel();

            vm.Title        = "编辑节点" + currentNode.ID.ToString();
            vm.X            = currentNode.X;
            vm.Y            = currentNode.Y;
            vm.Demand       = currentNode.Demand;
            dlg.DataContext = vm;
            dlg.ShowDialog();

            if (vm.Result)
            {
                NewX      = vm.X;
                NewY      = vm.Y;
                NewDemand = vm.Demand;
                return(true);
            }
            return(false);
        }