예제 #1
0
        private void Model_PropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            switch (e.PropertyName)
            {
            case "GetDataGridTermTranslationList":
                DataGridTermTranslationList = Model.TermTranslationList;
                DataGridItemList.Clear();
                DataGridTermList.Clear();
                DataGridTranslationList.Clear();
                StringSlicer();
                for (int i = 0; i < DataGridTermList.Count; i++)
                {
                    if (DataGridTermList[i].Length != 0)
                    {
                        DataGridItem dgi = new DataGridItem {
                            Term = DataGridTermList[i].Remove(DataGridTermList[i].Length - 1), Translation = DataGridTranslationList[i]
                        };
                        DataGridItemList.Add(dgi);
                    }
                }
                NotifyPropertyChanged();
                break;

            case "GetTermTranslationList":
                DataGridTermTranslationList = Model.TermTranslationList;
                DataGridItemList.Clear();
                DataGridTermList.Clear();
                DataGridTranslationList.Clear();
                StringSlicer();
                for (int i = 0; i < DataGridTermList.Count; i++)
                {
                    if (DataGridTermList[i].Length != 0)
                    {
                        DataGridItem dgi = new DataGridItem {
                            Term = DataGridTermList[i].Remove(DataGridTermList[i].Length - 1), Translation = DataGridTranslationList[i]
                        };
                        DataGridItemList.Add(dgi);
                    }
                }
                NotifyPropertyChanged();
                break;

            case "IsTestOn":
                if (Model.IsTestOn)
                {
                    if (StaticConfigProvider.IsTestOpenFirstly)
                    {
                        openWindowService.CreateTestWindow();
                    }
                }
                break;
            }
        }
예제 #2
0
 public void StringSlicer()
 {
     foreach (string str in DataGridTermTranslationList)
     {
         int index = str.IndexOf(" - ");
         if (index != -1)
         {
             int translationLength = str.Length - 2 - index;
             DataGridTermList.Add(str.Substring(0, index + 2));
             DataGridTranslationList.Add(str.Substring(index + 2, translationLength));
         }
         else
         {
             int secondIndex       = str.IndexOf("-");
             int translationLength = str.Length - 1 - secondIndex;
             DataGridTermList.Add(str.Substring(0, secondIndex + 1));
             DataGridTranslationList.Add(str.Substring(secondIndex + 1, translationLength));
         }
     }
 }