Пример #1
0
        private async void copyToolStripMenuItem_Click(object sender, EventArgs e)
        {
            mUnit copy = selectedUnit.Copy();

            using (UnitEditor ue = new UnitEditor(copy))
                if (ue.ShowDialog() == DialogResult.OK)
                {
                    string xml = await server.CheckUnitXml(ue.XML);

                    await galaxy.UpdateUnitXml(xml);
                }
        }
Пример #2
0
        public UnitEditor(mUnit mUnit)
        {
            InitializeComponent();

            if (mUnit == null)
            {
                throw new Exception("mUnit cannot be null");
            }

            this.mUnit = mUnit;

            Text = "Unit Editor";
        }
Пример #3
0
        private void pictureBox_MouseDown(object sender, MouseEventArgs e)
        {
            selectedUnit   = null;
            selectedRegion = null;

            if (e.Button == MouseButtons.Right)
            {
                updateToolStripMenuItem.Visible       = false;
                deleteToolStripMenuItem.Visible       = false;
                copyToolStripMenuItem.Visible         = false;
                updateRegionToolStripMenuItem.Visible = false;
                deleteRegionToolStripMenuItem.Visible = false;

                Point p = new Point((int)((e.X - cx) / zoom), (int)(-(e.Y - cy) / zoom));

                foreach (mUnit u in mUnits)
                {
                    if (!(u is mPlayerUnit) && Math.Pow(p.X - u.X, 2) + Math.Pow(p.Y - u.Y, 2) <= Math.Pow(u.R, 2))
                    {
                        selectedUnit = u;

                        updateToolStripMenuItem.Visible = true;
                        deleteToolStripMenuItem.Visible = true;
                        copyToolStripMenuItem.Visible   = true;

                        break;
                    }
                }

                foreach (Region r in regions)
                {
                    if (p.X >= r.Left && p.X <= r.Right && p.Y >= r.Bottom && p.Y <= r.Top)
                    {
                        selectedRegion = r;

                        updateRegionToolStripMenuItem.Visible = true;
                        deleteRegionToolStripMenuItem.Visible = true;

                        break;
                    }
                }

                contextMenuStrip.Show(MousePosition);
            }
        }
Пример #4
0
        private async void gatherEvents()
        {
            Queue <FlattiverseEvent> events = await server.GatherEvents();

            while (events.Count > 0)
            {
                FlattiverseEvent @event = events.Dequeue();

                if (@event is GoneUnitEvent)
                {
                    mUnit removed = mUnits.Find(u => u.Name == ((GoneUnitEvent)@event).Name);
                    mUnits.Remove(removed);
                }
                else if (@event is NewUnitEvent)
                {
                    Unit unit = ((UnitEvent)@event).Unit;

                    switch (unit)
                    {
                    case Buoy buoy: mUnits.Add(new mBuoy(buoy)); break;

                    case Meteoroid meteoroid: mUnits.Add(new mMeteoroid(meteoroid)); break;

                    case Moon moon: mUnits.Add(new mMoon(moon)); break;

                    case Planet planet: mUnits.Add(new mPlanet(planet)); break;

                    case Sun sun: mUnits.Add(new mSun(sun)); break;

                    case Target target: mUnits.Add(new mTarget(target)); break;

                    case PlayerUnit player: mUnits.Add(new mPlayerUnit(player)); break;
                    }
                }
                //else if (@event is UnitEvent)
                //Console.WriteLine("Unit Event");
                //else if (@event is UpdatedUnitEvent)
                //Console.WriteLine("UpdatedUnitEvent");
            }

            draw();
        }
