/// <summary>
 /// Updates the multiplication value.
 /// </summary>
 /// <param name="fact">The factor by which the multiplication state shoud be modified.</param>
 /// <param name="oper">The operation to be performed, depending from where the situation has ocurred.</param>
 private void UpdateMultiplication(int fact, Opers oper)
 {
     // If the operation comes from above multiply, else divide
     if (oper == Opers.OpenBelow)
     {
         multState *= fact;
     }
     else
     {
         multState /= fact;
     }
 }
        protected void Grid1_RowCommand(object sender, GridCommandEventArgs e)
        {
            string id = Grid1.DataKeys[Grid1.SelectedRowIndex][0].ToString();

            if (e.CommandName == "Delete")
            {
                Opers  o   = new Opers();
                string ret = o.deleteRest(Session["url"].ToString(), "/qcbin/rest/domains/" + Session["Domain"] + "/projects/" + Session["Project"] + "/defects/" + id);

                BindGrid();
            }
        }
        private void BindGrid()
        {
            string sortField     = Grid1.SortField;
            string sortDirection = Grid1.SortDirection;
            Opers  o             = new Opers();
            string ret           = o.getRest(Session["url"].ToString(), "/qcbin/rest/domains/" + Session["Domain"] + "/projects/" + Session["Project"] + "/defects");

            XmlDocument xmldoc = new XmlDocument();

            xmldoc.LoadXml(ret);
            XmlNodeList nodelist = xmldoc.SelectSingleNode("Entities").ChildNodes;

            // o.ConvertXMLToDataSet(ret);
            DataTable  table   = new DataTable();
            DataColumn column1 = new DataColumn("ID", typeof(string));
            DataColumn column2 = new DataColumn("Name", typeof(String));
            DataColumn column3 = new DataColumn("CreationTime", typeof(string));
            DataColumn column4 = new DataColumn("Priority", typeof(string));
            DataColumn column5 = new DataColumn("Status", typeof(string));
            DataColumn column6 = new DataColumn("Description", typeof(string));

            table.Columns.Add(column1);
            table.Columns.Add(column2);
            table.Columns.Add(column3);
            table.Columns.Add(column4);
            table.Columns.Add(column5);
            table.Columns.Add(column6);

            for (int i = 0; i < nodelist.Count; i++)
            {
                DataRow row = table.NewRow();
                row[0] = xmldoc.SelectNodes("//Field[@Name='id']")[i].InnerText;
                row[1] = xmldoc.SelectNodes("//Field[@Name='name']")[i].InnerText;
                row[2] = xmldoc.SelectNodes("//Field[@Name='creation-time']")[i].InnerText;
                row[3] = xmldoc.SelectNodes("//Field[@Name='priority']")[i].InnerText;
                row[4] = xmldoc.SelectNodes("//Field[@Name='status']")[i].InnerText;
                row[5] = xmldoc.SelectNodes("//Field[@Name='description']")[i].InnerText;
                table.Rows.Add(row);
            }

            DataView view1 = table.DefaultView;

            view1.Sort = String.Format("{0} {1}", sortField, sortDirection);
            DataSet ds = new DataSet();

            ds.Tables.Add(table);
            Grid1.DataSource = ds;
            Grid1.DataBind();
        }
        private void getSeverity()
        {
            Opers  o   = new Opers();
            string ret = o.getRest(Session["url"].ToString(), "/qcbin/rest/domains/" + Session["Domain"] + "/projects/" + Session["Project"] + "/customization/used-lists?name=Severity");

            XmlDocument xmldoc = new XmlDocument();

            xmldoc.LoadXml(ret);
            XmlNodeList nodelist = xmldoc.SelectSingleNode("//Items").ChildNodes;

            for (int i = 0; i < nodelist.Count; i++)
            {
                ddSeverity.Items.Add(nodelist[i].Attributes["value"].Value, nodelist[i].Attributes["value"].Value);
            }
        }
