示例#1
0
 private void RendererSanityCheckComplete(AsyncRef asyncRef)
 {
     Monitor.Enter(this);
     try
     {
         if (this.handled)
         {
             return;
         }
         this.handled = true;
     }
     finally
     {
         Monitor.Exit(this);
     }
     if (!(asyncRef.present is ImageRef))
     {
         if (asyncRef.present is RequestCanceledPresent)
         {
             new InsaneSourceMapRemover(this.sourceMap, this.mapTileSourceFactory, this.undoAddSourceMapDelegate, this.tryCount + 1);
             return;
         }
         string message;
         if (asyncRef.present is PresentFailureCode)
         {
             message = ((PresentFailureCode)asyncRef.present).exception.Message;
         }
         else
         {
             message = string.Format("Unexpected result type {0}", asyncRef.present.GetType().ToString());
         }
         this.undoAddSourceMapDelegate(message);
         return;
     }
 }
示例#2
0
 public PersistentInterest(AsyncRef asyncRef)
 {
     interestList = new InterestList();
     interestList.Add(asyncRef);
     interestList.Activate();
     asyncRef.AddCallback(AsyncCompleteCallback);
 }
示例#3
0
 public void AsyncRecordComplete(AsyncRef asyncRef)
 {
     if (this.viewerControl.asyncRequestGeneration == this.generation)
     {
         this.viewerControl.InvalidateView();
     }
 }
示例#4
0
        private InsaneSourceMapRemover(SourceMap sourceMap, MapTileSourceFactory mapTileSourceFactory,
                                       UndoAdddSourceMapDelegate removeSourceMapDelegate, int tryCount)
        {
            this.sourceMap            = sourceMap;
            this.mapTileSourceFactory = mapTileSourceFactory;
            undoAddSourceMapDelegate  = removeSourceMapDelegate;
            this.tryCount             = tryCount;
            if (tryCount > 3)
            {
                return;
            }

            Present present = mapTileSourceFactory.CreateUnwarpedSource(sourceMap)
                              .GetImagePrototype(new ImageParameterFromTileAddress(ContinuousCoordinateSystem.theInstance),
                                                 (FutureFeatures)7)
                              .Curry(new ParamDict(new object[]
            {
                TermName.TileAddress,
                new TileAddress(0, 0, ContinuousCoordinateSystem.theInstance.GetDefaultView().zoom)
            })).Realize("SourceMap.CheckRendererSanity");
            AsyncRef asyncRef = (AsyncRef)present;

            asyncRef.AddCallback(RendererSanityCheckComplete);
            new PersistentInterest(asyncRef);
        }
示例#5
0
        public async Task OnViewLoaded()
        {
            var isLoggedIn = false;

            do
            {
                var loginData = await _dialogCoordinator.ShowNtLogin(this);

                if (loginData == null)
                {
                    // User has cancelled Login, Should exist.
                    Application.Current.Shutdown();
                }

                IsBusy = true;
                var errorMsg = new AsyncRef <string>();
                isLoggedIn = await _currentUserService.Authenticate(loginData.Username, loginData.Password, errorMsg);

                IsBusy = false;
                if (!isLoggedIn)
                {
                    await _dialogCoordinator.ShowNtOkDialog(this, "Authentication Failed", errorMsg);
                }
            } while (!isLoggedIn);

            _eventAggregator.PublishMessage(new UserLoggedInMessage("User has logged in"));
        }
示例#6
0
        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);
            }
        }
示例#7
0
 public void RequestRenderRegion(IFuture asynchronousImageBoundsFuture)
 {
     if (this.renderRegion == null)
     {
         AsyncRef asyncRef = (AsyncRef)asynchronousImageBoundsFuture.Realize("LatentRegionHolder.RequestRenderRegion");
         asyncRef.AddCallback(new AsyncRecord.CompleteCallback(this.ImageBoundsAvailable));
         new PersistentInterest(asyncRef);
     }
 }
示例#8
0
        private void Invalidate()
        {
            AsyncRef asyncRef = (AsyncRef)this.displayableSource.GetUserBounds(this.latentRegionHolder, (FutureFeatures)7).Realize("UserRegionViewController.Invalidate");

            asyncRef.ProcessSynchronously();
            asyncRef.Dispose();
            this.svdp.InvalidateView();
            this.lastState.valid = false;
        }
