Exemple #1
0
 public void Stop()
 {
     if (panel.InvokeRequired)
     {
         var d = new StopDelegate(Stop);
         Invoke(d);
     }
     else
     {
         Panel replacement = new Panel();
         replacement.SetBounds(avion.DaForma()[0].Location.X, avion.DaForma()[1].Location.Y, 30, 20);
         replacement.BackColor = Color.Blue;
         replacement.Parent    = panel;
         avion.Scapa();
         stays = false;
         task1.Wait();
         task2.Wait();
         task3.Wait();
         ascunde();
         while (coada.DaPrim() != null)
         {
             coada.Pop();
         }
         replacement.Dispose();
     }
 }
Exemple #2
0
        static void Main(string[] args)
        {
            RunDelegate  r1 = new RunDelegate(Run);
            StopDelegate s1 = new StopDelegate(Stop);

            r1();
            s1();
            Console.Read();
        }
Exemple #3
0
        ///////////////////////////////////////////////////////////////////////

        void makeDelegates()
        {
            aquireDelegate            = new AquireDelegate(callbackHandler.Aquire);
            stopDelegate              = new StopDelegate(callbackHandler.Stop);
            clearCountDelegate        = new ClearImageCount(callbackHandler.ClearImageCount);
            incrementCountDelegate    = new IncrementImageCount(callbackHandler.IncrementImageCount);
            setSaveDirDelegate        = new SetSaveDirDelegate(setSaveDir);
            printDelegate             = new PrintDelegate(printFromDevice);
            externalTriggerOnDelegate = new ExternalTriggerOn(userInterface.externalTriggerOn);
        }
Exemple #4
0
 /// <summary>
 /// Stop Animation
 /// </summary>
 /// <returns></returns>
 public bool Stop()
 {
     if (this.InvokeRequired)
     {
         StopDelegate stopDelegate = new StopDelegate(this.Stop);
         return((bool)this.Invoke(stopDelegate));
     }
     _AnimDelay = Timeout.Infinite;
     return(StopAnimation());
 }
Exemple #5
0
 public PeerConnectionManager(int localPort, string address, ProgressChangedDelegate progressChangedDelegate)
 {
     requestedFileListDelegate = new RequestedFileListDelegate(RequestedFileList);
     requestedFileDelegate = new RequestedFileDelegate(RequestedFile);
     cancelFileTransferDelegate = new CancelFileTransferDelegate(CancelFileTransfer);
     stopDelegate = new StopDelegate(this.StopThread);
     getFileFromPeerDelegate = new GetFileFromPeer(this.GetFileFromPeer);
     getFileListFromPeerDelegate = new GetFileListFromPeer(this.GetFileListFromPeer);
     this.progressChangedDelegate = progressChangedDelegate;
     this._localPort = localPort;
     this._localAddress = address;
 }
