/// <summary>
        /// Skip either literals or prompt fields, depending on the SkipMode.
        /// Return the stop position, which is 0 to n - 1 characters,
        /// where n is the position of the stop character.
        /// </summary>
        protected int Skip(int pos, SkipMode mode)
        {
            int n   = pos;
            int len = 0;

            if (mode == SkipMode.Literal)
            {
                // Skip literals.
                while ((n < posToMaskIndex.Length) && (posToMaskIndex[n] < 0))
                {
                    ++len;
                    ++n;
                }
            }
            else
            {
                // Skip non-literals (input fields).
                while ((n < posToMaskIndex.Length) && (posToMaskIndex[n] >= 0))
                {
                    ++len;
                    ++n;
                }
            }

            return(pos + len);
        }
Exemplo n.º 2
0
        public void Process(SkipMode mode)
        {
            switch (mode)
            {
            case SkipMode.Skip:
                _mainReader.Skip();
                break;

            case SkipMode.ReadSubtree_discard:
                DiscardSubtree(_mainReader.ReadSubtree());
                break;

            case SkipMode.ReadSubtree_build:
                BuildSubtree(_mainReader.ReadSubtree(), _mainWriter);
                break;
            }
        }
Exemplo n.º 3
0
        private object DoStuffWithSkipper(SkipMode skipMode)
        {
            if (_removeType == null || _removeProperty == null)
            {
                throw new Exception("remove something is null");
            }

            bool more = _mainReader.Read();

            while (more)
            {
                bool skipped = false;
                switch (_mainReader.NodeType)
                {
                case XamlNodeType.StartObject:
                    if (_mainReader.Type == _removeType)
                    {
                        Process(skipMode);
                        skipped = true;
                    }
                    break;

                case XamlNodeType.StartMember:
                    if (_mainReader.Member == _removeProperty)
                    {
                        Process(skipMode);
                        skipped = true;
                    }
                    break;
                }
                if (!skipped)
                {
                    _mainWriter.WriteNode(_mainReader);
                    more = _mainReader.Read();
                }
            }

            _mainWriter.Close();
            XamlObjectWriter objectWriter = _mainWriter as XamlObjectWriter;

            return((objectWriter == null) ? null : objectWriter.Result);
        }
Exemplo n.º 4
0
 public void SkipAtSignCheck(SkipMode skipMode)
 {
     SkipAtSignCheck(_profanityFilter, skipMode);
 }
Exemplo n.º 5
0
 private static extern void SkipAtSignCheck(IntPtr profanityFilter, SkipMode skipMode);
Exemplo n.º 6
0
 private void skipButton_Click(object sender, EventArgs e)
 {
     lock (skipMonitor)
     {
         skipMode = SkipMode.NextFrontPage;
         Monitor.Pulse(skipMonitor);
     }
 }
Exemplo n.º 7
0
 private void nextButton_Click(object sender, EventArgs e)
 {
     lock (skipMonitor)
     {
         skipMode = SkipMode.NextArticles;
         Monitor.Pulse(skipMonitor);
     }
 }
