Beispiel #1
0
        public override void GenerateXmlAttributes(System.Xml.XmlWriter writer)
        {
            base.GenerateXmlAttributes(writer);

            if (Radius.HasValue)
            {
                writer.WriteAttributeString(AttrName + "Radius", Radius.ToString());
            }
            if (BgColor.HasValue)
            {
                writer.WriteAttributeString(AttrName + "BgColor", BgColor.GetHashCode().ToString());
            }
            if (BgAlpha.HasValue)
            {
                writer.WriteAttributeString(AttrName + "BgAlpha", BgAlpha.ToString());
            }
            if (Sides.HasValue)
            {
                writer.WriteAttributeString(AttrName + "Sides", Sides.ToString());
            }

            if (_borderAttr != null)
            {
                _borderAttr.GenerateXmlAttributes(writer);
            }
        }
Beispiel #2
0
        public override string ToString()
        {
            StringBuilder sb = new StringBuilder();

            if (Dice > 0 && Sides > 0)
            {
                if (Dice > 1)
                {
                    sb.Append(Dice.ToString());
                }
                sb.Append("d");
                sb.Append(Sides.ToString());

                if (Modifier > 0)
                {
                    sb.Append("+");
                    sb.Append(Modifier.ToString());
                }
                else if (Modifier < 0)
                {
                    sb.Append(Modifier.ToString());
                }

                if (Keep > 0 && Keep < Dice)
                {
                    sb.Append(":");
                    sb.Append(Keep.ToString());
                }
            }
            else
            {
                sb.Append(Modifier.ToString());
            }
            return(sb.ToString());
        }
        public override JObject SaveToJsonObject(StiJsonSaveMode mode)
        {
            var jObject = base.SaveToJsonObject(mode);

            jObject.Add(new JProperty("Rect", SaveRectangleFToJsonObject(Rect)));
            jObject.Add(new JProperty("Sides", Sides.ToString()));
            jObject.Add(new JProperty("IsPrinting", IsPrinting));

            return(jObject);
        }
Beispiel #4
0
        /// <summary>
        /// 속성들을 Xml Attribute로 생성합니다.
        /// </summary>
        /// <param name="writer">Attribute를 쓸 Writer</param>
        public override void GenerateXmlAttributes(System.Xml.XmlWriter writer)
        {
            base.GenerateXmlAttributes(writer);

            if (Id.IsNotWhiteSpace())
            {
                writer.WriteAttributeString("Id", Id);
            }
            if (Value.HasValue)
            {
                writer.WriteAttributeString("Value", Value.ToString());
            }
            if (ShowValue.HasValue)
            {
                writer.WriteAttributeString("ShowValue", ShowValue.GetHashCode().ToString());
            }
            if (EditMode.HasValue)
            {
                writer.WriteAttributeString("EditMode", EditMode.GetHashCode().ToString());
            }
            if (Color.HasValue)
            {
                writer.WriteAttributeString("Color", Color.Value.ToHexString());
            }
            if (Alpha.HasValue)
            {
                writer.WriteAttributeString("Alpha", Alpha.ToString());
            }

            if (_border != null)
            {
                _border.GenerateXmlAttributes(writer);
            }

            if (Radius.HasValue)
            {
                writer.WriteAttributeString("Radius", Radius.ToString());
            }
            if (Sides.HasValue)
            {
                writer.WriteAttributeString("Sides", Sides.ToString());
            }

            if (_link != null)
            {
                _link.GenerateXmlAttributes(writer);
            }

            if (ToolText.IsNotWhiteSpace())
            {
                writer.WriteAttributeString("ToolText", ToolText);
            }
        }
