Пример #1
0
    public static Recipes Instance()
    {
        if (recipes == null)
        {
            recipes = new Recipes();
        }

        return recipes;
    }
Пример #2
0
	// Use this for initialization
	void Start () {
		if (!instance)
		{
			instance = this;
			DontDestroyOnLoad(gameObject);
		} else
		{
			Destroy(gameObject);
		}
		recipes = JSON.Parse (recipeText.text);
	}
Пример #3
0
 public Image runRecipe(Recipes recipe, Image img1, bool maskOnly)
 {
     switch (recipe)
     {
         case Recipes.TrimImage1:
             return TrimImage1(img1, maskOnly);
         case Recipes.TrimImage2:
             return TrimImage2(img1, maskOnly);
         case Recipes.TrimImage3:
             return TrimImage3(img1, maskOnly);
         case Recipes.TrimImage4:
             return TrimImage4(img1, maskOnly);
         case Recipes.RotateResize:
             return RotateResize(img1, maskOnly);
         case Recipes.Shrink:
             return _CVMan.ShrinkPic(img1);
         case Recipes.Not:
             return _CVMan.ModPicMorph(img1, CAPI.MorphMode.NOT, CAPI.MorphStructureEnum.MORPH_CROSS, 0, 0);
         case Recipes.BlackBorder10PX:
             return _CVMan.ModPicMorph(img1, CAPI.MorphMode.BORDER, CAPI.MorphStructureEnum.MORPH_CROSS, 10, 0);
     }
     throw new NotImplementedException();
 }
Пример #4
0
        public void Write(Recipes recipes)
        {
            WriteUnsignedVarInt((uint)recipes.Count);

            foreach (Recipe recipe in recipes)
            {
                if (recipe is ShapelessRecipe)
                {
                    WriteSignedVarInt(0);                     // Type

                    ShapelessRecipe rec = (ShapelessRecipe)recipe;
                    WriteVarInt(rec.Input.Count);
                    foreach (Item stack in rec.Input)
                    {
                        Write(stack);
                    }
                    WriteVarInt(1);
                    Write(rec.Result);
                    Write(new UUID(Guid.NewGuid()));
                }
                else if (recipe is ShapedRecipe)
                {
                    WriteSignedVarInt(1);                     // Type

                    ShapedRecipe rec = (ShapedRecipe)recipe;
                    WriteSignedVarInt(rec.Width);
                    WriteSignedVarInt(rec.Height);

                    for (int w = 0; w < rec.Width; w++)
                    {
                        for (int h = 0; h < rec.Height; h++)
                        {
                            Write(rec.Input[(h * rec.Width) + w]);
                        }
                    }
                    WriteVarInt(1);
                    Write(rec.Result);
                    Write(new UUID(Guid.NewGuid()));
                }
                else if (recipe is SmeltingRecipe)
                {
                    SmeltingRecipe rec = (SmeltingRecipe)recipe;
                    WriteSignedVarInt(rec.Input.Metadata == 0 ? 2 : 3);                     // Type
                    WriteSignedVarInt(rec.Input.Id);
                    if (rec.Input.Metadata != 0)
                    {
                        WriteSignedVarInt(rec.Input.Metadata);
                    }
                    Write(rec.Result);
                }
                else if (recipe is EnchantingRecipe)
                {
                    //var memoryStream = MiNetServer.MemoryStreamManager.GetStream();
                    //McpeWriter writer = new McpeWriter(memoryStream);

                    //writer.Write((byte) 3); // Count
                    //{
                    //	writer.Write((int) 1); // Cost
                    //	writer.Write((byte) 1); // Count
                    //	writer.Write((int) 9); // Id
                    //	writer.Write((int) 1); // Level
                    //	writer.Write("Test1"); // Level
                    //}

                    //Write(4); // Type
                    //var bytes = memoryStream.ToArray();
                    //Write(bytes.Length);
                    //Write(bytes);
                }
            }

            Write((byte)1);
        }
Пример #5
0
        string Infoline(List <HistoryEntry> syslist, StarScan.SystemNode sysnode)
        {
            string infostr      = "";
            string jumponium    = "";
            bool   hasMaterials = false;

            if (syslist.Count > 1)
            {
                infostr = string.Format("First visit {0}".T(EDTx.UserControlStarList_FV), EDDConfig.Instance.ConvertTimeToSelectedFromUTC(syslist.Last().EventTimeUTC).ToShortDateString());
            }

            #region information

            if (sysnode != null)
            {
                if (sysnode.starnodes != null)
                {
                    string st = sysnode.StarTypesFound();
                    if (st.HasChars())
                    {
                        st = " " + st;
                    }
                    int stars = sysnode.StarsScanned();
                    infostr = infostr.AppendPrePad(string.Format("{0} Star(s){1}".T(EDTx.UserControlStarList_CS), stars, st), Environment.NewLine);

                    string extrainfo = "";
                    string prefix    = Environment.NewLine;

                    foreach (StarScan.ScanNode sn in sysnode.Bodies)
                    {
                        if (sn.ScanData != null && checkBoxBodyClasses.Checked)
                        {
                            JournalScan sc            = sn.ScanData;
                            string      bodynameshort = sc.BodyName.ReplaceIfStartsWith(syslist[0].System.Name);

                            if (sc.IsStar) // brief notification for special or uncommon celestial bodies, useful to traverse the history and search for that special body you discovered.
                            {
                                // Sagittarius A* is a special body: is the centre of the Milky Way, and the only one which is classified as a Super Massive Black Hole. As far as we know...
                                if (sc.StarTypeID == EDStar.SuperMassiveBlackHole)
                                {
                                    extrainfo = extrainfo.AppendPrePad(string.Format("{0} is a super massive black hole".T(EDTx.UserControlStarList_SMBH), sc.BodyName), prefix);
                                }

                                // black holes
                                if (sc.StarTypeID == EDStar.H)
                                {
                                    extrainfo = extrainfo.AppendPrePad(string.Format("{0} is a black hole".T(EDTx.UserControlStarList_BH), sc.BodyName), prefix);
                                }

                                // neutron stars
                                if (sc.StarTypeID == EDStar.N)
                                {
                                    extrainfo = extrainfo.AppendPrePad(string.Format("{0} is a neutron star".T(EDTx.UserControlStarList_NS), sc.BodyName), prefix);
                                }

                                // white dwarf (D, DA, DAB, DAO, DAZ, DAV, DB, DBZ, DBV, DO, DOV, DQ, DC, DCV, DX)
                                string WhiteDwarf = "White Dwarf";
                                if (sc.StarTypeText.Contains(WhiteDwarf))
                                {
                                    extrainfo = extrainfo.AppendPrePad(string.Format("{0} is a {1} white dwarf star".T(EDTx.UserControlStarList_WD), sc.BodyName, sc.StarTypeID), prefix);
                                }

                                // wolf rayet (W, WN, WNC, WC, WO)
                                string WolfRayet = "Wolf-Rayet";
                                if (sc.StarTypeText.Contains(WolfRayet))
                                {
                                    extrainfo = extrainfo.AppendPrePad(string.Format("{0} is a {1} wolf-rayet star".T(EDTx.UserControlStarList_WR), sc.BodyName, sc.StarTypeID), prefix);
                                }

                                // giants. It should recognize all classes of giants.
                                if (sc.StarTypeText.Contains("Giant"))
                                {
                                    extrainfo = extrainfo.AppendPrePad(string.Format("{0} is a {1}".T(EDTx.UserControlStarList_OTHER), sc.BodyName, sc.StarTypeText), prefix);
                                }

                                // rogue planets - not sure if they really exists, but they are in the journal, so...
                                if (sc.StarTypeID == EDStar.RoguePlanet)
                                {
                                    extrainfo = extrainfo.AppendPrePad(string.Format("{0} is a rogue planet".T(EDTx.UserControlStarList_RP), sc.BodyName), prefix);
                                }
                            }

                            else

                            {
                                // Check if a non-star body is a moon or not. We want it to further refine our brief summary in the visited star list.
                                // To avoid duplicates, we need to apply our filters before on the bodies recognized as a moon, than do the same for the other bodies that do not fulfill that criteria.

                                if (sn.level >= 2 && sn.type == StarScan.ScanNodeType.body)

                                // Tell us that that special body is a moon. After all, it can be quite an outstanding discovery...
                                {
                                    // Earth-like moon
                                    if (sc.PlanetTypeID == EDPlanet.Earthlike_body)
                                    {
                                        extrainfo = extrainfo.AppendPrePad(string.Format("{0} is an earth like moon".T(EDTx.UserControlStarList_ELM), bodynameshort), prefix);
                                    }

                                    // Terraformable water moon
                                    if (sc.Terraformable == true && sc.PlanetTypeID == EDPlanet.Water_world)
                                    {
                                        extrainfo = extrainfo.AppendPrePad(string.Format("{0} is a terraformable water moon".T(EDTx.UserControlStarList_TWM), bodynameshort), prefix);
                                    }
                                    // Water moon
                                    if (sc.Terraformable == false && sc.PlanetTypeID == EDPlanet.Water_world)
                                    {
                                        extrainfo = extrainfo.AppendPrePad(string.Format("{0} is a water moon".T(EDTx.UserControlStarList_WM), bodynameshort), prefix);
                                    }

                                    // Terraformable moon
                                    if (sc.Terraformable == true && sc.PlanetTypeID != EDPlanet.Water_world)
                                    {
                                        extrainfo = extrainfo.AppendPrePad(string.Format("{0} is a terraformable moon".T(EDTx.UserControlStarList_TM), bodynameshort), prefix);
                                    }

                                    // Ammonia moon
                                    if (sc.PlanetTypeID == EDPlanet.Ammonia_world)
                                    {
                                        extrainfo = extrainfo.AppendPrePad(string.Format("{0} is an ammonia moon".T(EDTx.UserControlStarList_AM), bodynameshort), prefix);
                                    }
                                }

                                else

                                // Do the same, for all planets
                                {
                                    // Earth Like planet
                                    if (sc.PlanetTypeID == EDPlanet.Earthlike_body)
                                    {
                                        extrainfo = extrainfo.AppendPrePad(string.Format("{0} is an earth like planet".T(EDTx.UserControlStarList_ELP), bodynameshort), prefix);
                                    }

                                    // Terraformable water world
                                    if (sc.PlanetTypeID == EDPlanet.Water_world && sc.Terraformable == true)
                                    {
                                        extrainfo = extrainfo.AppendPrePad(string.Format("{0} is a terraformable water world".T(EDTx.UserControlStarList_TWW), bodynameshort), prefix);
                                    }
                                    // Water world
                                    if (sc.PlanetTypeID == EDPlanet.Water_world && sc.Terraformable == false)
                                    {
                                        extrainfo = extrainfo.AppendPrePad(string.Format("{0} is a water world".T(EDTx.UserControlStarList_WW), bodynameshort), prefix);
                                    }

                                    // Terraformable planet
                                    if (sc.Terraformable == true && sc.PlanetTypeID != EDPlanet.Water_world)
                                    {
                                        extrainfo = extrainfo.AppendPrePad(string.Format("{0} is a terraformable planet".T(EDTx.UserControlStarList_TP), bodynameshort), prefix);
                                    }

                                    // Ammonia world
                                    if (sc.PlanetTypeID == EDPlanet.Ammonia_world)
                                    {
                                        extrainfo = extrainfo.AppendPrePad(string.Format("{0} is an ammonia world".T(EDTx.UserControlStarList_AW), bodynameshort), prefix);
                                    }
                                }

                                if (sn.Signals != null)
                                {
                                    extrainfo = extrainfo.AppendPrePad(string.Format("{0} has signals".T(EDTx.UserControlStarList_Signals), bodynameshort), prefix);
                                }
                            }
                        }

                        // Landable bodies with valuable materials
                        if (sn.ScanData != null && sn.ScanData.IsLandable == true && sn.ScanData.HasMaterials && checkBoxJumponium.Checked == true)
                        {
                            hasMaterials = true;

                            int basic    = 0;
                            int standard = 0;
                            int premium  = 0;

                            foreach (KeyValuePair <string, double> mat in sn.ScanData.Materials)
                            {
                                string usedin = Recipes.UsedInSythesisByFDName(mat.Key);
                                if (usedin.Contains("FSD-Basic"))
                                {
                                    basic++;
                                }
                                if (usedin.Contains("FSD-Standard"))
                                {
                                    standard++;
                                }
                                if (usedin.Contains("FSD-Premium"))
                                {
                                    premium++;
                                }
                            }

                            // string MaterialsBrief = sn.ScanData.DisplayMaterials(4).ToString();
                            //System.Diagnostics.Debug.WriteLine("{0} {1} {2} {3} {4}", sn.fullname , basic, standard, premium, MaterialsBrief);

                            if (basic > 0 || standard > 0 || premium > 0)
                            {
                                int mats = basic + standard + premium;

                                StringBuilder jumpLevel = new StringBuilder();

                                if (basic != 0)
                                {
                                    jumpLevel.AppendPrePad(basic + "/" + Recipes.FindSynthesis("FSD", "Basic").Count + " Basic".T(EDTx.UserControlStarList_BFSD), ", ");
                                }
                                if (standard != 0)
                                {
                                    jumpLevel.AppendPrePad(standard + "/" + Recipes.FindSynthesis("FSD", "Standard").Count + " Standard".T(EDTx.UserControlStarList_SFSD), ", ");
                                }
                                if (premium != 0)
                                {
                                    jumpLevel.AppendPrePad(premium + "/" + Recipes.FindSynthesis("FSD", "Premium").Count + " Premium".T(EDTx.UserControlStarList_PFSD), ", ");
                                }

                                jumponium = jumponium.AppendPrePad(Environment.NewLine + string.Format("{0} has {1} level elements.".T(EDTx.UserControlStarList_LE), sn.ScanData.BodyName, jumpLevel));
                            }
                        }
                    }

                    int total = sysnode.StarPlanetsScanned();

                    if (total > 0)
                    {
                        int totalwithoutstars = total - stars;

                        if (totalwithoutstars > 0)
                        {
                            infostr = infostr.AppendPrePad(string.Format("{0} Other bodies".T(EDTx.UserControlStarList_OB), totalwithoutstars.ToString()), ", ");
                        }

                        if (sysnode.FSSTotalBodies.HasValue && total < sysnode.FSSTotalBodies.Value)          // only show if you've not got them all
                        {
                            infostr += ", " + "Total".T(EDTx.UserControlStarList_Total) + " " + sysnode.FSSTotalBodies.Value.ToString();
                        }

                        infostr = infostr.AppendPrePad(extrainfo, prefix);
                    }
                    else
                    {   // we need this to allow the panel to scan also through systems which has only stars
                        infostr = infostr.AppendPrePad(extrainfo, prefix);
                    }
                    if (hasMaterials == true && checkBoxJumponium.Checked == true)
                    {
                        infostr = infostr.AppendPrePad(Environment.NewLine + Environment.NewLine + "This system has materials for FSD boost: ".T(EDTx.UserControlStarList_FSD));
                        infostr = infostr.AppendPrePad(jumponium);
                    }
                }
            }

            return(infostr);
        }
