//W przypadku gdy okno PosAdd zostało zamknięte kasuje odniesienie do niego w głównym oknie private void PosAddWindowClosed(object sender, WindowClosedEventArgs e) { if (posAdd != null) { posAdd.WindowClosed -= PosAddWindowClosed; posAdd = null; AddToLog("Position Add window closed."); } }
//Uruchamia okno Position add lub jeżeli jest ono uruchomione aktywuje je private void PositionAddButton_Click(object sender, RoutedEventArgs e) { if (posAdd is null) { posAdd = new PositionAdd(); posAdd.WindowClosed += PosAddWindowClosed; posAdd.posAdd.DataSend += SendToRobot; if (serialPort.IsOpen) { posAdd.ConnectionInfoLbl.Content = "connected"; } else { posAdd.ConnectionInfoLbl.Content = "disconnected"; } posAdd.Show(); AddToLog("Position add window opened."); } else { posAdd.Activate(); } }