Exemplo n.º 1
0
 /// <summary>
 /// Adds the specified layer
 /// </summary>
 /// <param name="layer"></param>
 public void Add(RuntimeMapLayer layer)
 {
     if (!Contains(layer))
     {
         var sel = new LayerSelection(layer);
         Add(sel);
     }
 }
Exemplo n.º 2
0
    void Start()
    {
        active   = Color.green;
        inactive = Color.white;

        quizOptions.gameObject.SetActive(false);
        counter.gameObject.SetActive(false);
        value.gameObject.SetActive(false);
        questionText.gameObject.SetActive(false);
        questionValue.gameObject.SetActive(false);
        points.gameObject.SetActive(false);
        pointsValue.gameObject.SetActive(false);
        pointer.gameObject.SetActive(false);

        mapSelection = GetComponent <MapSelection>();
        meshRenderer = display.GetComponent <MeshRenderer>();
        bOrto        = mapSelection.bOrto;
        bHipso       = mapSelection.bHipso;
        bRegio       = mapSelection.bRegio;

        cityLayerSelection = GetComponent <LayerSelection>();
        bCity               = cityLayerSelection.bCity;
        cityName            = cityLayerSelection.cityName;
        waterLayerSelection = GetComponent <LayerSelection>();
        bWater              = waterLayerSelection.bWater;
        waterName           = waterLayerSelection.waterName;
        regioLayerSelection = GetComponent <LayerSelection>();
        bbRegio             = regioLayerSelection.bRegio;
        regioName           = regioLayerSelection.regioName;
        sevLayerSelection   = GetComponent <LayerSelection>();
        bSev    = sevLayerSelection.bSev;
        sevName = sevLayerSelection.sevName;


        int i = 0;

        objects = new Transform[137];
        for (i = 0; i < citiesDisplay.transform.childCount; i++)
        {
            objects[i] = citiesDisplay.gameObject.transform.GetChild(i);
        }
        for (i = citiesDisplay.transform.childCount; i < citiesDisplay.transform.childCount + waterDisplay.transform.childCount; i++)
        {
            objects[i] = waterDisplay.gameObject.transform.GetChild(i - citiesDisplay.transform.childCount);
        }
        for (i = citiesDisplay.transform.childCount + waterDisplay.transform.childCount; i < citiesDisplay.transform.childCount + waterDisplay.transform.childCount + regioDisplay.transform.childCount; i++)
        {
            objects[i] = regioDisplay.gameObject.transform.GetChild(i - citiesDisplay.transform.childCount - waterDisplay.transform.childCount);
        }
        for (i = citiesDisplay.transform.childCount + waterDisplay.transform.childCount + regioDisplay.transform.childCount; i < citiesDisplay.transform.childCount + waterDisplay.transform.childCount + regioDisplay.transform.childCount + sevDisplay.transform.childCount; i++)
        {
            objects[i] = sevDisplay.gameObject.transform.GetChild(i - citiesDisplay.transform.childCount - waterDisplay.transform.childCount - regioDisplay.transform.childCount);
        }
    }
Exemplo n.º 3
0
        /// <summary>
        /// Removes the specified layer selection
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        public bool Remove(LayerSelection item)
        {
            int ix = IndexOf(item);

            if (ix < 0)
            {
                return(false);
            }

            _layers.RemoveAt(ix);
            return(true);
        }
 private void RefreshSelectionOIDs(IEnumerable <long> oids)
 {
     FieldAttributes.Clear();
     SetProperty(ref _selectedOID, null, () => SelectedOID);
     LayerSelection.Clear();
     lock (_lock)
     {
         foreach (var oid in oids)
         {
             LayerSelection.Add(oid);
         }
     }
 }
 private Task SelectedLayerChanged()
 {
     return(QueuedTask.Run(() =>
     {
         if (SelectedLayer == null)
         {
             RefreshSelectionOIDs(new List <long>());
         }
         else
         {
             var selection = SelectedLayer.GetSelection();
             RefreshSelectionOIDs(selection.GetObjectIDs());
         }
         SelectedOID = LayerSelection.FirstOrDefault();
     }));
 }
