コード例 #1
0
        public void AddChildNodesToGroupTest()
        {
            Application application = new Application();

            try
            {
                // Where ever we are creating object for WorkflowController_Accessor, we need to set the ThisAddIn_Accessor.ExcelApplication to
                // wither null or actual application object.
                ThisAddIn_Accessor.ExcelApplication = application;

                Group childGroup = new Group("Earth", GroupType.ReferenceFrame, null);
                Layer layer = new Layer();
                layer.Name = "Layer1";
                layer.Group = childGroup;
                LayerMap_Accessor localLayerMap = new LayerMap_Accessor(layer);
                localLayerMap.MapType = LayerMapType.Local;

                GroupChildren groupChild = LayerMapExtensions_Accessor.AddChildNodesToGroup(localLayerMap);
                Assert.AreEqual("Earth", groupChild.Name);
                Assert.AreEqual(1, groupChild.AllChildren.Count);
                Assert.AreEqual(1, groupChild.Layers.Count);
                foreach (Layer layerVal in groupChild.Layers)
                {
                    Assert.AreEqual("Layer1", layerVal.Name);
                }
            }
            finally
            {
                application.Close();
            }
        }
コード例 #2
0
 public void AltUnitTest()
 {
     Layer target = new Layer();
     AltUnit expected = AltUnit.Meters;
     target.AltUnit = expected;
     AltUnit actual = target.AltUnit;
     Assert.AreEqual(expected, actual);
 }
コード例 #3
0
 public void AltTypeTest()
 {
     Layer target = new Layer();
     AltType expected = AltType.Depth;
     target.AltType = expected;
     AltType actual = target.AltType;
     Assert.AreEqual(expected, actual);
 }
コード例 #4
0
 public void AltColumnTest()
 {
     Layer target = new Layer();
     int expected = 3;
     target.AltColumn = expected;
     int actual = target.AltColumn;
     Assert.AreEqual(expected, actual);
 }
コード例 #5
0
        public void GetLayerPropertiesLatLongTest()
        {
            string expected = "<LayerApi><Layer Name=\"California\" CoordinatesType=\"Spherical\" XAxisColumn=\"-1\" YAxisColumn=\"-1\" ZAxisColumn=\"-1\" XAxisReverse=\"false\" YAxisReverse=\"false\" ZAxisReverse=\"false\" LatColumn=\"2\" LngColumn=\"1\" GeometryColumn=\"-1\" ColorMapColumn=\"6\" AltColumn=\"3\" StartDateColumn=\"4\" EndDateColumn=\"-1\" SizeColumn=\"5\" NameColumn=\"0\" Decay=\"0\" ScaleFactor=\"1\" Opacity=\"0\" StartTime=\"1/1/0001 12:00:00 AM\" EndTime=\"12/31/9999 11:59:59 PM\" FadeSpan=\"00:00:00\" ColorValue=\"ARGBColor:255:255:255:255\" AltType=\"Altitude\" MarkerScale=\"World\" AltUnit=\"Meters\" RaUnits=\"Hours\" PointScaleType=\"Power\" FadeType=\"None\" PlotType=\"Gaussian\" MarkerIndex=\"0\" ShowFarSide=\"true\" /></LayerApi>";

            Layer layer = new Layer();

            layer.Name = "California";
            layer.LatColumn = 2;
            layer.LngColumn = 1;
            layer.GeometryColumn = -1;
            layer.ColorMapColumn = 6;
            layer.AltColumn = 3;
            layer.StartDateColumn = 4;
            layer.EndDateColumn = -1;
            layer.SizeColumn = 5;
            layer.NameColumn = 0;
            layer.TimeDecay = 0;
            layer.ScaleFactor = 1;
            layer.Opacity = 0;
            layer.StartTime = Convert.ToDateTime("1/1/0001 12:00:00 AM", CultureInfo.InvariantCulture);
            layer.EndTime = Convert.ToDateTime("12/31/9999 11:59:59 PM", CultureInfo.InvariantCulture);
            layer.FadeSpan = new TimeSpan();
            layer.Color = "ARGBColor:255:255:255:255";
            layer.AltType = AltType.Altitude;
            layer.MarkerScale = ScaleRelativeType.World;
            layer.AltUnit = AltUnit.Meters;
            layer.PointScaleType = ScaleType.Power;
            layer.FadeType = FadeType.None;

            // Dummy sun group
            Group group = new Group("Sun", GroupType.ReferenceFrame, null);
            layer.Group = group;

            string actual = WWTManager_Accessor.GetLayerProperties(layer, false);
            Assert.AreEqual(expected, actual);
        }
コード例 #6
0
 public void StartTimeTest()
 {
     Layer target = new Layer();
     DateTime expected = DateTime.Now;
     target.StartTime = expected;
     DateTime actual = target.StartTime;
     Assert.AreEqual(expected, actual);
 }
