コード例 #1
0
        public void RemoveCurrentPlaylist()
        {
            LanguageData dataLayer = new LanguageData();
            dataLayer.DeleteRecentPlaylistByIndex(0);

            RefreshRecentPlaylists();
        }
コード例 #2
0
        public void AddPlaylist(List<int> cardIDs, string description)
        {
            LanguageData dataLayer = new LanguageData();
            dataLayer.InsertRecentPlaylist(cardIDs, description, 10);

            RefreshRecentPlaylists();
        }
コード例 #3
0
        public void UpdateCurrentPlaylist(List<int> cardIDs, string description)
        {
            dsLanguageData.RecentPlaylistRow row = _dtRecentPlaylist[0];

            LanguageData dataLayer = new LanguageData();
            dataLayer.daRecentPlaylist.UpdateByID(row.ID, description, dataLayer.IntListToString(cardIDs), row.Index);

            RefreshRecentPlaylists();
        }
コード例 #4
0
        public CreateNewGroupDialog()
        {
            InitializeComponent();

            LanguageData dataLayer = new LanguageData();
            cmbBoxCollection.DataSource = dataLayer.daCollection.GetData();
            cmbBoxCollection.DisplayMember = "Name";
            cmbBoxCollection.ValueMember = "ID";
        }
コード例 #5
0
 void ldata_DataImported(LanguageData.DataImportedEventArgs e)
 {
     if (this.lvInfo.InvokeRequired)
     {
         // It's on a different thread, so use Invoke.
         LanguageData.DataImportedEventHandler d = new LanguageData.DataImportedEventHandler(updateInfo);
         this.Invoke(d, new object[] { e });
     }
     else
     {
         updateInfo(e);
     }
 }
コード例 #6
0
        public void RefreshRecentPlaylists()
        {
            listView1.Items.Clear();

            try
            {
                LanguageData dataLayer = new LanguageData();
                _dtRecentPlaylist = dataLayer.daRecentPlaylist.GetData();

                foreach (dsLanguageData.RecentPlaylistRow row in _dtRecentPlaylist)
                {
                    listView1.Items.Add(new IDListViewItem(row.ID, row.Name));
                }
            }
            catch (FileNotFoundException e)
            {
                //TODO send a message here that the main form will pick up and display on the bottom
            }
        }
