Beispiel #1
0
        public static Floorplan getHeadFloorplan()
        {
            Floorplan rs = new Floorplan();

            rs.description = "All Floorplan";
            return(rs);
        }
    internal Transform GetPrefab(Floorplan s)
    {
        switch (s)
        {
        case Floorplan.SolidFloor:
            return(FloorPrefab);

        case Floorplan.MeshFloor:
            return(FloorPrefab);

        case Floorplan.SolidWall:
            return(WallPrefab);

        case Floorplan.MeshWall:
            return(WallPrefab);

        case Floorplan.Door:
            return(DoorPrefab);

        case Floorplan.Window:
            return(WallPrefab);

        case Floorplan.SingleColumnWall:
            return(EdgeColumnPrefab);

        case Floorplan.DoubleColumnWall:
            return(EdgeColumnPrefab);

        case Floorplan.Column:
            return(SingleCornerColumnPrefab);
        }

        return(null);
    }
Beispiel #3
0
        public async Task <List <Device> > getDevicesByFloor(Floorplan floor)
        {
            JSONDevices devices = new JSONDevices();
            String      url     = "json.htm?type=devices&filter=all&used=true&order=Name&floor=" + floor.idx;
            var         request = new RestRequest(url, Method.GET);

            request.AddHeader("Content-Type", "application/json");
            request.AddHeader("Authorization", string.Format("Basic {0}", Convert.ToBase64String(Encoding.UTF8.GetBytes($"{username}:{password}"))));

            try
            {
                var respons = await client.Execute(request);

                if (respons != null)
                {
                    JsonDeserializer deserial = new JsonDeserializer();
                    devices = deserial.Deserialize <JSONDevices>(respons);
                }
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.WriteLine(e);
            }
            return(devices.result);
        }
Beispiel #4
0
        public string InsertSql(Floorplan entity)
        {
            string rs = "INSERT INTO floorplan (id,building_id,picture_id,sale_picture_id,description,type,is_split,is_studio,bedroom_count,"
                        + "bathroom_count,studyroom_count,open_baclony_count,enclosed_baclony_count,courtyard_count,orientation,"
                        + "internal_size,external_size,total_size,"
                        + "removed,creation_date,last_modified_date,enabled) VALUES (";

            rs += getString(entity.id);
            rs += COMMA + getString(entity.building_id);
            rs += COMMA + getStringNull(entity.picture_id);
            rs += COMMA + getStringNull(entity.sale_picture_id);
            rs += COMMA + getString(entity.description);
            rs += COMMA + getByte(entity.type);
            rs += COMMA + getByte(Utils.boolToByte(entity.is_split));
            rs += COMMA + getByte(Utils.boolToByte(entity.is_studio));
            rs += COMMA + getInt16(entity.bedroom_count);
            rs += COMMA + getInt16(entity.bathroom_count);
            rs += COMMA + getInt16(entity.studyroom_count);
            rs += COMMA + getInt16(entity.open_baclony_count);
            rs += COMMA + getInt16(entity.enclosed_baclony_count);
            rs += COMMA + getInt16(entity.courtyard_count);
            rs += COMMA + getInt16(entity.orientation);
            rs += COMMA + getDouble(entity.internal_size);
            rs += COMMA + getDouble(entity.external_size);
            rs += COMMA + getDouble(entity.total_size);

            rs += COMMA + getByte(Utils.boolToByte(entity.removed));
            rs += COMMA + getDate(entity.creation_date);
            rs += COMMA + getDate(entity.last_modified_date);
            rs += COMMA + getByte(Utils.boolToByte(entity.enabled));
            rs += ");";
            return(rs);
        }
Beispiel #5
0
        public async Task loadFloorplan()
        {
            fp = await APIService.Instance.getFloorplan();

            if (fp != null && APIService.Instance.status)
            {
                FloorplanSource = new Windows.UI.Xaml.Media.Imaging.BitmapImage(new Uri(APIService.Instance.apiURL + fp.Image));
                await loadDevices(fp);
            }
        }
Beispiel #6
0
 //[ValidateAntiForgeryToken]
 public ActionResult Edit([Bind(Include = "id,planName,active,width,height,numObjects, restID")] Floorplan floorplan)
 {
     if (ModelState.IsValid)
     {
         db.Entry(floorplan).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(floorplan));
 }
