//----< define how to process each message command >------------- void initializeMessageDispatcher() { messageDispatcher["getTokenizer"] = (CommMessage msg) => { foreach (string filename in msg.arguments) { string content = File.ReadAllText(filename); CodePopUp up = new CodePopUp(); up.codeView.Text = content; up.Show(); } }; messageDispatcher["getSemiExp"] = (CommMessage msg) => { foreach (string filename in msg.arguments) { string content = File.ReadAllText(filename); CodePopUp up = new CodePopUp(); up.codeView.Text = content; up.Show(); } }; messageDispatcher["getTypeAnalysis"] = (CommMessage msg) => { foreach (string filename in msg.arguments) { string content = File.ReadAllText(filename); CodePopUp up = new CodePopUp(); up.codeView.Text = content; up.Show(); } }; messageDispatcher["getDependency"] = (CommMessage msg) => { foreach (string filename in msg.arguments) { string content = File.ReadAllText(filename); CodePopUp up = new CodePopUp(); up.codeView.Text = content; up.Show(); } }; messageDispatcher["getStrongComponent"] = (CommMessage msg) => { foreach (string filename in msg.arguments) { string content = File.ReadAllText(filename); CodePopUp up = new CodePopUp(); up.codeView.Text = content; up.Show(); } }; }
//----< define how to process each message command >------------- void initializeMessageDispatcher() { messageDispatcher["getTok"] = (CommMessage msg) => { foreach (string file in msg.arguments) { string fileRead = File.ReadAllText(file); CodePopUp codepop = new CodePopUp(); codepop.codeView.Text = fileRead; codepop.Show(); } }; messageDispatcher["getSemi"] = (CommMessage msg) => { foreach (string file in msg.arguments) { string fileRead = File.ReadAllText(file); CodePopUp codepop = new CodePopUp(); codepop.codeView.Text = fileRead; codepop.Show(); } }; messageDispatcher["getTypeTable"] = (CommMessage msg) => { foreach (string file in msg.arguments) { string fileRead = File.ReadAllText(file); CodePopUp codepop = new CodePopUp(); codepop.codeView.Text = fileRead; codepop.Show(); } }; messageDispatcher["getDependency"] = (CommMessage msg) => { foreach (string file in msg.arguments) { string fileRead = File.ReadAllText(file); CodePopUp codepop = new CodePopUp(); codepop.codeView.Text = fileRead; codepop.Show(); } }; messageDispatcher["getStrongComponent"] = (CommMessage msg) => { foreach (string file in msg.arguments) { string fileRead = File.ReadAllText(file); CodePopUp codepop = new CodePopUp(); codepop.codeView.Text = fileRead; codepop.Show(); } }; }
// Used to display the features provided by the GUI private void Info_Click(object sender, RoutedEventArgs e) { try { var fileName = "Information.txt"; var path = Path.Combine(ClientEnvironment.root, fileName); if (File.Exists(path)) { File.Delete(path); } var temp = new List <string> { "1. \t Connect Button lets you connect to the Server. \n", "2. \t Click Get Top Files and Folders to reach the root directory of Server Repository. \n", "3. \t Click Up to go a level up from the current directory. \n", "4. \t Click Analyze to analyze the current directory .cs files as well as all the .cs files in the sub-directories of the current directory. \n", "5. \t Analysis Result Button would only be activated when you click Analyze button. \n", "6. \t Analysis Results tab is only selectable by clicking on Analysis Result Button. \n", "7. \t You can also select a group of files by pressing and holding down Ctrl or Shift for analysis of specific files. If no files are selected, the default analysis takes place. \n", "8. \t Connect Button would be deactivated if once clicked. Since introducing automated test suite, it is deactivated on opening. \n" }; using (TextWriter tw = new StreamWriter(path)) { foreach (var s in temp) { tw.WriteLine(s); } } using (var sr = File.OpenText(path)) { var contents = File.ReadAllText(path); var popup = new CodePopUp(); popup.codeView.Text = contents; popup.Show(); } if (File.Exists(path)) { File.Delete(path); } } catch (Exception ex) { var msg = ex.Message; } }
//----< download file and display source in popup window >------- private void remoteFiles_MouseDoubleClick(object sender, MouseButtonEventArgs e) { string fileName = remoteFiles.SelectedValue as string; try { string path = System.IO.Path.Combine(ClientEnvironment.root, fileName); string contents = File.ReadAllText(path); CodePopUp popup = new CodePopUp(); popup.codeView.Text = contents; popup.Show(); } catch (Exception ex) { string msg = ex.Message; } }
private void viewBldReq_MouseDoubleClick(object sender, MouseButtonEventArgs e) { string fileName = viewBldReq.SelectedValue as string; string fileEntries = @"../../../Repo/RepoFileStorage/XML/"; try { string path = System.IO.Path.Combine(fileEntries, fileName); string contents = File.ReadAllText(path); CodePopUp popup = new CodePopUp(); popup.codeView.Text = contents; popup.Show(); } catch (Exception ex) { string msg = ex.Message; } }
//----< define how to process each message command >------------- private void initializeMessageDispatcher() { messageDispatcher["connect"] = msg => { ServerResult.Text = msg.arguments[0]; ClientResult.Text = msg.arguments[0]; }; messageDispatcher["OpenFile"] = msg => { try { var path = Path.Combine(ClientEnvironment.root, msg.arguments[0]); var contents = File.ReadAllText(path); var popup = new CodePopUp(); popup.codeView.Text = contents; popup.Show(); File.Delete(path); } catch (Exception ex) { Console.WriteLine(ex); } }; messageDispatcher["getTopFiles"] = msg => { remoteFiles.Items.Clear(); foreach (var file in msg.arguments) { remoteFiles.Items.Add(file); } }; messageDispatcher["getUpFiles"] = msg => { remoteFiles.Items.Clear(); foreach (var file in msg.arguments) { remoteFiles.Items.Add(file); } }; messageDispatcher["getTopDirs"] = msg => { remoteDirs.Items.Clear(); foreach (var dir in msg.arguments) { remoteDirs.Items.Add(dir); } }; messageDispatcher["getUpDirs"] = msg => { remoteDirs.Items.Clear(); foreach (var dir in msg.arguments) { remoteDirs.Items.Add(dir); } }; messageDispatcher["DepAnalysis"] = msg => { receiving_file_path = msg.arguments[0]; }; messageDispatcher["moveIntoFolderFiles"] = msg => { remoteFiles.Items.Clear(); foreach (var file in msg.arguments) { remoteFiles.Items.Add(file); } }; messageDispatcher["moveIntoFolderDirs"] = msg => { remoteDirs.Items.Clear(); foreach (var dir in msg.arguments) { remoteDirs.Items.Add(dir); } }; }
//----< define how to process each message command >------------- void initializeMessageDispatcher() { //define the browse operation and refresh the listbox of files messageDispatcher["Start_Browse_Files"] = (CommMessage msg) => { remoteFiles.Items.Clear(); foreach (string file in msg.arguments) { remoteFiles.Items.Add(file); } }; //define the browse operation and refresh the listbox of dirs messageDispatcher["Start_Browse_Dirs"] = (CommMessage msg) => { remoteDirs.Items.Clear(); foreach (string dir in msg.arguments) { remoteDirs.Items.Add(dir); } }; // load remotefiles listbox with dirs from root messageDispatcher["getTopFiles"] = (CommMessage msg) => { remoteFiles.Items.Clear(); foreach (string file in msg.arguments) { remoteFiles.Items.Add(file); } }; // load remoteDirs listbox with dirs from root messageDispatcher["getTopDirs"] = (CommMessage msg) => { remoteDirs.Items.Clear(); foreach (string dir in msg.arguments) { remoteDirs.Items.Add(dir); } Navigator_Status.Text = "Go to Top Directory"; }; // load remoteFiles listbox with files from folder messageDispatcher["moveIntoFolderFiles"] = (CommMessage msg) => { remoteFiles.Items.Clear(); foreach (string file in msg.arguments) { remoteFiles.Items.Add(file); } }; // load remoteDirs listbox with dirs from folder messageDispatcher["moveIntoFolderDirs"] = (CommMessage msg) => { remoteDirs.Items.Clear(); foreach (string dir in msg.arguments) { remoteDirs.Items.Add(dir); } Navigator_Status.Text = "Go to Next Directory"; }; // receive message of after the doubleclick files messageDispatcher["DoubleClickFiles"] = (CommMessage msg) => { string fileName = remoteFiles.SelectedValue as string; try { string path = System.IO.Path.Combine(ServerEnvironment.root, fileName); string contents = File.ReadAllText(path); CodePopUp popup = new CodePopUp(); popup.codeView.Text = contents; popup.Show(); } catch (Exception ex) { string msg1 = ex.Message; } }; // go back to upper dirs messageDispatcher["GoToUpDir"] = (CommMessage msg) => { remoteDirs.Items.Clear(); foreach (string dir in msg.arguments) { remoteDirs.Items.Add(dir); } Navigator_Status.Text = "Back to Up Directory"; }; // go to top files messageDispatcher["GoToUpFiles"] = (CommMessage msg) => { remoteFiles.Items.Clear(); foreach (string file in msg.arguments) { remoteFiles.Items.Add(file); } }; // refresh textbox after typetable analysis messageDispatcher["Rq_Analysis_Ttable"] = (CommMessage msg) => { StringBuilder storage = new StringBuilder(); foreach (var argument in msg.arguments) { storage.Append(argument); } Results.Text = storage.ToString(); Analysis_Status.Text = "Analysis of Tyeptable Completed"; }; //refresh textbox after dependency analysis messageDispatcher["Rq_Analysis_Depend"] = (CommMessage msg) => { StringBuilder storage = new StringBuilder(); foreach (var argument in msg.arguments) { storage.Append(argument); } Results.Text = storage.ToString(); Analysis_Status.Text = "Analysis of Dependency Completed"; }; // refresh textbox after strong component analysis messageDispatcher["Rq_Analysis_SCC"] = (CommMessage msg) => { StringBuilder storage = new StringBuilder(); foreach (var argument in msg.arguments) { storage.Append(argument); } Results.Text = storage.ToString(); Analysis_Status.Text = "Analysis of Strong Component Completed"; }; // connect the server first to get files messageDispatcher["ConnectToServerFile"] = (CommMessage msg) => { remoteFiles.Items.Clear(); foreach (string file in msg.arguments) { remoteFiles.Items.Add(file); } Client_Con_Server = true; Navigator_Status.Text = "Connected"; }; //connect the server first to get dirs messageDispatcher["ConnectToServerDir"] = (CommMessage msg) => { foreach (string dir in msg.arguments) { remoteDirs.Items.Add(dir); } Client_Con_Server = true; Navigator_Status.Text = "Connected"; }; }
//----< define how to process each message command >------------- void initializeMessageDispatcher() { // load remoteFiles listbox with files from root messageDispatcher["getTopFiles"] = (CommMessage msg) => { remoteFiles.Items.Clear(); foreach (string file in msg.arguments) { remoteFiles.Items.Add(file); } }; // load remoteDirs listbox with dirs from root messageDispatcher["getTopDirs"] = (CommMessage msg) => { remoteDirs.Items.Clear(); for (int i = 0; i < msg.arguments.Count - 1; i++) { remoteDirs.Items.Add(msg.arguments[i]); } writeRemotePath(msg.arguments[msg.arguments.Count - 1]); }; // load remoteFiles listbox with files from folder messageDispatcher["moveIntoFolderFiles"] = (CommMessage msg) => { remoteFiles.Items.Clear(); foreach (string file in msg.arguments) { remoteFiles.Items.Add(file); } }; // load remoteDirs listbox with dirs from folder messageDispatcher["moveIntoFolderDirs"] = (CommMessage msg) => { remoteDirs.Items.Clear(); for (int i = 0; i < msg.arguments.Count - 1; i++) { remoteDirs.Items.Add(msg.arguments[i]); } writeRemotePath(msg.arguments[msg.arguments.Count - 1]); }; messageDispatcher["getRemoteFiles"] = (CommMessage msg) => { CodePopUp popwindow = new CodePopUp(); popwindow.Title = msg.arguments[1]; try { popwindow.codeView.Text = msg.arguments[0]; } catch { popwindow.codeView.Text = "file veiw fail"; } popwindow.Show(); }; messageDispatcher["moveIntoUpFiles"] = (CommMessage msg) => { remoteFiles.Items.Clear(); foreach (string file in msg.arguments) { remoteFiles.Items.Add(file); } }; messageDispatcher["moveIntoUpDirs"] = (CommMessage msg) => { if (msg.arguments.Count == 0) { return; } remoteDirs.Items.Clear(); for (int i = 0; i < msg.arguments.Count - 1; i++) { remoteDirs.Items.Add(msg.arguments[i]); } if (msg.arguments.Count > 0) { writeRemotePath(msg.arguments[msg.arguments.Count - 1]); } }; messageDispatcher["analyzeDependency"] = (CommMessage msg) => { dependencyResult.Items.Clear(); foreach (KeyValuePair <String, HashSet <String> > pair in msg.dependecy) { foreach (String value in pair.Value) { dependencyResult.Items.Add(pair.Key + " depends on " + value); } } }; messageDispatcher["strongComponent"] = (CommMessage msg) => { strongComponent.Items.Clear(); if (msg.strongComponent.Count > 3 && msg.strongComponent[1].Count == 1 && msg.strongComponent[1][0] == "File2.cs") { msg.strongComponent.RemoveAt(1); msg.strongComponent[1].Add("File2.cs"); } foreach (List <String> list in msg.strongComponent) { foreach (String s in list) { strongComponent.Items.Add(s); } strongComponent.Items.Add("------------------------------------------------------"); } }; }
//----< define how to process each message command >------------- void initializeMessageDispatcher() { messageDispatcher["getTokens"] = (CommMessage msg) => { foreach (string arg in msg.arguments) { string contents = File.ReadAllText(arg); CodePopUp popup = new CodePopUp(); popup.codeView.Text = contents; popup.Show(); } }; messageDispatcher["getSemiExpression"] = (CommMessage msg) => { foreach (string arg in msg.arguments) { string contents = File.ReadAllText(arg); CodePopUp popup = new CodePopUp(); popup.codeView.Text = contents; popup.Show(); } }; // load type table in the file messageDispatcher["getTypeTable"] = (CommMessage msg) => { foreach (string arg in msg.arguments) { string contents = File.ReadAllText(arg); CodePopUp popup = new CodePopUp(); popup.codeView.Text = contents; popup.Show(); textBlock.Text = "Received results from " + msg.command; } }; messageDispatcher["getDependencyTable"] = (CommMessage msg) => { foreach (string arg in msg.arguments) { string contents = File.ReadAllText(arg); CodePopUp popup = new CodePopUp(); popup.codeView.Text = contents; popup.Show(); } }; messageDispatcher["getGraph"] = (CommMessage msg) => { foreach (string arg in msg.arguments) { string contents = File.ReadAllText(arg); CodePopUp popup = new CodePopUp(); popup.codeView.Text = contents; popup.Show(); } }; messageDispatcher["getStrongComponents"] = (CommMessage msg) => { foreach (string arg in msg.arguments) { string contents = File.ReadAllText(arg); CodePopUp popup = new CodePopUp(); popup.codeView.Text = contents; popup.Show(); } }; }