コード例 #7
0
        public void BuildGroupCollectionTest()
        {
            Application application = new Application();

            try
            {
                Group parentGroup = new Group("Sun", GroupType.ReferenceFrame, null);
                Group childGroup = new Group("Earth", GroupType.ReferenceFrame, parentGroup);
                Layer layer = new Layer();
                layer.Name = "Layer1";
                layer.Group = childGroup;
                Layer layerMap = new Layer();
                layerMap.Name = "Layer2";
                layerMap.Group = new Group("Sun", GroupType.ReferenceFrame, null);
                LayerMap localLayerMap = new LayerMap(layer);
                localLayerMap.MapType = LayerMapType.Local;
                LayerMap wwtLayerMap = new LayerMap(layerMap);
                wwtLayerMap.MapType = LayerMapType.WWT;

                List<GroupChildren> wwtGroups = new List<GroupChildren>();
                List<GroupChildren> localGroups = new List<GroupChildren>();
                List<GroupChildren> existingGroups = new List<GroupChildren>();
                List<GroupChildren> groupwithChildren = new List<GroupChildren>();
                GroupChildren children = new GroupChildren();
                children.Group = parentGroup;
                GroupChildren children1 = new GroupChildren();
                children1.Group = childGroup;
                GroupChildren childNode = new GroupChildren();
                childNode.Group = parentGroup;
                childNode.Children.Add(children1);
                existingGroups.Add(children);
                groupwithChildren.Add(childNode);
                LayerMapExtensions.BuildGroupCollection(wwtLayerMap, wwtGroups);
                LayerMapExtensions.BuildGroupCollection(localLayerMap, localGroups);
                LayerMapExtensions.BuildGroupCollection(localLayerMap, existingGroups);
                LayerMapExtensions.BuildGroupCollection(localLayerMap, groupwithChildren);

                Assert.AreEqual(1, wwtGroups.Count);
                foreach (GroupChildren child in wwtGroups)
                {
                    Assert.AreEqual(1, child.AllChildren.Count);
                    Assert.AreEqual("Sun", child.Name);
                }

                Assert.AreEqual(1, localGroups.Count);
                foreach (GroupChildren child in localGroups)
                {
                    Assert.AreEqual(1, child.Children.Count);
                    Assert.AreEqual("Sun", child.Name);
                }

                Assert.AreEqual(1, existingGroups.Count);
                foreach (GroupChildren child in existingGroups)
                {
                    Assert.AreEqual(1, child.Children.Count);
                    foreach (GroupChildren childrenVal in child.Children)
                    {
                        Assert.AreEqual("Earth", childrenVal.Name);
                    }
                }

                Assert.AreEqual(1, groupwithChildren.Count);
                foreach (GroupChildren child in groupwithChildren)
                {
                    Assert.AreEqual(1, child.Children.Count);
                    foreach (GroupChildren childrenVal in child.Children)
                    {
                        Assert.AreEqual(1, childrenVal.AllChildren.Count);
                    }
                }
            }
            finally
            {
                application.Close();
            }
        }
コード例 #8
0
        public void SetMarkerPropertiesTest()
        {
            // Create an empty layer object.
            Layer layer = new Layer();

            XElement root = XElement.Parse("<LayerApi><Status>Success</Status><Layer Class=\"SpreadSheetLayer\" BeginRange=\"12/31/9999 11:59:59 PM\" EndRange=\"1/1/0001 12:00:00 AM\" Decay=\"16\" CoordinatesType=\"Spherical\" LatColumn=\"-1\" LngColumn=\"-1\" GeometryColumn=\"-1\" XAxisColumn=\"-1\" YAxisColumn=\"6\" ZAxisColumn=\"-1\" XAxisReverse=\"False\" YAxisReverse=\"False\" ZAxisReverse=\"False\" AltType=\"Depth\" MarkerMix=\"Same_For_All\" MarkerColumn=\"-1\" ColorMapColumn=\"-1\" PlotType=\"Gaussian\" MarkerIndex=\"0\" ShowFarSide=\"False\" MarkerScale=\"World\" AltUnit=\"Meters\" CartesianScale=\"Meters\" CartesianCustomScale=\"1\" AltColumn=\"-1\" StartDateColumn=\"-1\" EndDateColumn=\"-1\" SizeColumn=\"-1\" NameColumn=\"-1\" HyperlinkFormat=\"\" HyperlinkColumn=\"-1\" ScaleFactor=\"1\" PointScaleType=\"Power\" Opacity=\"1\" StartTime=\"1/1/0001 12:00:00 AM\" EndTime=\"12/31/9999 11:59:59 PM\" FadeSpan=\"00:00:00\" FadeType=\"None\" Name=\"Sheet1_1\" ColorValue=\"ARGBColor:255:255:0:0\" Enabled=\"True\" Astronomical=\"False\" /></LayerApi>", LoadOptions.PreserveWhitespace);

            // Get All Attributes list  of Layers.
            var listOfAttributes = root.Element(Constants.LayerElementNodeName).Attributes();

            WWTManager_Accessor.SetMarkerProperties(layer, listOfAttributes);

            Assert.AreEqual(layer.TimeDecay, 16);
            Assert.AreEqual(layer.ScaleFactor, 1);
            Assert.AreEqual(layer.Opacity, 1);
            Assert.AreEqual(layer.StartTime, Convert.ToDateTime("1/1/0001 12:00:00 AM", CultureInfo.CurrentCulture));
            Assert.AreEqual(layer.EndTime, Convert.ToDateTime("12/31/9999 11:59:59 PM", CultureInfo.CurrentCulture));
            Assert.AreEqual(layer.FadeSpan, TimeSpan.Parse("00:00:00", CultureInfo.CurrentCulture));
            Assert.AreEqual(layer.Color, "ARGBColor:255:255:0:0");
            Assert.AreEqual(layer.AltType, AltType.Depth);
            Assert.AreEqual(layer.MarkerScale, ScaleRelativeType.World);
            Assert.AreEqual(layer.AltUnit, AltUnit.Meters);
            Assert.AreEqual(layer.PointScaleType, ScaleType.Power);
            Assert.AreEqual(layer.FadeType, FadeType.None);
        }
