Ejemplo n.º 1
0
        public static List <Point> Rotate(List <Point> points, DegreeType degreeType) //TODO update to any degree
        {
            var newPoints = new List <Point>();

            switch (degreeType)
            {
            case DegreeType.CW_90:
            case DegreeType.CCW_270:
                newPoints.AddRange(points.Select(point => new Point(point._y, -point._x)));
                break;

            case DegreeType.CCW_90:
            case DegreeType.CW_270:
                newPoints.AddRange(points.Select(point => new Point(-point._y, point._x)));
                break;

            case DegreeType.CW_180:
            case DegreeType.CCW_180:
                newPoints.AddRange(points.Select(point => new Point(-point._x, -point._y)));
                break;

            default:
                throw new ArgumentException("Needs Valid DegreeType");
            }
            return(newPoints);
        }
Ejemplo n.º 2
0
        private void Bounce(IReadOnlyCollection <IBoundary> obstacles, IBall ball, out DegreeType degreeType)
        {
            degreeType = DegreeType.None;

            if (obstacles.Count == 1)
            {
                BounceBall(obstacles.First(), ball, out degreeType);
            }
            else if (obstacles.Count > 0)
            {
                if (IsPosXEqual(obstacles))
                {
                    BallBounceFromVertEdge(ball);
                }
                else if (IsPosYEqual(obstacles))
                {
                    BallBounceFromHorizEdge(ball);
                }
                else
                {
                    // bounce with 3 Bricks e.g. set in following way:
                    //    ==
                    //    o=
                    //
                    ball.BounceBack();
                }
            }
        }
Ejemplo n.º 3
0
        public JsonResult Create([Bind(Include = "Name, remark")] DegreeType degreeType)
        {
            ResultMessage msg = new ResultMessage();

            try
            {
                msg = DoValidation(degreeType);

                if (!msg.Success)
                {
                    return(Json(msg, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    IDegreeTypeService cs = new DegreeTypeService(Settings.Default.db);
                    bool isSucceed        = cs.Create(degreeType);

                    msg.Success = isSucceed;
                    msg.Content = isSucceed ? "" : "添加失败";

                    return(Json(msg, JsonRequestBehavior.AllowGet));
                }
            }
            catch (Exception ex)
            {
                return(Json(new ResultMessage()
                {
                    Success = false, Content = ex.Message
                }, JsonRequestBehavior.AllowGet));
            }
        }
Ejemplo n.º 4
0
        protected void btnInsert_Click(object sender, EventArgs e)
        {
            try
            {
                degreeType = new DegreeType();

                degreeType.Description = txtDescription.Text;

                // Add to the database
                int results = DegreeTypeManager.Insert(degreeType);

                // Add to the list
                degreeTypes.Add(degreeType);

                Response.Write("Inserted " + results.ToString() + " rows...");
                Rebind();

                ddlDegreeTypes.SelectedIndex = degreeTypes.Count - 1;
                ddlDegreeTypes_SelectedIndexChanged(sender, e);
            }
            catch (Exception ex)
            {
                Response.Write(ex.Message);
            }
        }
Ejemplo n.º 5
0
 protected void PlaceNextHexagon(int id, DegreeType degreeType, EdgeOrientation eo)
 {
     var pos = _lastPlacedHexagon.GetPositionNextTo(eo);
     Board.GetLimits(pos);
     var hex = Board.CreateHexagon(id, degreeType, pos);
     _lastPlacedHexagon = hex;
 }
Ejemplo n.º 6
0
        public void UpdateTest()
        {
            DegreeType degreeType = DegreeTypeManager.LoadById(4);

            degreeType.Description = "Updated";
            Assert.IsTrue(DegreeTypeManager.Update(degreeType) > 0);
        }
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            try
            {
                // Get the degreeType we want to delete from the combo box
                degreeType = degreeTypes[ddlDegreeTypes.SelectedIndex];
                if (degreeType != null)
                {
                    // Delete from the database
                    degreeType.Delete();

                    //Remove from the list in the UI
                    degreeTypes.Remove(degreeType);

                    // Update Session to this new list
                    Session["degreeTypes"] = degreeTypes;

                    Rebind();
                }
                else
                {
                    throw new Exception("Please pick a Degree Type to delete");
                }
            }
            catch (Exception ex)
            {
                Response.Write("Error: " + ex.Message);
            }
        }
Ejemplo n.º 8
0
        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            try
            {
                int index = ddlDegreeTypes.SelectedIndex;

                degreeType = degreeTypes[ddlDegreeTypes.SelectedIndex];

                degreeType.Description = txtDescription.Text;

                int results = DegreeTypeManager.Update(degreeType);

                // Update the degreeTypes
                degreeTypes[ddlDegreeTypes.SelectedIndex] = degreeType;
                Response.Write("Updated " + results.ToString() + " rows...");
                Rebind();

                ddlDegreeTypes.SelectedIndex = index;
                ddlDegreeTypes_SelectedIndexChanged(sender, e);
            }
            catch (Exception ex)
            {
                Response.Write(ex.Message);
            }
        }
        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            try
            {
                // Get the degreeType we want to update from the combo box
                degreeType = degreeTypes[ddlDegreeTypes.SelectedIndex];

                if (degreeType != null)
                {
                    // Update from database
                    degreeType.Description = txtDescription.Text;

                    degreeType.Update();

                    // Put the updated one in the list
                    degreeTypes[ddlDegreeTypes.SelectedIndex] = degreeType;

                    // Update Session to this new list
                    Session["degreeTypes"] = degreeTypes;

                    Rebind();
                }
                else
                {
                    throw new Exception("Please pick a Degree Type to update");
                }
            }
            catch (Exception ex)
            {
                Response.Write("Error: " + ex.Message);
            }
        }
