예제 #1
0
파일: History.cs 프로젝트: rstens/hets
        /// <summary>
        /// Returns true if History instances are equal
        /// </summary>
        /// <param name="other">Instance of History to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(History other)
        {
            if (other is null)
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     Id == other.Id ||
                     Id.Equals(other.Id)
                     ) &&
                 (
                     HistoryText == other.HistoryText ||
                     HistoryText != null &&
                     HistoryText.Equals(other.HistoryText)
                 ) &&
                 (
                     CreatedDate == other.CreatedDate ||
                     CreatedDate != null &&
                     CreatedDate.Equals(other.CreatedDate)
                 ));
        }
예제 #2
0
        private void BotClient_OnResponse(string message, MessageType type)
        {
            switch (type)
            {
            case MessageType.History:
                this.Dispatcher.BeginInvoke((Action)(() =>
                {
                    if (message.Contains(requestName))
                    {
                        StartButton_Click(this, new RoutedEventArgs());
                    }
                    HistoryText.AppendText(message + "\n");
                    SendText.Focus();
                    HistoryText.ScrollToEnd();
                }));
                break;

            case MessageType.Metadata:
                this.Dispatcher.BeginInvoke((Action)(() =>
                {
                    MetaText.AppendText(message + "\n");
                    SendText.Focus();
                    MetaText.ScrollToEnd();
                }));

                break;

            default:
                break;
            }
        }
예제 #3
0
        /// <summary>
        /// Gets the hash code
        /// </summary>
        /// <returns>Hash code</returns>
        public override int GetHashCode()
        {
            // credit: http://stackoverflow.com/a/263416/677735
            unchecked // Overflow is fine, just wrap
            {
                int hash = 41;

                // Suitable nullity checks
                hash = hash * 59 + Id.GetHashCode();

                if (HistoryText != null)
                {
                    hash = hash * 59 + HistoryText.GetHashCode();
                }

                if (LastUpdateUserid != null)
                {
                    hash = hash * 59 + LastUpdateUserid.GetHashCode();
                }

                if (LastUpdateTimestamp != null)
                {
                    hash = hash * 59 + LastUpdateTimestamp.GetHashCode();
                }

                if (AffectedEntityId != null)
                {
                    hash = hash * 59 + AffectedEntityId.GetHashCode();
                }

                return(hash);
            }
        }
예제 #4
0
        void getFed()
        {
            if (awake == false)
            {
                postHistory($"{petName} is asleep.");
            }
            if (awake == true)
            {
                switch ((hungrinessLevel > 75 ? "High" :
                         hungrinessLevel > 55 ? "Mid" :
                         hungrinessLevel > 25 ? "Low" :
                         hungrinessLevel > 10 ? "Little" : "None")) //I think "NONE" is less than 1...
                {
                case "High":
                    postHistory($"{petName} was very hungry and ate a lot.");
                    hungrinessLevel = hungrinessLevel - 70;
                    happinessLevel  = happinessLevel + 50;
                    healthLevel++;
                    break;

                case "Mid":
                    postHistory($"{petName} was quite hungry and ate a lot");
                    hungrinessLevel = hungrinessLevel - 50;
                    happinessLevel  = happinessLevel + 30;
                    healthLevel++;
                    break;

                case "Low":
                    postHistory($"{petName} was moderately hungry and ate a snack.");
                    hungrinessLevel = hungrinessLevel - 20;
                    happinessLevel  = happinessLevel + 20;
                    break;

                case "Little":
                    postHistory($"{petName} was barely hungry so had a nibble.");
                    hungrinessLevel = 0;
                    happinessLevel  = happinessLevel + 5;
                    break;

                case "None":
                    postHistory($"{petName} won't eat any more.");
                    hungrinessLevel = 0;
                    happinessLevel  = happinessLevel - 5;
                    break;
                }
            }
            HistoryText.ScrollToEnd();
            RefreshPrintLabel();
        }
