Пример #1
0
        /// <summary>
        /// Creates a layer group.
        /// </summary>
        /// <param name="sender">
        /// Create Group button.
        /// </param>
        /// <param name="e">
        /// Attributes of the event.
        /// </param>
        private void OnCreateGroup(object sender, RoutedEventArgs e)
        {
            try
            {
                var layerGroup = new LayerGroup();
                layerGroup.Owner = this;
                layerGroup.ShowDialog();
                if (!string.IsNullOrEmpty(layerGroup.LayerGroupName))
                {
                    TreeViewItem selectedNode = this.layersTree.SelectedItem as TreeViewItem;
                    if (selectedNode != null)
                    {
                        string url      = string.Format("http://{0}:5050/layerApi.aspx?cmd=group&frame={1}&name={2}", this.machineIp, selectedNode.Header.ToString(), layerGroup.LayerGroupName);
                        string payload  = string.Empty;
                        string response = WWTRequest.Send(url, payload);
                        this.PrintSendAndReceive(url, response);
                        this.PrintSendAndReceiveHeader("Create Group");

                        url      = string.Format("http://{0}:5050/layerApi.aspx?cmd=showlayermanager", this.machineIp);
                        response = WWTRequest.Send(url, string.Empty);
                        this.PrintSendAndReceive(url, response);
                        this.PrintSendAndReceiveHeader("Show Layer Manager Pane in WWT");

                        this.RefreshLayers(false, false);
                    }
                }
            }
            catch (CustomException ex)
            {
                // WorldWide Telescope might not be open.
                this.ReportError(ex.Message);
            }
        }
Пример #2
0
        /// <summary>
        /// Changes the view to one of Earth, Planet, Sky, Panorama, SolarSystem in WWT.
        /// </summary>
        /// <param name="mode">
        /// Mode to be set.
        /// </param>
        private void SetMode(string mode)
        {
            string url      = string.Format("http://{0}:5050/layerApi.aspx?cmd=mode&lookat=" + mode, this.machineIp);
            string payload  = string.Empty;
            string response = WWTRequest.Send(url, payload);

            this.PrintSendAndReceive(url, response);
            this.PrintSendAndReceiveHeader("Change mode to");
        }
Пример #3
0
        /// <summary>
        /// The load specifies a data file which can be loaded to WWT
        /// with some optional parameters, to apply to a new layer.
        /// </summary>
        /// <param name="filePath">Full file path.</param>
        private void LoadFile(string filePath)
        {
            TreeViewItem selectedNode = this.layersTree.SelectedItem as TreeViewItem;

            if (selectedNode != null)
            {
                string fileName = Path.GetFileNameWithoutExtension(filePath);
                string url      = string.Format("http://{0}:5050/layerApi.aspx?cmd=load&frame={1}&filename={2}&name={3}", this.machineIp, selectedNode.Header.ToString(), filePath, fileName);
                string payload  = string.Empty;
                string response = WWTRequest.Send(url, payload);
                this.PrintSendAndReceive(url, response);
                this.PrintSendAndReceiveHeader("Load File");
                this.RefreshLayers(false, false);
            }
        }
Пример #4
0
 /// <summary>
 /// Move view for left, right and in and out
 /// </summary>
 /// <param name="moveString">tag for view.</param>
 private void MoveView(string moveString, string content)
 {
     try
     {
         string url      = string.Format("http://{0}:5050/layerApi.aspx?cmd=move&move={1}", this.machineIp, moveString);
         string payload  = string.Empty;
         string response = WWTRequest.Send(url, payload);
         this.PrintSendAndReceive(url, response);
         this.PrintSendAndReceiveHeader(content);
     }
     catch (CustomException ex)
     {
         // WorldWide Telescope might not be open.
         this.ReportError(ex.Message);
     }
 }
