コード例 #1
0
    public int BinarySearchForIndex(int iBegin, int iCount, Infor item, IComparer <Infor> comparer)
    {
        int kq = -1;

        if (iBegin >= 0 && iCount > 0)
        {
            int begin = iBegin;
            int end   = begin + iCount - 1;
            int mid;
            while (begin <= end)
            {
                mid = (begin + end) / 2;
                Infor ItemMid = GetInfoFromIndex(mid);
                int   temp    = comparer.Compare(ItemMid, item);

                if (temp > 0)
                {
                    end = mid - 1;
                }
                else
                if (temp < 0)
                {
                    begin = mid + 1;
                }
                else
                {
                    kq = mid;
                    break;
                }
            }
        }
        return(kq);
    }
コード例 #2
0
 public static bool AddText(Infor tx)
 {
     using (var _context = new DBMindMapEntities())
     {
         try
         {
             _context.Infors.AddOrUpdate(tx);
             _context.SaveChanges();
             return(true);
         }
         catch (DbEntityValidationException e)
         {
             StringBuilder sb = new StringBuilder();
             foreach (var eve in e.EntityValidationErrors)
             {
                 sb.AppendLine(string.Format("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:",
                                             eve.Entry.Entity.GetType().Name,
                                             eve.Entry.State));
                 foreach (var ve in eve.ValidationErrors)
                 {
                     sb.AppendLine(string.Format("- Property: \"{0}\", Error: \"{1}\"",
                                                 ve.PropertyName,
                                                 ve.ErrorMessage));
                 }
             }
             throw new DbEntityValidationException(sb.ToString(), e);
         }
     }
 }
コード例 #3
0
    // Đọc file từ điển (*.con, *.ind, *.has) để lấy những thông tin cần thiết
    public void ReadFile(string szFileName)
    {
        _fsIndex = new FileStream(szFileName + ".ind", FileMode.Open, FileAccess.Read);
        FileStream fsHash = new FileStream(szFileName + ".has", FileMode.Open, FileAccess.Read);

        _fsContent = new FileStream(szFileName + ".con", FileMode.Open, FileAccess.Read);

        _Index.Clear();
        _Hash.Clear();
        FileToIndex(_fsIndex, _Index, _iSizeCountIndex, _iSizeKeywordIndex, _iSizePositionIndex);
        FileToHash(fsHash, _Hash, _iSizeCountHash, _iSizeKeywordHash, _iSizePositionHash);

        /*
         * for (int i = 0; i < count; ++i)
         * {
         *  arrtemp = new byte[indexOfindex[i + 1] - indexOfindex[i]];
         *  fsIndex.Read(arrtemp, 0, arrtemp.Length);
         *  string key = Encoding.UTF8.GetString(arrtemp, 0, arrtemp.Length - iPosition);
         *  int pos = CFunctions.GetInt(arrtemp, arrtemp.Length - iPosition, iPosition);
         *
         *  Infor ele = new Infor();
         *  ele.szWord = key.TrimEnd(new char[] { ' ' });
         *  ele.iPosition = pos;
         *  _Index.Add(ele);
         * }
         */
        // Phần tử cầm canh của file _Hash
        Infor temp = new Infor();

        temp.iPosition = _Index.Count - 1; // - 1: không tính phần tử cầm canh của _Index
        _Hash.Add(temp);

        fsHash.Close();
    }
コード例 #4
0
        public ActionResult DeleteConfirmed(int id)
        {
            Infor infor = inforRepo.Get(i => i.ID == id);

            inforRepo.Delete(infor);
            return(RedirectToAction("Index"));
        }
コード例 #5
0
 private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
 {
     if (e.Button == MouseButtons.Left)
     {
         Infor.Show(pictureBox1, -150, 25);
     }
 }
コード例 #6
0
ファイル: Account.cs プロジェクト: UIT-AnhTu-0325/BuyGear
        public Infor loadInfor()
        {
            string  sql   = "select * from dbo.infor where username = @username ";
            DataRow row   = Data.Instance.ExcuteQuery(sql, new object[] { Account.instance.userName }).Rows[0];
            Infor   infor = new Infor(row["name"].ToString(), row["numberphone"].ToString(), row["address"].ToString());

            return(infor);
        }
コード例 #7
0
        private void LoadInfor()
        {
            Infor infor = Account.Instance.loadInfor();

            lblname.Text   = infor.Hoten;
            lblsdt.Text    = infor.SDT;
            lbldiachi.Text = infor.DiaChi;
        }
