当前位置: 首页>>代码示例>>C#>>正文


C# Control.Invalidate方法代码示例

本文整理汇总了C#中Control.Invalidate方法的典型用法代码示例。如果您正苦于以下问题:C# Control.Invalidate方法的具体用法?C# Control.Invalidate怎么用?C# Control.Invalidate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Control的用法示例。


在下文中一共展示了Control.Invalidate方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: runWindows

        private static void runWindows(Control mainControl) {
            ConsoleAdapter canvas = new ConsoleAdapter( 80, 25 );
            canvas.Initialize(  );
            
            Renderer renderer = ConsoleApplication.Instance.Renderer;
            renderer.Canvas = canvas;
            // Fill the canvas by default
            renderer.RootElementRect = new Rect( new Point( 0, 0 ), canvas.Size );
            renderer.RootElement = mainControl;
            ConsoleApplication.Instance.RootControl = mainControl;
            //
            mainControl.Invalidate();
            renderer.UpdateLayout();
            renderer.FinallyApplyChangesToCanvas();

            Console.WriteLine("Applied to canvas");
            EventManager eventManager = ConsoleApplication.Instance.EventManager;

            canvas.UserInputReceived += ( sender, args ) => {
//                mainControl.Invalidate();
//                renderer.UpdateLayout();
//                renderer.FinallyApplyChangesToCanvas();
                eventManager.ParseInputEvent( args.InputRecord, mainControl );

                while (true) {
                    //bool anyInvokeActions = isAnyInvokeActions();
                    bool anyRoutedEvent = !eventManager.IsQueueEmpty();
                    bool anyLayoutToRevalidate = renderer.AnyControlInvalidated;

                    if (/*!anyInvokeActions &&*/ !anyRoutedEvent && !anyLayoutToRevalidate)
                        break;

                    eventManager.ProcessEvents();
                    //processInvokeActions();
                    renderer.UpdateLayout();
                }
                renderer.FinallyApplyChangesToCanvas();
            };
        }
开发者ID:furesoft,项目名称:consoleframework,代码行数:39,代码来源:Program.cs

示例2: SetPressedControl

 private void SetPressedControl(Control ctl)
 {
     if (ctl == null)
     {
         Control prevCtrl = mvarPressedControl;
         mvarPressedControl = null;
         if (prevCtrl != null) prevCtrl.Invalidate();
     }
     else
     {
         bool changed = (mvarPressedControl != ctl);
         mvarPressedControl = ctl;
         if (changed) mvarPressedControl.Invalidate();
     }
 }
开发者ID:alcexhim,项目名称:UniversalWidgetToolkit,代码行数:15,代码来源:Win32Engine.cs

