Пример #1
0
        /// <summary>
        /// Finds the current index
        /// </summary>
        /// <param name="find"></param>
        /// <returns></returns>
        private (int main, int sub) FindIndex(QueryDatabaseModel find)
        {
            for (int i = 0; i < QueryLists.Count; i++)
            {
                for (int j = 0; j < QueryLists[i].Count; j++)
                {
                    if (QueryLists[i][j].Equals(find))
                    {
                        return(i, j);
                    }
                }
            }

            return(-1, -1);
        }
Пример #2
0
        /// <summary>
        /// Inserts a query at a location
        /// </summary>
        /// <param name="locationType"></param>
        public void InsertQuery(InsertLocation locationType)
        {
            QueryDatabaseModel item = SelectedIndexes[0];
            var location            = FindIndex(item);

            switch (locationType)
            {
            case InsertLocation.After:
                if (location.main + 1 > QueryLists.Count)
                {
                    QueryLists.Add(new List <QueryDatabaseModel>()
                    {
                        new QueryDatabaseModel()
                    });
                }
                else
                {
                    QueryLists.Insert(location.main + 1, new List <QueryDatabaseModel>()
                    {
                        new QueryDatabaseModel()
                    });
                }
                break;

            case InsertLocation.Before:
                QueryLists.Insert(location.main, new List <QueryDatabaseModel>()
                {
                    new QueryDatabaseModel()
                });
                break;

            case InsertLocation.Into:
                QueryDatabaseModel value = new QueryDatabaseModel();
                value.AddLastBracer();
                if (QueryLists[location.main].Count == 1)
                {
                    QueryLists[location.main][0].AddFirstBracer();
                }
                else
                {
                    QueryLists[location.main][QueryLists[location.main].Count - 1].RemoveLastBracer();
                }

                QueryLists[location.main].Add(value);
                break;
            }
        }