Пример #5
0
 /// <summary>
 /// Gets the layer data from WWT for the specified layer
 /// It only fetches the data for the layer not the layer properties.
 /// </summary>
 /// <param name="sender">Get Layer Data button on the UI.</param>
 /// <param name="e">Attributes of the event</param>
 private void OnGetLayerData(object sender, RoutedEventArgs e)
 {
     try
     {
         string url      = string.Format("http://{0}:5050/layerApi.aspx?cmd=get&id={1}", this.machineIp, layerId);
         string payload  = string.Empty;
         string response = WWTRequest.GetLayerData(url);
         this.PrintSendAndReceive(url, response);
         this.PrintSendAndReceiveHeader("Get Layer Data");
     }
     catch (CustomException ex)
     {
         // WorldWide Telescope might not be open.
         this.ReportError(ex.Message);
     }
 }
Пример #6
0
        /// <summary>
        /// Sets the vantage point in the Client.
        /// </summary>
        /// <param name="instantType">
        /// Specifies whether the traversal is instantaneous or gradual.
        /// </param>
        private void SetPerspective(bool instantType)
        {
            string url      = string.Format("http://{0}:5050/layerApi.aspx?cmd=state&instant={1}&flyto={2},{3},{4},{5},{6}", this.machineIp, instantType.ToString(), this.latitude, this.longitude, this.zoomLevel, this.azimuth, this.lookAngle);
            string payload  = string.Empty;
            string response = WWTRequest.Send(url, payload);

            this.PrintSendAndReceive(url, response);
            if (instantType)
            {
                this.PrintSendAndReceiveHeader("Jump to New York");
            }
            else
            {
                this.PrintSendAndReceiveHeader("Traverse to New York");
            }
        }
Пример #7
0
 /// <summary>
 /// Sets multiple properties of the layer.
 /// Multiple properties of a layer can be set at a time.
 /// </summary>
 /// <param name="sender">
 /// Set Properties button.
 /// </param>
 /// <param name="e">
 /// Attributes of the event.
 /// </param>
 private void OnSetMultiProperties(object sender, RoutedEventArgs e)
 {
     try
     {
         string url      = string.Format("http://{0}:5050/layerApi.aspx?cmd=setprops&id={1}", this.machineIp, layerId);
         string payload  = "<?xml version=\"1.0\" encoding=\"utf-8\"?><LayerApi><Layer Opacity=\".5\" ColorValue=\"ARGBColor:255:255:0:0\"> </Layer></LayerApi>";
         string response = WWTRequest.Send(url, payload);
         this.PrintSendAndReceive(url + "\r\n" + payload, response);
         this.PrintSendAndReceiveHeader("Set Properties");
     }
     catch (CustomException ex)
     {
         // WorldWide Telescope might not be open.
         this.ReportError(ex.Message);
     }
 }
Пример #8
0
 /// <summary>
 /// Sets value for a single layer property.
 /// In this case PlotType value is set for the created layer in WWT.
 /// </summary>
 /// <param name="sender">
 /// Set PlotType button.
 /// </param>
 /// <param name="e">
 /// Attributes of the event.
 /// </param>
 private void OnSetPushPin(object sender, RoutedEventArgs e)
 {
     try
     {
         string url      = string.Format("http://{0}:5050/layerApi.aspx?cmd=setprop&id={1}&propname=PlotType&propvalue=PushPin", this.machineIp, layerId);
         string payload  = string.Empty;
         string response = WWTRequest.Send(url, payload);
         this.PrintSendAndReceive(url, response);
         this.PrintSendAndReceiveHeader("Use Push Pin");
     }
     catch (CustomException ex)
     {
         // WorldWide Telescope might not be open.
         this.ReportError(ex.Message);
     }
 }