Exemple #6
0
        /// <summary>
        /// Binds the class instance methods to the dll functions.
        /// </summary>
        /// <param name="hDll">A dll to bind to.</param>
        private void BindToDll(IntPtr hDll)
        {
            IntPtr pProcPtr = GetProcAddress(hDll, "EnumVideoInputDevices");

            this._enumVideoInputDevices =
                (EnumVideoInputDevicesDelegate)Marshal.GetDelegateForFunctionPointer(pProcPtr, typeof(EnumVideoInputDevicesDelegate));

            pProcPtr = GetProcAddress(hDll, "BuildCaptureGraph");
            this._buildCaptureGraph =
                (BuildCaptureGraphDelegate)Marshal.GetDelegateForFunctionPointer(pProcPtr, typeof(BuildCaptureGraphDelegate));

            pProcPtr = GetProcAddress(hDll, "AddRenderFilter");
            this._addRenderFilter =
                (AddRenderFilterDelegate)Marshal.GetDelegateForFunctionPointer(pProcPtr, typeof(AddRenderFilterDelegate));

            pProcPtr = GetProcAddress(hDll, "AddCaptureFilter");
            this._addCaptureFilter =
                (AddCaptureFilterDelegate)Marshal.GetDelegateForFunctionPointer(pProcPtr, typeof(AddCaptureFilterDelegate));

            pProcPtr = GetProcAddress(hDll, "ResetCaptureGraph");
            this._resetCaptureGraph =
                (ResetCaptureGraphDelegate)Marshal.GetDelegateForFunctionPointer(pProcPtr, typeof(ResetCaptureGraphDelegate));

            pProcPtr    = GetProcAddress(hDll, "Start");
            this._start = (StartDelegate)Marshal.GetDelegateForFunctionPointer(pProcPtr, typeof(StartDelegate));

            pProcPtr = GetProcAddress(hDll, "GetCurrentImage");
            this._getCurrentImage =
                (GetCurrentImageDelegate)Marshal.GetDelegateForFunctionPointer(pProcPtr, typeof(GetCurrentImageDelegate));

            pProcPtr           = GetProcAddress(hDll, "GetVideoSize");
            this._getVideoSize =
                (GetVideoSizeDelegate)Marshal.GetDelegateForFunctionPointer(pProcPtr, typeof(GetVideoSizeDelegate));

            pProcPtr   = GetProcAddress(hDll, "Stop");
            this._stop = (StopDelegate)Marshal.GetDelegateForFunctionPointer(pProcPtr, typeof(StopDelegate));

            pProcPtr = GetProcAddress(hDll, "DestroyCaptureGraph");
            this._destroyCaptureGraph =
                (DestroyCaptureGraphDelegate)Marshal.GetDelegateForFunctionPointer(pProcPtr, typeof(DestroyCaptureGraphDelegate));
        }
Exemple #7
0
 internal static extern void CSharpResource_SetMain(IntPtr resourcePointer, MainDelegate mainDelegate,
                                                    StopDelegate stopDelegate,
                                                    TickDelegate tickDelegate, ServerEventDelegate serverEventDelegate,
                                                    CheckpointDelegate checkpointDelegate,
                                                    ClientEventDelegate clientEventDelegate, PlayerDamageDelegate playerDamageDelegate,
                                                    PlayerConnectDelegate playerConnectDelegate, PlayerDeathDelegate playerDeathDelegate,
                                                    PlayerDisconnectDelegate playerDisconnectDelegate, PlayerRemoveDelegate playerRemoveDelegate,
                                                    VehicleRemoveDelegate vehicleRemoveDelegate,
                                                    PlayerChangeVehicleSeatDelegate playerChangeVehicleSeatDelegate,
                                                    PlayerEnterVehicleDelegate playerEnterVehicleDelegate,
                                                    PlayerLeaveVehicleDelegate playerLeaveVehicleDelegate,
                                                    CreatePlayerDelegate createPlayerDelegate, RemovePlayerDelegate removePlayerDelegate,
                                                    CreateVehicleDelegate createVehicleDelegate, RemoveVehicleDelegate removeVehicleDelegate,
                                                    CreateBlipDelegate createBlipDelegate, RemoveBlipDelegate removeBlipDelegate,
                                                    CreateCheckpointDelegate createCheckpointDelegate, RemoveCheckpointDelegate removeCheckpointDelegate,
                                                    CreateVoiceChannelDelegate createVoiceChannelDelegate,
                                                    RemoveVoiceChannelDelegate removeVoiceChannelDelegate,
                                                    ConsoleCommandDelegate consoleCommandDelegate,
                                                    MetaDataChange metaDataChange,
                                                    MetaDataChange syncedMetaDataChange,
                                                    CreateColShapeDelegate createColShapeDelegate,
                                                    RemoveColShapeDelegate removeColShapeDelegate,
                                                    ColShapeDelegate colShapeDelegate
                                                    );
