Beispiel #1
0
        /// <summary>
        /// You are not supposed to read this.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnDisplayMouseMove(object sender, MouseEventArgs e)
        {
            int        x = e.X;
            int        y = e.Y;
            GameOfLife m = this.model;

            if (m != null & m.Envir != null)
            {
                if (!this.controller.Running)
                {
                    Statics.GetFieldFromDisplayPos(x, y, m, this.display, out x, out y);
                    if (x >= m.SizeX || y >= m.SizeY)
                    {
                        return;
                    }

                    bool nc = (x != this.xlmp[0]) || (y != this.xlmp[1]);
                    // a secret
                    this.xlmp[0] = x;
                    this.xlmp[1] = y;

                    int sum = m.SumNeighbourHood(x, y);
                    if (m.Envir[x, y])
                    {
                        if (nc)
                        {
                            if (sum == 0)
                            {
                                string[] msgs = new string[] {
                                    "\"I'm so lonely, I think I'm going to die.\"",
                                    "\"What is the meaning of life, if there is nobody you can share it with?\"",
                                    "\"Knock, knock.\"\n\"Who's there?\"\n\"Death.\"\n\"x_x\""
                                };
                                int idx = new Random().Next(0, msgs.Length);
                                this.toolTips.SetToolTip(this.display,
                                                         msgs[idx]);
                            }
                        }
                    }
                    else
                    {
                        this.toolTips.SetToolTip(this.display, "");
                    }
                }
            }
        }