ProgWin
Наследование: System.Windows.Window, System.Windows.Markup.IComponentConnector
Пример #1
0
      /// <summary>
      /// This will load the file and pass the text to the editor.
      /// </summary>
      /// <param name="sender"></param>
      /// <param name="e"></param>
      private void submnuLoad_Click(object sender, RoutedEventArgs e)
      {
          Stream myStream = null;
          OpenFileDialog openFileDialog1 = new OpenFileDialog();

          openFileDialog1.InitialDirectory = "c:\\";
          openFileDialog1.Filter = "ssf files (*.ssf)|*.ssf|All files (*.*)|*.*";
          openFileDialog1.FilterIndex = 1;
          openFileDialog1.RestoreDirectory = true;
          String text = "";

          if (openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
          {
              try
              {
                  if ((myStream = openFileDialog1.OpenFile()) != null)
                  {
                      StreamReader sr = new StreamReader(openFileDialog1.FileName);
                      using(sr)
                      {
                          string line;
                          line = sr.ReadLine();
                          while ((line) != null)
                          {
                              text = text + line;
                              line = sr.ReadLine();
                              if (line != null)
                              {
                                  text += "\n";
                              }
                          }
                      }
                  }
                  ProgWin editor = new ProgWin(ProgWin.editorType.owner);
                  
                  editor.loadProgram(0, 0, text);
                  editor.Show();
                  editor.setUserList(userList);
              }
              catch (Exception ex)
              {
                  System.Windows.MessageBox.Show("Error: Could not read file from disk. Original error: " + ex.Message);
              }
          }

      }
Пример #2
0
 private void submnuNew_Click(object sender, RoutedEventArgs e)
 {
   ProgWin editor = new ProgWin(ProgWin.editorType.owner);
   //owner is the user itself. so pass the username here
   //list of the users in swarm
   //take the program name and send the program name
   editor.Show();
   editor.setUserList(userList);
 }
Пример #3
0
 private void NewAccessPermission(string guid, int read, int write, string text)
 {
     if (AccessControlList[guid] != null)
     {
         string permission = "";
         if (read == 1)
             permission += "R";
         if (write == 1)
             permission += "W";
         if (read == 0 && write == 0)
         {
             ProgWin temp = (ProgWin)AccessControlList[guid][1];
             temp.Close();
         }
         AccessControlList[guid][0] = permission;
     }
     else
     {
         ProgWin editor = new ProgWin(ProgWin.editorType.collaborator);
         ArrayList list = new ArrayList();
         string permission = "";
         if (read == 1)
             permission += "R";
         if (write == 1)
             permission += "W";
         list.Add(permission);
         list.Add(editor);
         AccessControlList.Add(guid, list);
         editor.loadProgram(text);
         editor.Show();
         editor.setPermissions(permission);
     }
 }
Пример #4
0
      private void OwnerThreadStartingPoint()
      {
          ProgWin editor = new ProgWin(ProgWin.editorType.owner);
          //owner is the user itself. so pass the username here
          //list of the users in swarm
          //take the program name and send the program name
          editor.setUserList(userList);
          editor.setPermissions("RW");
          editor.loadProgram(programText);
          string pid;
          pid = Guid.NewGuid().ToString();
          ArrayList list = new ArrayList();
          list.Add("RW");
          list.Add(editor);
          AccessControlList.Add(pid, list);
          editor.Show();

          System.Windows.Threading.Dispatcher.Run();
      }
Пример #5
0
      private void AccessThreadStartingPoint()
      {
          ProgWin editor = new ProgWin(ProgWin.editorType.collaborator, SC, IP, Port, AccessString[0], username, Prog + WindowCount.ToString());
          editor.CloseProgramEvent += new ProgWin.CloseProgramEventHandler(editor_CloseProgramEvent);
          ArrayList list = new ArrayList();
          string permission = "";
          if (AccessString[5].ToString() == "true")
              permission += "R";
          if (AccessString[6].ToString() == "true")
              permission += "W";
          list.Add(permission);
          list.Add(editor);
          AccessControlList.Add(AccessString[0], list);
          editor.loadProgram(AccessString[2]);
          foreach (string entry in userList)
          {
              string[] userInfo = entry.Split('|');
              if (userInfo[1].Trim() == AccessString[1])
              {
                  editor.setOwner(userInfo[0].Trim());
                  break;
              }
          }
          //editor.setOwner(s[1]);
          editor.SMObj().setOwner(AccessString[1]);
          editor.Show();
          editor.setUserList(userList);
          editor.setPermissions(permission);
          //editor.SMObj().createTheObjects(s[0], IP, Port);
          editor.SMObj().InitializeThePeer(AccessString[7]);
          editor.SMObj().adder(AccessString[3] + ":" + AccessString[4], AccessString[5], AccessString[6]);

          System.Windows.Threading.Dispatcher.Run();
      }
Пример #6
0
      private void OwnerThreadStartingPoint()
      {
          //try
          //{
              string pid;
              pid = Guid.NewGuid().ToString();
              ProgWin editor = new ProgWin(ProgWin.editorType.owner, SC, IP, Port, pid, username, Prog+WindowCount.ToString());
              editor.CloseProgramEvent += new ProgWin.CloseProgramEventHandler(editor_CloseProgramEvent);
              //owner is the user itself. so pass the username here
              //list of the users in swarm
              //take the program name and send the program name
              editor.setUserList(userList);
              editor.setPermissions("RW");
              editor.loadProgram(programText);
              editor.setOwner(username);
              editor.SMObj().setOwner(IP + ":" + Port);
              ArrayList list = new ArrayList();
              list.Add("RW");
              list.Add(editor);
              AccessControlList.Add(pid, list);
              //editor.Owner = this;
              editor.Show();

              System.Windows.Threading.Dispatcher.Run();
          
          //catch(Exception e)
          //{
          //    Console.WriteLine("**********************************************");
          //    Console.WriteLine(e.ToString());
          //    Console.WriteLine("**********************************************");
          //}
      }