Esempio n. 1
0
 private void btnEdit_Click(object sender, EventArgs e)
 {
     if (this.dgvTags.SelectedRows.Count > 0)
     {
         ITagDataSource dataBoundItem = this.dgvTags.SelectedRows[0].DataBoundItem as ITagDataSource;
         if (dataBoundItem != null)
         {
             TagEditForm form = new TagEditForm();
             form.TagEditControl.SetDataSource(dataBoundItem);
             form.StartPosition = FormStartPosition.CenterParent;
             if (form.ShowDialog(this) == DialogResult.OK)
             {
                 if (!this.IsTagNameUnique(dataBoundItem))
                 {
                     MessageBox.Show(this, "Tag name must be unique and not empty.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                 }
                 else
                 {
                     form.TagEditControl.GetDataSource(dataBoundItem);
                     this.m_adapter.UpdateTag(dataBoundItem);
                     this.Init(this.m_adapter);
                     if (this.m_editTags.Contains(dataBoundItem))
                     {
                         this.m_editTags.Remove(dataBoundItem);
                     }
                     this.m_editTags.Add(dataBoundItem);
                 }
             }
         }
     }
 }
Esempio n. 2
0
        private bool IsTagNameUnique(ITagDataSource ds)
        {
            IEnumerable <ITagDataSource> source = from item in this.m_adapter.GetTags()
                                                  where item.Name.Equals(ds.Name, StringComparison.CurrentCultureIgnoreCase) && !item.Equals(ds)
                                                  select item;

            string[] strArray = new string[] { "recent", "local", "iwads", "id games" };
            return((!string.IsNullOrEmpty(ds.Name) && (source.Count <ITagDataSource>() <= 0)) && !strArray.Contains <string>(ds.Name.ToLower()));
        }
Esempio n. 3
0
        public void InsertTag(ITagDataSource ds)
        {
            List <DbParameter> list;

            string[] exclude = new string[] { "TagID" };
            string   sql     = this.InsertStatement("Tags", ds, exclude, out list);

            this.DataAccess.ExecuteNonQuery(sql, list);
        }
Esempio n. 4
0
        public Tests()
        {
            var config = new Configuration();

            _helper = new Helper(config);
            _helper.Setup(TestData.FileName);

            // sut
            _sut = new TagDataSource(new NpgsqlConnection(config.ConnectionString));
        }
Esempio n. 5
0
 public void SetDataSource(ITagDataSource ds)
 {
     this.txtName.Text           = ds.Name;
     this.cmbTab.SelectedIndex   = ds.HasTab ? 0 : 1;
     this.cmbColor.SelectedIndex = ds.HasColor ? 0 : 1;
     if (ds.HasColor && ds.Color.HasValue)
     {
         this.m_color = new Color?(this.pnlColor.BackColor = Color.FromArgb(ds.Color.Value));
     }
 }
Esempio n. 6
0
        public void UpdateTag(ITagDataSource ds)
        {
            string             sql        = "update Tags set \r\n            Name = @Name, HasTab = @HasTab, HasColor = @HasColor, Color = @Color\r\n            where TagID = @TagID";
            List <DbParameter> parameters = new List <DbParameter> {
                this.DataAccess.DbAdapter.CreateParameter("Name", (ds.Name == null) ? string.Empty : ds.Name),
                this.DataAccess.DbAdapter.CreateParameter("HasTab", ds.HasTab),
                this.DataAccess.DbAdapter.CreateParameter("HasColor", ds.HasColor),
                this.DataAccess.DbAdapter.CreateParameter("Color", ds.Color.HasValue ? ((object)ds.Color) : ((object)DBNull.Value)),
                this.DataAccess.DbAdapter.CreateParameter("TagID", ds.TagID)
            };

            this.DataAccess.ExecuteNonQuery(sql, parameters);
        }
Esempio n. 7
0
 public void GetDataSource(ITagDataSource ds)
 {
     ds.Name     = this.txtName.Text;
     ds.HasTab   = this.cmbTab.SelectedIndex == 0;
     ds.HasColor = this.cmbColor.SelectedIndex == 0;
     if (this.m_color.HasValue)
     {
         ds.Color = new int?(this.m_color.Value.ToArgb());
     }
     else
     {
         ds.Color = null;
     }
 }
Esempio n. 8
0
 private void btnDelete_Click(object sender, EventArgs e)
 {
     if ((this.dgvTags.SelectedRows.Count > 0) && (MessageBox.Show(this, "Are you sure you want to delete this tag?", "Delete", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation) == DialogResult.OK))
     {
         ITagDataSource dataBoundItem = this.dgvTags.SelectedRows[0].DataBoundItem as ITagDataSource;
         if (dataBoundItem != null)
         {
             this.m_adapter.DeleteTag(dataBoundItem);
             this.m_adapter.DeleteTagMapping(dataBoundItem.TagID);
             this.Init(this.m_adapter);
             if (this.m_deleteTags.Contains(dataBoundItem))
             {
                 this.m_deleteTags.Remove(dataBoundItem);
             }
             this.m_deleteTags.Add(dataBoundItem);
         }
     }
 }
Esempio n. 9
0
        private void GameFileViewControl_CustomRowPaint(object sender, CancelEventArgs e)
        {
            e.Cancel = false;
            IGameFileDataSource gameFile = base.FromDataBoundItem(base.GameFileViewControl.CustomRowPaintDataBoundItem);

            if (gameFile != null)
            {
                ITagDataSource source2 = (from item in this.m_tagLookup.GetTags(gameFile)
                                          where item.HasColor && item.Color.HasValue
                                          select item).FirstOrDefault <ITagDataSource>();
                if (source2 != null)
                {
                    base.GameFileViewControl.CustomRowPaintForeColor = Color.FromArgb(source2.Color.Value);
                }
                else
                {
                    base.GameFileViewControl.CustomRowPaintForeColor = Control.DefaultForeColor;
                }
            }
        }
Esempio n. 10
0
 public IEnumerable <IGameFileDataSource> GetGameFiles(IGameFileGetOptions options, ITagDataSource tag)
 {
     throw new NotImplementedException();
 }
Esempio n. 11
0
 internal bool <GameFileViewControl_CustomRowPaint> b__2_0(ITagDataSource item) =>
 (item.HasColor && item.Color.HasValue);
Esempio n. 12
0
        public override bool Equals(object obj)
        {
            ITagDataSource source = obj as ITagDataSource;

            return((source != null) && (source.TagID == this.TagID));
        }
Esempio n. 13
0
 internal string <Init> b__5_0(ITagDataSource x) =>
Esempio n. 14
0
 public void InsertTag(ITagDataSource ds)
 {
     throw new NotImplementedException();
 }
Esempio n. 15
0
 public void DeleteTag(ITagDataSource ds)
 {
     this.DataAccess.ExecuteNonQuery($"delete from Tags where TagID = {ds.TagID}");
 }
Esempio n. 16
0
 public IEnumerable <IGameFileDataSource> GetGameFiles(ITagDataSource tag) =>
 Util.TableToStructure(this.DataAccess.ExecuteSelect($"select Files.* from GameFiles join TagMapping on TagMapping.FileID = GameFiles.GameFileID where TagID = {tag.TagID}").Tables[0], typeof(GameFileDataSource)).Cast <IGameFileDataSource>();
Esempio n. 17
0
        public IEnumerable <IGameFileDataSource> GetGameFiles(IGameFileGetOptions options, ITagDataSource tag)
        {
            DataTable table;
            string    selectFieldString = "GameFiles.*";
            string    str2 = string.Empty;
            string    str3 = string.Empty;

            if (tag != null)
            {
                str2 = "join TagMapping on TagMapping.FileID = GameFiles.GameFileID";
                str3 = $"TagMapping.TagID = {tag.TagID}";
            }
            if (options.SelectFields != null)
            {
                selectFieldString = this.GetSelectFieldString(options.SelectFields);
            }
            if (options.SearchField != null)
            {
                string str4 = s_opLookup[(int)options.SearchField.SearchOp];
                if (str4 == "like")
                {
                    options.SearchField.SearchText = string.Format("{0}{1}{0}", "%", options.SearchField.SearchText);
                }
                string str5 = options.SearchField.SearchFieldType.ToString("g");
                string str6 = "@search";
                if ((this.DataAccess.DbAdapter is SqliteDatabaseAdapter) && GameFileSearchField.IsDateTimeField(options.SearchField.SearchFieldType))
                {
                    str6 = $"Datetime('{DateTime.Parse(options.SearchField.SearchText).ToString("yyyy-MM-dd")}')";
                }
                if (str3 != string.Empty)
                {
                    str3 = $"and {str3}";
                }
                string        sql        = string.Format("select {2} from GameFiles {5} where {0} {1} {3} {4} {6}", new object[] { str5, str4, selectFieldString, str6, GetLimitOrderString(options), str2, str3 });
                DbParameter[] parameters = new DbParameter[] { this.DataAccess.DbAdapter.CreateParameter("search", options.SearchField.SearchText) };
                table = this.DataAccess.ExecuteSelect(sql, parameters).Tables[0];
            }
            else
            {
                if (str3 != string.Empty)
                {
                    str3 = $"where {str3}";
                }
                string str8 = string.Format("select {0} from GameFiles {2} {3} {1}", new object[] { selectFieldString, GetLimitOrderString(options), str2, str3 });
                table = this.DataAccess.ExecuteSelect(str8).Tables[0];
            }
            return(Util.TableToStructure(table, typeof(GameFileDataSource)).Cast <IGameFileDataSource>());
        }
Esempio n. 18
0
 public void DeleteTag(ITagDataSource ds)
 {
     throw new NotImplementedException();
 }
Esempio n. 19
0
 public TagTabView(object key, string title, IDataSourceAdapter adapter, GameFileFieldType[] selectFields, ITagDataSource tag) : base(key, title, adapter, selectFields)
 {
     this.InitializeComponent();
     this.TagDataSource = tag;
     this.m_tagAdapter  = adapter;
 }