示例#9
0
        /// <inheritdoc />
        public async Task <Stream> GetReader(string path, AsyncRef <string> mime)
        {
            HttpClient          client   = _clientFactory.CreateClient();
            HttpResponseMessage response = await client.GetAsync(path);

            response.EnsureSuccessStatusCode();
            mime.Value = response.Content.Headers.ContentType?.MediaType;
            return(await response.Content.ReadAsStreamAsync());
        }
示例#10
0
 /// <inheritdoc />
 public Task <Stream> GetReader(string path, AsyncRef <string> mime)
 {
     if (path == null)
     {
         throw new ArgumentNullException(nameof(path));
     }
     return(_GetFileSystemForPath(path, out string relativePath)
            .GetReader(relativePath, mime));
 }
示例#11
0
 /// <inheritdoc />
 public Task <Stream> GetReader(string path, AsyncRef <string> mime)
 {
     if (path == null)
     {
         throw new ArgumentNullException(nameof(path));
     }
     _provider.TryGetContentType(path, out string mimeValue);
     mime.Value = mimeValue;
     return(Task.FromResult <Stream>(File.OpenRead(path)));
 }
示例#12
0
        public async Task <bool> Authenticate(string userName, string password, AsyncRef <string> errorMessage)
        {
            var request = new AuthenticateRequest
            {
                Password = Convert.ToBase64String(System.Text.Encoding.ASCII.GetBytes(password)),
                Username = userName
            };

            var httpService = IoC.Get <IHttpService>();
            var response    = await httpService.PostAsync <AuthenticateRequest, AuthenticateResponse>(HttpUtils.ValidateUserUrl, request)
                              .ConfigureAwait(false);

            if (response.HasError)
            {
                errorMessage.Value = response.Errors.First();
                return(false);
            }
            UserName    = response.UserName;
            DisplayName = response.DisplayName;
            Bio         = response.Bio;
            AuthToken   = response.AuthToken;
            return(true);
        }
示例#13
0
 private void ImageBoundsAvailable(AsyncRef asyncRef)
 {
     this.StoreRenderRegion(asyncRef.present);
 }
示例#14
0
 public void AsyncCompleteCallback(AsyncRef boundsAsyncRef)
 {
     interestList.Dispose();
 }