コード例 #9
0
        /// <summary>
        /// Initializes a new instance of the LayerMap class.
        /// </summary>
        /// <param name="layer">
        /// Layer details.
        /// </param>
        internal LayerMap(Layer layer)
        {
            this.LayerDetails = layer;
            this.MapType = LayerMapType.WWT;
            this.columnsList = ColumnExtensions.PopulateColumnList();

            // Set mapped column type based on header row data
            SetMappedColumnType();

            // For WWT layers, notification will be started immediately.
            StartNotifying();
        }
コード例 #10
0
        public void OnLayerSelectionChangedEventTest()
        {
            LayerDetailsViewModel_Accessor target = new LayerDetailsViewModel_Accessor();
            Layer layer = new Layer();
            layer.Name = "Layer1";
            layer.StartTime = DateTime.Now;

            LayerMap_Accessor localLayerMap = new LayerMap_Accessor(layer);
            localLayerMap.MapType = LayerMapType.Local;
            localLayerMap.RangeDisplayName = "Sheet_1";
            localLayerMap.HeaderRowData = new Collection<string>();
            localLayerMap.HeaderRowData.Add("Lat");

            localLayerMap.MappedColumnType = new Collection<ColumnType>();
            localLayerMap.MappedColumnType.Add(ColumnType.RA);
            target.currentLayer = localLayerMap;

            object sender = localLayerMap;
            EventArgs e = null;
            target.OnLayerSelectionChangedEvent(sender, e);

            Assert.AreEqual("Layer1", target.SelectedLayerText);
        }
コード例 #11
0
        public void LayerSelectionHandlerExecuteTest()
        {
            LayerDetailsViewModel layerDetailsViewModel = new LayerDetailsViewModel();
            layerDetailsViewModel.LayerSelectionChangedEvent += new EventHandler(LayerModelLayerSelectionChangedEvent);

            LayerMapDropDownViewModel layerMapDropDown = new LayerMapDropDownViewModel();
            layerMapDropDown.ID = "1";
            layerMapDropDown.Name = "Select One";

            Layer layer = new Layer();
            layer.Name = "Layer1";

            LayerMap layerMap = new LayerMap(layer);
            layerMap.MapType = LayerMapType.Local;
            layerMap.HeaderRowData = new Collection<string>();
            layerMap.MappedColumnType = new Collection<ColumnType>();
            layerDetailsViewModel.Currentlayer = layerMap;

            LayerDetailsViewModel_Accessor.LayerSelectionHandler target = new LayerDetailsViewModel_Accessor.LayerSelectionHandler(layerDetailsViewModel);
            target.Execute(layerMapDropDown);
            Assert.IsNull(layerDetailsViewModel.Currentlayer);
        }
コード例 #12
0
        public void GetSelectedLayerMapWWTTest()
        {
            Application application = new Application();

            try
            {
                Workbook book = application.OpenWorkbook("WorkbookTestData.xlsx", false);
                WorkflowController_Accessor target = GetWorkflowControllerAccessor(application);
                Common.Globals_Accessor.wwtManager = new WWTManager(new WWTMockRequest());
                Common.Globals_Accessor.TargetMachine = new TargetMachine("localhost");
                target.OnNewWorkbook(book);

                Layer layer = new Layer();
                LayerMap_Accessor localLayer = new LayerMap_Accessor(layer);
                localLayer.MapType = LayerMapType.WWT;
                localLayer.LayerDetails.ID = "2cf4374f-e1ce-47a9-b08c-31079765ddcf";

                // CurrentWorkbookMap cannot be accessed directly through WorkflowController_Accessor object.
                WorkbookMap currentWorkbookMap = target.currentWorkbookMap.Target as WorkbookMap;
                currentWorkbookMap.AllLayerMaps[0].LayerDetails.ID = "2cf4374f-e1ce-47a9-b08c-31079765ddcf";
                currentWorkbookMap.AllLayerMaps[0].MapType = LayerMapType.WWT;
                LayerMap_Accessor layerMapAccessor = target.GetSelectedLayerMap(localLayer);

                // Make sure LayerMap is returned and the expected LayerMap ID is returned.
                Assert.IsNotNull(layerMapAccessor);
                Assert.AreEqual(layerMapAccessor.LayerDetails.ID, "2cf4374f-e1ce-47a9-b08c-31079765ddcf");
            }
            finally
            {
                application.Close();
            }
        }
コード例 #13
0
        public void SetGetLayerDataDisplayNameTest()
        {
            WorkflowController_Accessor target = GetWorkflowControllerAccessor(null);
            Layer layer = new Layer();

            LayerMap_Accessor selectedLayerMap = new LayerMap_Accessor(layer);
            target.layerDetailsViewModel = new LayerDetailsViewModel();

            // When MapType is Local/WWT, LayerDataDisplayName will be "Get Layer Data";
            string actual = "Get Layer Data";
            selectedLayerMap.MapType = LayerMapType.Local;
            target.SetGetLayerDataDisplayName(selectedLayerMap);

            string expected = target.layerDetailsViewModel.LayerDataDisplayName;

            Assert.AreEqual(actual, expected);

            // When MapType is LocalInWWT, LayerDataDisplayName will be "Refresh";
            actual = "Refresh";
            selectedLayerMap.MapType = LayerMapType.LocalInWWT;
            target.SetGetLayerDataDisplayName(selectedLayerMap);

            expected = target.layerDetailsViewModel.LayerDataDisplayName;

            Assert.AreEqual(actual, expected);
        }