Ejemplo n.º 10
0
        public int GenerateDegree(DegreeType type)
        {
            const int degreeMargin   = 10;
            const int degreeRangeMax = 30;
            int       degree         = random.Next(degreeRangeMax);
            int       Degree         = degree - degreeRangeMax / 2;

            Degree += degreeRangeMax / 2;

            switch (type)
            {
            case DegreeType.None:
                break;

            case DegreeType.Corner:
                Degree += degreeMargin;
                break;

            case DegreeType.Average:
                Degree += degreeRangeMax;
                break;

            case DegreeType.Centre:
                Degree += degreeRangeMax * 2;
                Degree -= degreeMargin;
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(type), type, "Unknwon type of DegreeType");
            }
            return(Degree);
        }
        public static DuFenMiao FromDoubleDegree(double degree, bool isLon)
        {
            int    du   = (int)degree;
            int    fen  = (int)((degree - du) * 60);
            double miao = (((degree - du) * 60) - fen) * 60;
            int    type = 0;

            if (isLon)
            {
                if (degree >= 0)
                {
                    type = 1;
                }
                else
                {
                    type = 3;
                }
            }
            else
            {
                if (degree >= 0)
                {
                    type = 2;
                }
                else
                {
                    type = 4;
                }
            }
            return(new DuFenMiao()
            {
                Du = du, Fen = fen, Miao = miao, type = (DegreeType)type
            });
        }
Ejemplo n.º 12
0
        public Matrix4 RotX(double angle, DegreeType degType = DegreeType.Radians)
        {
            Matrix4 xRot   = XRotationMat(angle, degType);
            Matrix4 result = this * xRot;

            double[,] values = (this * XRotationMat(angle, degType)).Values;
            return(new Matrix4(values));
        }
Ejemplo n.º 13
0
        public async Task EditDegree(DegreeType editDegree)
        {
            var degree = _context.DegreeTypes.Find(editDegree.DegreeTypeId);

            degree.TypeName = editDegree.TypeName;
            _context.Update(degree);
            _context.SaveChanges();
        }
Ejemplo n.º 14
0
        //public static List<UserType> GetAllTeachersByArea()
        //{
        //    var GetAllTeachers = new List<UserType>();
        //    using (FindEducatorsContext db = new FindEducatorsContext())
        //    {
        //        GetAllTeachers = db.UserTypes.ToList();
        //    }
        //    return GetAllTeachers;
        //}
        #endregion

        #region Insert
        public static void InsertDegreeType(DegreeType degreeType)
        {
            using (FindEducatorsContext db = new FindEducatorsContext())
            {
                db.DegreeTypes.Add(degreeType);
                db.SaveChanges();
            }
        }
        // GET: DegreeTypes/Delete/5
        public ActionResult Delete(int id)
        {
            DegreeType degreeType = new DegreeType();

            degreeType.Id = id;
            degreeType.LoadById();
            return(View(degreeType));
        }
Ejemplo n.º 16
0
 public IDegree GetDegree(DegreeType type, string id)
 {
     return new Degree
         {
             Id = id,
             Type = type
         };
 }
Ejemplo n.º 17
0
        public DegreeType Get(int id)
        {
            DegreeType degreetype = new DegreeType();

            degreetype.Id = id;
            degreetype.LoadById();
            return(degreetype);
        }
Ejemplo n.º 18
0
        public void InsertTest()
        {
            DegreeType degreeType = new DegreeType {
                Description = "Bachelors"
            };

            Assert.AreNotEqual(0, DegreeTypeManager.Insert(degreeType));
        }
Ejemplo n.º 19
0
        // GET: DegreeType/Create
        public ActionResult Create()
        {
            ViewBag.Title = "Create";

            DegreeType degreeType = new DegreeType();

            return(View(degreeType));
        }
