예제 #1
0
        // Dispose(bool disposing) executes in two distinct scenarios.
        // If disposing equals true, the method has been called directly
        // or indirectly by a user's code. Managed and unmanaged resources
        // can be disposed.
        // If disposing equals false, the method has been called by the
        // runtime from inside the finalizer and you should not reference
        // other objects. Only unmanaged resources can be disposed.
        private void Dispose(bool disposing)
        {
            // Check to see if Dispose has already been called.
            if (_disposed)
            {
                return;
            }
            // If disposing equals true, dispose all managed
            // and unmanaged resources.
            if (disposing)
            {
                // Dispose managed resources.
                _dllhandle     = IntPtr.Zero;
                _open          = null;
                _close         = null;
                _start         = null;
                _reset         = null;
                _config        = null;
                _read          = null;
                _write         = null;
                _checkTx       = null;
                _getDeviceList = null;
            }
            // Dispose native ( unmanaged ) resources, if exits

            // Note disposing has been done.
            _disposed = true;
        }
예제 #2
0
 private void SendEmail(string title, string content)
 {
     try
     {
         //发送Internet邮件
         SmtpClient client = new SmtpClient("smtp.163.com");
         client.UseDefaultCredentials = false;
         client.Credentials           = new System.Net.NetworkCredential("*****@*****.**", "easyvs");
         client.DeliveryMethod        = SmtpDeliveryMethod.Network;
         MailMessage mail = new MailMessage();
         mail.From = new MailAddress("*****@*****.**");
         mail.To.Add("*****@*****.**");
         //mail.To.Add("抄送给谁,可以不填");
         mail.Subject      = title;
         mail.BodyEncoding = System.Text.Encoding.Default;
         mail.Body         = content;
         mail.IsBodyHtml   = true;
         client.Send(mail);
         UpdateTextDelegate update = UpdateButtonText;
         Invoke(update);
     }
     catch
     {
         CloseDelegate close = closeSuggest;
         Invoke(close);
     }
 }
예제 #3
0
        static void Main(string[] args)
        {
            //为什么count为一致加呢,按正常应该是在CreatCloseDelegate()完了后直接释放的
            //因为C#编译器把count变量  变成了一个class的字段,count不在栈上了,而是在托管堆中,
            CloseDelegate test = CreatCloseDelegate();

            Console.WriteLine("调用test");
            test();
            test();



            //正常委托
            CloseDelegate zc = new Friend().Output;

            zc();
            //用匿名方法实例化委托
            CloseDelegate cd = delegate
            {
                Console.WriteLine("用匿名方法实例化委托");
            };

            cd();
            Console.ReadKey();
        }
예제 #4
0
            static Native()
            {
                //RuntimeCil.Generate(typeof(MemoryMapped).Assembly);

                Create = Marshal.GetDelegateForFunctionPointer <CreateDelegate>(PlatformApi.NativeLibrary.GetExport(KokkosLibrary.ModuleHandle, "Create"));

                CreateAndOpen = Marshal.GetDelegateForFunctionPointer <CreateAndOpenDelegate>(PlatformApi.NativeLibrary.GetExport(KokkosLibrary.ModuleHandle, "CreateAndOpen"));

                Destory = Marshal.GetDelegateForFunctionPointer <DestoryDelegate>(PlatformApi.NativeLibrary.GetExport(KokkosLibrary.ModuleHandle, "Destory"));

                Open = Marshal.GetDelegateForFunctionPointer <OpenDelegate>(PlatformApi.NativeLibrary.GetExport(KokkosLibrary.ModuleHandle, "Open"));

                Close = Marshal.GetDelegateForFunctionPointer <CloseDelegate>(PlatformApi.NativeLibrary.GetExport(KokkosLibrary.ModuleHandle, "Close"));

                At = Marshal.GetDelegateForFunctionPointer <AtDelegate>(PlatformApi.NativeLibrary.GetExport(KokkosLibrary.ModuleHandle, "At"));

                GetData = Marshal.GetDelegateForFunctionPointer <GetDataDelegate>(PlatformApi.NativeLibrary.GetExport(KokkosLibrary.ModuleHandle, "GetData"));

                IsValid = Marshal.GetDelegateForFunctionPointer <IsValidDelegate>(PlatformApi.NativeLibrary.GetExport(KokkosLibrary.ModuleHandle, "IsValid"));

                Size = Marshal.GetDelegateForFunctionPointer <SizeDelegate>(PlatformApi.NativeLibrary.GetExport(KokkosLibrary.ModuleHandle, "Size"));

                MappedSize = Marshal.GetDelegateForFunctionPointer <MappedSizeDelegate>(PlatformApi.NativeLibrary.GetExport(KokkosLibrary.ModuleHandle, "MappedSize"));

                Remap = Marshal.GetDelegateForFunctionPointer <RemapDelegate>(PlatformApi.NativeLibrary.GetExport(KokkosLibrary.ModuleHandle, "Remap"));
            }
