示例#1
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            // Get our button from the layout resource,
            // and attach an event to it
            Button button = FindViewById <Button>(Resource.Id.myButton);

            button.Text = GetIPAddress().ToString();

            button.Click += delegate
            {
                button.Text = string.Format("{0} clicks!", count++);
            };

            this.drawingView = new DrawingView(this.ApplicationContext);

            this.AddContentView(this.drawingView, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FillParent, LinearLayout.LayoutParams.FillParent));

            this.drawingView.Invalidate();

            AsyncTcpServer.Initialize(IPAddress.Any, PORT);
            AsyncTcpServer.Instance.Start();

            CaptureService.Initialize(new ScreenCapture(this.Window.DecorView.RootView), 1000);
            CaptureService.Instance.ScreenCaptured += (sender, args) =>
            {
                AsyncTcpServer.Instance.Write(JsonConvert.SerializeObject(args.Value));
            };
            CaptureService.Instance.Start();
        }
示例#2
0
        /// <summary>
        /// Capture one Bitmap.
        /// </summary>
        /// <param name="region"></param>
        public async void CaptureImage(Rectangle region)
        {
            var stream = new MemoryStream();
            var bitmap = CaptureService.CaptureBitmap(region);

            bitmap.Save(stream, SettingsService.Current.ImageFormat);

            // Copy bitmap to the clipboard
            if (!SettingsService.Current.NoImageCopy)
            {
                CopyImage(bitmap);
            }

            // Generate filename and start the upload(s)
            var url = await UploadAll(stream, SettingsService.Current.SafeImageExt);

            // Try to copy URL
            if (SettingsService.Current.NoImageCopy)
            {
                CopyUrl(url);
            }

            bitmap.Dispose();
            stream.Dispose();

            Complete(url != null); // Exits the application
        }
示例#3
0
        public async Task RunAsync(IBackgroundTaskInstance taskInstance)
        {
            deferral = taskInstance.GetDeferral();

            Configuration configuration = new Configuration();

            DefaultConfigurationLoader.Load(configuration);
            ApplicationTriggerConfigurationLoader.Load(configuration, taskInstance.TriggerDetails as ApplicationTriggerDetails);
            ApplicationTriggerDetails triggerDetails = taskInstance.TriggerDetails as ApplicationTriggerDetails;

            DeviceInformationCollection devices = await DeviceInformation.FindAllAsync(DeviceClass.VideoCapture);

            DeviceInformation device = devices.Where(d => d.EnclosureLocation != null).FirstOrDefault(d => d.EnclosureLocation.Panel == Panel.Back);

            if (device == null)
            {
                device = devices.FirstOrDefault();
            }

            captureService = new CaptureService(configuration.Interval, configuration.Delay, device);
            captureService.ExceptionHandler += OnCaptureException;
            captureService.TryStartIfNotStopped();

            IHttpHandler httpHandler = new AuthenticationHttpHandler(configuration.AuthenticationToken, this);

            server = new HttpServer(httpHandler);
            await server.StartAsync(configuration.Port);
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            UIApplication.SharedApplication.IdleTimerDisabled = true;

            // Perform any additional setup after loading the view, typically from a nib.
            AsyncTcpServer.Initialize(IPAddress.Any, PORT);
            AsyncTcpServer.Instance.Start();

            CaptureService.Initialize(new ScreenCapture(), 1000);
            CaptureService.Instance.ScreenCaptured += (sender, args) =>
            {
                AsyncTcpServer.Instance.Write(JsonConvert.SerializeObject(args.Value));
            };
            CaptureService.Instance.Start();
            lblHelloWorld.Text = (IosExtensions.GetIPAddress() ?? IPAddress.Any).ToString();

            drawingView = new DrawingView();
            drawingView.BackgroundColor = UIColor.Clear;
            drawingView.Frame           = new RectangleF(0, 0, 1024, 768);
            drawingView.Bounds          = new RectangleF(0, 0, 1024, 768);

            this.View.AddSubview(drawingView);
        }