Ejemplo n.º 20
0
        public ActionResult Insert()
        {
            HttpClient client = InitializeClient();

            DegreeType degreeType = new DegreeType();

            return(View("Create", degreeType));
        }
Ejemplo n.º 21
0
 public void CalculateNewDegree(DegreeType type)
 {
     if (type != DegreeType)
     {
         movement.Degree = randomGenerator.GenerateDegree(type);
         DegreeType      = type;
     }
 }
Ejemplo n.º 22
0
        // GET: DegreeType/Delete/5
        public ActionResult Delete(int id)
        {
            IDegreeTypeService cs = new DegreeTypeService(Settings.Default.db);

            DegreeType dgt = cs.FindById(id);

            return(View(dgt));
        }
        protected void ddlDegreeTypes_SelectedIndexChanged(object sender, EventArgs e)
        {
            // get the degreeType that i want to work on
            degreeType = degreeTypes[ddlDegreeTypes.SelectedIndex];

            // put the description on the screen
            txtDescription.Text = degreeType.Description;
        }
Ejemplo n.º 24
0
 public static void UpdateDegreeType(DegreeType degreeType)
 {
     using (FindEducatorsContext db = new FindEducatorsContext())
     {
         var tempDegreetype = db.DegreeTypes.Single(x => x.Id == degreeType.Id);
         tempDegreetype.DegreeTypeName = degreeType.DegreeTypeName;
         db.SaveChanges();
     }
 }
Ejemplo n.º 25
0
        public ActionResult Remove(int id)
        {
            HttpClient          client   = InitializeClient();
            HttpResponseMessage response = client.GetAsync("DegreeType/" + id).Result;
            string     result            = response.Content.ReadAsStringAsync().Result;
            DegreeType degreeType        = JsonConvert.DeserializeObject <DegreeType>(result);

            return(View("Delete", degreeType));
        }
Ejemplo n.º 26
0
        // GET: DegreeType/Delete/5
        public ActionResult Delete(int id)
        {
            ViewBag.Title = "Delete";

            DegreeType degreeType = new DegreeType();

            degreeType = DegreeTypeManager.LoadById(id);
            return(View(degreeType));
        }
Ejemplo n.º 27
0
 public Student
 (
     string first, string last, DateTime dateOfBirth, IContactInfo contactInfo, IList <IClass> classes,
     string programOfStudy, DegreeType degree
 )
     : base(first, last, dateOfBirth, contactInfo, classes)
 {
     this.ProgramOfStudy = programOfStudy;
     this.PursuedDegree  = degree;
 }
        public void InsertTest()
        {
            DegreeType degreeType = new DegreeType();

            degreeType.Description = "Test Degree Type";

            bool result = degreeType.Insert();

            Assert.IsTrue(result);
        }
Ejemplo n.º 29
0
 public void SetSpecializedSites(int x, int y,
                                 VertexOrientation vo, VertexOrientation vo2, DegreeType degree)
 {
     var hex = Board[x, y];
     if (hex != null)
     {
         hex[vo].MakeSpecialSite(degree);
         hex[vo2].MakeSpecialSite(degree);
     }
 }
Ejemplo n.º 30
0
        public IEnumerable<IDegree> FindDegrees(DegreeType type, string keyWord)
        {
            IRestRequest request = new RestRequest(SearchResourceTemplate);
            request.AddUrlSegment("ResourceType", type.ResourceName);
            request.AddParameter("query", keyWord);

            IRestResponse<SearchResponse> response = _restClient.Execute<SearchResponse>(request);

            return response.Data.Results;
        }
Ejemplo n.º 31
0
        public static DegreeType GetDegreeTypeById(int degreeTypeId)
        {
            var degreeType = new DegreeType();

            using (FindEducatorsContext db = new FindEducatorsContext())
            {
                degreeType = db.DegreeTypes.Single(x => x.Id == degreeTypeId);
            }

            return(degreeType);
        }
Ejemplo n.º 32
0
        public static Matrix4 ZRotationMat(double angle, DegreeType degType = DegreeType.Radians)
        {
            double p = A.ToRadian(angle, degType);

            return(new Matrix4(new double[4, 4]
            {
                { A.Cos(p), -A.Sin(p), 0, 0 },
                { A.Sin(p), A.Cos(p), 0, 0 },
                { 0, 0, 1, 0 },
                { 0, 0, 0, 1 }
            }));
        }