Beispiel #7
0
        public void UploadFloorplan_GetFloorplan_FloorplanDataCorrect()
        {
            _db.TableFloorplan.UploadFloorplan("Step4TableFloorplan_Floorplan", 15, 15, "");

            Floorplan testFloorplan = _db.TableFloorplan.GetFloorplan();

            Assert.That(testFloorplan.Name, Is.EqualTo("Step4TableFloorplan_Floorplan"));
            Assert.That(testFloorplan.Width, Is.EqualTo(15));
            Assert.That(testFloorplan.Height, Is.EqualTo(15));
            Assert.That(testFloorplan.FloorplanID, Is.EqualTo(1));
        }
Beispiel #8
0
        // GET: Floorplans/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Floorplan floorplan = db.Floorplan.Find(id);

            if (floorplan == null)
            {
                return(HttpNotFound());
            }
            return(View(floorplan));
        }
Beispiel #9
0
        public override void saveEntity()
        {
            if (this.entity == null)
            {
                this.entity = new Floorplan();
            }
            this.entity.project_id  = (string)this.comboBox_Project.SelectedValue;
            this.entity.building_id = (string)this.comboBox_Building.SelectedValue;
            if (!string.IsNullOrWhiteSpace(this.textBox_PictureId.Text))
            {
                this.entity.picture_id = this.textBox_PictureId.Text;
            }
            if (!string.IsNullOrWhiteSpace(this.textBox_SalePictureId.Text))
            {
                this.entity.sale_picture_id = this.textBox_SalePictureId.Text;
            }
            this.entity.type                   = (Byte)this.comboBox_Type.SelectedValue;
            this.entity.is_split               = this.checkBox_IsSplit.Checked;
            this.entity.is_studio              = this.checkBox_IsStudio.Checked;
            this.entity.bathroom_count         = (Int16)this.numericUpDown_BathRoom.Value;
            this.entity.bedroom_count          = (Int16)this.numericUpDown_BedRoom.Value;
            this.entity.courtyard_count        = (Int16)this.numericUpDown_CourtYard.Value;
            this.entity.external_size          = (Double)this.numericUpDown_ExternalSize.Value;
            this.entity.internal_size          = (Double)this.numericUpDown_InternalSize.Value;
            this.entity.studyroom_count        = (Int16)this.numericUpDown_StudyRoom.Value;
            this.entity.total_size             = (Double)this.numericUpDown_TotalSize.Value;
            this.entity.land_size              = (Double)this.numericUpDown_LandSize.Value;
            this.entity.open_baclony_count     = (Int16)this.numericUpDown_OpenBalcony.Value;
            this.entity.enclosed_baclony_count = (Int16)this.numericUpDown_EnclosedBalcony.Value;
            this.entity.orientation            = Utils.getOrientationValue(this.checkBox_Ori_East.Checked, this.checkBox_Ori_South.Checked, this.checkBox_Ori_West.Checked, this.checkBox_Ori_North.Checked);
            this.entity.description            = this.richTextBox_Description.Text;
            string originalId = this.entity.id;

            this.dao.save(this.entity);

            if (string.IsNullOrWhiteSpace(originalId))
            {
                string   apartmentsStr = this.richTextBox_Apartments.Text;
                string[] apartments    = apartmentsStr.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
                foreach (string apartment in apartments)
                {
                    Apartment tmpa        = new Apartment();
                    string    unit_number = apartment.Trim();
                    tmpa.unit_number  = unit_number;
                    tmpa.floorplan_id = this.entity.id;
                    tmpa.building_id  = this.entity.building_id;
                    this.apartmentDao.save(tmpa);
                }
            }
        }
Beispiel #10
0
        private async Task loadDevices(Floorplan fp)
        {
            if (fp != null && APIService.Instance.status)
            {
                List <Device> devices = await APIService.Instance.getDevicesByFloor(fp);

                DevicesItems = new ObservableCollection <Device>();

                devices.ForEach(delegate(Device d)
                {
                    d.reloadDevices = reloadDevices;
                    DevicesItems.Add(d);
                });
            }
        }
Beispiel #11
0
        //[ValidateAntiForgeryToken]
        public ActionResult DeleteConfirmed(int id)
        {
            Floorplan floorplan = db.Floorplan.Find(id);

            List <Bookings> bookings = db.Bookings.SqlQuery("SELECT * FROM bourguestMob.Bookings  WHERE restID = @rID ", new SqlParameter("@rID", floorplan.restID)).ToList();

            if (bookings.Count == 0)
            {
                db.Floorplan.Remove(floorplan);
                List <tableObject> tab = db.tableObject.SqlQuery("SELECT * FROM bourguestMob.tableObject WHERE floorplanID = @planID", new SqlParameter("@planID", id)).ToList();
                tab.ForEach(r => db.tableObject.Remove(r));
                db.SaveChanges();
            }
            return(RedirectToAction("Index"));
        }