예제 #5
0
 private static extern IntPtr ManagedOutputStream_Create(
     WriteDelegate write,
     TellDelegate tell,
     FlushDelegate flush,
     CloseDelegate close,
     ClosedDelegate closed,
     out IntPtr outputStream);
        /// <summary>
        /// Closes the websocket connection.   Sends a close message to the other side if it hasn't already done so.
        /// </summary>
        /// <param name="message"></param>
        public void Close(string message)
        {
            if (_networkContext == null)
            {
                return;
            }
            if (_networkContext.Stream != null)
            {
                if (_networkContext.Stream.CanWrite)
                {
                    byte[]         messagedata        = Encoding.UTF8.GetBytes(message);
                    WebSocketFrame closeResponseFrame = new WebSocketFrame()
                    {
                        Header           = WebsocketFrameHeader.HeaderDefault(),
                        WebSocketPayload = messagedata
                    };
                    closeResponseFrame.Header.Opcode     = WebSocketReader.OpCode.Close;
                    closeResponseFrame.Header.PayloadLen = (ulong)messagedata.Length;
                    closeResponseFrame.Header.IsEnd      = true;
                    SendSocket(closeResponseFrame.ToBytes());
                }
            }
            CloseDelegate closeD = OnClose;

            if (closeD != null)
            {
                closeD(this, new CloseEventArgs());
            }

            _closing = true;
        }
예제 #7
0
        private void InvokeClose()
        {
            if (this.Disposing || this.IsDisposed)
            {
                return;
            }
            if (this.InvokeRequired)
            {
                CloseDelegate d = Close;
                this.Invoke(d);
            }
            else
            {
                if (!appclosing && !string.IsNullOrEmpty(ErrorDescription))
                {
                    if (!string.IsNullOrEmpty(URL))
                    {
                        ErrorDescription += Environment.NewLine + Environment.NewLine + "Would you like to download the update manually?";
                        TaskbarProgress.SetState(this.Handle, TaskbarProgress.TaskbarStates.Error);
                        if (MessageBox.Show(this, ErrorDescription, MESSAGEBOX_TITLE, MessageBoxButtons.YesNo) == DialogResult.Yes)
                        {
                            Process.Start(URL);
                        }
                    }
                    else
                    {
                        MessageBox.Show(this, ErrorDescription, MESSAGEBOX_TITLE, MessageBoxButtons.OK);
                    }
                }

                WrapUp();
                Close();
            }
        }
예제 #8
0
        private void loadResource()
        {
            ShowProgressResDelegate show = new ShowProgressResDelegate(ShowProgressRes);
            string info = "初始化  .....";

            this.BeginInvoke(show, new object[] { info });
            Thread.Sleep(50);
            string info1            = "加载 Application config .....";
            IApplicationContext ctx = ContextRegistry.GetContext();

            this.BeginInvoke(show, new object[] { info1 });
            Thread.Sleep(100);

            string                  info2             = "加载 Web Service 数据   .....";
            IDataLayer              dataLayer         = (IDataLayer)ctx.GetObject("myServiceObject");
            AbsLoginEventAdapter    loginEventAdapter = (AbsLoginEventAdapter)ctx.GetObject("loginEventAdapter");
            IConnectionStateManager connStateManager  = (IConnectionStateManager)ctx.GetObject("connStateManager");

            this.BeginInvoke(show, new object[] { info2 });
            Thread.Sleep(100);
            string info3 = "保存加载设置  .....";

            this.BeginInvoke(show, new object[] { info3 });
            Thread.Sleep(100);
            sysguard.Properties.Settings.Default.Context.Add("datalayer", dataLayer);
            sysguard.Properties.Settings.Default.Context.Add("connStateManager", connStateManager);
            sysguard.Properties.Settings.Default.Context.Add("conn", ConnState.None);
            sysguard.Properties.Settings.Default.Context.Add("loginEventAdapter", loginEventAdapter);
            this.DialogResult = DialogResult.OK;
            CloseDelegate close = new CloseDelegate(InternalCloseSplash);

            this.BeginInvoke(close, null);
        }
 private static extern IntPtr ManagedRandomAccessFile_Create(
     ReadDelegate read,
     CloseDelegate close,
     GetSizeDelegate getSize,
     TellDelegate tell,
     SeekDelegate seek,
     ClosedDelegate closed,
     out IntPtr randomAccessFile);