Exemple #8
0
 internal static extern void CSharpResourceImpl_SetStopDelegate(IntPtr resource,
                                                                StopDelegate @delegate);
        /// <summary>
        /// Binds the class instance methods to the dll functions.
        /// </summary>
        /// <param name="hDll">A dll to bind to.</param>
        private void BindToDll(IntPtr hDll)
        {
            IntPtr pProcPtr = GetProcAddress(hDll, "Initialize");
            _initialize =
                (InitializeDelegate)Marshal.GetDelegateForFunctionPointer(pProcPtr, typeof(InitializeDelegate));

            //pProcPtr = GetProcAddress(hDll, "Open");
            //_open =
            //    (OpenDelegate)Marshal.GetDelegateForFunctionPointer(pProcPtr, typeof(OpenDelegate));

            pProcPtr = GetProcAddress(hDll, "StartPlay");
            _startPlayDelegate =
                (StartPlayDelegate)Marshal.GetDelegateForFunctionPointer(pProcPtr, typeof(StartPlayDelegate));

            pProcPtr = GetProcAddress(hDll, "GetCurrentFrame");
            _getCurrentFrame =
                (GetCurrentFrameDelegate)Marshal.GetDelegateForFunctionPointer(pProcPtr,
                typeof(GetCurrentFrameDelegate));

            pProcPtr = GetProcAddress(hDll, "GetFrameSize");
            _getFrameSize =
                (GetFrameSizeDelegate)Marshal.GetDelegateForFunctionPointer(pProcPtr,
                typeof(GetFrameSizeDelegate));

            pProcPtr = GetProcAddress(hDll, "Stop");
            _stop =
                (StopDelegate)Marshal.GetDelegateForFunctionPointer(pProcPtr, typeof(StopDelegate));

            pProcPtr = GetProcAddress(hDll, "Uninitialize");
            _uninitialize = (UninitializeDelegate)Marshal.GetDelegateForFunctionPointer(pProcPtr, typeof(UninitializeDelegate));
        }
Exemple #10
0
        /// <summary>
        /// Binds the class instance methods to the dll functions.
        /// </summary>
        /// <param name="hDll">A dll to bind to.</param>
        private void BindToDll(IntPtr hDll)
        {
            IntPtr pProcPtr = GetProcAddress(hDll, "EnumVideoInputDevices");
            _enumVideoInputDevices =
                (EnumVideoInputDevicesDelegate)Marshal.GetDelegateForFunctionPointer(pProcPtr, typeof(EnumVideoInputDevicesDelegate));

            pProcPtr = GetProcAddress(hDll, "BuildCaptureGraph");
            _buildCaptureGraph =
                (BuildCaptureGraphDelegate)Marshal.GetDelegateForFunctionPointer(pProcPtr, typeof(BuildCaptureGraphDelegate));

            pProcPtr = GetProcAddress(hDll, "AddRenderFilter");
            _addRenderFilter =
                (AddRenderFilterDelegate)Marshal.GetDelegateForFunctionPointer(pProcPtr, typeof(AddRenderFilterDelegate));

            pProcPtr = GetProcAddress(hDll, "AddCaptureFilter");
            _addCaptureFilter =
                (AddCaptureFilterDelegate)Marshal.GetDelegateForFunctionPointer(pProcPtr, typeof(AddCaptureFilterDelegate));

            pProcPtr = GetProcAddress(hDll, "ResetCaptureGraph");
            _resetCaptureGraph =
                (ResetCaptureGraphDelegate)Marshal.GetDelegateForFunctionPointer(pProcPtr, typeof(ResetCaptureGraphDelegate));

            pProcPtr = GetProcAddress(hDll, "Start");
            _start = (StartDelegate)Marshal.GetDelegateForFunctionPointer(pProcPtr, typeof(StartDelegate));

            pProcPtr = GetProcAddress(hDll, "GetCurrentImage");
            _getCurrentImage =
                (GetCurrentImageDelegate)Marshal.GetDelegateForFunctionPointer(pProcPtr, typeof(GetCurrentImageDelegate));

            pProcPtr = GetProcAddress(hDll, "GetVideoSize");
            _getVideoSize =
                (GetVideoSizeDelegate)Marshal.GetDelegateForFunctionPointer(pProcPtr, typeof(GetVideoSizeDelegate));

            pProcPtr = GetProcAddress(hDll, "Stop");
            _stop = (StopDelegate)Marshal.GetDelegateForFunctionPointer(pProcPtr, typeof(StopDelegate));

            pProcPtr = GetProcAddress(hDll, "DestroyCaptureGraph");
            _destroyCaptureGraph =
                (DestroyCaptureGraphDelegate)Marshal.GetDelegateForFunctionPointer(pProcPtr, typeof(DestroyCaptureGraphDelegate));
        }
 /// <summary>
 /// Create a new worker thread.
 /// </summary>
 /// <param name="threadFunction">The enumerator coroutine to call on each thread loop.</param>
 /// <param name="onQuit">The delegate to called to request the thread complete execution.</param>
 /// <param name="onStop">The delegate to call after joining the thread in <see cref="Stop()"/></param>
 public Workthread(IEnumerator threadFunction, QuitDelegate onQuit = null, StopDelegate onStop = null)
 {
     _threadFunction = threadFunction;
     _onStop         = onStop;
     _onQuit         = onQuit;
 }