Пример #9
0
        /// <summary>
        /// Fetches the structure of the layers and layer group names (in an XML document format)
        /// that are currently in the layer manager in WWT.
        /// </summary>
        /// <param name="displayResponse">show the response in response output</param>
        /// <param name="isLayerCreated">Checks if the call has come from Create layer</param>
        private void RefreshLayers(bool displayResponse, bool isLayerCreated)
        {
            try
            {
                string url      = string.Format("http://{0}:5050/layerApi.aspx?cmd=layerlist", this.machineIp);
                string payload  = string.Empty;
                string response = WWTRequest.Send(url, payload);
                if (displayResponse)
                {
                    this.PrintSendAndReceive(url, response);
                    this.PrintSendAndReceiveHeader("Refresh Layer List");
                }

                this.layersTree.Items.Clear();
                XmlDocument doc = new XmlDocument();
                doc.LoadXml(response);

                XmlNode root       = doc["LayerApi"];
                XmlNode layersNode = root["LayerList"];
                foreach (XmlElement element in layersNode.ChildNodes)
                {
                    TreeViewItem node = new TreeViewItem();
                    node.Header = element.Attributes["Name"].Value;
                    node.Name   = element.Name;
                    if (element.Attributes["ID"] != null)
                    {
                        node.Tag = element.Attributes["ID"].Value;
                    }

                    this.layersTree.Items.Add(node);
                    node.IsExpanded = true;
                    foreach (XmlElement child in element.ChildNodes)
                    {
                        // If the layer is not of spread sheet layer type, then ignore them.
                        if (child.Attributes["Type"] != null && !child.Attributes["Type"].Value.Equals("SpreadSheetLayer", StringComparison.OrdinalIgnoreCase))
                        {
                            continue;
                        }

                        TreeViewItem childNode = new TreeViewItem();
                        childNode.Header = child.Attributes["Name"].Value;
                        childNode.Name   = child.Name;
                        if (child.Attributes["ID"] != null)
                        {
                            childNode.Tag = child.Attributes["ID"].Value;
                        }

                        node.Items.Add(childNode);

                        // Select Earth.
                        if (childNode.Header.ToString().Equals("Earth", StringComparison.OrdinalIgnoreCase) && !isLayerCreated)
                        {
                            childNode.IsSelected = true;
                        }

                        foreach (XmlElement grandChild in child.ChildNodes)
                        {
                            // If the layer is not of spread sheet layer type, then ignore them.
                            if (grandChild.Attributes["Type"] != null && !grandChild.Attributes["Type"].Value.Equals("SpreadSheetLayer", StringComparison.OrdinalIgnoreCase))
                            {
                                continue;
                            }

                            TreeViewItem grandChildNode = new TreeViewItem();
                            grandChildNode.Header = grandChild.Attributes["Name"].Value;
                            grandChildNode.Name   = grandChild.Name;
                            if (grandChild.Attributes["ID"] != null)
                            {
                                grandChildNode.Tag = grandChild.Attributes["ID"].Value;
                                if (isLayerCreated)
                                {
                                    if (grandChild.Attributes["ID"].Value == layerId)
                                    {
                                        grandChildNode.IsSelected = true;
                                        layersTree.Focus();
                                        grandChildNode.Focus();
                                        childNode.IsExpanded = true;
                                    }
                                }
                            }

                            childNode.Items.Add(grandChildNode);
                            foreach (XmlElement greatGrandChild in grandChild.ChildNodes)
                            {
                                // If the layer is not of spread sheet layer type, then ignore them.
                                if (greatGrandChild.Attributes["Type"] != null && !greatGrandChild.Attributes["Type"].Value.Equals("SpreadSheetLayer", StringComparison.OrdinalIgnoreCase))
                                {
                                    continue;
                                }

                                TreeViewItem greatGrandChildNode = new TreeViewItem();
                                greatGrandChildNode.Header = greatGrandChild.Attributes["Name"].Value;
                                greatGrandChildNode.Name   = greatGrandChild.Name;
                                if (greatGrandChild.Attributes["ID"] != null)
                                {
                                    greatGrandChildNode.Tag = greatGrandChild.Attributes["ID"].Value;
                                    if (isLayerCreated)
                                    {
                                        if (greatGrandChild.Attributes["ID"].Value == layerId)
                                        {
                                            greatGrandChildNode.IsSelected = true;
                                            layersTree.Focus();
                                            greatGrandChildNode.Focus();
                                            childNode.IsExpanded      = true;
                                            grandChildNode.IsExpanded = true;
                                        }
                                    }
                                }

                                grandChildNode.Items.Add(greatGrandChildNode);
                            }
                        }
                    }
                }

                if (this.cmbModes.SelectedIndex <= 0)
                {
                    this.cmbModes.SelectedIndex = 0;
                }
            }
            catch (CustomException ex)
            {
                // Refresh has failed
                this.SetLayerButtons(false);
                this.SetCommonOperationsButtons(false);

                // WorldWide Telescope might not be open.
                throw ex;
            }
        }
