예제 #1
0
 private void Refresh()
 {
     TextBox1.Text = string.Empty;
     lianduis = Lianduis.LoadFromFile("Lianduis.xml");
     System.Diagnostics.Debug.WriteLine("Load: " + lianduis.Liandui.Count);
     DataGrid1.DataContext = lianduis;
     WordCount.Content = lianduis.Liandui.Count.ToString(NUMBER_FORMAT) + " found";
     SaveButton.IsEnabled = true;
 }
예제 #2
0
        public void NullAttribuiteSaveToFileTest()
        {
            Lianduis target = new Lianduis();
            Liandui liandui = new Liandui();
            //liandui.Prefix = 1;
            //liandui.Type = HLGranite.Type.n;
            liandui.Value = "7435ewrew";
            target.Liandui.Add(liandui);

            string fileName = "Lianduis.xml";
            target.SaveToFile(fileName);
        }
예제 #3
0
 public static bool LoadFromFile(string fileName, out Lianduis obj)
 {
     System.Exception exception = null;
     return LoadFromFile(fileName, out obj, out exception);
 }
예제 #4
0
 /// <summary>
 /// Deserializes xml markup from file into an Lianduis object
 /// </summary>
 /// <param name="fileName">string xml file to load and deserialize</param>
 /// <param name="obj">Output Lianduis object</param>
 /// <param name="exception">output Exception value if deserialize failed</param>
 /// <returns>true if this XmlSerializer can deserialize the object; otherwise, false</returns>
 public static bool LoadFromFile(string fileName, out Lianduis obj, out System.Exception exception)
 {
     exception = null;
     obj = default(Lianduis);
     try
     {
         obj = LoadFromFile(fileName);
         return true;
     }
     catch (System.Exception ex)
     {
         exception = ex;
         return false;
     }
 }
예제 #5
0
 public static bool Deserialize(string xml, out Lianduis obj)
 {
     System.Exception exception = null;
     return Deserialize(xml, out obj, out exception);
 }
예제 #6
0
 /// <summary>
 /// Deserializes workflow markup into an Lianduis object
 /// </summary>
 /// <param name="xml">string workflow markup to deserialize</param>
 /// <param name="obj">Output Lianduis object</param>
 /// <param name="exception">output Exception value if deserialize failed</param>
 /// <returns>true if this XmlSerializer can deserialize the object; otherwise, false</returns>
 public static bool Deserialize(string xml, out Lianduis obj, out System.Exception exception)
 {
     exception = null;
     obj = default(Lianduis);
     try
     {
         obj = Deserialize(xml);
         return true;
     }
     catch (System.Exception ex)
     {
         exception = ex;
         return false;
     }
 }
예제 #7
0
        /// <summary>
        /// Search liandui entry by given keyword.
        /// </summary>
        /// <remarks>
        /// Keyword can be in one character or a long string.
        /// </remarks>
        /// <param name="keyword"></param>
        /// <param name="isFirstCharacter">True if only match first character otherwise false.</param>
        /// <returns></returns>
        private Lianduis Search(string keyword, bool isFirstCharacter)
        {
            //counter = 0;//reset
            char[] keys = keyword.ToCharArray();
            Lianduis merge = new Lianduis();
            foreach (char key in keys)
            {
                //why linq union fail?
                //hack: merge.Liandui.Union(Search(key, isFirstCharacter).Liandui);
                //merge.Liandui.Union(from l in Search(key, isFirstCharacter).Liandui select l);
                foreach (Liandui liandui in Search(key, isFirstCharacter).Liandui)
                {
                    if (!merge.Liandui.Contains(liandui)) merge.Liandui.Add(liandui);
                }
            }

            //System.Diagnostics.Debug.Write("run " + counter);
            return merge;
        }
예제 #8
0
 private void SearchButton_Click(object sender, RoutedEventArgs e)
 {
     //todo: highlight the match text.
     if (TextBox1.Text.Trim().Length > 0)
     {
         bool isFirst = (FirstRadio.IsChecked == true) ? true : false;
         lianduis = Search(TextBox1.Text.Trim(), isFirst);
         DataGrid1.DataContext = lianduis;
         WordCount.Content = lianduis.Liandui.Count.ToString(NUMBER_FORMAT) + " found";
         SaveButton.IsEnabled = false;
     }
     else
         Refresh();
 }