Exemplo n.º 1
0
        public void AddFilesToProject()
        {
            Project project = (Project)CurrentNode.GetParentDataItem(typeof(Project), true);

            AddFileDialog fdiag = new AddFileDialog(GettextCatalog.GetString("Add files"));

            fdiag.CurrentFolder  = GetFolderPath(CurrentNode.DataItem);
            fdiag.SelectMultiple = true;
            fdiag.TransientFor   = IdeApp.Workbench.RootWindow;
            fdiag.BuildActions   = project.GetBuildActions();

            string overrideAction = null;

            if (!fdiag.Run())
            {
                return;
            }

            var files = fdiag.SelectedFiles;

            overrideAction = fdiag.OverrideAction;

            ProjectFolder folder        = CurrentNode.GetParentDataItem(typeof(ProjectFolder), true) as ProjectFolder;
            FilePath      baseDirectory = folder != null ? folder.Path : project.BaseDirectory;

            IdeApp.ProjectOperations.AddFilesToProject(project, files, baseDirectory, overrideAction);

            IdeApp.ProjectOperations.Save(project);
        }
Exemplo n.º 2
0
        public async void AddFilesToProject()
        {
            Project project    = (Project)CurrentNode.GetParentDataItem(typeof(Project), true);
            var     targetRoot = ((FilePath)GetFolderPath(CurrentNode.DataItem)).CanonicalPath;

            AddFileDialog fdiag = new AddFileDialog(GettextCatalog.GetString("Add files"));

            fdiag.CurrentFolder  = !PreviousFolderPath.IsNullOrEmpty && !PreviousFolderPath.IsChildPathOf(project.ParentSolution.BaseDirectory) ? PreviousFolderPath : targetRoot;
            fdiag.SelectMultiple = true;
            fdiag.TransientFor   = IdeApp.Workbench.RootWindow;
            fdiag.BuildActions   = project.GetBuildActions();

            string overrideAction = null;

            if (!fdiag.Run())
            {
                return;
            }
            PreviousFolderPath = fdiag.SelectedFiles.Select(f => f.FullPath.ParentDirectory).FirstOrDefault();

            var files = fdiag.SelectedFiles;

            overrideAction = fdiag.OverrideAction;

            ProjectFolder folder        = CurrentNode.GetParentDataItem(typeof(ProjectFolder), true) as ProjectFolder;
            FilePath      baseDirectory = folder != null ? folder.Path : project.BaseDirectory;

            IdeApp.ProjectOperations.AddFilesToProject(project, files, baseDirectory, overrideAction);

            await IdeApp.ProjectOperations.SaveAsync(project);
        }
        public void AddFilesToProject()
        {
            var project    = (FolderBasedProject)CurrentNode.GetParentDataItem(typeof(FolderBasedProject), true);
            var targetRoot = ((FilePath)GetPath(CurrentNode.DataItem)).CanonicalPath;

            var fdiag = new AddFileDialog(GettextCatalog.GetString("Add files"));

            fdiag.CurrentFolder  = !PreviousFolderPath.IsNullOrEmpty ? PreviousFolderPath : targetRoot;
            fdiag.SelectMultiple = true;
            fdiag.TransientFor   = IdeApp.Workbench.RootWindow;
            fdiag.BuildActions   = project.GetBuildActions();

            string overrideAction = null;

            if (!fdiag.Run())
            {
                return;
            }
            PreviousFolderPath = fdiag.SelectedFiles.Select(f => f.FullPath.ParentDirectory).FirstOrDefault();

            var files = fdiag.SelectedFiles;

            overrideAction = fdiag.OverrideAction;

            var      folder        = CurrentNode.GetParentDataItem(typeof(SystemFolder), true) as SystemFolder;
            FilePath baseDirectory = folder != null ? folder.Path : project.BaseDirectory;

            foreach (var file in files)
            {
                CopyFile(file, baseDirectory);
            }

            project.OnFilesAdded(files.ToList());
            Tree.BuilderContext.GetTreeBuilder(CurrentNode).UpdateChildren();
        }