コード例 #8
0
        public ActionResult DeleteConfirmed(int id)
        {
            Infor infor = db.Infors.Find(id);

            db.Infors.Remove(infor);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
コード例 #9
0
 public ActionResult Edit([Bind(Include = "ID,Title,Publisher,ReleaseTime,Content")] Infor infor)
 {
     if (ModelState.IsValid)
     {
         inforRepo.Update(infor);
         return(RedirectToAction("Index"));
     }
     return(View(infor));
 }
コード例 #10
0
 public bool delete(int id)
 {
     i = user.Infor.Where(x => x.IdUsers == id).Single <Infor>();
     user.Infor.DeleteOnSubmit(i);
     obj = user.Users.Where(x => x.IdUser == id).Single <Users>();
     user.Users.DeleteOnSubmit(obj);
     user.SubmitChanges();
     return(true);
 }
コード例 #11
0
 public ActionResult Edit([Bind(Include = "StudentId,StudentName,Age")] Infor infor)
 {
     if (ModelState.IsValid)
     {
         db.Entry(infor).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(infor));
 }
コード例 #12
0
        public ActionResult Delete(int?id)
        {
            Infor infor = inforRepo.Get(i => i.ID == id);

            if (infor == null)
            {
                return(HttpNotFound());
            }
            return(View(infor));
        }
コード例 #13
0
        public bool update(TextBox textBox1, TextBox textBox2, TextBox textBox3, int id)
        {
            obj      = user.Users.Where(x => x.IdUser == id).Single <Users>();
            obj.Name = textBox1.Text;
            obj.Age  = Convert.ToInt32(textBox2.Text);
            i        = user.Infor.Where(x => x.IdUsers == id).Single <Infor>();
            i.Info   = textBox3.Text;
            user.SubmitChanges();

            return(true);
        }
コード例 #14
0
        public ActionResult Create([Bind(Include = "StudentId,StudentName,Age")] Infor infor)
        {
            if (ModelState.IsValid)
            {
                db.Infors.Add(infor);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(infor));
        }
コード例 #15
0
        private void listen()
        {
            var ip = GetHostIP();

            try
            {
                _tcpl = new TcpListener(IPAddress.Parse(ip), 7100);
                _tcpl.Start();
                Sta = "ÕýÔÚ¼àÌý...";
                FiveGame.isplaying = true;
                while (_listenerRun)
                {
                    var s      = _tcpl.AcceptSocket();
                    var stream = new byte[80];
                    s.Receive(stream);
                    var substr  = "";
                    var tmp1    = "";
                    var message = Encoding.UTF8.GetString(stream);
                    Infor = message;
                    if (Infor.Length >= 4)
                    {
                        substr = Infor.Substring(0, 4);
                        tmp1   = Infor.Substring(4);
                    }

                    if (substr == "####")
                    {
                        var ss = tmp1.Split(',');
                        FiveGame.returnid     = ss[0];
                        FiveGame.speakmessage = ss[1];
                    }

                    if (substr == "%%$$")
                    {
                        var ss = tmp1.Split(',');
                        FiveGame.returnid = ss[0];
                        FiveGame.reip     = ss[1];
                        FiveGame.relevel  = ss[2];
                    }
                }
            }
            catch (SecurityException)
            {
                Sta = "·À»ðǽ°²È«´íÎó£¡";
            }
            catch (Exception ex)
            {
                Sta = "ÒÑÍ£Ö¹¼àÌý£¡" + ex.Message;
            }
        }
コード例 #16
0
        // GET: Infors/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Infor infor = db.Infors.Find(id);

            if (infor == null)
            {
                return(HttpNotFound());
            }
            return(View(infor));
        }
コード例 #17
0
    // Lấy thông tin của Record (word, pos) thứ index trong file Index
    private Infor GetInfoFromIndex(int index)
    {
        Infor kq = new Infor();

        int posWord       = _Index[index];
        int lenRecordWord = _Index[index + 1] - _Index[index];

        _fsIndex.Position = posWord;
        byte[] temp = new byte[lenRecordWord];
        _fsIndex.Read(temp, 0, temp.Length);

        kq.szWord    = Encoding.UTF8.GetString(temp, 0, lenRecordWord - _iPositionIndex);
        kq.iPosition = CFunctions.GetInt(temp, lenRecordWord - _iPositionIndex, _iPositionIndex);

        return(kq);
    }
