Пример #1
0
        private async Task LoadTemplate(string templateId)
        {
            if (string.IsNullOrWhiteSpace(templateId))
            {
                return;
            }

            Clear();
            _model = await _lootTemplateService.Get(templateId);

            if (_model == null)
            {
                MessageBox.Show($@"Object with ObjectId: {templateId} not found", @"Object not found");
                return;
            }

            BindingService.BindData(_model.MobXLootTemplate, this);
            _MobXLootTemplate_ID.Text = _model.MobXLootTemplate.ObjectId;

            var mob = _mobs.FirstOrDefault(x => _model.MobXLootTemplate.MobName == x.Name);

            if (mob != null)
            {
                await _modelImageService.LoadMob(mob.Model, pictureBox2.Width, pictureBox2.Height)
                .ContinueWith(x => pictureBox2.Image = x.Result);
            }

            var bindingList = new BindingList <LootTemplate>(_model.LootTemplates);
            var source      = new BindingSource(bindingList, null);

            dataGridView1.DataSource = source;
            SetGridColumns();
        }
Пример #2
0
 private void Clear()
 {
     _model = null;
     BindingService.ClearData(this);
     dataGridView1.DataSource = null;
     pictureBox1.Image        = null;
     pictureBox2.Image        = null;
 }
Пример #3
0
        public async Task <LootTemplateModel> Get(string templateId)
        {
            return(await Task.Run(() =>
            {
                var template = DatabaseManager.Database.FindObjectByKey <MobXLootTemplate>(templateId);
                if (template == null)
                {
                    return null;
                }

                var model = new LootTemplateModel
                {
                    MobXLootTemplate = template,
                    LootTemplates = DatabaseManager.Database
                                    .SelectObjects <LootTemplate>("`TemplateName` = @TemplateName",
                                                                  new QueryParameter("@TemplateName", template.LootTemplateName))
                                    .ToList()
                };

                return model;
            }));
        }