Пример #6
0
        private void Display()
        {
            //DONT turn on sorting in the future, thats not how it works.  You click and drag to sort manually since it gives you
            // the order of recipies.
            List <Tuple <Recipes.Recipe, int> > wantedList = null;

            System.Diagnostics.Trace.WriteLine(BaseUtils.AppTicks.TickCount100 + " SY " + displaynumber + " Begin Display");

            if (last_he != null)
            {
                List <MaterialCommodities> mcl = last_he.MaterialCommodity.Sort(false);
                int fdrow = dataGridViewSynthesis.FirstDisplayedScrollingRowIndex;      // remember where we were displaying

                Recipes.ResetUsed(mcl);

                wantedList = new List <Tuple <Recipes.Recipe, int> >();

                string        recep       = SQLiteDBClass.GetSettingString(DbRecipeFilterSave, "All");
                string[]      recipeArray = recep.Split(';');
                string        levels      = SQLiteDBClass.GetSettingString(DbLevelFilterSave, "All");
                string[]      lvlArray    = (levels == "All" || levels == "None") ? new string[0] : levels.Split(';');
                string        materials   = SQLiteDBClass.GetSettingString(DbMaterialFilterSave, "All");
                List <string> matList;

                if (materials == "All" || materials == "None")
                {
                    matList = new List <string>();
                }
                else
                {
                    matList = materials.Split(';').Where(x => !string.IsNullOrEmpty(x)).Select(m => matLookUp.Where(u => u.Item2 == m).First().Item1).ToList();
                }

                for (int i = 0; i < Recipes.SynthesisRecipes.Count; i++)
                {
                    int rno = (int)dataGridViewSynthesis.Rows[i].Tag;
                    dataGridViewSynthesis.Rows[i].Cells[2].Value = Recipes.HowManyLeft(mcl, Recipes.SynthesisRecipes[rno]).Item1.ToStringInvariant();
                    bool visible = true;

                    if (recep == "All" && levels == "All" && materials == "All")
                    {
                        visible = true;
                    }
                    else
                    {
                        visible = false;
                        if (recep == "All")
                        {
                            visible = true;
                        }
                        else
                        {
                            visible = recipeArray.Contains(Recipes.SynthesisRecipes[rno].name);
                        }
                        if (levels == "All")
                        {
                            visible = visible && true;
                        }
                        else
                        {
                            visible = visible && lvlArray.Contains(Recipes.SynthesisRecipes[rno].level);
                        }
                        if (materials == "All")
                        {
                            visible = visible && true;
                        }
                        else
                        {
                            var included = matList.Intersect <string>(Recipes.SynthesisRecipes[rno].ingredients.ToList <string>());
                            visible = visible && included.Count() > 0;
                        }
                    }

                    dataGridViewSynthesis.Rows[i].Visible = visible;
                }

                for (int i = 0; i < Recipes.SynthesisRecipes.Count; i++)
                {
                    int rno = (int)dataGridViewSynthesis.Rows[i].Tag;
                    if (dataGridViewSynthesis.Rows[i].Visible)
                    {
                        Tuple <int, int, string, string> res = Recipes.HowManyLeft(mcl, Recipes.SynthesisRecipes[rno], Wanted[rno]);
                        //System.Diagnostics.Debug.WriteLine("{0} Recipe {1} executed {2} {3} ", i, rno, Wanted[rno], res.Item2);

                        using (DataGridViewRow row = dataGridViewSynthesis.Rows[i])
                        {
                            row.Cells[3].Value       = Wanted[rno].ToStringInvariant();
                            row.Cells[4].Value       = res.Item2.ToStringInvariant();
                            row.Cells[5].Value       = res.Item3;
                            row.Cells[5].ToolTipText = res.Item4;
                        }
                    }
                    if (Wanted[rno] > 0 && (dataGridViewSynthesis.Rows[i].Visible || isEmbedded))
                    {
                        wantedList.Add(new Tuple <Recipes.Recipe, int>(Recipes.SynthesisRecipes[rno], Wanted[rno]));
                    }
                }

                dataGridViewSynthesis.RowCount = Recipes.SynthesisRecipes.Count;         // truncate previous shopping list..

                if (!isEmbedded)
                {
                    Recipes.ResetUsed(mcl);
                    List <MaterialCommodities> shoppinglist = Recipes.GetShoppingList(wantedList, mcl);
                    shoppinglist.Sort(delegate(MaterialCommodities left, MaterialCommodities right) { return(left.Details.Name.CompareTo(right.Details.Name)); });

                    foreach (MaterialCommodities c in shoppinglist)        // and add new..
                    {
                        Object[] values = { c.Details.Name, "", c.scratchpad.ToStringInvariant(), "", c.Details.Shortname };
                        int      rn     = dataGridViewSynthesis.Rows.Add(values);
                        dataGridViewSynthesis.Rows[rn].ReadOnly = true;     // disable editing wanted..
                    }
                }

                if (fdrow >= 0 && dataGridViewSynthesis.Rows[fdrow].Visible)        // better check visible, may have changed..
                {
                    dataGridViewSynthesis.FirstDisplayedScrollingRowIndex = fdrow;
                }
            }

            if (OnDisplayComplete != null)
            {
                OnDisplayComplete(wantedList);
            }

            System.Diagnostics.Trace.WriteLine(BaseUtils.AppTicks.TickCount100 + " SY " + displaynumber + " Load Finished");
        }
Пример #7
0
        public IActionResult AddRecipe(Recipes recipe)
        {
            recipeDAL.AddRecipe(recipe);

            return(RedirectToAction("Index", "Home"));
        }
Пример #8
0
        public Recipes ReadRecipes()
        {
            Recipes recipes = new Recipes();

            int count = ReadInt();

            for (int i = 0; i < count; i++)
            {
                int recipeType = ReadInt();
                int len        = ReadInt();
                if (recipeType < 0 || len == 0)
                {
                    Log.Error("Read void recipe");
                    continue;
                }

                if (recipeType == 0)
                {
                    //const ENTRY_SHAPELESS = 0;
                    ShapelessRecipe recipe          = new ShapelessRecipe();
                    int             ingrediensCount = ReadInt();         //
                    for (int j = 0; j < ingrediensCount; j++)
                    {
                        recipe.Input.Add(ReadItem());
                    }
                    ReadInt();                     // 1?
                    recipe.Result = ReadItem();
                    recipe.Id     = ReadUUID();    // Id
                    recipes.Add(recipe);
                }
                else if (recipeType == 1)
                {
                    //const ENTRY_SHAPED = 1;
                    int          width  = ReadInt();           // Width
                    int          height = ReadInt();           // Height
                    ShapedRecipe recipe = new ShapedRecipe(width, height);
                    if (width > 3 || height > 3)
                    {
                        throw new Exception("Wrong number of ingredience. Width=" + width + ", height=" + height);
                    }
                    for (int w = 0; w < width; w++)
                    {
                        for (int h = 0; h < height; h++)
                        {
                            recipe.Input[(h * width) + w] = ReadItem();
                        }
                    }

                    int resultCount = ReadInt();                     // 1?
                    for (int j = 0; j < resultCount; j++)
                    {
                        recipe.Result = ReadItem();
                    }
                    recipe.Id = ReadUUID();                     // Id
                    recipes.Add(recipe);
                }
                else if (recipeType == 2)
                {
                    //const ENTRY_FURNACE = 2;
                    SmeltingRecipe recipe = new SmeltingRecipe();
                    short          meta   = ReadShort();        // input (with metadata)
                    short          id     = ReadShort();        // input (with metadata)
                    Item           result = ReadItem();         // Result
                    recipe.Input  = ItemFactory.GetItem(id, meta);
                    recipe.Result = result;
                    recipes.Add(recipe);
                }
                else if (recipeType == 3)
                {
                    //const ENTRY_FURNACE_DATA = 3;
                    SmeltingRecipe recipe = new SmeltingRecipe();
                    short          id     = ReadShort();        // input (with metadata)
                    short          meta   = ReadShort();        // input (with metadata)
                    Item           result = ReadItem();         // Result
                    recipe.Input  = ItemFactory.GetItem(id, meta);
                    recipe.Result = result;
                    recipes.Add(recipe);
                }
                else if (recipeType == 4)
                {
                    Log.Error("Reading ENCHANT_LIST");
                    //const ENTRY_ENCHANT_LIST = 4;
                    int enchantmentListCount = ReadByte();                     // count
                    for (int j = 0; j < enchantmentListCount; j++)
                    {
                        ReadInt();                          // Cost
                        byte enchantmentCount = ReadByte(); // EnchantCount
                        for (int k = 0; k < enchantmentCount; k++)
                        {
                            ReadInt();                             // Id
                            ReadInt();                             // Level(strenght)
                        }
                        string name = ReadString();                // Name
                        Log.Error("Enchant: " + name);
                    }
                }
                else
                {
                    Log.Error($"Read unknown recipe type: {recipeType}, lenght: {len}");
                    ReadBytes(len);
                }
            }

            ReadByte();             // Clean (1) or update (0)

            return(recipes);
        }