Ejemplo n.º 33
0
 public void HashDegree(Color color, DegreeType degree, int quantity)
 {
     if (quantity == 0)
     {
         return;
     }
     Dictionary<int, ulong> dict = _coloredHashing[color].DegreeHash[degree];
     if (!dict.ContainsKey(quantity))
     {
         dict[quantity] = NextNewInt64();
     }
     Hash ^= dict[quantity];
 }
 public ActionResult Delete(int id, DegreeType degreeType)
 {
     try
     {
         // TODO: Add delete logic here
         degreeType.Delete();
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View(degreeType));
     }
 }
 public ActionResult Create(DegreeType degreeType)
 {
     try
     {
         // TODO: Add insert logic here
         degreeType.Insert();
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View(degreeType));
     }
 }
Ejemplo n.º 36
0
 public TradingMove(DegreeType tradeOut, int outNumber, DegreeType tradeIn)
 {
     TradeOut = tradeOut;
     OutQuantity = outNumber;
     TradeIn = tradeIn;
     if (TradeIn == DegreeType.None)
     {
         while (true)
         {
             TradeIn = (DegreeType) (RandomGenerator.Next(GameConstants.RealDegrees.Length) + 1);
             if (TradeIn != TradeOut)
             {
                 break;
             }
         }
     }
     _needed = new[]
                   {
                       new StudentGroup(TradeOut, OutQuantity)
                   };
 }
Ejemplo n.º 37
0
 public StudentGroup(DegreeType degree, int quantity)
 {
     Degree = degree;
     Quantity = quantity;
 }
Ejemplo n.º 38
0
 internal void MakeSpecialSite(DegreeType degree)
 {
     TradingSite = new SpecialTradingSite(degree);
 }
Ejemplo n.º 39
0
 internal void AddBackStudents(DegreeType[] degreeType)
 {
     if (degreeType == null) return;
     foreach (var degree in degreeType)
     {
         Students[degree] += 1;
     }
 }
Ejemplo n.º 40
0
 internal void EnrolStudents(DegreeType degree, int number)
 {
     _game.Hashing.HashDegree(Color, degree, Students[degree]);
     Students[degree] += number;
     _game.Hashing.HashDegree(Color, degree, Students[degree]);
 }
Ejemplo n.º 41
0
 internal void UntradeInStudents(DegreeType tradedIn)
 {
     Students[tradedIn] -= 1;
 }
Ejemplo n.º 42
0
{
    public class GraduateStudent : Student
    {
        public enum DegreeType { BA, BS }
        private DegreeType awardedDegreeType;
Ejemplo n.º 43
0
        private readonly Vertex[] _vertices = new Vertex[6]; // 6 vertices

        #endregion Fields

        #region Constructors

        public Hexagon(int id, DegreeType degree, Position position)
        {
            ProductionNumber = id;
            Degree = degree;
            Position = position;
        }
Ejemplo n.º 44
0
 public void UnTradeInStudent(DegreeType tradedIn)
 {
     CurrentUniversity.UntradeInStudents(tradedIn);
 }
Ejemplo n.º 45
0
 private DegreeType[][] CutStudents()
 {
     var dict = new DegreeType[NumberOfUniversities][];
     for (var i = 0; i < NumberOfUniversities; ++i)
     {
         dict[i] = _universities[i].CutStudents();
     }
     return dict;
 }
Ejemplo n.º 46
0
 public SpecialTradingSite(DegreeType degree)
 {
     TradeOutDegree = degree;
     _studentsNeeded =
         new StudentGroup(degree, TradeOutStudentQuantity);
 }
Ejemplo n.º 47
0
 protected void PlaceFirstHexagon(int id, DegreeType degreeType)
 {
     var hex = Board.CreateHexagon(id, degreeType, new Position(0, 0));
     _lastPlacedHexagon = hex;
 }
Ejemplo n.º 48
0
 internal Hexagon CreateHexagon(int id, DegreeType degree, Position position)
 {
     var hex = new Hexagon(id, degree, position);
     _hexagons.Add(hex);
     _hexgonPositions[position] = hex;
     if (!_id2HexgonMap.ContainsKey(id))
     {
         _id2HexgonMap[id] = new List<Hexagon>();
     }
     _id2HexgonMap[id].Add(hex);
     return hex;
 }
Ejemplo n.º 49
0
 public void HashDegree(Color color, DegreeType degree, int quantity)
 {
 }
Ejemplo n.º 50
0
 public void TradeInStudent(DegreeType tradedIn)
 {
     CurrentUniversity.EnrolStudents(tradedIn, 1);
 }
Ejemplo n.º 51
0
 public static char Transform(DegreeType degree)
 {
     switch (degree)
     {
         case DegreeType.Brick:
             return 'b';
         case DegreeType.Grain:
             return 'g';
         case DegreeType.Ore:
             return 'o';
         case DegreeType.Sheep:
             return 's';
         case DegreeType.Wood:
             return 'w';
         default:
             throw new Exception("Unknown degree type: " + degree);
     }
 }