예제 #5
0
        void getCleaned()
        {
            switch ((stinkinessLevel > 75 ? "High" :
                     stinkinessLevel > 55 ? "Mid" :
                     stinkinessLevel > 25 ? "Low" :
                     stinkinessLevel > 1 ? "Little" : "None")) //I think "NONE" is less than 1...
            {
            case "High":
                postHistory("A big poo was cleaned up.");
                stinkinessLevel = stinkinessLevel - 70;
                happinessLevel  = happinessLevel + 50;
                healthLevel++;
                break;

            case "Mid":
                postHistory("A medium poo was cleaned up.");
                stinkinessLevel = stinkinessLevel - 50;
                happinessLevel  = happinessLevel + 30;
                break;

            case "Low":
                postHistory("A little poo was cleaned up.");
                stinkinessLevel = stinkinessLevel - 20;
                happinessLevel  = happinessLevel + 20;
                healthLevel++;

                break;

            case "Little":
                postHistory("The rest of the poo was cleaned up.");
                stinkinessLevel = 0;
                healthLevel++;

                happinessLevel = happinessLevel + 15;
                break;

            case "None":
                postHistory("There is no poo... for now.");
                stinkinessLevel = 0;
                break;
            }

            HistoryText.ScrollToEnd();
            RefreshPrintLabel();
        }
예제 #6
0
        protected override void Push(string pDisplayString, int pListIndex)
        {
            if (_separatorImage == null)
            {
                return;
            }

            float left = 0.0f;

            foreach (HistoryText text in currentHistory)
            {
                left += text.Width + _separatorImage.Size.Width;
            }
            var historyItem = new HistoryText(pListIndex, MaxItemPixelLength, pDisplayString, TextStyle, left);

            currentHistory.Add(historyItem);
            AddViewControl(historyItem);
            historyItem.Click = OnHistoryClick;
        }
예제 #7
0
파일: History.cs 프로젝트: rstens/hets
        /// <summary>
        /// Gets the hash code
        /// </summary>
        /// <returns>Hash code</returns>
        public override int GetHashCode()
        {
            // credit: http://stackoverflow.com/a/263416/677735
            unchecked // Overflow is fine, just wrap
            {
                int hash = 41;

                // Suitable nullity checks
                hash = hash * 59 + Id.GetHashCode();

                if (HistoryText != null)
                {
                    hash = hash * 59 + HistoryText.GetHashCode();
                }

                if (CreatedDate != null)
                {
                    hash = hash * 59 + CreatedDate.GetHashCode();
                }

                return(hash);
            }
        }
예제 #8
0
        /// <summary>
        /// Returns true if HistoryViewModel instances are equal
        /// </summary>
        /// <param name="other">Instance of HistoryViewModel to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(HistoryViewModel other)
        {
            if (other is null)
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     Id == other.Id ||
                     Id.Equals(other.Id)
                     ) &&
                 (
                     HistoryText == other.HistoryText ||
                     HistoryText != null &&
                     HistoryText.Equals(other.HistoryText)
                 ) &&
                 (
                     LastUpdateUserid == other.LastUpdateUserid ||
                     LastUpdateUserid != null &&
                     LastUpdateUserid.Equals(other.LastUpdateUserid)
                 ) &&
                 (
                     LastUpdateTimestamp == other.LastUpdateTimestamp ||
                     LastUpdateTimestamp != null &&
                     LastUpdateTimestamp.Equals(other.LastUpdateTimestamp)
                 ) &&
                 (
                     AffectedEntityId == other.AffectedEntityId ||
                     AffectedEntityId != null &&
                     AffectedEntityId.Equals(other.AffectedEntityId)
                 ));
        }
 public void registerHistoryText(HistoryText t)
 {
     texts.Add (t);
 }
예제 #10
0
 void postHistory(string message)
 {
     //Posts a message to the history box, automatically adds the timestamp and tabs, new line
     HistoryText.AppendText($"\n{getTimestamp()}:\t " + message);
 }