示例#5
0
        /// <summary>
        /// Capture a lot of bitmaps and convert them to video.
        /// </summary>
        /// <param name="region"></param>
        /// <param name="offset"></param>
        public async void CaptureVideo(Rectangle region, Point offset)
        {
            MemoryStream stream;
            var          toast = -1;

            // Create a new toast which closing event gonna stop the recording
            toast = ToastService.Create(Resources.StopRecording, Color.OrangeRed, 0, () =>
            {
                toast = ToastService.Create(Resources.Encoding, 0);
                CaptureService.StopRecording();
            });

            // Use Mpeg if enabled
            if (ConfigService.Current.EnableMpeg)
            {
                stream = await CaptureService.RecordMpeg(region, offset);
            }
            else
            {
                stream = await CaptureService.RecordGif(region, offset);
            }

            ToastService.Remove(toast);

            // Generate filename and start the upload(s)
            var url = await UploadAll(stream, ConfigService.Current.EnableMpeg? "mp4" : "gif");

            stream.Dispose();

            CopyUrl(url);
            Complete(url != null); // Exits the application
        }
 public CaptureSettingsDialog()
 {
     InitializeComponent();
     foreach (string device in CaptureService.GetAllDevices())
     {
         cb_interfaceList.Items.Add(device.ToString());
     }
 }
示例#7
0
        /// <summary>
        /// Loop: start tasks
        /// </summary>
        private static async Task Start()
        {
            Helper.Message("Starting...\r\n");

            await CaptureService.StartLoop(_options, _configuration);

            Console.ReadKey();
        }
 public LocalClient(Guid key, int port, string authenticationToken, int interval, int delay)
 {
     Key                 = key;
     Port                = port;
     Interval            = interval;
     Delay               = delay;
     AuthenticationToken = authenticationToken;
     service             = new CaptureService(TimeSpan.FromSeconds(interval), TimeSpan.FromSeconds(delay));
 }
        public void CaptureService_Can_Write_A_Capture_To_Disk_When_Backed_By_A_FileStream()
        {
            var statesToWrite = 100;
            var simulator = new WeatherSimulator();
            var controller = new WeatherStateController(simulator);

            var stateResolver = new StateResolver();
            stateResolver.Add(controller);

            var tmpFile = System.IO.Path.GetTempFileName();

            try
            {
                using (var ms = new FileStream(tmpFile,FileMode.Create))
                {
                    var baseStream = new ConcurrentStream(ms);
                    var captureService = new CaptureService
                    {
                        Stream = baseStream,
                        StateResolver = stateResolver
                    };

                    captureService.Start();

                    controller.Initialise(captureService.CaptureStream);

                    simulator.Start();

                    var count = 0;
                    var resetEvent = new SlimResetEvent(20);

                    simulator.NewTemperature += delegate
                    {
                        count++;

                        if (count == statesToWrite)
                        {
                            simulator.Stop();
                            resetEvent.Set();
                        }
                    };

                    resetEvent.Wait();

                    captureService.Flush();
                }

                Assert.True(File.Exists(tmpFile));
                Assert.True(new FileInfo(tmpFile).Length > 0);

            }
            finally
            {
                File.Delete(tmpFile);
            }
        }
示例#10
0
        /// <summary>
        /// Refresh the background if transparency is disabled.
        /// </summary>
        private void RefreshBackground()
        {
            if (!SettingsService.Current.NoTransparency)
            {
                return;
            }

            var bitmap = CaptureService.CaptureBitmap(new Rectangle(PointToScreen(Location), ClientSize));

            BackgroundImage = bitmap;
            Opacity         = 1.0D;
        }
