Ejemplo n.º 1
0
 void OnDeserialized(StreamingContext context)
 {
     if (!Layers.Any(lyr => lyr.Handler.GetType().Equals(typeof(RazerLayerHandler))))
     {
         Layers.Add(new Layer("Chroma Lighting", new RazerLayerHandler()));
     }
 }
Ejemplo n.º 2
0
 void OnDeserialized(StreamingContext context)
 {
     if (!Layers.Any(lyr => lyr.Handler.GetType().Equals(typeof(Aurora.Settings.Layers.WrapperLightsLayerHandler))))
     {
         Layers.Add(new Layer("Wrapper Lighting", new Aurora.Settings.Layers.WrapperLightsLayerHandler()));
     }
 }
Ejemplo n.º 3
0
        public bool ContainsAnythingNamed(string name)
        {
            if (Layers.Any(l => _comparer.Compare(l.Name, name) == 0))
            {
                return(true);
            }

            return(Layers.Any(l => l.ContainsAnythingNamed(name)));
        }
Ejemplo n.º 4
0
        override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            if (!_isLoaded)
            {
                _isLoaded = true;

                if (CompatUtility.IsDesignMode && (Layers == null || !Layers.Any()))
                {
                    if (_legendTree.LayerItems == null)
                    {
                        // Create a basic hierarchy for design :  Map Layer -> SubLayer -> LegendItemViewModel
                        var legendItem1 = new LegendItemViewModel
                        {
                            Label  = "LegendItem1",
                            Symbol = new SimpleMarkerSymbol {
                                Style = SimpleMarkerStyle.Circle, Color = Colors.Red
                            }
                        };
                        var legendItem2 = new LegendItemViewModel
                        {
                            Label  = "LegendItem2",
                            Symbol = new SimpleMarkerSymbol {
                                Style = SimpleMarkerStyle.Diamond, Color = Colors.Green
                            }
                        };

                        var layerItem = new LayerItemViewModel
                        {
                            Label       = "LayerItem",
                            LegendItems = new ObservableCollection <LegendItemViewModel> {
                                legendItem1, legendItem2
                            }
                        };

                        var mapLayerItem = new LayerItemViewModel
                        {
                            Label      = "MapLayerItem",
                            LayerType  = MapLayerItem.MapLayerType,
                            LayerItems = new ObservableCollection <LayerItemViewModel> {
                                layerItem
                            },
                        };

                        _legendTree.LayerItems = new ObservableCollection <LayerItemViewModel> {
                            mapLayerItem
                        };
                    }
                }
                else
                {
                    // Initialize the Map now that all parameters are well known
                    _legendTree.Layers = Layers;
                }
            }
        }
Ejemplo n.º 5
0
        public void AddLayer(Layer newLayer)
        {
            if (Layers.Any())
            {
                var lastLayer = Layers.Last();
                newLayer.ConnectLayers(lastLayer);
            }

            Layers.Add(newLayer);
        }
        //--------------------------------------------------------------------------------------------------

        public void Add(Layer layer)
        {
            if (Layers.Any(l => l.Guid == layer.Guid))
            {
                return;
            }

            CoreContext.Current?.UndoHandler?.AddTopologyChange(UndoHandler.TopologyAction.Added, this, layer);
            layer.Collection = this;
            Layers.Add(layer);
            CollectionChanged?.Invoke(this, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, layer, Layers.IndexOf(layer)));
        }
Ejemplo n.º 7
0
        public void AddLayer(ILayer newLayer)
        {
            if (Layers.Any())
            {
                newLayer.ConnectTo(OutputLayer);
            }
            else
            {
                newLayer.ConnectTo(InputLayer);
            }

            Layers.Add(newLayer);
            //_neuronErrors.Add(_layers.Count - 1, new double[newLayer.Neurons.Count]);
        }
