Esempio n. 1
0
        private void tileView1_ItemClick(object sender, DevExpress.XtraGrid.Views.Tile.TileViewItemClickEventArgs e)
        {
            int       item_id   = (int)tileView1.GetRowCellValue(e.Item.RowHandle, Id);
            EventView eventView = EventViews.First(t => t.Id == item_id);

            eventView.Checked = !eventView.Checked;
        }
Esempio n. 2
0
        public void ChangeEventRegister(int eventId, AllEventViews allEventViews)
        {
            UnBindToEventView();
            EventView eventView = allEventViews.list.Find(t => t.EventId == eventId);

            eventView.RegisterChip(this.ChipId ?? 0);
            BindToEventView(allEventViews);
        }
Esempio n. 3
0
        public main()
        {
            InitializeComponent();
            // This line of code is generated by Data Source Configuration Wizard
            serveStatus_start.Visibility     = BarItemVisibility.Never;
            serveStatus_stop.Visibility      = BarItemVisibility.Always;
            ribbonbtn_serveAct_start.Enabled = true;
            ribbonbtn_serveAct_stop.Enabled  = false;
            //ListTimerViews =  new AllTimerViews();
            //ListEventViews = new AllEventViews(timerContext);
            int id = 0;

            foreach (Event item in dbContext.Events.ToList())
            {
                if (item.Amount > 1)//项目的台子大于1时,生成多个eventview
                {
                    for (int i = 1; i <= item.Amount; i++)
                    {
                        EventView eventView = new EventView();
                        eventView.ChipId = item.Chips.Count() >= i?item.Chips.ToList()[i - 1].Serial : 0;

                        eventView.Name       = item.Name + i.ToString();
                        eventView.Time_limit = item.TimeLimit;
                        eventView.EventId    = item.Id;
                        eventView.Id         = id;
                        EventViews.Add(eventView);
                        id++;
                    }
                }
                else if (item.Amount > 0)
                {
                    EventView eventView = new EventView();
                    eventView.ChipId     = item.Chips.Count() >= 1 ? item.Chips.FirstOrDefault().Serial: 0;
                    eventView.Name       = item.Name;
                    eventView.Time_limit = item.TimeLimit;
                    eventView.EventId    = item.Id;
                    eventView.Id         = id;
                    EventViews.Add(eventView);
                    id++;
                }
            }



            //gridControl1.DataSource = ListEventViews.list;

            gridControl1.DataSource = EventViews;
            gridControl2.DataSource = TimerViews;
            //  ListTimerViews.list = TimerViews;
            // ListEventViews.list = EventViews;



            // This line of code is generated by Data Source Configuration Wizard
            lookUpEdit1.Properties.DataSource    = EventViews;
            lookUpEdit1.Properties.ValueMember   = "Id";
            lookUpEdit1.Properties.DisplayMember = "Name";
        }
Esempio n. 4
0
        public void BindToEventView(AllEventViews allEventViews)
        {
            EventView eventView = allEventViews.list.Find(t => t.ChipId == this.ChipId);

            if (eventView != null)
            {
                eventView.BindTimerView(this);
            }
        }
Esempio n. 5
0
        private void BindChip(TimerView timerView)
        {
            EventView eventView = EventViews.First(t => t.ChipId == timerView.ChipId);

            eventView.Timer     = timerView;
            timerView.EventName = eventView.Name;
            SendMessageToSocket("setdata,eventname," + eventView.Name, timerView.Socket);
            SendMessageToSocket("setdata,timelimit," + eventView.Time_limit.GetValueOrDefault().TotalSeconds, timerView.Socket);
        }
Esempio n. 6
0
        public AllEventViews(Competition.EF.Models.CompetitionDbContext dbContext)
        {
            list = new List <EventView>();
            foreach (Event item in dbContext.Events.ToList())
            {
                foreach (Chip chip in item.Chips)
                {
                    EventView eventView = new EventView();
                    eventView.ChipId     = chip.Id;
                    eventView.Name       = item.Name;
                    eventView.Time_limit = item.TimeLimit;
                    eventView.EventId    = item.Id;

                    list.Add(eventView);
                }
            }
        }
Esempio n. 7
0
        private void ChangeEventRegister(int chipid, int item_id)
        {
            TimerView timer = TimerViews.First(t => t.ChipId == chipid); //查找对应的timer对象

            //timer.ChangeEventRegister(eventid, ListEventViews);
            UnBindChip(timer);//先取消与此timer有关的eventView注册


            EventView eventView = EventViews.Find(t => t.Id == item_id); //查找对应的eventView对象

            eventView.ChipId = chipid;                                   //设置内存里EventView里的chipid
            BindChip(timer);                                             //注册修改后的timer对象到eventView中
            try
            {
                Chip chip = dbContext.Chips.Where(c => c.Serial == chipid).FirstOrDefault();
                if (chip != null)
                {
                    chip.EventId = eventView.EventId;
                }
                else
                {
                    dbContext.Chips.Add(new Chip()
                    {
                        EventId = eventView.EventId, Serial = chipid
                    });
                }

                dbContext.SaveChanges();
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }


            // dbContext.Events.First(t => t.Id == eventid).ChipId = chipid;//修改数据库里的event的chipid
        }