示例#11
0
        public ActionResult SendLeadToAdmin(int id)
        {
            CaptureService _capture = new CaptureService();

            // var id = _captureService.NewAdminLeadCapture(lead, "http://localhost:3431/dataConverstion/capture");

            //  var id = _captureService.NewAdminLeadCapture(lead, "https://api.websearchmedia.co.uk/dataConverstion/capture");
            if (id > 0)
            {
                var returnid = _capture.LeadTransfer("https://api.websearchmedia.co.uk/dataConverstion/LeadTransfer?leadId=" + id);
            }
            return(View());
        }
示例#12
0
        /// <summary>
        /// Set scalling by screen index.
        /// </summary>
        /// <param name="index"></param>
        public void SetScaling()
        {
            var list = ConfigService.Current.SafeManualScaling;

            if (index < list.Count)
            {
                // ManualScalling is in percentage
                CaptureService.Scaling = list[index] / 100.0f;
            }
            else
            {
                CaptureService.Scaling = CaptureService.GetScaling();
            }
        }
示例#13
0
        /// <summary>
        /// Refresh the background if transparency is disabled.
        /// </summary>
        private void RefreshBackground()
        {
            if (!ConfigService.Current.NoTransparency)
            {
                return;
            }

            SetScaling();

            var bitmap = CaptureService.GetBitmap(new Rectangle(Point.Empty, screen.Size), screen.Location);

            BackgroundImage = CaptureService.ResizeBitmap(bitmap, Width, Height);
            Opacity         = 1.0D;
        }
示例#14
0
        private void StopCaptureButton_Click(object sender, RoutedEventArgs e)
        {
            //GameDataContext context = new GameDataContext();
            //var list = context.PlayerInfos.ToList();
            //int count = 0;
            //foreach (var item in list)
            //{
            //    count = count + int.Parse(item.UGold) + int.Parse(item.Gold);
            //}
            //Console.WriteLine(count);
            //Console.ReadLine();

            CaptureService.GetInstance().Shutdown();
        }
示例#15
0
 public override void Act()
 {
     try
     {
         Task.WaitAll(CaptureService.CaptureDocument(Request, default));
     }
     catch (AggregateException ex)
     {
         Catched = ex.InnerException;
     }
     catch (Exception ex)
     {
         Catched = ex;
     }
 }
示例#16
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            Debug.WriteLine("SharpPcap版本:" + SharpPcap.Version.VersionString);
            int i = 0;

            if (File.Exists(@"E:\nox\Nox\bin\nox_adb.exe"))
            {
                i = 0;
            }
            if (File.Exists(@"E:\Nox\bin\nox_adb.exe"))
            {
                i = 1;
            }
            CaptureService.GetInstance().StartCapture(i, "host " + SoftContext.ServerIp);
        }
示例#17
0
        private async System.Threading.Tasks.Task MainWindow_Loaded(object sender, RoutedEventArgs e)
        {
            try
            {
                // GameLogin game = new GameLogin("huang77", "huang77");
                //game.Login(PlatformLogin.Platform.楚游_070703sy);
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
            }

            //初始化大漠对象,注册,新建一个大漠对象
            OperationResult initResult = SoftContext.Initialize();

            if (!initResult.Successed)
            {
                await SoftContext.ShowMessageAsync("初始化失败", initResult.Message);

                SoftContext.RunStatus = SoftRunStatus.StartFail;

                Locator.Main.StatusBar = $"初始化失败:{initResult.Message}";

                return;
            }
            else
            {
                Debug.WriteLine("SharpPcap版本:" + SharpPcap.Version.VersionString);
                int i = 0;
                if (File.Exists(@"E:\nox\Nox\bin\nox_adb.exe"))
                {
                    i = 0;
                }
                if (File.Exists(@"E:\Nox\bin\nox_adb.exe"))
                {
                    i = 0;
                }
                CaptureService.GetInstance().StartCapture(i, "host " + SoftContext.ServerIp);

                Locator.Main.StatusBar = "准备就绪";
                return;
            }
        }