Exemplo n.º 8
0
        private void CycleThread(object param)
        {
            try
            {
                do
                {
                    //- - - - - - - - - - - - - - - -
                    // SELECT THE FRONTPAGE TO DISPLAY
                    //- - - - - - - - - - - - - - - -

                    FrontPage currentFrontPage;

                    // select a front page
                    lock (frontPageLock)
                    {
                        currentFrontPage = NextFrontPage();
                    }

                    if (currentFrontPage == null)
                    {
                        continue;
                    }

                    int articlesOffset = 0;

                    Site s = Profile.FindSiteOf(currentFrontPage);
                    string layoutPlugin = s.LayoutPlugin;

                    //- - - - - - - - - - - - - - - -
                    // SELECT THE ARTICLES TO DISPLAY
                    //- - - - - - - - - - - - - - - -

                    do
                    {
                        // obtain desired layout and
                        // start rendering it in the background

                        ILayoutPlugin layoutToPrepare = null;
                        this.Invoke((MethodInvoker)delegate
                        {
                            layoutToPrepare = PluginsManager.GetInstance().GetLayout(layoutPlugin);
                            Preload(layoutToPrepare);
                            layoutToPrepare.FrontPage = currentFrontPage;
                            articlesOffset = layoutToPrepare.SetupArticles(articlesOffset);
                        });

                        // in case no article is available
                        // for display, exit the loop
                        // so that the next frontpage
                        // gets selected

                        if (articlesOffset < 0)
                        {
                            break;
                        }

                        // wait until all articles are ready
                        // to be displayed (with a timeout of 5 seconds).

                        layoutToPrepare.WaitForReady(5000);

                        // put the layout to the front,
                        // and dispose of the previously
                        // visible layout.

                        this.Invoke((MethodInvoker)delegate
                        {
                            ILayoutPlugin toBeDisposedOf = Switch();
                            if (toBeDisposedOf != null)
                            {
                                toBeDisposedOf.Close();
                                toBeDisposedOf.Dispose();
                            }
                        });

                        // Pause the thread for a moment (typically 10 seconds)
                        // and wait for a UI event at the same time. UI events
                        // can be: skip to next articles, skip to next frontpage,
                        // pause the thread for a longer moment, etc...

                        lock (skipMonitor)
                        {
                            // Enable the buttons that let the user
                            // skip the current layout
                            nextButton.Invoke((MethodInvoker)delegate { EnableButtons(true); });

                            int pauseTime_sec = 10;
                            do
                            {
                                if (Monitor.Wait(skipMonitor, 1000) == false)
                                {
                                    // one second passed without the user
                                    // triggering any button on the UI.
                                    switch (skipMode)
                                    {
                                        case SkipMode.Pause: /* do not decrement timer */ break;
                                        default: pauseTime_sec--; break;
                                    }
                                }
                                else
                                {
                                    // the user has pushed a button on the UI...
                                    x
                                    pauseTime_sec = 0;
                                    if (skipMode == SkipMode.NextFrontPage)
                                    {
                                        articlesOffset = -1;
                                        skipMode = SkipMode.NextArticles;
                                    }
                                }
                            } while (pauseTime_sec > 0);

                            // Disable the buttons that let the user
                            // skip the current layout
                            nextButton.Invoke((MethodInvoker)delegate { EnableButtons(false); });
                        }

                    } while (threadRunning && (articlesOffset > 0));

                } while (threadRunning);
            }
            catch (ThreadInterruptedException)
            {
            }
            finally
            {
                threadRunning = false;
            }
        }
Exemplo n.º 9
0
        private void DoResume(ref bool var)
        {
            bool pauseChanged = false;

            lock (skipMonitor)
            {
                bool wasInPause = internalPause || externalPause;
                var = false;
                bool isInPause = internalPause || externalPause;

                if ((wasInPause == true) && (isInPause == false))
                {
                    skipMode = SkipMode.Resume;
                    Monitor.Pulse(skipMonitor);
                    pauseChanged = true;
                }
            }

            if (pauseChanged)
            {
                pauseCheckBox.Invoke((MethodInvoker)delegate { pauseCheckBox.ImageKey = "pause.png"; });
                OnPauseChanged();
            }
        }