Exemplo n.º 4
0
        private void добавитьФайлToolStripMenuItem_Click(object sender, EventArgs e)
        {
            AddFileDialog.ShowDialog();
            if (AddFileDialog.FileNames.Length == 0)
            {
                return;
            }

            int index = pathFiles.Length;

            Array.Resize(ref pathFiles, pathFiles.Length + AddFileDialog.FileNames.Length);

            foreach (string a in AddFileDialog.FileNames)
            {
                ListViewItem item = this.FilesList.Items.Add((this.FilesList.Items.Count + 1).ToString());
                item.SubItems.Add(a.Substring(a.LastIndexOf('\\') + 1));
                FileInfo fileInfo = new FileInfo(a);
                item.SubItems.Add((fileInfo.Length / 1000000.0).ToString() + " МБ");
                item.SubItems.Add("Готов к отправке");

                pathFiles[index++] = a;

                LogApplication.WriteLog("[SendFileForm] В список к отправке добавлен файл " + a);
            }
        }
Exemplo n.º 5
0
        private async Task <AddFileDialogOutput> ShowAddFileDialog(string fileName)
        {
            AddFileDialog dialog = new AddFileDialog(fileName);
            await dialog.ShowAsync();

            return(dialog.Result);
        }
Exemplo n.º 6
0
 /// <summary>
 /// 文件拖入且松开
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void File_Drop(object sender, System.Windows.DragEventArgs e)
 {
     if (e.Data.GetDataPresent(System.Windows.DataFormats.FileDrop))
     {
         string[] files = (string[])e.Data.GetData(System.Windows.DataFormats.FileDrop);
         if (files.Length < 1)
         {
             return;
         }
         AddFileDialog addFileDialog = new AddFileDialog(files[0]);
         addFileDialog.ShowDialog();
     }
 }
Exemplo n.º 7
0
        public string AddFile([NotNull] string title)
        {
            Assert.ArgumentNotNull(title, nameof(title));

            var dialog = new AddFileDialog(RepositoryName)
            {
                Title = title
            };

            if (AppHost.Shell.ShowDialog(dialog) != true)
            {
                return(string.Empty);
            }

            return(dialog.SelectedFileName);
        }
Exemplo n.º 8
0
        public void AddFilesToProject()
        {
            Project project = (Project)CurrentNode.GetParentDataItem(typeof(Project), true);

            AddFileDialog fdiag = new AddFileDialog(GettextCatalog.GetString("Add files"));

            fdiag.CurrentFolder  = GetFolderPath(CurrentNode.DataItem);
            fdiag.SelectMultiple = true;
            fdiag.TransientFor   = IdeApp.Workbench.RootWindow;
            fdiag.BuildActions   = project.GetBuildActions();

            string overrideAction = null;

            if (!fdiag.Run())
            {
                return;
            }

            var files = fdiag.SelectedFiles;

            overrideAction = fdiag.OverrideAction;

            ProjectFolder folder        = CurrentNode.GetParentDataItem(typeof(ProjectFolder), true) as ProjectFolder;
            FilePath      baseDirectory = folder != null ? folder.Path : project.BaseDirectory;

            var addedFiles = IdeApp.ProjectOperations.AddFilesToProject(project, files, baseDirectory);

            //override the build action of the added files if needed
            if (!string.IsNullOrEmpty(overrideAction))
            {
                foreach (var pf in addedFiles)
                {
                    if (pf != null)
                    {
                        pf.BuildAction = overrideAction;
                    }
                }
            }

            IdeApp.ProjectOperations.Save(project);
        }
		protected void OnAddFileButtonClicked (object sender, EventArgs e)
		{
			var baseDirectory = GetSelectedDirectory ();
			var fileDialog = new AddFileDialog (GettextCatalog.GetString ("Add files")) {
				CurrentFolder = baseDirectory,
				SelectMultiple = true,
				TransientFor = IdeApp.Workbench.RootWindow,
				BuildActions = buildActions ?? project.GetBuildActions ()
			};

			if (defaultFilter != null) {
				fileDialog.Filters.Clear ();
				fileDialog.Filters.Add (defaultFilter);
				fileDialog.DefaultFilter = defaultFilter;
			}

			if (!fileDialog.Run ())
				return;

			var buildAction = fileDialog.OverrideAction;
			if (buildActions != null && buildActions.Length > 0 && String.IsNullOrEmpty (buildAction))
				buildAction = buildActions [0];

			IdeApp.ProjectOperations.AddFilesToProject (project,
				fileDialog.SelectedFiles, baseDirectory, buildAction);

			IdeApp.ProjectOperations.SaveAsync (project);

			UpdateFileList (sender, e);
		}