コード例 #14
0
 public void ColorMapColumnTest()
 {
     Layer target = new Layer();
     int expected = 4;
     target.ColorMapColumn = expected;
     int actual = target.ColorMapColumn;
     Assert.AreEqual(expected, actual);
 }
コード例 #15
0
 public void TimeDecayTest()
 {
     Layer target = new Layer();
     double expected = 3F;
     target.TimeDecay = expected;
     double actual = target.TimeDecay;
     Assert.AreEqual(expected, actual);
 }
コード例 #16
0
        public void LayerModelFadeTimeExecuteTest()
        {
            LayerDetailsViewModel layerDetailsViewModel = new LayerDetailsViewModel();
            Layer layer = new Layer();
            layer.Name = "Layer1";

            LayerMap layerMap = new LayerMap(layer);
            layerMap.MapType = LayerMapType.Local;
            layerMap.HeaderRowData = new Collection<string>();
            layerMap.MappedColumnType = new Collection<ColumnType>();
            layerDetailsViewModel.Currentlayer = layerMap;
            LayerDetailsViewModel_Accessor.FadeTimeChangeHandler target = new LayerDetailsViewModel_Accessor.FadeTimeChangeHandler(layerDetailsViewModel);
            string fadeTime = "10:10:10";
            target.Execute(fadeTime);
            Assert.AreEqual(fadeTime, layerDetailsViewModel.FadeTime.ToString());
        }
コード例 #17
0
        public void LayerModelLayerDisplayExecuteTest()
        {
            LayerDetailsViewModel layerDetailsViewModel = new LayerDetailsViewModel();
            LayerDetailsViewModel_Accessor.LayerMapNameChangeHandler target = new LayerDetailsViewModel_Accessor.LayerMapNameChangeHandler(layerDetailsViewModel);
            string layerName = "Layer1";
            Layer layer = new Layer();
            layer.Name = layerName;

            LayerMap layerMap = new LayerMap(layer);
            layerMap.MapType = LayerMapType.Local;
            layerMap.HeaderRowData = new Collection<string>();
            layerMap.MappedColumnType = new Collection<ColumnType>();
            layerDetailsViewModel.Currentlayer = layerMap;

            target.Execute(layerName);
            Assert.AreEqual(layerDetailsViewModel.SelectedLayerName, layerName);
        }
コード例 #18
0
 /// <summary>
 /// Updates the layer map properties with the layer values
 /// </summary>
 /// <param name="layerMap">Layer map value</param>
 /// <param name="layer">Layer details</param>
 /// <returns>Updated layer map</returns>
 internal static LayerMap UpdateLayerMapProperties(this LayerMap layerMap, Layer layer)
 {
     if (layerMap != null && layer != null)
     {
         lock (WorkflowController.LockObject)
         {
             layerMap.LayerDetails = layer;
             layerMap.ColumnsList = ColumnExtensions.PopulateColumnList();
             layerMap.SetMappedColumnType();
         }
     }
     return layerMap;
 }
コード例 #19
0
        public void OnGroupSelectionChangedTest()
        {
            LayerDetailsViewModel_Accessor target = new LayerDetailsViewModel_Accessor();
            Group group = new Group("Sun", GroupType.ReferenceFrame, null);
            Group skyGroup = new Group("Sky", GroupType.ReferenceFrame, null);
            Layer layer = new Layer();
            layer.Name = "Layer1";
            layer.StartTime = DateTime.Now;

            LayerMap_Accessor localLayerMap = new LayerMap_Accessor(layer);
            localLayerMap.MapType = LayerMapType.Local;
            localLayerMap.RangeDisplayName = "Sheet_1";
            localLayerMap.HeaderRowData = new Collection<string>();
            localLayerMap.HeaderRowData.Add("Lat");

            localLayerMap.MappedColumnType = new Collection<ColumnType>();
            localLayerMap.MappedColumnType.Add(ColumnType.RA);
            target.currentLayer = localLayerMap;

            ColumnViewModel columnView = new ColumnViewModel();
            columnView.ExcelHeaderColumn = "RA";
            columnView.WWTColumns = new ObservableCollection<Column>();
            ColumnExtensions.PopulateColumnList().ToList().ForEach(col => columnView.WWTColumns.Add(col));
            columnView.SelectedWWTColumn = columnView.WWTColumns.Where(column => column.ColType == ColumnType.RA).FirstOrDefault();

            target.ColumnsView = new ObservableCollection<ColumnViewModel>();
            target.ColumnsView.Add(columnView);

            target.selectedScaleType = new System.Collections.Generic.KeyValuePair<ScaleType, string>(ScaleType.StellarMagnitude, "StellarMagnitude");

            object sender = group;
            EventArgs e = null;
            target.OnGroupSelectionChanged(sender, e);

            Assert.AreEqual(false, target.isRAUnitVisible);
            Assert.AreEqual("Sun", target.selectedGroupText);
            Assert.AreEqual(ScaleType.Power, target.selectedScaleType.Key);

            sender = skyGroup;
            target.OnGroupSelectionChanged(sender, e);
            Assert.AreEqual(ScaleType.StellarMagnitude, target.selectedScaleType.Key);
        }
