Example #1
0
        internal ImageEditorViewModel(SKBitmap bitmap, ImageEditorConfig config)
        {
            Config = config;

            cropperCanvas = new ImageCropperCanvasView(bitmap, config.CropAspectRatio);
            cropperCanvas.SetAspectRatio(new CropItem("crop_square", CropRotateType.CropSquare));

            mainCanvas = new TouchManipulationCanvasView(config);
            mainCanvas.AddBitmapToCanvas(bitmap.Copy(), BitmapType.Main);
            mainCanvas.TextBitmapClicked += MainCanvas_TextBitmapClicked;
            mainCanvas.TrashEnabled      += MainCanvas_TrashVisebled;
            ColorCollect = SkiaHelper.GetColors();
            CropCollect  = CropItem.GetCropItems(config.CanChangeCropAspectRatio);
            Message      = config?.LoadingText;
            MessagingCenter.Subscribe <Application>(this, "BBDroidBackButton", (sender) => OnBackPressed());
        }
Example #2
0
        void CreateInventory()
        {
            CropItem wheatItem   = new CropItem(wheatSprite, new Vector2(-100, -100), 600, 0, "wheat", 600);
            SeedItem wheatSeed   = new SeedItem(wheatSeedSprite, new Vector2(-100, -100), 100, 0, "wheat");
            CropItem lettuceItem = new CropItem(lettuceSprite, new Vector2(-100, -100), 250, 0, "lettuce", 250);
            SeedItem lettuceSeed = new SeedItem(lettuceSeedSprite, new Vector2(-100, -100), 50, 0, "lettuce");
            CropItem cornItem    = new CropItem(cornSprite, new Vector2(-100, -100), 75, 0, "corn", 50);
            SeedItem cornSeed    = new SeedItem(cornSeedSprite, new Vector2(-100, -100), 5, 0, "corn");
            MeatItem cowItem     = new MeatItem(cowSprite, new Vector2(-100, -100), 750, 0, "cow", 1150);
            MeatItem chickenItem = new MeatItem(chickenSprite, new Vector2(-100, -100), 300, 0, "chicken", 650);

            Inventory.Add(wheatItem);
            Inventory.Add(lettuceItem);
            Inventory.Add(cornItem);
            Inventory.Add(cowItem);
            Inventory.Add(chickenItem);
            seeds.Add(wheatSeed);
            seeds.Add(lettuceSeed);
            seeds.Add(cornSeed);
        }
Example #3
0
 private Mature GetMature(User _friendsInfo, int place)
 {
     JsonObject farmStatus = GetFUserInfo(_friendsInfo.userId, out dogJson);
     Land newLand = new Land(farmStatus.GetCollection()[place]);
     CropItem newCropItem = new CropItem(GetCropModel(newLand.a));
     string landStatus = "";
     string cropStatus = "";
     string dogId = "";
     string isHungry = "";
     dogId = dogJson.GetValue("dogId");
     isHungry = dogJson.GetValue("isHungry");
     Mature m = new Mature();
     m.userId = _friendsInfo.userId;
     m.userName = _friendsInfo.userName;
     m.place = place;
     landStatus = GetLandStatus(newLand, newCropItem);
     m.cName = landStatus;
     GetCropStatus(out cropStatus, newLand);
     m.cStatus = cropStatus;
     m.cId = newLand.a;
     m.cWeed = newLand.f;//f > 0有草
     m.cWorm = newLand.g;//g > 0有虫
     m.cDry = newLand.h.Equals("0") ? "Yes" : "No";// h = 0干旱
     m.hasDog = (dogId.Equals("0") || isHungry.Equals("1")) ? "No" : "Yes";
     //无狗或者无狗粮时等于没有狗
     m.cTime = Convert.ToInt64(newLand.q) + Convert.ToInt64(newCropItem.growthCycle) + Convert.ToInt64(newCropItem.growthCycleNext) * Convert.ToInt64(newLand.j);
     return m;
 }
Example #4
0
 private string GetLandStatus(Land newLand, CropItem newCropItem)
 {
     string landStatus;
     if (newLand.b.Equals("0"))
     {
         landStatus = "空地";
     }
     else if (newLand.b.Equals("7"))
     {
         landStatus = "枯萎";
     }
     else
     {
         landStatus = newCropItem.cName;
     }
     return landStatus;
 }
Example #5
0
 private CropGet getCropGet(string cId, string numCrop)
 {
     CropGet temp = new CropGet();
     temp.cropId = cId;
     CropItem tmpCropItem = new CropItem(GetCropModel(cId));
     temp.cropName = tmpCropItem.cName;
     if (cId.Equals(""))
     {
         temp.numCrop = 0;
     }
     else
     {
         temp.numCrop = Convert.ToInt32(numCrop);
     }
     return temp;
 }