Beispiel #5
0
 //Find all words that have some property:
 public static void FindAll()
 {
     foreach (string file in Directory.GetFiles(@"C:\MBM\michmech\BuNaMo\noun"))
     {
         XmlDocument doc  = new XmlDocument(); doc.Load(file);
         Noun        noun = new Noun(doc);
         foreach (FormPlGen form in noun.plGen)
         {
             if (form.strength == Strength.Weak && Opers.IsSlender(form.value))
             {
                 Console.WriteLine(form.value);
             }
         }
     }
 }
        private void LoadData()
        {
            getStatus();
            getPriority();
            string id  = Request.QueryString["id"];
            Opers  o   = new Opers();
            string ret = o.getRest(Session["url"].ToString(), "/qcbin/rest/domains/" + Session["Domain"] + "/projects/" + Session["Project"] + "/defects/" + id);

            XmlDocument xmldoc = new XmlDocument();

            xmldoc.LoadXml(ret);
            lblID.Text         = xmldoc.SelectSingleNode("//Field[@Name='id']").InnerText;
            lblName.Text       = xmldoc.SelectSingleNode("//Field[@Name='name']").InnerText;
            ddStatus.Text      = xmldoc.SelectSingleNode("//Field[@Name='status']").InnerText;
            ddPriority.Text    = xmldoc.SelectSingleNode("//Field[@Name='priority']").InnerText;
            dCreationTime.Text = xmldoc.SelectSingleNode("//Field[@Name='creation-time']").InnerText;
            hDescription.Text  = xmldoc.SelectSingleNode("//Field[@Name='description']").InnerText;
        }
    /// <summary>
    ///  Flips the cards after a valid card is selected.
    /// </summary>
    /// <param name="level">The level at which the selected card is.</param>
    /// <param name="posCard">The position within the level at which the card is.</param>
    /// <param name="oper">The operation to be performed, if to go back a level or go forward.</param>
    public void FlipCards(int level, int posCard, Opers oper)
    {
        // If the action is to open a card.
        if (oper == Opers.OpenBelow)
        {
            // Delete the hint
            hintTxt.text = "";

            // Play the sound effect when clicking a card
            if (soundOn)
            {
                GetComponent <AudioSource>().Play();
            }

            // Update the multiplication
            UpdateMultiplication(gameObjLst[level][posCard].GetComponent <Card>().CardNum, oper);

            // Set cards at the same level gray
            for (int i = posCard + 1; ; i++)
            {
                if (i >= gameObjLst[level].Count())
                {
                    break;
                }
                gameObjLst[level][i].GetComponent <Card>().CardStt = Card.State.Gray;
            }

            for (int i = (posCard - 1); ; i--)
            {
                if (i < 0)
                {
                    break;
                }
                gameObjLst[level][i].GetComponent <Card>().CardStt = Card.State.Gray;
            }

            // Flip the two cards on the level below
            if (level < (gameObjLst.Count() - 1))
            {
                gameObjLst[level + 1][posCard].GetComponent <Card>().CardStt     = Card.State.Blue;
                gameObjLst[level + 1][posCard + 1].GetComponent <Card>().CardStt = Card.State.Blue;
            }

            // If the level is zero, clear everything
            if (currentLevel == 0)
            {
                levelHistory.Clear();
                levelHistory.Add(new Tuple <int, int>(0, 0));
            }

            // Add one to the level and the corresponding cards
            if ((currentLevel + 1) < (gameObjLst.Count()))
            {
                currentLevel++;
                levelHistory.Add(new Tuple <int, int>(posCard, posCard + 1));
            }

            // Update the submit button state
            UpdateSubmitButton();
        }
        else if (oper == Opers.OpenAbove && !ansSubmitted)
        {
            //Auxiliary variables
            int idx1;
            int idx2;

            // Checks condition for the previous to last
            bool checkCond = false;

            // Check that the previous to last level is not red before proceeding
            if (currentLevel == (gameObjLst.Count() - 1))
            {
                checkCond = checkCond || gameObjLst[currentLevel][posCard].GetComponent <Card>().CardStt == Card.State.Red;
                checkCond = checkCond || gameObjLst[currentLevel][posCard + 1].GetComponent <Card>().CardStt == Card.State.Red;
            }

            // Turn the cards over if needed
            if (currentLevel == (gameObjLst.Count() - 1) && level == currentLevel)
            {
                // Delete the hint
                hintTxt.text = "";

                // Update the multiplication
                UpdateMultiplication(gameObjLst[level][posCard].GetComponent <Card>().CardNum, oper);

                // Get the indexes of the cards that where initially gray and turn them blue
                idx1 = levelHistory[currentLevel].Item1;
                idx2 = levelHistory[currentLevel].Item2;

                // Turn the cards blue, no need to delete the history
                gameObjLst[currentLevel][idx1].GetComponent <Card>().CardStt = Card.State.Blue;
                gameObjLst[currentLevel][idx2].GetComponent <Card>().CardStt = Card.State.Blue;

                // Play the sound effect when clicking a card
                if (soundOn)
                {
                    GetComponent <AudioSource>().Play();
                }
            }
            else if ((level + 1) == currentLevel && !checkCond)
            {
                // Delete the hint
                hintTxt.text = "";

                // Update the multiplication
                UpdateMultiplication(gameObjLst[level][posCard].GetComponent <Card>().CardNum, oper);

                // Get the indexes of the cards at the current level and set them to gray
                idx1 = levelHistory[currentLevel].Item1;
                idx2 = levelHistory[currentLevel].Item2;

                // Turn the cards blue, no need to delete the history
                gameObjLst[currentLevel][idx1].GetComponent <Card>().CardStt = Card.State.Gray;
                gameObjLst[currentLevel][idx2].GetComponent <Card>().CardStt = Card.State.Gray;

                // Delete the last entry from the array
                levelHistory.RemoveAt(currentLevel);

                // Go down one level and set the cards to blue
                if (currentLevel > 0)
                {
                    currentLevel--;
                }

                // Get the indexes of the cards at the current level and set them to blue
                idx1 = levelHistory[currentLevel].Item1;
                idx2 = levelHistory[currentLevel].Item2;

                // Turn the cards blue, no need to delete the history
                gameObjLst[currentLevel][idx1].GetComponent <Card>().CardStt = Card.State.Blue;
                gameObjLst[currentLevel][idx2].GetComponent <Card>().CardStt = Card.State.Blue;

                // Play the sound effect when clicking a card
                if (soundOn)
                {
                    GetComponent <AudioSource>().Play();
                }
            }

            // Update the submit button state
            UpdateSubmitButton();
        }
    }
