private void ReReadFiles()
        {
            FilesGrid.Items.Clear();
            try
            {
                Configuration config = (App.Current as App).config;
                using (TcpClient eClient = new TcpClient(config.IP.ToString(), config.Port))
                {
                    using (NetworkStream writerStream = eClient.GetStream())
                    {
                        MSG message = new MSG();
                        message.stat = STATUS.GET_FILES;
                        BinaryFormatter formatter = new BinaryFormatter();
                        formatter.Serialize(writerStream, message);
                        formatter.Serialize(writerStream, _eventId);
                        formatter.Serialize(writerStream, false);
                        _files = (Dictionary<string, string>)formatter.Deserialize(writerStream);
                        foreach (var file in _files)
                        {
                            FilesGrid.Items.Add(new FileRow(file.Key, "Викладач"));
                        }
                    }
                }

            }
            catch (Exception)
            {
                MessageBox.Show("Помилка додавання файлу");
            }
        }
Ejemplo n.º 2
0
 public int FContinueMessageLoop(uint uReason, IntPtr pvLoopData, MSG[] pMsgPeeked) {
   return 1;
 }
Ejemplo n.º 3
0
 public int FPreTranslateMessage(MSG[] pMsg) {
   return 0;
 }
Ejemplo n.º 4
0
 public int FPreTranslateMessage(MSG[] pMsg)
 {
     return VSConstants.S_OK;
 }
Ejemplo n.º 5
0
 public int FContinueMessageLoop(uint uReason, IntPtr pvLoopData, MSG[] pMsgPeeked)
 {
     return VSConstants.S_FALSE;
 }
Ejemplo n.º 6
0
 int IOleComponent.FPreTranslateMessage(MSG[] pMsg)
 {
     return 0;
 }
Ejemplo n.º 7
0
 int IOleComponent.FContinueMessageLoop(uint uReason, IntPtr pvLoopData, MSG[] pMsgPeeked)
 {
     return 1;
 }
 private void AddFile_Click(object sender, RoutedEventArgs e)
 {
     OpenFileDialog openDialog = new OpenFileDialog();
     openDialog.Multiselect = true;
     openDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
     if (openDialog.ShowDialog() == true)
     {
         try
         {
             Configuration config = (App.Current as App).config;
             using (TcpClient eClient = new TcpClient(config.IP.ToString(), config.Port))
             {
                 using (NetworkStream writerStream = eClient.GetStream())
                 {
                     MSG message = new MSG();
                     message.stat = STATUS.ADD_FILE;
                     BinaryFormatter formatter = new BinaryFormatter();
                     formatter.Serialize(writerStream, message);
                     formatter.Serialize(writerStream, 0);
                     formatter.Serialize(writerStream, _eventId);
                     formatter.Serialize(writerStream, openDialog.FileNames.Length);
                     foreach (var fileName in openDialog.FileNames)
                     {
                         if (fileName != null)
                         {
                             formatter.Serialize(writerStream, System.IO.Path.GetFileName(fileName));
                             formatter.Serialize(writerStream, File.ReadAllBytes(fileName));
                         }
                     }
                 }
             }
         }
         catch (Exception)
         {
             MessageBox.Show("Помилка додавання файлу");
         }
         ReReadFiles();
     }
 }
 private void DeleteFile_Click(object sender, RoutedEventArgs e)
 {
     int index = FilesGrid.SelectedIndex;
     if (index < 0)
     {
         MessageBox.Show("Оберіть файл");
     }
     else
     {
         try
         {
             Configuration config = (App.Current as App).config;
             using (TcpClient eClient = new TcpClient(config.IP.ToString(), config.Port))
             {
                 using (NetworkStream writerStream = eClient.GetStream())
                 {
                     MSG message = new MSG();
                     message.stat = STATUS.DELETE_FILE;
                     BinaryFormatter formatter = new BinaryFormatter();
                     formatter.Serialize(writerStream, message);
                     formatter.Serialize(writerStream, _eventId);
                     formatter.Serialize(writerStream, FilesGrid.SelectedItems.Count);
                     foreach (var item in FilesGrid.SelectedItems)
                     {
                         formatter.Serialize(writerStream, _files[((FileRow)item).FileName]);
                     }
                     bool fl = (bool)formatter.Deserialize(writerStream);
                     if (!fl)
                     {
                         MessageBox.Show("Помилка видалення файлу");
                     }
                     ReReadFiles();
                 }
             }
         }
         catch (Exception)
         {
             MessageBox.Show("Помилка видалення файлу");
         }
     }
 }