コード例 #18
0
        private void loadSanPham()
        {
            List <ItemInGioHang> listSP_byBtn = Data_gioHang.Instance.loadDataSanPhamTrongGioNoPic();

            foreach (ItemInGioHang sp in listSP_byBtn)
            {
                ucSanPhamTrongGio_DatHang ucSanPham = new ucSanPhamTrongGio_DatHang();
                ucSanPham.SetThongTin(sp.SoLuongTrongGio, sp.TenSP, sp.Gia);
                this.fpnlMatHang.Controls.Add(ucSanPham);
            }
            Infor infor = Account.Instance.loadInfor();

            lblTenInDiaChi.Text = infor.Hoten;
            lblSDT.Text         = infor.SDT;
            lblDiaChi.Text      = infor.DiaChi;
        }
コード例 #19
0
    // There are 8 workers
    private void Awake()
    {
        EndGame = false;

        rewardTaps = 10;
        if (instance_Infor == null)
        {
            instance_Infor = this;
        }
        else
        {
            Destroy(gameObject);
        }

        entityManager = World.DefaultGameObjectInjectionWorld.EntityManager;
    }
コード例 #20
0
    // Lấy word và meaning của từ thứ index
    public CRecord this[int index]
    {
        get
        {
            Infor word1 = GetInfoFromIndex(index);
            Infor word2 = GetInfoFromIndex(index + 1);

            int pos = word1.iPosition;
            int len = word2.iPosition - pos;

            _fsContent.Position = pos;
            byte[] temp = new byte[len];
            _fsContent.Read(temp, 0, len);

            CRecord result = new CRecord(word1.szWord, Encoding.UTF8.GetString(temp, 0, temp.Length));
            return(result);
        }
    }
コード例 #21
0
    // Đưa nội dung của file Hash vào List<Infor>
    // iSizeCount: số byte qui định về Số lượng kí tự
    // iSizeKeyword: số byte qui định về Keyword
    // iSizePosition: số byte qui định về Position
    // iSizeCount + iSizeKeyword + iSizePosition: tổng số byte dùng để mô tả thông tin của file
    private void FileToHash(FileStream fs, List <Infor> lst, int iSizeCount, int iSizeKeyword, int iSizePosition)
    {
        int iCount;
        int iKeyword;
        int iPosition;

        LayThongTinMoTa(fs, iSizeCount, iSizeKeyword, iSizePosition, out iCount, out iKeyword, out iPosition);

        byte[] temp = new byte[iKeyword + iPosition];
        while (fs.Read(temp, 0, temp.Length) != 0)
        {
            string key = Encoding.UTF8.GetString(temp, 0, iKeyword);
            int    pos = CFunctions.GetInt(temp, iKeyword, iPosition);

            Infor ele = new Infor();
            ele.szWord    = key.TrimEnd(new char[] { ' ' });
            ele.iPosition = pos;
            lst.Add(ele);
        }
    }
コード例 #22
0
    public int FindWord(string szWord)
    {
        if (_Index.Count == 0)
        {
            return(-1);
        }
        if (szWord.Length == 0)
        {
            return(-1);
        }

        int result = -1;
        // Tìm vị trí của word có ký tự đầu trùng với ký tự đầu của szWord
        Infor temp = new Infor();

        temp.szWord = szWord[0].ToString();
        int index = _Hash.BinarySearch(0, _Hash.Count - 1, temp, new CompareInfor());

        result = index;

        if (index >= 0)
        {
            int begin     = _Hash[index].iPosition;
            int count     = _Hash[index + 1].iPosition - begin;
            int indexTemp = -1;
            temp.szWord = szWord;
            index       = BinarySearchForIndex(begin, count, temp, new CompareInforWithoutExact());
            while (index >= 0)
            {
                indexTemp = index;
                count     = index - begin;
                index     = BinarySearchForIndex(begin, count, temp, new CompareInforWithoutExact());
            }
            index = indexTemp;

            result = index;
        }
        return(result);
    }