Example #6
0
 private void FrmFarm_Load(object sender, EventArgs e)
 {
     configApply();
     /*
     //读取_shop信息
     try
     {
         readShop();
     }
     catch (Exception)
     {
         _shop = new JsonObject(ScanShop());
         //保存_shop信息
         saveShop();
     }*/
     //读取_crop
     try
     {
         readCrop();
         toLog("读取植物信息成功");
     }
     catch (Exception)
     {
         try
         {
             readShop();
         }
         catch (Exception)
         {
             _shop = new JsonObject(ScanShop());
             //保存_shop信息
             saveShop();
         }
     }
     foreach(string key in _crop["种子"].Keys)
     {
         comboBoxAutoPlant.Items.Add(key);
     }
     CropItem tempCropItem = new CropItem(GetCropModel(cId));
     comboBoxAutoPlant.Text = tempCropItem.cName;
     threadGetFriends = new Thread(new ThreadStart(ListFriends));
     //ListFriends();
     threadGetUserInfo = new Thread(new ThreadStart(this.GetUserInfo));
     threadGetFriends.Start();
     threadGetUserInfo.Start();
     Thread threadGetBagInfo = new Thread(new ThreadStart(this.getBagInfo));
     threadGetBagInfo.Start();
     timer2.Enabled = false;
     timer1.Enabled = false;
     timer3.Enabled = true;
     //getUserInfo();
 }
Example #7
0
 private void buySeed(string cid, string number)
 {
     string farmTime = FarmKey.GetFarmTime();
     string farmKey = FarmKey.GetFarmKey(farmTime, farmKeyEncodeString);
     string url = runUrl + "/bbs/source/plugin/qqfarm/core/mync.php?mod=repertory&act=buySeed";
     //uIdx=19991&cId=2&uinY=29991&number=2&farmTime=1298473054&farmKey=bc8ab86352bf312e86f204366eaf097b
     string postData = "uIdx=" + uIdx + "&cId=" + cid + "uinY=" + uinY + "&number=" + number + "&farmTime=" + farmTime + "&farmKey=" + farmKey;
     string content = "";
     try
     {
         content = HttpChinese.GetHtml(postData, cookie, url);
     }
     catch (Exception except)
     {
         toLog(except.Message);
         toLog("购买种子失败");
     }
     CropItem newCropItem = new CropItem(GetCropModel(cid));
     if (content.Contains("\"cId\":" + cid))
     {
         toLog("购买" + newCropItem.cName + "种子" + number + "个成功");
     }
     else
     {
         toLog("购买" + newCropItem.cName + "种子" + number + "个失败");
     }
 }
Example #8
0
 private void showFarmland(JsonObject farmStatus)
 {
     this.Invoke((MethodInvoker)delegate
     {
         listViewFarmland.Items.Clear();
     });
     string landStatus = "";
     string cropStatus = "";
     for (int i = 0; i < farmStatus.GetCollection().Count; i++)
     {
         ListViewItem lv = new ListViewItem();
         lv.SubItems[0].Text = i.ToString();
         Land newLand = new Land(farmStatus.GetCollection()[i]);
         CropItem newCropItem = new CropItem(GetCropModel(newLand.a));
         //lv.SubItems.Add(newLand.b.Equals("0") ? "空地":newShopItem.cName);
         landStatus = GetLandStatus(newLand, newCropItem);
         lv.SubItems.Add(landStatus);
         lv.SubItems.Add(newLand.f.Equals("0") ? "无" : newLand.f);
         lv.SubItems.Add(newLand.g.Equals("0") ? "无" : newLand.g);
         lv.SubItems.Add(newLand.h.Equals("0") ? "是" : "否");
         GetCropStatus(out cropStatus, newLand);
         lv.SubItems.Add(cropStatus);
         lv.SubItems.Add(TimeFormat.FormatTime((Convert.ToInt64(newLand.q) + Convert.ToInt64(newCropItem.growthCycle)).ToString()));
         this.Invoke((MethodInvoker)delegate
         {
             listViewFarmland.Items.Add(lv);
         });
     }
 }
Example #9
0
        private void LandPlant(string userId, JsonObject theFarmStatus)
        {
            string have = "";
            string result = "";
            User friendInfo = new User(GetUserModel(userId));
            CropItem cropInfo = new CropItem(GetCropModel(cId));

            if (!userId.Equals(""))
            {
                for (int i = 0; i < theFarmStatus.GetCollection().Count; i++)
                {
                    Land newLand = new Land(theFarmStatus.GetCollection()[i]);
                    have = newLand.b;
                    if (have.Equals("0"))//无植物
                    {
                        BagItem newBagItem = new BagItem(GetBagItemModel(cId));
                        if (_autoSeed && (Convert.ToInt32(newBagItem.amount) == 0))
                        {
                            buySeed(cId, "1");
                        }
                        else
                        { }
                        result = Plant(cId, userId, i.ToString());
                        if (result.Contains("\"farmlandIndex\":" + i.ToString()) && result.Contains("\"cId\":" + cId.ToString()))
                        {
                            toLog("往" + friendInfo.userName + "的农场的第" + i.ToString() + "号地种植" + cropInfo.cName + "成功");
                        }
                        else
                        {
                            toLog("往" + friendInfo.userName + "的农场的第" + i.ToString() + "号地种植" + cropInfo.cName + "失败");
                        }
                    }
                }
            }
        }