示例3: runWindows

        private void runWindows(Control control)
        {
            this.mainControl = control;
            //
            stdInputHandle = Win32.GetStdHandle(StdHandleType.STD_INPUT_HANDLE);
            stdOutputHandle = Win32.GetStdHandle(StdHandleType.STD_OUTPUT_HANDLE);
            IntPtr[] handles = new[] {
                exitWaitHandle.SafeWaitHandle.DangerousGetHandle(),
                stdInputHandle,
                invokeWaitHandle.SafeWaitHandle.DangerousGetHandle(  )
            };

            // Set console mode to enable mouse and window resizing events
            const uint ENABLE_WINDOW_INPUT = 0x0008;
            const uint ENABLE_MOUSE_INPUT = 0x0010;
            uint consoleMode;
            Win32.GetConsoleMode( stdInputHandle, out consoleMode );
            Win32.SetConsoleMode(stdInputHandle, consoleMode | ENABLE_MOUSE_INPUT | ENABLE_WINDOW_INPUT);

            // Get console screen buffer size
            CONSOLE_SCREEN_BUFFER_INFO screenBufferInfo;
            Win32.GetConsoleScreenBufferInfo( stdOutputHandle, out screenBufferInfo );

            // Set Canvas size to current console window size (not to whole buffer size)
            savedWindowRect = new Rect( new Point( Console.WindowLeft, Console.WindowTop ),
                                        new Size( Console.WindowWidth, Console.WindowHeight ) );
            CanvasSize = new Size(savedWindowRect.Width, savedWindowRect.Height);

            canvas = userCanvasSize.IsEmpty
                ? new PhysicalCanvas( screenBufferInfo.dwSize.X, screenBufferInfo.dwSize.Y, stdOutputHandle )
                : new PhysicalCanvas( userCanvasSize.Width, userCanvasSize.Height, stdOutputHandle);
            renderer.Canvas = canvas;

            // Fill the canvas by default
            renderer.RootElementRect = userRootElementRect.IsEmpty
                ? new Rect( new Point(0, 0), canvas.Size ) : userRootElementRect;
            renderer.RootElement = mainControl;
            //
            mainControl.Invalidate();
            renderer.UpdateLayout();
            renderer.FinallyApplyChangesToCanvas(  );

            // Initially hide the console cursor
            HideCursor();

            this.running = true;
            this.mainThreadId = Thread.CurrentThread.ManagedThreadId;
            //
            while (true) {
                // 100 ms instead of Win32.INFINITE to check console window Zoomed and Iconic
                // state periodically (because if user presses Maximize/Restore button
                // there are no input event generated).
                uint waitResult = Win32.WaitForMultipleObjects(3, handles, false, 100);
                if (waitResult == 0) {
                    break;
                }
                if (waitResult == 1) {
                    processInput();
                }
                if ( waitResult == 2 ) {
                    // Do nothing special - because invokeActions will be invoked in loop anyway
                }

                // If we received WAIT_TIMEOUT - check window Zoomed and Iconic state
                // and correct buffer size and console window size
                if ( waitResult == 0x00000102 ) {
                    IntPtr consoleWindow = getConsoleWindowHwnd( );
                    bool isZoomed = Win32.IsZoomed(consoleWindow);
                    bool isIconic = Win32.IsIconic(consoleWindow);
                    if (maximized != isZoomed && !isIconic) {
                        if (isZoomed)
                            Maximize();
                        else
                            Restore();
                    }
                    if ( !maximized ) {
                        savedWindowRect = new Rect( new Point( Console.WindowLeft, Console.WindowTop ),
                                                    new Size( Console.WindowWidth, Console.WindowHeight ) );
                    }
                }
                // WAIT_FAILED
                if ( waitResult == 0xFFFFFFFF) {
                    throw new InvalidOperationException("Invalid wait result of WaitForMultipleObjects.");
                }

                while ( true ) {
                    bool anyInvokeActions = isAnyInvokeActions( );
                    bool anyRoutedEvent = !EventManager.IsQueueEmpty( );
                    bool anyLayoutToRevalidate = renderer.AnyControlInvalidated;

                    if (!anyInvokeActions && !anyRoutedEvent && !anyLayoutToRevalidate)
                        break;

                    EventManager.ProcessEvents();
                    processInvokeActions(  );
                    renderer.UpdateLayout(  );
                }

                renderer.FinallyApplyChangesToCanvas( );
            }
//.........这里部分代码省略.........
开发者ID:KSLcom,项目名称:consoleframework,代码行数:101,代码来源:ConsoleApplication.cs

示例4: runLinux

        private void runLinux(Control control)
        {
            this.mainControl = control;

            if ( userCanvasSize.IsEmpty ) {
                // Create physical canvas with actual terminal size
                winsize ws = Libc.GetTerminalSize( isDarwin );
                canvas = new PhysicalCanvas( ws.ws_col, ws.ws_row );
            } else {
                canvas = new PhysicalCanvas( userCanvasSize.Width, userCanvasSize.Height );
            }
            renderer.Canvas = canvas;
            renderer.RootElementRect = userRootElementRect.IsEmpty
                ? new Rect( canvas.Size ) : userRootElementRect;
            renderer.RootElement = mainControl;
            //
            mainControl.Invalidate ();

            // Terminal initialization sequence

            // This is magic workaround to avoid messing up terminal after program finish
            // The bug is described at https://bugzilla.xamarin.com/show_bug.cgi?id=15118
            bool ignored = Console.KeyAvailable;

            IntPtr stdscr = NCurses.initscr ();
            NCurses.cbreak ();
            NCurses.noecho ();
            NCurses.nonl ();
            NCurses.intrflush (stdscr, false);
            NCurses.keypad (stdscr, true);
            NCurses.start_color ();

            HideCursor ();
            try {
                renderer.UpdateLayout( );
                renderer.FinallyApplyChangesToCanvas(  );

                termkeyHandle = LibTermKey.termkey_new( 0, TermKeyFlag.TERMKEY_FLAG_SPACESYMBOL );

                // Setup the input mode
                Console.Write( "\x1B[?1002h" );
                pollfd fd = new pollfd( );
                fd.fd = 0;
                fd.events = POLL_EVENTS.POLLIN;

                pollfd[ ] fds = new pollfd[ 2 ];
                fds[ 0 ] = fd;
                fds[ 1 ] = new pollfd( );
                int pipeResult = Libc.pipe( pipeFds );
                if ( pipeResult == -1 ) {
                    throw new InvalidOperationException( "Cannot create self-pipe." );
                }
                fds[ 1 ].fd = pipeFds[ 0 ];
                fds[ 1 ].events = POLL_EVENTS.POLLIN;

                try {
            #if !WIN32
                    // Catch SIGWINCH to handle terminal resizing
                    UnixSignal[] signals = new UnixSignal [] {
                        new UnixSignal (Signum.SIGWINCH)
                    };
                    Thread signal_thread = new Thread (delegate () {
                        while (true) {
                            // Wait for a signal to be delivered
                            int index = UnixSignal.WaitAny (signals, -1);
                            Signum signal = signals [index].Signum;
                            Libc.writeInt64 (pipeFds[1], 2);
                        }
                    }
                    );
                    signal_thread.IsBackground = false;
                    signal_thread.Start ();
            #endif
                    TermKeyKey key = new TermKeyKey( );
                    //
                    this.running = true;
                    this.mainThreadId = Thread.CurrentThread.ManagedThreadId;
                    //
                    int nextwait = -1;
                    while ( true ) {
                        int pollRes = Libc.poll( fds, 2, nextwait );
                        if ( pollRes == 0 ) {
                            if (nextwait == -1)
                                throw new InvalidOperationException( "Assertion failed." );
                            if (TermKeyResult.TERMKEY_RES_KEY == LibTermKey.termkey_getkey_force(termkeyHandle, ref key) ) {
                                processLinuxInput( key );
                            }
                        }
                        if ( pollRes == -1 ) {
                            int errorCode = Marshal.GetLastWin32Error();
                            if ( errorCode != Libc.EINTR ) {
                                throw new InvalidOperationException(string.Format("poll() returned with error code {0}", errorCode));
                            }
                        }

                        if ( fds[ 1 ].revents != POLL_EVENTS.NONE ) {
                            UInt64 u;
                            Libc.readInt64( fds[ 1 ].fd, out u );
                            if ( u == 1 ) {
                                // Exit from application
//.........这里部分代码省略.........
开发者ID:KSLcom,项目名称:consoleframework,代码行数:101,代码来源:ConsoleApplication.cs


注:本文中的Control.Invalidate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。