/// <summary>
        /// This function is used to Add WWT layers.
        /// </summary>
        /// <param name="workbookMap">
        /// Parent container.
        /// </param>
        /// <param name="group">
        /// Group in which the layer is present.
        /// </param>
        private static void AddWWTLayers(WorkbookMap workbookMap, Group group)
        {
            foreach (string layerID in group.LayerIDs)
            {
                if (!workbookMap.Exists(layerID))
                {
                    Layer wwtLayer = WWTManager.GetLayerDetails(layerID, group, true);
                    if (wwtLayer != null)
                    {
                        workbookMap.AllLayerMaps.Add(new LayerMap(wwtLayer));
                    }
                }
            }

            foreach (Group child in group.Children)
            {
                AddWWTLayers(workbookMap, child);
            }
        }
示例#2
0
        /// <summary>
        /// Implementation for the BackgroundWorker which will be syncing the layer properties.
        /// </summary>
        /// <param name="sender">Background Worker</param>
        /// <param name="e">BackgroundWorker event arguments</param>
        private void OnPropertyChangeNotifierDoWork(object sender, DoWorkEventArgs e)
        {
            try
            {
                e.Result = false;

                int         layerVersion      = WWTManager.CreateLayerNotification(this.LayerDetails.ID, this.LayerDetails.Version, this.cancellationTokenSource.Token);
                WorkbookMap parentWorkbookMap = WorkflowController.Instance.GetWorkbookMapForLayerMap(this);

                // Rebuild the Layer Details view model/Custom Task Pane if the layer's properties are updated in WWT.
                if (layerVersion > LayerDetails.Version)
                {
                    if (IsPropertyChangedFromCode)
                    {
                        LayerDetails.Version = layerVersion;
                    }
                    else
                    {
                        // Get the current properties of the layer from WWT.
                        Layer layerDetails = WWTManager.GetLayerDetails(LayerDetails.ID, LayerDetails.Group, true);

                        if (layerDetails != null)
                        {
                            LayerDetails = layerDetails;

                            // Update the received latest properties to the LayerMap.
                            this.UpdateLayerMapProperties(LayerDetails);

                            // Save the workbook map to the workbook which it belongs to.
                            this.SaveWorkbookMap();

                            if (parentWorkbookMap != null && parentWorkbookMap.SelectedLayerMap == this)
                            {
                                // This will update the custom task pane.
                                e.Result = true;
                            }
                        }
                    }
                }
                else if (layerVersion == -1)
                {
                    // In case if the layer is deleted or WWT is closed, layerVersion will be returned as -1.
                    // In case of Timeout, layers current version will be returned which is expected in case of no update to the layer properties.
                    // Setting not in sync will stop the notification as well.
                    IsNotInSync = true;

                    if (parentWorkbookMap != null && parentWorkbookMap.SelectedLayerMap == this)
                    {
                        if (MapType == LayerMapType.WWT)
                        {
                            // If current layer map is of type WWT and it is selected in layer dropdown, make sure the selection is removed.
                            parentWorkbookMap.SelectedLayerMap = null;
                        }

                        // This will update the custom task pane.
                        e.Result = true;
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.LogException(ex);
            }
        }