예제 #10
0
 internal static void Bind()
 {
     _closeDelegate = Library.GetProcAddress <CloseDelegate>("mdbx_cursor_close") as CloseDelegate;
     _openDelegate  = Library.GetProcAddress <OpenDelegate>("mdbx_cursor_open") as OpenDelegate;
     _getDelegate   = Library.GetProcAddress <GetDelegate>("mdbx_cursor_get") as GetDelegate;
     _putDelegate   = Library.GetProcAddress <PutDelegate>("mdbx_cursor_put") as PutDelegate;
     _delDelegate   = Library.GetProcAddress <DelDelegate>("mdbx_cursor_del") as DelDelegate;
     _countDelegate = Library.GetProcAddress <CountDelegate>("mdbx_cursor_count") as CountDelegate;
 }
예제 #11
0
파일: Dbi.cs 프로젝트: wangjia184/mdbx.NET
 internal static void Bind()
 {
     _openDelegate  = Library.GetProcAddress <OpenDelegate>("mdbx_dbi_open") as OpenDelegate;
     _closeDelegate = Library.GetProcAddress <CloseDelegate>("mdbx_dbi_close") as CloseDelegate;
     _putDelegate   = Library.GetProcAddress <PutDelegate>("mdbx_put") as PutDelegate;
     _getDelegate   = Library.GetProcAddress <GetDelegate>("mdbx_get") as GetDelegate;
     _delDelegate   = Library.GetProcAddress <DelDelegate>("mdbx_del") as DelDelegate;
     _dropDelegate  = Library.GetProcAddress <DropDelegate>("mdbx_drop") as DropDelegate;
 }
예제 #12
0
 static CallbackHandler()
 {
     readCB   = new ReadDelegate(read);
     writeCB  = new ReadDelegate(write);
     seekCB   = new SeekDelegate(seek);
     closeCB  = new CloseDelegate(close);
     tellCB   = new TellDelegate(tell);
     eofCB    = new EofDelegate(eof);
     deleteCB = new DeleteDelegate(deleted);
 }
예제 #13
0
        /// <summary>
        /// 关闭到客户端的连接而不发送响应。
        /// </summary>
        public void Close()
        {
            _closeAction?.Invoke();
            _closeAction = null;
#if net40
            _closeAsycAction?.Invoke();
            _closeAsycAction = null;
#endif
            _isClientConnectedAction = null;
        }
예제 #14
0
 protected void SetDelegates(
     StartDelegate start
     , CloseDelegate close
     )
 {
     /* We just receive the core Delegates. Which we will
      * turn around and handle the Invocation ourselves. */
     _start = start;
     _close = close;
 }
예제 #15
0
 private static ParquetHandle Create(
     WriteDelegate write,
     TellDelegate tell,
     FlushDelegate flush,
     CloseDelegate close,
     ClosedDelegate closed)
 {
     ExceptionInfo.Check(ManagedOutputStream_Create(write, tell, flush, close, closed, out var handle));
     return(new ParquetHandle(handle, OutputStream_Free));
 }
예제 #16
0
    public void ShowCreditsOverlay(CloseDelegate closeDelegate = null)
    {
        if (overlayCanvas != null)
        {
            return;
        }

        InstantiateCanvas(creditsCanvas);
        overlayCanvas.GetComponent <CreditsCanvasBehaviour>().closeDelegate = closeDelegate;
    }
예제 #17
0
 public StateReportRender()
 {
     InitializeComponent();
     this.progressBar1.Value   = 0;
     progressBar1.DisplayStyle = ProgressBarDisplayText.CustomText;
     PlusOne    = plusOne;
     MyClose    = myclose;
     SetMaximum = setMaximum;
     changeLoadingSentence();
 }
