Exemplo n.º 1
0
        private async void SendProgram()
        {
            var programService = new ProgramService(manipulator);
            var program        = new Driver.Program("test")
            {
                Content = richTextBoxRead.Text
            };
            await programService.UploadProgram(program);

            var programs = await programService.ReadProgramInfo();

            var programa = await programService.DownloadProgram(programs[0]);

            richTextBoxRead.Text = programa.Content;
        }
        /// <summary>
        /// Occurs after user triggers upload event.
        /// </summary>
        /// <param name="obj">The object.</param>
        private async void Upload(object obj)
        {
            var dialog = new OpenFileDialog
            {
                Filter          = "Text files (.txt)|*.txt",
                CheckFileExists = true
            };


            if (dialog.ShowDialog().GetValueOrDefault(false))
            {
                var path = dialog.FileName;

                if (string.IsNullOrWhiteSpace(path) || Uri.IsWellFormedUriString(path, UriKind.RelativeOrAbsolute))
                {
                    return;
                }

                var name    = Path.GetFileNameWithoutExtension(path);
                var content = File.ReadAllText(dialog.FileName);
                var program = new Program(name)
                {
                    Content = content
                };

                DialogHostIsOpen             = true;
                uploadDialog                 = new DialogHost();
                uploadDialog.CurrentAction   = "Preparing upload";
                uploadDialog.Message         = "Please wait...";
                uploadDialog.CurrentProgress = "0%";
                DialogHost = uploadDialog;  //only temporary

                var contentWithLineNumbers = ProgramContentConverter.ToManipulator(program.Content);
                program.Content = contentWithLineNumbers;

                await programService.UploadProgram(program, uploadDialog.CancellationToken);
            }
        }
 /// <summary>
 /// Occurs after user triggers upload event.
 /// </summary>
 private void Upload(object obj)
 {
     programService.UploadProgram();
 }
Exemplo n.º 4
0
 /// <summary>
 /// Occurs after user triggers upload event.
 /// </summary>
 private async void Download(object obj)
 {
     await programServce.UploadProgram(SelectedRemoteProgram);
 }