Beispiel #8
0
        private void InitOpers()
        {
            OperList = new Opers
            {
                //0 - ignore
                //1 - for number
                // 2 for dot and brackets
                //3 etc for other operations

                new Oper {
                    Name = "sin", Priority = 3, Opertyp = OperTyp.Unar
                },
                new Oper {
                    Name = "*", Priority = 4, Opertyp = OperTyp.Binar, CalcOper = BinarMulltiple
                },
                new Oper {
                    Name = "/", Priority = 4, Opertyp = OperTyp.Binar, CalcOper = BinarDivide
                },
                new Oper {
                    Name = "+", Priority = 3, Opertyp = OperTyp.Unarbinar, CalcOper = UnarBinarPlus
                },
                new Oper {
                    Name = "-", Priority = 3, Opertyp = OperTyp.Unarbinar, CalcOper = UnarBinarMinus
                },
                new Oper {
                    Name = ")", Priority = 2, Opertyp = OperTyp.Unar, CalcOper = BracketProc
                },
                new Oper {
                    Name = ".", Priority = 2, Opertyp = OperTyp.Binar, CalcOper = BinarDot
                },
                new Oper {
                    Name = ",", Priority = 2, Opertyp = OperTyp.Binar, CalcOper = BinarDot
                },

                new Oper {
                    Name = "(", Priority = 0, Opertyp = OperTyp.Unar
                },
                new Oper {
                    Name = " ", Priority = 1, Opertyp = OperTyp.Space, CalcOper = SpaceProc
                },
                new Oper {
                    Name = "0", Priority = 1, Opertyp = OperTyp.Number, CalcOper = ConvertNumber
                },
                new Oper {
                    Name = "1", Priority = 1, Opertyp = OperTyp.Number, CalcOper = ConvertNumber
                },
                new Oper {
                    Name = "2", Priority = 1, Opertyp = OperTyp.Number, CalcOper = ConvertNumber
                },
                new Oper {
                    Name = "3", Priority = 1, Opertyp = OperTyp.Number, CalcOper = ConvertNumber
                },
                new Oper {
                    Name = "4", Priority = 1, Opertyp = OperTyp.Number, CalcOper = ConvertNumber
                },
                new Oper {
                    Name = "5", Priority = 1, Opertyp = OperTyp.Number, CalcOper = ConvertNumber
                },
                new Oper {
                    Name = "6", Priority = 1, Opertyp = OperTyp.Number, CalcOper = ConvertNumber
                },
                new Oper {
                    Name = "7", Priority = 1, Opertyp = OperTyp.Number, CalcOper = ConvertNumber
                },
                new Oper {
                    Name = "8", Priority = 1, Opertyp = OperTyp.Number, CalcOper = ConvertNumber
                },
                new Oper {
                    Name = "9", Priority = 1, Opertyp = OperTyp.Number, CalcOper = ConvertNumber
                }
            };
        }