Beispiel #12
0
        public ActionResult Create(Floorplan floorplan)
        {
            floorplan.id = 1;
            try
            {
                floorplan.id = db.Floorplan.OrderByDescending(t => t.id).FirstOrDefault().id + 1;
            }
            catch (NullReferenceException e)
            {
            }
            var resID = db.Restaurant.SqlQuery("SELECT * FROM bourguestMob.Restaurant WHERE Email = @email", new SqlParameter("@email", User.Identity.Name)).First();

            floorplan.restID = resID.id;
            if (ModelState.IsValid)
            {
                db.Floorplan.Add(floorplan);
                db.SaveChanges();
                return(Json(new { success = true }));
            }
            else
            {
                return(Json(new { success = false }));
            }
        }
 internal static Sprite Sprite(this Floorplan s)
 {
     return(FloorplanBridge.Instance.Floorplans.Sprites[(int)s]);
 }
Beispiel #14
0
        public override void renderEntity()
        {
            if (this.entity == null)
            {
                this.entity = new Apartment();
            }
            string floorplan_id = entity.floorplan_id;
            string building_id  = entity.building_id;
            string stage_id     = entity.stage_id;
            string project_id   = entity.project_id;

            if (!string.IsNullOrWhiteSpace(floorplan_id))
            {
                Floorplan floorplan = this.floorplanDao.queryById(floorplan_id);
                building_id = floorplan.building_id;
            }
            if (!string.IsNullOrWhiteSpace(building_id))
            {
                Building building = this.buildingDao.queryById(building_id);
                stage_id = building.stage_id;
            }
            if (!string.IsNullOrWhiteSpace(stage_id))
            {
                Stage stage = this.stageDao.queryById(stage_id);
                project_id = stage.project_id;
            }


            //project list
            if (string.IsNullOrWhiteSpace(project_id))
            {
                if (this.projectList != null && this.projectList.Count > 0)
                {
                    project_id = (string)this.comboBox_Project.SelectedValue;
                }
            }
            else
            {
                this.comboBox_Project.SelectedItem = Utils.getSelectedProject(this.projectList, project_id);
            }
            this.comboBox_Project_SelectedIndexChanged(null, null);
            //stage list
            if (string.IsNullOrWhiteSpace(stage_id))
            {
                if (this.stageList != null && this.stageList.Count > 0)
                {
                    stage_id = (string)this.comboBox_Stage.SelectedValue;
                }
            }
            else
            {
                this.comboBox_Stage.SelectedItem = Utils.getSelectedStage(this.stageList, stage_id);
            }
            this.comboBox_Stage_SelectedIndexChanged(null, null);
            //building list
            if (string.IsNullOrWhiteSpace(building_id))
            {
                if (this.buildingList != null && this.buildingList.Count > 0)
                {
                    building_id = (string)this.comboBox_Building.SelectedValue;
                }
            }
            else
            {
                this.comboBox_Building.SelectedItem = Utils.getSelectedBuilding(this.buildingList, building_id);
            }
            this.comboBox_Building_SelectedIndexChanged(null, null);

            //floorplan list
            if (string.IsNullOrWhiteSpace(floorplan_id))
            {
                if (this.floorplanList != null && this.floorplanList.Count > 0)
                {
                    floorplan_id = (string)this.comboBox_Floorplan.SelectedValue;
                }
            }
            else
            {
                this.comboBox_Floorplan.SelectedItem = Utils.getSelectedFloorplan(this.floorplanList, floorplan_id);
            }

            this.textBox_ColorScheme.Text            = this.entity.colorscheme;
            this.textBox_LotNumber.Text              = this.entity.lot_number;
            this.textBox_UnitNumber.Text             = this.entity.unit_number;
            this.numericUpDown_CarParking.Value      = this.entity.car_parking_count;
            this.numericUpDown_StorageRoom.Value     = this.entity.storageroom_count;
            this.numericUpDown_Floor.Value           = this.entity.floor;
            this.numericUpDown_Price.Value           = this.entity.price;
            this.numericUpDown_UnitEntitlement.Value = this.entity.unit_entitle_ment;
            this.checkBox_Penthouse.Checked          = this.entity.penthouse;
            this.checkBox_SoldOut.Checked            = this.entity.sold_out;
            this.richTextBox_Description.Text        = this.entity.description;
        }