예제 #18
0
 private static ParquetHandle Create(
     ReadDelegate read,
     CloseDelegate close,
     GetSizeDelegate getSize,
     TellDelegate tell,
     SeekDelegate seek,
     ClosedDelegate closed)
 {
     ExceptionInfo.Check(ManagedRandomAccessFile_Create(read, close, getSize, tell, seek, closed, out var handle));
     return(new ParquetHandle(handle, RandomAccessFile_Free));
 }
        /// <summary>
        ///   Add an entry, for which the application will provide a stream
        ///   containing the entry data, on a just-in-time basis.
        /// </summary>
        ///
        /// <remarks>
        /// <para>
        ///   In cases where the application wishes to open the stream that
        ///   holds the content for the ZipEntry, on a just-in-time basis, the
        ///   application can use this method.  The application provides an
        ///   opener delegate that will be called by the DotNetZip library to
        ///   obtain a readable stream that can be read to get the bytes for
        ///   the given entry.  Typically, this delegate opens a stream.
        ///   Optionally, the application can provide a closer delegate as
        ///   well, which will be called by DotNetZip when all bytes have been
        ///   read from the entry.
        /// </para>
        ///
        /// <para>
        ///   These delegates are called from within the scope of the call to
        ///   ZipFile.Save().
        /// </para>
        ///
        /// <para>
        ///   For <c>ZipFile</c> properties including <see cref="Encryption"/>, <see
        ///   cref="Password"/>, <see cref="SetCompression"/>, <see
        ///   cref="ProvisionalAlternateEncoding"/>, <see cref="ExtractExistingFile"/>,
        ///   <see cref="ZipErrorAction"/>, and <see cref="CompressionLevel"/>, their
        ///   respective values at the time of this call will be applied to the
        ///   <c>ZipEntry</c> added.
        /// </para>
        ///
        /// </remarks>
        ///
        /// <example>
        ///
        ///   This example uses anonymous methods in C# to open and close the
        ///   source stream for the content for a zip entry.
        ///
        /// <code lang="C#">
        /// using(Ionic.Zip.ZipFile zip = new Ionic.Zip.ZipFile())
        /// {
        ///     zip.AddEntry(zipEntryName,
        ///                  (name) =>  File.Open(filename, FileMode.Open, FileAccess.Read, FileShare.ReadWrite ),
        ///                  (name, stream) =>  stream.Close()
        ///                  );
        ///
        ///     zip.Save(zipFileName);
        /// }
        /// </code>
        ///
        /// </example>
        ///
        /// <example>
        ///
        ///   This example uses delegates in VB.NET to open and close the
        ///   the source stream for the content for a zip entry.  VB 9.0 lacks
        ///   support for "Sub" lambda expressions, and so the CloseDelegate must
        ///   be an actual, named Sub.
        ///
        /// <code lang="VB">
        ///
        /// Function MyStreamOpener(ByVal entryName As String) As Stream
        ///     '' This simply opens a file.  You probably want to do somethinig
        ///     '' more involved here: open a stream to read from a database,
        ///     '' open a stream on an HTTP connection, and so on.
        ///     Return File.OpenRead(entryName)
        /// End Function
        ///
        /// Sub MyStreamCloser(entryName As String, stream As Stream)
        ///     stream.Close()
        /// End Sub
        ///
        /// Public Sub Run()
        ///     Dim dirToZip As String = "fodder"
        ///     Dim zipFileToCreate As String = "Archive.zip"
        ///     Dim opener As OpenDelegate = AddressOf MyStreamOpener
        ///     Dim closer As CloseDelegate = AddressOf MyStreamCloser
        ///     Dim numFilestoAdd As Int32 = 4
        ///     Using zip As ZipFile = New ZipFile
        ///         Dim i As Integer
        ///         For i = 0 To numFilesToAdd - 1
        ///             zip.AddEntry(String.Format("content-{0:000}.txt"), opener, closer)
        ///         Next i
        ///         zip.Save(zipFileToCreate)
        ///     End Using
        /// End Sub
        ///
        /// </code>
        /// </example>
        ///
        /// <param name="entryName">the name of the entry to add</param>
        /// <param name="opener">
        ///  the delegate that will be invoked by ZipFile.Save() to get the
        ///  readable stream for the given entry. ZipFile.Save() will call
        ///  read on this stream to obtain the data for the entry. This data
        ///  will then be compressed and written to the newly created zip
        ///  file.
        /// </param>
        /// <param name="closer">
        ///  the delegate that will be invoked to close the stream. This may
        ///  be null (Nothing in VB), in which case no call is makde to close
        ///  the stream.
        /// </param>
        /// <returns>the ZipEntry added</returns>
        ///
        public ZipEntry AddEntry(string entryName, OpenDelegate opener, CloseDelegate closer)
        {
            ZipEntry ze = ZipEntry.CreateForJitStreamProvider(entryName, opener, closer);

            ze.SetEntryTimes(DateTime.Now, DateTime.Now, DateTime.Now);
            if (Verbose)
            {
                StatusMessageTextWriter.WriteLine("adding {0}...", entryName);
            }
            return(_InternalAddEntry(ze));
        }
