public PersistentInterest(AsyncRef asyncRef)
 {
     interestList = new InterestList();
     interestList.Add(asyncRef);
     interestList.Activate();
     asyncRef.AddCallback(AsyncCompleteCallback);
 }
        private void HandleUpdate()
        {
            if (!needUpdate)
            {
                return;
            }

            needUpdate = false;
            Monitor.Enter(this);
            try
            {
                if (previewInterest != null)
                {
                    previewInterest.Dispose();
                    previewInterest = null;
                    waitingForCI    = null;
                }

                if (_legend != null)
                {
                    try
                    {
                        IFuture renderedLegendFuture =
                            _legend.GetRenderedLegendFuture(displayableSource, (FutureFeatures)5);
                        if (previewFuture != renderedLegendFuture)
                        {
                            previewFuture = renderedLegendFuture;
                            AsyncRef asyncRef =
                                (AsyncRef)renderedLegendFuture.Realize("LegendOptionsPanel.UpdatePreviewPanel");
                            if (asyncRef.present == null)
                            {
                                waitingForCI = new CallbackIgnorinator(this);
                                asyncRef.AddCallback(waitingForCI.Callback);
                                asyncRef.SetInterest(524296);
                                previewInterest = new InterestList();
                                previewInterest.Add(asyncRef);
                                previewInterest.Activate();
                                UpdatePreviewImage(null);
                            }
                            else
                            {
                                if (asyncRef.present is ImageRef)
                                {
                                    UpdatePreviewImage((ImageRef)asyncRef.present);
                                }
                            }
                        }
                    }
                    catch (Legend.RenderFailedException)
                    {
                    }
                }
            }
            finally
            {
                Monitor.Exit(this);
            }
        }
Exemple #3
0
        private void PaintGraphics(PaintSpecification e, LatLonZoom llz)
        {
            tilesRequired  = 0;
            tilesAvailable = 0;
            asyncRequestGeneration++;
            if (baseLayer == null)
            {
                return;
            }

            InterestList interestList = activeTiles;

            activeTiles = new InterestList();
            e.ResetClip();
            e.Graphics.FillRectangle(new SolidBrush(Color.LightPink), new Rectangle(new Point(0, 0), e.Size));
            List <PaintKit> list = new List <PaintKit>();

            list.AddRange(AssembleLayer(e, llz, baseLayer, 0));
            int num = 1;

            foreach (IDisplayableSource current in alphaLayers)
            {
                list.AddRange(AssembleLayer(e, llz, current, num));
                num++;
            }

            activeTiles.Activate();
            PaintKits(e.Graphics, list);
            e.ResetClip();
            if (userRegionViewController != null)
            {
                e.ResetClip();
                userRegionViewController.Paint(e, llz, Size);
            }

            if (MapDrawingOption.IsEnabled(ShowCrosshairs))
            {
                Pen   pen   = new Pen(Color.Yellow);
                Pen[] array = new[] { pen, new Pen(Color.Black)
                                      {
                                          DashStyle = DashStyle.Dash
                                      } };
                for (int i = 0; i < array.Length; i++)
                {
                    Pen pen2 = array[i];
                    e.Graphics.DrawLine(pen2, 0, Size.Height / 2, Size.Width, Size.Height / 2);
                    e.Graphics.DrawLine(pen2, Size.Width / 2, 0, Size.Width / 2, Size.Height);
                }
            }

            if (MapDrawingOption.IsEnabled(ShowPushPins) && pinList != null)
            {
                List <PositionAssociationView> list2 = new List <PositionAssociationView>();
                list2.AddRange(pinList);
                list2.Sort(delegate(PositionAssociationView p0, PositionAssociationView p1)
                {
                    double num2 = p1.position.pinPosition.lat - p0.position.pinPosition.lat;
                    if (num2 != 0.0)
                    {
                        if (num2 <= 0.0)
                        {
                            return(-1);
                        }

                        return(1);
                    }
                    else
                    {
                        double num3 = p1.position.pinPosition.lon - p0.position.pinPosition.lon;
                        if (num3 == 0.0)
                        {
                            return(0);
                        }

                        if (num3 <= 0.0)
                        {
                            return(-1);
                        }

                        return(1);
                    }
                });
                foreach (PositionAssociationView current2 in list2)
                {
                    DrawMarker(current2, e);
                }
            }

            if (interestList != null)
            {
                interestList.Dispose();
            }

            if (tilesRequired == 0 || tilesAvailable == tilesRequired)
            {
                displayProgressBar.Visible = false;
                return;
            }

            displayProgressBar.Visible = true;
            displayProgressBar.Minimum = 0;
            displayProgressBar.Maximum = tilesRequired;
            displayProgressBar.Value   = tilesAvailable;
        }