Пример #9
0
        public IRequest Marshall(UpdateLayerRequest updateLayerRequest)
        {
            IRequest request = new DefaultRequest(updateLayerRequest, "AmazonOpsWorks");
            string   target  = "OpsWorks_20130218.UpdateLayer";

            request.Headers["X-Amz-Target"] = target;

            request.Headers["Content-Type"] = "application/x-amz-json-1.1";


            string uriResourcePath = "";

            if (uriResourcePath.Contains("?"))
            {
                int    queryPosition = uriResourcePath.IndexOf("?", StringComparison.OrdinalIgnoreCase);
                string queryString   = uriResourcePath.Substring(queryPosition + 1);
                uriResourcePath = uriResourcePath.Substring(0, queryPosition);

                foreach (string s in queryString.Split('&', ';'))
                {
                    string[] nameValuePair = s.Split('=');
                    if (nameValuePair.Length == 2 && nameValuePair[1].Length > 0)
                    {
                        request.Parameters.Add(nameValuePair[0], nameValuePair[1]);
                    }
                    else
                    {
                        request.Parameters.Add(nameValuePair[0], null);
                    }
                }
            }

            request.ResourcePath = uriResourcePath;


            using (StringWriter stringWriter = new StringWriter(CultureInfo.InvariantCulture))
            {
                JsonWriter writer = new JsonWriter(stringWriter);
                writer.WriteObjectStart();

                if (updateLayerRequest != null && updateLayerRequest.IsSetLayerId())
                {
                    writer.WritePropertyName("LayerId");
                    writer.Write(updateLayerRequest.LayerId);
                }
                if (updateLayerRequest != null && updateLayerRequest.IsSetName())
                {
                    writer.WritePropertyName("Name");
                    writer.Write(updateLayerRequest.Name);
                }
                if (updateLayerRequest != null && updateLayerRequest.IsSetShortname())
                {
                    writer.WritePropertyName("Shortname");
                    writer.Write(updateLayerRequest.Shortname);
                }
                if (updateLayerRequest != null)
                {
                    if (updateLayerRequest.Attributes != null && updateLayerRequest.Attributes.Count > 0)
                    {
                        writer.WritePropertyName("Attributes");
                        writer.WriteObjectStart();
                        foreach (string updateLayerRequestAttributesKey in updateLayerRequest.Attributes.Keys)
                        {
                            string attributesListValue;
                            bool   attributesListValueHasValue = updateLayerRequest.Attributes.TryGetValue(updateLayerRequestAttributesKey, out attributesListValue);
                            writer.WritePropertyName(updateLayerRequestAttributesKey);

                            writer.Write(attributesListValue);
                        }
                        writer.WriteObjectEnd();
                    }
                }
                if (updateLayerRequest != null && updateLayerRequest.IsSetCustomInstanceProfileArn())
                {
                    writer.WritePropertyName("CustomInstanceProfileArn");
                    writer.Write(updateLayerRequest.CustomInstanceProfileArn);
                }

                if (updateLayerRequest != null && updateLayerRequest.CustomSecurityGroupIds != null && updateLayerRequest.CustomSecurityGroupIds.Count > 0)
                {
                    List <string> customSecurityGroupIdsList = updateLayerRequest.CustomSecurityGroupIds;
                    writer.WritePropertyName("CustomSecurityGroupIds");
                    writer.WriteArrayStart();

                    foreach (string customSecurityGroupIdsListValue in customSecurityGroupIdsList)
                    {
                        writer.Write(StringUtils.FromString(customSecurityGroupIdsListValue));
                    }

                    writer.WriteArrayEnd();
                }

                if (updateLayerRequest != null && updateLayerRequest.Packages != null && updateLayerRequest.Packages.Count > 0)
                {
                    List <string> packagesList = updateLayerRequest.Packages;
                    writer.WritePropertyName("Packages");
                    writer.WriteArrayStart();

                    foreach (string packagesListValue in packagesList)
                    {
                        writer.Write(StringUtils.FromString(packagesListValue));
                    }

                    writer.WriteArrayEnd();
                }

                if (updateLayerRequest != null && updateLayerRequest.VolumeConfigurations != null && updateLayerRequest.VolumeConfigurations.Count > 0)
                {
                    List <VolumeConfiguration> volumeConfigurationsList = updateLayerRequest.VolumeConfigurations;
                    writer.WritePropertyName("VolumeConfigurations");
                    writer.WriteArrayStart();

                    foreach (VolumeConfiguration volumeConfigurationsListValue in volumeConfigurationsList)
                    {
                        writer.WriteObjectStart();
                        if (volumeConfigurationsListValue != null && volumeConfigurationsListValue.IsSetMountPoint())
                        {
                            writer.WritePropertyName("MountPoint");
                            writer.Write(volumeConfigurationsListValue.MountPoint);
                        }
                        if (volumeConfigurationsListValue != null && volumeConfigurationsListValue.IsSetRaidLevel())
                        {
                            writer.WritePropertyName("RaidLevel");
                            writer.Write(volumeConfigurationsListValue.RaidLevel);
                        }
                        if (volumeConfigurationsListValue != null && volumeConfigurationsListValue.IsSetNumberOfDisks())
                        {
                            writer.WritePropertyName("NumberOfDisks");
                            writer.Write(volumeConfigurationsListValue.NumberOfDisks);
                        }
                        if (volumeConfigurationsListValue != null && volumeConfigurationsListValue.IsSetSize())
                        {
                            writer.WritePropertyName("Size");
                            writer.Write(volumeConfigurationsListValue.Size);
                        }
                        writer.WriteObjectEnd();
                    }
                    writer.WriteArrayEnd();
                }
                if (updateLayerRequest != null && updateLayerRequest.IsSetEnableAutoHealing())
                {
                    writer.WritePropertyName("EnableAutoHealing");
                    writer.Write(updateLayerRequest.EnableAutoHealing);
                }
                if (updateLayerRequest != null && updateLayerRequest.IsSetAutoAssignElasticIps())
                {
                    writer.WritePropertyName("AutoAssignElasticIps");
                    writer.Write(updateLayerRequest.AutoAssignElasticIps);
                }
                if (updateLayerRequest != null && updateLayerRequest.IsSetAutoAssignPublicIps())
                {
                    writer.WritePropertyName("AutoAssignPublicIps");
                    writer.Write(updateLayerRequest.AutoAssignPublicIps);
                }

                if (updateLayerRequest != null)
                {
                    Recipes customRecipes = updateLayerRequest.CustomRecipes;
                    if (customRecipes != null)
                    {
                        writer.WritePropertyName("CustomRecipes");
                        writer.WriteObjectStart();

                        if (customRecipes != null && customRecipes.Setup != null && customRecipes.Setup.Count > 0)
                        {
                            List <string> setupList = customRecipes.Setup;
                            writer.WritePropertyName("Setup");
                            writer.WriteArrayStart();

                            foreach (string setupListValue in setupList)
                            {
                                writer.Write(StringUtils.FromString(setupListValue));
                            }

                            writer.WriteArrayEnd();
                        }

                        if (customRecipes != null && customRecipes.Configure != null && customRecipes.Configure.Count > 0)
                        {
                            List <string> configureList = customRecipes.Configure;
                            writer.WritePropertyName("Configure");
                            writer.WriteArrayStart();

                            foreach (string configureListValue in configureList)
                            {
                                writer.Write(StringUtils.FromString(configureListValue));
                            }

                            writer.WriteArrayEnd();
                        }

                        if (customRecipes != null && customRecipes.Deploy != null && customRecipes.Deploy.Count > 0)
                        {
                            List <string> deployList = customRecipes.Deploy;
                            writer.WritePropertyName("Deploy");
                            writer.WriteArrayStart();

                            foreach (string deployListValue in deployList)
                            {
                                writer.Write(StringUtils.FromString(deployListValue));
                            }

                            writer.WriteArrayEnd();
                        }

                        if (customRecipes != null && customRecipes.Undeploy != null && customRecipes.Undeploy.Count > 0)
                        {
                            List <string> undeployList = customRecipes.Undeploy;
                            writer.WritePropertyName("Undeploy");
                            writer.WriteArrayStart();

                            foreach (string undeployListValue in undeployList)
                            {
                                writer.Write(StringUtils.FromString(undeployListValue));
                            }

                            writer.WriteArrayEnd();
                        }

                        if (customRecipes != null && customRecipes.Shutdown != null && customRecipes.Shutdown.Count > 0)
                        {
                            List <string> shutdownList = customRecipes.Shutdown;
                            writer.WritePropertyName("Shutdown");
                            writer.WriteArrayStart();

                            foreach (string shutdownListValue in shutdownList)
                            {
                                writer.Write(StringUtils.FromString(shutdownListValue));
                            }

                            writer.WriteArrayEnd();
                        }
                        writer.WriteObjectEnd();
                    }
                }
                if (updateLayerRequest != null && updateLayerRequest.IsSetInstallUpdatesOnBoot())
                {
                    writer.WritePropertyName("InstallUpdatesOnBoot");
                    writer.Write(updateLayerRequest.InstallUpdatesOnBoot);
                }

                writer.WriteObjectEnd();

                string snippet = stringWriter.ToString();
                request.Content = System.Text.Encoding.UTF8.GetBytes(snippet);
            }


            return(request);
        }
Пример #10
0
        /******************
        * Private methods
        ******************/

        /// <summary>
        /// Checks if item is ingredient of an available recipe, setting <see cref="CurrentRecipe"/> accordingly.
        /// </summary>
        /// <returns><c>true</c>, if found a recipe with the given ingredient, <c>false</c> otherwise.</returns>
        /// <param name="object">Object.</param>
        private bool TryForRecipe(SObject @object, out Recipe foundRecipe)
        {
            foundRecipe = Recipes.FirstOrDefault(recipe => recipe.AcceptsInput(@object));
            return(foundRecipe != null);
        }
Пример #11
0
 // Use this for initialization
 void Start()
 {
     recipes = GameObject.FindGameObjectWithTag ("Recipes").GetComponent<Recipes>();
     showBook = true;
 }
Пример #12
0
        async internal Task ParseBarrel(string rootUrl)
        {
            var uri      = new Uri(rootUrl);
            var document = await LoadFromCache(rootUrl);

            var barrelRecipeTable = document.QuerySelector("table.wikitable");

            var items = barrelRecipeTable.QuerySelector("tr")
                        .QuerySelectorAll("div.factorio-icon")
                        .Select(async div => await ParseFactorioIcon(div, uri))
                        .Select(t => t.Result)
                        .ToList();

            foreach (var resource in items.Take(3))
            {
                AddProduct(resource);
            }

            var input       = items[0];
            var time        = items[1];
            var output      = items[2];
            var techElement = barrelRecipeTable.QuerySelectorAll("tr").Skip(1).First();
            var tech        = await ParseFactorioIconImage(techElement, uri, techElement.QuerySelector("a").TextContent);

            var barrelRecipe = new
            {
                inputs  = new[] { RecipePart(input) },
                outputs = new[] { RecipePart(output) },
                time    = time?.image?.text,
                tech
            };

            Recipes.Add(barrelRecipe);

            foreach (var table in document.QuerySelectorAll("table.wikitable").Skip(1))
            {
                foreach (var row in table?.QuerySelectorAll("tr").Skip(1))
                {
                    var columns = row.QuerySelectorAll("td").ToList();

                    var inputs = columns[1]
                                 .QuerySelectorAll("div.factorio-icon")
                                 .Select(async div => await ParseFactorioIcon(div, uri))
                                 .Select(t => t.Result)
                                 .ToList();

                    foreach (var resource in inputs)
                    {
                        AddProduct(resource);
                    }

                    var machines = columns[2].QuerySelectorAll("div.factorio-icon")
                                   .Select(async div => await ParseFactorioIcon(div, uri))
                                   .Select(t => t.Result)
                                   .ToList();

                    var outputs = columns[3].QuerySelectorAll("div.factorio-icon")
                                  .Select(async div => await ParseFactorioIcon(div, uri))
                                  .Select(t => t.Result)
                                  .ToList();

                    foreach (var resource in outputs)
                    {
                        AddProduct(resource);
                    }

                    var recipe = new
                    {
                        inputs  = inputs.Take(inputs.Count() - 1).Where(e => e != null).Select(RecipePart),
                        outputs = outputs.Where(e => e != null).Select(RecipePart),
                        time    = inputs.Last()?.image?.text,
                        process = await ParseFactorioIconImage(columns[0], uri, columns[0].TextContent),
                        machines,
                        tech
                    };

                    Recipes.Add(recipe);
                }
            }
        }
