Esempio n. 1
0
        public static void Main(string[] args)
        {
            Capturing capture = new Capturing();

            Tcp_packets_holder.Pairs.OnNewRequest += (pair) =>
            {
            };

            Tcp_packets_holder.Pairs.OnNewResponse += (pair) =>
            {
                var response = pair.Response;
                if (/*response.IsCompleted*/ response.Headers != null)
                {
                    WriteInfo(pair);
                }
                else
                {
                    response.OnBytesAdded += () =>
                    {
                        if (/*response.IsCompleted*/ response.Headers != null)
                        {
                            WriteInfo(pair);
                        }
                    };
                }
            };

            capture.StartCapturing(0);
        }
Esempio n. 2
0
 public void Die()
 {
     Player.Units.Remove(this);
     if (Capturing != null)
     {
         Capturing.StopCapture();
     }
 }
Esempio n. 3
0
 private void FinishButton_Click(object sender, EventArgs e)
 {
     if (Capturing != null)
     {
         Capturing.StopRecording();
     }
     else
     {
         Recognize();
     }
 }
Esempio n. 4
0
 public void Wait()
 {
     if (Moved)
     {
         return;
     }
     if (Capturing != null)
     {
         Capturing.StopCapture();
     }
     Moved = true;
 }
Esempio n. 5
0
        static void Main(string[] args)
        {
            StandardedMessages.startMessage();                                             //StandardedMessage Class

            IDictionary <string, string> person = Capturing.CaptureData();                 //Capturing Class capturing person data

            IDictionary <string, string> validatePerson = Validating.validateData(person); //Validating class

            Person selectedPerson = Information.fillingInformation(validatePerson);        //Information class

            Showing.showingData(selectedPerson);
        }
Esempio n. 6
0
 public void Move(Vector2 position)
 {
     if (Moved)
     {
         return;
     }
     if (Capturing != null && position != Position)
     {
         Capturing.StopCapture();
     }
     Position = position;
     Moved    = true;
 }
Esempio n. 7
0
        /// <summary>
        /// Captures a payment for the <see cref="IInvoice"/>
        /// </summary>
        /// <param name="invoice">The invoice to be paid</param>
        /// <param name="payment">The payment to capture</param>
        /// <param name="amount">The amount of the payment to be captured</param>
        /// <param name="args">Additional arguments required by the payment processor</param>
        /// <returns>A <see cref="IPaymentResult"/></returns>
        public virtual IPaymentResult CapturePayment(IInvoice invoice, IPayment payment, decimal amount, ProcessorArgumentCollection args)
        {
            Mandate.ParameterNotNull(invoice, "invoice");

            var operationData = new PaymentOperationData()
            {
                Invoice       = invoice,
                Payment       = payment,
                Amount        = amount,
                PaymentMethod = this.PaymentMethod,
                ProcessorArgumentCollection = args
            };

            Capturing.RaiseEvent(new SaveEventArgs <PaymentOperationData>(operationData), this);

            // persist the invoice
            if (!invoice.HasIdentity)
            {
                GatewayProviderService.Save(invoice);
            }

            var response = PerformCapturePayment(invoice, payment, amount, args);

            //((PaymentResult)response).ApproveOrderCreation = this.EnsureApproveOrderCreation(response, invoice);

            // Special case where the order has already been created due to configuration override.
            if (invoice.Orders.Any() && response.ApproveOrderCreation)
            {
                ((PaymentResult)response).ApproveOrderCreation = false;
            }

            CaptureAttempted.RaiseEvent(new PaymentAttemptEventArgs <IPaymentResult>(response), this);

            if (!response.Payment.Success)
            {
                return(response);
            }

            AssertPaymentApplied(response, response.Invoice);

            AssertInvoiceStatus(response.Invoice);


            // give response
            return(response);
        }