コード例 #23
0
        private void btnExport_Click(object sender, EventArgs e)
        {
            if (frmListProject.OpenPro != -1)
            {
                // Update
                ProjectShape pro = new ProjectShape();
                pro.IDPro = frmListProject.OpenPro;
                pro.Note  = frmOutliner.note;
                ProjectController.AddProject(pro);

                Shape sp = new Shape();

                sp.ID        = root.IdObj;
                sp.LocationX = root.Point.X;
                sp.LocationY = root.Point.Y;
                sp.Witdh     = root.Witdh;
                sp.Height    = root.Height;
                sp.NameShape = root.Name;
                sp.IDPro     = frmListProject.OpenPro;
                ShapeController.AddShape(sp);

                foreach (var shape in root.lstObj)
                {
                    sp.ID        = shape.IdObj;
                    sp.LocationX = shape.Point.X;
                    sp.LocationY = shape.Point.Y;
                    sp.Witdh     = shape.Witdh;
                    sp.Height    = shape.Height;
                    sp.NameShape = shape.Name;
                    sp.IDPro     = frmListProject.OpenPro;
                    if (shape.Name == "Curve")
                    {
                        sp.LocationX2 = shape.P2.X;
                        sp.LocationY2 = shape.P2.Y;
                    }
                    ShapeController.AddShape(sp);
                }
                Infor t = new Infor();
                foreach (var temp in lstRt)
                {
                    t.ID          = Convert.ToInt32(temp.Tag);
                    t.LocationX   = temp.Location.X;
                    t.LocationY   = temp.Location.Y;
                    t.Witdh       = temp.Size.Width;
                    t.Height      = temp.Size.Height;
                    t.Description = temp.Text;

                    TextController.AddText(t);
                }
            }
            else
            {
                // Add new
                var lst = ProjectController.getListProject(frmMain.idPro);
                while (lst.Count() > 0)
                {
                    frmMain.idPro++;
                    lst = ProjectController.getListProject(frmMain.idPro);
                }
                ;
                ProjectShape pro = new ProjectShape();
                pro.IDPro = frmMain.idPro;
                pro.Note  = frmOutliner.note;
                ProjectController.AddProject(pro);

                Shape sp = new Shape();

                // Lưu root
                var c = ShapeController.CheckShape(root.IdObj);
                while (c.Count() > 0)
                {
                    root.IdObj = root.IdObj + 1;
                    c          = ShapeController.CheckShape(root.IdObj);
                }
                sp.ID        = root.IdObj;
                sp.LocationX = root.Point.X;
                sp.LocationY = root.Point.Y;
                sp.Witdh     = root.Witdh;
                sp.Height    = root.Height;
                sp.NameShape = root.Name;
                sp.IDPro     = pro.IDPro;
                ShapeController.AddShape(sp);

                foreach (var shape in root.lstObj)
                {
                    // Lưu shape
                    var d = ShapeController.CheckShape(shape.IdObj);
                    while (d.Count() > 0)
                    {
                        shape.IdObj = shape.IdObj + 1;
                        d           = ShapeController.CheckShape(shape.IdObj);
                    }
                    sp.ID        = shape.IdObj;
                    sp.LocationX = shape.Point.X;
                    sp.LocationY = shape.Point.Y;
                    sp.Witdh     = shape.Witdh;
                    sp.Height    = shape.Height;
                    sp.NameShape = shape.Name;
                    sp.IDPro     = pro.IDPro;
                    if (shape.Name == "Curve")
                    {
                        sp.LocationX2 = shape.P2.X;
                        sp.LocationY2 = shape.P2.Y;
                    }
                    ShapeController.AddShape(sp);
                }

                Infor t = new Infor();
                foreach (var temp in lstRt)
                {
                    t.ID          = Convert.ToInt32(temp.Tag);
                    t.LocationX   = temp.Location.X;
                    t.LocationY   = temp.Location.Y;
                    t.Witdh       = temp.Size.Width;
                    t.Height      = temp.Size.Height;
                    t.Description = temp.Text;

                    TextController.AddText(t);
                }
            }
        }
