Interaction logic for ListButton.xaml
상속: System.Windows.Controls.UserControl, IComparable
        private void PageSelected(ListButton lb)
        {
            StopSlideshow();

            SelectPage(lb);
        }
        private void SelectPage(ListButton lb)
        {
            foreach (var olb in Pages)
            {
                if (olb == lb) olb.IsSelected = true;
                else olb.IsSelected = false;
            }

            foreach (var category in SubCategories)
            {
                var config = category.PluginConfigurations.Find(x => GetPluginName(x.Name) == GetPluginName(lb.Text));
                if (config != null)
                {
                    currentPage = config;
                    break;
                }
            }

            // Set Page as PageContent
            PageContent = lb.DataObject as UserControl;

            // Save selected page
            int index = Pages.ToList().FindIndex(x => x == lb);
            if (index >= 0)
            {
                Properties.Settings.Default.DashboardSelectedPage = index;
                Properties.Settings.Default.Save();
            }

            // Load Saved Zoom Level
            ZoomLevel = MainWindow.LoadSavedPageZoomValue(lb.DataObject as IPage);
        }
        public void Plugins_Load(PluginConfiguration config)
        {
            if (Plugins != null)
            {
                if (!enabledPlugins.Contains(config))
                {
                    IClientPlugin plugin = Plugins.Find(x => x.Title.ToUpper() == config.Name.ToUpper());
                    if (plugin != null)
                    {
                        try
                        {
                            plugin.SubCategories = config.SubCategories;
                            plugin.SendData += Plugin_SendData;

                            plugin.Initialize();
                        }
                        catch { }

                        var bt = new ListButton();
                        if (plugin.Image != null) bt.Image = new BitmapImage(plugin.Image);
                        bt.Text = plugin.Title;
                        bt.Selected += PageSelected;
                        bt.DataObject = plugin;
                        Pages.Add(bt);

                        SortPageList();

                        enabledPlugins.Add(config);
                    }
                }
            }
        }
        private void ListButton_Selected(ListButton LB)
        {
            foreach (ListButton oLB in Pages)
            {
                if (oLB == LB) oLB.IsSelected = true;
                else oLB.IsSelected = false;
            }

            var page = LB.DataObject as IPage;
            PageContent = page;
        }
        public void AddPage(IPage page)
        {
            var lb = new ListButton();

            // Bind ListButton.Text to PageName property
            var pageImageBinding = new Binding();
            pageImageBinding.Source = page;
            pageImageBinding.Path = new PropertyPath("Image");
            BindingOperations.SetBinding(lb, ListButton.ImageProperty, pageImageBinding);

            // Bind ListButton.Text to PageName property
            var pageTitleBinding = new Binding();
            pageTitleBinding.Source = page;
            pageTitleBinding.Path = new PropertyPath("Title");
            BindingOperations.SetBinding(lb, ListButton.TextProperty, pageTitleBinding);

            lb.Selected += ListButton_Selected;
            lb.DataObject = page;

            Pages.Add(lb);
        }
        void Page_Selected(ListButton lb)
        {
            if (lb.DataObject != null)
            {
                var info = (IConfigurationInfo)lb.DataObject;

                var page = ConfigurationPages.Find(x => x.Title == info.Title);
                if (page == null)
                {
                    page = CreatePage(info);
                    page.SendData += page_SendData;
                    page.SettingChanged += page_SettingChanged;

                    page.GetSentData(GetProbeHeader());
                    page.GetSentData(GetProbeDataItems());
                    page.GetSentData(CreateCurrentUserEventData());

                    ConfigurationPages.Add(page);
                }

                LoadPage(page);

                foreach (ListButton olb in PageList.ToList()) if (olb != lb) olb.IsSelected = false;
                lb.IsSelected = true;

                CurrentPage = page;
            }
        }
        void AddPageButton(IConfigurationInfo info)
        {
            var bt = new ListButton();
            bt.Text = info.Title;

            if (info.Image != null) bt.Image = new BitmapImage(info.Image);
            else bt.Image = new BitmapImage(new Uri("pack://application:,,,/TrakHound_Dashboard.Pages.DeviceManager;component/Resources/Plug_01.png"));

            bt.Selected += Page_Selected;
            bt.DataObject = info;

            if (info.Title == "Description") Page_Selected(bt);

            PageList.Add(bt);
            PageList.Sort();
        }