コード例 #1
0
 private static IRecord CreateRecord(object item, System.Collections.Generic.IList <string> aliases)
 {
     System.Collections.ICollection collection = item as System.Collections.ICollection;
     if (collection != null)
     {
         System.Collections.Generic.List <object> list = collection.Cast <object>().ToList <object>();
         if (aliases != null && aliases.Count != list.Count)
         {
             aliases = null;
         }
         if (list.Count != 1)
         {
             int counter             = 0;
             DictionaryRecord record = new DictionaryRecord();
             list.ForEach(delegate(object obj)
             {
                 record.SetValue((aliases != null) ? aliases[counter++] : ("Value" + ++counter), obj);
             });
             return(record);
         }
         if (aliases != null)
         {
             aliases[0] = Pluralizer.ToSingular(aliases[0]);
         }
         item = list[0];
     }
     if (aliases == null || aliases.Count != 1)
     {
         return(RecordBase.CreateRecord(item));
     }
     return(RecordBase.CreateRecord(item, aliases[0]));
 }
コード例 #2
0
 public TextToSpeech(DictionaryRecord r) : base()
 {
     FrameworkDispatcher.Update(); // initialize XNA (required)
     SpeakCompleted += new EventHandler<BingTranslator.SpeakCompletedEventArgs>(TextToSpeech_SpeakCompleted);
     store = IsolatedStorageFile.GetUserStoreForApplication();
     record = r;
 }
コード例 #3
0
 private bool ExistDictionaryRecord(DictionaryRecord dictionaryRecord)
 {
     return(_unitOfWork.DictionaryRecords.Get(c => c.UserId == dictionaryRecord.UserId &&
                                              c.WordName == dictionaryRecord.WordName &&
                                              c.Translation == dictionaryRecord.Translation &&
                                              c.LanguageName == dictionaryRecord.LanguageName) != null);
 }
コード例 #4
0
        public void UpdateDictionaryRecord(int id, DictionaryRecord dictionaryRecordUpdate)
        {
            DictionaryRecord dictionaryRecord = _unitOfWork.DictionaryRecords.Get(id);

            dictionaryRecord.Translation = dictionaryRecordUpdate.Translation;
            _unitOfWork.DictionaryRecords.Update(dictionaryRecord);
            _unitOfWork.Save();
        }
コード例 #5
0
        public void AddDictionaryRecord(DictionaryRecord dictionaryRecord)
        {
            AddWord(dictionaryRecord.WordName);

            if (!ExistDictionaryRecord(dictionaryRecord))
            {
                _unitOfWork.DictionaryRecords.Create(dictionaryRecord);
                _unitOfWork.Save();
            }
        }
コード例 #6
0
        public void DeleteDictionaryRecord(int id)
        {
            DictionaryRecord dictionaryRecord = _unitOfWork.DictionaryRecords.Get(id);

            if (dictionaryRecord == null)
            {
                return;
            }

            _unitOfWork.DictionaryRecords.Delete(dictionaryRecord);
            _unitOfWork.Save();
        }
コード例 #7
0
 /// <summary>
 /// Fill in CSPro dictionary record a record specification
 /// </summary>
 /// <param name="dictRecord">Empty CSPro DictionaryRecord to fill in</param>
 /// <param name="recordName">Name to use for record</param>
 /// <param name="recSpec">RecordSpecification for the record to be generated</param>
 /// <param name="dbColumns">List of database columns to include the generated record</param>
 /// <param name="valueSetRetriever">Utility class to get value sets for generated dictionary items</param>
 private void CreateRecord(DictionaryRecord dictRecord, string recordName, RecordSpec recSpec, IEnumerable <DatabaseColumn> dbColumns, ValueSetRetriever valueSetRetriever)
 {
     dictRecord.Label      = recSpec.Name;
     dictRecord.Name       = recordName;
     dictRecord.RecordType = recSpec.Type.ToString();
     dictRecord.Note       = String.Format("#table {0}", recSpec.DatabaseTable.FullName);
     foreach (var dbCol in dbColumns)
     {
         string itemName = MakeName(dbCol.Name, "_" + dictRecord.Name);
         CreateItem(dictRecord.AddItem(), itemName, dbCol, valueSetRetriever);
     }
 }