Esempio n. 8
0
        /// <summary>
        /// Authorizes and Captures a Payment
        /// </summary>
        /// <param name="invoice">The invoice to be paid</param>
        /// <param name="amount">The amount of the payment to the invoice</param>
        /// <param name="args">Additional arguments required by the payment processor</param>
        /// <returns>A <see cref="IPaymentResult"/></returns>
        public virtual IPaymentResult AuthorizeCapturePayment(IInvoice invoice, decimal amount, ProcessorArgumentCollection args)
        {
            Mandate.ParameterNotNull(invoice, "invoice");

            var operationData = new PaymentOperationData()
            {
                Invoice = invoice,
                Amount  = amount,
                ProcessorArgumentCollection = args
            };

            Capturing.RaiseEvent(new SaveEventArgs <PaymentOperationData>(operationData), this);

            // persist the invoice
            if (!invoice.HasIdentity)
            {
                GatewayProviderService.Save(invoice);
            }

            // authorize and capture the payment
            var response = PerformAuthorizeCapturePayment(invoice, amount, args);

            //((PaymentResult)response).ApproveOrderCreation = this.EnsureApproveOrderCreation(response, invoice);

            AuthorizeCaptureAttempted.RaiseEvent(new PaymentAttemptEventArgs <IPaymentResult>(response), this);

            if (!response.Payment.Success)
            {
                return(response);
            }

            AssertPaymentApplied(response, invoice);

            AssertInvoiceStatus(invoice);

            // Check configuration for override on ApproveOrderCreation
            if (!response.ApproveOrderCreation)
            {
                ((PaymentResult)response).ApproveOrderCreation = MerchelloConfiguration.Current.AlwaysApproveOrderCreation;
            }

            // give response
            return(response);
        }
Esempio n. 9
0
        private void Capture_RecordingStopped(object sender, StoppedEventArgs e)
        {
            if (Capturing != null)
            {
                Capturing.DataAvailable    -= Capture_DataAvailable;
                Capturing.RecordingStopped -= Capture_RecordingStopped;

                Capturing.Dispose();
                Capturing = null;
            }

            if (Writer != null)
            {
                Writer.Dispose();
                Writer = null;
            }

            Recognize();
        }
Esempio n. 10
0
        private void RegisterCallbacks()
        {
            RegisterErrorCallback();
            RegisterFocusStateChanged();
            RegisterInterruptStartedCallback();
            RegisterInterruptedCallback();
            RegisterStateChangedCallback();

            //Define capturing callback
            _capturingCallback = (IntPtr main, IntPtr postview, IntPtr thumbnail, IntPtr userData) =>
            {
                Capturing?.Invoke(this, new CameraCapturingEventArgs(new StillImage(main),
                                                                     postview == IntPtr.Zero ? null : new StillImage(postview),
                                                                     thumbnail == IntPtr.Zero ? null : new StillImage(thumbnail)));
            };

            //Define captureCompleted callback
            _captureCompletedCallback = _ =>
            {
                SetState(CameraState.Captured);
                CaptureCompleted?.Invoke(this, EventArgs.Empty);
            };
        }
        private void DrawFastestLap(Graphics g, Capturing.OverlayData.FastLap fastestLap)
        {
            Func<GraphicRect, GraphicRect> blueBox = rr =>
               rr.WithBrush(Styles.TransparentLightBlueBrush)
               .WithPen(Styles.BlackPen)
               .DrawRectangleWithBorder()
               .WithBrush(Styles.BlackBrush)
               .WithFont(fontName, 20, FontStyle.Bold)
               .WithStringFormat(StringAlignment.Center);

            g.InRectangle(1920 - 80 - 450, 900, 450, 34)
                .With(blueBox)
                .DrawText("New Fast Lap")
                .ToBelow(width: 50)
                .With(blueBox)
                .DrawText(fastestLap.Driver.CarNumber)
                .ToRight(width: 250)
                .With(blueBox)
                .DrawText(fastestLap.Driver.UserName)
                .ToRight(width: 150)
                .With(blueBox)
                .DrawText(TimeSpan.FromSeconds(fastestLap.Time).ToString(@"mm\:ss\.fff"));
        }