Exemplo n.º 10
0
        public void AddFilesToProject()
        {
            Project project = (Project) CurrentNode.GetParentDataItem (typeof(Project), true);
            var targetRoot = ((FilePath) GetFolderPath (CurrentNode.DataItem)).CanonicalPath;

            AddFileDialog fdiag  = new AddFileDialog (GettextCatalog.GetString ("Add files"));
            fdiag.CurrentFolder = !PreviousFolderPath.IsNullOrEmpty ? PreviousFolderPath : targetRoot;
            fdiag.SelectMultiple = true;
            fdiag.TransientFor = IdeApp.Workbench.RootWindow;
            fdiag.BuildActions = project.GetBuildActions ();

            string overrideAction = null;

            if (!fdiag.Run ())
                return;
            PreviousFolderPath = fdiag.SelectedFiles.Select (f => f.FullPath.ParentDirectory).FirstOrDefault ();

            var files = fdiag.SelectedFiles;
            overrideAction = fdiag.OverrideAction;

            ProjectFolder folder = CurrentNode.GetParentDataItem (typeof(ProjectFolder), true) as ProjectFolder;
            FilePath baseDirectory = folder != null ? folder.Path : project.BaseDirectory;

            IdeApp.ProjectOperations.AddFilesToProject (project, files, baseDirectory, overrideAction);

            IdeApp.ProjectOperations.Save (project);
        }
Exemplo n.º 11
0
		public void AddFilesToProject()
		{
			Project project = (Project) CurrentNode.GetParentDataItem (typeof(Project), true);
			
			AddFileDialog fdiag  = new AddFileDialog (GettextCatalog.GetString ("Add files"));
			fdiag.CurrentFolder = GetFolderPath (CurrentNode.DataItem);
			fdiag.SelectMultiple = true;
			fdiag.TransientFor = IdeApp.Workbench.RootWindow;
			fdiag.BuildActions = project.GetBuildActions ();	
			
			string overrideAction = null;
			
			if (!fdiag.Run ())
				return;
			
			var files = fdiag.SelectedFiles;
			overrideAction = fdiag.OverrideAction;
			
			ProjectFolder folder = CurrentNode.GetParentDataItem (typeof(ProjectFolder), true) as ProjectFolder;
			FilePath baseDirectory = folder != null ? folder.Path : project.BaseDirectory;
			
			IdeApp.ProjectOperations.AddFilesToProject (project, files, baseDirectory, overrideAction);
			
			IdeApp.ProjectOperations.Save (project);
		}
