Example #1
0
        protected virtual void MainThreadAction(object backgroundProcessingResult)
        {
            if (!IsDisposed)
            {
                var result = backgroundProcessingResult as OutlineRegionsChange;

                if (result != null && TextRange.IsValid(result.ChangedRange))
                {
                    lock (_regionsLock) {
                        CurrentRegions = result.NewRegions;
                    }

                    RegionsChanged?.Invoke(this,
                                           new OutlineRegionsChangedEventArgs(CurrentRegions.Clone() as OutlineRegionCollection,
                                                                              result.ChangedRange)
                                           );
                }
            }
        }
Example #2
0
        public void OnDraggableRegionsChanged(IWebBrowser browserControl, IBrowser browser, IList <DraggableRegion> regions)
        {
            if (!Enable)
            {
                return;
            }

            if (browser.IsPopup == false)
            {
                draggableRegion = null;
                if (regions != null && regions.Count > 0)
                {
                    foreach (var region in regions)
                    {
                        // Console.WriteLine(region.X + " - " + region.Y + " - " + region.Width + " - " + region.Height);
                        var rect = new Rectangle(region.X, region.Y, region.Width, region.Height);

                        if (draggableRegion == null)
                        {
                            draggableRegion = new Region(rect);
                        }
                        else
                        {
                            if (region.Draggable)
                            {
                                draggableRegion.Union(rect);
                            }
                            else
                            {
                                //In the scenario where we have an outer region, that is draggable and it has
                                // an inner region that's not, we must exclude the non draggable.
                                // Not all scenarios are covered in this example.
                                draggableRegion.Exclude(rect);
                            }
                        }
                    }
                }

                RegionsChanged?.Invoke(draggableRegion);
            }
        }
Example #3
0
        /// <summary>
        /// Called whenever the regions marked with the css style "-webkit-app-region: drag/no-drag;" moved (after load and scroll for example)
        /// </summary>
        /// <param name="chromiumWebBrowser"></param>
        /// <param name="browser"></param>
        /// <param name="frame"></param>
        /// <param name="regions"></param>
        public void OnDraggableRegionsChanged(IWebBrowser chromiumWebBrowser, IBrowser browser, IFrame frame, IList <DraggableRegion> regions)
        {
            // update the draggeable region
            draggableRegion = null;
            if (regions != null && regions.Count > 0)
            {
                foreach (var region in regions)
                {
                    Logger.Log("Draggable region found: " + region.X + " - " + region.Y + " - " + region.Width + " - " + region.Height, Logger.LogLevel.debug);

                    var rect = new Rectangle(region.X, region.Y, region.Width, region.Height);

                    if (draggableRegion == null)
                    {
                        draggableRegion = new Region(rect);
                    }
                    else
                    {
                        if (region.Draggable)
                        {
                            draggableRegion.Union(rect);
                        }
                        else
                        {
                            // In the scenario where we have an outer region, that is draggable and it has
                            // an inner region that's not, we must exclude the non draggable.
                            // Not all scenarios are covered in this example.
                            draggableRegion.Exclude(rect);
                        }
                    }
                }
            }

            // inform about change
            if (RegionsChanged != null)
            {
                RegionsChanged.Invoke(draggableRegion);
            }
        }