Exemple #12
0
 /// <summary>
 /// Stop Animation
 /// </summary>
 /// <returns></returns>
 public bool Stop()
 {
     if (this.InvokeRequired)
     {
         StopDelegate stopDelegate = new StopDelegate(this.Stop);
         return (bool)this.Invoke(stopDelegate);
     }
     _AnimDelay = Timeout.Infinite;
     return StopAnimation();
 }
Exemple #13
0
        /// <summary>
        /// Stops the recording or stops the pre-start timer.
        /// </summary>
        private void Stop()
        {
            try
            {
                _frameCount = 0; //put this in other location

                timerCapture.Stop();
                timerCaptureFull.Stop();
                timerCapWithCursor.Stop();
                timerCapWithCursorFull.Stop();

                if (_stage != Stage.Stopped && _stage != Stage.PreStarting && _listFrames.Any()) //if not already stoped or pre starting, stops
                {
                    #region To Stop and Save

                    try
                    {
                        _actHook.Stop(); //Stops the hook.
                    }
                    catch (Exception ex) { }

                    _stopDel = StopAsync;
                    _stopDel.BeginInvoke(CallBackStop, null);

                    this.Cursor = Cursors.AppStarting;
                    panelBottom.Enabled = false;

                    return;

                    #endregion
                }
                else if ((_stage == Stage.PreStarting || _stage == Stage.Snapping) && !_listFrames.Any()) // if Pre-Starting or in Snapmode and no frames, stops.
                {
                    #region To Stop

                    timerPreStart.Stop();
                    _stage = Stage.Stopped;

                    //Enables the controls that are disabled while recording;
                    numMaxFps.Enabled = true;
                    btnRecordPause.Enabled = true;
                    tbHeight.Enabled = true;
                    tbWidth.Enabled = true;

                    btnMaximize.Enabled = true;
                    btnMinimize.Enabled = true;

                    btnRecordPause.Text = Resources.btnRecordPause_Record;
                    btnRecordPause.Image = Resources.Record;
                    btnRecordPause.ImageAlign = ContentAlignment.MiddleLeft;
                    this.Text = Resources.TitleStoped;

                    AutoFitButtons();
                    this.Invalidate();

                    try
                    {
                        //Re-starts the keyboard hook.
                        _actHook.OnMouseActivity += null;
                        _actHook.Start(false, true);
                    }
                    catch (Exception) { }

                    #endregion
                }
            }
            catch (NullReferenceException nll)
            {
                MessageBox.Show(nll.Message, "NullReference", MessageBoxButtons.OK, MessageBoxIcon.Error);
                LogWriter.Log(nll, "NullPointer in the Stop function");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                LogWriter.Log(ex, "Error in the Stop function");
            }
        }