Пример #13
0
        private void Display()
        {
            HistoryEntry last_he = userControlSynthesis.CurrentHistoryEntry;             // sync with what its showing

            if (EngineeringWanted != null && SynthesisWanted != null && last_he != null) // if we have all the ingredients (get it!)
            {
                List <MaterialCommodities> mcl = last_he.MaterialCommodity.Sort(false);
                Recipes.ResetUsed(mcl);
                Color textcolour = IsTransparent ? discoveryform.theme.SPanelColor : discoveryform.theme.LabelColor;
                Color backcolour = this.BackColor;
                List <Tuple <Recipes.Recipe, int> > totalWanted = EngineeringWanted.Concat(SynthesisWanted).ToList();
                string techBrokers = SQLiteDBClass.GetSettingString(DBTechBrokerFilterSave, "None");
                if (techBrokers != "None")
                {
                    List <string> techBrokerList = techBrokers.Split(';').ToList <string>();
                    foreach (Recipes.Recipe r in Recipes.TechBrokerUnlocks)
                    {
                        if (techBrokers == "All" || techBrokerList.Contains(r.name))
                        {
                            totalWanted.Add(new Tuple <Recipes.Recipe, int>(r, 1));
                        }
                    }
                }

                List <MaterialCommodities> shoppinglist = Recipes.GetShoppingList(totalWanted, mcl);
                JournalScan         sd      = null;
                StarScan.SystemNode last_sn = null;

                if (last_he.IsLanded && (showListAvailability || showPlanetMats))
                {
                    sd = discoveryform.history.GetScans(last_he.System.Name).Where(sc => sc.BodyName == last_he.WhereAmI).FirstOrDefault();
                }
                if (!last_he.IsLanded && showSystemAvailability)
                {
                    last_sn = discoveryform.history.starscan.FindSystem(last_he.System, useEDSMForSystemAvailability);
                }

                StringBuilder wantedList = new StringBuilder();

                if (shoppinglist.Any())
                {
                    double available;
                    wantedList.Append("Needed Mats:\n");
                    List <string> capExceededMats = new List <string>();
                    foreach (MaterialCommodities c in shoppinglist.OrderBy(mat => mat.name))      // and add new..
                    {
                        string present = "";
                        if (showListAvailability)
                        {
                            if (sd != null && sd.HasMaterials)
                            {
                                if (sd.Materials.TryGetValue(c.fdname, out available))
                                {
                                    present = $" {available.ToString("N1")}%";
                                }
                                else
                                {
                                    present = " -";
                                }
                            }
                        }
                        wantedList.Append($"  {c.scratchpad} {c.name}{present}");
                        int?onHand   = mcl.Where(m => m.shortname == c.shortname).FirstOrDefault()?.count;
                        int totalReq = c.scratchpad + (onHand.HasValue ? onHand.Value : 0);
                        if ((c.type == MaterialFreqVeryCommon && totalReq > VeryCommonCap) ||
                            (c.type == MaterialFreqCommon && totalReq > CommonCap) ||
                            (c.type == MaterialFreqStandard && totalReq > StandardCap) ||
                            (c.type == MaterialFreqRare && totalReq > RareCap) ||
                            (c.type == MaterialFreqVeryRare && totalReq > VeryRareCap))
                        {
                            capExceededMats.Add(c.name);
                        }
                        if (!last_he.IsLanded && last_sn != null)
                        {
                            var landables = last_sn.Bodies.Where(b => b.ScanData != null && (!b.ScanData.IsEDSMBody || useEDSMForSystemAvailability) &&
                                                                 b.ScanData.HasMaterials && b.ScanData.Materials.ContainsKey(c.fdname));
                            if (landables.Count() > 0)
                            {
                                wantedList.Append("\n    ");
                                List <Tuple <string, double> > allMats = new List <Tuple <string, double> >();
                                foreach (StarScan.ScanNode sn in landables)
                                {
                                    sn.ScanData.Materials.TryGetValue(c.fdname, out available);
                                    allMats.Add(new Tuple <string, double>(sn.fullname.Replace(last_he.System.Name, "", StringComparison.InvariantCultureIgnoreCase).Trim(), available));
                                }
                                allMats = allMats.OrderByDescending(m => m.Item2).ToList();
                                int n = 1;
                                foreach (Tuple <string, double> m in allMats)
                                {
                                    if (n % 6 == 0)
                                    {
                                        wantedList.Append("\n    ");
                                    }
                                    wantedList.Append($"{m.Item1.ToUpperInvariant()}: {m.Item2.ToString("N1")}% ");
                                    n++;
                                }
                            }
                        }
                        wantedList.Append("\n");
                    }

                    if (capExceededMats.Any())
                    {
                        wantedList.Append("\nFilling Shopping List would exceed capacity for:");
                        foreach (string mat in capExceededMats)
                        {
                            wantedList.Append($"\n  {mat}");
                        }
                    }
                }
                else
                {
                    wantedList.Append("No materials currently required.");
                }

                if (showMaxInjections)
                {
                    Recipes.ResetUsed(mcl);
                    Tuple <int, int, string, string> basic    = Recipes.HowManyLeft(mcl, Recipes.SynthesisRecipes.First(r => r.name == "FSD" && r.level == "Basic"));
                    Tuple <int, int, string, string> standard = Recipes.HowManyLeft(mcl, Recipes.SynthesisRecipes.First(r => r.name == "FSD" && r.level == "Standard"));
                    Tuple <int, int, string, string> premium  = Recipes.HowManyLeft(mcl, Recipes.SynthesisRecipes.First(r => r.name == "FSD" && r.level == "Premium"));
                    wantedList.Append($"\nMax FSD Injections\n   {basic.Item1} Basic\n   {standard.Item1} Standard\n   {premium.Item1} Premium");
                }

                if (showPlanetMats && sd != null && sd.HasMaterials)
                {
                    wantedList.Append($"\n\nMaterials on {last_he.WhereAmI}\n");
                    foreach (KeyValuePair <string, double> mat in sd.Materials)
                    {
                        int?onHand = mcl.Where(m => m.fdname == mat.Key).FirstOrDefault()?.count;
                        MaterialCommodityData md = GetCachedMaterial(mat.Key);
                        int max = MaterialLimit(md).Value;
                        wantedList.AppendFormat("   {0} {1}% ({2}/{3})\n", System.Threading.Thread.CurrentThread.CurrentCulture.TextInfo.ToTitleCase(mat.Key.ToLower(System.Globalization.CultureInfo.InvariantCulture)),
                                                mat.Value.ToString("N1"), (onHand.HasValue ? onHand.Value : 0), max);
                    }
                }

                Font font = discoveryform.theme.GetFont;
                pictureBoxList.ClearImageList();
                PictureBoxHotspot.ImageElement displayList = pictureBoxList.AddTextAutoSize(new Point(0, 0), new Size(1000, 1000), wantedList.ToNullSafeString(), font, textcolour, backcolour, 1.0F);
                pictureBoxList.Render();
                font.Dispose();

                // if transparent, we don't show the eng/synth panels

                userControlEngineering.Visible = userControlSynthesis.Visible = !IsTransparent;
                userControlEngineering.Enabled = userControlSynthesis.Enabled = !IsTransparent;
                buttonTechBroker.Visible       = buttonTechBroker.Enabled = !IsTransparent;

                splitContainerVertical.Panel1MinSize = displayList.img.Width + 8;       // panel left has minimum width to accomodate the text

                if (IsTransparent)
                {
                    RevertToNormalSize();
                    int minWidth = Math.Max(((UserControlForm)FindForm()).TitleBarMinWidth(), displayList.img.Width) + 8;
                    RequestTemporaryResize(new Size(minWidth, displayList.img.Height + 4));
                }
                else
                {
                    RevertToNormalSize();       // eng/synth is on, normal size
                }
            }
        }
Пример #14
0
 private void OnRecipeAdded(RecipeAdded @event)
 {
     Recipes.Add(@event.Recipe.ToRecipeListItemViewModel(_messenger));
 }
Пример #15
0
 public void Awake()
 {
     GenRecipes();
     instance = this;
 }
Пример #16
0
	// Use this for initialization
	void Start () {
        targets = GameObject.Find("Targets");
        recipes = GetComponent<Recipes>();
        SpawnEnemies();
	}
Пример #17
0
 // Code to execute when the application is deactivated (sent to background)
 // This code will not execute when the application is closing
 private async void Application_Deactivated(object sender, DeactivatedEventArgs e)
 {
     await Recipes.SaveUserImagesLocalDataAsync();
 }