Exemplo n.º 12
0
        private void передатьФайлToolStripMenuItem_Click(object sender, EventArgs e)
        {
            LogApplication.WriteLog("\n\n[Передача файла EVENT] Открытие диалога выбора файла");
            this.TransferFile_Progress.Value = 0;
            Label_State.Text = "Выбор файла";

            GlavnForm.Invoke((MethodInvoker) delegate
            {
                AddFileDialog.ShowDialog();
            });

            LogApplication.WriteLog("[Передача файла EVENT] Проверка количества выбранных файлов");

            if (AddFileDialog.FileNames.Length == 0)
            {
                LogApplication.WriteLog("[Передача файла EVENT] Файлы не были выбранны");
                return;
            }

            LogApplication.WriteLog("[Передача файла EVENT] Создание item'a в таблице");

            ListViewItem item = this.FilesList.Items.Add((this.FilesList.Items.Count + 1).ToString());

            item.SubItems.Add(AddFileDialog.FileNames[0].Substring(AddFileDialog.FileNames[0].LastIndexOf('\\') + 1));
            FileInfo fileInfo = new FileInfo(AddFileDialog.FileNames[0]);

            item.SubItems.Add((fileInfo.Length / 1000000f).ToString() + " МБ");
            item.SubItems.Add("Отправляется");


            LogApplication.WriteLog("[Передача файла EVENT] ApplicationDoEvents");
            Application.DoEvents();

            client = new UdpClient();
            string buffer = "1" + AddFileDialog.FileNames[0].Substring(AddFileDialog.FileNames[0].LastIndexOf('\\') + 1, AddFileDialog.FileNames[0].Length - AddFileDialog.FileNames[0].LastIndexOf('\\') - 1);

            LogApplication.WriteLog($"[Передача файла EVENT] Передача клиенту названия файла {buffer}");
            {
                Label_State.Text = "Передача названия файла";
                client.Send(Config.Encoder.GetBytes(buffer), Config.Encoder.GetBytes(buffer).Length, RemoteIp.ToString(), Config.UDP_FILE_NAME_RECEIVE);
            }

            LogApplication.WriteLog($"[Передача файла EVENT] Передача клиенту размера файла");
            {
                buffer = $"4{fileInfo.Length / 1000000f}";
                client.Send(Config.Encoder.GetBytes(buffer), Config.Encoder.GetBytes(buffer).Length, RemoteIp.ToString(), Config.UDP_FILE_NAME_RECEIVE);
            }

            new Task(() =>
            {
                LogApplication.WriteLog("[Передача файла EVENT] Передано, начинаю передачу по TCP -> " + AddFileDialog.FileNames[0] + "\n\n\n");
                BinaryReader reader = new BinaryReader(new FileStream(AddFileDialog.FileNames[0], FileMode.Open));

                this.TransferFile_Progress.Maximum = (int)reader.BaseStream.Length;

                long sendedBytes = 0;

                Label_State.Text = "Передача файла";

                while (reader.BaseStream.Position < reader.BaseStream.Length)
                {
                    try
                    {
                        byte[] ReadBytes = reader.ReadBytes(1024);
                        tcpClient.GetStream().Write(ReadBytes, 0, ReadBytes.Length);

                        sendedBytes += ReadBytes.Length;
                        this.TransferFile_Progress.Value += ReadBytes.Length;
                        LogApplication.WriteLog($"SEND bytes {ReadBytes.Length.ToString()}/{sendedBytes}");
                        LogApplication.WriteLog($"Stream position {reader.BaseStream.Position}/{reader.BaseStream.Length}\n");
                    }
                    catch (Exception Ex)
                    {
                        LogApplication.WriteLog("[SendBytes] exception \n" + Ex.Message);
                    }


                    GlavnForm.Invoke((MethodInvoker) delegate
                    {
                        Label_State.Text = $"Идёт передача {reader.BaseStream.Position / (float)reader.BaseStream.Length * 100} из 100%";
                    });
                }


                Thread.Sleep(300);
                LogApplication.WriteLog("[Передача файла EVENT] Типа передано, отправляю сигнал о закрытии потока");
                client.Send(Config.Encoder.GetBytes("00zdkf"), Config.Encoder.GetBytes("00zdkf").Length, RemoteIp.ToString(), Config.UDP_FILE_NAME_RECEIVE);

                LogApplication.WriteLog("[Передача файла EVENT] Конец");

                GlavnForm.Invoke((MethodInvoker) delegate
                {
                    item.SubItems[3].Text = "Передано";
                    new PopupNotifier()
                    {
                        TitleText   = "FileExchange",
                        ContentText = $"Файл {item.SubItems[1].Text} успешно передан"
                    }.Popup();
                });
                reader.Close();
            }).Start();
        }
Exemplo n.º 13
0
		public void AddFilesToProject()
		{
			Project project = (Project) CurrentNode.GetParentDataItem (typeof(Project), true);
			
			AddFileDialog fdiag  = new AddFileDialog (GettextCatalog.GetString ("Add files"));
			fdiag.CurrentFolder = GetFolderPath (CurrentNode.DataItem);
			fdiag.SelectMultiple = true;
			fdiag.TransientFor = IdeApp.Workbench.RootWindow;
			fdiag.BuildActions = project.GetBuildActions ();	
			
			string overrideAction = null;
			
			if (!fdiag.Run ())
				return;
			
			var files = fdiag.SelectedFiles;
			overrideAction = fdiag.OverrideAction;
			
			ProjectFolder folder = CurrentNode.GetParentDataItem (typeof(ProjectFolder), true) as ProjectFolder;
			FilePath baseDirectory = folder != null ? folder.Path : project.BaseDirectory;
			
			var addedFiles = IdeApp.ProjectOperations.AddFilesToProject (project, files, baseDirectory);
			
			//override the build action of the added files if needed
			if (!string.IsNullOrEmpty (overrideAction)) {
				foreach (var pf in addedFiles)
					if (pf != null)
						pf.BuildAction = overrideAction;
			}
			
			IdeApp.ProjectOperations.Save (project);
		}