/// <summary>
        /// Event handler for layer selection changes.
        /// </summary>
        private void SelectedLayersChanged(ArcGIS.Desktop.Mapping.Events.MapViewEventArgs mapViewArgs)
        {
            State state = (FrameworkApplication.Panes.ActivePane != null) ? FrameworkApplication.Panes.ActivePane.State : null;

            if (state != null)
            {
                IReadOnlyList <Layer> selectedLayers = mapViewArgs.MapView.GetSelectedLayers();
                if (selectedLayers.Count == 1)
                {
                    state.Activate("esri_custom_mutipleLayersNotSelectedState");
                }
                else
                {
                    state.Deactivate("esri_custom_mutipleLayersNotSelectedState");
                    return;
                }

                Layer firstSelectedLayer = selectedLayers.First();
                if (firstSelectedLayer != null)
                {
                    if (firstSelectedLayer is ImageServiceLayer && !(firstSelectedLayer is ImageMosaicSubLayer))
                    {
                        state.Activate("esri_custom_imageServiceLayerSelectedState");
                    }
                    else
                    {
                        state.Deactivate("esri_custom_imageServiceLayerSelectedState");
                    }
                }
                else
                {
                    state.Deactivate("esri_custom_imageServiceLayerSelectedState");
                }
            }
        }
Example #2
0
    private bool changingStock; // True if the stock is currently changing

    /*
     * PUBLIC INTERFACE
     */

    public virtual void StartStockChange()
    {
        bool alreadyChangingStock = changingStock;

        changingStock = true;
        stockChangeNotReady.Activate(timeBetweenChanges);

        // If the stock was not already chaning, invoke change started event
        if (!alreadyChangingStock)
        {
            changeStartedEvent.Invoke();
        }
    }
Example #3
0
 public GenericUserInterface(string layerName)
 {
     State = CreateState();
     SetState(State);
     State.Activate();
     LayerName = string.Format("{0}: {1}", Terraria3D.Instance.DisplayName, layerName);
 }
Example #4
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="NewState"></param>
 public void SwitchState(State NewState)
 {
     if (_window.ActiveState != null)
     {
         _window.ActiveState.Deactivate(NewState);
     }
     NewState.Activate(_window.ActiveState);
     _window.ActiveState = NewState;
 }
Example #5
0
 public void GoTo(State nextState)
 {
     if (currentState != nextState)
     {
         currentState?.Deactivate();
         currentState = nextState;
         Debug.Log("Transition to " + currentState.GetType().ToString());
         currentState.Activate();
     }
     else
     {
         Debug.LogWarning("Cannot go to already active state");
     }
 }
    private Vector2 fromPointToHere = new Vector2();    // Points from the point of blowback to the position of this mover

    // Move in the direction, speed, and for the time specifed
    // Additional functionality locks movement of the mover until blowback is finished
    public void ApplyForce(Vector2 direction, float speed, float time = DEFAULT_BLOWBACK_TIME)
    {
        // Disable the blownback state and move according to the move towards method
        if (_isForced)
        {
            Stop();
        }
        MoveTowards(direction, speed);

        // Activate the blowback state and schedule the object to stop moving when finished
        _isForced.Activate(time);
        CancelInvoke();
        Invoke("Stop", time);
    }
Example #7
0
    public void GoTo <T>() where T : State
    {
        State nextState = FindObjectOfType <T>();

        if (currentState != nextState)
        {
            currentState?.Deactivate();
            currentState = nextState;
            Debug.Log("Transition to " + currentState.GetType().ToString());
            currentState.Activate();
        }
        else
        {
            Debug.LogWarning("Cannot go to already active state");
        }
    }
    public void ChangeState <T> () where T : State
    {
        if (state != null)
        {
            state.enabled = false;
        }
        T s = GetComponent <T>();

        if (s == null)
        {
            s = gameObject.AddComponent <T>();
        }
        else
        {
            s.enabled = true;
        }
        state = s;
        state.Activate();
    }
Example #9
0
 /// <summary>
 /// 激活使用,此时排除其他对象对该实例的使用
 /// </summary>
 public virtual void Activate()
 {
     State.Activate(this);
 }