Ejemplo n.º 8
0
        public void AddLayer(ILayer layer)
        {
            if (layer == null)
            {
                throw new ArgumentNullException("layer");
            }
            if (Layers.Any() && NumOutputs != layer.NumInputs)
            {
                throw new InvalidOperationException(string.Format(
                                                        "Expected layer to take {0} inputs, but it takes {1}",
                                                        NumOutputs, layer.NumInputs));
            }

            m_layers.Add(layer);
        }
Ejemplo n.º 9
0
 private string EnsureUniqueName(string name)
 {
     if (Layers.Any(x => x.LayerName == name))
     {
         string originalName = name;
         bool   unique;
         int    counter = 2;
         do
         {
             name   = string.Format("{0} - {1}", originalName, counter++);
             unique = Layers.All(x => x.LayerName != name);
         } while (!unique);
     }
     return(name);
 }
Ejemplo n.º 10
0
        public override void OnMouseUp(Coordinate worldPosition, MouseEventArgs e)
        {
            if (!Layers.Any())
            {
                return;
            }

            if (!isBusy)
            {
                return;
            }
            if (null == snapResult)
            {
                MapControl.SelectTool.Clear();
            }
            else
            {
                newNetworkFeature = (IPoint)GeometryHelper.SetCoordinate(newNetworkFeature, 0, snapResult.Location);

                var      layer = Layers.First();
                IFeature feature;
                if (GetFeaturePerProvider != null && layer.DataSource is FeatureCollection)
                {
                    feature = GetFeaturePerProvider(newNetworkFeature).First(); //ToDo: give the user the option to choose a provider (read model)
                    if (feature != null)
                    {
                        ((FeatureCollection)layer.DataSource).Add(feature);
                    }
                }
                else
                {
                    feature = layer.DataSource.Add(newNetworkFeature);
                }

                if (feature == null)
                {
                    isBusy = false;
                    return;
                }

                layer.RenderRequired = true;
                MapControl.SelectTool.Select(layer, feature);
            }
            isBusy = false;
            StopDrawing();
            MapControl.Refresh();
        }
Ejemplo n.º 11
0
        protected virtual void WriteHtml(HtmlTextWriter writer)
        {
            if (writer == null)
            {
                throw new ArgumentNullException("writer");
            }

            IHtmlNode rootTag = builder.Build();

            rootTag.WriteTo(writer);

            var languaje      = (Culture != null) ? "&language=" + Culture.TwoLetterISOLanguageName : String.Empty;
            var key           = (ApiKey.HasValue()) ? "&key=" + ApiKey : String.Empty;
            var visualization = Layers.Any(l => l.GetType() == typeof(HeatmapLayer)) ? "&libraries=visualization" : "";
            var isAjax        = builder.ViewContext.HttpContext.Request.IsAjaxRequest() ? "&callback=executeAsync" : "";
            var version       = (String.IsNullOrWhiteSpace(Version)) ? "" : ("v=" + Version);
            var mainJs        = String.Format("https://maps.googleapis.com/maps/api/js?{0}{1}{2}{3}{4}", version, key, languaje, visualization, isAjax);

            ScriptFileNames.Add(mainJs);

            if (EnableMarkersClustering)
            {
                ScriptFileNames.Add("markerclusterer.js");
            }

            if (Markers.Any(m => m.Window != null))
            {
                //Build Container for InfoWindows
                IHtmlNode infoWindowsRootTag = new HtmlElement("div")
                                               .Attribute("id", String.Format("{0}-InfoWindowsHolder", Id))
                                               .Attribute("style", "display: none");

                Markers.Where(m => m.Window != null).Each(m =>
                {
                    IHtmlNode markerInfoWindows = new HtmlElement("div")
                                                  .Attribute("id", String.Format("{0}Marker{1}", Id, m.Index))
                                                  .AddClass("content");

                    m.Window.Template.Apply(markerInfoWindows);
                    infoWindowsRootTag.Children.Add(markerInfoWindows);
                });

                infoWindowsRootTag.WriteTo(writer);
            }
        }