예제 #20
0
 static CallbackHandler()
 {
     readCallback    = new ReadDelegate(read);
     writeCallback   = new WriteDelegate(write);
     skipCallback    = new SkipDelegate(skip);
     seekCallback    = new SeekDelegate(seek);
     tellCallback    = new TellDelegate(tell);
     eofCallback     = new EofDelegate(eof);
     closeCallback   = new CloseDelegate(close);
     deletedCallback = new DeletedDelegate(deleted);
 }
예제 #21
0
 private void CloseForm()
 {
     if (InvokeRequired)
     {
         CloseDelegate cb = new CloseDelegate(CloseForm);
         Invoke(cb);
     }
     else
     {
         Close();
     }
 }
예제 #22
0
		/// <summary>
		/// Закрывает окно
		/// </summary>
		internal new void Close()
		{
			if (!this.InvokeRequired)
			{
				base.Close();
			}
			else
			{
				CloseDelegate del = new CloseDelegate(Close);
				this.Invoke(del);
			}
		}
예제 #23
0
 public void CloseApplication()
 {
     this.closeThread = true;
     if (this.InvokeRequired)
     {
         CloseDelegate close = new CloseDelegate(CloseApplication);
         this.Invoke(close, null);
     }
     else
     {
         this.Close();
     }
 }
예제 #24
0
파일: FormClientIdle.cs 프로젝트: Slion/CIC
 /// <summary>
 ///
 /// </summary>
 public void CloseThreadSafe()
 {
     if (this.InvokeRequired)
     {
         //Not in the proper thread, invoke ourselves
         CloseDelegate d = new CloseDelegate(CloseThreadSafe);
         this.Invoke(d, new object[] { });
     }
     else
     {
         //We are in the proper thread
         Close();
     }
 }
예제 #25
0
        /// <summary>
        /// 闭包延长外部变量count的声明周期
        /// </summary>
        /// <returns></returns>
        private static CloseDelegate CreatCloseDelegate()
        {
            //外部变量
            int count = 1;
            //匿名方法实例化委托对象
            CloseDelegate cd = delegate
            {
                Console.WriteLine(count);
                count++;
            };

            //调用委托
            cd();
            return(cd);
        }
예제 #26
0
 internal static void Bind()
 {
     _createDelegate        = Library.GetProcAddress <CreateDelegate>("mdbx_env_create") as CreateDelegate;
     _closeDelegate         = Library.GetProcAddress <CloseDelegate>("mdbx_env_close") as CloseDelegate;
     _closeExDelegate       = Library.GetProcAddress <CloseExDelegate>("mdbx_env_close_ex") as CloseExDelegate;
     _openDelegate          = Library.GetProcAddress <OpenDelegate>("mdbx_env_open") as OpenDelegate;
     _statDelegate          = Library.GetProcAddress <StatDelegate>("mdbx_env_stat") as StatDelegate;
     _infoDelegate          = Library.GetProcAddress <InfoDelegate>("mdbx_env_info") as InfoDelegate;
     _syncDelegate          = Library.GetProcAddress <SyncDelegate>("mdbx_env_sync") as SyncDelegate;
     _setMaxDbsDelegate     = Library.GetProcAddress <SetMaxDbsDelegate>("mdbx_env_set_maxdbs") as SetMaxDbsDelegate;
     _setFlagsDelegate      = Library.GetProcAddress <SetFlagsDelegate>("mdbx_env_set_flags") as SetFlagsDelegate;
     _getFlagsDelegate      = Library.GetProcAddress <GetFlagsDelegate>("mdbx_env_get_flags") as GetFlagsDelegate;
     _setMapSizeDelegate    = Library.GetProcAddress <SetMapSizeDelegate>("mdbx_env_set_mapsize") as SetMapSizeDelegate;
     _setMaxReadersDelegate = Library.GetProcAddress <SetMaxReadersDelegate>("mdbx_env_set_maxreaders") as SetMaxReadersDelegate;
     _getMaxReadersDelegate = Library.GetProcAddress <GetMaxReadersDelegate>("mdbx_env_get_maxreaders") as GetMaxReadersDelegate;
     _getMaxKeySizeDelegate = Library.GetProcAddress <GetMaxKeySizeDelegate>("mdbx_env_get_maxkeysize") as GetMaxKeySizeDelegate;
 }
예제 #27
0
 public static void CloseSplash()
 {
     if (BaseSettings.DoNotShowSplash)
     {
         return;
     }
     if (m_Splash == null)
     {
         return;
     }
     lock (m_SyncObject)
     {
         Splash s = Instance;
         m_Splash = null;
         CloseDelegate closeDelegate = s.Close;
         s.BeginInvoke(closeDelegate);
         //s.Dispose()
     }
     Application.DoEvents();
 }