Beispiel #15
0
        public static async void FloormapAsync(Grid grid, int px, int py, int sx, int sy, string header, JObject data)
        {
            Microsoft.AppCenter.Analytics.Analytics.TrackEvent("Create Floormap Widget");

            try
            {
                Floorplan flooritem = data.ToObject <Floorplan>();
                CrossLogger.Current.Debug("Floormap", "URL: " + flooritem.Url);

                var httpClient = new HttpClient();
                var svgString  = await httpClient.GetStringAsync(flooritem.Url);

                //Loop through SVG and find "ID" and add as Sensor
                MatchCollection matches = Regex.Matches(svgString, "(id=\")(.*)(.\\b(on|off))", RegexOptions.IgnoreCase);
                for (int j = 0; j < matches.Count; j++)
                {
                    string Itemid = matches[j].Groups[2].Value;
                    if (App.Config.Items.Find(s => s.Name == Itemid) == null)
                    {
                        CrossLogger.Current.Debug("Floormap", "Adding: " + Itemid);

                        RestService GetItemUpdate = new RestService();
                        string      state         = GetItemUpdate.GetItem(Itemid);

                        if (state != null)
                        {
                            App.TrackItem sensor = new App.TrackItem
                            {
                                Name  = Itemid,
                                State = state,
                                Type  = Itemtypes.Sensor
                            };
                            App.Config.Items.Add(sensor);
                        }
                    }
                }

                #region w_grid
                Grid w_grid = new Grid
                {
                    RowSpacing        = 0,
                    ColumnSpacing     = 0,
                    Padding           = new Thickness(0, 0, 0, 0),
                    BackgroundColor   = App.Config.CellColor,
                    VerticalOptions   = LayoutOptions.FillAndExpand,
                    HorizontalOptions = LayoutOptions.FillAndExpand,
                };
                grid.Children.Add(w_grid, px, px + sx, py, py + sy);
                #endregion w_grid

                #region Header
                w_grid.Children.Add(new Label
                {
                    Text                    = header,
                    FontSize                = Device.GetNamedSize(NamedSize.Medium, typeof(Label)),
                    TextColor               = App.Config.TextColor,
                    BackgroundColor         = App.Config.CellColor,
                    HorizontalTextAlignment = TextAlignment.Center,
                    VerticalTextAlignment   = TextAlignment.Start
                }, 0, 0);
                #endregion Header

                #region SVG
                SvgCachedImage svg = new SvgCachedImage
                {
                    DownsampleToViewSize = false,
                    CacheDuration        = TimeSpan.FromMilliseconds(1000),
                    Aspect = Aspect.AspectFit,
                    BitmapOptimizations = false,
                    Source = SvgImageSource.FromSvgString(svgString)
                };
                w_grid.Children.Add(svg, 0, 0);

                App.TrackItem svgImage = new App.TrackItem
                {
                    State    = svgString,
                    Header   = header,
                    Type     = Itemtypes.Floormap,
                    SvgImage = svg
                };
                App.Config.Items.Add(svgImage);
                #endregion SVG

                CrossLogger.Current.Debug("Floormap", "SVGBefore");
                foreach (App.TrackItem item in App.Config.Items.Where(n => n.Type == Itemtypes.Sensor))
                {
                    svgImage.State = UpdateOnOff(item, svgImage.State);
                }
                svgImage.SvgImage.Source = SvgImageSource.FromSvgString(svgImage.State);
                svgImage.SvgImage.ReloadImage();
                CrossLogger.Current.Debug("Floormap", "SVGAfter");

                //Button must be last to be added to work
                Button dummyButton = new Button
                {
                    HorizontalOptions = LayoutOptions.FillAndExpand,
                    VerticalOptions   = LayoutOptions.FillAndExpand,
                    BackgroundColor   = Color.Transparent,
                };
                w_grid.Children.Add(dummyButton, 0, 0);
                dummyButton.Clicked += OnDummyButtonClicked;
            }
            catch (Exception ex)
            {
                CrossLogger.Current.Error("Floormap", "Widgets.Floormap crashed: " + ex.ToString());
                Error(grid, px, py, sx, sy, ex.ToString());
            }
        }
 protected Module()
 {
     Keywords = new List<string>();
     Floorplan = new Floorplan();
     DecorationPoints = new List<Location>();
 }
