Esempio n. 1
0
        public void Visit(Element.Element element)
        {
            var random = new Random();

            var planet = element as Planet;

            planet.Population += (long)(planet.Population * (random.Next(1, 25) / 100m));
        }
Esempio n. 2
0
        public void Visit(Element.Element element)
        {
            var random = new Random();

            var planet = element as Planet;

            planet.Population -= (long)(random.Next(1000, 1000000));
        }
Esempio n. 3
0
        public void Visit(Element.Element element)
        {
            var random = new Random();

            var planet = element as Planet;

            planet.Population -= (long)(planet.Population * random.NextDouble());
        }
Esempio n. 4
0
        private void HoveringMoving(MouseEventArgs e)
        {
            Point currentLocation = e.Location;

            Element.Element currentHovered = null;

            #region 节点Hover检查
            for (int idx = this._nodes.Count - 1; idx >= 0; idx--)
            {
                NodeElement node = this._nodes[idx];
                if (node.CaughtBy(currentLocation))
                {
                    currentHovered = node;
                    break;
                }
                else
                {
                    AnchorElement anchor = node.AnchorCaughtBy(currentLocation);
                    if (anchor != null)
                    {
                        currentHovered = anchor;
                        break;
                    }
                }
            }
            #endregion

            #region 连接Hover检查
            for (int idx = this._connections.Count - 1; idx >= 0; idx--)
            {
                ConnectionElement conn = this._connections[idx];
                if (conn.CaughtBy(currentLocation))
                {
                    currentHovered = conn;
                    break;
                }
            }
            #endregion

            #region 更新Hovered元素
            if (currentHovered != this._theHovered)
            {
                if (currentHovered != null)
                {
                    currentHovered.Hovered = true;
                }
                if (this._theHovered != null)
                {
                    this._theHovered.Hovered = false;
                }
                this._theHovered = currentHovered;
            }
            #endregion
        }
Esempio n. 5
0
        public void Visit(Element.Element element)
        {
            if (!(element is Employee employee))
            {
                return;
            }

            // Provide 10% pay raise
            employee.Income *= 1.10;
            Console.WriteLine($"{employee.GetType().Name} {employee.Name}'s new income: {employee.Income}");
        }
Esempio n. 6
0
        public void Visit(Element.Element element)
        {
            if (!(element is Employee employee))
            {
                return;
            }

            // Provide 3 extra vacation days
            employee.VacationDays += 3;
            Console.WriteLine(
                $"{employee.GetType().Name} {employee.Name}'s new vacation days: {employee.VacationDays}");
        }
Esempio n. 7
0
        private void LeftMouseDown(MouseEventArgs e)
        {
            Point currentLocation = e.Location;

            this._clickLocation = currentLocation;
            Element.Element currentSelected = null;

            #region 节点Select检查
            for (int idx = this._nodes.Count - 1; idx >= 0; idx--)
            {
                NodeElement node = this._nodes[idx];
                if (node.CaughtBy(currentLocation))
                {
                    currentSelected = node;
                    break;
                }
                else
                {
                    AnchorElement anchor = node.AnchorCaughtBy(currentLocation);
                    if (anchor != null)
                    {
                        currentSelected = anchor;
                        break;
                    }
                }
            }
            #endregion

            #region 连接Select检查
            for (int idx = this._connections.Count - 1; idx >= 0; idx--)
            {
                ConnectionElement conn = this._connections[idx];
                if (conn.CaughtBy(currentLocation))
                {
                    currentSelected = conn;
                    break;
                }
            }
            #endregion

            #region 更新当前被选择的元素
            if (currentSelected != this._theSelected)
            {
                if (currentSelected != null)
                {
                    currentSelected.Selected = true;
                }
                if (this._theSelected != null)
                {
                    this._theSelected.Selected = false;
                }
                this._theSelected = currentSelected;
            }
            #endregion

            this._dragging = true;
            // 若为锚点,则开始进行连接行为
            if (!(this._theSelected is AnchorElement from))
            {
                return;
            }
            AnchorElement     tempTo   = ElementFactory.AnchorElement(currentLocation.X, currentLocation.Y, null, this);
            ConnectionElement tempConn = ElementFactory.ConnectionElement(@from, tempTo, this);
            this._tempConnection = tempConn;
            @from.Selected       = false;
            tempTo.Selected      = true;
            this._theSelected    = tempTo;
        }
Esempio n. 8
0
        public void Visit(Element.Element element)
        {
            var employee = element as Employee;

            employee.AnnualSalary *= 1.10m;
        }
Esempio n. 9
0
        public void Visit(Element.Element element)
        {
            var employee = element as Employee;

            employee.PaidTimeOffDays += 3;
        }