Ejemplo n.º 12
0
        private void BandOnPropertyChanged(object sender, PropertyChangedEventArgs propertyChangedEventArgs)
        {
            if (propertyChangedEventArgs.PropertyName != nameof(CreateLayerViewModel.R) &&
                propertyChangedEventArgs.PropertyName != nameof(CreateLayerViewModel.G) &&
                propertyChangedEventArgs.PropertyName != nameof(CreateLayerViewModel.B))
            {
                return;
            }

            foreach (var band in Layers)
            {
                band.PropertyChanged -= BandOnPropertyChanged;

                if (band == sender)
                {
                    band.R = propertyChangedEventArgs.PropertyName == nameof(CreateLayerViewModel.R);
                    band.G = propertyChangedEventArgs.PropertyName == nameof(CreateLayerViewModel.G);
                    band.B = propertyChangedEventArgs.PropertyName == nameof(CreateLayerViewModel.B);
                }
                else
                {
                    switch (propertyChangedEventArgs.PropertyName)
                    {
                    case nameof(CreateLayerViewModel.R):
                        band.R = false;
                        break;

                    case nameof(CreateLayerViewModel.G):
                        band.G = false;
                        break;

                    case nameof(CreateLayerViewModel.B):
                        band.B = false;
                        break;
                    }
                }
                band.PropertyChanged += BandOnPropertyChanged;
            }

            AllRgbChannelsAdded = Layers.Any(b => b.R) && Layers.Any(b => b.G) && Layers.Any(b => b.B);
        }
Ejemplo n.º 13
0
        public void Update(IReadOnlyList <float> inputs)
        {
            if (inputs == null)
            {
                throw new ArgumentNullException("inputs");
            }
            if (!Layers.Any())
            {
                throw new InvalidOperationException("The network has no layers");
            }
            if (inputs.Count != NumInputs)
            {
                throw new InvalidOperationException(string.Format(
                                                        "Expected {0} inputs, got {1}", NumInputs, inputs.Count));
            }

            foreach (var layer in Layers)
            {
                layer.Update(inputs);
                inputs = layer.Outputs;
            }
        }
Ejemplo n.º 14
0
        public void AddLayer(BaseLayer layer)
        {
            Shape inputShape;

            if (Layers.Any())
            {
                var lastLayer = _layers.Last();
                inputShape     = lastLayer.OutputShape;
                layer.Prev     = lastLayer;
                lastLayer.Next = layer;
            }
            else
            {
                inputShape = InputShape;
            }

            if (!layer.IsInit)
            {
                layer.Initialize(inputShape);
            }
            _layers.Add(layer);
        }
