Inheritance: System.Windows.Controls.UserControl, IDisplayHandler, IDownloadHandler, ILifeSpanHandler, IContextMenuHandler
示例#1
0
 public void RefreshFavs(MainWindow mw)
 {
     Dispatcher.BeginInvoke((Action)(() =>
     {
         try
         {
             bookmarks.ItemsCount = 0;
             bookmarks.RowsCount = 0;
             bookmarks.mainCanvas.Children.Clear();
             if (System.IO.File.Exists(StaticDeclarations.Bookmarkspath))
             {
                 string readFile = System.IO.File.ReadAllText(StaticDeclarations.Bookmarkspath);
                 dynamic json = JsonConvert.DeserializeObject(readFile);
                 foreach (dynamic item in json)
                 {
                     TabView tabView = bookmarks.FindParent <TabView>();
                     bookmarks.AddBookmark(Convert.ToString(item.Url), Convert.ToString(item.Title), tabView, mw);
                 }
             }
         }
         catch (Exception ex)
         {
             Console.WriteLine("Refresh settings error: " + ex.Message + " " + ex.Data);
         }
     }));
 }
示例#2
0
        public void RemoveTab(Tab tabToRemove)
        {
            TabCount       = 0;
            AddButtonCount = 1;

            TabCollection.Remove(tabToRemove);
            canvas.Children.Remove(tabToRemove);

            foreach (var ctrl in TabCollection)
            {
                ctrl.Width = tabWidth;
                Canvas.SetLeft(ctrl, TabCount * tabWidth);
                AddButton.BeginAnimation(Canvas.LeftProperty,
                                         new DoubleAnimation(Canvas.GetLeft(AddButton), AddButtonCount * tabWidth, TimeSpan.FromMilliseconds(moveButtonDuration)));
                TabCount       += 1;
                AddButtonCount += 1;
                CalcSizes();
                tabToRemove.mainWindow.container.Children.Remove(tabToRemove.form);
                if (tabToRemove.form.GetType() == typeof(TabView))
                {
                    TabView tv = (tabToRemove.form as TabView);
                    tv.Shutdown();
                }
                SelectTab(TabCollection[TabCollection.Count - 1]);
            }
        }
示例#3
0
        private async void Me_MouseDown(object sender, MouseButtonEventArgs e)
        {
            TabBar tb = this.FindParent <TabBar>();

            tb.SelectTab(this);

            if (form.GetType() == typeof(TabView))
            {
                TabView tv = (form as TabView);
                await tv.ChangeColor();
            }
        }
示例#4
0
        public void AddTab(OpenTabCommandParameters commandParams, MainWindow mw)
        {
            UserControl userControl;

            if(commandParams.Control == null)
            {
                 userControl = new TabView(mw, commandParams.Url);
            }
            else
            {
                userControl = commandParams.Control;
            }

            Dispatcher.BeginInvoke((Action) (() =>
            {
                tab = new Tab(commandParams.Title, mw, userControl, commandParams.Brush);

                tab.Width = tabWidth;
                tab.Height = tabHeight;
                canvas.Children.Add(tab);
                Canvas.SetLeft(tab, TabCount * tabWidth);
                Canvas.SetTop(tab, 0);
                Canvas.SetTop(AddButton, 0);
                if (AddButtonCount == 1)
                {
                    AddButton.BeginAnimation(Canvas.LeftProperty,
                        new DoubleAnimation(0, AddButtonCount * tabWidth, TimeSpan.FromMilliseconds(moveButtonDuration)));
                }
                else
                {
                    AddButton.BeginAnimation(Canvas.LeftProperty,
                        new DoubleAnimation(Canvas.GetLeft(AddButton), AddButtonCount * tabWidth, TimeSpan.FromMilliseconds(moveButtonDuration)));
                }
                TabCount += 1;
                AddButtonCount += 1;
                TabCollection.Add(tab);

                var fade = new DoubleAnimation()
                {
                    From = 0,
                    To = 1,
                    Duration = TimeSpan.FromSeconds(0.25),
                };
                Storyboard.SetTarget(fade, tab);
                Storyboard.SetTargetProperty(fade, new PropertyPath(Button.OpacityProperty));

                var sb = new Storyboard();
                sb.Children.Add(fade);
                sb.Begin();

                CalcSizes();
            }));
        }
示例#5
0
        public void AddTab(OpenTabCommandParameters commandParams, MainWindow mw)
        {
            UserControl userControl;

            if (commandParams.Control == null)
            {
                userControl = new TabView(mw, commandParams.Url);
            }
            else
            {
                userControl = commandParams.Control;
            }

            Dispatcher.BeginInvoke((Action)(() =>
            {
                tab = new Tab(commandParams.Title, mw, userControl, commandParams.Brush);

                tab.Width = tabWidth;
                tab.Height = tabHeight;
                canvas.Children.Add(tab);
                Canvas.SetLeft(tab, TabCount * tabWidth);
                Canvas.SetTop(tab, 0);
                Canvas.SetTop(AddButton, 0);
                if (AddButtonCount == 1)
                {
                    AddButton.BeginAnimation(Canvas.LeftProperty,
                                             new DoubleAnimation(0, AddButtonCount * tabWidth, TimeSpan.FromMilliseconds(moveButtonDuration)));
                }
                else
                {
                    AddButton.BeginAnimation(Canvas.LeftProperty,
                                             new DoubleAnimation(Canvas.GetLeft(AddButton), AddButtonCount * tabWidth, TimeSpan.FromMilliseconds(moveButtonDuration)));
                }
                TabCount += 1;
                AddButtonCount += 1;
                TabCollection.Add(tab);

                var fade = new DoubleAnimation()
                {
                    From = 0,
                    To = 1,
                    Duration = TimeSpan.FromSeconds(0.25),
                };
                Storyboard.SetTarget(fade, tab);
                Storyboard.SetTargetProperty(fade, new PropertyPath(Button.OpacityProperty));

                var sb = new Storyboard();
                sb.Children.Add(fade);
                sb.Begin();

                CalcSizes();
            }));
        }
示例#6
0
 public async Task LoadFavs(MainWindow mw)
 {
     await Dispatcher.BeginInvoke((Action)(() =>
     {
         try
         {
             if (System.IO.File.Exists(StaticDeclarations.Bookmarkspath))
             {
                 string readFile = System.IO.File.ReadAllText(StaticDeclarations.Bookmarkspath);
                 dynamic json = JsonConvert.DeserializeObject(readFile);
                 foreach (dynamic item in json)
                 {
                     TabView tabView = bookmarks.FindParent <TabView>();
                     bookmarks.AddBookmark(Convert.ToString(item.Url), Convert.ToString(item.Title), tabView, mw);
                 }
             }
         }
         catch (Exception ex)
         {
             Console.WriteLine("Load bookmarks error: " + ex.Message + " " + ex.Data);
         }
     }));
 }
 public void loadFavs(MainWindow mw)
 {
     Dispatcher.BeginInvoke((Action)(() =>
     {
         try {
             string[] readText = System.IO.File.ReadAllLines(TabView.Bookspath);
             ArrayList arr = new ArrayList();
             foreach (var sr in readText)
             {
                 arr.Add(sr);
             }
             Grid parent = this.Parent as Grid;
             TabView parent2 = parent.Parent as TabView;
             foreach (string s in arr)
             {
                 string[] split = s.Split((char)42);
                 bookmarks.AddBookmark(split[0], split[1], parent2, mw);
             }
         } catch (Exception ex)
         {
             Console.WriteLine("LoadFavs error: " + ex.Message);
         }
     }));
 }