コード例 #1
0
ファイル: DB.cs プロジェクト: mbmdm/PersonalDictionary
        private void Init_Progress()
        {
            var root = xdoc.Element(root_xml_name).Element(xml_traing_progress_applest_name);

            foreach (var e in root.Elements())
            {
                AppletData app_info = new AppletData();
                {
                    app_info.AppletID      = e.Attribute("uid").Value.ToString();
                    app_info.AppletDisplay = e.Attribute("display").Value.ToString();
                    app_info.WordProgress  = new Dictionary <Word, int>();

                    foreach (var e_ in e.Elements())
                    {
                        int  id       = int.Parse(e_.Attribute("ref").Value.ToString());
                        Word w        = GetWord(id);
                        int  progress = int.Parse(e_.Attribute("progress").Value.ToString());

                        if (w != null)
                        {
                            app_info.WordProgress.Add(w, progress);
                        }
                        else
                        {
                            throw new Exception("Some exception in PersonalDictionary.DB.Init_Progress(). Check invariant of xml data");
                        }
                    }
                };

                ApplestsData.Add(app_info);
            }
        }
コード例 #2
0
ファイル: DB.cs プロジェクト: mbmdm/PersonalDictionary
        internal void RegisterApplet(AppletData applet)
        {
            var root = xdoc.Element(root_xml_name).Element(xml_traing_progress_applest_name);

            XElement xe = new XElement("applet");

            xe.Add(new XAttribute("uid", applet.AppletID));
            xe.Add(new XAttribute("display", applet.AppletDisplay));
            root.Add(xe);
            xdoc.Save(Environment.CurrentDirectory + "\\" + xml_Name);

            Init();
        }
コード例 #3
0
ファイル: App.xaml.cs プロジェクト: mbmdm/PersonalDictionary
        private void AttachApplets()
        {
            string path = Environment.CurrentDirectory;
            path += "\\applets";

            string[] dlls = System.IO.Directory.GetFiles(path, "*.dll");

            if (dlls.Length == 0)
                throw new Exception("Exception in PersonalDictionary.App.xaml.cs.AttachApplets().At list one applet must be in the \\applets\\.. directory");

            foreach (var dll_ka in dlls)
            {
                var asm = Assembly.LoadFrom(dll_ka);

                var types = asm.GetTypes().Where((t, obj) => t.IsClass).ToList();

                foreach (var item in types)
                {
                    IApplet obj = null;
                    try { obj = asm.CreateInstance(item.FullName) as IApplet; }
                    catch { }
                    if (obj != null)
                    {
                        applets.Add(obj.ToType().FullName, obj);

                        //Регистрация апплета в БД для сохранения результатов (прогресса)
                        string applet_uid = asm.ManifestModule.Name.Substring(0, asm.ManifestModule.Name.LastIndexOf('.'));
                        applet_uid += "." + obj.ToType().FullName;

                        if (DB.GetInstance().ApplestsData.Where(app => app.AppletID == applet_uid).ToArray().Length == 0)
                        {
                            AppletData appletData = new AppletData();
                            appletData.AppletID = applet_uid;
                            appletData.AppletDisplay = obj.DisplayName();
                            DB.GetInstance().RegisterApplet(appletData);
                        }
                    }

                }
            }
        }
コード例 #4
0
        private void Ok_btn_Click(object sender, RoutedEventArgs e)
        {
            Settings sets = Settings.Get();
            string   val  = string.Empty;

            List <CheckBox> boxes = new List <CheckBox>();

            foreach (var item in panel1.Children)
            {
                boxes.Add(item as CheckBox);
            }
            foreach (var item in panel2.Children)
            {
                boxes.Add(item as CheckBox);
            }


            foreach (var item in boxes)
            {
                if (item == null)
                {
                    continue;
                }

                CheckBox   ch      = item as CheckBox;
                AppletData appData = ch.Tag as AppletData;

                if (ch.IsChecked == true)
                {
                    val += "#" + appData.AppletID;
                }
            }
            sets[property_name] = val;
            sets.Commit();

            Close();
        }
コード例 #5
0
ファイル: Testing.cs プロジェクト: mbmdm/PersonalDictionary
 public static void RegisterApplet(AppletData data)
 {
     DB.GetInstance().RegisterApplet(data);
 }