コード例 #20
0
        public void SetMappingOnSizeColumnTest()
        {
            Collection<ColumnType> mappedColTypes = new Collection<ColumnType>();
            mappedColTypes.Add(ColumnType.RA);
            mappedColTypes.Add(ColumnType.Dec);
            mappedColTypes.Add(ColumnType.None);
            mappedColTypes.Add(ColumnType.Long);

            Layer layer = new Layer();
            layer.Name = "Layer1";
            layer.StartTime = DateTime.Now;
            layer.SizeColumn = 2;

            LayerMap_Accessor layerMapAccessor = new LayerMap_Accessor(layer);
            layerMapAccessor.MappedColumnType = mappedColTypes;

            Assert.AreEqual(mappedColTypes[2], ColumnType.None);
            layerMapAccessor.SetMappingOnSizeColumn();
            Assert.AreEqual(mappedColTypes[2], ColumnType.Mag);
        }
コード例 #21
0
        public void OnMapColumnSelectionChangedEventRAGeoTest()
        {
            LayerDetailsViewModel_Accessor target = new LayerDetailsViewModel_Accessor();

            ColumnViewModel columnView = new ColumnViewModel();
            columnView.ExcelHeaderColumn = "RA";
            columnView.WWTColumns = new ObservableCollection<Column>();
            ColumnExtensions.PopulateColumnList().ToList().ForEach(col => columnView.WWTColumns.Add(col));
            columnView.SelectedWWTColumn = columnView.WWTColumns.Where(column => column.ColType == ColumnType.RA).FirstOrDefault();

            target.ColumnsView = new ObservableCollection<ColumnViewModel>();
            target.ColumnsView.Add(columnView);

            target.sizeColumnList = new ObservableCollection<System.Collections.Generic.KeyValuePair<int, string>>();
            target.sizeColumnList.Add(new System.Collections.Generic.KeyValuePair<int, string>(0, "LAT"));
            target.sizeColumnList.Add(new System.Collections.Generic.KeyValuePair<int, string>(1, "MAG"));
            target.sizeColumnList.Add(new System.Collections.Generic.KeyValuePair<int, string>(2, "LONG"));
            target.sizeColumnList.Add(new System.Collections.Generic.KeyValuePair<int, string>(3, "DEPTH"));

            target.hoverTextColumnList = new ObservableCollection<System.Collections.Generic.KeyValuePair<int, string>>();
            target.hoverTextColumnList.Add(new System.Collections.Generic.KeyValuePair<int, string>(0, "LAT"));
            target.hoverTextColumnList.Add(new System.Collections.Generic.KeyValuePair<int, string>(1, "MAG"));
            target.hoverTextColumnList.Add(new System.Collections.Generic.KeyValuePair<int, string>(2, "LONG"));
            target.hoverTextColumnList.Add(new System.Collections.Generic.KeyValuePair<int, string>(3, "DEPTH"));

            Layer layer = new Layer();
            layer.Name = "Layer1";
            layer.StartTime = DateTime.Now;

            LayerMap_Accessor localLayerMap = new LayerMap_Accessor(layer);
            localLayerMap.MapType = LayerMapType.Local;
            localLayerMap.RangeDisplayName = "Sheet_1";
            target.currentLayer = localLayerMap;

            EventArgs e = null;
            target.OnMapColumnSelectionChanged(columnView, e);

            Assert.AreEqual(true, target.isMarkerTabEnabled);
            Assert.AreEqual(false, target.isDistanceVisible);
            Assert.AreEqual(true, target.IsRAUnitVisible);
            Assert.AreEqual(AngleUnit.Hours, target.selectedRAUnit.Key);

            columnView.SelectedWWTColumn = columnView.WWTColumns.Where(column => column.ColType == ColumnType.Geo).FirstOrDefault();

            target.ColumnsView = new ObservableCollection<ColumnViewModel>();
            target.ColumnsView.Add(columnView);

            target.OnMapColumnSelectionChanged(columnView, e);
            Assert.AreEqual(true, target.isMarkerTabEnabled);
            Assert.AreEqual(false, target.isDistanceVisible);
            Assert.AreEqual(false, target.IsRAUnitVisible);
        }
コード例 #22
0
        /// <summary>
        /// This function is used to create the layer properties from the response XML.
        /// </summary>
        /// <param name="response">
        /// Response xml.
        /// </param>
        /// <param name="layerId">
        /// Id of the layer.
        /// </param>
        /// <param name="group">
        /// Group of the layer.
        /// </param>
        /// <returns>
        /// Instance of layer class.
        /// </returns>
        private static Layer GetLayer(string response, string layerId, Group group)
        {
            Layer layer = new Layer();
            layer.ID = layerId;
            layer.Group = group;
            XElement root = XElement.Parse(response, LoadOptions.PreserveWhitespace);

            // Get All Attributes list  of Layers.
            var listOfAttributes = root.Element(Constants.LayerElementNodeName).Attributes();

            // Set layer properties.
            SetLayerProperties(layer, listOfAttributes);

            // Set marker properties.
            SetMarkerProperties(layer, listOfAttributes);

            return layer;
        }
コード例 #23
0
        public void SetLayerPropertiesWithRaDecTest()
        {
            Layer layer = new Layer();
            layer.Group = new Group("Sky", GroupType.ReferenceFrame, null);

            string expected = "<LayerApi><Layer Name=\"California\" CoordinatesType=\"Spherical\" XAxisColumn=\"-1\" YAxisColumn=\"-1\" ZAxisColumn=\"-1\" XAxisReverse=\"false\" YAxisReverse=\"false\" ZAxisReverse=\"false\" LatColumn=\"2\" LngColumn=\"1\" GeometryColumn=\"-1\" ColorMapColumn=\"6\" AltColumn=\"3\" StartDateColumn=\"4\" EndDateColumn=\"-1\" SizeColumn=\"5\" NameColumn=\"0\" Decay=\"16\" ScaleFactor=\"8\" 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=\"Meters\" RaUnits=\"Hours\" PointScaleType=\"Power\" FadeType=\"None\" PlotType=\"Gaussian\" MarkerIndex=\"0\" ShowFarSide=\"true\" /></LayerApi>";

            XElement element = XElement.Parse(expected);
            var listOfAttributes = element.Element(Constants.LayerElementNodeName).Attributes();
            WWTManager_Accessor.SetLayerProperties(layer, listOfAttributes);

            string actual = WWTManager_Accessor.GetLayerProperties(layer, false);
            Assert.AreEqual(expected, actual);
        }
