public IEnumerable <IGameFile> GetGameFiles(ITagData tag) { DataTable dt = DataAccess.ExecuteSelect(string.Format("select GameFiles.* from GameFiles join TagMapping on TagMapping.FileID = GameFiles.GameFileID where TagID = {0}", tag.TagID)).Tables[0]; return(Util.TableToStructure(dt, typeof(GameFile)).Cast <IGameFile>()); }
public TagTabView(object key, string title, IDataSourceAdapter adapter, GameFileFieldType[] selectFields, ITagData tag) : base(key, title, adapter, selectFields) { InitializeComponent(); TagDataSource = tag; m_tagAdapter = adapter; }
private void btnEdit_Click(object sender, EventArgs e) { if (tagSelectCtrl.SelectedItem != null) { ITagData tag = tagSelectCtrl.SelectedItem; TagEditForm form = new TagEditForm(); form.TagEditControl.SetDataSource(tag); form.StartPosition = FormStartPosition.CenterParent; if (form.ShowDialog(this) == DialogResult.OK) { form.TagEditControl.GetDataSource(tag); if (!IsTagNameUnique(tag)) { MessageBox.Show(this, "Tag name must be unique and not empty.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); SetTagData(); } else { m_adapter.UpdateTag(tag); SetTagData(); if (m_editTags.Contains(tag)) { m_editTags.Remove(tag); } m_editTags.Add(tag); } tagSelectCtrl.SetSelectedItem(tag); } } }
public void UpdateGameFileTags(IEnumerable <IGameFile> gameFiles, IEnumerable <ITagData> tags) { ITagData[] changedTagsAll = new ITagData[] { }; foreach (IGameFile gameFile in gameFiles) { ITagData[] existingTags = DataCache.Instance.TagMapLookup.GetTags(gameFile); var addTags = tags.Except(existingTags); var removeTags = existingTags.Except(tags); foreach (var tag in addTags) { AddGameFileTag(new IGameFile[] { gameFile }, tag, out _); } foreach (var tag in removeTags) { RemoveGameFileTag(new IGameFile[] { gameFile }, tag); } changedTagsAll = changedTagsAll.Union(addTags.Union(removeTags)).ToArray(); } TagMapLookup.Refresh(changedTagsAll); }
public void InsertTag(ITagData tag) { List <DbParameter> parameters; string insert = InsertStatement("Tags", tag, new string[] { "TagID" }, out parameters); DataAccess.ExecuteNonQuery(insert, parameters); }
public IEnumerable <IGameFile> GetGameFiles(IGameFileGetOptions options, ITagData tag) { DataTable dt; string selectColumns = "GameFiles.*"; string join = string.Empty; string where = string.Empty; if (tag != null) { join = "join TagMapping on TagMapping.FileID = GameFiles.GameFileID"; where = string.Format("TagMapping.TagID = {0}", tag.TagID); } if (options.SelectFields != null) { selectColumns = GetSelectFieldString(options.SelectFields); } if (options.SearchField != null) { string op = s_opLookup[(int)options.SearchField.SearchOp]; if (op == "like") { options.SearchField.SearchText = string.Format("{0}{1}{0}", "%", options.SearchField.SearchText); } string searchCol = options.SearchField.SearchFieldType.ToString("g"); string searchParam = "@search"; if (DataAccess.DbAdapter is SqliteDatabaseAdapter && GameFileSearchField.IsDateTimeField(options.SearchField.SearchFieldType)) //sqlite datetime comparison hack { searchParam = string.Format("Datetime('{0}')", DateTime.Parse(options.SearchField.SearchText).ToString("yyyy-MM-dd")); } if (where != string.Empty) { where = string.Format("and {0}", where); } string query = string.Format("select {2} from GameFiles {5} where {0} {1} {3} {4} {6}", searchCol, op, selectColumns, searchParam, GetLimitOrderString(options), join, where); dt = DataAccess.ExecuteSelect(query, new DbParameter[] { DataAccess.DbAdapter.CreateParameter("search", options.SearchField.SearchText) }).Tables[0]; } else { if (where != string.Empty) { where = string.Format("where {0}", where); } string query = string.Format("select {0} from GameFiles {2} {3} {1}", selectColumns, GetLimitOrderString(options), join, where); dt = DataAccess.ExecuteSelect(query).Tables[0]; } return(Util.TableToStructure(dt, typeof(GameFile)).Cast <IGameFile>()); }
private void TagSelectCtrl_TagSelectionChanged(object sender, ITagData tag) { ITabView tagView = m_tabHandler.TabViewForTag(tag); if (tagView != null) { m_tabHandler.SelectTabView(tagView); } }
/// <summary>Initializes a new instance of the <see cref="PhotoService" /> class.</summary> /// <param name="photoData">The photo data.</param> /// <param name="tagData">The tag data.</param> /// <param name="logger">The logger.</param> /// <param name="fileSystemService">The file system service.</param> /// <param name="dynamicConfig">The dynamic configuration.</param> /// <param name="backgroundTaskQueue">The background task queue.</param> public PhotoService(IPhotoData photoData, ITagData tagData, ILogger <PhotoService> logger, IFileSystemService fileSystemService, IDynamicConfig dynamicConfig, IBackgroundTaskQueue backgroundTaskQueue) { _photoData = photoData; _tagData = tagData; _logger = logger; _fileSystemService = fileSystemService; _dynamicConfig = dynamicConfig; _backgroundTaskQueue = backgroundTaskQueue; }
public void SetDataSource(ITagData tag) { txtName.Text = tag.Name; cmbTab.SelectedIndex = tag.HasTab ? 0 : 1; cmbColor.SelectedIndex = tag.HasColor ? 0 : 1; if (tag.HasColor && tag.Color.HasValue) { m_color = pnlColor.BackColor = Color.FromArgb(tag.Color.Value); } }
public void RemoveGameFileTag(IEnumerable <IGameFile> gameFiles, ITagData tag) { TagMapping tagMapping = new TagMapping(); foreach (IGameFile gameFile in gameFiles) { tagMapping.TagID = tag.TagID; tagMapping.FileID = gameFile.GameFileID.Value; DataSourceAdapter.DeleteTagMapping(tagMapping); } }
public override bool Equals(object obj) { ITagData tag = obj as ITagData; if (tag != null) { return(tag.TagID == this.TagID); } return(false); }
public ITabView TabViewForTag(ITagData tag) { foreach (var item in m_tabLookup) { if (item.Value.TabView is TagTabView tagTabView && tagTabView.TagDataSource.TagID == tag.TagID) { return(item.Value.TabView); } } return(null); }
public void SetSelectedItem(ITagData tag) { ClearSelections(); foreach (DataGridViewRow row in dgvTags.Rows) { if (row.DataBoundItem is ITagData tagData && tagData.Equals(tag)) { dgvTags.FirstDisplayedScrollingRowIndex = row.Index; row.Selected = true; break; } } }
public void GetDataSource(ITagData tag) { tag.Name = txtName.Text; tag.HasTab = cmbTab.SelectedIndex == 0; tag.HasColor = cmbColor.SelectedIndex == 0; if (m_color.HasValue) { tag.Color = m_color.Value.ToArgb(); } else { tag.Color = null; } }
public void UpdateTag(ITagData tag) { string query = @"update Tags set Name = @Name, HasTab = @HasTab, HasColor = @HasColor, Color = @Color where TagID = @TagID"; List <DbParameter> parameters = new List <DbParameter>(); parameters.Add(DataAccess.DbAdapter.CreateParameter("Name", tag.Name == null ? string.Empty : tag.Name)); parameters.Add(DataAccess.DbAdapter.CreateParameter("HasTab", tag.HasTab)); parameters.Add(DataAccess.DbAdapter.CreateParameter("HasColor", tag.HasColor)); parameters.Add(DataAccess.DbAdapter.CreateParameter("Color", tag.Color.HasValue ? tag.Color : (object)DBNull.Value)); parameters.Add(DataAccess.DbAdapter.CreateParameter("TagID", tag.TagID)); DataAccess.ExecuteNonQuery(query, parameters); }
private void TryGettingVariable(ITagData tags, string variableWeLookFor, ref int variableValueHolder) { var vorbisComment = tags.GetTagSingle(variableWeLookFor); if (!vorbisComment.StartsWith(variableWeLookFor)) { return; } int value; if (int.TryParse(vorbisComment, out value)) { variableValueHolder = value; } }
public void GetDataSource(ITagData tag) { tag.Name = txtName.Text; tag.HasTab = cmbTab.SelectedIndex == 0; tag.HasColor = cmbColor.SelectedIndex == 0; tag.ExcludeFromOtherTabs = cmbExclude.SelectedIndex == 0; tag.Favorite = cmbFavorite.SelectedIndex == 0; if (m_color.HasValue) { tag.Color = m_color.Value.ToArgb(); } else { tag.Color = null; } }
private void DataCache_TagsChanged(object sender, EventArgs e) { if (m_tabHandler == null) { return; } foreach (var tabView in m_tabHandler.TabViews) { if (tabView is TagTabView tagTabView) { ITagData findTag = DataCache.Instance.Tags.FirstOrDefault(x => x.TagID == tagTabView.TagDataSource.TagID); if (findTag != null) { tagTabView.TagDataSource = findTag; } } } }
void GameFileViewControl_CustomRowPaint(object sender, System.ComponentModel.CancelEventArgs e) { e.Cancel = false; IGameFile gameFile = FromDataBoundItem(GameFileViewControl.CustomRowPaintDataBoundItem); if (gameFile != null) { ITagData tag = m_tagLookup.GetTags(gameFile).Where(x => x.HasColor && x.Color.HasValue).FirstOrDefault(); if (tag != null) { GameFileViewControl.CustomRowPaintForeColor = Color.FromArgb(tag.Color.Value); } else { GameFileViewControl.CustomRowPaintForeColor = CDataGridView.DefaultForeColor; } } }
private void btnDelete_Click(object sender, EventArgs e) { if (tagSelectCtrl.SelectedItem != null && MessageBox.Show(this, "Are you sure you want to delete this tag?", "Delete", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK) { ITagData tag = tagSelectCtrl.SelectedItem; m_adapter.DeleteTag(tag); m_adapter.DeleteTagMapping(tag.TagID); SetTagData(); if (m_deleteTags.Contains(tag)) { m_deleteTags.Remove(tag); } m_deleteTags.Add(tag); } }
public void UpdateTag(ITagData tag) { string query = @"update Tags set Name = @Name, HasTab = @HasTab, HasColor = @HasColor, Color = @Color, ExcludeFromOtherTabs = @ExcludeFromOtherTabs, Favorite = @Favorite where TagID = @TagID"; List <DbParameter> parameters = new List <DbParameter> { DataAccess.DbAdapter.CreateParameter("Name", tag.Name ?? string.Empty), DataAccess.DbAdapter.CreateParameter("HasTab", tag.HasTab), DataAccess.DbAdapter.CreateParameter("HasColor", tag.HasColor), DataAccess.DbAdapter.CreateParameter("Color", tag.Color.HasValue ? tag.Color : (object)DBNull.Value), DataAccess.DbAdapter.CreateParameter("TagID", tag.TagID), DataAccess.DbAdapter.CreateParameter("ExcludeFromOtherTabs", tag.ExcludeFromOtherTabs), DataAccess.DbAdapter.CreateParameter("Favorite", tag.Favorite) }; DataAccess.ExecuteNonQuery(query, parameters); }
public void AddGameFileTag(IEnumerable <IGameFile> gameFiles, ITagData tag, out List <IGameFile> alreadyTagged) { alreadyTagged = new List <IGameFile>(); foreach (IGameFile gameFile in gameFiles) { TagMapping tagMapping = new TagMapping { FileID = gameFile.GameFileID.Value, TagID = tag.TagID }; if (!DataSourceAdapter.GetTagMappings(tagMapping.FileID).Contains(tagMapping)) { DataSourceAdapter.InsertTagMapping(tagMapping); } else { alreadyTagged.Add(gameFile); } } }
public void SetCheckedTags() { int index = GetCheckBoxCellIndex(); if (index == -1) { return; } HashSet <ITagData> tagHash = new HashSet <ITagData>(m_checkedTags); foreach (DataGridViewRow row in dgvTags.Rows) { ITagData tag = row.DataBoundItem as ITagData; if (!(dgvTags.Rows[row.Index].Cells[index] is DataGridViewCheckBoxCell checkCell)) { continue; } checkCell.Value = tagHash.Contains(tag); } }
private void btnDelete_Click(object sender, EventArgs e) { if (dgvTags.SelectedRows.Count > 0 && MessageBox.Show(this, "Are you sure you want to delete this tag?", "Delete", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK) { ITagData tag = dgvTags.SelectedRows[0].DataBoundItem as ITagData; if (tag != null) { m_adapter.DeleteTag(tag); m_adapter.DeleteTagMapping(tag.TagID); Init(m_adapter); if (m_deleteTags.Contains(tag)) { m_deleteTags.Remove(tag); } m_deleteTags.Add(tag); } } }
private TagTabView CreateTagTab(ColumnField[] columnTextFields, ColumnConfig[] colConfig, string name, ITagData tag, bool isNew) { //use the local tab configuration for new tabs if (isNew) { colConfig = colConfig.Where(x => x.Parent == "Local").ToArray(); Array.ForEach(colConfig, x => x.Parent = tag.Name); } TagTabView tabView = new TagTabView(tag.TagID, name, DataSourceAdapter, DefaultGameFileSelectFields, tag); SetupTabBase(tabView, columnTextFields, colConfig, mnuLocal, true); tabView.GameFileViewControl.SetColumnFormat("ReleaseDate", CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern); tabView.GameFileViewControl.SetColumnFormat("Downloaded", CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern); tabView.GameFileViewControl.SetColumnFormat("LastPlayed", CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern); return(tabView); }
public void DeleteTag(ITagData tag) { throw new NotImplementedException(); }
private bool IsTagNameUnique(ITagData tag) { IEnumerable <ITagData> check = m_adapter.GetTags().Where(x => x.Name.Equals(tag.Name, StringComparison.CurrentCultureIgnoreCase) && !x.Equals(tag)); return(!(string.IsNullOrEmpty(tag.Name) || check.Any() || TabKeys.KeyNames.ToList().FindAll(x => tag.Name.Equals(x, StringComparison.CurrentCultureIgnoreCase)).Any())); }
public RecipeController(IRecipeData recipe, ITagData tags, RecipeDbContext context) { _recipe = recipe; _tags = tags; _context = context; }
public void DeleteTag(ITagData tag) { DataAccess.ExecuteNonQuery(string.Format("delete from Tags where TagID = {0}", tag.TagID)); }
public HomeController(ILinkData linkData, ITagData tagData) { _linkData = linkData; _tagData = tagData; }