Пример #18
0
        public async Task <ActionResult> Create([Bind(Include = "id,Title,Content,Img,Contester_id,R_Status,Cate_id")] Recipes recipes, HttpPostedFileBase[] Url, string[] txtText, string[] txtIgredent, int txtStatus, string rate)
        {
            int    flag    = 0;
            string Cont    = "";
            string url_img = "";
            string ingre   = "";

            string[] formats = new string[] { ".jpg", ".png", ".gif", ".jpeg" };
            ViewBag.Cate_id = new SelectList(db.Categories.ToList(), "id", "Cate_name");
            if (ModelState.IsValid)
            {
                try
                {
                    foreach (HttpPostedFileBase img in Url)
                    {
                        if (img != null)
                        {
                            string ex = Path.GetExtension(img.FileName);
                            if (!check(ex, formats))
                            {
                                flag = 1;
                                ViewBag.FileStatus = ex + " is not an image";
                                ViewBag.Cate_id    = new SelectList(db.Categories.ToList(), "id", "Cate_name");
                                return(View(recipes));
                            }
                            url_img += Path.GetFileName(img.FileName) + "$";
                        }
                        else
                        {
                            flag = 1;
                            ViewBag.FileStatus = "Content must have image !!!!";
                            ViewBag.Cate_id    = new SelectList(db.Categories.ToList(), "id", "Cate_name");
                            return(View(recipes));
                        }
                        if (flag != 1)
                        {
                            string path = Path.Combine(Server.MapPath("~/images"), Path.GetFileName(img.FileName));
                            img.SaveAs(path);
                        }
                    }
                }
                catch (Exception e)
                {
                    ViewBag.FileStatus = "Error while file uploading.";
                }

                recipes.Img = url_img.Substring(0, url_img.Length - 1);

                foreach (var text in txtText)
                {
                    if (text != "")
                    {
                        Cont += text + "$";
                    }
                }
                foreach (var ingredent in txtIgredent)
                {
                    if (ingredent != "")
                    {
                        ingre += ingredent + "$";
                    }
                }
                Cont              = Cont.Substring(0, Cont.Length - 1);
                recipes.Content   = Cont;
                recipes.ingredent = ingre.Substring(0, ingre.Length - 1);
                if (Session["user"] != null)
                {
                    var isvalid = (Users)Session["user"];
                    recipes.Contester_id = isvalid.id;
                }
                else
                {
                    recipes.Contester_id = db.Users.Where(p => p.UPhone == "000").FirstOrDefault().id;
                }
                if (flag != 1)
                {
                    if (Session["user"] != null)
                    {
                        var isvalid = (Users)Session["user"];
                        recipes.Contester_id = isvalid.id;
                    }
                    else
                    {
                        recipes.Contester_id = db.Users.Where(p => p.UPhone == "000").FirstOrDefault().id;
                    }
                }
                recipes.Levels   = rate;
                recipes.R_Status = txtStatus;
                db.Recipes.Add(recipes);
                await db.SaveChangesAsync();

                if (TempData["Supplement"] != null)
                {
                    TempData["reId"] = recipes.id;
                    return(RedirectToAction("Create", "Exams"));
                }
                return(RedirectToAction("Index"));
            }
            return(View(recipes));
        }
        private void DisplayWeapons()
        {
            DataGridViewColumn sortcolprev   = dataGridViewWeapons.SortedColumn != null ? dataGridViewWeapons.SortedColumn : dataGridViewWeapons.Columns[1];
            SortOrder          sortorderprev = dataGridViewWeapons.SortedColumn != null ? dataGridViewWeapons.SortOrder : SortOrder.Ascending;
            int firstline = dataGridViewWeapons.SafeFirstDisplayedScrollingRowIndex();

            extPanelDataGridViewScrollWeapons.SuspendLayout();
            dataGridViewWeapons.SuspendLayout();

            dataGridViewWeapons.Rows.Clear();

            if (last_weapons >= 0)
            {
                var weaponlist = discoveryform.history.WeaponList.Weapons.Get(last_weapons, x => x.Sold == false); // get unsold weapons

                foreach (var w in weaponlist)
                {
                    var weaponinfo = ItemData.GetWeapon(w.Value.FDName);    // may be null
                    var weapondp   = weaponinfo?.GetStats(w.Value.Class);   // may be null
                    if (weapondp != null && w.Value.WeaponMods != null)     // apply engineering to weapon stats
                    {
                        weapondp = weapondp.ApplyEngineering(w.Value.WeaponMods);
                    }

                    string smods = w.Value.WeaponMods != null?string.Join(", ", w.Value.WeaponMods.Select(x => Recipes.GetBetterNameForEngineeringRecipe(x))) : "";

                    object[] rowobj = new object[] { EDDConfig.Instance.ConvertTimeToSelectedFromUTC(w.Value.EventTime).ToString(),
                                                     w.Value.FriendlyName, //+ ":" + (w.Value.ID%10000) ,
                                                     w.Value.Class,
                                                     smods,
                                                     w.Value.Price.ToString("N0"),
                                                     weaponinfo != null ? (weaponinfo.Primary?"Primary":"Secondary") : "",
                                                     weaponinfo != null?weaponinfo.Class.ToString().SplitCapsWord() : "",
                                                         weaponinfo != null?weaponinfo.DamageType.ToString().SplitCapsWord() : "",
                                                             weaponinfo != null?weaponinfo.FireMode.ToString().SplitCapsWord() : "",
                                                                 weapondp?.Damage.ToString("N1") ?? "",
                                                                 weapondp?.RatePerSec.ToString("N1") ?? "",
                                                                 weapondp?.DPS.ToString("N1") ?? "",
                                                                 weapondp?.ClipSize.ToString("N0") ?? "",
                                                                 weapondp?.HopperSize.ToString("N0") ?? "",
                                                                 weapondp?.Range.ToString("N0") ?? "",
                                                                 weapondp?.HeadShotMultiplier.ToString("N1") ?? "", };
                    // System.Diagnostics.Debug.WriteLine("Weapon row {0} {1}", w.Value.EventTime, w.Value.FriendlyName);
                    dataGridViewWeapons.Rows.Add(rowobj);
                }
            }


            dataGridViewWeapons.Sort(sortcolprev, (sortorderprev == SortOrder.Descending) ? ListSortDirection.Descending : ListSortDirection.Ascending);
            dataGridViewWeapons.Columns[sortcolprev.Index].HeaderCell.SortGlyphDirection = sortorderprev;
            if (firstline >= 0 && firstline < dataGridViewWeapons.RowCount)
            {
                dataGridViewWeapons.SafeFirstDisplayedScrollingRowIndex(firstline);
            }

            dataGridViewWeapons.ResumeLayout();
            extPanelDataGridViewScrollWeapons.ResumeLayout();
        }
Пример #20
0
        public RecipeResult CreateRecipe(AuthIdentity identity, Recipe recipe)
        {
            using (var session = this.GetSession())
            {
                using (var transaction = session.BeginTransaction())
                {
                    // Create Recipe
                    var recipes = new Recipes
                    {
                        Title = recipe.Title,
                        Description = recipe.Description,
                        CookTime = recipe.CookTime,
                        PrepTime = recipe.PreparationTime,
                        Credit = recipe.Credit,
                        CreditUrl = recipe.CreditUrl,
                        DateEntered = recipe.DateEntered,
                        ImageUrl = recipe.ImageUrl,
                        Rating = recipe.AvgRating,
                        ServingSize = recipe.ServingSize,
                        Steps = recipe.Method
                    };

                    session.Save(recipes);

                    // Create Ingredients
                    short displayOrder = 0;
                    recipe.Ingredients.ForEach(i =>
                    {
                        var dbIngredient = new RecipeIngredients
                        {
                            Recipe = recipes,
                            Ingredient = Ingredients.FromId(i.Ingredient.Id),
                            IngredientForm = i.Form != null ? IngredientForms.FromId(i.Form.FormId) : null,
                            Qty = i.Amount != null ? (float?)i.Amount.SizeHigh : null,
                            QtyLow = i.Amount != null ? (float?)i.Amount.SizeLow : null,
                            Unit = i.Amount != null ? i.Amount.Unit : Units.Unit,
                            Section = i.Section,
                            DisplayOrder = ++displayOrder
                        };

                        session.Save(dbIngredient);
                    });

                    // Create RecipeMetadata
                    var recipeMetadata = new RecipeMetadata
                    {
                        Recipe = recipes,
                        DietGlutenFree = recipe.Tags.HasTag(RecipeTag.GlutenFree),
                        DietNoAnimals = recipe.Tags.HasTag(RecipeTag.NoAnimals),
                        DietNomeat = recipe.Tags.HasTag(RecipeTag.NoMeat),
                        DietNoPork = recipe.Tags.HasTag(RecipeTag.NoPork),
                        DietNoRedMeat = recipe.Tags.HasTag(RecipeTag.NoRedMeat),
                        MealBreakfast = recipe.Tags.HasTag(RecipeTag.Breakfast),
                        MealDessert = recipe.Tags.HasTag(RecipeTag.Dessert),
                        MealDinner = recipe.Tags.HasTag(RecipeTag.Dinner),
                        MealLunch = recipe.Tags.HasTag(RecipeTag.Lunch),
                        NutritionLowCalorie = recipe.Tags.HasTag(RecipeTag.LowCalorie),
                        NutritionLowCarb = recipe.Tags.HasTag(RecipeTag.LowCarb),
                        NutritionLowFat = recipe.Tags.HasTag(RecipeTag.LowFat),
                        NutritionLowSodium = recipe.Tags.HasTag(RecipeTag.LowSodium),
                        NutritionLowSugar = recipe.Tags.HasTag(RecipeTag.LowSugar),
                        SkillCommon = recipe.Tags.HasTag(RecipeTag.CommonIngredients),
                        SkillEasy = recipe.Tags.HasTag(RecipeTag.EasyToMake),
                        SkillQuick = recipe.Tags.HasTag(RecipeTag.Quick)
                    };

                    session.Save(recipeMetadata);
                    transaction.Commit();

                    return new RecipeResult
                    {
                        RecipeCreated = true,
                        NewRecipeId = recipes.RecipeId
                    };
                }
            }
        }
