Esempio n. 1
0
 public void True(SynergyList sl)
 {
     foreach(SynergyItem si in sl.Items)
     {
         AddItem(si);
     }
 }
        private SynergyList EnsureList(string listName)
        {
            SynergyList sl = GetListByName(listName);

            if (sl == null)
            {
                sl = new SynergyList()
                {
                    Name = listName
                };

                _lists.Add(sl);
            }

            return sl;
        }
        private void txtListName_KeyUp(object sender, KeyEventArgs e)
        {
            //TODO: we can add predictive text without losing our current bevior, 
            //but it will take a bit more time than I have at the moment
            //heres how I'm thinking: as we type (second block below)
            //instead of GetListByName() we call GetFirstListThatStartsWith(listNamePartial)
            //which still returns null if nothing is found, but otherwise returns
            //the first list that starts with the current value
            //then we populate the textbox with that list's name, but
            //we set selection on all letters that are not included in the original entry
            //(eg. if we type "Tes" and there is a list called "Testing" it would
            //set txtListName to "Test" with the final "t" highlighted, so if
            //a user keeps typing, it is overwritten with the next letter and the 
            //process starts all over again to match another list if it exists
            //
            //NB: if enter is pressed, make sure it doesn't erase the highlighted text
            //
            //NB: re: listNameExists/StartsWith(): for any camel cased letters in the input, 
            //insert spaces prior to processing. Spaces are the expected separator, but 
            //if type ahead is used, the list names populating it will be PascalCase. A 
            //conversion is one way to ensure uniformity of behavior, for both input cases.



            if (e.Key == Key.Enter)
            {
                txtListName.Text = SynergyUtils.ProcessListName(txtListName.Text);
                BindingExpression exp = this.txtListName.GetBindingExpression(TextBox.TextProperty);
                exp.UpdateSource();
                txtListName.Text = "";
            }
            else
            {
                //check as we type
                string listName = SynergyUtils.ProcessListName(txtListName.Text);

                SynergyList sl = GetListByName(listName);

                if (sl != null)
                {
                    SelectedList = sl;
                }
                else
                {
                    SelectedList = null;
                }
            }
        }
 private void ClearAll()
 {
     _lists.Clear();
     SelectedList = null;
     txtInput.Text = "";
     ReLoadListItems(); //will clear list because selected list is null
     statusBar.StatusBarText = "All Lists Cleared.";
 }
Esempio n. 5
0
        public override IEnumerable<SynergyList> GetLists(bool active)
        {
            Dictionary<string, SynergyList> lists =
                new Dictionary<string, SynergyList>();

            try
            {
                using (var conn =
                    new SQLiteConnection(@"Data Source=" +
                        Configuration.GetSqliteDbPath(GetDbName())))
                {
                    conn.Open();

                    using (var cmd = new SQLiteCommand(conn))
                    {
                        using (var transaction = conn.BeginTransaction())
                        {
                            string cmdString =
                                "SELECT sl." + NwdContract.COLUMN_SYNERGY_LIST_NAME + ", " +
                                       "si." + NwdContract.COLUMN_SYNERGY_ITEM_VALUE + ", " +
                                       "std." + NwdContract.COLUMN_SYNERGY_TO_DO_COMPLETED_AT + ", " +
                                       "std." + NwdContract.COLUMN_SYNERGY_TO_DO_ARCHIVED_AT + " " +
                                "FROM " + NwdContract.TABLE_SYNERGY_LIST + " sl " +
                                "JOIN " + NwdContract.TABLE_SYNERGY_LIST_ITEM + " sli " +
                                    "ON sl." + NwdContract.COLUMN_SYNERGY_LIST_ID +
                                    " = sli." + NwdContract.COLUMN_SYNERGY_LIST_ID + " " +
                                "JOIN " + NwdContract.TABLE_SYNERGY_ITEM + " si " +
                                    "ON sli." + NwdContract.COLUMN_SYNERGY_ITEM_ID +
                                    " = si." + NwdContract.COLUMN_SYNERGY_ITEM_ID + " " +
                                "JOIN " + NwdContract.TABLE_SYNERGY_TO_DO + " std " +
                                    "ON sli." + NwdContract.COLUMN_SYNERGY_LIST_ITEM_ID + " " +
                                    " = std." + NwdContract.COLUMN_SYNERGY_LIST_ITEM_ID + " " +
                                "WHERE (std." + NwdContract.COLUMN_SYNERGY_TO_DO_COMPLETED_AT + " IS NULL OR " +
                                       "std." + NwdContract.COLUMN_SYNERGY_TO_DO_COMPLETED_AT + " = '') " +
                                "AND (std." + NwdContract.COLUMN_SYNERGY_TO_DO_ARCHIVED_AT + " IS NULL OR " +
                                     "std." + NwdContract.COLUMN_SYNERGY_TO_DO_ARCHIVED_AT + " = '') ";

                            if (active)
                            {
                                cmdString += "AND sl." + NwdContract.COLUMN_SYNERGY_LIST_ACTIVATED_AT +
                                    " > sl." + NwdContract.COLUMN_SYNERGY_LIST_SHELVED_AT + " ";
                            }

                            cmd.CommandText = cmdString;

                            //cmd.Parameters.AddWithValue("@active", active);

                            using (var rdr = cmd.ExecuteReader())
                            {
                                while (rdr.Read())
                                {
                                    string listName = rdr.GetString(0);
                                    string itemValue = rdr.GetString(1);
                                    string completedAt = "";
                                    string archivedAt = "";

                                    if (!rdr.IsDBNull(2))
                                    {
                                        completedAt = rdr.GetString(2);
                                    }

                                    if (!rdr.IsDBNull(3))
                                    {
                                        archivedAt = rdr.GetString(3);
                                    }

                                    if (!lists.ContainsKey(listName))
                                    {
                                        lists[listName] = new SynergyList()
                                        {
                                            Name = listName
                                        };
                                    }

                                    SynergyItem si = new SynergyItem();

                                    si.TurnOffFragmentUpdating();
                                    si.Item = itemValue;
                                    si.CompletedAt = completedAt;
                                    si.ArchivedAt = archivedAt;
                                    si.TurnOnFragmentUpdatingAndUpdate();

                                    lists[listName].AddItem(si);
                                }
                            }

                            transaction.Commit();
                        }
                    }

                    conn.Close();
                }
            }
            catch (Exception ex)
            {
                //lets just throw it for now, but put something here eventually
                throw ex;
            }

            return lists.Values
                .OrderBy(x => x.Name)
                .ToList<SynergyList>();
        }
Esempio n. 6
0
        public static SynergyList EnsureList(this List<SynergyList> lst, string listName)
        {
            SynergyList found = null;

            foreach(SynergyList sl in lst)
            {
                if (sl.Name.Equals(listName))
                {
                    found = sl;
                }
            }

            if(found == null)
            {
                found = new SynergyList()
                {
                    Name = listName
                };

                lst.Add(found);
            }

            return found;
        }
Esempio n. 7
0
 private void WriteListToPath(SynergyList lst, string path, int ignoredCount)
 {
     if (!File.Exists(path))
     {
         File.WriteAllLines(path, lst.Items.ToFragmentArray());
     }
     else
     {
         ignoredCount++;
     }
 }