Beispiel #5
0
        /// <summary>
        /// 속성들을 Xml Attribute로 생성합니다.
        /// </summary>
        /// <param name="writer">Attribute를 쓸 Writer</param>
        public override void GenerateXmlAttributes(System.Xml.XmlWriter writer)
        {
            base.GenerateXmlAttributes(writer);

            if (Sides.HasValue)
            {
                writer.WriteAttributeString("Sides", Sides.ToString());
            }
            if (StartAngle.HasValue)
            {
                writer.WriteAttributeString("StartAngle", StartAngle.ToString());
            }
            if (EndAngle.HasValue)
            {
                writer.WriteAttributeString("EndAngle", EndAngle.ToString());
            }
        }
Beispiel #6
0
        private Solution LiftBoard(Sides liftedSide, string moves)
        {
            var newBoardState = new Board
            {
                Size    = this.Size,
                Marbles = Marbles.Select(m => new Marble {
                    IsInHole = m.IsInHole, Number = m.Number, Position = new Position {
                        Row = m.Position.Row, Column = m.Position.Column
                    }
                }).ToArray(),
                Holes = Holes.Select(h => new Hole {
                    IsFilled = h.IsFilled, Number = h.Number, Position = new Position {
                        Row = h.Position.Row, Column = h.Position.Column
                    }
                }).ToArray(),
                Walls = this.Walls
            };

            DirectionResponse response = newBoardState.MoveMarbles(liftedSide);

            if (response.Success && !newBoardState.BoardStateDidNotChange(response.BoardState))
            {
                moves += liftedSide.ToString()[0];
                if (response.Finished)
                {
                    return new Solution {
                               Success = true, Route = moves
                    }
                }
                ;
                else
                {
                    bool marblesStateChanged = newBoardState.Marbles.Count(m => !m.IsInHole) != response.BoardState.Marbles.Count(m => !m.IsInHole);

                    newBoardState.UpdateBoardState(response.BoardState);
                    return(newBoardState.FindRoute(moves, marblesStateChanged));
                }
            }
            return(new Solution {
                Route = moves += '*'
            });
        }
        /// <summary>
        /// OVerrides the toString method and returns a string representation of the thrown dice
        /// </summary>
        /// <returns>string of the form 2w5+1</returns>
        public override string ToString()
        {
            string diceString = "";

            if (Amount == 0 || Sides == 0)
            {
                return(diceString = Adder.ToString());
            }

            diceString += Amount.ToString() + "w" + Sides.ToString();
            if (Adder != 0)
            {
                if (Adder > 0)
                {
                    diceString += "+";
                }
                diceString += Adder.ToString();
            }
            return(diceString);
        }
        public enum Sides { Nome = 0, Left = 1, Right = 2, Top = 4, Bottom = 8 } // Powers of 2
        public static void Main()
        {
            Sides leftRight = Sides.Left | Sides.Right;

            if ((leftRight & Sides.Left) != 0)
            {
                System.Console.WriteLine("Left is included");
            }

            string formatted = leftRight.ToString();

            System.Console.WriteLine($"leftRight includes: {formatted}");

            System.Console.WriteLine();
            Sides s = Sides.Left;

            s |= Sides.Right;
            System.Console.WriteLine(s == leftRight);

            s ^= Sides.Right;
            System.Console.WriteLine(s);
        }
Beispiel #9
0
        /// <summary>
        /// Chart 설정 또는 변량에 대해 XML 속성으로 생성합니다.
        /// </summary>
        /// <param name="writer">xml writer</param>
        public override void GenerateXmlAttributes(XmlWriter writer)
        {
            base.GenerateXmlAttributes(writer);

            if (Draw.HasValue)
            {
                writer.WriteAttributeString("DrawAnchors", Draw.GetHashCode().ToString());
            }
            if (Sides.HasValue)
            {
                writer.WriteAttributeString("AnchorSides", Sides.ToString());
            }
            if (Radius.HasValue)
            {
                writer.WriteAttributeString("AnchorRadius", Radius.ToString());
            }
            if (BorderColor.HasValue)
            {
                writer.WriteAttributeString("AnchorBorderColor", BorderColor.Value.ToHexString());
            }
            if (BorderThickness.HasValue)
            {
                writer.WriteAttributeString("AnchorBorderThickness", BorderThickness.ToString());
            }
            if (BgColor.HasValue)
            {
                writer.WriteAttributeString("AnchorBgColor", BgColor.Value.ToHexString());
            }
            if (Alpha.HasValue)
            {
                writer.WriteAttributeString("AnchorAlpha", Alpha.ToString());
            }
            if (BgAlpha.HasValue)
            {
                writer.WriteAttributeString("AnchorBgAlpha", BgAlpha.ToString());
            }
        }