Example #10
0
 public void RemoveGrowCrop(CropItem growcrop)
 {
     growCrops.Remove(growcrop);
     CalcHarvestEP();
 }
Example #11
0
 public void AddGrowCrop(CropItem growcrop)
 {
     growCrops.Add(growcrop);
     CalcHarvestEP();
 }
Example #12
0
 public void RemoveCrop(CropItem crop)
 {
     crops.Remove(crop);
     CalcWaterEP();
     CalcFertilizeEP();
 }
Example #13
0
 public void AddCrop(CropItem crop)
 {
     crops.Add(crop);
     CalcWaterEP();
     CalcFertilizeEP();
 }
Example #14
0
        private static List<CropItem> GetImageCropperCrops(string dataTypeAlias = "Image Cropper")
        {
            List<CropItem> crops = null;
            try
            {
                if (_crops.ContainsKey(dataTypeAlias))
                {
                    crops = _crops[dataTypeAlias];
                }

                if (crops != null && crops.Any(c => c == null))
                {
                    var sb = new StringBuilder("Crops corrupt, rebuilding! > Corrupt set: ");
                    foreach (var crop in crops)
                    {
                        if (crop != null)
                        {
                            sb.AppendFormat("**{0}|{1}|{2}|{3}|{4}**", crop.Name, crop.Width, crop.Height, crop.KeepAspectRatio, crop.Position);
                        }
                        else
                        {
                            sb.AppendFormat("**NULL**");
                        }
                    }
                    ILog logger = LogManager.GetLogger(string.Empty);
                    logger.Error(new ApplicationException(sb.ToString()));
                    crops = null;
                }
            }
            catch (Exception ex)
            {
                ILog logger = LogManager.GetLogger(string.Empty);
                logger.Error(ex);
                crops = null;
            }

            if (crops == null)
            {
                lock (_syncLock)
                {
                    var dtd = umbraco.cms.businesslogic.datatype.DataTypeDefinition.GetAll().FirstOrDefault(i => i.DataType != null && i.DataType.DataTypeName == dataTypeAlias);
                    if (dtd != null)
                    {
                        var pvs = umbraco.cms.businesslogic.datatype.PreValues.GetPreValues(dtd.Id);
                        if (pvs != null && pvs.Count > 0)
                        {
                            var value = (pvs[0] as PreValue).Value;
                            var cropStrings = value.Split(new char[] { '|', ';' }, StringSplitOptions.RemoveEmptyEntries).Skip(1);
                            crops = new List<CropItem>();
                            foreach (var cropString in cropStrings)
                            {
                                var csp = cropString.Split(',');
                                var ci = new CropItem() { Name = csp[0], Width = int.Parse(csp[1]), Height = int.Parse(csp[2]), KeepAspectRatio = (csp[3] == "1"), Position = csp[4] };
                                crops.Add(ci);
                            }
                        }
                        if (_crops.ContainsKey(dataTypeAlias))
                        {
                            _crops[dataTypeAlias] = crops;
                        }
                        else
                        {
                            _crops.Add(dataTypeAlias, crops);
                        }
                    }
                }
            }
            return crops;
        }
Example #15
0
 private static CropItem AddCropToImageCropper(int width, int height, string dataTypeAlias = "Image Cropper")
 {
     var regCrops = GetImageCropperCrops();
     var name = width.ToString() + "x" + height.ToString();
     var newCrop = new CropItem() { Name = name, Width = width, Height = height, KeepAspectRatio = true, Position = "CM" };
     regCrops.Add(newCrop);
     var value = "umbracoFile,1,0|";
     foreach (var item in regCrops)
     {
         if (!value.EndsWith("|")) { value += ";"; }
         value += item.Name + "," + item.Width.ToString() + "," + item.Height.ToString() + "," + (item.KeepAspectRatio ? "1" : "0") + "," + item.Position;
     }
     var dtd = umbraco.cms.businesslogic.datatype.DataTypeDefinition.GetAll().FirstOrDefault(i => i.DataType != null && i.DataType.DataTypeName == dataTypeAlias);
     if (dtd != null)
     {
         var pvs = umbraco.cms.businesslogic.datatype.PreValues.GetPreValues(dtd.Id);
         var pv = pvs[0] as PreValue;
         pv.Value = value;
         pv.Save();
         if (_crops.ContainsKey(dataTypeAlias))
         {
             _crops[dataTypeAlias] = regCrops;
         }
         else
         {
             _crops.Add(dataTypeAlias, regCrops);
         }
         return newCrop;
     }
     return null;
 }