Exemplo n.º 10
0
        private void ArticlesRotatorThread(object param)
        {
            try
            {
                do
                {
                    //- - - - - - - - - - - - - - - -
                    // SELECT THE FRONTPAGE TO DISPLAY
                    //- - - - - - - - - - - - - - - -

                    FrontPage currentFrontPage;

                    // select a front page
                    lock (frontPageLock)
                    {
                        currentFrontPage = NextFrontPage();
                    }

                    if (currentFrontPage == null)
                    {
                        continue;
                    }

                    int articlesOffset = 0;

                    Site s = Profile.FindSiteOf(currentFrontPage);
                    string layoutPlugin = s.LayoutPlugin;

                    //- - - - - - - - - - - - - - - -
                    // SELECT THE ARTICLES TO DISPLAY
                    //- - - - - - - - - - - - - - - -

                    do
                    {
                        // obtain desired layout and
                        // start rendering it in the background

                        ILayoutPlugin layoutToPrepare = null;
                        this.Invoke((MethodInvoker)delegate
                        {
                            layoutToPrepare = PluginsManager.GetInstance().GetLayout(layoutPlugin);
                            layoutToPrepare.Controller = this;
                            Preload(layoutToPrepare);
                            layoutToPrepare.FrontPage = currentFrontPage;
                            articlesOffset = layoutToPrepare.SetupArticles(articlesOffset);
                        });

                        // in case no article is available
                        // for display, exit the loop
                        // so that the next frontpage
                        // gets selected

                        if (articlesOffset < 0)
                        {
                            this.Invoke((MethodInvoker)delegate
                            {
                                CancelPreload(layoutToPrepare);
                            });
                            break;
                        }

                        // wait until all articles are ready
                        // to be displayed (with a timeout of 5 seconds).

                        layoutToPrepare.WaitForReady(5000);

                        // put the layout to the front,
                        // and dispose of the previously
                        // visible layout.

                        this.Invoke((MethodInvoker)delegate
                        {
                            ILayoutPlugin toBeDisposedOf = Switch();
                            if (toBeDisposedOf != null)
                            {
                                toBeDisposedOf.Close();
                                toBeDisposedOf.Dispose();
                            }
                        });

                        GC.Collect();

                        // Update stats
                        debugForm.MediaControlCount = MediaControl.DebugCount;
                        debugForm.LayoutCount = Controls.Count;
                        debugForm.RotationCount++;

                        // Pause the thread for a moment (typically 10 seconds)
                        // and wait for a UI event at the same time. UI events
                        // can be: skip to next articles, skip to next frontpage,
                        // pause the thread for a longer moment, etc...

                        lock (skipMonitor)
                        {
                            // Enable the buttons that let the user
                            // skip the current layout
                            nextButton.Invoke((MethodInvoker)delegate { EnableButtons(true); });

                            int pauseTime_sec = ROTATOR_DISPLAY_TIME_SEC;
                            do
                            {
                                if (Monitor.Wait(skipMonitor, 1000) == false)
                                {
                                    // One second elapsed, no UI button triggered:
                                    switch (skipMode)
                                    {
                                        case SkipMode.Pause:
                                            // do not decrease timer
                                            // is Pause mode is activated
                                            Console.Out.WriteLine("Paused");
                                            break;
                                        default:
                                            pauseTime_sec--;
                                            break;
                                    }
                                }
                                else
                                {
                                    // a button has been triggered
                                    // by the user on the UI:

                                    switch (skipMode)
                                    {
                                        case SkipMode.Resume:
                                            // Force a return to standard mode
                                            skipMode = SkipMode.NextArticles;
                                            break;

                                        case SkipMode.NextArticles:
                                            // Exit timer loop immediately
                                            pauseTime_sec = 0;
                                            break;

                                        case SkipMode.NextFrontPage:
                                            // Force a change of frontpage
                                            articlesOffset = -1;
                                            // Force a return to standard mode
                                            skipMode = SkipMode.NextArticles;
                                            // Exit timer loop immediately
                                            pauseTime_sec = 0;
                                            break;
                                    }

                                }
                            } while (pauseTime_sec > 0);

                            // Disable the buttons that let the user
                            // skip the current layout
                            nextButton.Invoke((MethodInvoker)delegate { EnableButtons(false); });
                        }

                    } while (rotatorThreadRunning && (articlesOffset > 0));

                } while (rotatorThreadRunning);
            }
            catch (ThreadInterruptedException)
            {
            }
            finally
            {
                rotatorThreadRunning = false;
            }
        }
Exemplo n.º 11
0
        /// <summary>
        /// Skip either literals or prompt fields, depending on the SkipMode.
        /// Return the stop position, which is 0 to n - 1 characters, 
        /// where n is the position of the stop character.
        /// </summary>
        protected int Skip(int pos, SkipMode mode)
        {
            int n = pos;
            int len = 0;

            if (mode == SkipMode.Literal)
            {
                // Skip literals.
                while ((n < posToMaskIndex.Length) && (posToMaskIndex[n] < 0))
                {
                    ++len;
                    ++n;
                }
            }
            else
            {
                // Skip non-literals (input fields).
                while ((n < posToMaskIndex.Length) && (posToMaskIndex[n] >= 0))
                {
                    ++len;
                    ++n;
                }
            }

            return pos + len;
        }
Exemplo n.º 12
0
 public EmptyTestRoutine(SkipMode mode)
 {
     Mode = mode;
 }