예제 #1
0
        private void _OpenMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                if (_FolderBrowserDialog.ShowDialog() == DialogResult.OK)
                {
                    FileManager fm = new FileManager();

                    _Model1 = fm.LoadModel(_FolderBrowserDialog.SelectedPath + @"\clean.xml");
                    _Model2 = fm.LoadModel(_FolderBrowserDialog.SelectedPath + @"\dirty.xml");

                    _Nicotine = new Nicotine(_Model1, 0, _Model2, 24);

                    _Scene.Model = _Nicotine.Smoke(0.01);

                    _Screen = new Screen(pictureBox1.CreateGraphics(),
                                         pictureBox1.Width, pictureBox1.Height, _ProgressBar);
                    ShowScene();
                }
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.ToString(), "Ошибка!");
            }
        }
예제 #2
0
        /// <summary>
        /// Create the view for the fragment.
        /// </summary>
        /// <param name="inflater">The inflater to use to inflate an XML layout.</param>
        /// <param name="container">The container of the resulting view.</param>
        /// <param name="savedInstanceState">No clue.</param>
        /// <returns>The created view.</returns>
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            var res = inflater.Inflate(Resource.Layout.RecipeDetailLayout, container, false);

            Cheeseknife.Inject(this, res);

            nameField.Text      = Recipe.Name;
            targetNicField.Text = Recipe.TargetNicotine.ToString();
            batchSizeField.Text = Recipe.BatchSize.ToString();

            ArrayAdapter <Nicotine> nicAdapter = new ArrayAdapter <Nicotine>(Activity, Android.Resource.Layout.SimpleSpinnerDropDownItem,
                                                                             Nicotines);

            nicotineSpinner.Adapter       = nicAdapter;
            nicotineSpinner.ItemSelected += delegate(Object caller, ItemSelectedEventArgs args) {
                Nicotine nic = Nicotines[args.Position];
                Recipe.Nicotine = nic;
            };

            int pg = Recipe.PG;
            int vg = 100 - pg;

            pgSlider.Progress         = pg;
            pgSlider.ProgressChanged += delegate {
                pgLabel.Text = "" + pgSlider.Progress + "% / " + (100 - pgSlider.Progress) + "%";
            };
            pgLabel.Text = "" + pg + "% / " + vg + "%";

            return(res);
        }
예제 #3
0
        /// <summary>
        /// Remove a nicotine from the database.
        /// </summary>
        /// <param name="nicotine">The nicotine to remove.</param>
        public void RemoveNicotine(Nicotine nicotine)
        {
            string cmd = $"DELETE FROM {NIC_TABLE_NAME} WHERE {NIC_ID_COL}={nicotine.ID};";

            try {
                WritableDatabase.ExecSQL(cmd);
            } catch (SQLiteAbortException e) {
                Console.WriteLine(e.Message);
            }
        }
예제 #4
0
        //delete Nicotine
        public static void Delete(Nicotine nicotine)
        {
            var sqlQuery  = "UPDATE nicotine SET Deleted = True WHERE NicotineId = @NicotineId";
            var sqlParams = new List <MySqlParameter>()
            {
                new MySqlParameter("@NicotineId", nicotine.NicotineId),
            };

            Db.ExecDb(sqlQuery, Database.DatabaseProcedureType.Text, sqlParams.ToArray(), Database.ReturnType.None, false);
        }
예제 #5
0
        /// <summary>
        /// Parse a nicotine from the current row.
        /// </summary>
        /// <param name="iter">The database cursor pointing to a valid query result.</param>
        /// <returns>The parsed nicotine.</returns>
        private Nicotine ParseNicotine(ICursor iter)
        {
            Nicotine res = new Nicotine();

            res.ID            = iter.GetInt(0);
            res.Name          = iter.GetString(1);
            res.VG            = (byte)iter.GetInt(2);
            res.Concentration = iter.GetInt(3);

            return(res);
        }
예제 #6
0
        //create Nicotine
        public static void Create(Nicotine nicotine)
        {
            var sqlQuery  = "INSERT INTO nicotine (Nicotine, Updated) VALUES (@Nicotine, @Updated)";
            var sqlParams = new List <MySqlParameter>()
            {
                new MySqlParameter("@Nicotine", nicotine.NicotineStrength),
                new MySqlParameter("@Updated", DateTime.Now)
            };

            Db.ExecDb(sqlQuery, Database.DatabaseProcedureType.Text, sqlParams.ToArray(), Database.ReturnType.None, false);
        }
예제 #7
0
 public ActionResult GetNicotine(Nicotine nicotine)
 {
     try
     {
         return(Json(NicotineFunctions.Get(nicotine)));
     }
     catch (Exception ex)
     {
         return(Json("Error occurred. Error details: " + ex.Message));
     }
 }
예제 #8
0
        /// <summary>
        /// Update a nicotine in the database.
        /// </summary>
        /// <param name="nicotine">The nicotine to update.</param>
        public void UpdateNicotine(Nicotine nicotine)
        {
            string cmd = $"UPDATE {NIC_TABLE_NAME} SET {NIC_NAME_COL}=\"{nicotine.Name}\", {NIC_VG_COL}={nicotine.VG}, " +
                         $" {NIC_CONC_COL}={nicotine.Concentration} WHERE {NIC_ID_COL}={nicotine.ID};";

            try {
                WritableDatabase.ExecSQL(cmd);
            } catch (SQLiteAbortException e) {
                Console.WriteLine(e.Message);
            }
        }