コード例 #24
0
        private void btnOpenProject_Click(object sender, EventArgs e)
        {
            try
            {
                int x = int.Parse(this.dtgvListProject.CurrentRow.Cells[0].Value.ToString());
                OpenPro = x;
                this.Close();

                var pro = ProjectController.getProject(OpenPro);
                frmOutliner.note = pro.Note;


                frmMap fMap = new frmMap();
                fMap.Show();
                List <Shape> openShape = new List <Shape>();

                openShape = ShapeController.getListShape(OpenPro);
                foreach (var s in openShape)
                {
                    if (s.NameShape == "Root")
                    {
                        MessageBox.Show("Project " + OpenPro);
                        frmMap.root = new Root(s.ID, "Root", new Point(Convert.ToInt32(s.LocationX), Convert.ToInt32(s.LocationY)), Convert.ToInt32(s.Witdh), Convert.ToInt32(s.Height));
                        frmMap.root.Draw(fMap.g2, fMap.myPen);

                        Infor infor = TextController.getInfor(s.ID);
                        if (infor != null)
                        {
                            RichTextBox rt = new RichTextBox();
                            rt.Visible  = true;
                            rt.Location = new Point(Convert.ToInt32(infor.LocationX), Convert.ToInt32(infor.LocationY));
                            rt.Size     = new Size(Convert.ToInt32(infor.Witdh), Convert.ToInt32(infor.Height));
                            rt.Text     = infor.Description;
                            rt.Tag      = infor.ID;
                            fMap.ptbDraw.Controls.Add(rt);
                            fMap.lstRt.Add(rt);
                        }
                    }
                    else if (s.NameShape == "Rectangle")
                    {
                        //MessageBox.Show("Rec");
                        Rec rec = new Rec(s.ID, "Rectangle", new Point(Convert.ToInt32(s.LocationX), Convert.ToInt32(s.LocationY)), Convert.ToInt32(s.Witdh), Convert.ToInt32(s.Height));
                        frmMap.root.lstObj.Add(rec);

                        Infor infor = TextController.getInfor(s.ID);
                        if (infor != null)
                        {
                            RichTextBox rt = new RichTextBox();
                            rt.Visible  = true;
                            rt.Location = new Point(Convert.ToInt32(infor.LocationX), Convert.ToInt32(infor.LocationY));
                            rt.Size     = new Size(Convert.ToInt32(infor.Witdh), Convert.ToInt32(infor.Height));
                            rt.Text     = infor.Description;
                            rt.Tag      = infor.ID;
                            fMap.ptbDraw.Controls.Add(rt);
                            fMap.lstRt.Add(rt);
                        }
                    }
                    else if (s.NameShape == "Circle")
                    {
                        //MessageBox.Show("Cir");
                        Circle cir = new Circle(s.ID, "Circle", new Point(Convert.ToInt32(s.LocationX), Convert.ToInt32(s.LocationY)), Convert.ToInt32(s.Witdh), Convert.ToInt32(s.Height));
                        frmMap.root.lstObj.Add(cir);

                        Infor infor = TextController.getInfor(s.ID);
                        if (infor != null)
                        {
                            RichTextBox rt = new RichTextBox();
                            rt.Visible  = true;
                            rt.Location = new Point(Convert.ToInt32(infor.LocationX), Convert.ToInt32(infor.LocationY));
                            rt.Size     = new Size(Convert.ToInt32(infor.Witdh), Convert.ToInt32(infor.Height));
                            rt.Text     = infor.Description;
                            rt.Tag      = infor.ID;
                            fMap.ptbDraw.Controls.Add(rt);
                            fMap.lstRt.Add(rt);
                        }
                    }
                    else if (s.NameShape == "Curve")
                    {
                        //MessageBox.Show("Cur");
                        Curve cur = new Curve(s.ID, "Curve", new Point(Convert.ToInt32(s.LocationX), Convert.ToInt32(s.LocationY)), new Point(Convert.ToInt32(s.LocationX2), Convert.ToInt32(s.LocationY2)), Convert.ToInt32(s.Witdh), Convert.ToInt32(s.Height));
                        frmMap.root.lstObj.Add(cur);
                    }
                }
                fMap.DrawObj(frmMap.root);
            } catch { }
        }
コード例 #25
0
    // Start is called before the first frame update
    void Start()
    {
        m_infor = Infor.instance_Infor;
        switch (m_type)
        {
        case TypeOfCheck.Coin:
            if (GetComponent <TextMeshProUGUI>())
            {
                m_text = GetComponent <TextMeshProUGUI>();
                m_text.SetText(m_infor.m_Coin.ToString());
            }
            break;

        case TypeOfCheck.Health:
            if (GetComponent <Slider>())
            {
                m_slider       = GetComponent <Slider>();
                m_slider.value = m_infor.m_PlayerCurrenthealth / m_infor.m_PlayerMaxhealth;
            }
            break;

        case TypeOfCheck.Hungry:
            if (GetComponent <Slider>())
            {
                m_slider       = GetComponent <Slider>();
                m_slider.value = m_infor.m_PlayerCurrentHungry / m_infor.m_PlayerMaxHungry;
            }
            break;

        case TypeOfCheck.Stress:
            if (GetComponent <Slider>())
            {
                m_slider       = GetComponent <Slider>();
                m_slider.value = m_infor.m_PlayerCurrentStrees / m_infor.m_PlayerMaxStrees;
            }
            break;

        case TypeOfCheck.HealthKid:
            if (GetComponent <Slider>())
            {
                m_slider       = GetComponent <Slider>();
                m_slider.value = m_infor.m_ChildCurrenthealth / m_infor.m_ChildMaxhealth;
            }
            break;

        case TypeOfCheck.HungryKid:
            if (GetComponent <Slider>())
            {
                m_slider       = GetComponent <Slider>();
                m_slider.value = m_infor.m_ChildCurrentHungry / m_infor.m_ChildMaxHungry;
            }
            break;

        case TypeOfCheck.StressKid:
            if (GetComponent <Slider>())
            {
                m_slider       = GetComponent <Slider>();
                m_slider.value = m_infor.m_ChildCurrentStrees / m_infor.m_ChildMaxStrees;
            }

            break;
        }
    }