コード例 #7
0
        private void dictionaryDataGrid_UserDeletingRow(object sender, DataGridViewRowCancelEventArgs e)
        {
            if (MessageBox.Show("Are you sure you want to delete to selected row?", "Delete Row?", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                //Todo delete the row and update the DataSet + DataGrid
                LanguageData dataLayer = new LanguageData();
                int i = dataLayer.daDictionary.DeleteByID((int)e.Row.Cells[0].Value);

                if (i > 0)
                {
                    if (DataChanged != null)
                        DataChanged(this, new EventArgs());
                }
            }
            else
            {
                e.Cancel = true;
            }
        }
コード例 #8
0
        void updateInfo(LanguageData.DataImportedEventArgs e)
        {
            ListViewItem item = new ListViewItem(e.Message);
            if (!e.Success)
            {
                item.ForeColor = Color.Red;
            }

            lvInfo.Items.Insert(0, item);

            progressBar1.Maximum = e.Total;
            progressBar1.Value = e.Index;

            if (e.Total == e.Index)
            {
                progressBar1.Value = 0;
                MessageBox.Show("Finished Importing Data", "All Done");
            }

            this.Refresh();
        }
コード例 #9
0
ファイル: MainForm.cs プロジェクト: eneifert/LanguageLearner
        void addNewCard()
        {
            //check to see if the card should maybe be added to a CardList
            if (cardListPlayList.CardListIDs.Count > 0)
            {
                //If the user needs to select which cardLists to add it to
                if (_chooseCardListsDialog == null || _chooseCardListsDialog.Description != cardListPlayList.Description || !_chooseCardListsDialog.RememberSelection)
                {
                    _chooseCardListsDialog = new ChooseCardListsDialog(cardListPlayList.CardListIDs, cardListPlayList.Description);
                    _chooseCardListsDialog.ShowDialog();

                    if (_chooseCardListsDialog.DialogResult != DialogResult.OK)
                    {
                        _chooseCardListsDialog = null;
                        return;
                    }
                }
            }

            //Create the card
            LanguageData dataLayer = new LanguageData();
            dsLanguageData.CardRow newCard = new dsLanguageData.CardDataTable().MakeNewCardRow();
            int tmp = dataLayer.InsertOrUpdateCard(newCard);

            //Add the card to the selected CardLists
            if (_chooseCardListsDialog != null)
            {
                foreach (int id in _chooseCardListsDialog.SelectedCardListIDs)
                {
                    int i = dataLayer.InsertCardListDataItem(id, newCard.ID);
                }
            }

            //Load the card and refresh the lists
            cardListPlayList.RefreshCards();
            cardControl.LoadCard(newCard);

            cardListPlayList.AddCard(newCard);
        }
コード例 #10
0
        void Dictionary_RowChanged(object sender, DataRowChangeEventArgs e)
        {
            switch (e.Action)
            {
                case DataRowAction.Add:
                case DataRowAction.Change:
                    LanguageData dataLayer = new LanguageData();
                    dsLanguageData.DictionaryRow dict = toDictionaryRow((dsDictionary.DictionaryRow) e.Row);

                    if (isValidRow(dict))
                    {
                        int i = dataLayer.InsertOrUpdateDictionary(dict);
                        if (i > 0)
                        {
                            if (DataChanged != null)
                                DataChanged(this, new EventArgs());
                        }
                        dsDictionary.AcceptChanges();
                    }

                    break;
            }
        }
コード例 #11
0
        private void listViewResults_ItemDrag(object sender, ItemDragEventArgs e)
        {
            List<int> cardIDs = new List<int>();

            foreach (ListViewItem item in listViewResults.SelectedItems)
            {
                if(item is IDListViewItem)
                    cardIDs.Add(((IDListViewItem)item).ID);
            }

            if (cardIDs.Count > 0)
            {
                LanguageData dataLayer = new LanguageData();
                string description = string.Empty;

                foreach (dsLanguageData.CardRow card in dataLayer.GetCardsByIDs(cardIDs))
                {
                    description += ", " + card.Question;
                }
                description = description.Remove(0, 2);

                DoDragDrop(new CardDragDropHolder(this, cardIDs, description, CardDragDropAction.Add), DragDropEffects.All);
            }
        }
コード例 #12
0
ファイル: GetImages.cs プロジェクト: eneifert/LanguageLearner
        void loadCard(dsLanguageData.CardRow card)
        {
            clearCard();

            _curCard = card;

            if (_curCard != null)
            {
                txtAnswer.Text = _curCard.Answer;
                txtQuestion.Text = _curCard.Question;

                LanguageData dataLayer = new LanguageData();
                dsLanguageData.PictureDataTable dtPic = dataLayer.daPicture.GetDataByCardID(_curCard.ID);
                if (dtPic != null && dtPic.Rows.Count > 0 && dtPic[0].Image.Length > 0)
                {
                    cardPreviewPictureBox.Image = dataLayer.ByteArrayToImage(dtPic[0].Image);
                }
            }
        }
コード例 #13
0
        dsLanguageData.CardDataTable getSelectedCardsBySelectedLetters()
        {
            string whereClause = string.Empty;
            bool empty = true;
            string column = string.Empty;

            LanguageData dataLayer = new LanguageData();
            dsLanguageData.DictionaryDataTable dictionary = dataLayer.daDictionary.GetData();

            foreach (MWCommon.MWTreeNodeWrapper node in dictionaryTreeView.SelNodes.Values)
            {
                MyTreeNode tmp = node.Node as MyTreeNode;
                if (tmp.Type == MyTreeNodeType.Letter)
                {
                    empty = false;
                    DataRow[] rows = dictionary.Select(string.Format("Name = '{0}'", tmp.Parent.Text));
                    column = rows[0]["Column"].ToString();
                    whereClause += string.Format("({0} LIKE '{1}%') OR", column, tmp.Text);
                }
            }

            if (!empty)
            {
                whereClause = whereClause.Remove(whereClause.Length - 2, 2);
                whereClause += string.Format(" Order By {0}", column);
            }

            return dataLayer.GetCardsWhere(whereClause);
        }
コード例 #14
0
        void setListView(List<int> cardListIDs, ListView listView)
        {
            listView.Items.Clear();
            LanguageData dataLayer = new LanguageData();

            foreach (int id in cardListIDs)
            {
                dsLanguageData.CardListRow row = dataLayer.daCardList.GetDataByID(id)[0];
                listView.Items.Add(new IDListViewItem(row.ID, row.Name));
            }
        }
コード例 #15
0
        /// <summary>
        /// Loads all of the cards images in the results panel
        /// </summary>
        /// <param name="cards"></param>
        public void LoadImagesForCards(dsLanguageData.CardDataTable cards)
        {
            resultsFlowLayoutPanel.Controls.Clear();

            LanguageData dataLayer = new LanguageData();

            resultsFlowLayoutPanel.SuspendLayout();

            foreach (dsLanguageData.CardRow card in cards)
            {
                Image img = dataLayer.GetPictureForCard(card.ID);
                AddImagePreview(img, card.Answer, true, true);
            }

            resultsFlowLayoutPanel.ResumeLayout();
        }
コード例 #16
0
        dsLanguageData.CardDataTable getSelectedCardsBySelectedCardsInDictionary()
        {
            string whereClause = "Where ID in (";
            bool empty = true;

            LanguageData dataLayer = new LanguageData();
            dsLanguageData.DictionaryDataTable dictionary = dataLayer.daDictionary.GetData();
            string column = string.Empty;

            foreach (MWCommon.MWTreeNodeWrapper node in dictionaryTreeView.SelNodes.Values)
            {
                MyTreeNode tmp = node.Node as MyTreeNode;
                if (tmp.Type == MyTreeNodeType.Card)
                {
                    DataRow[] rows = dictionary.Select(string.Format("Name = '{0}'", tmp.Parent.Parent.Text));
                    column = rows[0]["Column"].ToString();

                    whereClause += tmp.ID.ToString() + ", ";
                    empty = false;
                }
            }

            if(empty)
                return new dsLanguageData.CardDataTable();

            whereClause = whereClause.Remove(whereClause.Length - 2,2);
            whereClause += ") Order By " + column;

            return dataLayer.GetCardsWhere(whereClause);
        }
コード例 #17
0
        void search()
        {
            if (txtSearch.Text.Trim().Length < 1)
            {
                MessageBox.Show("Please enter text to search for.", "Search for what?", MessageBoxButtons.OK);
                return;
            }

            string precision = "%";
            if (chkBoxExact.Checked)
                precision = string.Empty;

            string whereClause = string.Format("Where {0} like '{2}{1}{2}'", cmbSearchBy.SelectedItem.ToString(), txtSearch.Text, precision);

            if (cmbSearchBy.SelectedItem.ToString() == both)
            {
                whereClause = string.Format("Where Answer like '{1}{0}{1}' OR Question like '{1}{0}{1}'", txtSearch.Text, precision);
            }

            LanguageData dataLayer = new LanguageData();
            loadResults(dataLayer.GetCardsWhere(whereClause));
        }
コード例 #18
0
        /// <summary>
        /// Loads the card and also checks to make sure the user is finished with the previous card.
        /// </summary>
        /// <param name="card"></param>
        /// <returns>Whether or not the card was loaded</returns>
        public bool LoadCard(dsLanguageData.CardRow card)
        {
            bool result = false;

            if (ChangesHaveBeenSavedOrIgnored())
            {
                ClearCard();

                if (card == null)
                    return true;

                SuspendLayout();

                _curCard = card;

                LanguageData dataLayer = new LanguageData();

                dsLanguageData.SoundClipDataTable dtSound = dataLayer.daSoundClip.GetDataByCardID(_curCard.ID);
                if (dtSound.Rows.Count > 0 && dtSound[0].SoundClip != null)
                {
                    _curSoundClip = dtSound[0];
                    _dictaphone.WavStream = new MemoryStream(_curSoundClip.SoundClip);
                    _dictaphone.ClosePlayer();
                    setSoundButton(true);
                }

                dsLanguageData.PictureDataTable dtPic = dataLayer.daPicture.GetDataByCardID(_curCard.ID);
                if (dtPic.Rows.Count > 0 && dtPic[0].Image != null)
                {
                    pictureBox.Image = dataLayer.ByteArrayToImage(dtPic[0].Image);
                }

                txtQuestion.Text = getTextForQuestion(_curCard);

                if (chkBoxShowAnswer.Checked)
                    ShowInformation();

                txtNotes.Text = _curCard.Notes;
                Difficulty = _curCard.Difficulty;

                result = true;

                ResumeLayout();
            }

            if (result)
            {
                SetEnable(true);
            }

            return result;
        }
コード例 #19
0
        dsLanguageData.CardDataTable getSelectedCardsBySelectedCardLists()
        {
            dsLanguageData.CardDataTable cards = new dsLanguageData.CardDataTable();
            List<int> cardListIDs = new List<int>();

            foreach (MWCommon.MWTreeNodeWrapper node in cardListsTreeView.SelNodes.Values)
            {
                MyTreeNode tmp = node.Node as MyTreeNode;
                if (tmp.Type == MyTreeNodeType.CardList)
                    cardListIDs.Add(tmp.ID);
            }

            if (cardListIDs.Count > 0)
            {
                LanguageData dataLayer = new LanguageData();
                cards = dataLayer.GetCardsInCardLists(cardListIDs);
            }

            return cards;
        }
コード例 #20
0
        /// <summary>
        /// Checks to see if any changes have been handled.
        /// </summary>
        /// <returns></returns>        
        public bool ChangesHaveBeenSavedOrIgnored()
        {
            bool ok = true;

            if (_curCard == null)
                return ok;

            LanguageData dataLayer = new LanguageData();

            if (hasChanges())
            {
                ok = false;
                DialogResult result = MessageBox.Show("Do you want to save the changes?", "Save Changes?", MessageBoxButtons.YesNoCancel);
                if (result == DialogResult.Yes)
                {
                    //if the card has no data just get rid of it
                    if (_curCard != null && isCardEmpty(this.writeDataToCard(_curCard), this.writeSoundDataToSoundClip(_curSoundClip)))
                    {
                        deleteCard(_curCard);
                        ok = true;
                    }
                    else
                    {
                        ok = SaveCard();
                    }
                }
                else if (result == DialogResult.No)
                {
                    //check to see if the old card is empty and delete if it is
                    dsLanguageData.CardRow cardBeforeChanges = dataLayer.daCard.GetDataByCardID(_curCard.ID)[0];
                    dsLanguageData.SoundClipRow soundClipBeforeChanges;
                    try
                    {
                        soundClipBeforeChanges = dataLayer.daSoundClip.GetDataByCardID(cardBeforeChanges.ID)[0];
                    }
                    catch (IndexOutOfRangeException)
                    {
                        soundClipBeforeChanges = null;
                    }
                    if (isCardEmpty(cardBeforeChanges, soundClipBeforeChanges))
                    {
                        deleteCard(cardBeforeChanges);
                    }

                    ok = true;
                }
            }
            else
            {
                if (isCardEmpty(_curCard, _curSoundClip) && _curCard != null)
                {
                    deleteCard(_curCard);
                }
            }
            return ok;
        }
コード例 #21
0
        private void CardListPlayList_DragDrop(object sender, DragEventArgs e)
        {
            string[] formats = e.Data.GetFormats();
            bool wasEmpty = Cards.Count < 1;

            if (e.Data.GetData(formats[0]) is CardDragDropHolder)
            {
                //Add the card to the list
                LanguageData dataLayer = new LanguageData();
                CardDragDropHolder tmp = e.Data.GetData(formats[0]) as CardDragDropHolder;

                dsLanguageData.CardDataTable dtNewCards = dataLayer.GetCardsByIDs(tmp.CardIDs);
                if (tmp.Action == CardDragDropAction.Add)
                    AddOrLoadCards(dtNewCards, tmp.Description, tmp.CardListIDs,  AddOrLoad.Add);
                else
                    AddOrLoadCards(dtNewCards, tmp.Description, tmp.CardListIDs, AddOrLoad.Load);
            }
        }
コード例 #22
0
        /// <summary>
        /// Refreshes all the loaded cards without getting the from the DB
        /// </summary>
        /// <param name="fromDB"></param>
        public void RefreshCards(bool fromDB)
        {
            listView.Items.Clear();

            if (fromDB && Cards.Rows.Count > 0)
            {
                try
                {
                    LanguageData dataLayer = new LanguageData();
                    _cards = dataLayer.GetCardsByIDs(_cards.GetIDList());
                }
                catch (FileNotFoundException e)
                {
                    //TODO send a message here that the main form will pick up and display on the bottom
                }
            }

            foreach (dsLanguageData.CardRow row in Cards)
            {
                listView.Items.Add(new IDListViewItem(row.ID, getDisplayText(row)));
            }

            listView.Refresh();
        }
コード例 #23
0
        /// <summary>
        /// Download and save images for a group of cards by matching images with the answer text.         
        /// </summary>
        /// <param name="cards"></param>
        public void DownloadAndSaveImagesForCards(dsLanguageData.CardDataTable cards)
        {
            //If it is already working.
            if (_WTIM_GetForCards != null && _WTIM_GetForCards.IsWorking)
            {
                return;
            }

            List<WebImageSearchItem> searchItems = new List<WebImageSearchItem>();
            LanguageData dataLayer = new LanguageData();
            foreach (dsLanguageData.CardRow card in cards)
            {
                if (!dataLayer.CardHasPicture(card.ID))
                    searchItems.Add(new WebImageSearchItem(card.ID, card.Answer));
            }

            progressBar.Maximum = searchItems.Count;
            progressBar.Step = 1;
            progressBar.Value = 0;

            if (searchItems.Count > 0)
            {
                lblStatus.Text = "Downloading... Please Wait...";
            }
            else
            {
                lblStatus.Text = "All done. No need to get any pictures";

                LoadImagesForCards(cards);

                return;
            }

            LoadingPanelIsVisible = true;
            loadingSmallPictureBox.Visible = true;

            errors = new List<ImageRecievedCallbackItem>();

            _WTIM_GetForCards = WebImage.ProcessImageBatchWithThreadPool(searchItems, wTIM_GetForSelectedCardsCallback, 5);
        }
コード例 #24
0
ファイル: GetImages.cs プロジェクト: eneifert/LanguageLearner
 private void btnSavePicture_Click(object sender, EventArgs e)
 {
     LanguageData dataLayer = new LanguageData();
     if (_curCard != null && cardPreviewPictureBox.Image != null && dataLayer.ImageToByteArray(cardPreviewPictureBox.Image).Length > 0)
         dataLayer.InsertUpdatePicture(cardPreviewPictureBox.Image, _curCard.ID, _curCard.Answer);
 }
コード例 #25
0
        /// <summary>
        /// Saves the card.
        /// </summary>
        /// <returns></returns>
        public bool SaveCard()
        {
            if (_curCard == null)
                return false;

            writeDataToCard(_curCard);

            LanguageData dataLayer = new LanguageData();
            int i = dataLayer.InsertOrUpdateCard(_curCard);

            writeSoundDataToSoundClip(_curSoundClip);

            i += dataLayer.InsertUpdateOrDeleteSoundClip(_curSoundClip);

            i += dataLayer.InsertUpdateOrDeleteImage(pictureBox.Image, _curCard.ID, _curCard.Answer);

            if(CardDataChanged != null)
                CardDataChanged(this, new CardChangedEventArgs(_curCard, _curSoundClip));

            if(i > 0)
                return true;
            return false;
        }
コード例 #26
0
 void deleteCard(dsLanguageData.CardRow card)
 {
     LanguageData dataLayer = new LanguageData();
     dataLayer.DeleteCard(card.ID);
     ClearCard();
 }
コード例 #27
0
        public int ImportFromNewDB(string conString, bool importMarks)
        {
            //Open the other DB
            if (conString == ConnectionString || !conString.EndsWith("s3db"))
                throw new InvalidDataException("Invalid Database");

            int affectedRows = 0;
            LanguageData otherDBLayer = new LanguageData(conString);
            Dictionary<int, int> cardIDHashTable = new Dictionary<int, int>();

            int totalRows = int.Parse(otherDBLayer.daCard.Count().ToString());
            totalRows += int.Parse(otherDBLayer.daCardList.Count().ToString());
            totalRows += int.Parse(otherDBLayer.daCollection.Count().ToString());
            totalRows += int.Parse(otherDBLayer.daDictionary.Count().ToString());

            int progress = 0;

            //Import the Cards
            foreach (dsLanguageData.CardRow otherCard in otherDBLayer.daCard.GetData())
            {
                progress++;

                //Check for dups
                dsLanguageData.CardDataTable dtCard = daCard.GetDataByCardInfo(otherCard.Question, otherCard.Answer);
                if (dtCard.Rows.Count > 0)
                {
                    //Don't insert it, just add the ID to the Dictionary
                    cardIDHashTable.Add(otherCard.ID, dtCard[0].ID);
                    DataImported(new DataImportedEventArgs(true, string.Format("Skipped Card: {0}", otherCard.Answer), progress, totalRows));
                }
                else
                {
                    //insert the card and add the ID to the Dictionary
                    dsLanguageData.CardRow tmpCard = dsLanguageData.CardDataTable.CloneRow(otherCard, new dsLanguageData.CardDataTable());
                    tmpCard.ID = -1;

                    if (!importMarks)
                    {
                        tmpCard.ClearMarks();
                    }

                    affectedRows += InsertOrUpdateCard(tmpCard);
                    cardIDHashTable.Add(otherCard.ID, tmpCard.ID);
                    DataImported(new DataImportedEventArgs(true, string.Format("Added Card: {0}", tmpCard.Answer), progress, totalRows));

                    //insert the soundfile
                    if (otherDBLayer.CardHasSound(otherCard.ID))
                    {
                        dsLanguageData.SoundClipRow otherSoundRow = otherDBLayer.daSoundClip.GetDataByCardID(otherCard.ID)[0];
                        dsLanguageData.SoundClipRow tmpSound = dsLanguageData.SoundClipDataTable.CloneRow(otherSoundRow);
                        tmpSound.ID = -1;

                        affectedRows += InsertUpdateOrDeleteSoundClip(tmpSound);
                    }

                    //insert the picture
                    if (otherDBLayer.CardHasPicture(otherCard.ID))
                    {
                        dsLanguageData.PictureRow otherPicRow = otherDBLayer.daPicture.GetDataByCardID(otherCard.ID)[0];
                        affectedRows += InsertUpdatePicture(ByteArrayToImage(otherPicRow.Image), tmpCard.ID, otherPicRow.SearchText);
                    }
                }
            }//end foreach

            //Collection
            Dictionary<int, int> collectionHashTable = new Dictionary<int, int>();
            foreach (dsLanguageData.CollectionRow otherCollection in otherDBLayer.daCollection.GetData())
            {
                progress++;

                //check for dups
                if (daCollection.GetDataByName(otherCollection.Name).Rows.Count > 0)
                {
                    collectionHashTable.Add(otherCollection.ID, daCollection.GetDataByName(otherCollection.Name)[0].ID);
                    DataImported(new DataImportedEventArgs(true, string.Format("Skipped Collection: {0}", otherCollection.Name), progress, totalRows));
                }
                else
                {
                    //Insert the new collection
                    dsLanguageData.CollectionRow tmpCollection = dsLanguageData.CollectionDataTable.CloneRow(otherCollection);
                    tmpCollection.ID = -1;

                    affectedRows += InsertCollection(tmpCollection);
                    collectionHashTable.Add(otherCollection.ID, tmpCollection.ID);
                    DataImported(new DataImportedEventArgs(true, string.Format("Added Collection: {0}", tmpCollection.Name), progress, totalRows));
                }
            }

            //CardList
            Dictionary<int, int> cardListHashTable = new Dictionary<int, int>();
            foreach (dsLanguageData.CardListRow otherCardList in otherDBLayer.daCardList.GetData())
            {
                progress++;

                //Check for dups
                if (daCardList.GetDataByName(otherCardList.Name).Rows.Count > 0)
                {
                    cardListHashTable.Add(otherCardList.ID, daCardList.GetDataByName(otherCardList.Name)[0].ID);
                    DataImported(new DataImportedEventArgs(true, string.Format("Skipped CardList: {0}", otherCardList.Name), progress, totalRows));
                }
                else
                {
                    //insert the new list
                    dsLanguageData.CardListRow tmpCardList = dsLanguageData.CardListDataTable.CloneRow(otherCardList);
                    tmpCardList.ID = -1;
                    tmpCardList.CollectionID = collectionHashTable[otherCardList.CollectionID];

                    affectedRows += InsertCardList(tmpCardList);
                    cardListHashTable.Add(otherCardList.ID, tmpCardList.ID);
                    DataImported(new DataImportedEventArgs(true, string.Format("Added CardList: {0}", tmpCardList.Name), progress, totalRows));
                }

                //CardListData
                foreach (dsLanguageData.CardListDataRow otherCardListData in otherDBLayer.daCardListData.GetDataByCardListID(otherCardList.ID))
                {
                    //If there if it is not already there
                    if (daCardListData.GetDataByIDs(cardListHashTable[otherCardList.ID], cardIDHashTable[otherCardListData.CardID]).Rows.Count < 1)
                    {
                        //add the cardID to the list
                        affectedRows += InsertCardListDataItem(cardListHashTable[otherCardList.ID], cardIDHashTable[otherCardListData.CardID]);
                    }
                }//end foreach

            }//end foreach

            //Dictionry
            foreach (dsLanguageData.DictionaryRow otherDictionary in otherDBLayer.daDictionary.GetData())
            {
                progress++;

                //if it is not a duplicate
                if (daDictionary.GetDataByName(otherDictionary.Name).Rows.Count < 1)
                {
                    //insert it
                    dsLanguageData.DictionaryRow tmpDictionary = dsLanguageData.DictionaryDataTable.CloneRow(otherDictionary);
                    tmpDictionary.ID = -1;

                    affectedRows += InsertOrUpdateDictionary(tmpDictionary);
                    DataImported(new DataImportedEventArgs(true, string.Format("Added Dictionary: {0}", tmpDictionary.Name), progress, totalRows));
                }
                else
                {
                    DataImported(new DataImportedEventArgs(true, string.Format("Skipped Dictionary: {0}", otherDictionary.Name), progress, totalRows));
                }
            }

            return affectedRows;
        }
コード例 #28
0
        bool hasChanges()
        {
            if(_curCard == null)
                return false;

            bool hasChanges = false;

            try
            {
                LanguageData dataLayer = new LanguageData();
                dsLanguageData.CardRow tmpCard = dataLayer.daCard.GetDataByCardID(_curCard.ID).Rows[0] as dsLanguageData.CardRow;
                dsLanguageData.SoundClipDataTable tmpDTSound = dataLayer.daSoundClip.GetDataByCardID(_curCard.ID);
                dsLanguageData.SoundClipRow tmpSoundClip = null;
                if (tmpDTSound.Rows.Count > 0)
                    tmpSoundClip = tmpDTSound[0];

                if (tmpCard.Question.Trim() != getQuestionText())
                    hasChanges = true;
                if (!_informationWasShown)
                    ShowInformation();
                if (tmpCard.Answer.Trim() != getAnswerText())
                    hasChanges = true;
                if (tmpCard.Notes.Trim() != txtNotes.Text.Trim())
                    hasChanges = true;
                if (tmpCard.Difficulty != Difficulty)
                    hasChanges = true;

                //if the sound clips are not null check to see if the match
                if (tmpSoundClip != null && _curSoundClip != null)
                {
                    if (tmpSoundClip.SoundClip.Length != _curSoundClip.SoundClip.Length)
                        hasChanges = true;
                }
                else if (tmpSoundClip != _curSoundClip)
                    hasChanges = true;

            }
            catch (IndexOutOfRangeException)
            {
                hasChanges = true;
            }
            catch (RowNotInTableException)
            {
                ClearCard();
                hasChanges = false;
            }

            return hasChanges;
        }
コード例 #29
0
 /// <summary>
 /// Deletes the current card. And clears the data from the screen.
 /// </summary>
 public void DeleteCard()
 {
     if (_curCard != null && _curCard.ID > 0)
     {
         int id = _curCard.ID;
         LanguageData dataLayer = new LanguageData();
         if (dataLayer.DeleteCard(_curCard.ID) > 0)
         {
             if (CardWasDeleted != null)
                 CardWasDeleted(this, id);
         }
     }
     ClearCard();
 }
コード例 #30
0
        void wTIM_GetForSelectedCardsCallback(ImageRecievedCallbackItem imageItem)
        {
            if (imageItem.Success)
            {
                //Save the image
                LanguageData dataLayer = new LanguageData();
                dataLayer.InsertUpdatePicture(imageItem.Images[0], imageItem.SearchItem.ID, imageItem.SearchItem.SearchText);
            }
            else
            {
                //Handle the error
                errors.Add(imageItem);
            }

            //update the screen
            this.Invoke(new UpdateAfterImageDownloadedAndSavedCallback(updateAfterImageDownloadedAndSaved), new object[] { imageItem });
        }