Beispiel #17
0
        public override void renderEntity()
        {
            if (this.entity == null)
            {
                this.entity = new Floorplan();
            }

            //project list
            string project_id = this.entity.project_id;

            if (string.IsNullOrWhiteSpace(project_id))
            {
                if (projectList.Count > 0)
                {
                    project_id = (string)this.comboBox_Project.SelectedValue;
                }
            }
            else
            {
                this.comboBox_Project.SelectedItem = Utils.getSelectedProject(this.projectList, project_id);
            }
            this.comboBox_Project_SelectedIndexChanged(null, null);
            //stage list
            string   building_id = this.entity.building_id;
            Building building    = null;
            string   stage_id    = null;

            if (!string.IsNullOrWhiteSpace(building_id))
            {
                building = this.buildingDao.queryById(building_id);
                stage_id = building.stage_id;
            }
            if (string.IsNullOrWhiteSpace(stage_id))
            {
                if (stageList != null && stageList.Count > 0)
                {
                    stage_id = (string)this.comboBox_Stage.SelectedValue;
                }
            }
            else
            {
                this.comboBox_Stage.SelectedItem = Utils.getSelectedStage(this.stageList, stage_id);
            }
            this.comboBox_Stage_SelectedIndexChanged(null, null);
            //building list
            if (string.IsNullOrWhiteSpace(building_id))
            {
                if (buildingList != null && buildingList.Count > 0)
                {
                    building_id = (string)this.comboBox_Building.SelectedValue;
                }
            }
            else
            {
                this.comboBox_Building.SelectedItem = Utils.getSelectedBuilding(this.buildingList, building_id);
            }

            this.textBox_PictureId.Text = this.entity.picture_id;
            if (!string.IsNullOrWhiteSpace(this.entity.picture_id))
            {
                this.picture = this.MediaDao.queryById(this.entity.picture_id);
                if (this.picture != null)
                {
                    this.renderPicture();
                }
            }
            this.textBox_SalePictureId.Text = this.entity.sale_picture_id;
            if (!string.IsNullOrWhiteSpace(this.entity.sale_picture_id))
            {
                this.salePicture = this.MediaDao.queryById(this.entity.sale_picture_id);
                if (this.salePicture != null)
                {
                    this.renderSalePicture();
                }
            }

            this.comboBox_Type.SelectedItem          = Utils.getSelected(this.typeList, this.entity.type);
            this.checkBox_IsSplit.Checked            = this.entity.is_split;
            this.checkBox_IsStudio.Checked           = this.entity.is_studio;
            this.numericUpDown_BathRoom.Value        = this.entity.bathroom_count;
            this.numericUpDown_BedRoom.Value         = this.entity.bedroom_count;
            this.numericUpDown_CourtYard.Value       = this.entity.courtyard_count;
            this.numericUpDown_ExternalSize.Value    = (decimal)this.entity.external_size;
            this.numericUpDown_InternalSize.Value    = (decimal)this.entity.internal_size;
            this.numericUpDown_StudyRoom.Value       = this.entity.studyroom_count;
            this.numericUpDown_TotalSize.Value       = (decimal)this.entity.total_size;
            this.numericUpDown_LandSize.Value        = (decimal)this.entity.land_size;
            this.numericUpDown_OpenBalcony.Value     = this.entity.open_baclony_count;
            this.numericUpDown_EnclosedBalcony.Value = this.entity.enclosed_baclony_count;
            BeFun.Model.Domain.Orientation ori = Utils.getOrientation(this.entity.orientation);
            this.checkBox_Ori_East.Checked    = ori.east;
            this.checkBox_Ori_South.Checked   = ori.south;
            this.checkBox_Ori_West.Checked    = ori.west;
            this.checkBox_Ori_North.Checked   = ori.north;
            this.richTextBox_Description.Text = this.entity.description;
            if (!string.IsNullOrWhiteSpace(this.entity.id))
            {
                this.richTextBox_Apartments.ReadOnly = true;
            }
        }
    void Start()
    {
        Instance = this;
        PlacedModules = new Dictionary<ModuleScript, Vector3>();
        unfinishedModules = new Queue<ModuleScript>();
        Floorplan = new Floorplan();

        //here, pick a level "format" or "rule set" and broadcast it to clients
        //this should be able to be passed in from the lobby
        //this is also probably the best place to pick and broadcast a random seed (or, again, accept one from the lobby)
        int seed = 0;
        //int seed = (int)DateTime.Now.Ticks;
        LevelRNG = new System.Random(seed);
        Debug.Log("Seed:" + seed);
        Level = Level.ReadRulesXML("");

        Vector3 position = new Vector3(0, 0, 0);
        RootModule = Instantiate(ModuleContainerPrefab, position, Quaternion.identity) as ModuleScript;
        RootModule.Module = Level.RootModule;

        RootModule.BuildModule(2);
        PlacedModules.Add(RootModule, position);
        Floorplan.Merge(RootModule.Module.Floorplan, 0, 0, 0);

        unfinishedModules.Enqueue(RootModule);
    }