Example #1
0
        public void Upload()
        {
            UpdateModel();
            var builder = GetPackageBuilder();
            var cts     = new CancellationTokenSource();

            var task = Task.Factory.StartNew(async() =>
            {
                await builder.Build(cts.Token);

                var pen = TipToiPen.GetAll().FirstOrDefault();
                if (pen != null)
                {
                    await builder.Upload(cts.Token, pen);
                }
                else
                {
                    System.Windows.Forms.MessageBox.Show(String.Format("Upload is not possible because the Tiptoi pen is not connected."), About.Product);
                    ShowOutput(builder);
                }

                log.Info("complete");
            }, TaskCreationOptions.LongRunning);

            var f = new TaskForm(task, cts)
            {
                Text = "Convert and Upload"
            };

            f.Show();
        }
Example #2
0
        public void Print()
        {
            if (!Firefox.IsInstalled)
            {
                System.Windows.Forms.MessageBox.Show(String.Format(
                                                         @"It is recommended to install the Firefox browser to print the TipToi optical codes.

Your default browser may not be able to print the TipToi optical codes correctly."), about.Product);
            }

            UpdateModel();
            var builder = GetPackageBuilder();
            var cts     = new CancellationTokenSource();
            var task    = Task.Factory.StartNew(async() =>
            {
                await builder.CreateHtmlPage(cts.Token);
                await builder.OpenHtmlPage(cts.Token);
            }, TaskCreationOptions.LongRunning);
            var f = new TaskForm(task, cts)
            {
                Text = "Print"
            };

            f.Show();
        }
Example #3
0
 public static Task StartTask(string caption, System.Action action)
 {
     var cts = new CancellationTokenSource();
     var task = Task.Factory.StartNew(action, cts.Token, TaskCreationOptions.LongRunning, TaskScheduler.Current);
     var tw = new TaskForm(task, cts) { Text = caption };
     tw.Show();
     return task;
 }
Example #4
0
        public static Task StartTask(string caption, System.Action action)
        {
            var cts  = new CancellationTokenSource();
            var task = Task.Factory.StartNew(action, cts.Token, TaskCreationOptions.LongRunning, TaskScheduler.Current);
            var tw   = new TaskForm(task, cts)
            {
                Text = caption
            };

            tw.Show();
            return(task);
        }
Example #5
0
        public void Print()
        {
            var cts  = new CancellationTokenSource();
            var task = Task.Factory.StartNew(() =>
            {
                UpdateModel();
                var builder = GetPackageBuilder();
                builder.OpenHtmlPage(cts.Token);
            }, TaskCreationOptions.LongRunning);
            var f = new TaskForm(task, cts)
            {
                Text = "Print"
            };

            f.Show();
        }
Example #6
0
        public void Upload()
        {
            var cts  = new CancellationTokenSource();
            var task = Task.Factory.StartNew(() =>
            {
                UpdateModel();
                var builder = GetPackageBuilder();
                builder.Build(cts.Token).Wait();
                log.Info("complete");
            }, TaskCreationOptions.LongRunning);

            var f = new TaskForm(task, cts)
            {
                Text = "Upload"
            };

            f.Show();
        }
Example #7
0
        public void Upload()
        {
            var cts = new CancellationTokenSource();
            var task = Task.Factory.StartNew(() =>
            {
                UpdateModel();
                var builder = GetPackageBuilder();
                builder.Build(cts.Token);
            }, TaskCreationOptions.LongRunning);

            var f = new TaskForm(task, cts) { Text = "Upload" };
            f.Show();
        }
Example #8
0
        void StartConversion()
        {
            UpdateModel();

            var files = listViewInputFiles.Items.Cast<ListViewItem>().Select(_ => (string)_.Tag).ToList();
            if (!files.Any())
            {
                MessageBox.Show("Drop some audio files into the list first.");
                return;
            }

            var cancellationTokenSource = new System.Threading.CancellationTokenSource();
            var task = Convert(cancellationTokenSource.Token, files, textBoxTitle.Text, textBoxProductId.Text);

            var taskForm = new TaskForm(task, cancellationTokenSource)
            {
                Text = "Convert and Copy to Pen"
            };
                
            taskForm.Show();
        }