Esempio n. 12
0
    public MainWindow() : base("catcher")
    {
        Build();
        view                = new ItemsView();
        view.Reorderable    = true;
        view.Selection.Mode = SelectionMode.Multiple;

        view.KeyPressEvent += (object o, KeyPressEventArgs args) =>
        {
            if (args.Event.Key == Gdk.Key.Delete)
            {
                var         s_items = view.SelectedItems.ToList <ItemModel>();
                List <long> ids     = new List <long>();
                if (s_items.Count > 0)
                {
                    textview1.Buffer.Text = "";
                    textview2.Buffer.Text = "";

                    lock (_lock)
                    {
                        selection_on = false;
                        foreach (ItemModel i in s_items)
                        {
                            view.RemoveItem(i);
                            items.Remove(i);
                            ids.Add(i.Pair.Id);
                        }
                        Capturing.RegisterRemovePairs(ids);
                        selection_on = true;
                    }
                }
            }
        };

        foreach (var column in view.Columns)
        {
            column.Reorderable = true;
        }
        listview1.Child = view;
        listview1.ShowAll();
        view.ModifyFont(FontDescription.FromString("serif 9"));
        //view.ModifyBase(StateType.Normal, new Gdk.Color(150,205,205));
        //view.ModifyText(StateType.Normal, new Gdk.Color(230,232,250));
        textview1.ModifyFont(FontDescription.FromString("monospace bold 10"));
        textview2.ModifyFont(FontDescription.FromString("monospace bold 10"));
        textview1.ModifyBase(StateType.Normal, new Gdk.Color(82, 82, 82));
        textview1.ModifyText(StateType.Normal, new Gdk.Color(217, 135, 25));
        textview2.ModifyBase(StateType.Normal, new Gdk.Color(82, 82, 82));
        textview2.ModifyText(StateType.Normal, new Gdk.Color(217, 135, 25));

        view.ItemSelected += (ItemModel[] items) =>
        {
            if (selection_on)
            {
                lock (_lock)
                {
                    if (items.Count() > 0)
                    {
                        if (!string.IsNullOrEmpty(items[0].RequestText))
                        {
                            textview1.Buffer.Text = items[0].RequestText;
                        }
                        else
                        {
                            textview1.Buffer.Text = "";
                        }
                        if (!string.IsNullOrEmpty(items[0].ResponseText))
                        {
                            textview2.Buffer.Text = items[0].ResponseText;
                        }
                        else
                        {
                            textview2.Buffer.Text = "";
                        }
                    }
                    else
                    {
                        textview1.Buffer.Text = "";
                        textview2.Buffer.Text = "";
                    }
                    SelectedItem = items[0];
                }
            }
            else
            {
                SelectedItem = null;
            }
        };

        Tcp_packets_holder.StartWorking();
        StartCapturing();
    }
Esempio n. 13
0
    void StartCapturing()
    {
        int saved = GetSavedDevice();

        capture = new Capturing();
        var menu_item = new MenuItem("Devices");

        menubar1.Insert(menu_item, 1);
        var submenu = new Menu();

        menu_item.Submenu = submenu;
        List <Tuple <MenuItem, DeviceInfo> > map = new List <Tuple <MenuItem, DeviceInfo> >();

        foreach (var d in capture.GetDevices())
        {
            MenuItem md = new MenuItem(d.Name);
            if (d.Number == saved)
            {
                statusbar1.Push(0, "Sniffing on: " + d.Name);
            }
            map.Add(new Tuple <MenuItem, DeviceInfo>(md, d));
            md.Activated += (sender, e) =>
            {
                var di = map.Single(f => f.Item1 == sender as MenuItem).Item2;
                statusbar1.Push(0, "Sniffing on: " + di.Name);
                t.Abort();
                t = new Thread(f => StartCapturingOnANewThread(di.Number));
                t.Start();
                SaveDevice(di.Number);
            };
            submenu.Append(md);
        }
        menu_item.ShowAll();
        Tcp_packets_holder.Pairs.OnNewRequest += (pair) =>
        {
            var       request = pair.Request;
            ItemModel item    = new ItemModel()
            {
                Pair        = pair,
                Number      = counter++.ToString(),
                Host        = request.Host,
                Protocol    = request.Protocol,
                Url         = request.Url,
                RequestText = request.First_Line + "\n" + request.Headers_String + "\n\n" + request.Body_String
            };

            request.OnBytesAdded += () =>
            {
                lock (_lock)
                {
                    item.RequestText = request.First_Line + "\n" + request.Headers_String + "\n\n" + request.Body_String;
                }
            };
            lock (_lock)
            {
                items.Add(item);
                undisplayed_counter++;
            }
        };

        Tcp_packets_holder.Pairs.OnNewResponse += (pair) =>
        {
            var response = pair.Response;
            if (response.First_Line != null)
            {
                OnResponseReady(pair);
            }

            response.OnBytesAdded += () =>
            {
                if (response.First_Line != null)
                {
                    OnResponseReady(pair);
                }
            };
        };
        catcher.Utils.SetInterval(() => {
            lock (_lock)
            {
                if (undisplayed_counter > 0)
                {
                    for (int i = items.Count - undisplayed_counter; i < items.Count; i++)
                    {
                        view.AddItem(items[i]);
                    }
                    undisplayed_counter = 0;
                }
            }
        }, 500);


        t = new Thread(f => StartCapturingOnANewThread(saved));
        t.Start();
    }
Esempio n. 14
0
 private void Window_MouseDown(object sender, MouseButtonEventArgs e)
 {
     Screenshot.Source = Capturing.CaptureSubImageTest().Result?.ToBitmap().ToImageSource();
 }