コード例 #24
0
        /// <summary>
        /// This function is used to retrieve payload for the updating the header.
        /// </summary>
        /// <param name="layer">Details of the layer.</param>
        /// <param name="isTimeSeriesRequired">If time series attribute is required to be set explicitly.</param>
        /// <returns>The payload of the header.</returns>
        private static string GetLayerProperties(Layer layer, bool isTimeSeriesRequired)
        {
            XAttribute cartesianScale = null;

            if (layer.CoordinatesType != CoordinatesType.Spherical)
            {
                cartesianScale = new XAttribute(Constants.CartesianScaleAttributeName, layer.AltUnit);
            }

            // If the Layer group is of type SKY (NOT PLANET) then LAT is DEC and Long is RA respectively.
            var layerElement = new XElement(
             Constants.LayerElementNodeName,
             new XAttribute(Constants.NameAttribute, layer.Name),
             new XAttribute(Constants.CoordinateTypeAttributeName, layer.CoordinatesType),
             new XAttribute(Constants.XAxisColumnAttributeName, layer.XAxis),
             new XAttribute(Constants.YAxisColumnAttributeName, layer.YAxis),
             new XAttribute(Constants.ZAxisColumnAttributeName, layer.ZAxis),
             new XAttribute(Constants.ReverseXAxisColumnAttributeName, layer.ReverseXAxis),
             new XAttribute(Constants.ReverseYAxisColumnAttributeName, layer.ReverseYAxis),
             new XAttribute(Constants.ReverseZAxisColumnAttributeName, layer.ReverseZAxis),
             new XAttribute(Constants.LatColumnAttributeName, layer.Group.IsPlanet() ? layer.LatColumn : layer.DecColumn),
             new XAttribute(Constants.LngColumnAttributeName, layer.Group.IsPlanet() ? layer.LngColumn : layer.RAColumn),
             new XAttribute(Constants.GeometryColumnAttributeName, layer.GeometryColumn),
             new XAttribute(Constants.ColorMapColumnAttributeName, layer.ColorMapColumn),
             new XAttribute(Constants.AltColumnAttributeName, layer.AltColumn),
             new XAttribute(Constants.StartDateColumnAttributeName, layer.StartDateColumn),
             new XAttribute(Constants.EndDateColumnAttributeName, layer.EndDateColumn),
             new XAttribute(Constants.SizeColumnAttributeName, layer.SizeColumn),
             new XAttribute(Constants.NameColumnAttributeName, layer.NameColumn),
             new XAttribute(Constants.DecayAttributeName, layer.TimeDecay),
             new XAttribute(Constants.ScaleFactorAttributeName, layer.ScaleFactor),
             new XAttribute(Constants.OpacityAttributeName, layer.Opacity),
             new XAttribute(Constants.StartTimeAttributeName, layer.StartTime.ToString()),
             new XAttribute(Constants.EndTimeAttributeName, layer.EndTime.ToString()),
             new XAttribute(Constants.FadeSpanAttributeName, layer.FadeSpan.ToString()),
             new XAttribute(Constants.ColorValueAttributeName, layer.Color),
             new XAttribute(Constants.AltTypeAttributeName, layer.AltType),
             new XAttribute(Constants.MarkerScaleAttributeName, layer.MarkerScale),
             new XAttribute(Constants.AltUnitAttributeName, layer.AltUnit),
             cartesianScale,
             new XAttribute(Constants.RAUnitAttributeName, layer.RAUnit),
             new XAttribute(Constants.PointScaleTypeAttributeName, layer.PointScaleType),
             new XAttribute(Constants.FadeTypeAttributeName, layer.FadeType),
             new XAttribute(Constants.MarkerTypeAttributeName, layer.PlotType),
             new XAttribute(Constants.MarkerIndexAttributeName, layer.MarkerIndex),
             new XAttribute(Constants.ShowFarSideAttributeName, layer.ShowFarSide));

            if (isTimeSeriesRequired)
            {
                layerElement.Add(new XAttribute(Constants.TimeSeriesAttributeName, layer.HasTimeSeries));
            }
            XElement root = new XElement(Constants.LCAPIElementName, layerElement);

            return root.ToString(SaveOptions.DisableFormatting);
        }
