Interaction logic for ChatsControl.xaml
Inheritance: System.Windows.Controls.UserControl
Ejemplo n.º 1
0
        public void Initialize(Controls.ChatsControl ChatsControl, string LayoutStore)
        {
            ChatConfigStorage.Load(LayoutStore);

            foreach (string file in Directory.GetFiles(App.RootFolder + "/Chats/", "*.dll"))
            {
                try {
                    Assembly a = Assembly.LoadFile(file);
                    foreach (Type t in a.GetTypes())
                    {
                        Type iface = t.GetInterface("RatChat.Core.IChatSource");
                        if (iface != null)
                        {
                            var v = RatChat.Core.ChatNameAttribute.GetAttribute(t);
                            if (v != null)
                            {
                                Sources[v.Name] = t;
                            }
                            else
                            {
                                //Sources[Path.GetFileNameWithoutExtension(file)] = t;
                            }
                        }
                    }
                } catch {
                    //////
                }
            }

            RestoreChats(ChatsControl);
        }
Ejemplo n.º 2
0
        public void StoreChats(Controls.ChatsControl ChatsControl)
        {
            StringBuilder sb = new StringBuilder();

            for (int j = 0; j < Chats.Count; ++j)
            {
                var data = Chats[j].Tag as Tuple <RatChat.Core.IChatSource, string>;

                sb.AppendFormat(
                    CultureInfo.InvariantCulture,
                    "|{0}={1}={2}",
                    data.Item2,
                    data.Item1.ConfigPrefix,
                    ChatsControl.GetChatHeightByIndex(j));
            }
            ChatConfigStorage["ChatManager.UberChatList"] = sb.ToString();
        }
Ejemplo n.º 3
0
        public void RestoreChats(Controls.ChatsControl ChatsControl)
        {
            string Settings = ChatConfigStorage.GetDefault("ChatManager.UberChatList", "");

            if (string.IsNullOrEmpty(Settings))
            {
                return;
            }

            string[] chats = Settings.Split(new string[] { "|" }, StringSplitOptions.RemoveEmptyEntries);

            for (int j = 0; j < chats.Length; ++j)
            {
                string[] vals = chats[j].Split('=');
                CreateChat(vals[1], vals[0]);

                if (vals.Length > 2)
                {
                    ChatsControl.SetChatHeightByIndex(j, double.Parse(vals[2], CultureInfo.InvariantCulture));
                }
            }
        }