コード例 #8
0
        public void UpdateDictionaryRecord(DictionaryRecord record)
        {
            var dictDef = DbEditorService.GetDictionary(record.DictionaryId);

            if (dictDef.DictionaryType == DAL.Models.DictionaryType.Int)
            {
                DbDictionaryCache.UpdateDictionaryRecord(dictDef, Convert.ToInt32(record.Key), record.Description);
            }
            else
            {
                DbDictionaryCache.UpdateDictionaryRecord(dictDef, record.Key, record.Description);
            }
        }
コード例 #9
0
        public async Task <IActionResult> GetDictionaryRecord([FromRoute] int id)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            DictionaryRecord dictionaryRecord = _dictionaryService.GetDictionaryRecord(id);

            if (dictionaryRecord == null)
            {
                return(NotFound());
            }

            return(Ok(_mapper.Map <DictionaryRecordViewDTO>(dictionaryRecord)));
        }
コード例 #10
0
        public async Task <IActionResult> PutDictionaryRecord([FromRoute] int id, [FromBody] DictionaryRecordCreatingDTO dictionaryRecordCreatingDTO)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            try
            {
                DictionaryRecord dictionaryRecord = _mapper.Map <DictionaryRecord>(dictionaryRecordCreatingDTO);
                await Task.Run(() => _dictionaryService.UpdateDictionaryRecord(id, dictionaryRecord));
            }
            catch (ArgumentException ex)
            {
                return(BadRequest(ex.Message));
            }

            return(Ok());
        }
コード例 #11
0
        public void Colorize(TextBlock textBlock, DictionaryRecord record, PinyinColorScheme selected)
        {
            if (selected == PinyinColorScheme.None)
            {
                textBlock.Text = record.Chinese.Pinyin;
                return;
            }
            
            PinyinColorPalette colors = options[selected];
            textBlock.Text = "";
            bool first = true;

            foreach (Chinese.Character c in record.Chinese.Characters)
            {
                Run run = new Run();
                run.Text = first ? c.Pinyin.MarkedUp : " " + c.Pinyin.MarkedUp;
                Color color = colors[c.Pinyin.Tone];
                if (color != Colors.Black) // black is special
                    run.Foreground = new SolidColorBrush(color);
                textBlock.Inlines.Add(run);
                first = false;
            }
        }
コード例 #12
0
 /// <summary>
 /// Create a character array with capacity to hold all data items in record
 /// </summary>
 /// <param name="record">CSPro dictionary record</param>
 /// <returns>Character array long enough for the record</returns>
 private static char[] CreateLineBuffer(DictionaryRecord record)
 {
     return(Enumerable.Repeat(' ', record.Length).ToArray());
 }
コード例 #13
0
 void Search(DictionaryRecord record)
 {
     Query.Text = record.Chinese.Simplified;
     TriggerSearch(Query.Text, 30);
 }
コード例 #14
0
ファイル: DictionaryCache.cs プロジェクト: DCT-UA/Monator
        public bool Put(string key, object entity, DateTime expired)
        {
            var record = new DictionaryRecord(entity, expired);

            return(Cache.AddOrUpdate(key, record, (k, o) => record) == record);
        }
コード例 #15
0
 void Decompose(DictionaryRecord record)
 {
     List<DictionaryRecord> results = new List<DictionaryRecord>();
     results.Add(record);
     foreach (Chinese.Character c in record.Chinese.Characters)
         results.AddRange(s.Search(c.Simplified.ToString(), 100));
     Query.Text = record.Chinese.Simplified + " (split)";
     prev[Results.Name] = -1; // override expansion marker
     Status.Visibility = Visibility.Collapsed;
     App.ViewModel.LoadData(results);
     Results.ScrollIntoView(Results.Items[0]);
 }
