public void MouseRightClick(NodeDotViewModel node) { if (SelectedNode != null) { switch (MainViewModel.ActionControlVM.ModeStatus) { case ModeType.EdgeAdd: if (NodePixels.Where(x => x.ID == SelectedNode.ID).Single().ConnectedNodes.Where(y => y.ID == node.ID).Count() == 0) { //SelectedNode.ConnectedNodes.Add(node); NodePixels.Where(x => x.ID == SelectedNode.ID).Single().ConnectedNodes.Add(node); } break; case ModeType.EdgeDel: NodePixels.Where(x => x.ID == node.ID).Single().ConnectedNodes.Remove(node); SelectedNode.ConnectedNodes.Remove(node); RaisePropertyChanged(nameof(NodePixels)); RaisePropertyChanged(nameof(EdgePixels)); //SelectedNode.ConnectedNodes.Where(x => x.ID == node.ID).Select(x => SelectedNode.ConnectedNodes.Remove(x)); //NodePixels.Where(x => x.ID == node.ID).Select(x => NodePixels.Remove(x)); break; } RaisePropertyChanged(nameof(EdgePixels)); } }
public void DataLoadProcess(string filePath) { MapDataList mapDataList = MapDataList.Instance; mapDataList.MapData.Nodes.Clear(); mapDataList.MapData.Edges.Clear(); MainViewModel.WorkSpaceVM.NodePixels.Clear(); MainViewModel.WorkSpaceVM.EdgePixels.Clear(); mapDataList.Load(filePath); if (mapDataList != null && mapDataList.MapData.Nodes != null && mapDataList.MapData.Edges != null) { foreach (Node nodeData in mapDataList.MapData.Nodes) { NodeDotViewModel t = new NodeDotViewModel() { X = nodeData.NOD_X, Y = nodeData.NOD_Y, ID = nodeData.NOD_ID, Text = nodeData.NOD_ID, Margin = new Thickness(nodeData.NOD_X, nodeData.NOD_Y, 0, 0), Floor = nodeData.NOD_FLOOR, IsUse = nodeData.NOD_ISUSE == true ? "1" : "0", Map = nodeData.MAP_ID }; if (nodeData.NOD_CATEGORY != null) { try { t.Type = (NodeType)Enum.Parse(typeof(NodeType), nodeData.NOD_CATEGORY, true); } catch { t.Type = NodeType.Normal; } } else { t.Type = NodeType.Normal; } MainViewModel.WorkSpaceVM.NodePixels.Add(t); } foreach (Edge edgeData in mapDataList.MapData.Edges) { MainViewModel.WorkSpaceVM.NodePixels.Where(x => x.ID == edgeData.EDG_NODE1).Single().ConnectedNodes.Add(MainViewModel.WorkSpaceVM.NodePixels.Where(y => y.ID == edgeData.EDG_NODE2).Single()); } } else { MessageBox.Show("파일을 읽는중 오류가 발생하였습니다."); } }
public void WorkSpaceClick(NodeDotViewModel node, double posX, double posY) { double px = posX - (posX % 8); double py = posY - (posY % 8); px = px < 0 ? 0 : px; py = py < 0 ? 0 : py; NodeDotViewModel t = new NodeDotViewModel() { X = px, Y = py, ID = Guid.NewGuid().ToString(), Type = Model.NodeType.Normal, Margin = new Thickness(px, py, 0, 0), Floor = MainViewModel.ActionControlVM.FloorString, Map = MainViewModel.ActionControlVM.MapString, IsUse = "1", }; t.Text = t.ID; switch (MainViewModel.ActionControlVM.ModeStatus) { case ModeType.EdgeAdd: break; case ModeType.EdgeDel: break; case ModeType.NodeDelete: if (NodePixels.Where(x => x.ID == node.ID).Count() == 1) { NodePixels.Remove(NodePixels.Where(x => x.ID == node.ID).Single()); } break; } }
public void WorkSpaceDoubleClick(double posX, double posY) { double px = posX - (posX % 8); double py = posY - (posY % 8); px = px < 0 ? 0 : px; py = py < 0 ? 0 : py; NodeDotViewModel t = new NodeDotViewModel() { X = px, Y = py, ID = Guid.NewGuid().ToString(), Type = Model.NodeType.Normal, Margin = new Thickness(px, py, 0, 0), Floor = MainViewModel.ActionControlVM.FloorString, Map = MainViewModel.ActionControlVM.MapString, IsUse = "1", }; t.Text = t.ID; switch (MainViewModel.ActionControlVM.ModeStatus) { case ModeType.NodeElevator: t.Type = NodeType.Elevator; if (NodePixels.Select(x => x).Where(y => y.ID == t.ID).Count() == 0) { NodePixels.Add(t); } break; case ModeType.NodeEscalator: t.Type = NodeType.Escalator; if (NodePixels.Select(x => x).Where(y => y.ID == t.ID).Count() == 0) { NodePixels.Add(t); } break; case ModeType.NodeFacility: t.Type = NodeType.Facility; if (NodePixels.Select(x => x).Where(y => y.ID == t.ID).Count() == 0) { NodePixels.Add(t); } break; case ModeType.NodeKiosk: t.Type = NodeType.Kiosk; if (NodePixels.Select(x => x).Where(y => y.ID == t.ID).Count() == 0) { NodePixels.Add(t); } break; case ModeType.NodeLegend: t.Type = NodeType.Legend; if (NodePixels.Select(x => x).Where(y => y.ID == t.ID).Count() == 0) { NodePixels.Add(t); } break; case ModeType.NodeNormal: t.Type = NodeType.Normal; if (NodePixels.Select(x => x).Where(y => y.ID == t.ID).Count() == 0) { NodePixels.Add(t); } break; case ModeType.NodeStairs: t.Type = NodeType.Stairs; if (NodePixels.Select(x => x).Where(y => y.ID == t.ID).Count() == 0) { NodePixels.Add(t); } break; } }