示例#18
0
//        private static string[] GetIpAddresses()
//        {
//            return Dns.GetHostEntry(Dns.GetHostName()).AddressList.Where(x => x.AddressFamily == AddressFamily.InterNetwork).Select(x => x.ToString()).ToArray();
//        }

        public static void Main(string[] args)
        {
            AsyncTcpServer.Initialize(IPAddress.Any, PORT);
            AsyncTcpServer.Instance.DataReceived += (sender, e) => System.Console.WriteLine("Received data from client {0}, data: {1}", e.Value1.Client.LocalEndPoint.ToString(), e.Value2);
            AsyncTcpServer.Instance.Start();

            CaptureService.Initialize(new ScreenCapture(), 1000);
            CaptureService.Instance.ScreenCaptured += (sender, e) =>
            {
                var jsonString = "{" + string.Format("\"CursorX\":0,\"CursorY\":0,\"EncodedBitmap\":\"{0}\"", e.Value.EncodedBitmap) + "}";
                AsyncTcpServer.Instance.Write(jsonString);
            };
            CaptureService.Instance.Start();


            System.Console.WriteLine("Listening for incoming connections...");
            System.Console.ReadLine();

            CaptureService.Instance.Stop();
        }
示例#19
0
        /// <summary>
        /// Listen for mouse up event and proceed to upload.
        /// </summary>
        /// <param name="e"></param>
        protected override void OnMouseUp(MouseEventArgs e)
        {
            base.OnMouseUp(e);
            MakeClickable();

            if (!isMouseDown)
            {
                return;
            }

            mouseUpPoint    = mouseMovePoint = e.Location;
            mouseButtonUsed = e.Button;
            isMouseDown     = false;

            // IMPORTANT: Convert the local (window) points to absolute (screen) points
            var region = CaptureService.GetRectangle(
                PointToScreen(mouseDownPoint),
                PointToScreen(mouseUpPoint));

            if (region.Width < 1 || region.Height < 1)
            {
                return;
            }

            FormService.HideCropForms();
            Application.DoEvents();

            // Wait the form to be hidden
            Thread.Sleep(200);

            switch (e.Button)
            {
            case MouseButtons.Left:
                controller.CaptureImage(region);
                break;

            case MouseButtons.Right:
                controller.CaptureVideo(region);
                break;
            }
        }
示例#20
0
        /// <summary>
        /// Listen for mouse up event and proceed to upload.
        /// </summary>
        /// <param name="e"></param>
        protected override void OnMouseUp(MouseEventArgs e)
        {
            base.OnMouseUp(e);
            MakeClickable();

            if (!isMouseDown)
            {
                return;
            }

            mouseUpPoint    = mouseMovePoint = e.Location;
            mouseButtonUsed = e.Button;
            isMouseDown     = false;

            var region = CaptureService.GetRectangle(mouseDownPoint, mouseUpPoint);

            if (region.X < 0 || region.Y < 0 || region.Width < 1 || region.Height < 1)
            {
                return;
            }

            FormService.HideCropForms();
            Application.DoEvents();

            SetScaling();

            // Wait the crop form to be hidden
            Thread.Sleep(VersionService.GetPlatform() == PlatformType.Windows ? 50 : 500);

            switch (e.Button)
            {
            case MouseButtons.Left:
                controller.CaptureImage(region, screen.Location);
                break;

            case MouseButtons.Right:
                controller.CaptureVideo(region, screen.Location);
                break;
            }
        }
示例#21
0
        /// <summary>
        /// Paint the rectangle if the mouse button is down.
        /// </summary>
        /// <param name="e"></param>
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);

            if (!isMouseDown)
            {
                return;
            }

            var region = CaptureService.GetRectangle(mouseDownPoint, mouseMovePoint);

            if (mouseButtonUsed == MouseButtons.Left)
            {
                DrawSelectRectangle(e.Graphics, Config.LeftColor, region);
            }
            else if (mouseButtonUsed == MouseButtons.Right)
            {
                DrawSelectRectangle(e.Graphics, Config.RightColor, region);
            }

            lastRegion = region;
        }