Пример #21
0
        private void Display()
        {
            //DONT turn on sorting in the future, thats not how it works.  You click and drag to sort manually since it gives you
            // the order of recipies.

            List <Tuple <Recipes.Recipe, int> > wantedList = null;

            System.Diagnostics.Trace.WriteLine(BaseUtils.AppTicks.TickCountLap(this, true) + " EN " + displaynumber + " Begin Display");

            if (last_he != null)
            {
                List <MaterialCommodities> mcl = last_he.MaterialCommodity.Sort(false);

                int fdrow = dataGridViewEngineering.FirstDisplayedScrollingRowIndex;      // remember where we were displaying

                Recipes.ResetUsed(mcl);

                wantedList = new List <Tuple <Recipes.Recipe, int> >();

                string        engineers = SQLiteDBClass.GetSettingString(DbEngFilterSave, "All");
                List <string> engList   = engineers.Split(';').ToList <string>();
                string        modules   = SQLiteDBClass.GetSettingString(DbModFilterSave, "All");
                List <string> modList   = modules.Split(';').ToList <string>();
                string        levels    = SQLiteDBClass.GetSettingString(DbLevelFilterSave, "All");
                string[]      lvlArray  = (levels == "All" || levels == "None") ? new string[0] : levels.Split(';');
                string        upgrades  = SQLiteDBClass.GetSettingString(DbUpgradeFilterSave, "All");
                string[]      upgArray  = upgrades.Split(';');
                string        materials = SQLiteDBClass.GetSettingString(DbMaterialFilterSave, "All");
                List <string> matList;
                if (materials == "All" || materials == "None")
                {
                    matList = new List <string>();
                }
                else
                {
                    matList = materials.Split(';').Where(x => !string.IsNullOrEmpty(x) && matLookUp.ContainsKey(x)).Select(m => matLookUp[m]).ToList();
                }

                for (int i = 0; i < Recipes.EngineeringRecipes.Count; i++)
                {
                    int rno = (int)dataGridViewEngineering.Rows[i].Tag;
                    dataGridViewEngineering[MaxCol.Index, i].Value = Recipes.HowManyLeft(mcl, Recipes.EngineeringRecipes[rno]).Item1.ToStringInvariant();
                    bool visible = true;

                    if (engineers == "All" && modules == "All" && levels == "All" && upgrades == "All" && materials == "All")
                    {
                        visible = true;
                    }
                    else
                    {
                        visible = false;
                        if (engineers == "All")
                        {
                            visible = true;
                        }
                        else
                        {
                            var included = engList.Intersect <string>(Recipes.EngineeringRecipes[rno].engineers.ToList <string>());
                            visible = included.Count() > 0;
                        }
                        if (modules == "All")
                        {
                            visible = visible && true;
                        }
                        else
                        {
                            var included = modList.Intersect <string>(Recipes.EngineeringRecipes[rno].modules.ToList <string>());
                            visible = visible && included.Count() > 0;
                        }
                        if (levels == "All")
                        {
                            visible = visible && true;
                        }
                        else
                        {
                            visible = visible && lvlArray.Contains(Recipes.EngineeringRecipes[rno].level);
                        }
                        if (upgrades == "All")
                        {
                            visible = visible && true;
                        }
                        else
                        {
                            visible = visible && upgArray.Contains(Recipes.EngineeringRecipes[rno].name);
                        }
                        if (materials == "All")
                        {
                            visible = visible && true;
                        }
                        else
                        {
                            var included = matList.Intersect <string>(Recipes.EngineeringRecipes[rno].ingredients.ToList <string>());
                            visible = visible && included.Count() > 0;
                        }
                    }

                    dataGridViewEngineering.Rows[i].Visible = visible;

                    if (visible)
                    {
                        Tuple <int, int, string, string> res = Recipes.HowManyLeft(mcl, Recipes.EngineeringRecipes[rno], Wanted[rno]);
                        //System.Diagnostics.Debug.WriteLine("{0} Recipe {1} executed {2} {3} ", i, rno, Wanted[rno], res.Item2);

                        dataGridViewEngineering[WantedCol.Index, i].Value      = Wanted[rno].ToStringInvariant();
                        dataGridViewEngineering[AvailableCol.Index, i].Value   = res.Item2.ToStringInvariant();
                        dataGridViewEngineering[NotesCol.Index, i].Value       = res.Item3;
                        dataGridViewEngineering[NotesCol.Index, i].ToolTipText = res.Item4;
                    }
                    if (Wanted[rno] > 0 && (visible || isEmbedded))      // embedded, need to
                    {
                        wantedList.Add(new Tuple <Recipes.Recipe, int>(Recipes.EngineeringRecipes[rno], Wanted[rno]));
                    }
                }

                if (!isEmbedded)
                {
                    Recipes.ResetUsed(mcl);
                    List <MaterialCommodities> shoppinglist = Recipes.GetShoppingList(wantedList, mcl);
                    dataGridViewEngineering.RowCount = Recipes.EngineeringRecipes.Count;             // truncate previous shopping list..
                    foreach (MaterialCommodities c in shoppinglist.OrderBy(mat => mat.Details.Name)) // and add new..
                    {
                        int rn = dataGridViewEngineering.Rows.Add();

                        foreach (var cell in dataGridViewEngineering.Rows[rn].Cells.OfType <DataGridViewCell>())
                        {
                            if (cell.OwningColumn == UpgradeCol)
                            {
                                cell.Value = c.Details.Name;
                            }
                            else if (cell.OwningColumn == WantedCol)
                            {
                                cell.Value = c.scratchpad.ToStringInvariant();
                            }
                            else if (cell.OwningColumn == NotesCol)
                            {
                                cell.Value = c.Details.Shortname;
                            }
                            else if (cell.ValueType == null || cell.ValueType.IsAssignableFrom(typeof(string)))
                            {
                                cell.Value = string.Empty;
                            }
                        }
                        dataGridViewEngineering.Rows[rn].ReadOnly = true;   // disable editing wanted..
                    }
                }

                if (fdrow >= 0 && dataGridViewEngineering.Rows[fdrow].Visible)        // better check visible, may have changed..
                {
                    dataGridViewEngineering.FirstDisplayedScrollingRowIndex = fdrow;
                }
            }

            if (OnDisplayComplete != null)
            {
                OnDisplayComplete(wantedList);
            }

            System.Diagnostics.Trace.WriteLine(BaseUtils.AppTicks.TickCountLap(this) + " EN " + displaynumber + " Load Finished");
        }
        private void DisplaySuits()
        {
            DataGridViewColumn sortcolprev   = dataGridViewSuits.SortedColumn != null ? dataGridViewSuits.SortedColumn : dataGridViewSuits.Columns[1];
            SortOrder          sortorderprev = dataGridViewSuits.SortedColumn != null ? dataGridViewSuits.SortOrder : SortOrder.Ascending;
            int firstline = dataGridViewSuits.SafeFirstDisplayedScrollingRowIndex();

            extPanelDataGridViewScrollSuits.SuspendLayout();
            dataGridViewSuits.SuspendLayout();

            dataGridViewSuits.Rows.Clear();
            //  System.Diagnostics.Debug.WriteLine("Clear Suit grid");

            if (last_suits >= 0)
            {
                var suitlist = discoveryform.history.SuitList.Suits(last_suits);
                //foreach (var su in suitlist) System.Diagnostics.Debug.WriteLine($"Suit gen {last_suits}: {su.Value.ID} {su.Value.FDName}");

                var cursuit    = discoveryform.history.SuitList.CurrentID(last_suits);                  // get current suit ID, or 0 if none
                var curloadout = discoveryform.history.SuitLoadoutList.CurrentID(last_loadout);         // get current loadout ID, or 0 if none

                foreach (var s in suitlist)
                {
                    string stime  = EDDConfig.Instance.ConvertTimeToSelectedFromUTC(s.Value.EventTime).ToString();
                    string sname  = s.Value.FriendlyName;// + ":"+(s.Value.ID % 10000);
                    string sprice = s.Value.Price.ToString("N0");
                    string smods  = s.Value.SuitMods != null?string.Join(", ", s.Value.SuitMods.Select(x => Recipes.GetBetterNameForEngineeringRecipe(x))) : "";

                    var loadouts = discoveryform.history.SuitLoadoutList.GetLoadoutsForSuit(last_loadout, s.Value.ID);

                    if (loadouts == null || loadouts.Count == 0)
                    {
                        object[] rowobj = new object[] { stime, sname + (cursuit == s.Value.ID ? "*" : ""), smods, sprice };
                        dataGridViewSuits.Rows.Add(rowobj);
                        DataGridViewRow r = dataGridViewSuits.Rows[dataGridViewSuits.RowCount - 1];
                        r.Tag = s.Value;
                    }
                    else
                    {
                        int i = 0;

                        foreach (var l in loadouts)
                        {
                            object[] rowobj = new object[] { };

                            var rw = dataGridViewSuits.RowTemplate.Clone() as DataGridViewRow;
                            rw.CreateCells(dataGridViewSuits,
                                           stime,           //0
                                           (i == 0 ? sname : "") + (cursuit == s.Value.ID && curloadout == l.Value.ID ? " *" : ""),
                                           (i == 0 ? smods : ""),
                                           (i == 0 ? sprice : ""),
                                           l.Value.Name + "(" + ((l.Value.ID % 10000).ToString()) + ")",
                                           l.Value.GetModuleDescription("primaryweapon1"),
                                           l.Value.GetModuleDescription("primaryweapon2"),
                                           l.Value.GetModuleDescription("secondaryweapon")
                                           );

                            rw.Cells[1].Tag = sname;
                            rw.Cells[2].Tag = smods;
                            rw.Cells[3].Tag = sprice;

                            dataGridViewSuits.Rows.Add(rw);

                            DataGridViewRow r = dataGridViewSuits.Rows[dataGridViewSuits.RowCount - 1];
                            r.Tag = s.Value;

                            i++;
                        }
                    }
                }
            }

            dataGridViewSuits.Sort(sortcolprev, (sortorderprev == SortOrder.Descending) ? ListSortDirection.Descending : ListSortDirection.Ascending);
            dataGridViewSuits.Columns[sortcolprev.Index].HeaderCell.SortGlyphDirection = sortorderprev;
            if (firstline >= 0 && firstline < dataGridViewSuits.RowCount)
            {
                dataGridViewSuits.SafeFirstDisplayedScrollingRowIndex(firstline);
            }

            dataGridViewSuits.ResumeLayout();
            extPanelDataGridViewScrollSuits.ResumeLayout();
        }
Пример #23
0
 public void AddRecipe(Recipe recipe)
 {
     Recipes.Add(recipe);
     CombineIngredients();
 }
        public RecipesController(ApplicationDbContext db)
        {
            Recipes recipe = new Recipes();

            _db = db;
        }
Пример #25
0
        public void Write(Recipes recipes)
        {
            Write(recipes.Count);

            foreach (Recipe recipe in recipes)
            {
                if (recipe is ShapelessRecipe)
                {
                    var        memoryStream = MiNetServer.MemoryStreamManager.GetStream();
                    McpeWriter writer       = new McpeWriter(memoryStream);

                    ShapelessRecipe rec = (ShapelessRecipe)recipe;
                    writer.Write(rec.Input.Count);
                    foreach (Item stack in rec.Input)
                    {
                        writer.Write(stack);
                    }
                    writer.Write(1);
                    writer.Write(rec.Result);
                    writer.Write(new UUID(Guid.NewGuid()));

                    Write(0);                     // Type
                    var bytes = memoryStream.ToArray();
                    Write(bytes.Length);
                    Write(bytes);
                }
                else if (recipe is ShapedRecipe)
                {
                    var        memoryStream = MiNetServer.MemoryStreamManager.GetStream();
                    McpeWriter writer       = new McpeWriter(memoryStream);

                    ShapedRecipe rec = (ShapedRecipe)recipe;
                    writer.Write(rec.Width);
                    writer.Write(rec.Height);

                    for (int w = 0; w < rec.Width; w++)
                    {
                        for (int h = 0; h < rec.Height; h++)
                        {
                            writer.Write(rec.Input[(h * rec.Width) + w]);
                        }
                    }
                    writer.Write(1);
                    writer.Write(rec.Result);
                    writer.Write(new UUID(Guid.NewGuid()));

                    Write(1);                     // Type
                    var bytes = memoryStream.ToArray();
                    Write(bytes.Length);
                    Write(bytes);
                }
                else if (recipe is SmeltingRecipe)
                {
                    ////const ENTRY_FURNACE = 2;
                    //SmeltingRecipe recipe = new SmeltingRecipe();
                    //short meta = ReadShort(); // input (with metadata)
                    //short id = ReadShort(); // input (with metadata)
                    //Item result = ReadItem(); // Result
                    //recipe.Input = ItemFactory.GetItem(id, meta);
                    //recipe.Result = result;
                    //recipes.Add(recipe);
                    var        memoryStream = MiNetServer.MemoryStreamManager.GetStream();
                    McpeWriter writer       = new McpeWriter(memoryStream);

                    SmeltingRecipe rec = (SmeltingRecipe)recipe;
                    writer.Write(rec.Input.Metadata);
                    writer.Write(rec.Input.Id);
                    writer.Write(rec.Result);

                    Write(rec.Input.Metadata == 0 ? 2 : 3);                     // Type
                    var bytes = memoryStream.ToArray();
                    Write(bytes.Length);
                    Write(bytes);
                }
                else if (recipe is EnchantingRecipe)
                {
                    var        memoryStream = MiNetServer.MemoryStreamManager.GetStream();
                    McpeWriter writer       = new McpeWriter(memoryStream);

                    writer.Write((byte)3);                      // Count
                    {
                        writer.Write((int)1);                   // Cost
                        writer.Write((byte)1);                  // Count
                        writer.Write((int)9);                   // Id
                        writer.Write((int)1);                   // Level
                        writer.Write("Test1");                  // Level
                    }

                    {
                        writer.Write((int)2);                          // Cost
                        writer.Write((byte)1);                         // Count
                        writer.Write((int)10);                         // Id
                        writer.Write((int)2);                          // Level
                        writer.Write("Test2");                         // Level
                    }
                    {
                        writer.Write((int)3);                          // Cost
                        writer.Write((byte)1);                         // Count
                        writer.Write((int)12);                         // Id
                        writer.Write((int)3);                          // Level
                        writer.Write("Test3");                         // Level
                    }

                    Write(4);                     // Type
                    var bytes = memoryStream.ToArray();
                    Write(bytes.Length);
                    Write(bytes);
                }
            }

            Write((byte)1);
        }
Пример #26
0
        public Recipes ReadRecipes()
        {
            Recipes recipes = new Recipes();

            int count = ReadInt();

            Log.InfoFormat("Recipes Count: {0}", count);

            for (int i = 0; i < count; i++)
            {
                int recipeType = ReadInt();
                int len        = ReadInt();
                if (recipeType < 0 || len == 0)
                {
                    Log.Warn("Read void recipe");
                    return(recipes);
                }

                if (recipeType == 0)
                {
                    //const ENTRY_SHAPELESS = 0;
                    ShapelessRecipe recipe          = new ShapelessRecipe();
                    int             ingrediensCount = ReadInt();         //
                    for (int j = 0; j < ingrediensCount; j++)
                    {
                        recipe.Input.Add(ReadMetadataSlot().Value);
                    }
                    ReadInt();                     // 1?
                    recipe.Result = ReadMetadataSlot().Value;
                    recipe.Id     = ReadUUID();    // Id
                    recipes.Add(recipe);
                }
                else if (recipeType == 1)
                {
                    //const ENTRY_SHAPED = 1;
                    int          width  = ReadInt();           // Width
                    int          height = ReadInt();           // Height
                    ShapedRecipe recipe = new ShapedRecipe(width, height);
                    //if(width > 3 || height > 3) throw new Exception("Wrong number of ingredience. Width=" + width + ", height=" + height);
                    for (int w = 0; w < width; w++)
                    {
                        for (int h = 0; h < height; h++)
                        {
                            recipe.Input[(h * width) + w] = ReadMetadataSlot().Value.Item;
                        }
                    }

                    ReadInt();                     // 1?
                    recipe.Result = ReadMetadataSlot().Value;
                    recipe.Id     = ReadUUID();    // Id
                    recipes.Add(recipe);
                }
                else if (recipeType == 2)
                {
                    //const ENTRY_FURNACE = 2;
                    ReadInt();                     // type
                    ReadInt();                     // input (with metadata)
                    ReadMetadataSlot();            // Result
                }
                else if (recipeType == 3)
                {
                    //const ENTRY_FURNACE_DATA = 3;
                    ReadInt();                     // input
                    ReadMetadataSlot();            // Result
                }
                else if (recipeType == 4)
                {
                    //const ENTRY_ENCHANT_LIST = 4;
                    int enchantmentListCount = ReadByte();                     // count
                    for (int j = 0; j < enchantmentListCount; j++)
                    {
                        ReadMetadataSlot();
                        ReadInt();                          // Cost
                        byte enchantmentCount = ReadByte(); // EnchantCount
                        for (int k = 0; k < enchantmentCount; k++)
                        {
                            ReadInt();                        // Id
                            ReadInt();                        // Level(strenght)
                        }
                        ReadString();                         // Name
                    }
                }
            }

            return(recipes);
        }