Beispiel #10
0
        void ExecuteAction()
        {
            _goReference = Fsm.GetOwnerDefaultTarget(gameObject);

            if (_goReference == null)
            {
                if (!side.IsNone)
                {
                    side.Value = _side;
                }

                if (!sideAsString.IsNone)
                {
                    sideAsString.Value = _side.ToString();
                }

                return;
            }

            if (!point.IsNone)
            {
                _position = space == Space.Self ? _goReference.transform.TransformPoint(_position):_position;
            }
            else
            {
                _goPosition = Fsm.GetOwnerDefaultTarget(pointGameObject);
                _position   = _goPosition.transform.position;
            }

            _side = GetSide(_goReference.transform, _goReference.transform.position, _position);

            if (!side.IsNone)
            {
                side.Value = _side;
            }

            if (!sideAsString.IsNone)
            {
                sideAsString.Value = _side.ToString();
            }

            if (_previousSide != _side)
            {
                if (_side == Sides.Front)
                {
                    Fsm.Event(frontEvent);
                }
                if (_side == Sides.Back)
                {
                    Fsm.Event(backEvent);
                }
                if (_side == Sides.Top)
                {
                    Fsm.Event(topEvent);
                }
                if (_side == Sides.Bottom)
                {
                    Fsm.Event(bottomEvent);
                }
                if (_side == Sides.Left)
                {
                    Fsm.Event(leftEvent);
                }
                if (_side == Sides.Right)
                {
                    Fsm.Event(rightEvent);
                }
            }
        }
        /// <summary>
        /// Gets the filters, gets new lists using the filters, and reloads the page
        /// </summary>
        /// <param name="SearchTerms">Phrase to search for</param>
        /// <param name="Category">Entree, Side, or Drink</param>
        /// <param name="PriceMin">Min price</param>
        /// <param name="PriceMax">Max price</param>
        /// <param name="CalorieMin">min Calorie</param>
        /// <param name="CalorieMax">max Calorie</param>
        public void OnGet(string SearchTerms, string[] Category, double?PriceMin, double?PriceMax, int?CalorieMin, int?CalorieMax)
        {
            this.SearchTerms = SearchTerms;
            this.Category    = Category;
            this.PriceMin    = PriceMin;
            this.PriceMax    = PriceMax;
            this.CalorieMin  = CalorieMin;
            this.CalorieMax  = CalorieMax;
            Entrees          = Menu.Entrees();
            Sides            = Menu.Sides();
            Drinks           = Menu.Drinks();

            if (SearchTerms != null && SearchTerms != "")
            {
                string[] array = SearchTerms.Split(' ');
                int      count = 0;
                foreach (string k in array)
                {
                    array[count] = k.ToLower();
                    count++;
                }

                Entrees = Entrees.Where(entree => Entrees.ToString() != null && (entree.ToString().Contains(SearchTerms, StringComparison.OrdinalIgnoreCase) || array.Any(entree.Description.ToLower().Contains)));
                Sides   = Sides.Where(side => Sides.ToString() != null && (side.ToString().Contains(SearchTerms, StringComparison.OrdinalIgnoreCase) || array.Any(side.Description.ToLower().Contains)));
                Drinks  = Drinks.Where(drink => Drinks.ToString() != null && (drink.ToString().Contains(SearchTerms, StringComparison.OrdinalIgnoreCase) || array.Any(drink.Description.ToLower().Contains)));
            }

            if (Category.Count() != 0)
            {
                bool[] cont = new bool[3];

                foreach (string item in Category)
                {
                    switch (item)
                    {
                    case "Entree":
                        cont[0] = true;
                        break;

                    case "Side":
                        cont[1] = true;
                        break;

                    case "Drink":
                        cont[2] = true;
                        break;
                    }
                }
                if (!cont[0])
                {
                    Entrees = new List <IOrderItem>();
                }
                if (!cont[1])
                {
                    Sides = new List <IOrderItem>();
                }
                if (!cont[2])
                {
                    Drinks = new List <IOrderItem>();
                }
            }

            ///?PriceMin=0&PriceMax=1&Category=Side&CalorieMin=0&CalorieMax=100&SearchTerms=vokun

            if (CalorieMin != null && CalorieMax == null)
            {
                Entrees = Entrees.Where(entree => entree.Calories >= CalorieMin);
                Sides   = Sides.Where(side => side.Calories >= CalorieMin);
                Drinks  = Drinks.Where(drink => drink.Calories >= CalorieMin);
            }

            if (CalorieMin == null && CalorieMax != null)
            {
                Entrees = Entrees.Where(entree => entree.Calories <= CalorieMax);
                Sides   = Sides.Where(side => side.Calories <= CalorieMax);
                Drinks  = Drinks.Where(drink => drink.Calories <= CalorieMax);
            }

            if (CalorieMin != null && CalorieMax != null)
            {
                Entrees = Entrees.Where(entree => entree.Calories >= CalorieMin && entree.Calories <= CalorieMax);
                Sides   = Sides.Where(side => side.Calories >= CalorieMin && side.Calories <= CalorieMax);
                Drinks  = Drinks.Where(drink => drink.Calories >= CalorieMin && drink.Calories <= CalorieMax);
            }

            if (PriceMin != null && PriceMax == null)
            {
                Entrees = Entrees.Where(entree => entree.Price >= PriceMin);
                Sides   = Sides.Where(side => side.Price >= PriceMin);
                Drinks  = Drinks.Where(drink => drink.Price >= PriceMin);
            }

            if (PriceMin == null && PriceMax != null)
            {
                Entrees = Entrees.Where(entree => entree.Price <= PriceMax);
                Sides   = Sides.Where(side => side.Price <= PriceMax);
                Drinks  = Drinks.Where(drink => drink.Price <= PriceMax);
            }

            if (PriceMin != null && PriceMax != null)
            {
                Entrees = Entrees.Where(entree => entree.Price >= PriceMin && entree.Price <= PriceMax);
                Sides   = Sides.Where(side => side.Price >= PriceMin && side.Price <= PriceMax);
                Drinks  = Drinks.Where(drink => drink.Price >= PriceMin && drink.Price <= PriceMax);
            }

            Entrees = Entrees.ToList();
            Sides   = Sides.ToList();
            Drinks  = Drinks.ToList();

            /*
             * Entrees = Menu.Search(Entrees, SearchTerms);
             * Sides = Menu.Search(Sides, SearchTerms);
             * Drinks = Menu.Search(Drinks, SearchTerms);
             *
             * Entrees = Menu.FilterByCategory(Entrees, Category);
             * Sides = Menu.FilterByCategory(Sides, Category);
             * Drinks = Menu.FilterByCategory(Drinks, Category);
             *
             * Entrees = Menu.FilterByCalories(Entrees, CalorieMin, CalorieMax);
             * Sides = Menu.FilterByCalories(Sides, CalorieMin, CalorieMax);
             * Drinks = Menu.FilterByCalories(Drinks, CalorieMin, CalorieMax);
             *
             * Entrees = Menu.FilterByPrice(Entrees, PriceMin, PriceMax);
             * Sides = Menu.FilterByPrice(Sides, PriceMin, PriceMax);
             * Drinks = Menu.FilterByPrice(Drinks, PriceMin, PriceMax);*/
        }