Exemple #14
0
        /// <summary>
        /// Binds the class instance methods to the dll functions.
        /// </summary>
        /// <param name="hDll">A dll to bind to.</param>
        private void BindToDll(IntPtr hDll)
        {
            IntPtr pProcPtr = GetProcAddress(hDll, "Initialize");
            _initialize =
                (InitializeDelegate)Marshal.GetDelegateForFunctionPointer(pProcPtr, typeof(InitializeDelegate));

            pProcPtr = GetProcAddress(hDll, "StartPlay");
            _startPlayDelegate =
                (StartPlayDelegate)Marshal.GetDelegateForFunctionPointer(pProcPtr, typeof(StartPlayDelegate));

            pProcPtr = GetProcAddress(hDll, "StartPlayPiP");
            _startPlayPiPDelegate =
                (StartPlayPiPDelegate)Marshal.GetDelegateForFunctionPointer(pProcPtr, typeof(StartPlayPiPDelegate));

            pProcPtr = GetProcAddress(hDll, "GetCurrentFrame");
            _getCurrentFrame =
                (GetCurrentFrameDelegate)Marshal.GetDelegateForFunctionPointer(pProcPtr,
                typeof(GetCurrentFrameDelegate));

            pProcPtr = GetProcAddress(hDll, "GetFrameSize");
            _getFrameSize =
                (GetFrameSizeDelegate)Marshal.GetDelegateForFunctionPointer(pProcPtr,
                typeof(GetFrameSizeDelegate));

            pProcPtr = GetProcAddress(hDll, "SetupPiP");
            _setupPiP =
                (SetupPiPDelegate)Marshal.GetDelegateForFunctionPointer(pProcPtr,
                typeof(SetupPiPDelegate));

            pProcPtr = GetProcAddress(hDll, "SetupZoom");
            _setupZoom =
                (SetupZoomDelegate)Marshal.GetDelegateForFunctionPointer(pProcPtr,
                typeof(SetupZoomDelegate));

            pProcPtr = GetProcAddress(hDll, "SetupCross");
            _setupCross =
                (SetupCrossDelegate)Marshal.GetDelegateForFunctionPointer(pProcPtr,
                typeof(SetupCrossDelegate));

            pProcPtr = GetProcAddress(hDll, "Stop");
            _stop =
                (StopDelegate)Marshal.GetDelegateForFunctionPointer(pProcPtr, typeof(StopDelegate));

            pProcPtr = GetProcAddress(hDll, "Uninitialize");
            _uninitialize = (UninitializeDelegate)Marshal.GetDelegateForFunctionPointer(pProcPtr, typeof(UninitializeDelegate));
        }
Exemple #15
0
        public static void Main_Service_Console <T>(StartDelegate _StartDelegate, StopDelegate _StopDelegate, string _sApplicationName, bool _bShouldRunAsSingleInstance)
        {
            if (Environment.UserInteractive)
            {
                try
                {
                    bool createdNew = true;

                    Process currentProcess = Process.GetCurrentProcess();
                    string  sAppName       = (string.IsNullOrWhiteSpace(_sApplicationName) == true) ? currentProcess.ProcessName : _sApplicationName.RemoveWhiteSpace();

                    using (Mutex mutex = new Mutex(true, sAppName, out createdNew))
                    {
                        // SKislyuk 11/3/2016 2:23:09 PM
                        // if the app can run as multiple instances app then disregard the mutex
                        createdNew = (_bShouldRunAsSingleInstance == true) ? createdNew : true;

                        if (createdNew)
                        {
                            //@cmnt SKislyuk: [03 November 16, 14:33:02]   [161103_143302]
                            // running as console app
                            //
                            //if (_StartDelegate != null)
                            //{
                            //	_StartDelegate();
                            //}
                            // the following like equivalent to code commented above
                            _StartDelegate?.Invoke();


                            Console.WriteLine("Press any key to stop...");
                            Console.ReadKey(true);
                            // SKislyuk 5/4/2018 11:42:43 AM
                            // stopping app
                            //
                            //if (_StopDelegate != null)
                            //{
                            //_StopDelegate();
                            //}
                            // the following like equivalent to code commented above
                            _StopDelegate?.Invoke();
                        }
                        else
                        {
                            ShowProcess();
                        }
                    }
                }
                catch (Exception exp)
                {
                    Logger.WriteErrorLogOnly(exp, "cc27108e-0987-4cbf-b9de-69001127b72f");
                }
            }
            else
            {
                try
                {
                    // running as service
                    using (ServiceBase service = (ServiceBase)Activator.CreateInstance(typeof(T)))
                    {
                        ServiceBase.Run(service);
                    }
                }
                catch (Exception exp)
                {
                    Logger.WriteErrorLogOnly(exp, "ed78d049-1bc4-47f9-8f21-8c25376714fe");
                }
            }
        }
Exemple #16
0
 public static void Main_Service_Console <T>(StartDelegate _StartDelegate, StopDelegate _StopDelegate)
 {
     Main_Service_Console <T>(_StartDelegate, _StopDelegate, string.Empty, true);
 }