示例#15
0
        private List <ViewerControl.PaintKit> AssembleLayer(PaintSpecification e, LatLonZoom llz, IDisplayableSource tileSource, int stackOrder)
        {
            List <ViewerControl.PaintKit> list = new List <ViewerControl.PaintKit>();
            CoordinateSystemIfc           defaultCoordinateSystem = tileSource.GetDefaultCoordinateSystem();
            TileDisplayDescriptorArray    tileArrayDescriptor     = defaultCoordinateSystem.GetTileArrayDescriptor(llz, e.Size);
            AsyncRef asyncRef;

            try
            {
                asyncRef = (AsyncRef)tileSource.GetUserBounds(null, (FutureFeatures)7).Realize("ViewerControl.PaintLayer boundsRef");
            }
            catch (Exception ex)
            {
                ViewerControl.MessagePainter item = new ViewerControl.MessagePainter(stackOrder * 12, BigDebugKnob.theKnob.debugFeaturesEnabled ? ex.ToString() : "X", stackOrder == 0);
                foreach (TileDisplayDescriptor current in tileArrayDescriptor)
                {
                    list.Add(new ViewerControl.PaintKit(current.paintLocation)
                    {
                        annotations =
                        {
                            item
                        }
                    });
                }
                return(list);
            }
            Region clipRegion = null;

            if (asyncRef.present == null)
            {
                asyncRef.AddCallback(new AsyncRecord.CompleteCallback(this.BoundsRefAvailable));
                asyncRef.SetInterest(524290);
            }
            if ((this.ShowSourceCrop == null || this.ShowSourceCrop.Enabled) && asyncRef.present is IBoundsProvider)
            {
                clipRegion = ((IBoundsProvider)asyncRef.present).GetRenderRegion().GetClipRegion(defaultCoordinateSystem.GetUnclippedMapWindow(this.center().llz, e.Size), this.center().llz.zoom, defaultCoordinateSystem);
                this.UpdateUserRegion();
            }
            new PersistentInterest(asyncRef);
            int num = 0;

            foreach (TileDisplayDescriptor current2 in tileArrayDescriptor)
            {
                ViewerControl.PaintKit paintKit = new ViewerControl.PaintKit(current2.paintLocation);
                D.Sayf(10, "count {0} tdd {1}", new object[]
                {
                    num,
                    current2.tileAddress
                });
                num++;
                if (e.SynchronousTiles)
                {
                    D.Sayf(0, "PaintLayer({0}, tdd.ta={1})", new object[]
                    {
                        tileSource.GetHashCode(),
                        current2.tileAddress
                    });
                }
                bool    arg_1F5_0 = e.SynchronousTiles;
                Present present   = tileSource.GetImagePrototype(null, (FutureFeatures)15).Curry(new ParamDict(new object[]
                {
                    TermName.TileAddress,
                    current2.tileAddress
                })).Realize("ViewerControl.PaintLayer imageAsyncRef");
                AsyncRef  asyncRef2 = (AsyncRef)present;
                Rectangle rectangle = Rectangle.Intersect(e.ClipRectangle, current2.paintLocation);
                int       interest  = rectangle.Height * rectangle.Width + 524296;
                asyncRef2.SetInterest(interest);
                if (asyncRef2.present == null)
                {
                    ViewerControl.AsyncNotifier @object = new ViewerControl.AsyncNotifier(this);
                    asyncRef2.AddCallback(new AsyncRecord.CompleteCallback(@object.AsyncRecordComplete));
                }
                this.activeTiles.Add(asyncRef2);
                asyncRef2 = (AsyncRef)asyncRef2.Duplicate("ViewerControl.PaintLayer");
                if (e.SynchronousTiles)
                {
                    D.Assert(false, "unimpl");
                }
                if (asyncRef2.present == null)
                {
                    D.Assert(!e.SynchronousTiles);
                }
                bool flag;
                if (asyncRef2.present != null && asyncRef2.present is ImageRef)
                {
                    flag = false;
                    ImageRef imageRef = (ImageRef)asyncRef2.present.Duplicate("tpc");
                    paintKit.meatyParts.Add(new ViewerControl.ImagePainter(imageRef, clipRegion));
                }
                else
                {
                    if (asyncRef2.present != null && asyncRef2.present is BeyondImageBounds)
                    {
                        flag = false;
                    }
                    else
                    {
                        if (asyncRef2.present != null && asyncRef2.present is PresentFailureCode)
                        {
                            flag = false;
                            PresentFailureCode           presentFailureCode = (PresentFailureCode)asyncRef2.present;
                            ViewerControl.MessagePainter item2 = new ViewerControl.MessagePainter(stackOrder * 12, BigDebugKnob.theKnob.debugFeaturesEnabled ? StringUtils.breakLines(presentFailureCode.ToString()) : "X", stackOrder == 0);
                            paintKit.annotations.Add(item2);
                        }
                        else
                        {
                            flag = true;
                            ViewerControl.MessagePainter item3 = new ViewerControl.MessagePainter(stackOrder * 12, stackOrder.ToString(), stackOrder == 0);
                            if (stackOrder == 0)
                            {
                                paintKit.meatyParts.Add(item3);
                            }
                            else
                            {
                                paintKit.annotations.Add(item3);
                            }
                        }
                    }
                }
                this.tilesRequired++;
                if (!flag)
                {
                    this.tilesAvailable++;
                }
                if ((flag && stackOrder == 0) || MapDrawingOption.IsEnabled(this.ShowTileBoundaries))
                {
                    paintKit.annotations.Add(new ViewerControl.TileBoundaryPainter());
                }
                if (MapDrawingOption.IsEnabled(this.ShowTileNames))
                {
                    paintKit.annotations.Add(new ViewerControl.TileNamePainter(current2.tileAddress.ToString()));
                }
                asyncRef2.Dispose();
                list.Add(paintKit);
            }
            return(list);
        }
示例#16
0
 private void BoundsRefAvailable(AsyncRef asyncRef)
 {
     base.Invalidate();
 }
示例#17
0
 public void Callback(AsyncRef asyncRef)
 {
     this.lop.AsyncReadyCallback(this);
 }