Exemplo n.º 6
0
                    public static LayerSelection FromBaseObject(BaseObject baseObj)
                    {
                        if (baseObj == null || baseObj.NativeObject == IntPtr.Zero)
                        {
                            return(null);
                        }
                        LayerSelection obj = baseObj as  LayerSelection;

                        if (object.Equals(obj, null))
                        {
                            obj = new LayerSelection(CreatedWhenConstruct.CWC_NotToCreate);
                            obj.BindNativeObject(baseObj.NativeObject, "CLayerSelection");
                            obj.IncreaseCast();
                        }

                        return(obj);
                    }
        private Task UpdateForActiveMap(bool activeMapChanged = true, Dictionary <MapMember, List <long> > mapSelection = null)
        {
            return(QueuedTask.Run(() =>
            {
                SelectedLayerInfo selectedLayerInfo = null;
                if (!_selectedLayerInfos.ContainsKey(_activeMap))
                {
                    selectedLayerInfo = new SelectedLayerInfo();
                    _selectedLayerInfos.Add(_activeMap, selectedLayerInfo);
                }
                else
                {
                    selectedLayerInfo = _selectedLayerInfos[_activeMap];
                }

                if (activeMapChanged)
                {
                    RefreshLayerCollection();

                    SetProperty(ref _selectedLayer, (selectedLayerInfo.SelectedLayer != null) ? selectedLayerInfo.SelectedLayer : Layers.FirstOrDefault(), () => SelectedLayer);
                    if (_selectedLayer == null)
                    {
                        FrameworkApplication.SetCurrentToolAsync("esri_mapping_exploreTool");
                        return;
                    }
                    selectedLayerInfo.SelectedLayer = SelectedLayer;
                }

                if (SelectedLayer == null)
                {
                    RefreshSelectionOIDs(new List <long>());
                }
                else
                {
                    List <long> oids = new List <long>();
                    if (mapSelection != null)
                    {
                        if (mapSelection.ContainsKey(SelectedLayer))
                        {
                            oids.AddRange(mapSelection[SelectedLayer]);
                        }
                    }
                    else
                    {
                        oids.AddRange(SelectedLayer.GetSelection().GetObjectIDs());
                    }
                    RefreshSelectionOIDs(oids);
                }

                SetProperty(ref _selectedOID, (selectedLayerInfo.SelectedOID != null && LayerSelection.Contains(selectedLayerInfo.SelectedOID)) ? selectedLayerInfo.SelectedOID : LayerSelection.FirstOrDefault(), () => SelectedOID);
                selectedLayerInfo.SelectedOID = SelectedOID;
                ShowAttributes();
            }));
        }
Exemplo n.º 8
0
        public void DoLayout(SVGLayer[] layers, LayerSelection layerSelection)
        {
            if (layers == null)
            {
                return;
            }

            float width  = EditorGUIUtility.currentViewWidth - 55f;
            float height = itemHeight * Mathf.Min(layers.Length, maxVisibleItems);

            Rect rect = GUILayoutUtility.GetRect(width, height);

            rect.width = width;
            Rect finRect = new Rect(rect.position.x - rect.width * 0.5f, rect.position.y - itemHeight * 0.5f, rect.width, itemHeight);

            int layersLength = scrollIndex + Mathf.Clamp(layers.Length - scrollIndex, 0, maxVisibleItems);
            int index        = 0;

            if (rect.Contains(Event.current.mousePosition))
            {
                hilightedLayer = Mathf.Clamp(Mathf.FloorToInt((Event.current.mousePosition.y - rect.y) / itemHeight), 0, layers.Length);
                if (Event.current.type == EventType.ScrollWheel)
                {
                    scrollIndex = Mathf.Clamp(scrollIndex + (int)Mathf.Sign(Event.current.delta.y), 0, layers.Length);
                    Event.current.Use();
                }
            }
            else
            {
                hilightedLayer = -1;
            }

            bool selected;
            bool lastSelected;

            for (int i = scrollIndex; i < layersLength; i++)
            {
                finRect.x = rect.x;
                finRect.y = rect.y + index * itemHeight;

                lastSelected = layerSelection.Contains(i);
                selected     = GUI.Toggle(finRect, layerSelection.Contains(i), GUIContent.none);
                if (selected != lastSelected)
                {
                    if (selected)
                    {
                        layerSelection.Add(i);
                    }
                    else
                    {
                        layerSelection.Remove(i);
                    }
                }

                finRect.x += itemHeight;
                GUI.Label(finRect, i + " " + layers[i].name);
                index++;
            }

            if (layers.Length > maxVisibleItems)
            {
                finRect.x      = width + 20;
                finRect.y      = rect.y;
                finRect.width  = 35f;
                finRect.height = rect.height;
                scrollIndex    = Mathf.Clamp((int)GUI.VerticalScrollbar(finRect, scrollIndex, maxVisibleItems, 0f, layers.Length), 0, layers.Length);
            }
            else
            {
                scrollIndex = 0;
            }
        }
Exemplo n.º 9
0
 /// <summary>
 /// Gets whether this selection contains the specified layer selection
 /// </summary>
 /// <param name="item"></param>
 /// <returns></returns>
 public bool Contains(LayerSelection item) => IndexOf(item) >= 0;
Exemplo n.º 10
0
 /// <summary>
 /// Inserts a selection layer into the collection
 /// </summary>
 /// <param name="index">The index to place the item at</param>
 /// <param name="item">The item to insert</param>
 public void Insert(int index, LayerSelection item) => _layers.Insert(index, item);
Exemplo n.º 11
0
 /// <summary>
 /// Returns the index of the given layer
 /// </summary>
 /// <param name="item">The layer to look for</param>
 /// <returns>The index of the layer, or -1 if the layer is not in the collection</returns>
 public int IndexOf(LayerSelection item) => IndexOf(item.Layer);
Exemplo n.º 12
0
                    public BaseObject Create()
                    {
                        LayerSelection emptyInstance = new LayerSelection(CreatedWhenConstruct.CWC_NotToCreate);

                        return(emptyInstance);
                    }