コード例 #16
0
 private void AddToListButton_Click(object sender, RoutedEventArgs e)
 {
     Button button = (Button)sender;
     int i = int.Parse(button.Tag.ToString());
     DictionaryRecord record = d[i];
     App app = (App)Application.Current;
     switch (app.ListManager.CountWriteable)
     {
         case 0:
             MessageBox.Show("You need to create a list before you can save items to it.");
             return;
         case 1:
             DictionaryRecordList list = app.ListManager.DefaultList();
             list.Add(record);
             app.Transition = App.TransitionType.PostAdd;
             app.TransitionData = record;
             OpenList(list.Name);
             break;
         default:
             RecordToAdd = record;
             pivot.SelectedIndex = pivot.Items.IndexOf(ListsPane);
             break;
     }
 }
コード例 #17
0
        private void ListListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            ListBox list = (ListBox)sender;
            int item = list.SelectedIndex;
            list.SelectedIndex = -1; // reset
            if (item == -1)
                return;

            ListViewModel lvm = (ListViewModel)ListsPane.DataContext;
            if (lvm.EditInProgress) // don't open lists while adding/renaming
                return;

            ListItemViewModel ivm = (ListItemViewModel)list.Items[item];
            if (RecordToAdd != null) // user is selecting a target list to add an entry
            {
                App app = (App)Application.Current;
                DictionaryRecordList target = app.ListManager[ivm.Name];
                if (target.IsDeleted)
                    return; // can't add items to a deleted list
                target.Add(RecordToAdd);
                app.Transition = App.TransitionType.PostAdd;
                app.TransitionData = RecordToAdd;
                RecordToAdd = null; // come out of add-to-list mode
                LoadLists();
            }

            lvm.AddInProgress = false;
            OpenList(ivm.Name);
        }
コード例 #18
0
 private static IRecord CreateRecord(object item, System.Collections.Generic.IList<string> aliases)
 {
     System.Collections.ICollection collection = item as System.Collections.ICollection;
     if (collection != null)
     {
         System.Collections.Generic.List<object> list = collection.Cast<object>().ToList<object>();
         if (aliases != null && aliases.Count != list.Count)
         {
             aliases = null;
         }
         if (list.Count != 1)
         {
             int counter = 0;
             DictionaryRecord record = new DictionaryRecord();
             list.ForEach(delegate(object obj)
             {
                 record.SetValue((aliases != null) ? aliases[counter++] : ("Value" + ++counter), obj);
             });
             return record;
         }
         if (aliases != null)
         {
             aliases[0] = Pluralizer.ToSingular(aliases[0]);
         }
         item = list[0];
     }
     if (aliases == null || aliases.Count != 1)
     {
         return RecordBase.CreateRecord(item);
     }
     return RecordBase.CreateRecord(item, aliases[0]);
 }
コード例 #19
0
        public DictionaryRecord GetDictionaryRecord(int id)
        {
            DictionaryRecord dictionaryRecord = _unitOfWork.DictionaryRecords.Get(id);

            return(dictionaryRecord);
        }
コード例 #20
0
 /// <summary>
 /// Insert record type in appropriate location in buffer
 /// </summary>
 /// <param name="lineBuffer">Buffer in which to write record type</param>
 /// <param name="dictionary">CSPro dictionary</param>
 /// <param name="record">CSPro dictionary record</param>
 static void CopyRecordType(char[] lineBuffer, DataDictionary dictionary, DictionaryRecord record)
 {
     record.RecordType.CopyTo(0, lineBuffer, dictionary.RecordTypeStart - 1, dictionary.RecordTypeLength);
 }
コード例 #21
0
 public Response UpdateDictionaryRecord(DictionaryRecord record)
 {
     return(GetResponse(() => new TicketService(User).UpdateDictionaryRecord(record)));
 }