示例#22
0
        /// <summary>
        /// Capture a lot of bitmaps and convert them to video.
        /// </summary>
        /// <param name="region"></param>
        public async void CaptureVideo(Rectangle region)
        {
            MemoryStream stream;
            var          toast = -1;

            // Create a new toast which closing event gonna stop the recording
            toast = ToastService.Create(Resources.StopRecording, Color.OrangeRed, 0, () =>
            {
                toast = ToastService.Create(Resources.Encoding, 0);
                CaptureService.StopRecording();
            });

            stream = await CaptureService.RecordVideo(region, Config.VideoExt, SettingsService.Current.SafeVideoFps);

            ToastService.Remove(toast);

            // Generate filename and start the upload(s)
            var url = await UploadAll(stream, Config.VideoExt);

            stream.Dispose();

            CopyUrl(url);
            Complete(url != null); // Exits the application
        }
        private void button1_Click(object sender, RoutedEventArgs e)
        {
            if (cb_interfaceList.SelectedIndex == -1)
            {
                MessageBox.Show("You must select an interface to listen on!");
                return;
            }
            if (textBox1.Text == "")
            {
                MessageBox.Show("You must choose one or more TCP ports to listen on for Proxy traffic!");
                return;
            }
            string portsStr = textBox1.Text;

            string[] portsStrs = portsStr.Split(',');
            int[]    ports     = new int[portsStrs.Length];
            for (int i = 0; i < portsStrs.Length; i++)
            {
                ports[i] = int.Parse(portsStrs[i]);
            }
            CaptureService.ProxyCapturePorts = ports;
            CaptureService.SelectDevice(cb_interfaceList.SelectedIndex);
            this.Close();
        }
        public void Multiple_IStateRecorders_Are_Written_In_Chronological_Order_Into_A_Shared_Stream()
        {
            var guid = Guid.NewGuid();
            var stream = new ConcurrentStream(new MemoryStream());

            var stateController = new SimpleStateController { Guid = guid };

            var stateResolver = new StateResolver();
            stateResolver.Add(stateController);

            var captureService = new CaptureService
            {
                Stream = stream,
                StateResolver = stateResolver
            };

            var recorder1 = new Mock<IStateRecorder>();
            var recorder2 = new Mock<IStateRecorder>();

            var recorderBuffer1 = new SimpleBuffer<ICaptureState>();
            var recorderBuffer2 = new SimpleBuffer<ICaptureState>();

            recorder1.Setup(b => b.Buffer).Returns(recorderBuffer1);
            recorder2.Setup(b => b.Buffer).Returns(recorderBuffer2);

            //push some dummy states into the buffers

            var state1 = new Mock<ICaptureState>();
            var firstTimestamp = DateTime.Now.AddDays(1);
            state1.Setup(s => s.Timestamp).Returns(firstTimestamp);
            state1.Setup(s => s.Guid).Returns(guid);

            var state2 = new Mock<ICaptureState>();
            var secondTimestamp = DateTime.Now.AddDays(2);
            state2.Setup(s => s.Timestamp).Returns(secondTimestamp);
            state2.Setup(s => s.Guid).Returns(guid);

            recorderBuffer1.Enqueue(state1.Object);
            recorderBuffer2.Enqueue(state2.Object);

            //add the 2nd recorder in first as it's timestamp is at a time in the future beyond the first recorder's state
            captureService.Add(recorder2.Object);

            captureService.Add(recorder1.Object);

            captureService.Start();
            captureService.Flush();

            Assert.Equal(2, captureService.CaptureStream.Count);

            //open the stream for reading now
            stream.Position = 0;

            var captureStream = new CaptureStream(stream, FileAccess.Read, stateResolver);

            //first value read back should be from state1
            Assert.Equal(firstTimestamp, captureStream.Read().Timestamp);
            Assert.Equal(secondTimestamp, captureStream.Read().Timestamp);
        }