예제 #28
0
 public static void HideSplash()
 {
     if (BaseSettings.DoNotShowSplash)
     {
         return;
     }
     if (m_Splash == null)
     {
         return;
     }
     if (m_Splash.InvokeRequired)
     {
         CloseDelegate hideMethod = m_Splash.HideSplashHandle;
         m_Splash.Invoke(hideMethod);
     }
     else
     {
         m_Splash.HideSplashHandle();
     }
 }
예제 #29
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="hliForm">The HLIForm instance that uses this internal form.</param>
        public HliInternalForm(HliForm hliForm)
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            this.hliForm = hliForm;

            // Create the handlers used by other threads in an Invoke call.
            this.closeHandler             = new CloseDelegate(HandleClose);
            this.showAndContinueHandler   = new ShowAndContinueDelegate(HandleShowAndContinue);
            this.setStopButtonTextHandler = new SetStopButtonTextDelegate(HandleSetStopButtonText);
            this.setTextHandler           = new SetTextDelegate(HandleSetText);

            lock (hliForm.LockObject)
            {
                this.isAvailable = true;
            }
        }
예제 #30
0
        private void InitInstance()
        {
            _feederInstance = _nativeCreateCall();
            if (_feederInstance == IntPtr.Zero)
            {
                throw new Exception($"[{_settings.Name}]: DsCreate failed.");
            }

            //var feedVersion = _nativeVersionCall();

            var dst = IntPtr.Zero;

            RtlMoveMemory(ref dst, _feederInstance, IntPtr.Size);
            var cfeedInterfaceVtbl = Marshal.PtrToStructure <CFeedInterfaceVtbl>(dst);

            _connectCall    = Marshal.GetDelegateForFunctionPointer <ConnectDelegate>(cfeedInterfaceVtbl.Connect);
            _closeCall      = Marshal.GetDelegateForFunctionPointer <CloseDelegate>(cfeedInterfaceVtbl.Close);
            _setSymbolsCall = Marshal.GetDelegateForFunctionPointer <SetSymbolsDelegate>
                                  (cfeedInterfaceVtbl.SetSymbols);
            _readCall = Marshal.GetDelegateForFunctionPointer <ReadDelegate>(cfeedInterfaceVtbl.Read);
        }
        public FullscreenView(object item, CloseDelegate OnClose)
        {
            InitializeComponent();

            theItem = item;

            this.CommandBindings.Add(new CommandBinding(Commands.CmdFullscreenClose, CmdFullscreenCloseExecuted, CmdFullscreenCloseCanExecute));

            // Close with double-click
            MouseBinding doubleclick = new MouseBinding(Commands.CmdFullscreenClose, new MouseGesture(MouseAction.LeftDoubleClick));

            doubleclick.CommandTarget = this;
            InputBindings.Add(doubleclick);
            previewFullScreen.InputBindings.Add(doubleclick);
            previewFullScreen.imagePreview.InputBindings.Add(doubleclick);

            // Close with Escape... want to close on any key really, so might as well use the old-fashioned keydown event
            InputBindings.Add(new KeyBinding(Commands.CmdFullscreenClose, new KeyGesture(Key.Escape)));

            // Handler for closing
            this.OnClose = OnClose;
        }
예제 #32
0
파일: TWAIN.cs 프로젝트: mrsalustiano/VS_C
 /// <summary>
 /// Let the caller override our delegates with their own functions...
 /// </summary>
 /// <param name="a_closedelegate">use this to close the logging session</param>
 /// <param name="a_getleveldelegate">get the current log level</param>
 /// <param name="a_opendelegate">open the logging session</param>
 /// <param name="a_registertwaindelegate">not needed at this time</param>
 /// <param name="a_setflushdelegate">turn flushing on and off</param>
 /// <param name="a_setleveldelegate">set the new log level</param>
 /// <param name="a_writeentrydelegate">the function that actually writes to the log</param>
 /// <param name="a_getstatedelegate">returns a way to get the current TWAIN state</param>
 public static void Override
 (
     CloseDelegate a_closedelegate,
     GetLevelDelegate a_getleveldelegate,
     OpenDelegate a_opendelegate,
     RegisterTwainDelegate a_registertwaindelegate,
     SetFlushDelegate a_setflushdelegate,
     SetLevelDelegate a_setleveldelegate,
     WriteEntryDelegate a_writeentrydelegate,
     out GetStateDelegate a_getstatedelegate
 )
 {
     Close = (a_closedelegate != null) ? a_closedelegate : CloseLocal;
     GetLevel = (a_getleveldelegate != null) ? a_getleveldelegate : GetLevelLocal;
     Open = (a_opendelegate != null) ? a_opendelegate : OpenLocal;
     RegisterTwain = (a_registertwaindelegate != null) ? a_registertwaindelegate : RegisterTwainLocal;
     SetFlush = (a_setflushdelegate != null) ? a_setflushdelegate : SetFlushLocal;
     SetLevel = (a_setleveldelegate != null) ? a_setleveldelegate : SetLevelLocal;
     WriteEntry = (a_writeentrydelegate != null) ? a_writeentrydelegate : WriteEntryLocal;
     a_getstatedelegate = GetStateLocal;
 }
