Exemple #1
0
 /// <summary>
 /// Use this method to go from one state to the other
 /// </summary>
 public virtual void SwitchState()
 {
     _knobMovementStartedAt = Time.time;
     if (CurrentSwitchState == SwitchStates.Off)
     {
         CurrentSwitchState = SwitchStates.On;
         if (_animator != null)
         {
             _animator?.SetTrigger("Right");
         }
         if (SwitchOn != null)
         {
             SwitchOn.Invoke();
         }
     }
     else
     {
         CurrentSwitchState = SwitchStates.Off;
         if (_animator != null)
         {
             _animator?.SetTrigger("Left");
         }
         if (SwitchOff != null)
         {
             SwitchOff.Invoke();
         }
     }
 }
Exemple #2
0
 /// <summary>
 /// Use this method to go from one state to the other
 /// </summary>
 public virtual void ToggleSwitch()
 {
     if (CurrentSwitchState == SwitchStates.Off)
     {
         CurrentSwitchState = SwitchStates.On;
         if (SwitchOn != null)
         {
             SwitchOn.Invoke();
         }
         if (SwitchToggle != null)
         {
             SwitchToggle.Invoke();
         }
         SwitchOnFeedback?.PlayFeedbacks(this.transform.position);
     }
     else
     {
         CurrentSwitchState = SwitchStates.Off;
         if (SwitchOff != null)
         {
             SwitchOff.Invoke();
         }
         if (SwitchToggle != null)
         {
             SwitchToggle.Invoke();
         }
         SwitchOffFeedback?.PlayFeedbacks(this.transform.position);
     }
     ToggleFeedback?.PlayFeedbacks(this.transform.position);
 }
        public static void GetUserInputChanges(DataGridView dataGridView, ref Metadata metadata, FileEntryAttribute fileEntry)
        {
            int columnIndex = DataGridViewHandler.GetColumnIndexUserInput(dataGridView, fileEntry);

            if (columnIndex == -1)
            {
                return;                    //Column has not yet become aggregated or has already been removed
            }
            if (!DataGridViewHandler.IsColumnPopulated(dataGridView, columnIndex))
            {
                return;
            }

            metadata.PersonalRegionList.Clear();
            for (int rowIndex = 0; rowIndex < DataGridViewHandler.GetRowCount(dataGridView); rowIndex++)
            {
                SwitchStates switchStates = DataGridViewHandler.GetCellStatusSwichStatus(dataGridView, columnIndex, rowIndex);
                if (switchStates == SwitchStates.On)
                {
                    RegionStructure regionStructure = DataGridViewHandler.GetCellRegionStructure(dataGridView, columnIndex, rowIndex);
                    if (regionStructure != null)
                    {
                        metadata.PersonalRegionListAddIfNotAreaAndNameExists(regionStructure);
                    }
                }
            }
        }
Exemple #4
0
 /// <summary>
 /// On init, we set our current switch state
 /// </summary>
 protected virtual void Start()
 {
     CurrentSwitchState = InitialState;
     SwitchOffFeedback?.Initialization(this.gameObject);
     SwitchOnFeedback?.Initialization(this.gameObject);
     ToggleFeedback?.Initialization(this.gameObject);
 }
Exemple #5
0
        private void Switch_MouseClick(object sender, MouseEventArgs e)
        {
            switch (CurrentState)
            {
            case SwitchStates.On:
                CurrentState = SwitchStates.Off;
                this.Refresh();
                break;

            case SwitchStates.Off:
                CurrentState = SwitchStates.On;
                this.Refresh();
                break;
            }

            try
            {
                if (Switched != null)
                {
                    Switched(this, new SwitchedEventArgs(this, CurrentState));
                }

                // TODO: Debug; not working.
                //Switched?.Invoke(this, new SwitchedEventArgs(this, CurrentState));
            }
            catch (Exception exception)
            {
                throw exception;
            }
        }
 private void SetSwitchState()
 {
     if (triggerEntered && switchStates == SwitchStates.LIGHTS_ON)
     {
         switchStates = SwitchStates.LIGHTS_OFF;
     }
     else if (triggerEntered && switchStates == SwitchStates.LIGHTS_ON)
     {
         switchStates = SwitchStates.LIGHTS_ON;
     }
 }