示例#25
0
 private ScreenCapturer()
 {
     capService = new CaptureService();
 }
示例#26
0
        /// <summary>
        /// Paint the rectangle if the mouse button is down.
        /// </summary>
        /// <param name="e"></param>
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);

            if (!isMouseDown)
            {
                return;
            }

            var draw = new Action <Brush, Rectangle>((color, r) =>
            {
                if (!ConfigService.Current.NoTransparency)
                {
                    var back = new SolidBrush(BackColor);

                    if (last.X < r.X)
                    {
                        e.Graphics.FillRectangle(back, last.X, last.Y, r.X - last.X, last.Height);
                    }

                    if (last.Y < r.Y)
                    {
                        e.Graphics.FillRectangle(back, last.X, last.Y, last.Width, r.Y - last.Y);
                    }

                    if (last.Y + last.Height > r.Y + r.Height)
                    {
                        e.Graphics.FillRectangle(back, last.X, r.Y + r.Height, last.Width, last.Y + last.Height - (r.Y + r.Height));
                    }

                    if (last.X + last.Width > r.X + r.Width)
                    {
                        e.Graphics.FillRectangle(back, r.X + r.Width, last.Y, last.X + last.Width - (r.X + r.Width), last.Height);
                    }

                    e.Graphics.FillRectangle(color, r.X, r.Y, r.Width, r.Height);
                }
                else
                {
                    var path = new[]
                    {
                        new Point {
                            X = r.X, Y = r.Y
                        },
                        new Point {
                            X = r.X + r.Width, Y = r.Y
                        },
                        new Point {
                            X = r.X + r.Width, Y = r.Y + r.Height
                        },
                        new Point {
                            X = r.X, Y = r.Y + r.Height
                        },
                        new Point {
                            X = r.X, Y = r.Y
                        }
                    };

                    e.Graphics.DrawLines(new Pen(color, Constants.PenWidth), path);
                }
            });

            var rectangle = CaptureService.GetRectangle(mouseDownPoint, mouseMovePoint);

            switch (mouseButtonUsed)
            {
            case MouseButtons.Left:
                draw(Constants.LeftColor, rectangle);
                break;

            case MouseButtons.Right:
                draw(Constants.RightColor, rectangle);
                break;
            }

            last = rectangle;
        }
        //    private ObservableAsPropertyHelper<ObservableCollection<AudioMeterModel>> _audioMeters;

        public MainWindowViewModel()
        {
            _deviceEnumerator   = new MMDeviceEnumerator();
            _notificationClient = new MMNotificationClient(_deviceEnumerator);

            CaptureService.ItemsUpdated.ObserveOn(RxApp.MainThreadScheduler).Subscribe(x =>
            {
                if (AudioMeters.Count == 0)
                {
                    foreach (var audioMeterModel in x)
                    {
                        AudioMeters.Add(audioMeterModel);
                    }

                    return;
                }

                if (PeakVolume > 0)
                {
                    if (x[0].Value > PeakVolume + PeakOffset)
                    {
                        Console.WriteLine("ALERT");
                    }
                }
                test.Add(x[0].Value);
                for (var i = 0; i < x.Count; i++)
                {
                    AudioMeters[i] = x[i];
                }
            });


            UpdateDevices = ReactiveCommand.Create(() =>
            {
                Devices.Clear();
                foreach (var device in _deviceEnumerator.EnumAudioEndpoints(DataFlow.All, DeviceState.Active))
                {
                    Devices.Add(device);
                }
            });

            StartVolumeCapture =
                ReactiveCommand.Create(() => { CaptureService.Start(); }, outputScheduler: RxApp.MainThreadScheduler);
            StopVolumeCapture =
                ReactiveCommand.Create(() => { CaptureService.Stop(); }, outputScheduler: RxApp.MainThreadScheduler);
            PeakVolumeCapture =
                ReactiveCommand.CreateFromObservable <Unit, Unit>(_ =>
            {
                CaptureService.Start();
                test.Clear();
                return(Observable.Return(Unit.Default)
                       .Delay(TimeSpan.FromSeconds(10))
                       .Do(x => CaptureService.Stop()));
            });
            PeakVolumeCapture.Subscribe(x => PeakVolume = test.Max());
            PeakVolumeCapture.ThrownExceptions.Subscribe(Console.WriteLine);
            Observable.FromEventPattern <DeviceNotificationEventArgs>(
                x => _notificationClient.DeviceAdded += x,
                x => _notificationClient.DeviceAdded -= x).Merge(
                Observable.FromEventPattern <DeviceNotificationEventArgs>(
                    y => _notificationClient.DeviceRemoved += y,
                    y => _notificationClient.DeviceRemoved -= y))
            .ObserveOn(RxApp.MainThreadScheduler)
            .Select(x => Unit.Default)
            .InvokeCommand(UpdateDevices);

            Observable.FromEventPattern <DevicePropertyChangedEventArgs>(
                z => _notificationClient.DevicePropertyChanged += z,
                z => _notificationClient.DevicePropertyChanged -= z)
            .ObserveOn(RxApp.MainThreadScheduler)
            .Select(x => Unit.Default)
            .InvokeCommand(UpdateDevices);
        }
 public CaptureDispatcher(CaptureService service) => _service = service;
