Inheritance: IdentifiedEntity
Exemplo n.º 1
0
        private void ApplyConfig(MediaConfig config, MediaConfigFile[] mediaFiles)
        {
            foreach (var file in mediaFiles)
            {
                vlcControl.Medias.Add(new LocationMedia(String.Format(MediaFileUriPattern, config.ServiceUrl, file.Id)));
            }

            vlcControl.Stop();
            vlcControl.Play();
        }
Exemplo n.º 2
0
 private void MediaConfigFilesGridViewRow(DataGridViewRow row, MediaConfigFile mediaConfigFile)
 {
     row.Cells["nameColumn"].Value = mediaConfigFile.Name;
     row.Tag = mediaConfigFile;
 }
Exemplo n.º 3
0
        private async void EditMediaConfigFileForm_Load(object sender, EventArgs e)
        {
            Enabled = false;

            using (var channel = ChannelManager.CreateChannel())
            {
                try
                {
                    mediaConfig = await taskPool.AddTask(channel.Service.GetMediaConfig());

                    if (mediaConfigFileId != Guid.Empty)
                    {
                        MediaConfigFile = await taskPool.AddTask(channel.Service.GetMediaConfigFile(mediaConfigFileId));
                    }
                    else
                    {
                        MediaConfigFile = new MediaConfigFile();
                    }

                    Enabled = true;
                }
                catch (OperationCanceledException) { }
                catch (CommunicationObjectAbortedException) { }
                catch (ObjectDisposedException) { }
                catch (InvalidOperationException) { }
                catch (FaultException exception)
                {
                    UIHelper.Warning(exception.Reason.ToString());
                }
                catch (Exception exception)
                {
                    UIHelper.Warning(exception.Message);
                }
            }
        }
Exemplo n.º 4
0
        private async void uploadButton_Click(object sender, EventArgs eventArgs)
        {
            if (selectMediaFileDialog.ShowDialog() == DialogResult.OK)
            {
                string fileName = selectMediaFileDialog.FileName;

                using (var channel = ChannelManager.CreateChannel())
                {
                    try
                    {
                        if (MediaConfigFile.Id == Guid.Empty)
                        {
                            MediaConfigFile = await taskPool.AddTask(channel.Service.EditMediaConfigFile(MediaConfigFile));
                        }

                        CancellationTokenSource uploadOperation = new CancellationTokenSource();

                        var progress = new ProgressMessageHandler();
                        progress.HttpSendProgress += new EventHandler<HttpProgressEventArgs>((s, e) =>
                        {
                            try
                            {
                                Invoke(new MethodInvoker(() =>
                                {
                                    uploadMediaFileProgressBar.Value = e.ProgressPercentage;
                                }));
                            }
                            catch (ObjectDisposedException)
                            {
                                uploadOperation.Cancel();
                            }
                        });

                        Uri uri = new Uri(string.Format("{0}/media-config/files/{1}/upload", mediaConfig.ServiceUrl, mediaConfigFile.Id));

                        var message = new HttpRequestMessage()
                        {
                            Method = HttpMethod.Post,
                            Content = new StreamContent(File.OpenRead(selectMediaFileDialog.FileName)),
                            RequestUri = uri
                        };

                        var client = HttpClientFactory.Create(progress);

                        await taskPool.AddTask(client.SendAsync(message, uploadOperation.Token));
                    }
                    catch (OperationCanceledException) { }
                    catch (CommunicationObjectAbortedException) { }
                    catch (ObjectDisposedException) { }
                    catch (InvalidOperationException) { }
                    catch (FaultException exception)
                    {
                        UIHelper.Warning(exception.Reason.ToString());
                    }
                    catch (Exception exception)
                    {
                        UIHelper.Warning(exception.Message);
                    }
                }
            }
        }
Exemplo n.º 5
0
        private async void saveButton_Click(object sender, EventArgs e)
        {
            using (var channel = ChannelManager.CreateChannel())
            {
                try
                {
                    saveButton.Enabled = false;

                    MediaConfigFile = await taskPool.AddTask(channel.Service.EditMediaConfigFile(mediaConfigFile));

                    if (Saved != null)
                    {
                        Saved(this, EventArgs.Empty);
                    }
                }
                catch (OperationCanceledException) { }
                catch (CommunicationObjectAbortedException) { }
                catch (ObjectDisposedException) { }
                catch (InvalidOperationException) { }
                catch (FaultException exception)
                {
                    UIHelper.Warning(exception.Reason.ToString());
                }
                catch (Exception exception)
                {
                    UIHelper.Warning(exception.Message);
                }
                finally
                {
                    saveButton.Enabled = true;
                }
            }
        }