示例#1
0
    protected void OnRecordStopBtnClicked(object sender, EventArgs e)
    {
        Gtk.Application.Invoke(delegate
        {
            if (_screenRecorder.Recording)
            {
                _screenRecorder.FinishAsync();
            }
            else
            {
                try
                {
                    Directory.CreateDirectory(_settings.Recordings.Folder);

                    string fileName = System.IO.Path.Combine(
                        _settings.Recordings.Folder,
                        string.Format(
                            "{0}{1}",
                            Guid.NewGuid().ToString("N"),
                            ".gif"
                            )
                        );

                    try
                    {
                        using (FileStream fs = File.Create(fileName))
                        {
                        }

                        recordStopBtn.Label = "Stop";

                        _screenRecorder.StartAsync(fileName, true);
                    }
                    catch
                    {
                        MessageDialog dialog = new MessageDialog(
                            this,
                            DialogFlags.Modal,
                            MessageType.Error,
                            ButtonsType.Ok,
                            string.Format("Cannot create the file {0}", fileName)
                            );

                        dialog.Run();
                        dialog.Destroy();
                    }
                }
                catch
                {
                    MessageDialog dialog = new MessageDialog(
                        this,
                        DialogFlags.Modal,
                        MessageType.Error,
                        ButtonsType.Ok,
                        string.Format("Cannot create directory {0}", _settings.Recordings.Folder)
                        );

                    dialog.Run();
                    dialog.Destroy();
                }
            }
        });
    }