Exemplo n.º 1
0
        private void bolus_start_Click(object sender, EventArgs e)
        {
            if (bolusSpeed.Value != 0 && bolusInj.Value != 0)
            {
                Thread.Sleep(500);

                validateVolumeUpDown(bolusInj);


                MODE = InjectionMode.BOLUS;

                lastPosition = currentPosition;

                syringe.setSpeed((double)bolusSpeed.Value);

                rbtn_1x.Checked = true;
                this.Invoke(new Action(() => this.buttons_enabled(false)));

                t.Start();
                if (ModeManager.Bolus.startInjection(syringe, (double)bolusInj.Value, lastPosition))
                {
                    sw.Start();
                }
            }
        }
Exemplo n.º 2
0
        private void start_btn_Click(object sender, EventArgs e)
        {
            if (validateSyringe() && speed_val != 0)
            {
                Thread.Sleep(500);
                if (progressValue < 100)
                {
                    rbtn_1x.Checked = true;
                    this.Invoke(new Action(() => this.buttons_enabled(false)));
                    t.Start();

                    start_btn.BackColor = Color.FromArgb(150, colors.text_color.R, colors.text_color.G, colors.text_color.B);

                    if (ModeManager.ConstantMode.startInjection(syringe))
                    {
                        MODE = InjectionMode.CONSTANT;
                        sw.Start();
                    }
                }
            }
            else
            {
                MessageBox.Show("Select a syringe and speed value!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 3
0
        private void stop_btn_result()
        {
            switch (MODE)
            {
            case InjectionMode.HOMMING:
                progressPanel.Invoke(new Action(() => progressPanel.setInjectedText("Homming stopped")));
                MODE = InjectionMode.WAITING;
                break;

            case InjectionMode.START_POS:
                progressPanel.Invoke(new Action(() => progressPanel.setInjectedText("Setting start position stopped")));
                MODE = InjectionMode.WAITING;
                break;

            case InjectionMode.BOLUS:
                bolus_start.Enabled = true;
                exit_bolus.Enabled  = true;
                progressPanel.Invoke(new Action(() => progressPanel.setInjectedText("Bolus stopped")));
                MODE = InjectionMode.WAITING;
                break;

            default:
                MODE = InjectionMode.WAITING;
                break;
            }
        }
Exemplo n.º 4
0
        private static void ScanAndRegister(this IServiceCollection services,
                                            Assembly[] assemblies,
                                            InjectionMode injectionMode,
                                            bool asSelf)
        {
            services.Scan(scan =>
            {
                var serviceTypeSelector = scan.FromAssemblies(assemblies)
                                          .AddClasses(classes => classes.Where(type =>
                {
                    var injectionAttributeType = typeof(InjectableAttribute);
                    var customAttribute        = type.GetCustomAttributes()
                                                 .FirstOrDefault(attribute =>
                    {
                        var attributeType = attribute.GetType();

                        return(attributeType == injectionAttributeType ||
                               attributeType.IsSubclassOf(injectionAttributeType));
                    });

                    if (customAttribute is null)
                    {
                        return(false);
                    }

                    var injectableAttribute = (InjectableAttribute)customAttribute;

                    return(injectableAttribute.AsSelf == asSelf &&
                           injectableAttribute.Mode == injectionMode);
                }));

                var lifeTimeSelector = asSelf ? serviceTypeSelector.AsSelf() : serviceTypeSelector.AsImplementedInterfaces();
                switch (injectionMode)
                {
                case InjectionMode.Singleton:
                    {
                        lifeTimeSelector.WithSingletonLifetime();
                        break;
                    }

                case InjectionMode.Scoped:
                    {
                        lifeTimeSelector.WithScopedLifetime();
                        break;
                    }

                case InjectionMode.Transient:
                    {
                        lifeTimeSelector.WithTransientLifetime();
                        break;
                    }

                default:
                    throw new ArgumentOutOfRangeException(nameof(injectionMode), injectionMode, null);
                }
            });
        }
Exemplo n.º 5
0
 public int decodeMessage(string message)
 {
     try
     {
         if (message.Contains("1:"))
         {
             int l = message.Length;
             step = Int32.Parse(message.Substring(2, l - 2));
             mode = InjectionMode.CONSTANT;
             if (syringe.length != 0)
             {
                 progress = (step - syringe.start_pos) * 100 / (double)syringe.length;
                 pumped   = (syringe.volume * (step - syringe.start_pos)) / (double)syringe.length;
                 injected = (syringe.volume * (step - acctualPosition)) / (double)syringe.length;
             }
             onNewPositionArrived();
         }
         else if (message.Contains("12:"))
         {
             mode = InjectionMode.HOME_DONE;
             step = 0;
             onHomingDoneArrived();
             mode = InjectionMode.WAITING;
         }
         else if (message.Contains("14:"))
         {
             int l = message.Length;
             mode            = InjectionMode.START_POS_DONE;
             acctualPosition = step;
             onStartPosArrived();
             mode = InjectionMode.WAITING;
         }
         else if (message.Contains("16:"))
         {
             mode = InjectionMode.BOLUS_DONE;
             onBolusDoneArrived();
             mode = InjectionMode.WAITING;
         }
         else if (message.Contains("18:"))
         {
             mode = InjectionMode.WAITING;
             onSyringeStoppedArrived();
         }
         else
         {
             mode = InjectionMode.WAITING;
             onSyringeStoppedArrived();
         }
         return(1);
     }
     catch
     {
         mode = InjectionMode.WAITING;
         onSyringeStoppedArrived();
         return(0);
     }
 }
Exemplo n.º 6
0
 private void back_btn_MouseDown(object sender, MouseEventArgs e)
 {
     if (MODE == InjectionMode.START_POS_DONE || MODE == InjectionMode.HOME_DONE)
     {
         progressPanel.Invoke(new Action(() => progressPanel.setInjectedText("")));
     }
     MODE = InjectionMode.MOVING_BACK;
     t.Start();
     ModeManager.Move.startInjection(MODE);
 }
Exemplo n.º 7
0
        internal ServiceInfo(Type serviceType, Type implementationType, ServiceScope scope, object instance, Func <IDependencyResolver, object> creationFunction, InjectionMode injectionMode)
        {
            ServiceType = serviceType;

            if (implementationType != null)
            {
                ImplementationTypeInfo = ServiceTypeInfo.Get(implementationType);
            }

            Scope            = scope;
            Instance         = instance;
            CreationFunction = creationFunction;
            InjectionMode    = injectionMode;
        }
Exemplo n.º 8
0
        private void Inject(Type instanceType, object instance, InjectionMode mode, bool persistent = false)
        {
            if (mode == InjectionMode.InjectAndResolve || mode == InjectionMode.ResolveOnly)
            {
                ResolveDepedencies(instanceType, instance);
            }

            if (mode == InjectionMode.InjectAndResolve || mode == InjectionMode.InjectOnly)
            {
                _injected.Add(instanceType, new Injection {
                    instance = instance, persistent = persistent
                });
            }
        }
Exemplo n.º 9
0
        private void home_1_Click(object sender, EventArgs e)
        {
            buttons_enabled(false);
            rbtn_4x.Checked = true;

            ModeManager.Move.homming();
            MODE = InjectionMode.HOMMING;

            t.Start();

            reset(sw);
            progressPanel.Invoke(new Action(() => progressPanel.setElapsedTime(TimeSpan.FromMilliseconds(sw.ElapsedMilliseconds))));
            progressPanel.Invoke(new Action(() => progressPanel.setProgressValue(0)));
            progressPanel.Invoke(new Action(() => progressPanel.setInjectedText("Homming...")));
        }
Exemplo n.º 10
0
        private void pos_start_btn_Click(object sender, EventArgs e)
        {
            if (validateSyringe())
            {
                buttons_enabled(false);
                rbtn_4x.Checked = true;

                ModeManager.Move.startPosition(syringe);
                MODE = InjectionMode.START_POS;

                t.Start();

                progressValue = 0;
                progressPanel.Invoke(new Action(() => progressPanel.setInjectedText("Moving to start position...")));
            }
        }
Exemplo n.º 11
0
        /// <summary>
        /// インジェクションを追加します。
        /// </summary>
        /// <param name="injectionAction">インジェクション関数を指定します。</param>
        /// <param name="mode">インジェクションの方針を決定します。</param>
        public void Injection(InjectDelegate <T> injectAction, InjectionMode mode)
        {
            switch (mode)
            {
            case InjectionMode.InjectionFirst:
                this.callFirst.AddFirst(injectAction);
                break;

            case InjectionMode.InjectionLast:
                this.callLast.AddLast(injectAction);
                break;

            case InjectionMode.NoConsider:
            default:
                this.callMiddle.AddLast(injectAction);
                break;
            }
        }
Exemplo n.º 12
0
 private void forth_btn_MouseDown(object sender, MouseEventArgs e)
 {
     if (MODE == InjectionMode.START_POS_DONE || MODE == InjectionMode.HOME_DONE)
     {
         progressPanel.Invoke(new Action(() => progressPanel.setInjectedText("")));
     }
     //if (pumped.Visible != true)
     //    pumped.Visible = true;
     if (progressValue < 100)
     {
         MODE = InjectionMode.MOVING_FORTH;
         t.Start();
         ModeManager.Move.startInjection(MODE);
     }
     else
     {
         MODE = InjectionMode.WAITING;
     }
 }
Exemplo n.º 13
0
            public static bool startInjection(InjectionMode mode)
            {
                string message = "";

                if (mode == InjectionMode.MOVING_FORTH)
                {
                    message = Commands.FORWARD.ToString("D");
                }
                else if (mode == InjectionMode.MOVING_BACK)
                {
                    message = Commands.BACKWARD.ToString("D");
                }

                try
                {
                    communication.sendCommand(message);
                    return(SUCCESS);
                }
                catch
                {
                    return(ERROR);
                }
            }
Exemplo n.º 14
0
        private void StartCapture(InjectionMode mode)
        {
            if (GetInjectionMode() == InjectionMode.Disabled)
            {
                return;
            }

            if (GetInjectionMode() != mode)
            {
                StopCapturing();
            }

            if (!userInterfaceState.IsCapturing())
            {
                StoreConfiguration();
                SetInjectionMode(mode);
                if (mode == InjectionMode.Single)
                {
                    startSingleApplicationButton.Content = "Stop overlay";
                    overlayTracker.StartCaptureExe(targetExePath.Text, commandArgsExePath.Text);
                    userInterfaceState.IsCapturingSingle = true;
                }
                else if (mode == InjectionMode.All)
                {
                    overlayTracker.StartCaptureAll();
                    userInterfaceState.IsCapturingGlobal = true;
                    startOverlayGlobalButton.Content     = "Stop overlay";

                    RegistryUpdater.EnableImplicitlayer();
                }
            }
            else
            {
                if (mode == InjectionMode.All)
                {
                    // Check if all processes with GameOverlay.dll are terminated, otherwise
                    // warn the user to finish all processes.
                    if (overlayTracker.GetHookedProcesses().Count() > 0)
                    {
                        var    processIds = overlayTracker.GetHookedProcesses();
                        string processes  = "";

                        foreach (int id in processIds)
                        {
                            try
                            {
                                Process process = Process.GetProcessById(id);
                                if (process.ProcessName != "ApplicationFrameHost")
                                {
                                    processes += "\n" + process.ProcessName;
                                }
                            }
                            catch
                            {
                                // skip - process does not exist anymore
                            }
                        }

                        if (processes.Length > 0)
                        {
                            var result = MessageBox.Show(
                                "Continue stop capturing? Following processes are still running: " + processes, "Running processes", MessageBoxButton.YesNo);

                            if (result == MessageBoxResult.No)
                            {
                                return;
                            }
                        }
                    }
                }

                StopCapturing();
            }
        }
Exemplo n.º 15
0
 private void processDone(InjectionMode mode)
 {
     MODE = mode;
     this.Invoke(new Action(() => stop_btn.PerformClick()));
     t.Stop();
 }
Exemplo n.º 16
0
        public void Inject(object instance, InjectionMode mode, bool persistent = false)
        {
            Type instanceType = instance.GetType();

            Inject(instanceType, instance, mode, persistent);
        }
        /// <summary>
        /// Injects Singleton, Scoped or Transient mappings based on the supplied parameters
        /// </summary>
        /// <param name="services"></param>
        /// <param name="rootNamespace">Root namespace to poll for interfaces</param>
        /// <param name="interfaceSuffixList">Suffixes for injectable interfaces</param>
        /// <param name="interfacePrefix">Prefix for injectable interfaces</param>
        /// <param name="enforceStrictNaming">If true, will only inject concrete types whos class names are {interfacePrefix}{ConcreteClassName}{InterfaceSuffix}</param>
        /// <param name="restrictImplementationsToInterfaceNamespaces">If true, will only map interfaces to concrete classes in the same root namespace</param>
        private static IServiceCollection InjectFrom(this IServiceCollection services, InjectionMode mode, string rootNamespace,
                                                     List <string> interfaceSuffixList, string interfacePrefix = "I", bool enforceStrictNaming = true,
                                                     bool restrictImplementationsToInterfaceNamespaces         = false)
        {
            var settings = new InjectionSettings
            {
                EnforceStrictNaming     = enforceStrictNaming,
                InjectionMode           = mode,
                InterfaceRootNamespaces = new List <string> {
                    rootNamespace
                },
                InterfacePrefix     = interfacePrefix,
                InterfaceSuffixList = interfaceSuffixList,
                RestrictImplementationsToInterfaceNamespaces = restrictImplementationsToInterfaceNamespaces
            };

            return(services.InjectByConvention(settings));
        }
Exemplo n.º 18
0
 /// <summary>
 /// Create new instance by entry mode.
 /// </summary>
 /// <param name="mode"></param>
 public InjectableAttribute(InjectionMode mode)
 {
     Mode = mode;
 }
 IInjectionRootNamespaceConfiguration IInjectionModeConfiguration.WithInjectionMode(InjectionMode mode)
 {
     InjectionMode = mode;
     return(this);
 }
 public void Deconstruct(out string name, out InjectionMode injectionMode)
 {
     injectionMode = this.InjectionMode;
     name          = this.Namespace;
 }
Exemplo n.º 21
0
 private void SetInjectionMode(InjectionMode captureMode)
 {
     userInterfaceState.ApplicationInjectionMode = captureMode;
 }
 public void Deconstruct(out InjectionMode injectionMode)
 {
     injectionMode = this.InjectionMode;
 }
        public static IInjectionRootNamespaceConfiguration WithInjectionMode(InjectionMode mode)
        {
            var settings = new InjectionSettings();

            return(((IInjectionModeConfiguration)settings).WithInjectionMode(mode));
        }
 public void Deconstruct(out string name, out InjectionMode injectionMode, out string defaultPrefix)
 {
     injectionMode = this.InjectionMode;
     name          = this.Namespace;
     defaultPrefix = this.DefaultPrefix;
 }