Beispiel #1
0
        public TabbedWindow()
        {
            InitializeComponent();



            List <FontHandler> List   = FontHandler.GetFontList();
            List <FontHandler> Cached = List;
            Favorites          favs   = new Favorites();

            this.MouseDown += (s, e) =>
            {
                this.Topmost = true;
            };

            this.MouseEnter += (s, e) =>
            {
                if (IsFavoriteUpdated)
                {
                    UpdateUIList(List);
                    IsFavoriteUpdated = false;
                }
            };
            #region Parsing Favorites
            new Thread(() =>
            {
                FavListWrapper.Dispatcher.Invoke(new Action(delegate()
                {
                    foreach (FontHandler F in List.Where(l => Favorites.FavoriteList.Any(f => f.fontname == l.FontName)).ToList <FontHandler>())
                    {
                        FavListWrapper.Children.Add(GetFontPanel(F));
                    }
                }), DispatcherPriority.Background);
            }).Start();

            #endregion
            #region Parsing All Fonts
            new Thread(() =>
            {
                DispatcherOperation dp = gListWrapper.Dispatcher.BeginInvoke(new Action(delegate()
                {
                    foreach (FontHandler F in List)
                    {
                        gListWrapper.Children.Add(GetFontPanel(F));
                    }
                }), DispatcherPriority.Background);

                dp.Completed += (s, e) =>
                {
                    lblLoading.Dispatcher.Invoke(
                        new Action(delegate()
                    {
                        lblLoading.Visibility = System.Windows.Visibility.Hidden;
                    }),
                        DispatcherPriority.Background);
                };
            }).Start();

            #endregion
            #region Search Text Changed Event
            txtSearch.TextChanged += (s, e) =>
            {
                string T = txtSearch.Text;
                IsProgressBarVisible(true);

                new Thread(() =>
                {
                    DispatcherOperation dp = gListWrapper.Dispatcher.BeginInvoke(new Action(delegate()
                    {
                        if (!string.IsNullOrEmpty(T))
                        {
                            UpdateUIList(UpdateFontList(T, List));
                        }
                        else
                        {
                            UpdateUIList(Cached);
                        }
                    }), DispatcherPriority.Background);

                    dp.Completed += (sender, eventArgs) =>
                    {
                        pbBusy.Dispatcher.Invoke(new Action(delegate()
                        {
                            IsProgressBarVisible(false);
                        }), DispatcherPriority.Background);
                    };
                }).Start();
            };

            #endregion
            #region Search Button Click Event
            btnSearch.Click += (s, e) =>
            {
                string T = txtSearch.Text;
                if (!string.IsNullOrEmpty(T))
                {
                    new Thread(() =>
                    {
                        gListWrapper.Dispatcher.Invoke(new Action(delegate()
                        {
                            UpdateUIList(UpdateFontList(T, List));
                        }), System.Windows.Threading.DispatcherPriority.Background);
                    }).Start();
                }
            };
            #endregion
        }
Beispiel #2
0
        public FontWindow()
        {
            InitializeComponent();

            this.MouseDown += (s, e) => { this.Topmost = true; };

            List <FontHandler> List   = FontHandler.GetFontList();
            List <FontHandler> Cached = List;

            new Thread(() =>
            {
                DispatcherOperation dp = gListWrapper.Dispatcher.BeginInvoke(new Action(delegate()
                {
                    foreach (FontHandler F in List)
                    {
                        gListWrapper.Children.Add(GetFontPanel(F));
                    }
                }), DispatcherPriority.Background);

                dp.Completed += (s, e) =>
                {
                    lblLoading.Dispatcher.Invoke(
                        new Action(delegate()
                    {
                        lblLoading.Visibility = System.Windows.Visibility.Hidden;
                    }),
                        DispatcherPriority.Background);
                };
            }).Start();


            txtSearch.TextChanged += (s, e) =>
            {
                string T = txtSearch.Text;
                IsProgressBarVisible(true);

                new Thread(() =>
                {
                    DispatcherOperation dp = gListWrapper.Dispatcher.BeginInvoke(new Action(delegate()
                    {
                        if (!string.IsNullOrEmpty(T))
                        {
                            UpdateUIList(UpdateFontList(T, List));
                        }
                        else
                        {
                            UpdateUIList(Cached);
                        }
                    }), DispatcherPriority.Background);

                    dp.Completed += (sender, eventArgs) =>
                    {
                        pbBusy.Dispatcher.Invoke(new Action(delegate()
                        {
                            IsProgressBarVisible(false);
                        }), DispatcherPriority.Background);
                    };
                }).Start();
            };

            btnSearch.Click += (s, e) =>
            {
                string T = txtSearch.Text;
                if (!string.IsNullOrEmpty(T))
                {
                    new Thread(() =>
                    {
                        gListWrapper.Dispatcher.Invoke(new Action(delegate()
                        {
                            UpdateUIList(UpdateFontList(T, List));
                        }), System.Windows.Threading.DispatcherPriority.Background);
                    }).Start();
                }
            };
        }