Ejemplo n.º 15
0
        public virtual void WriteInitializationScript(TextWriter writer)
        {
            var currentCulture = Thread.CurrentThread.CurrentCulture;

            Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");

            var objectWriter = new ClientSideObjectWriter(Id, "GoogleMap", writer);

            objectWriter.Start();

            objectWriter.Append("clientId", Id);
            objectWriter.Append("disableDoubleClickZoom", DisableDoubleClickZoom, false);
            objectWriter.Append("draggable", Draggable, true);
            objectWriter.Append("enableMarkersClustering", EnableMarkersClustering, false);
            objectWriter.Append("markersFromAddress", MarkersGeocoding, false);
            objectWriter.Append("fitToMarkersBounds", FitToMarkersBounds, false);

            if (Address.HasValue())
            {
                objectWriter.AppendObject("center", new { Address });
            }
            else
            {
                objectWriter.AppendObject("center", new { Latitude, Longitude, UseCurrentPosition });
            }

            objectWriter.Append("mapTypeId", MapTypeId);
            objectWriter.Append("mapTypeControlPosition", MapTypeControlPosition, ControlPosition.TopRight);
            objectWriter.Append("mapTypeControlVisible", MapTypeControlVisible, true);
            objectWriter.Append("mapTypeControlStyle", MapTypeControlStyle, MapTypeControlStyle.Default);

            if (Layers.Any())
            {
                var layers = new List <IDictionary <string, object> >();

                Layers.Each(l => layers.Add(l.CreateSerializer().Serialize()));

                if (layers.Any())
                {
                    objectWriter.AppendCollection("layers", layers);
                }
            }

            if (ImageMapTypes.Any())
            {
                if (!ImageMapTypes.Select(mt => mt.MapTypeName).Contains(MapTypeId))
                {
                    throw new Exception("Cannot find the MapTypeId in the ImageMapTypes collection");
                }

                var mapTypes = new List <IDictionary <string, object> >();

                ImageMapTypes.Each(m => mapTypes.Add(m.CreateSerializer().Serialize()));

                if (mapTypes.Any())
                {
                    objectWriter.AppendCollection("imageMapTypes", mapTypes);
                }
            }

            if (StyledMapTypes.Any())
            {
                var mapTypes = new List <IDictionary <string, object> >();

                StyledMapTypes.Each(m => mapTypes.Add(m.CreateSerializer().Serialize()));

                if (mapTypes.Any())
                {
                    objectWriter.AppendCollection("styledMapTypes", mapTypes);
                }
            }

            objectWriter.Append("panControlPosition", PanControlPosition, ControlPosition.TopLeft);
            objectWriter.Append("panControlVisible", PanControlVisible, true);

            objectWriter.Append("overviewMapControlVisible", OverviewMapControlVisible, false);
            objectWriter.Append("overviewMapControlOpened", OverviewMapControlOpened, false);

            objectWriter.Append("streetViewControlVisible", StreetViewControlVisible, true);
            objectWriter.Append("streetViewControlPosition", StreetViewControlPosition, ControlPosition.TopLeft);

            objectWriter.Append("zoomControlVisible", ZoomControlVisible, true);
            objectWriter.Append("zoomControlPosition", ZoomControlPosition, ControlPosition.TopLeft);
            objectWriter.Append("zoomControlStyle", ZoomControlStyle, ZoomControlStyle.Default);


            objectWriter.Append("scaleControlVisible", ScaleControlVisible, false);
            objectWriter.Append("zoom", (Zoom == 0) ? 6 : Zoom, 6);
            objectWriter.Append("minZoom", MinZoom, 0);
            objectWriter.Append("maxZoom", MaxZoom, 0);

            if (EnableMarkersClustering)
            {
                objectWriter.AppendObject("markerClusteringOptions", MarkerClusteringOptions.Serialize());
            }

            if (Markers.Any())
            {
                var markers = new List <IDictionary <string, object> >();
                int i       = 0;
                Markers.Each(m =>
                {
                    if (String.IsNullOrWhiteSpace(m.Id))
                    {
                        m.Id = i.ToString();
                    }
                    markers.Add(m.CreateSerializer().Serialize());
                    i++;
                });

                if (markers.Any())
                {
                    objectWriter.AppendCollection("markers", markers);
                }

                objectWriter.AppendClientEventObject("markerEvents", this.MarkerClientEvents);
            }

            if (Polygons.Any())
            {
                var polygons = new List <IDictionary <string, object> >();

                Polygons.Each(p => polygons.Add(p.CreateSerializer().Serialize()));

                if (polygons.Any())
                {
                    objectWriter.AppendCollection("polygons", polygons);
                }
            }

            if (Circles.Any())
            {
                var circles = new List <IDictionary <string, object> >();

                Circles.Each(c => circles.Add(c.CreateSerializer().Serialize()));

                if (circles.Any())
                {
                    objectWriter.AppendCollection("circles", circles);
                }
            }

            this.ClientEvents.SerializeTo(objectWriter);

            //TODO: Call a virtual method OnCompleting to allow derived class to inject its own json objects

            objectWriter.Complete();

            Thread.CurrentThread.CurrentCulture = currentCulture;
        }