コード例 #25
0
 /// <summary>
 /// This function is used to set all layer properties of the layer.
 /// </summary>
 /// <param name="layer">
 /// Layer which is in focus.
 /// </param>
 /// <param name="listOfAttributes">
 /// Attributes of layer.
 /// </param>
 private static void SetLayerProperties(Layer layer, IEnumerable<XAttribute> listOfAttributes)
 {
     // If the Layer from Group SKY then the LAT is DEC and LON is RA respectively.
     // Process and update attributes in layer Details.
     foreach (XAttribute attribute in listOfAttributes)
     {
         switch (attribute.Name.LocalName)
         {
             case Constants.LatColumnAttributeName:
                 if (layer.Group.IsPlanet())
                 {
                     layer.LatColumn = attribute.Value.AsInteger(Constants.DefaultColumnIndex);
                 }
                 else
                 {
                     layer.DecColumn = attribute.Value.AsInteger(Constants.DefaultColumnIndex);
                 }
                 break;
             case Constants.LngColumnAttributeName:
                 if (layer.Group.IsPlanet())
                 {
                     layer.LngColumn = attribute.Value.AsInteger(Constants.DefaultColumnIndex);
                 }
                 else
                 {
                     layer.RAColumn = attribute.Value.AsInteger(Constants.DefaultColumnIndex);
                 }
                 break;
             case Constants.GeometryColumnAttributeName:
                 layer.GeometryColumn = attribute.Value.AsInteger(Constants.DefaultColumnIndex);
                 break;
             case Constants.ColorMapColumnAttributeName:
                 layer.ColorMapColumn = attribute.Value.AsInteger(Constants.DefaultColumnIndex);
                 break;
             case Constants.AltColumnAttributeName:
                 layer.AltColumn = attribute.Value.AsInteger(Constants.DefaultColumnIndex);
                 break;
             case Constants.StartDateColumnAttributeName:
                 layer.StartDateColumn = attribute.Value.AsInteger(Constants.DefaultColumnIndex);
                 break;
             case Constants.EndDateColumnAttributeName:
                 layer.EndDateColumn = attribute.Value.AsInteger(Constants.DefaultColumnIndex);
                 break;
             case Constants.SizeColumnAttributeName:
                 layer.SizeColumn = attribute.Value.AsInteger(Constants.DefaultColumnIndex);
                 break;
             case Constants.NameColumnAttributeName:
                 layer.NameColumn = attribute.Value.AsInteger(Constants.DefaultColumnIndex);
                 break;
             case Constants.NameAttribute:
                 layer.Name = attribute.Value;
                 break;
             case Constants.XAxisColumnAttributeName:
                 layer.XAxis = attribute.Value.AsInteger(Constants.DefaultColumnIndex);
                 break;
             case Constants.YAxisColumnAttributeName:
                 layer.YAxis = attribute.Value.AsInteger(Constants.DefaultColumnIndex);
                 break;
             case Constants.ZAxisColumnAttributeName:
                 layer.ZAxis = attribute.Value.AsInteger(Constants.DefaultColumnIndex);
                 break;
             case Constants.ReverseXAxisColumnAttributeName:
                 layer.ReverseXAxis = attribute.Value.AsBoolean(false);
                 break;
             case Constants.ReverseYAxisColumnAttributeName:
                 layer.ReverseYAxis = attribute.Value.AsBoolean(false);
                 break;
             case Constants.ReverseZAxisColumnAttributeName:
                 layer.ReverseZAxis = attribute.Value.AsBoolean(false);
                 break;
             case Constants.VersionAttribute:
                 layer.Version = attribute.Value.AsInteger(Constants.DefaultLayerVersion);
                 break;
         }
     }
 }
コード例 #26
0
 /// <summary>
 /// This function is used to set all marker properties of the layer.
 /// </summary>
 /// <param name="layer">
 /// Layer which is in focus.
 /// </param>
 /// <param name="listOfAttributes">
 /// Attributes of layer.
 /// </param>
 private static void SetMarkerProperties(Layer layer, IEnumerable<XAttribute> listOfAttributes)
 {
     // Process and update attributes in layer Details.
     foreach (XAttribute attribute in listOfAttributes)
     {
         switch (attribute.Name.LocalName)
         {
             case Constants.DecayAttributeName:
                 layer.TimeDecay = attribute.Value.AsDouble(Constants.DefaultTimeDecay);
                 break;
             case Constants.ScaleFactorAttributeName:
                 layer.ScaleFactor = attribute.Value.AsDouble(Constants.DefaultScaleFactor);
                 break;
             case Constants.OpacityAttributeName:
                 layer.Opacity = attribute.Value.AsDouble(Constants.DefaultOpacity);
                 break;
             case Constants.StartTimeAttributeName:
                 layer.StartTime = attribute.Value.AsDateTime(Constants.DefaultStartTime);
                 break;
             case Constants.EndTimeAttributeName:
                 layer.EndTime = attribute.Value.AsDateTime(Constants.DefaultEndTime);
                 break;
             case Constants.FadeSpanAttributeName:
                 layer.FadeSpan = attribute.Value.AsTimeSpan(Constants.DefaultFadeSpan);
                 break;
             case Constants.ColorValueAttributeName:
                 layer.Color = string.IsNullOrEmpty(attribute.Value) ? Constants.DefaultColor : attribute.Value;
                 break;
             case Constants.AltTypeAttributeName:
                 layer.AltType = attribute.Value.AsEnum<AltType>(AltType.Depth);
                 break;
             case Constants.MarkerScaleAttributeName:
                 layer.MarkerScale = attribute.Value.AsEnum<ScaleRelativeType>(ScaleRelativeType.World);
                 break;
             case Constants.CartesianScaleAttributeName:
                 // In case of non Spherical co-ordinates, value to be read from CartesianScale attribute.
                 if (layer.CoordinatesType != CoordinatesType.Spherical)
                 {
                     layer.AltUnit = attribute.Value.AsEnum<AltUnit>(AltUnit.Meters);
                 }
                 break;
             case Constants.AltUnitAttributeName:
                 // In case of Spherical co-ordinates, value to be read from AltUnit attribute.
                 if (layer.CoordinatesType == CoordinatesType.Spherical)
                 {
                     layer.AltUnit = attribute.Value.AsEnum<AltUnit>(AltUnit.Meters);
                 }
                 break;
             case Constants.RAUnitAttributeName:
                 layer.RAUnit = attribute.Value.AsEnum<AngleUnit>(AngleUnit.Hours);
                 break;
             case Constants.PointScaleTypeAttributeName:
                 layer.PointScaleType = attribute.Value.AsEnum<ScaleType>(ScaleType.Power);
                 break;
             case Constants.FadeTypeAttributeName:
                 layer.FadeType = attribute.Value.AsEnum<FadeType>(FadeType.None);
                 break;
             case Constants.MarkerIndexAttributeName:
                 layer.MarkerIndex = attribute.Value.AsInteger(Constants.DefaultMarkerIndex);
                 break;
             case Constants.MarkerTypeAttributeName:
                 layer.PlotType = attribute.Value.AsEnum<MarkerType>(MarkerType.Gaussian);
                 break;
             case Constants.ShowFarSideAttributeName:
                 layer.ShowFarSide = attribute.Value.AsBoolean(false);
                 break;
             case Constants.CoordinateTypeAttributeName:
                 layer.CoordinatesType = attribute.Value.AsEnum<CoordinatesType>(CoordinatesType.Spherical);
                 break;
             case Constants.TimeSeriesAttributeName:
                 layer.HasTimeSeries = attribute.Value.AsBoolean(false);
                 break;
         }
     }
 }