示例#29
0
        public override void Arrange()
        {
            base.Arrange();

            CaptureService = new CaptureService(UnitOfWork, UserContext);
        }
示例#30
0
 public ApiController(ILogger <ApiController> logger, CaptureService captureService, FWContext context)
 {
     _logger         = logger;
     _captureService = captureService;
     _context        = context;
 }
        public void Multiple_IStateRecorders_Can_Be_Written_Into_The_Same_IStream()
        {
            var guid = Guid.NewGuid();
            var stateController = new Mock<IStateController>();
            stateController.Setup(s => s.Guid).Returns(guid);
            //stateController.Setup(s => s.Create(It.IsAny<byte[]>(), It.IsAny<DateTime>())).Returns(new Mock<ICaptureState>().Object);
            var stateResolver = new StateResolver();
            stateResolver.Add(stateController.Object);

            var captureService = new CaptureService
            {
                Stream = new ConcurrentStream(new MemoryStream()),
                StateResolver = stateResolver
            };

            var recorder1 = new Mock<IStateRecorder>();
            var recorder2 = new Mock<IStateRecorder>();

            var recorderBuffer1 = new SimpleBuffer<ICaptureState>();
            var recorderBuffer2 = new SimpleBuffer<ICaptureState>();

            recorder1.Setup(b => b.Buffer).Returns(recorderBuffer1);
            recorder2.Setup(b => b.Buffer).Returns(recorderBuffer2);

            //push some dummy states into the buffers

            var state1 = new Mock<ICaptureState>();
            state1.Setup(s=>s.Timestamp).Returns(new DateTime(2011, 2, 3));
            state1.Setup(s => s.Guid).Returns(guid);

            var state2 = new Mock<ICaptureState>();
            state2.Setup(s => s.Timestamp).Returns(new DateTime(2011, 2, 4));
            state2.Setup(s => s.Guid).Returns(guid);

            recorderBuffer1.Enqueue(state1.Object);
            recorderBuffer2.Enqueue(state2.Object);

            captureService.Add(recorder1.Object);
            captureService.Add(recorder2.Object);

            captureService.Start();

            captureService.Flush();

            Assert.Equal(2, captureService.CaptureStream.Count);
        }
 public CaptureServiceTest(
     MockHttpClientFixture mockHttpClientFixture)
     : base(mockHttpClientFixture)
 {
     service = new CaptureService(Client);
 }
示例#33
0
 void captureSettingsDialog_Closed(object sender, EventArgs e)
 {
     CaptureService.mw = this;
     CaptureService.StartCapture();
 }