Пример #27
0
        string Infoline(List <HistoryEntry> syslist)
        {
            string infostr      = "";
            string jumponium    = "";
            bool   hasMaterials = false;

            if (syslist.Count > 1)
            {
                infostr = string.Format("First visit {0}".Tx(this, "FV"), syslist.Last().EventTimeLocal.ToShortDateString());
            }

            HistoryEntry he = syslist[0];

            StarScan.SystemNode node = discoveryform.history.starscan?.FindSystem(he.System, false);

            #region information

            if (node != null)
            {
                if (node.starnodes != null)
                {
                    infostr = infostr.AppendPrePad(string.Format("{0} Star(s)".Tx(this, "CS"), node.starnodes.Count), Environment.NewLine);
                    string extrainfo = "";
                    string prefix    = Environment.NewLine;
                    int    total     = 0;

                    foreach (StarScan.ScanNode sn in node.Bodies)
                    {
                        total++;
                        if (sn.ScanData != null && checkBoxBodyClasses.Checked)
                        {
                            JournalScan sc = sn.ScanData;

                            if (sc.IsStar) // brief notification for special or uncommon celestial bodies, useful to traverse the history and search for that special body you discovered.
                            {
                                // Sagittarius A* is a special body: is the centre of the Milky Way, and the only one which is classified as a Super Massive Black Hole. As far as we know...
                                if (sc.StarTypeID == EDStar.SuperMassiveBlackHole)
                                {
                                    extrainfo = extrainfo.AppendPrePad(string.Format("{0} is a super massive black hole".Tx(this, "SMBH"), sc.BodyName), prefix);
                                }

                                // black holes
                                if (sc.StarTypeID == EDStar.H)
                                {
                                    extrainfo = extrainfo.AppendPrePad(string.Format("{0} is a black hole".Tx(this, "BH"), sc.BodyName), prefix);
                                }

                                // neutron stars
                                if (sc.StarTypeID == EDStar.N)
                                {
                                    extrainfo = extrainfo.AppendPrePad(string.Format("{0} is a neutron star".Tx(this, "NS"), sc.BodyName), prefix);
                                }

                                // white dwarf (D, DA, DAB, DAO, DAZ, DAV, DB, DBZ, DBV, DO, DOV, DQ, DC, DCV, DX)
                                string WhiteDwarf = "White Dwarf";
                                if (sc.StarTypeText.Contains(WhiteDwarf))
                                {
                                    extrainfo = extrainfo.AppendPrePad(string.Format("{0} is a {1} white dwarf star".Tx(this, "WD"), sc.BodyName, sc.StarTypeID), prefix);
                                }

                                // wolf rayet (W, WN, WNC, WC, WO)
                                string WolfRayet = "Wolf-Rayet";
                                if (sc.StarTypeText.Contains(WolfRayet))
                                {
                                    extrainfo = extrainfo.AppendPrePad(string.Format("{0} is a {1} wolf-rayet star".Tx(this, "WR"), sc.BodyName, sc.StarTypeID), prefix);
                                }

                                // giants. It should recognize all classes of giants.
                                if (sc.StarTypeText.Contains("Giant"))
                                {
                                    extrainfo = extrainfo.AppendPrePad(string.Format("{0} is a {1}".Tx(this, "OTHER"), sc.BodyName, sc.StarTypeText), prefix);
                                }

                                // rogue planets - not sure if they really exists, but they are in the journal, so...
                                if (sc.StarTypeID == EDStar.RoguePlanet)
                                {
                                    extrainfo = extrainfo.AppendPrePad(string.Format("{0} is a rogue planet".Tx(this, "RP"), sc.BodyName), prefix);
                                }
                            }

                            else

                            {
                                // Check if a non-star body is a moon or not. We want it to further refine our brief summary in the visited star list.
                                // To avoid duplicates, we need to apply our filters before on the bodies recognized as a moon, than do the same for the other bodies that do not fulfill that criteria.

                                if (sn.level >= 2 && sn.type == StarScan.ScanNodeType.body)

                                // Tell us that that special body is a moon. After all, it can be quite an outstanding discovery...
                                {
                                    // Earth-like moon
                                    if (sc.PlanetTypeID == EDPlanet.Earthlike_body)
                                    {
                                        extrainfo = extrainfo.AppendPrePad(string.Format("{0} is an earth like moon".Tx(this, "ELM"), sc.BodyName), prefix);
                                    }

                                    // Terraformable water moon
                                    if (sc.Terraformable == true && sc.PlanetTypeID == EDPlanet.Water_world)
                                    {
                                        extrainfo = extrainfo.AppendPrePad(string.Format("{0} is a terraformable water moon".Tx(this, "TWM"), sc.BodyName), prefix);
                                    }
                                    // Water moon
                                    if (sc.Terraformable == false && sc.PlanetTypeID == EDPlanet.Water_world)
                                    {
                                        extrainfo = extrainfo.AppendPrePad(string.Format("{0} is a water moon".Tx(this, "WM"), sc.BodyName), prefix);
                                    }

                                    // Terraformable moon
                                    if (sc.Terraformable == true && sc.PlanetTypeID != EDPlanet.Water_world)
                                    {
                                        extrainfo = extrainfo.AppendPrePad(string.Format("{0} is a terraformable moon".Tx(this, "TM"), sc.BodyName), prefix);
                                    }

                                    // Ammonia moon
                                    if (sc.PlanetTypeID == EDPlanet.Ammonia_world)
                                    {
                                        extrainfo = extrainfo.AppendPrePad(string.Format("{0} is an ammonia moon".Tx(this, "AM"), sc.BodyName), prefix);
                                    }
                                }

                                else

                                // Do the same, for all planets
                                {
                                    // Earth Like planet
                                    if (sc.PlanetTypeID == EDPlanet.Earthlike_body)
                                    {
                                        extrainfo = extrainfo.AppendPrePad(string.Format("{0} is an earth like planet".Tx(this, "ELP"), sc.BodyName), prefix);
                                    }

                                    // Terraformable water world
                                    if (sc.PlanetTypeID == EDPlanet.Water_world && sc.Terraformable == true)
                                    {
                                        extrainfo = extrainfo.AppendPrePad(string.Format("{0} is a terraformable water world".Tx(this, "TWW"), sc.BodyName), prefix);
                                    }
                                    // Water world
                                    if (sc.PlanetTypeID == EDPlanet.Water_world && sc.Terraformable == false)
                                    {
                                        extrainfo = extrainfo.AppendPrePad(string.Format("{0} is a water world".Tx(this, "WW"), sc.BodyName), prefix);
                                    }

                                    // Terraformable planet
                                    if (sc.Terraformable == true && sc.PlanetTypeID != EDPlanet.Water_world)
                                    {
                                        extrainfo = extrainfo.AppendPrePad(string.Format("{0} is a terraformable planet".Tx(this, "TP"), sc.BodyName), prefix);
                                    }

                                    // Ammonia world
                                    if (sc.PlanetTypeID == EDPlanet.Ammonia_world)
                                    {
                                        extrainfo = extrainfo.AppendPrePad(string.Format("{0} is an ammonia world".Tx(this, "AW"), sc.BodyName), prefix);
                                    }
                                }
                            }
                        }

                        // Landable bodies with valuable materials
                        if (sn.ScanData != null && sn.ScanData.IsLandable == true && sn.ScanData.HasMaterials && checkBoxJumponium.Checked == true)
                        {
                            hasMaterials = true;

                            int basic    = 0;
                            int standard = 0;
                            int premium  = 0;

                            foreach (KeyValuePair <string, double> mat in sn.ScanData.Materials)
                            {
                                string usedin = Recipes.UsedInSythesisByFDName(mat.Key);
                                if (usedin.Contains("FSD-Basic"))
                                {
                                    basic++;
                                }
                                if (usedin.Contains("FSD-Standard"))
                                {
                                    standard++;
                                }
                                if (usedin.Contains("FSD-Premium"))
                                {
                                    premium++;
                                }
                            }

                            // string MaterialsBrief = sn.ScanData.DisplayMaterials(4).ToString();
                            //System.Diagnostics.Debug.WriteLine("{0} {1} {2} {3} {4}", sn.fullname , basic, standard, premium, MaterialsBrief);

                            if (basic > 0 || standard > 0 || premium > 0)
                            {
                                int mats = basic + standard + premium;

                                StringBuilder jumpLevel = new StringBuilder();

                                if (basic != 0)
                                {
                                    jumpLevel.AppendPrePad(basic + "/" + Recipes.FindSynthesis("FSD", "Basic").Count + " Basic".Tx(this, "BFSD"), ", ");
                                }
                                if (standard != 0)
                                {
                                    jumpLevel.AppendPrePad(standard + "/" + Recipes.FindSynthesis("FSD", "Standard").Count + " Standard".Tx(this, "SFSD"), ", ");
                                }
                                if (premium != 0)
                                {
                                    jumpLevel.AppendPrePad(premium + "/" + Recipes.FindSynthesis("FSD", "Premium").Count + " Premium".Tx(this, "PFSD"), ", ");
                                }

                                jumponium = jumponium.AppendPrePad(Environment.NewLine + string.Format("{0} has {1} level elements.".Tx(this, "LE"), sn.ScanData.BodyName, jumpLevel));
                            }
                        }
                    }

                    total -= node.starnodes.Count;
                    if (total > 0)
                    {   // tell us that a system has other bodies, and how much, beside stars
                        infostr = infostr.AppendPrePad(string.Format("{0} Other bodies".Tx(this, "OB"), total.ToStringInvariant()), ", ");
                        infostr = infostr.AppendPrePad(extrainfo, prefix);
                    }
                    else
                    {   // we need this to allow the panel to scan also through systems which has only stars
                        infostr = infostr.AppendPrePad(extrainfo, prefix);
                    }
                    if (hasMaterials == true && checkBoxJumponium.Checked == true)
                    {
                        infostr = infostr.AppendPrePad(Environment.NewLine + Environment.NewLine + "This system has materials for FSD boost: ".Tx(this, "FSD"));
                        infostr = infostr.AppendPrePad(jumponium);
                    }
                }
            }

            return(infostr);
        }
Пример #28
0
 public void Write(Recipes recipes)
 {
 }
Пример #29
0
        public IActionResult Print(int recipeId)
        {
            Recipes recipe = recipeDAL.GetRecipe(recipeId);

            return(View(recipe));
        }
Пример #30
0
        public async Task <ActionResult> Create(CategoriesListData model, HttpPostedFileBase picture)
        {
            model.AllCategory = new CategoryManager().GetAllCategory();
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            var userManager = HttpContext.GetOwinContext().GetUserManager <ApplicationUserManager>();
            var user        = await userManager.FindByIdAsync(User.Identity.GetUserId());

            var recipe = new Recipes
            {
                CategoryID   = model.RecipesDB.CategoryID,
                Title        = model.RecipesDB.Title,
                HowToPrepare = model.RecipesDB.HowToPrepare,
                Ingredients  = model.RecipesDB.Ingredients,
                PrepareTime  = model.RecipesDB.PrepareTime,
                UserID       = user.Id,
                FriendlyUrl  = FriendlyUrlHelper.RemoveDiacritics(model.RecipesDB.Title.Replace(" ", "_"))
            };
            var pictureUrl = FileHelper.GetFileName("", picture);

            if (pictureUrl == null)
            {
                if (picture != null)
                {
                    if (picture.ContentLength > 0)
                    {
                        ModelState.AddModelError("", "Nem megfelelő fájlformátum.");
                        return(View(model));
                    }
                }
                else
                {
                    ModelState.AddModelError("", "Nincs kép kiválasztva.");
                    return(View(model));
                }
            }
            else if (picture.ContentLength > 5000000)
            {
                ModelState.AddModelError("", "Túl nagy méretű kép.");
                return(View(model));
            }
            db.Recipes.Add(recipe);
            db.SaveChanges();

            int     id  = recipe.ID;
            Recipes rec = db.Recipes.Find(id);

            pictureUrl = FileHelper.GetFileName(rec.ID.ToString(), picture);
            if (pictureUrl != null)
            {
                rec.PictureUrl = pictureUrl;
                try
                {
                    picture.SaveAs(Path.Combine(Server.MapPath("~"), "Upload\\Images", pictureUrl));
                }
                catch { }
            }
            db.SaveChanges();

            return(RedirectToAction("Details"));
        }