コード例 #27
0
        public void UpdateLayerMapPropertiesTest()
        {
            Layer layer = new Layer();
            Layer dummyLayer = new Layer();
            LayerMap expected = new LayerMap(dummyLayer);

            // UpdateLayerMapProperties will set the layer in layer details.
            expected.UpdateLayerMapProperties(layer);

            // LayerDetails should not be dummy layer. It should be set with layer object.
            Assert.AreEqual(expected.LayerDetails, layer);
        }
コード例 #28
0
        /// <summary>
        /// This function is used to update the layer header in WWT using LCAPI.
        /// </summary>
        /// <param name="layerDetails">
        /// Details of the layer.
        /// </param>
        /// <param name="isConsumeException">
        /// Whether to consume exception?
        /// </param>
        /// <param name="isTimeSeriesRequired">
        /// Whether to time series is required or not.
        /// Time series is set explicitly only when a layer is created.
        /// </param>
        /// <returns>
        /// True if the layer is updated; otherwise false.
        /// </returns>
        public static bool UpdateLayer(Layer layerDetails, bool isConsumeException, bool isTimeSeriesRequired)
        {
            bool isValid = false;
            if (layerDetails != null)
            {
                // Create a new layer with a data format
                string url = string.Format(
                    System.Globalization.CultureInfo.InvariantCulture,
                    Constants.UpdateLayerCommand,
                    Globals.TargetMachine.MachineIP,
                    layerDetails.ID);

                string header = Constants.XmlHeaderTag + GetLayerProperties(layerDetails, isTimeSeriesRequired);
                string response = request.Send(url, header, isConsumeException);
                isValid = IsValidResponse(response);
            }

            return isValid;
        }
コード例 #29
0
        public void AddLayerNodeTest()
        {
            Application application = new Application();

            try
            {
                // Where ever we are creating object for WorkflowController_Accessor, we need to set the ThisAddIn_Accessor.ExcelApplication to
                // wither null or actual application object.
                ThisAddIn_Accessor.ExcelApplication = application;
                List<GroupChildren> groups = new List<GroupChildren>();
                List<GroupChildren> nestedGroups = new List<GroupChildren>();

                Group parentGroup = new Group("Earth", GroupType.ReferenceFrame, null);
                Layer layer = new Layer();
                layer.Name = "Layer1";
                layer.Group = parentGroup;

                LayerMap_Accessor localLayerMap = new LayerMap_Accessor(layer);
                localLayerMap.MapType = LayerMapType.Local;
                localLayerMap.RangeDisplayName = "Sheet_1";

                Group childGroup = new Group("Earth", GroupType.ReferenceFrame, parentGroup);
                Layer nestedLayer = new Layer();
                nestedLayer.Name = "Layer1";
                nestedLayer.Group = childGroup;

                LayerMap_Accessor nestedLayerMap = new LayerMap_Accessor(nestedLayer);
                nestedLayerMap.MapType = LayerMapType.Local;
                nestedLayerMap.RangeDisplayName = "Sheet_1";

                LayerMapExtensions_Accessor.AddLayerNode(groups, localLayerMap);
                LayerMapExtensions_Accessor.AddLayerNode(nestedGroups, nestedLayerMap);

                Assert.AreEqual(1, groups.Count);
                foreach (GroupChildren group in groups)
                {
                    Assert.AreEqual("Earth", group.Name);
                    Assert.AreEqual(1, group.AllChildren.Count);
                    foreach (LayerMap layerVal in group.AllChildren)
                    {
                        Assert.AreEqual("Layer1", layerVal.LayerDetails.Name);
                    }
                }

                Assert.AreEqual(1, nestedGroups.Count);
                foreach (GroupChildren group in nestedGroups)
                {
                    Assert.AreEqual("Earth", group.Name);
                    Assert.AreEqual(1, group.Children.Count);
                }
            }
            finally
            {
                application.Close();
            }
        }
コード例 #30
0
 public void StartDateColumnTest()
 {
     Layer target = new Layer();
     int expected = 7;
     target.StartDateColumn = expected;
     int actual = target.StartDateColumn;
     Assert.AreEqual(expected, actual);
 }