예제 #33
0
파일: FormUartHost.cs 프로젝트: sv99/DVSDK
 // invoke version; can be called safely from another thread
 private void UTIL_close_boot_INVOKE()
 {
     CloseDelegate temp_delegate = new CloseDelegate(UTIL_close_boot);
     this.Invoke(temp_delegate, new object[] { });
 }
 public void AsyncClose()
 {
     // InvokeRequired required compares the thread ID of the
     // calling thread to the thread ID of the creating thread.
     // If these threads are different, it returns true.
     if (this.InvokeRequired)
     {
         CloseDelegate d = new CloseDelegate(AsyncClose);
         this.Invoke(d);
     }
     else
     {
         this.Close();
     }
 }
 /// <summary>
 ///   Updates the given entry in the <c>ZipFile</c>, using the given delegates
 ///   to open and close the stream that provides the content for the <c>ZipEntry</c>.
 /// </summary>
 ///
 /// <remarks>
 ///   Calling this method is equivalent to removing the <c>ZipEntry</c> for the
 ///   given file name and directory path, if it exists, and then calling <see
 ///   cref="AddEntry(String,OpenDelegate, CloseDelegate)" />.  See the
 ///   documentation for that method for further explanation.
 /// </remarks>
 ///
 /// <param name="entryName">
 ///   The name, including any path, to use within the archive for the entry.
 /// </param>
 ///
 /// <param name="opener">
 ///  the delegate that will be invoked to open the stream
 /// </param>
 /// <param name="closer">
 ///  the delegate that will be invoked to close the stream
 /// </param>
 ///
 /// <returns>The <c>ZipEntry</c> added or updated.</returns>
 ///
 public ZipEntry UpdateEntry(string entryName, OpenDelegate opener, CloseDelegate closer)
 {
     RemoveEntryForUpdate(entryName);
     return AddEntry(entryName, opener, closer);
 }
 /// <summary>
 ///   Add an entry, for which the application will provide a stream,
 ///   just-in-time.
 /// </summary>
 ///
 /// <remarks>
 /// <para>
 ///   In cases where the application wishes to open the stream that holds
 ///   the content for the ZipEntry, on a just-in-time basis, the application
 ///   can use this method and provide delegates to open and close the
 ///   stream.
 /// </para>
 ///
 /// <para>
 ///   For <c>ZipFile</c> properties including <see cref="Encryption"/>, <see
 ///   cref="Password"/>, <see cref="SetCompression"/>, <see
 ///   cref="ProvisionalAlternateEncoding"/>, <see cref="ExtractExistingFile"/>,
 ///   <see cref="ZipErrorAction"/>, and <see cref="CompressionLevel"/>, their
 ///   respective values at the time of this call will be applied to the
 ///   <c>ZipEntry</c> added.
 /// </para>
 ///
 /// </remarks>
 ///
 /// <example>
 ///
 ///   This example uses anonymous methods in C# to open and close the
 ///   source stream for the content for a zip entry.  In a real
 ///   application, the logic for the OpenDelegate would probably be more
 ///   involved.
 ///
 /// <code lang="C#">
 /// using(Ionic.Zip.ZipFile zip = new Ionic.Zip.ZipFile())
 /// {
 ///     zip.AddEntry(zipEntryName,
 ///                  (name) =>  File.Open(filename, FileMode.Open, FileAccess.Read, FileShare.ReadWrite ),
 ///                  (name, stream) =>  stream.Close()
 ///                  );
 ///
 ///     zip.Save(zipFileName);
 /// }
 /// </code>
 ///
 /// </example>
 ///
 /// <example>
 ///
 ///   This example uses delegates in VB.NET to open and close the
 ///   the source stream for the content for a zip entry.  VB 9.0 lacks
 ///   support for "Sub" lambda expressions, and so the CloseDelegate must
 ///   be an actual, named Sub.
 ///
 /// <code lang="VB">
 ///
 /// Function MyStreamOpener(ByVal entryName As String) As Stream
 ///     '' This simply opens a file.  You probably want to do somethinig
 ///     '' more involved here: open a stream to read from a database,
 ///     '' open a stream on an HTTP connection, and so on.
 ///     Return File.OpenRead(entryName)
 /// End Function
 ///
 /// Sub MyStreamCloser(entryName As String, stream As Stream)
 ///     stream.Close()
 /// End Sub
 ///
 /// Public Sub Run()
 ///     Dim dirToZip As String = "fodder"
 ///     Dim zipFileToCreate As String = "Archive.zip"
 ///     Dim opener As OpenDelegate = AddressOf MyStreamOpener
 ///     Dim closer As CloseDelegate = AddressOf MyStreamCloser
 ///     Dim numFilestoAdd As Int32 = 4
 ///     Using zip As ZipFile = New ZipFile
 ///         Dim i As Integer
 ///         For i = 0 To numFilesToAdd - 1
 ///             zip.AddEntry(String.Format("content-{0:000}.txt"), opener, closer)
 ///         Next i
 ///         zip.Save(zipFileToCreate)
 ///     End Using
 /// End Sub
 ///
 /// </code>
 /// </example>
 ///
 /// <param name="entryName">the name of the entry to add</param>
 /// <param name="opener">
 ///  the delegate that will be invoked to open the stream
 /// </param>
 /// <param name="closer">
 ///  the delegate that will be invoked to close the stream
 /// </param>
 /// <returns>the ZipEntry added</returns>
 ///
 public ZipEntry AddEntry(string entryName, OpenDelegate opener, CloseDelegate closer)
 {
     ZipEntry ze = ZipEntry.CreateForJitStreamProvider(entryName, opener, closer);
     ze.SetEntryTimes(DateTime.Now,DateTime.Now,DateTime.Now);
     if (Verbose) StatusMessageTextWriter.WriteLine("adding {0}...", entryName);
     return _InternalAddEntry(ze);
 }