Пример #5
0
        public static int UpdateUnit(mUnit pUnit)
        {
            int isSucess = 0;

            using (SqlConnection con = new SqlConnection(Global.connString))
            {
                con.Open();

                using (SqlCommand command = new SqlCommand("UPDATE tblUnit SET  [UnitType] = @UnitType, [BuildingID] = @BuildingID, [UnitNumber] = @UnitNumber, [FloorLevel] = @FloorLevel, " +
                                                           " [UnitSize] = @UnitSize, [UnitAddress] = @UnitAddress, [UnitCity] = @UnitCity, [Description] = @Description," +
                                                           " [Bedrooms] = @Bedrooms,[Bathrooms] = @Bathrooms,[Kitchen] = @Kitchen,[UnitPrice] = @UnitPrice,  " +
                                                           " [Garage] = @Garage, [Furnishing] = @Furnishing, [Available] = @Available, [UnitPictures] = @UnitPictures WHERE UnitID = @UnitID ", con))

                {
                    command.Parameters.AddWithValue("@UnitID", pUnit.UnitID);
                    command.Parameters.AddWithValue("@UnitType", pUnit.UnitType);
                    command.Parameters.AddWithValue("@BuildingID", pUnit.BuildingID);
                    command.Parameters.AddWithValue("@LandLordID", pUnit.LandLordID);
                    command.Parameters.AddWithValue("@UnitNumber", pUnit.UnitNumber);
                    command.Parameters.AddWithValue("@FloorLevel", pUnit.FloorLevel);
                    command.Parameters.AddWithValue("@UnitSize", pUnit.UnitSize);
                    command.Parameters.AddWithValue("@UnitAddress", pUnit.UnitAddress);
                    command.Parameters.AddWithValue("@UnitCity", pUnit.UnitCity);
                    command.Parameters.AddWithValue("@Description", pUnit.Description);
                    command.Parameters.AddWithValue("@Bedrooms", pUnit.Bedrooms);
                    command.Parameters.AddWithValue("@Bathrooms", pUnit.Bathrooms);
                    command.Parameters.AddWithValue("@Kitchen", pUnit.Kitchen);
                    command.Parameters.AddWithValue("@UnitPrice", pUnit.UnitPrice);
                    command.Parameters.AddWithValue("@Garage", pUnit.Garage);
                    command.Parameters.AddWithValue("@Furnishing", pUnit.Furnishing);
                    command.Parameters.AddWithValue("@Available", pUnit.Available);
                    command.Parameters.AddWithValue("@UnitPictures", pUnit.UnitPictures);


                    isSucess = command.ExecuteNonQuery();
                }
            }

            return(isSucess);
        }
Пример #6
0
        public static int AddUnit(mUnit pUnit)
        {
            int isSucess = 0;

            using (SqlConnection con = new SqlConnection(Global.connString))
            {
                con.Open();

                using (SqlCommand command = new SqlCommand("INSERT INTO tblUnit (UnitType, BuildingID, LandLordID, UnitNumber, FloorLevel , UnitSize, UnitAddress, UnitCity, Description, Bedrooms, Bathrooms, Kitchen, UnitPrice, Garage, Furnishing, Available, UnitPictures, UnitAddedOn) " +
                                                           " VALUES ( @UnitType, @BuildingID, @LandLordID, @UnitNumber, @FloorLevel, @UnitSize, @UnitAddress, @UnitCity, @Description , @Bedrooms,  @Bathrooms, @Kitchen, @UnitPrice, @Garage, @Furnishing, @Available, @UnitPictures, @UnitAddedOn ) ", con))
                {
                    command.Parameters.AddWithValue("@UnitType", pUnit.UnitType);
                    command.Parameters.AddWithValue("@BuildingID", pUnit.BuildingID);
                    command.Parameters.AddWithValue("@LandLordID", pUnit.LandLordID);
                    command.Parameters.AddWithValue("@UnitNumber", pUnit.UnitNumber);
                    command.Parameters.AddWithValue("@FloorLevel", pUnit.FloorLevel);
                    command.Parameters.AddWithValue("@UnitSize", pUnit.UnitSize);
                    command.Parameters.AddWithValue("@UnitAddress", pUnit.UnitAddress);
                    command.Parameters.AddWithValue("@UnitCity", pUnit.UnitCity);
                    command.Parameters.AddWithValue("@Description", pUnit.Description);
                    command.Parameters.AddWithValue("@Bedrooms", pUnit.Bedrooms);
                    command.Parameters.AddWithValue("@Bathrooms", pUnit.Bathrooms);
                    command.Parameters.AddWithValue("@Kitchen", pUnit.Kitchen);
                    command.Parameters.AddWithValue("@UnitPrice", pUnit.UnitPrice);
                    command.Parameters.AddWithValue("@Garage", pUnit.Garage);
                    command.Parameters.AddWithValue("@Furnishing", pUnit.Furnishing);
                    command.Parameters.AddWithValue("@Available", pUnit.Available);
                    command.Parameters.AddWithValue("@UnitPictures", pUnit.UnitPictures);
                    command.Parameters.AddWithValue("@UnitAddedOn", DateTime.Now);

                    isSucess = command.ExecuteNonQuery();
                }
            }



            return(isSucess);
        }