Exemple #7
0
 /// <summary>
 /// Turns the switch off
 /// </summary>
 public virtual void TurnSwitchOff()
 {
     CurrentSwitchState = SwitchStates.Off;
     if (SwitchOff != null)
     {
         SwitchOff.Invoke();
     }
     if (SwitchToggle != null)
     {
         SwitchToggle.Invoke();
     }
     SwitchOffFeedback?.PlayFeedbacks(this.transform.position);
 }
 /// <summary>
 /// Use this method to go from one state to the other
 /// </summary>
 public virtual void SwitchState()
 {
     if (CurrentSwitchState == SwitchStates.Left)
     {
         CurrentSwitchState = SwitchStates.Right;
         _animator.SetTrigger("Right");
         if (SwitchOn != null)
         {
             SwitchOn.Invoke();
         }
     }
     else
     {
         CurrentSwitchState = SwitchStates.Left;
         _animator.SetTrigger("Left");
         if (SwitchOff != null)
         {
             SwitchOff.Invoke();
         }
     }
 }
 /// <summary>
 /// On init, we set our current switch state
 /// </summary>
 protected override void Initialization()
 {
     base.Initialization();
     CurrentSwitchState = InitialState;
     InitializeState();
 }
        //Check what data has been updated by users
        public static void GetUserInputChanges(DataGridView dataGridView, ref Metadata metadata, FileEntryAttribute fileEntryColumn)
        {
            int columnIndex = DataGridViewHandler.GetColumnIndexUserInput(dataGridView, fileEntryColumn);

            if (columnIndex == -1)
            {
                return;                    //Column has not yet become aggregated or has already been removed
            }
            if (!DataGridViewHandler.IsColumnPopulated(dataGridView, columnIndex))
            {
                return;
            }


            int keywordsStarts = DataGridViewHandler.GetRowHeaderItemStarts(dataGridView, headerKeywords);
            int keywordsEnds   = DataGridViewHandler.GetRowHeaderItemsEnds(dataGridView, headerKeywords);

            metadata.PersonalAlbum = (string)DataGridViewHandler.GetCellValueNullOrStringTrim(dataGridView, columnIndex, headerMedia, tagAlbum);
            if (metadata.PersonalAlbum != null)
            {
                metadata.PersonalAlbum = metadata.PersonalAlbum.Trim();
            }

            metadata.PersonalTitle = (string)DataGridViewHandler.GetCellValueNullOrStringTrim(dataGridView, columnIndex, headerMedia, tagTitle);
            if (metadata.PersonalTitle != null)
            {
                metadata.PersonalTitle = metadata.PersonalTitle.Trim();
            }

            metadata.PersonalDescription = (string)DataGridViewHandler.GetCellValueNullOrStringTrim(dataGridView, columnIndex, headerMedia, tagDescription);
            if (metadata.PersonalDescription != null)
            {
                metadata.PersonalDescription = metadata.PersonalDescription.Trim();
            }

            metadata.PersonalComments = (string)DataGridViewHandler.GetCellValueNullOrStringTrim(dataGridView, columnIndex, headerMedia, tagComments);
            if (metadata.PersonalComments != null)
            {
                metadata.PersonalComments = metadata.PersonalComments.Trim();
            }

            metadata.PersonalAuthor = (string)DataGridViewHandler.GetCellValueNullOrStringTrim(dataGridView, columnIndex, headerMedia, tagAuthor);
            if (metadata.PersonalAuthor != null)
            {
                metadata.PersonalAuthor = metadata.PersonalAuthor.Trim();
            }

            byte rating      = 255; //empty
            var  ratingValue = DataGridViewHandler.GetCellValue(dataGridView, columnIndex, headerMedia, tagRating);

            if (ratingValue == null)
            {
            }
            else if (ratingValue.GetType() == typeof(byte))
            {
                rating = (byte)ratingValue;
            }
            else if (ratingValue.GetType() == typeof(int))
            {
                rating = (byte)(int)ratingValue;
            }
            else if (ratingValue.GetType() == typeof(string))
            {
                byte.TryParse((string)ratingValue, out rating);
            }

            if (rating >= 0 && rating <= 5)
            {
                metadata.PersonalRating = rating;
            }
            else
            {
                metadata.PersonalRating = null;
            }

            for (int rowIndex = keywordsStarts; rowIndex <= keywordsEnds; rowIndex++)
            {
                DataGridViewGenericRow dataGridViewGenericRow = DataGridViewHandler.GetRowDataGridViewGenericRow(dataGridView, rowIndex);

                SwitchStates switchStates = DataGridViewHandler.GetCellStatusSwichStatus(dataGridView, columnIndex, rowIndex);
                if (switchStates == SwitchStates.On)
                {
                    //Add tag
                    if (!metadata.PersonalKeywordTags.Contains(new KeywordTag(dataGridViewGenericRow.RowName)))
                    {
                        metadata.PersonalKeywordTags.Add(new KeywordTag(dataGridViewGenericRow.RowName));
                    }
                }
                else
                {
                    //Remove tag
                    if (metadata.PersonalKeywordTags.Contains(new KeywordTag(dataGridViewGenericRow.RowName)))
                    {
                        metadata.PersonalKeywordTags.Remove(new KeywordTag(dataGridViewGenericRow.RowName));
                    }
                }
            }
        }
 // Use this for initialization
 void Start()
 {
     sl           = GameObject.Find("SceneMgr").GetComponent <SceneLoader>();
     switchStates = SwitchStates.LIGHTS_ON;
 }
Exemple #12
0
 public SwitchedEventArgs(Switch sender, SwitchStates state)
 {
     this.switchState = state;
 }
 public DataGridViewGenericCellStatus(MetadataBrokerType metadataBrokerTypes, SwitchStates switchStates, bool cellReadOnly)
 {
     MetadataBrokerType = metadataBrokerTypes;
     SwitchState        = switchStates;
     CellReadOnly       = cellReadOnly;
 }