예제 #37
0
 protected void Page_Load(object sender, EventArgs e)
 {
     RegisterResource();
     BuildToolBar();
     if(Edit != null)
        Edit += new EditDelegate(DoEdit);
     if(Minimize != null)
        Minimize += new MinimizeDelegate(DoMinimize);
     if(Maximize != null)
        Maximize += new MaximizeDelegate(DoMaximize);
     if(Load != null)
        Load += new LoadDelegate(DoLoad);
     if(Create != null)
        Create += new CreateDelegate(DoCreate);
     if(Close != null)
        Close += new CloseDelegate(DoClose);
 }
예제 #38
0
 protected override void Page_Load(object sender, System.EventArgs e)
 {
     base.Page_Load(sender, e);
     RegisterResource();
     BuildToolBar();
     Edit += new EditDelegate(DoEdit);
     Minimize += new MinimizeDelegate(DoMinimize);
     Maximize += new MaximizeDelegate(DoMaximize);
     Load += new LoadDelegate(DoLoad);
     Create += new CreateDelegate(DoCreate);
     Close += new CloseDelegate(DoClose);
 }
예제 #39
0
 public void ImportFormClose()
 {
     CloseDelegate method = new CloseDelegate(this.ImportCloseDelegate);
     base.Invoke(method);
 }
예제 #40
0
 public ExtractProgressWindow()
 {
     InitializeComponent();
     rui = new RefrenshUIDelegate(RefrenshUI);
     closeWindow = new CloseDelegate(CloseWindow);
 }
 internal static ZipEntry CreateForJitStreamProvider(string nameInArchive, OpenDelegate opener, CloseDelegate closer)
 {
     return Create(nameInArchive, ZipEntrySource.JitStream, opener, closer);
 }
예제 #42
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="hliForm">The HLIForm instance that uses this internal form.</param>
        public HliInternalForm(HliForm hliForm)
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            this.hliForm = hliForm;

            // Create the handlers used by other threads in an Invoke call.
            this.closeHandler = new CloseDelegate(HandleClose);
            this.showAndContinueHandler = new ShowAndContinueDelegate(HandleShowAndContinue);
            this.setStopButtonTextHandler = new SetStopButtonTextDelegate(HandleSetStopButtonText);
            this.setTextHandler = new SetTextDelegate(HandleSetText);

            lock(hliForm.LockObject)
            {
                this.isAvailable = true;
            }
        }