Пример #10
0
        /// <summary>
        /// Creates a new layer in WWT through header data and updates the properties
        /// of layer created and pass data to be attached to the layer which is created.
        /// </summary>
        /// <param name="sender">
        /// Create Layer button.
        /// </param>
        /// <param name="e">
        /// Attributes of the event.
        /// </param>
        private void OnCreateNewLayer(object sender, RoutedEventArgs e)
        {
            try
            {
                TreeViewItem selectedNode = this.layersTree.SelectedItem as TreeViewItem;
                if (selectedNode != null)
                {
                    // Call New to create the layer.
                    string url = string.Format(
                        "http://{0}:5050/layerApi.aspx?cmd=new&datetime={1}&name={2}&frame={3}&color={4}",
                        this.machineIp,
                        "1/9/2009 3:44:38 AM",
                        "New Layer",
                        selectedNode.Header.ToString(),
                        "FFFF0000");
                    string payload  = "TIME\tLAT\tLON\tDEPTH\tMAG\tColor";
                    string response = WWTRequest.Send(url, payload);
                    this.PrintSendAndReceive(url, response);
                    this.PrintSendAndReceiveHeader("Step 1 : Create new layer");

                    if (!string.IsNullOrEmpty(response))
                    {
                        XmlDocument doc = new XmlDocument();
                        doc.LoadXml(response);
                        XmlNode node = doc["LayerApi"];
                        layerId = node.InnerText;

                        url = string.Format("http://{0}:5050/layerApi.aspx?cmd=setprops&id={1}", this.machineIp, layerId);

                        payload = "<?xml version=\"1.0\" encoding=\"utf-8\"?><LayerApi><Layer Name=\"New Layer\" LatColumn=\"1\" LngColumn=\"2\" GeometryColumn=\"-1\"" +
                                  " ColorMapColumn=\"5\" AltColumn=\"3\" StartDateColumn=\"0\" EndDateColumn=\"-1\" SizeColumn=\"4\" NameColumn=\"0\" Decay=\"16\" ScaleFactor=\"1\" Opacity=\"1\" StartTime=\"1/1/0001 12:00:00 AM\" EndTime=\"12/31/9999 11:59:59 PM\" FadeSpan=\"00:00:00\" ColorValue=\"ARGBColor:255:255:0:0\" AltType=\"Depth\" MarkerScale=\"World\"" +
                                  " AltUnit=\"Kilometers\" RaUnits=\"Hours\" PointScaleType=\"Power\" FadeType=\"None\" PlotType=\"Gaussian\" MarkerIndex=\"0\" ShowFarSide=\"true\" TimeSeries=\"false\" /></LayerApi>";
                        response = WWTRequest.Send(url, payload);

                        this.PrintSendAndReceive(url + "\r\n" + payload, response);
                        this.PrintSendAndReceiveHeader("Step 2 : Update layer properties");

                        // Call Update to update the layer with data.
                        url = string.Format("http://{0}:5050/layerApi.aspx?cmd=update&id={1}", this.machineIp, layerId);
                        string lineBuffer = "1/9/2009 3:44\t0\t0\t10\t7\tRed\r\n1/9/2009 6:28\t0\t10\t243\t9\tBlue\r\n1/9/2009 6:54\t-5\t5\t35\t8\t90%Green";
                        response = WWTRequest.Send(url, lineBuffer);

                        this.PrintSendAndReceive(url + "\r\n" + lineBuffer, response);
                        this.PrintSendAndReceiveHeader("Step 3 : Send layer data");

                        url      = string.Format("http://{0}:5050/layerApi.aspx?cmd=showlayermanager", this.machineIp);
                        response = WWTRequest.Send(url, string.Empty);
                        this.PrintSendAndReceive(url, response);
                        this.PrintSendAndReceiveHeader("Step 4 : Show Layer Manager Pane in WWT");
                    }

                    this.RefreshLayers(false, true);
                    this.tabControl.SelectedIndex = 0;
                }
            }
            catch (CustomException ex)
            {
                // WorldWide Telescope might not be open.
                this.ReportError(ex.Message);
            }
        }