예제 #9
0
        /// <summary>
        /// Add a new nicotine to the nicotine table.
        /// </summary>
        /// <param name="nicotine">The nicotine to add.</param>
        public void PutNicotine(Nicotine nicotine)
        {
            string cmd = $"INSERT INTO {NIC_TABLE_NAME} ({NIC_NAME_COL}, {NIC_VG_COL}, {NIC_CONC_COL}) " +
                         $"VALUES (\"{nicotine.Name}\", {nicotine.VG}, {nicotine.Concentration});";

            try {
                WritableDatabase.ExecSQL(cmd);
                nicotine.ID = GetLastInsertedID();
            } catch (SQLiteAbortException e) {
                Console.WriteLine(e.Message);
            }
        }
예제 #10
0
        /// <summary>
        /// Called to begin editing a nicotine.
        /// </summary>
        /// <param name="toEdit">The nicotine to edit.</param>
        public void StartEditNicotine(Nicotine toEdit)
        {
            NicotineDetailFragment ndFrag = new NicotineDetailFragment();

            ndFrag.SetNicotine(toEdit);

            var trans = SupportFragmentManager.BeginTransaction();

            trans.SetCustomAnimations(Resource.Animation.fromLeftAnimation, Resource.Animation.fadeOutAnimation, Resource.Animation.fadeInAnimation, Resource.Animation.toLeftAnimation);
            trans.Replace(Resource.Id.naFragmentView, ndFrag, "detailFragment");
            trans.AddToBackStack("startEditNicotine");
            trans.Commit();
        }
예제 #11
0
        //update Nicotine
        public static void Update(Nicotine nicotine)
        {
            var sqlQuery  = "UPDATE nicotine SET Nicotine = @Nicotine, Updated = @Updated, UserIdUpdated = @UserIdUpdated  WHERE NicotineId = @NicotineId";
            var sqlParams = new List <MySqlParameter>()
            {
                new MySqlParameter("@Nicotine", nicotine.NicotineStrength),
                new MySqlParameter("@Updated", DateTime.Now),
                new MySqlParameter("@UserIdUpdated", nicotine.UserIdUpdated),  //use identity user
                new MySqlParameter("@NicotineId", nicotine.NicotineId),
            };

            Db.ExecDb(sqlQuery, Database.DatabaseProcedureType.Text, sqlParams.ToArray(), Database.ReturnType.None, false);
        }
예제 #12
0
        //get Nicotine
        public static Nicotine Get(Nicotine nicotine)
        {
            var sqlQuery  = $"SELECT * FROM nicotine WHERE NicotineId = @NicotineId";
            var sqlParams = new List <MySqlParameter>()
            {
                new MySqlParameter("@NicotineId", nicotine.NicotineId)
            };
            var dt = (DataTable)Db.ExecDb(sqlQuery, Database.DatabaseProcedureType.Text, sqlParams.ToArray(), Database.ReturnType.DataTable, false);

            if (dt.Rows.Count > 0)
            {
                nicotine.NicotineId       = Convert.ToInt32(SqlHelperFunctions.NullCheck(dt.Rows[0]["NicotineId"]));
                nicotine.NicotineStrength = Convert.ToInt32(SqlHelperFunctions.NullCheck(dt.Rows[0]["Nicotine"]));
            }
            ;
            return(nicotine);
        }
예제 #13
0
        /// <summary>
        /// Retrieve all nicotines from the database.
        /// </summary>
        /// <returns>The collection of all nicotines currently in the database.</returns>
        public IList <Nicotine> GetNicotines()
        {
            IList <Nicotine> res = new List <Nicotine>();
            string           cmd = $"SELECT * FROM {NIC_TABLE_NAME};";

            ICursor iter = ReadableDatabase.RawQuery(cmd, null);

            while (iter.MoveToNext())
            {
                Nicotine newNic = ParseNicotine(iter);
                if (newNic != null)
                {
                    res.Add(newNic);
                }
            }
            iter.Close();
            return(res);
        }
예제 #14
0
        /// <summary>
        /// Parse a recipe from the current row.
        /// </summary>
        /// <param name="iter">The database cursor pointing to a row of a query.</param>
        /// <returns>The parsed recipe.</returns>
        private Recipe ParseRecipe(ICursor iter)
        {
            Recipe   res    = new Recipe();
            Nicotine resNic = new Nicotine();

            res.Nicotine         = resNic;
            res.ID               = iter.GetInt(0);
            res.Name             = iter.GetString(1);
            res.VG               = (byte)iter.GetInt(2);
            res.BatchSize        = iter.GetInt(3);
            res.TargetNicotine   = iter.GetFloat(4);
            resNic.ID            = iter.GetInt(5);
            resNic.Name          = iter.GetString(6);
            resNic.VG            = (byte)iter.GetInt(7);
            resNic.Concentration = iter.GetInt(8);

            return(res);
        }
예제 #15
0
        public ActionResult CreateUpdateNicotine(Nicotine nicotine)
        {
            try
            {
                if (nicotine.NicotineId != null)
                {
                    NicotineFunctions.Update(nicotine);
                }
                else
                {
                    NicotineFunctions.Create(nicotine);
                }

                return(Json("Success"));
            }
            catch (Exception ex)
            {
                return(Json("Error occurred. Error details: " + ex.Message));
            }
        }
예제 #16
0
 public ActionResult DeleteNicotine(Nicotine nicotine)
 {
     NicotineFunctions.Delete(nicotine);
     return(RedirectToAction("Nicotine", "ProductOptions"));
 }
예제 #17
0
 /// <summary>
 /// Set the nicotine to edited/created.
 /// </summary>
 /// <param name="newNicotine"></param>
 public void SetNicotine(Nicotine newNicotine)
 {
     this.nicotine = newNicotine;
 }