Пример #31
0
 public IActionResult UpdateRecipes([FromBody] Recipes recipe)
 {
     _context.Recipes.Update(recipe);
     _context.SaveChanges();
     return(Ok(recipe));
 }
Пример #32
0
 public void InsertRecipe(Recipes recipe)
 {
     throw new NotImplementedException();
 }
Пример #33
0
        public Recipes ReadRecipes()
        {
            Recipes recipes = new Recipes();

            int count = (int)ReadUnsignedVarInt();

            Log.Error($"Reading {count} recipes");

            for (int i = 0; i < count; i++)
            {
                int recipeType = (int)ReadSignedVarInt();

                //Log.Error($"Read recipe no={i} type={recipeType}");

                if (recipeType < 0 /*|| len == 0*/)
                {
                    Log.Error("Read void recipe");
                    break;
                }

                if (recipeType == 0)
                {
                    //const ENTRY_SHAPELESS = 0;
                    ShapelessRecipe recipe          = new ShapelessRecipe();
                    int             ingrediensCount = ReadVarInt();         //
                    for (int j = 0; j < ingrediensCount; j++)
                    {
                        recipe.Input.Add(ReadItem());
                    }
                    ReadVarInt();                     // 1?
                    recipe.Result = ReadItem();
                    recipe.Id     = ReadUUID();       // Id
                    recipes.Add(recipe);
                    //Log.Error("Read shapeless recipe");
                }
                else if (recipeType == 1)
                {
                    //const ENTRY_SHAPED = 1;
                    int          width  = ReadSignedVarInt();           // Width
                    int          height = ReadSignedVarInt();           // Height
                    ShapedRecipe recipe = new ShapedRecipe(width, height);
                    if (width > 3 || height > 3)
                    {
                        throw new Exception("Wrong number of ingredience. Width=" + width + ", height=" + height);
                    }
                    for (int w = 0; w < width; w++)
                    {
                        for (int h = 0; h < height; h++)
                        {
                            recipe.Input[(h * width) + w] = ReadItem();
                        }
                    }

                    int resultCount = ReadVarInt();                     // 1?
                    for (int j = 0; j < resultCount; j++)
                    {
                        recipe.Result = ReadItem();
                    }
                    recipe.Id = ReadUUID();                     // Id
                    recipes.Add(recipe);
                    //Log.Error("Read shaped recipe");
                }
                else if (recipeType == 2)
                {
                    //const ENTRY_FURNACE = 2;
                    SmeltingRecipe recipe = new SmeltingRecipe();
                    //short meta = (short) ReadVarInt(); // input (with metadata)
                    short id     = (short)ReadSignedVarInt();     // input (with metadata)
                    Item  result = ReadItem();                    // Result
                    recipe.Input  = ItemFactory.GetItem(id, 0);
                    recipe.Result = result;
                    recipes.Add(recipe);
                    //Log.Error("Read furnace recipe");
                    //Log.Error($"Input={id}, meta={""} Item={result.Id}, Meta={result.Metadata}");
                }
                else if (recipeType == 3)
                {
                    //const ENTRY_FURNACE_DATA = 3;
                    SmeltingRecipe recipe = new SmeltingRecipe();
                    short          id     = (short)ReadSignedVarInt(); // input (with metadata)
                    short          meta   = (short)ReadSignedVarInt(); // input (with metadata)
                    Item           result = ReadItem();                // Result
                    recipe.Input  = ItemFactory.GetItem(id, meta);
                    recipe.Result = result;
                    recipes.Add(recipe);
                    //Log.Error("Read smelting recipe");
                    //Log.Error($"Input={id}, meta={meta} Item={result.Id}, Meta={result.Metadata}");
                }
                else if (recipeType == 4)
                {
                    //const ENTRY_ENCHANT_LIST = 4;
                    Log.Error("Reading ENCHANT_LIST");

                    ReadUUID();
                }
                else
                {
                    Log.Error($"Read unknown recipe type: {recipeType}");
                    //ReadBytes(len);
                }
            }

            ReadByte();             // Clean (1) or update (0)

            return(recipes);
        }
Пример #34
0
 public void UpdateRecipe(Recipes recipe)
 {
     throw new NotImplementedException();
 }
        private void Display(MaterialCommoditiesList mcl)       // update display. mcl can be null
        {
            last_mcl = mcl;

            DataGridViewColumn sortcolprev   = dataGridViewMC.SortedColumn != null ? dataGridViewMC.SortedColumn : dataGridViewMC.Columns[0];
            SortOrder          sortorderprev = dataGridViewMC.SortedColumn != null ? dataGridViewMC.SortOrder : SortOrder.Ascending;
            int firstline = dataGridViewMC.SafeFirstDisplayedScrollingRowIndex();

            dataGridViewMC.Rows.Clear();

            textBoxItems1.Text = textBoxItems2.Text = "";

            if (mcl == null)
            {
                return;
            }

            //System.Diagnostics.Debug.WriteLine("Display mcl " + mcl.GetHashCode());

            string filters = GetSetting(dbFilter, "All");

            //System.Diagnostics.Debug.WriteLine("Filter is " + filters);
            string[] filter    = filters.SplitNoEmptyStartFinish(';');
            bool     all       = filter.Length > 0 && filter[0] == "All";
            bool     showzeros = checkBoxShowZeros.Checked;

            dataViewScrollerPanel.SuspendLayout();

            MaterialCommodityData[] allitems = materials ? MaterialCommodityData.GetMaterials(true) : MaterialCommodityData.GetCommodities(true);

            foreach (MaterialCommodityData mcd in allitems)   // we go thru all items..
            {
                if (all || filter.Contains(mcd.FDName))       // and see if they are in the filter
                {
                    object[] rowobj;

                    MaterialCommodities m = mcl.List.Find(x => string.Equals(x.Details.FDName, mcd.FDName, StringComparison.InvariantCultureIgnoreCase)); // and we see if we actually have some at this time

                    if (showzeros || (m != null && m.Count > 0))                                                                                          // if display zero, or we have some..
                    {
                        string s = Recipes.UsedInRecipesByFDName(mcd.FDName, Environment.NewLine);

                        if (materials)
                        {
                            int limit = mcd.MaterialLimit() ?? 0;

                            rowobj = new[] { mcd.Name, mcd.Shortname, mcd.TranslatedCategory,
                                             mcd.TranslatedType + (limit > 0 ? " (" + limit.ToString() + ")" : ""),
                                             m != null?m.Count.ToString() : "0", s };
                        }
                        else
                        {
                            rowobj = new[] { mcd.Name, mcd.TranslatedType,
                                             m != null?m.Count.ToString() : "0",
                                                 m != null?m.Price.ToString("0.#") : "-", s };
                        }

                        dataGridViewMC.Rows.Add(rowobj);
                        dataGridViewMC.Rows[dataGridViewMC.RowCount - 1].Cells[dataGridViewMC.ColumnCount - 1].ToolTipText = s;
                        dataGridViewMC.Rows[dataGridViewMC.RowCount - 1].Tag = s;
                    }
                }
            }

            dataViewScrollerPanel.ResumeLayout();

            dataGridViewMC.Sort(sortcolprev, (sortorderprev == SortOrder.Descending) ? ListSortDirection.Descending : ListSortDirection.Ascending);
            dataGridViewMC.Columns[sortcolprev.Index].HeaderCell.SortGlyphDirection = sortorderprev;
            if (firstline >= 0 && firstline < dataGridViewMC.RowCount)
            {
                dataGridViewMC.SafeFirstDisplayedScrollingRowIndex(firstline);
            }

            if (materials)
            {
                textBoxItems1.Text = mcl.DataCount.ToString();
                textBoxItems2.Text = mcl.MaterialsCount.ToString();
            }
            else
            {
                textBoxItems1.Text = mcl.CargoCount.ToString();
            }
        }
Пример #36
0
		/// <summary>
		///     Handles the container set slot.
		/// </summary>
		/// <param name="message">The message.</param>
		protected virtual void HandleContainerSetSlot(McpeContainerSetSlot message)
		{
			lock (Inventory)
			{
				if (HealthManager.IsDead) return;

				ItemStack itemStack = message.item.Value;

				if (GameMode != GameMode.Creative)
				{
					if (!VerifyItemStack(itemStack))
					{
						Log.Error($"Kicked {Username} for inventory hacking.");
						Disconnect("Error #324. Please report this error.");
						return;
					}
				}

				Log.Info($"Player {Username} set inventory item on window 0x{message.windowId:X2} with slot: {message.slot} HOTBAR: {message.unknown} Item ID: {itemStack.Id} Item Count: {itemStack.Count} Meta: {itemStack.Metadata}: DatagramSequenceNumber: {message.DatagramSequenceNumber}, ReliableMessageNumber: {message.ReliableMessageNumber}, OrderingIndex: {message.OrderingIndex}");

				// on all set container content, check if we have active inventory
				// and update that inventory.
				// Inventory manager makes sure other players with the same inventory open will 
				// also get the update.

				if (_openInventory != null)
				{
					if (_openInventory.WindowsId == message.windowId)
					{
						if (_openInventory.Type == 4)
						{
							Recipes recipes = new Recipes();
							recipes.Add(new EnchantingRecipe());
							McpeCraftingData crafting = new McpeCraftingData {recipes = recipes};
							SendPackage(crafting);
						}

						// block inventories of various kinds (chests, furnace, etc)
						_openInventory.SetSlot(this, (byte) message.slot, itemStack);
						return;
					}
				}

				switch (message.windowId)
				{
					case 0:
						Inventory.Slots[message.slot] = itemStack;
						break;
					case 0x79:
						Inventory.Slots[message.slot] = itemStack;
						break;
					case 0x78:

						var armorItem = itemStack.Item;
						switch (message.slot)
						{
							case 0:
								Inventory.Helmet = armorItem;
								break;
							case 1:
								Inventory.Chest = armorItem;
								break;
							case 2:
								Inventory.Leggings = armorItem;
								break;
							case 3:
								Inventory.Boots = armorItem;
								break;
						}

						McpePlayerArmorEquipment armorEquipment = McpePlayerArmorEquipment.CreateObject();
						armorEquipment.entityId = EntityId;
						armorEquipment.helmet = new MetadataSlot(new ItemStack(Inventory.Helmet, 1));
						armorEquipment.chestplate = new MetadataSlot(new ItemStack(Inventory.Chest, 1));
						armorEquipment.leggings = new MetadataSlot(new ItemStack(Inventory.Leggings, 1));
						armorEquipment.boots = new MetadataSlot(new ItemStack(Inventory.Boots, 1));
						Level.RelayBroadcast(this, armorEquipment);

						break;
					case 0x7A:
						//Inventory.ItemHotbar[message.unknown] = message.slot/* + PlayerInventory.HotbarSize*/;
						break;
				}
			}
		}
Пример #37
0
 // Code to execute when the application is closing (eg, user hit Back)
 // This code will not execute when the application is deactivated
 private async void Application_Closing(object sender, ClosingEventArgs e)
 {
     await Recipes.SaveUserImagesLocalDataAsync();
 }
Пример #38
0
 public CocktailDetailPage(Recipes cocktail)
 {
     InitializeComponent();
     _cocktail           = cocktail;
     this.BindingContext = _cocktail;
 }