private void BlockList_MouseDoubleClick(object sender, MouseButtonEventArgs e) { string nm = BlockList.SelectedItem.ToString(); if (dispatcherTimer != null) { dispatcherTimer.Stop(); } if (myDiag != null) { myDiag.Close(); myDiag = null; } myBlock = MC7Converter.GetAWLBlock(_myconn.PLCGetBlockInMC7(nm), 0, myblkFld); if (myBlock != null) { if (myBlock.BlockType == PLCBlockType.DB) { toppanel.ClearValue(HeightProperty); toppanel.ClearValue(DockPanel.DockProperty); textEditor.Visibility = System.Windows.Visibility.Collapsed; } else { toppanel.Height = 160; toppanel.SetValue(DockPanel.DockProperty, Dock.Top); textEditor.Visibility = System.Windows.Visibility.Visible; } textEditor.Text = myBlock.ToString(); blockName.Content = nm; Upload.IsEnabled = true; Optimize.IsEnabled = true; Diag.IsEnabled = true; if (myBlock.BlockType == PLCBlockType.DB) { myTree.DataContext = ((S7DataBlock)myBlock).Structure.Children; } else { myTree.DataContext = ((S7FunctionBlock)myBlock).Parameter.Children; } } }
private void Optimize_Click(object sender, RoutedEventArgs e) { AWLCodeOptimizer.OptimizeAWL((S7FunctionBlock)myBlock, 0); textEditor.Text = myBlock.ToString(); }