// Sets the button's visual state to match its value. protected virtual void SetButtonState() { int prevState = (int)state; state = controlIsEnabled ? (btnValue ? CONTROL_STATE.True : CONTROL_STATE.False) : CONTROL_STATE.Disabled; int index = (int)state; // First see if we need to postpone this state // change for when we are active: if (!gameObject.active) { stateChangeWhileDeactivated = true; return; } this.UseStateLabel(index); // End any current transition: if (prevTransition != null) { prevTransition.StopSafe(); } StartTransition(index, prevState); }
// animates the open animation private void UpdateAnimateIn(float deltaTime) { if (transform.position.y < m_targetYPos) { float nextY = transform.position.y + (deltaTime * k_movementSpeed); if (nextY >= m_targetYPos) { nextY = m_targetYPos; } transform.position = new Vector3(transform.position.x, nextY, transform.position.z); } if (transform.localScale.x < m_targetScale) { float nextScale = transform.localScale.x + (deltaTime * 0.025f); if (nextScale >= m_targetScale) { nextScale = m_targetScale; } transform.localScale = new Vector3(nextScale, nextScale, nextScale); } if ((transform.position.y == m_targetYPos) && (transform.localScale.x == m_targetScale)) { m_currState = CONTROL_STATE.FULLY_VISIBLE; } }
// Sets the layers to represent the current control state // (includes states not directly supported by the control // itself, such as Over and Active) protected void SetLayerState(CONTROL_STATE s) { // Skip if redundant: if (s == layerState) { return; } layerState = s; // This index is valid for our layers as // they can also support "Over" and "Active": int layerIndex = (int)layerState; // Loop through each layer and set its state, // provided we have a valid index for that state: for (int i = 0; i < layers.Length; ++i) { if (-1 != stateIndices[i, layerIndex]) { layers[i].Hide(IsHidden()); layers[i].SetState(stateIndices[i, layerIndex]); } else { layers[i].Hide(true); } } }
// Queues a transition to play following the previous (currently-running) transition protected void QueueTransition(int newState, int prevState, bool suppressTransition) { if (deleted) { return; } nextTransition = transitions[newState].list[DetermineNextTransition(newState, prevState)]; nextState = (CONTROL_STATE)newState; if (suppressTransition) { prevTransition.End(); prevTransition = nextTransition; prevTransition.Start(); prevTransition.End(); // Immediately place the transition into its "end state". return; } // See if we've already queued to run a follow-up transition: if (!transitionQueued) { prevTransition.AddTransitionEndDelegate(RunFollowupTrans); } transitionQueued = true; }
// Sets the control to its disabled appearance: protected void DisableMe() { // The disabled state is the last in the state list: SetState(states.Length - 1); // Set the label: this.UseStateLabel(states.Length - 1); // Set the layer states: for (int i = 0; i < layers.Length; ++i) { if (stateIndices[i, states.Length - 1] != -1) { layers[i].SetState(stateIndices[i, states.Length - 1]); } } // End any current transition: if (prevTransition != null) { prevTransition.StopSafe(); } StartTransition((int)CONTROL_STATE.Disabled, (int)state); state = CONTROL_STATE.Disabled; }
// Sets the button's visual state to match its value. protected virtual void SetButtonState(bool suppressTransition) { // Make sure we have a mesh: if (spriteMesh == null) { return; } // Make sure we're initialized since // we might have been called as a result of // another button in our group settings its // value on Start() before we've had a cance // to Start() ourselves, meaning we may lack // important info like a valid screensize, // etc. which is necessary for sizing or else // we'll get vertices of "infinite" value // resulting in a !local.IsValid() error: if (!m_started) { return; } int prevState = (int)state; state = controlIsEnabled ? (btnValue ? CONTROL_STATE.True : CONTROL_STATE.False) : CONTROL_STATE.Disabled; // Clamp the index just to the state indices // directly supported by the control int index = Mathf.Clamp((int)state, 0, 2); // First see if we need to postpone this state // change for when we are active: if (!gameObject.active) { stateChangeWhileDeactivated = true; return; } this.SetState(index); this.UseStateLabel(index); // Recalculate our collider UpdateCollider(); SetLayerState(state); if (!suppressTransition) { // End any current transition: if (prevTransition != null) { prevTransition.StopSafe(); } StartTransition(index, prevState); } }
public void SetAnimationState(CONTROL_STATE controlState) { m_currState = controlState; if (m_currState == CONTROL_STATE.ANIMATING_IN) { MeshRenderer controlRenderer = transform.GetComponentInChildren <MeshRenderer>(); controlRenderer.enabled = true; } }
public virtual void SetControlState(CONTROL_STATE s, bool suppressTransitions) { // If this is the same as the current state, ignore: if (m_ctrlState == s) { return; } // Only stop our transition if it isn't an active state // transition and we don't want it to run to completion: if (!(alwaysFinishActiveTransition && (prevTransition == transitions[(int)UIButton.CONTROL_STATE.ACTIVE].list[0] || prevTransition == transitions[(int)UIButton.CONTROL_STATE.ACTIVE].list[1]) )) { int prevState = (int)m_ctrlState; m_ctrlState = s; this.UseStateLabel((int)s); if (s == CONTROL_STATE.DISABLED) { m_controlIsEnabled = false; } else { m_controlIsEnabled = true; } // Go no further if we're suppressing transitions: if (suppressTransitions) { return; } // End any current transition: if (prevTransition != null) { prevTransition.StopSafe(); } // Start a new transition: StartTransition((int)s, prevState); } else // Else, have our desired transition run when the active transition is complete: { // Go no further if we're suppressing transitions: if (suppressTransitions) { return; } QueueTransition((int)s, (int)UIButton.CONTROL_STATE.ACTIVE); } }
protected override void OnDisable() { // First, save our state as it will get changed // in UIButton's implementation: CONTROL_STATE oldState = controlState; base.OnDisable(); // Now restore our previous state: SetControlState(oldState); }
public override void Start() { base.Start(); state = controlIsEnabled ? (btnValue ? CONTROL_STATE.True : CONTROL_STATE.False) : CONTROL_STATE.Disabled; /* * if (btnValue) * PopOtherButtonsInGroup(); */ // Runtime init stuff: if (Application.isPlaying) { // Setup our transitions: for (int i = 0; i < transitions.Length; ++i) { for (int j = 0; j < transitions[i].list.Length; ++j) { transitions[i].list[j].MainSubject = this.gameObject; // Add our text as a sub-subject of our transitions: if (spriteText != null) { transitions[i].list[j].AddSubSubject(spriteText.gameObject); } } } // We'll use this to setup our state: int stateIdx = btnValue ? 0 : 1; stateIdx = m_controlIsEnabled ? stateIdx : 2; // Create a default collider if none exists: if (GetComponent <Collider>() == null) { AddCollider(); } //SetState(stateIdx); } Value = btnValue; if (useParentForGrouping && transform.parent != null) { SetGroup(transform.parent.GetHashCode()); } else { SetGroup(radioGroup); } }
// Sets the control to its disabled appearance: protected void DisableMe() { // End any current transition: if (prevTransition != null) { prevTransition.StopSafe(); } StartTransition((int)CONTROL_STATE.Disabled, (int)state); state = CONTROL_STATE.Disabled; }
// move down, set scale control size way down, turn off renderers private void SetDefaultState() { m_currState = CONTROL_STATE.OPEN_HIDDEN; //move position transform.position = new Vector3(transform.position.x, transform.position.y - k_startYPosOffset, transform.position.z); // adjust scale transform.localScale = new Vector3(0.0f, 0.0f, 0.0f); // turn off renderer MeshRenderer controlRenderer = transform.GetComponentInChildren <MeshRenderer>(); controlRenderer.enabled = false; }
private void fn_SetState(COMM_STATE nComState, CONTROL_STATE nConState, PORT_STATE nPortState, PROCESS_STATE nProcState, ALARM_STATE nAlarmState) { stState.CommunicationState = (int)nComState; stState.ControlState = (int)nConState; stState.PortState = (int)nPortState; stState.ProcessState = (int)nProcState; stState.AlarmState = (int)nAlarmState; Server.SendPacket.DataClear(); Server.SendPacket.Reply = (int)REPLY.ack_Success; Server.SendPacket.PushData <State>(stState); Server.fn_PushSendQueue(Server.SendPacket); }
// Sets the control to its disabled appearance: protected void DisableMe() { this.UseStateLabel(states.Length - 1); // End any current transition: if (prevTransition != null) { prevTransition.StopSafe(); } StartTransition((int)CONTROL_STATE.Disabled, (int)state); state = CONTROL_STATE.Disabled; }
public void SetState(CONTROL_STATE s) { switch (s) { case CONTROL_STATE.NORMAL: if (m_ButtonImage != null && m_ButtonImage.Length > 0) { for (int i = 0, iMax = m_ButtonImage.Length; i < iMax; ++i) { m_ButtonImage[i].target.spriteName = m_ButtonImage[i].normalSprite; } } break; case CONTROL_STATE.OVER: if (m_ButtonImage != null && m_ButtonImage.Length > 0) { for (int i = 0, iMax = m_ButtonImage.Length; i < iMax; ++i) { m_ButtonImage[i].target.spriteName = m_ButtonImage[i].hoverSprite; } } break; case CONTROL_STATE.ACTIVE: if (m_ButtonImage != null && m_ButtonImage.Length > 0) { for (int i = 0, iMax = m_ButtonImage.Length; i < iMax; ++i) { m_ButtonImage[i].target.spriteName = m_ButtonImage[i].pressedSprite; } } break; case CONTROL_STATE.DISABLED: if (m_ButtonImage != null && m_ButtonImage.Length > 0) { for (int i = 0, iMax = m_ButtonImage.Length; i < iMax; ++i) { m_ButtonImage[i].target.spriteName = m_ButtonImage[i].disabledSprite; } } break; default: break; } }
// Sets the button's visual state to match its value. protected void SetButtonState() { int prevState = (int)state; state = controlIsEnabled ? (btnValue ? CONTROL_STATE.True : CONTROL_STATE.False) : CONTROL_STATE.Disabled; int index = (int)state; // End any current transition: if (prevTransition != null) { prevTransition.StopSafe(); } StartTransition(index, prevState); }
// Queues a transition to play following the previous (currently-running) transition protected void QueueTransition(int newState, int prevState) { if (deleted) { return; } nextTransition = transitions[newState].list[DetermineNextTransition(newState, prevState)]; nextState = (CONTROL_STATE)newState; // See if we've already queued to run a follow-up transition: if (!transitionQueued) { prevTransition.AddTransitionEndDelegate(RunFollowupTrans); } transitionQueued = true; }
//--------------------------------------------------------------------------- public void fn_SetControlState() { CONTROL_STATE state = new CONTROL_STATE(); if (FM.fn_GetRunMode(EN_RUN_MODE.AUTO_MODE)) { state = CONTROL_STATE.AUTO; } else if (FM.fn_GetRunMode(EN_RUN_MODE.MAN_MODE)) { state = CONTROL_STATE.MANUAL; } else if (FM.fn_GetRunMode(EN_RUN_MODE.TEST_MODE)) { state = CONTROL_STATE.OFFLINE; } curState.ControlState = (int)state; }
public override void Start() { state = controlIsEnabled ? (btnValue ? CONTROL_STATE.True : CONTROL_STATE.False) : CONTROL_STATE.Disabled; /* * if (btnValue) * PopOtherButtonsInGroup(); */ // Runtime init stuff: if (Application.isPlaying) { // Setup our transitions: transitions[0].list[0].MainSubject = this.gameObject; transitions[1].list[0].MainSubject = this.gameObject; transitions[2].list[0].MainSubject = this.gameObject; transitions[2].list[1].MainSubject = this.gameObject; // We'll use this to setup our state: int stateIdx = btnValue ? 0 : 1; stateIdx = m_controlIsEnabled ? stateIdx : 2; // Create a default collider if none exists: if (collider == null) { AddCollider(); } //SetState(stateIdx); } Value = btnValue; if (useParentForGrouping && transform.parent != null) { SetGroup(transform.parent.GetHashCode()); } else { SetGroup(radioGroup); } }
protected override void OnEnable() { base.OnEnable(); if (Application.isPlaying && m_started) { // Set it to some bogus value so we can force // it to be reset: m_ctrlState = (CONTROL_STATE)(-1); if (controlIsEnabled) { SetControlState(CONTROL_STATE.NORMAL, true); } else { SetControlState(CONTROL_STATE.DISABLED, true); } } }
// Switches the displayed sprite(s) to match the current state: protected void SetControlState(CONTROL_STATE s) { // If this is the same as the current state, ignore: if (m_ctrlState == s) { return; } int prevState = (int)m_ctrlState; m_ctrlState = s; // End any current transition: if (prevTransition != null) { prevTransition.StopSafe(); } // Start a new transition: StartTransition((int)s, prevState); }
public override void Copy(SpriteRoot s, ControlCopyFlags flags) { base.Copy(s, flags); if (!(s is UIRadioBtn)) { return; } UIRadioBtn b = (UIRadioBtn)s; if ((flags & ControlCopyFlags.State) == ControlCopyFlags.State) { state = b.state; prevTransition = b.prevTransition; if (Application.isPlaying) { Value = b.Value; } } if ((flags & ControlCopyFlags.Settings) == ControlCopyFlags.Settings) { group = b.group; defaultValue = b.defaultValue; } if ((flags & ControlCopyFlags.Invocation) == ControlCopyFlags.Invocation) { scriptWithMethodToInvoke = b.scriptWithMethodToInvoke; methodToInvoke = b.methodToInvoke; whenToInvoke = b.whenToInvoke; delay = b.delay; } if ((flags & ControlCopyFlags.Sound) == ControlCopyFlags.Sound) { soundToPlay = b.soundToPlay; } }
// Sets the button's visual state to match its value. protected void SetButtonState() { int prevState = (int)state; state = controlIsEnabled ? (btnValue ? CONTROL_STATE.True : CONTROL_STATE.False) : CONTROL_STATE.Disabled; int index = (int)state; // End any current transition: if (prevTransition != null) prevTransition.StopSafe(); StartTransition(index, prevState); // Notify our change delegate: if (changeDelegate != null) changeDelegate(this); }
protected void Start() { state = controlIsEnabled ? (btnValue ? CONTROL_STATE.True : CONTROL_STATE.False) : CONTROL_STATE.Disabled; /* if (btnValue) PopOtherButtonsInGroup(); */ // Runtime init stuff: if (Application.isPlaying) { // Setup our transitions: transitions[0].list[0].MainSubject = this.gameObject; transitions[1].list[0].MainSubject = this.gameObject; transitions[2].list[0].MainSubject = this.gameObject; transitions[2].list[1].MainSubject = this.gameObject; // We'll use this to setup our state: int stateIdx = btnValue ? 0 : 1; stateIdx = m_controlIsEnabled ? stateIdx : 2; // Create a default collider if none exists: if (collider == null) { AddCollider(); } //SetState(stateIdx); } }
// Sets the button's visual state to match its value. protected void SetButtonState() { // Make sure we have a mesh: if (spriteMesh == null) { return; } // Make sure we're initialized since // we might have been called as a result of // another button in our group settings its // value on Start() before we've had a cance // to Start() ourselves, meaning we may lack // important info like a valid screensize, // etc. which is necessary for sizing or else // we'll get vertices of "infinite" value // resulting in a !local.IsValid() error: if (!m_started) { return; } int prevState = (int)state; state = controlIsEnabled ? (btnValue ? CONTROL_STATE.True : CONTROL_STATE.False) : CONTROL_STATE.Disabled; int index = (int)state; // First see if we need to postpone this state // change for when we are active: if (!gameObject.active) { stateChangeWhileDeactivated = true; return; } this.SetState(index); this.UseStateLabel(index); // Recalculate our collider UpdateCollider(); // Loop through each layer and set its state, // provided we have a valid index for that state: for (int i = 0; i < layers.Length; ++i) { if (-1 != stateIndices[i, index]) { layers[i].Hide(false); layers[i].SetState(stateIndices[i, index]); } else { layers[i].Hide(true); } } // End any current transition: if (prevTransition != null) { prevTransition.StopSafe(); } StartTransition(index, prevState); }
public override void Start() { if (m_started) return; base.Start(); // Assign our aggregate layers: aggregateLayers = new SpriteRoot[1][]; aggregateLayers[0] = layers; state = controlIsEnabled ? (btnValue ? CONTROL_STATE.True : CONTROL_STATE.False) : CONTROL_STATE.Disabled; /* if (btnValue) PopOtherButtonsInGroup(); */ // Runtime init stuff: if (Application.isPlaying) { // Setup our transitions: for (int i = 0; i < transitions.Length; ++i) for (int j = 0; j < transitions[i].list.Length; ++j) { transitions[i].list[j].MainSubject = this.gameObject; // Add our text as a sub-subject of our transitions: if (spriteText != null) transitions[i].list[j].AddSubSubject(spriteText.gameObject); } // Add our text as a sub-subject of our transitions: stateIndices = new int[layers.Length, 5]; // We'll use this to setup our state: int stateIdx = btnValue ? 0 : 1; stateIdx = m_controlIsEnabled ? stateIdx : 2; // Populate our state indices based on if we // find any valid states/animations in each // sprite layer: for (int i = 0; i < layers.Length; ++i) { if (layers[i] == null) { Debug.LogError("A null layer sprite was encountered on control \"" + name + "\". Please fill in the layer reference, or remove the empty element."); continue; } stateIndices[i, 0] = layers[i].GetStateIndex("true"); stateIndices[i, 1] = layers[i].GetStateIndex("false"); stateIndices[i, 2] = layers[i].GetStateIndex("disabled"); stateIndices[i, 3] = layers[i].GetStateIndex("over"); stateIndices[i, 4] = layers[i].GetStateIndex("active"); // Add this as a subject of our transition for // each state, as appropriate: if (stateIndices[i, 0] != -1) { transitions[0].list[0].AddSubSubject(layers[i].gameObject); transitions[0].list[1].AddSubSubject(layers[i].gameObject); } if (stateIndices[i, 1] != -1) { transitions[1].list[0].AddSubSubject(layers[i].gameObject); transitions[1].list[1].AddSubSubject(layers[i].gameObject); } if (stateIndices[i, 2] != -1) { transitions[2].list[0].AddSubSubject(layers[i].gameObject); transitions[2].list[1].AddSubSubject(layers[i].gameObject); } // Set the layer's state: if (stateIndices[i, stateIdx] != -1) layers[i].SetState(stateIndices[i, stateIdx]); else layers[i].Hide(true); } // Create a default collider if none exists: if (collider == null) AddCollider(); SetValue(btnValue, true); if (useParentForGrouping && transform.parent != null) SetGroup(transform.parent.GetHashCode()); else SetGroup(radioGroup); } // Since hiding while managed depends on // setting our mesh extents to 0, and the // foregoing code causes us to not be set // to 0, re-hide ourselves: if (managed && m_hidden) Hide(true); }
// Sets the button's visual state to match its value. protected void SetButtonState() { // Make sure we have a mesh: if (spriteMesh == null) return; // Make sure we're initialized since // we might have been called as a result of // another button in our group settings its // value on Start() before we've had a cance // to Start() ourselves, meaning we may lack // important info like a valid screensize, // etc. which is necessary for sizing or else // we'll get vertices of "infinite" value // resulting in a !local.IsValid() error: if (!m_started) return; int prevState = (int)state; state = controlIsEnabled ? (btnValue ? CONTROL_STATE.True : CONTROL_STATE.False) : CONTROL_STATE.Disabled; int index = (int)state; this.SetState(index); this.UseStateLabel(index); // Recalculate our collider UpdateCollider(); // Loop through each layer and set its state, // provided we have a valid index for that state: for (int i = 0; i < layers.Length; ++i) { if (-1 != stateIndices[i, index]) { layers[i].Hide(false); layers[i].SetState(stateIndices[i, index]); } else layers[i].Hide(true); } // End any current transition: if (prevTransition != null) prevTransition.StopSafe(); StartTransition(index, prevState); // Notify our change delegate: if (changeDelegate != null) changeDelegate(this); }
//--------------------------------------------------------------------------- public void fn_SetControlState(CONTROL_STATE state) { curState.ControlState = (int)state; }
// Sets the button's visual state to match its value. protected virtual void SetButtonState() { int prevState = (int)state; state = controlIsEnabled ? (btnValue ? CONTROL_STATE.True : CONTROL_STATE.False) : CONTROL_STATE.Disabled; int index = (int)state; // First see if we need to postpone this state // change for when we are active: #if UNITY_4_0 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_4 || UNITY_4_5 || UNITY_4_6 || UNITY_4_7 || UNITY_4_8 || UNITY_4_9 if (!gameObject.activeInHierarchy) #else if (!gameObject.active) #endif { stateChangeWhileDeactivated = true; return; } this.UseStateLabel(index); // End any current transition: if (prevTransition != null) prevTransition.StopSafe(); StartTransition(index, prevState); }
// Switches the displayed sprite(s) to match the current state: public virtual void SetControlState(CONTROL_STATE s, bool suppressTransitions) { // If this is the same as the current state, ignore: if (m_ctrlState == s) return; // Only stop our transition if it isn't an active state // transition and we don't want it to run to completion: if ( !( alwaysFinishActiveTransition && ( (prevTransition == transitions[(int)UIButton.CONTROL_STATE.ACTIVE].list[0] || prevTransition == transitions[(int)UIButton.CONTROL_STATE.ACTIVE].list[1]) && prevTransition.IsRunning() ) ) ) { int prevState = (int)m_ctrlState; m_ctrlState = s; // Validate that we can go to this appearance: if (animations[(int)s].GetFrameCount() > 0) this.SetState((int)s); this.UseStateLabel((int)s); if (s == CONTROL_STATE.DISABLED) m_controlIsEnabled = false; else m_controlIsEnabled = true; // Recalculate our collider UpdateCollider(); // Loop through each layer and set its state, // provided we have a valid index for that state: for (int i = 0; i < layers.Length; ++i) { if (-1 != stateIndices[i, (int)s]) { layers[i].Hide(IsHidden()); layers[i].SetState(stateIndices[i, (int)s]); } else layers[i].Hide(true); } // End any current transition: if (prevTransition != null) prevTransition.StopSafe(); // Start a new transition: StartTransition((int)s, prevState, suppressTransitions); } else // Else, have our desired transition run when the active transition is complete: { // Go no further if we're suppressing transitions: QueueTransition((int)s, (int)UIButton.CONTROL_STATE.ACTIVE, suppressTransitions); } }
public virtual void SetControlState(CONTROL_STATE s) { SetControlState(s, false); }
public override void Start() { state = controlIsEnabled ? (btnValue ? CONTROL_STATE.True : CONTROL_STATE.False) : CONTROL_STATE.Disabled; /* if (btnValue) PopOtherButtonsInGroup(); */ // Runtime init stuff: if (Application.isPlaying) { // Setup our transitions: transitions[0].list[0].MainSubject = this.gameObject; transitions[1].list[0].MainSubject = this.gameObject; transitions[2].list[0].MainSubject = this.gameObject; transitions[2].list[1].MainSubject = this.gameObject; // We'll use this to setup our state: int stateIdx = btnValue ? 0 : 1; stateIdx = m_controlIsEnabled ? stateIdx : 2; // Create a default collider if none exists: if (collider == null) { AddCollider(); } //SetState(stateIdx); } Value = btnValue; if (useParentForGrouping && transform.parent != null) SetGroup(transform.parent.GetHashCode()); else SetGroup(radioGroup); }
public void SetState(CONTROL_STATE s) { switch (s) { case CONTROL_STATE.NORMAL: if (m_ButtonImage != null && m_ButtonImage.Length > 0) { for (int i = 0, iMax = m_ButtonImage.Length; i < iMax; ++i) m_ButtonImage[i].target.spriteName = m_ButtonImage[i].normalSprite; } break; case CONTROL_STATE.OVER: if (m_ButtonImage != null && m_ButtonImage.Length > 0) { for (int i = 0, iMax = m_ButtonImage.Length; i < iMax; ++i) m_ButtonImage[i].target.spriteName = m_ButtonImage[i].hoverSprite; } break; case CONTROL_STATE.ACTIVE: if (m_ButtonImage != null && m_ButtonImage.Length > 0) { for (int i = 0, iMax = m_ButtonImage.Length; i < iMax; ++i) m_ButtonImage[i].target.spriteName = m_ButtonImage[i].pressedSprite; } break; case CONTROL_STATE.DISABLED: if (m_ButtonImage != null && m_ButtonImage.Length > 0) { for (int i = 0, iMax = m_ButtonImage.Length; i < iMax; ++i) m_ButtonImage[i].target.spriteName = m_ButtonImage[i].disabledSprite; } break; default: break; } }
public PageSetting_Manual_PMC() { InitializeComponent(); //Timer 생성 m_UpdateTimer.IsEnabled = false; m_UpdateTimer.Interval = TimeSpan.FromMilliseconds(100); m_UpdateTimer.Tick += new EventHandler(fn_tmUpdate); //Back Color Set this.Background = UserConst.G_COLOR_PAGEBACK; ubComm1.Tag = COMMAND.cmdStop; ubComm2.Tag = COMMAND.cmdCycleStop; ubComm3.Tag = COMMAND.cmdOrigin; ubComm4.Tag = COMMAND.cmdModeChange; ubComm5.Tag = COMMAND.cmdPrepareProc; ubComm6.Tag = COMMAND.cmdLoadStart; ubComm7.Tag = COMMAND.cmdUnloadStart; ubComm8.Tag = COMMAND.cmdAlarm; ubComm9.Tag = COMMAND.cmdAreYouAlive; ubComm10.Tag = COMMAND.cmdRunProc; ubComm11.Tag = COMMAND.cmdVersion; ubComm12.Tag = COMMAND.cmdCurrentState; ubComm13.Tag = COMMAND.cmdCurrentData; ubComm1.Content = COMMAND.cmdStop; ubComm2.Content = COMMAND.cmdCycleStop; ubComm3.Content = COMMAND.cmdOrigin; ubComm4.Content = COMMAND.cmdModeChange; ubComm5.Content = COMMAND.cmdPrepareProc; ubComm6.Content = COMMAND.cmdLoadStart; ubComm7.Content = COMMAND.cmdUnloadStart; ubComm8.Content = COMMAND.cmdAlarm; ubComm9.Content = COMMAND.cmdAreYouAlive; ubComm10.Content = COMMAND.cmdRunProc; ubComm11.Content = COMMAND.cmdVersion; ubComm12.Content = COMMAND.cmdCurrentState; ubComm13.Content = COMMAND.cmdCurrentData; EN_PORT_ID portId = new EN_PORT_ID(); for (int i = 0; i < Enum.GetNames(typeof(EN_PORT_ID)).Length; i++) { cbPortNo.Items.Add(portId++); } EN_PORT_ID procId = new EN_PORT_ID(); for (int i = 0; i < Enum.GetNames(typeof(EN_PORT_ID)).Length; i++) { cbProcNo.Items.Add(procId++); } PORT_STATE temp = new PORT_STATE(); for (int i = 0; i < Enum.GetNames(typeof(PORT_STATE)).Length; i++) { cbPortState.Items.Add(temp++); } PROCESS_STATE tempProc = new PROCESS_STATE(); for (int i = 0; i < Enum.GetNames(typeof(PROCESS_STATE)).Length; i++) { cbProcState.Items.Add(tempProc++); } CONTROL_STATE tempCont = new CONTROL_STATE(); for (int i = 0; i < Enum.GetNames(typeof(CONTROL_STATE)).Length; i++) { cbContState.Items.Add(tempCont++); } }
// Sets the control to its disabled appearance: protected void DisableMe() { // End any current transition: if (prevTransition != null) prevTransition.StopSafe(); StartTransition((int)CONTROL_STATE.Disabled, (int)state); state = CONTROL_STATE.Disabled; }
// Queues a transition to play following the previous (currently-running) transition protected void QueueTransition(int newState, int prevState, bool suppressTransition) { if (deleted) return; nextTransition = transitions[newState].list[DetermineNextTransition(newState, prevState)]; nextState = (CONTROL_STATE)newState; if (suppressTransition) { prevTransition.End(); prevTransition = nextTransition; prevTransition.Start(); prevTransition.End(); // Immediately place the transition into its "end state". return; } // See if we've already queued to run a follow-up transition: if (!transitionQueued) prevTransition.AddTransitionEndDelegate(RunFollowupTrans); transitionQueued = true; }
public override void Start() { base.Start(); state = controlIsEnabled ? (btnValue ? CONTROL_STATE.True : CONTROL_STATE.False) : CONTROL_STATE.Disabled; /* if (btnValue) PopOtherButtonsInGroup(); */ // Runtime init stuff: if (Application.isPlaying) { // Setup our transitions: for (int i = 0; i < transitions.Length; ++i) for (int j = 0; j < transitions[i].list.Length; ++j) { transitions[i].list[j].MainSubject = this.gameObject; // Add our text as a sub-subject of our transitions: if (spriteText != null) transitions[i].list[j].AddSubSubject(spriteText.gameObject); } // We'll use this to setup our state: int stateIdx = btnValue ? 0 : 1; stateIdx = m_controlIsEnabled ? stateIdx : 2; // Create a default collider if none exists: if (collider == null) { AddCollider(); } //SetState(stateIdx); } Value = btnValue; if (useParentForGrouping && transform.parent != null) SetGroup(transform.parent.GetHashCode()); else SetGroup(radioGroup); }
// Sets the layers to represent the current control state // (includes states not directly supported by the control // itself, such as Over and Active) protected void SetLayerState(CONTROL_STATE s) { // Skip if redundant: if (s == layerState) return; layerState = s; // This index is valid for our layers as // they can also support "Over" and "Active": int layerIndex = (int)layerState; // Loop through each layer and set its state, // provided we have a valid index for that state: for (int i = 0; i < layers.Length; ++i) { if (-1 != stateIndices[i, layerIndex]) { layers[i].Hide(IsHidden()); layers[i].SetState(stateIndices[i, layerIndex]); } else layers[i].Hide(true); } }
// Sets the control to its disabled appearance: protected void DisableMe() { this.UseStateLabel(states.Length - 1); // End any current transition: if (prevTransition != null) prevTransition.StopSafe(); StartTransition((int)CONTROL_STATE.Disabled, (int)state); state = CONTROL_STATE.Disabled; }
public virtual void SetControlState(CONTROL_STATE s, bool suppressTransitions) { // If this is the same as the current state, ignore: if (m_ctrlState == s) return; // Only stop our transition if it isn't an active state // transition and we don't want it to run to completion: if (!(alwaysFinishActiveTransition && (prevTransition == transitions[(int)UIButton.CONTROL_STATE.ACTIVE].list[0] || prevTransition == transitions[(int)UIButton.CONTROL_STATE.ACTIVE].list[1]) )) { int prevState = (int)m_ctrlState; m_ctrlState = s; this.UseStateLabel((int)s); if (s == CONTROL_STATE.DISABLED) m_controlIsEnabled = false; else m_controlIsEnabled = true; // Go no further if we're suppressing transitions: if (suppressTransitions) return; // End any current transition: if (prevTransition != null) prevTransition.StopSafe(); // Start a new transition: StartTransition((int)s, prevState); } else // Else, have our desired transition run when the active transition is complete: { // Go no further if we're suppressing transitions: if (suppressTransitions) return; QueueTransition((int)s, (int)UIButton.CONTROL_STATE.ACTIVE); } }
protected override void Start() { base.Start(); // Assign our aggregate layers: aggregateLayers = new SpriteRoot[1][]; aggregateLayers[0] = layers; state = controlIsEnabled ? (btnValue ? CONTROL_STATE.True : CONTROL_STATE.False) : CONTROL_STATE.Disabled; /* if (btnValue) PopOtherButtonsInGroup(); */ // Runtime init stuff: if (Application.isPlaying) { // Setup our transitions: transitions[0].list[0].MainSubject = this.gameObject; transitions[1].list[0].MainSubject = this.gameObject; transitions[2].list[0].MainSubject = this.gameObject; transitions[2].list[1].MainSubject = this.gameObject; stateIndices = new int[layers.Length, 3]; // We'll use this to setup our state: int stateIdx = btnValue ? 0 : 1; stateIdx = m_controlIsEnabled ? stateIdx : 2; // Populate our state indices based on if we // find any valid states/animations in each // sprite layer: for (int i = 0; i < layers.Length; ++i) { if (layers[i] == null) { Debug.LogError("A null layer sprite was encountered on control \"" + name + "\". Please fill in the layer reference, or remove the empty element."); continue; } stateIndices[i, 0] = layers[i].GetStateIndex("true"); stateIndices[i, 1] = layers[i].GetStateIndex("false"); stateIndices[i, 2] = layers[i].GetStateIndex("disabled"); // Add this as a subject of our transition for // each state, as appropriate: if (stateIndices[i, 0] != -1) transitions[0].list[0].AddSubSubject(layers[i].gameObject); if (stateIndices[i, 1] != -1) transitions[1].list[0].AddSubSubject(layers[i].gameObject); if (stateIndices[i, 2] != -1) { transitions[2].list[0].AddSubSubject(layers[i].gameObject); transitions[2].list[1].AddSubSubject(layers[i].gameObject); } // Set the layer's state: if (stateIndices[i, stateIdx] != -1) layers[i].SetState(stateIndices[i, stateIdx]); else layers[i].Hide(true); } // Create a default collider if none exists: if (collider == null) AddCollider(); Value = btnValue; } }
// Switches the displayed sprite(s) to match the current state: public virtual void SetControlState(CONTROL_STATE s, bool suppressTransitions) { // If this is the same as the current state, ignore: if (m_ctrlState == s) { return; } // Only stop our transition if it isn't an active state // transition and we don't want it to run to completion: if ( !( alwaysFinishActiveTransition && ( (prevTransition == transitions[(int)UIButton.CONTROL_STATE.ACTIVE].list[0] || prevTransition == transitions[(int)UIButton.CONTROL_STATE.ACTIVE].list[1]) && prevTransition.IsRunning() ) ) ) { int prevState = (int)m_ctrlState; m_ctrlState = s; // Validate that we can go to this appearance: if (animations[(int)s].GetFrameCount() > 0) { this.SetState((int)s); } this.UseStateLabel((int)s); if (s == CONTROL_STATE.DISABLED) { m_controlIsEnabled = false; } else { m_controlIsEnabled = true; } // Recalculate our collider UpdateCollider(); // Loop through each layer and set its state, // provided we have a valid index for that state: for (int i = 0; i < layers.Length; ++i) { if (-1 != stateIndices[i, (int)s]) { layers[i].Hide(IsHidden()); layers[i].SetState(stateIndices[i, (int)s]); } else { layers[i].Hide(true); } } // End any current transition: if (prevTransition != null) { prevTransition.StopSafe(); } // Start a new transition: StartTransition((int)s, prevState, suppressTransitions); } else // Else, have our desired transition run when the active transition is complete: { // Go no further if we're suppressing transitions: QueueTransition((int)s, (int)UIButton.CONTROL_STATE.ACTIVE, suppressTransitions); } }
public override void Copy(SpriteRoot s, ControlCopyFlags flags) { base.Copy(s, flags); if (!(s is UIRadioBtn)) return; UIRadioBtn b = (UIRadioBtn)s; if ((flags & ControlCopyFlags.State) == ControlCopyFlags.State) { state = b.state; prevTransition = b.prevTransition; if (Application.isPlaying) Value = b.Value; } if ((flags & ControlCopyFlags.Settings) == ControlCopyFlags.Settings) { group = b.group; defaultValue = b.defaultValue; } if ((flags & ControlCopyFlags.Invocation) == ControlCopyFlags.Invocation) { scriptWithMethodToInvoke = b.scriptWithMethodToInvoke; methodToInvoke = b.methodToInvoke; whenToInvoke = b.whenToInvoke; delay = b.delay; } if ((flags & ControlCopyFlags.Sound) == ControlCopyFlags.Sound) { soundToPlay = b.soundToPlay; } }
// Switches the displayed sprite(s) to match the current state: public void SetControlState(CONTROL_STATE s) { // If this is the same as the current state, ignore: if (m_ctrlState == s) return; int prevState = (int)m_ctrlState; m_ctrlState = s; // Validate that we can go to this appearance: if(animations[(int)s].GetFrameCount() > 0) this.SetState((int)s); this.UseStateLabel((int)s); if (s == CONTROL_STATE.DISABLED) m_controlIsEnabled = false; else m_controlIsEnabled = true; // Recalculate our collider UpdateCollider(); // Loop through each layer and set its state, // provided we have a valid index for that state: for (int i = 0; i < layers.Length; ++i) { if (-1 != stateIndices[i, (int)s]) { layers[i].Hide(false); layers[i].SetState(stateIndices[i, (int)s]); } else layers[i].Hide(true); } // End any current transition: if (prevTransition != null) prevTransition.StopSafe(); // Start a new transition: StartTransition((int)s, prevState); }
// Sets the button's visual state to match its value. protected virtual void SetButtonState(bool suppressTransition) { // Make sure we have a mesh: if (spriteMesh == null) return; // Make sure we're initialized since // we might have been called as a result of // another button in our group settings its // value on Start() before we've had a cance // to Start() ourselves, meaning we may lack // important info like a valid screensize, // etc. which is necessary for sizing or else // we'll get vertices of "infinite" value // resulting in a !local.IsValid() error: if (!m_started) return; int prevState = (int)state; state = controlIsEnabled ? (btnValue ? CONTROL_STATE.True : CONTROL_STATE.False) : CONTROL_STATE.Disabled; // Clamp the index just to the state indices // directly supported by the control int index = Mathf.Clamp((int)state, 0, 2); // First see if we need to postpone this state // change for when we are active: if (!gameObject.active) { stateChangeWhileDeactivated = true; return; } this.SetState(index); this.UseStateLabel(index); // Recalculate our collider UpdateCollider(); SetLayerState(state); if (!suppressTransition) { // End any current transition: if (prevTransition != null) prevTransition.StopSafe(); StartTransition(index, prevState); } }
// Queues a transition to play following the previous (currently-running) transition protected void QueueTransition(int newState, int prevState) { if (deleted) return; nextTransition = transitions[newState].list[DetermineNextTransition(newState, prevState)]; nextState = (CONTROL_STATE)newState; // See if we've already queued to run a follow-up transition: if (!transitionQueued) prevTransition.AddTransitionEndDelegate(RunFollowupTrans); transitionQueued = true; }
// Sets the control to its disabled appearance: protected void DisableMe() { // The disabled state is the last in the state list: SetState(states.Length - 1); // Set the label: this.UseStateLabel(states.Length - 1); // Set the layer states: for (int i = 0; i < layers.Length; ++i) { if (stateIndices[i, states.Length - 1] != -1) layers[i].SetState(stateIndices[i, states.Length - 1]); } // End any current transition: if (prevTransition != null) prevTransition.StopSafe(); StartTransition((int)CONTROL_STATE.Disabled, (int)state); state = CONTROL_STATE.Disabled; }
public override void Start() { if (m_started) { return; } base.Start(); // Assign our aggregate layers: aggregateLayers = new SpriteRoot[1][]; aggregateLayers[0] = layers; state = controlIsEnabled ? (btnValue ? CONTROL_STATE.True : CONTROL_STATE.False) : CONTROL_STATE.Disabled; /* * if (btnValue) * PopOtherButtonsInGroup(); */ // Runtime init stuff: if (Application.isPlaying) { // Setup our transitions: for (int i = 0; i < transitions.Length; ++i) { for (int j = 0; j < transitions[i].list.Length; ++j) { transitions[i].list[j].MainSubject = this.gameObject; // Add our text as a sub-subject of our transitions: if (spriteText != null) { transitions[i].list[j].AddSubSubject(spriteText.gameObject); } } } // Add our text as a sub-subject of our transitions: stateIndices = new int[layers.Length, 5]; // We'll use this to setup our state: int stateIdx = btnValue ? 0 : 1; stateIdx = m_controlIsEnabled ? stateIdx : 2; // Populate our state indices based on if we // find any valid states/animations in each // sprite layer: for (int i = 0; i < layers.Length; ++i) { if (layers[i] == null) { Debug.LogError("A null layer sprite was encountered on control \"" + name + "\". Please fill in the layer reference, or remove the empty element."); continue; } stateIndices[i, 0] = layers[i].GetStateIndex("true"); stateIndices[i, 1] = layers[i].GetStateIndex("false"); stateIndices[i, 2] = layers[i].GetStateIndex("disabled"); stateIndices[i, 3] = layers[i].GetStateIndex("over"); stateIndices[i, 4] = layers[i].GetStateIndex("active"); // Add this as a subject of our transition for // each state, as appropriate: if (stateIndices[i, 0] != -1) { transitions[0].list[0].AddSubSubject(layers[i].gameObject); transitions[0].list[1].AddSubSubject(layers[i].gameObject); } if (stateIndices[i, 1] != -1) { transitions[1].list[0].AddSubSubject(layers[i].gameObject); transitions[1].list[1].AddSubSubject(layers[i].gameObject); } if (stateIndices[i, 2] != -1) { transitions[2].list[0].AddSubSubject(layers[i].gameObject); transitions[2].list[1].AddSubSubject(layers[i].gameObject); } // Set the layer's state: if (stateIndices[i, stateIdx] != -1) { layers[i].SetState(stateIndices[i, stateIdx]); } else { layers[i].Hide(true); } } // Create a default collider if none exists: if (collider == null) { AddCollider(); } SetValue(btnValue, true); if (useParentForGrouping && transform.parent != null) { SetGroup(transform.parent.GetHashCode()); } else { SetGroup(radioGroup); } } // Since hiding while managed depends on // setting our mesh extents to 0, and the // foregoing code causes us to not be set // to 0, re-hide ourselves: if (managed && m_hidden) { Hide(true); } }
// Switches the displayed sprite(s) to match the current state: protected void SetControlState(CONTROL_STATE s) { // If this is the same as the current state, ignore: if (m_ctrlState == s) return; int prevState = (int)m_ctrlState; m_ctrlState = s; // End any current transition: if (prevTransition != null) prevTransition.StopSafe(); // Start a new transition: StartTransition((int)s, prevState); }
protected override void OnEnable() { base.OnEnable(); if (Application.isPlaying && m_started) { // Set it to some bogus value so we can force // it to be reset: m_ctrlState = (CONTROL_STATE)(-1); if (controlIsEnabled) SetControlState(CONTROL_STATE.NORMAL, true); else SetControlState(CONTROL_STATE.DISABLED, true); } }
public void ChangeControlState(CONTROL_STATE newState, PrimaryMessageWrapper e, SecsMessage secsmsg, ref PROCESS_MSG_RESULT lResult) { SanwaSV svObj; if (_currentState == CONTROL_STATE.EQUIPMENT_OFF_LINE || _currentState == CONTROL_STATE.ON_LINE_LOCAL || _currentState == CONTROL_STATE.ON_LINE_REMOTE) { //1:Eqp OffLine, 2:OnLine Local, 3:OnLine Remote _svList.TryGetValue(SVName.GEM_PREVIOUS_CONTROL_STATE, out svObj); if (svObj != null) { if (_currentState == CONTROL_STATE.EQUIPMENT_OFF_LINE) { SetSV(SVName.GEM_PREVIOUS_CONTROL_STATE, 1); } if (_currentState == CONTROL_STATE.ON_LINE_LOCAL) { SetSV(SVName.GEM_PREVIOUS_CONTROL_STATE, 2); } if (_currentState == CONTROL_STATE.ON_LINE_REMOTE) { SetSV(SVName.GEM_PREVIOUS_CONTROL_STATE, 3); } } } switch (_currentState) { case CONTROL_STATE.EQUIPMENT_OFF_LINE: if (e != null) //是否由Host收到訊息 { if (newState == CONTROL_STATE.HOST_OFF_LINE) { //已經是HOST_OFF_LINE ReplyInOffLineState(e); } else if (newState == CONTROL_STATE.ON_LINE_LOCAL || newState == CONTROL_STATE.ON_LINE_REMOTE) { //拒絕連線 byte[] replybyte = { SanwaACK.ONLACK_NOT_ACCEPTED }; ReplyOnLineState(e, secsmsg, replybyte); } return; } //僅能接收嘗試連線(CONTROL_STATE.ATTEMPT_ON_LINE) if (CONTROL_STATE.ATTEMPT_ON_LINE != newState) { return; } _currentState = newState; break; case CONTROL_STATE.ATTEMPT_ON_LINE: if (e != null) { //已經是HOST_OFF_LINE,拒絕Host任何指令 ReplyInOffLineState(e); return; } _currentState = newState; break; case CONTROL_STATE.HOST_OFF_LINE: //1.由EQP進入 => e == null //2.由HOST進入=> e != null if (e != null) { if (CONTROL_STATE.HOST_OFF_LINE == newState) { ReplyInOffLineState(e); return; } lResult = PROCESS_MSG_RESULT.ALREADY_REPLIED; //需通知AP層 _currentState = newState; //由外部參數決定EC為CONTROL_STATE.ON_LINE_LOCATE 或 CONTROL_STATE.ON_LINE_REMOTE //接收連線要求 byte[] replybyte = { SanwaACK.ONLACK_ACCEPTED }; ReplyOnLineState(e, secsmsg, replybyte); } else { //僅能接收嘗試連線(CONTROL_STATE.EQUIPMENT_OFF_LINE) if (CONTROL_STATE.EQUIPMENT_OFF_LINE != newState) { return; } _currentState = newState; } break; case CONTROL_STATE.ON_LINE_LOCAL: //1.由EQP進入 => e == null //2.由HOST進入=> e != null if (e != null) { _currentState = newState; if (newState == CONTROL_STATE.HOST_OFF_LINE) { lResult = PROCESS_MSG_RESULT.ALREADY_REPLIED; byte[] replybyte = { SanwaACK.OFLACK_ACK }; ReplyOnLineState(e, secsmsg, replybyte); } else if (newState == CONTROL_STATE.ON_LINE_LOCAL || newState == CONTROL_STATE.ON_LINE_REMOTE) { byte[] replybyte = { SanwaACK.ONLACK_ALREADY_ON_LINE }; ReplyOnLineState(e, secsmsg, replybyte); } } else { if (!(CONTROL_STATE.EQUIPMENT_OFF_LINE == newState || CONTROL_STATE.ON_LINE_REMOTE == newState)) { return; } _currentState = newState; } break; case CONTROL_STATE.ON_LINE_REMOTE: if (e != null) { _currentState = newState; if (newState == CONTROL_STATE.HOST_OFF_LINE) { lResult = PROCESS_MSG_RESULT.ALREADY_REPLIED; byte[] replybyte = { SanwaACK.OFLACK_ACK }; ReplyOnLineState(e, secsmsg, replybyte); } else if (newState == CONTROL_STATE.ON_LINE_LOCAL || newState == CONTROL_STATE.ON_LINE_REMOTE) { byte[] replybyte = { SanwaACK.ONLACK_ALREADY_ON_LINE }; ReplyOnLineState(e, secsmsg, replybyte); } } else { if (!(CONTROL_STATE.EQUIPMENT_OFF_LINE == newState || CONTROL_STATE.ON_LINE_LOCAL == newState)) { return; } _currentState = newState; } break; } //_svList.TryGetValue(SVName.GEM_CONTROL_STATE, out svObj); //if (svObj != null) // svObj._value = GetCurrentStateForSV(); SetSV(SVName.GEM_CONTROL_STATE, GetCurrentStateForSV()); //傳給使用端 ThreadPool.QueueUserWorkItem(callback => { ChangeControlStateEvent?.Invoke(this, _currentState); }); }