Exemple #1
0
        private void button_Enter(object sender, MouseEventArgs e)
        {
            Button   btn = (Button)sender;
            TabImage img = (TabImage)btn.Content;

            img.Opacity = img.SelectedOpacity;
        }
Exemple #2
0
        public SettingsWindow()
        {
            InitializeComponent();

            this.apiWrapper = MastodonAPIWrapper.sharedApiWrapper;

            int topMargin = 43;

            accountUIHandlers = new List <AccountUIHandler>();

            foreach (Account twitterAccount in MastodonAPIWrapper.sharedApiWrapper.accounts)
            {
                AccountUIHandler accountUIHandler = new AccountUIHandler();
                accountUIHandler.twitterAccountToken = twitterAccount.accessToken;

                Button accountButton = new Button();
                accountButton.ClipToBounds        = false;
                accountButton.HorizontalAlignment = HorizontalAlignment.Left;
                accountButton.VerticalAlignment   = VerticalAlignment.Top;
                accountButton.Height = 50;
                accountButton.Margin = new Thickness(13, topMargin, 0, 0);
                accountButton.Style  = Resources["FlatButton"] as Style;
                accountButton.Click += Account_Click;
                accountButton.Cursor = Cursors.Hand;
                this.sidebarGrid.Children.Add(accountButton);
                accountUIHandler.accountButton = accountButton;
                topMargin += 60;

                Image accountImage = new Image();
                accountImage.Clip             = new RectangleGeometry(new Rect(0, 0, 50, 50), 4, 4);
                accountButton.Content         = accountImage;
                accountUIHandler.accountImage = accountImage;

                accountImage.Opacity = 0;
                this.apiWrapper.getProfileAvatar(twitterAccount, accountImage);

                accountUIHandlers.Add(accountUIHandler);
            }

            Button homeBtn = new Button();

            homeBtn.HorizontalAlignment = HorizontalAlignment.Left;
            homeBtn.VerticalAlignment   = VerticalAlignment.Top;
            homeBtn.Style  = Resources["FlatTab"] as Style;
            homeBtn.Height = 40;
            homeBtn.Margin = new Thickness(4, topMargin, 0, 0);
            homeBtn.Cursor = Cursors.Hand;
            this.sidebarGrid.Children.Add(homeBtn);

            TabImage tabImage = new TabImage();

            tabImage.Height              = 30;
            tabImage.Width               = 38;
            tabImage.Source              = new BitmapImage(new Uri("Resources/add.png", UriKind.Relative));
            tabImage.VerticalAlignment   = VerticalAlignment.Center;
            tabImage.HorizontalAlignment = HorizontalAlignment.Center;
            tabImage.Margin              = new Thickness(2, 1, 20, 1);
            homeBtn.Content              = tabImage;
        }
        public void setSelectedControl(int newSelected)
        {
            if (newSelected == selectedControl)
            {
                return;
            }

            if (newSelected > (controls.Count() - 1))
            {
                throw new Exception("Index " + newSelected + " is out of range [0.." + (controls.Count - 1) + "].");
            }
            dynamic previousControl = controls[selectedControl];

            buttons[selectedControl].Style = Resources["FlatTab"] as Style;
            TabImage buttonImg = (TabImage)buttons[selectedControl].Content;

            buttonImg.Opacity = buttonImg.DefaultOpacity;

            selectedControl = newSelected;
            dynamic newControl = controls[selectedControl];

            buttons[selectedControl].Style = Resources["FlatTab-selected"] as Style;
            buttonImg         = (TabImage)buttons[selectedControl].Content;
            buttonImg.Opacity = buttonImg.SelectedOpacity;

            previousControl.Visibility = Visibility.Visible;
            newControl.Visibility      = Visibility.Visible;

            DoubleAnimation hideAnim = new DoubleAnimation();

            hideAnim.From = 1;
            hideAnim.To   = 0;
            Storyboard.SetTarget(hideAnim, previousControl);
            Storyboard.SetTargetProperty(hideAnim, new PropertyPath(UserControl.OpacityProperty));

            DoubleAnimation showAnim = new DoubleAnimation();

            showAnim.From = 0;
            showAnim.To   = 1;
            Storyboard.SetTarget(showAnim, newControl);
            Storyboard.SetTargetProperty(showAnim, new PropertyPath(UserControl.OpacityProperty));

            Storyboard storyBoard = new Storyboard();

            storyBoard.SpeedRatio *= 3;
            storyBoard.Children.Add(hideAnim);
            storyBoard.Children.Add(showAnim);

            storyBoard.Completed += (sender, e) =>
            {
                previousControl.Visibility = Visibility.Hidden;
            };

            storyBoard.Begin();
            newControl.WillDisplay();
        }
Exemple #4
0
        private void button_Leave(object sender, MouseEventArgs e)
        {
            Button   btn = (Button)sender;
            TabImage img = (TabImage)btn.Content;

            if (!tabController.isButtonSelected(btn))
            {
                img.Opacity = img.DefaultOpacity;
            }
        }
        public void addControl(dynamic control, Button button)
        {
            control.Width  = this.Width;
            control.Height = this.Height;
            control.Margin = new Thickness(0);
            this.mainGrid.Children.Add((UserControl)control);
            controls.Add(control);
            buttons.Add(button);
            button.Click += (object sender, RoutedEventArgs e) =>
            {
                this.setSelectedControl(buttons.IndexOf(button));
            };
            button.MouseRightButtonUp += (object sender, MouseButtonEventArgs e) =>
            {
                ContextMenu menu = new ContextMenu();

                MenuItem open = new MenuItem();
                open.Header = "Open";
                open.Click += (object sender2, RoutedEventArgs e2) =>
                {
                    this.setSelectedControl(buttons.IndexOf(button));
                };
                menu.Items.Add(open);

                MenuItem addColumn = new MenuItem();
                addColumn.Header = "Add Column";
                addColumn.Click += (object sender2, RoutedEventArgs e2) =>
                {
                    Console.WriteLine(windowWidth);
                    dynamic controlCopy = control.createCopy();
                    controlCopy.Width  = this.Width;
                    controlCopy.Margin = new Thickness(windowWidth + 1, 1, 1, 1);
                    controlCopy.HorizontalAlignment = HorizontalAlignment.Left;
                    controlCopy.ClipToBounds        = true;
                    windowWidth += this.Width + 1;

                    this.parentGrid.Children.Add(controlCopy);
                    Console.WriteLine(windowWidth);
                    this.parentWindow.Width    = windowWidth;
                    this.parentWindow.MinWidth = windowWidth;
                    this.parentWindow.MaxWidth = windowWidth;
                    controlCopy.WillDisplay();
                };
                menu.Items.Add(addColumn);

                menu.PlacementTarget = (UIElement)sender;
                menu.IsOpen          = true;
            };
            if (controls.Count() != 1)
            {
                control.Opacity    = 0;
                control.Visibility = Visibility.Hidden;
                button.Style       = Resources["FlatTab"] as Style;
                TabImage buttonImg = (TabImage)button.Content;
                buttonImg.Opacity = buttonImg.DefaultOpacity;
            }
            else
            {
                button.Style = Resources["FlatTab-selected"] as Style;
                TabImage buttonImg = (TabImage)button.Content;
                buttonImg.Opacity = buttonImg.SelectedOpacity;
                control.WillDisplay();
            }
        }
Exemple #6
0
        public MainWindow()
        {
            InitializeComponent();

            if (Environment.OSVersion.Version.Minor == 0 || Environment.OSVersion.Version.Minor == 1) //Vista and Win7
            {
                //roundCornersHandler.RadiusX = 10;
                //roundCornersHandler.RadiusY = 10;
                mainGrid.Background = new SolidColorBrush(Color.FromArgb(64, 0, 0, 0));
            }

            this.apiWrapper = MastodonAPIWrapper.sharedApiWrapper;

            new NotificationsHandler();
            sharedMainWindow = this;

            closeBtn_MouseDown(null, null);
            minimizeBtn_MouseDown(null, null);

            this.Show();

            tabController                     = new TabsController();
            tabController.parentGrid          = this.mainGrid;
            tabController.parentWindow        = this;
            tabController.ClipToBounds        = true;
            tabController.Margin              = new Thickness(77, 1, 1, 1);
            tabController.VerticalAlignment   = VerticalAlignment.Stretch;
            tabController.HorizontalAlignment = HorizontalAlignment.Left;
            tabController.Background          = Brushes.Transparent;
            tabController.Width               = this.RenderSize.Width - 77;

            tabController.windowWidth = this.RenderSize.Width;

            //tabController.Width = this.RenderSize.Width - 97;
            //tabController.Height = this.RenderSize.Height - 20;
            this.mainGrid.Children.Add(tabController);


            TimelinePanel timelinePanel;

            NavController navController;

            int topMargin = 43;

            accountUIHandlers = new List <AccountUIHandler>();

            foreach (Account twitterAccount in MastodonAPIWrapper.sharedApiWrapper.accounts)
            {
                AccountUIHandler accountUIHandler = new AccountUIHandler();
                accountUIHandler.twitterAccountToken = twitterAccount.accessToken;

                Button accountButton = new Button();
                accountButton.ClipToBounds        = false;
                accountButton.HorizontalAlignment = HorizontalAlignment.Left;
                accountButton.VerticalAlignment   = VerticalAlignment.Top;
                accountButton.Height = 50;
                accountButton.Margin = new Thickness(13, topMargin, 0, 0);
                accountButton.Style  = Resources["FlatButton"] as Style;
                accountButton.Click += Account_Click;
                accountButton.Cursor = Cursors.Hand;
                this.sidebarGrid.Children.Add(accountButton);
                accountUIHandler.accountButton = accountButton;
                topMargin += 60;

                Image accountImage = new Image();
                accountImage.Clip             = new RectangleGeometry(new Rect(0, 0, 50, 50), 4, 4);
                accountButton.Content         = accountImage;
                accountUIHandler.accountImage = accountImage;

                accountImage.Opacity = 0;
                this.apiWrapper.getProfileAvatar(twitterAccount, accountImage);

                #region Home
                Button homeBtn = new Button();
                homeBtn.HorizontalAlignment = HorizontalAlignment.Left;
                homeBtn.VerticalAlignment   = VerticalAlignment.Top;
                homeBtn.Style  = Resources["FlatTab"] as Style;
                homeBtn.Height = 40;
                homeBtn.Margin = new Thickness(4, topMargin, 0, 0);
                homeBtn.Cursor = Cursors.Hand;
                this.sidebarGrid.Children.Add(homeBtn);
                if (twitterAccount.accessToken.Equals(MastodonAPIWrapper.sharedApiWrapper.selectedAccount.accessToken))
                {
                    topMargin += 50;
                }
                else
                {
                    homeBtn.Opacity = 0;
                }
                accountUIHandler.homeBtn = homeBtn;

                TabImage tabImage = new TabImage();
                tabImage.Height              = 30;
                tabImage.Width               = 38;
                tabImage.Source              = new BitmapImage(new Uri("Resources/sidebar_home.png", UriKind.Relative));
                tabImage.VerticalAlignment   = VerticalAlignment.Center;
                tabImage.HorizontalAlignment = HorizontalAlignment.Center;
                tabImage.Margin              = new Thickness(2, 1, 20, 1);
                homeBtn.Content              = tabImage;

                timelinePanel = new TimelinePanel();
                timelinePanel.twitterAccountToken = twitterAccount.accessToken;
                //timelinePanel.refreshTimeline();
                navController = new NavController(timelinePanel);

                navController.Margin = new Thickness(0);
                tabController.addControl(navController, homeBtn);

                #endregion
                #region Mentions
                Button mentionsBtn = new Button();
                mentionsBtn.HorizontalAlignment = HorizontalAlignment.Left;
                mentionsBtn.VerticalAlignment   = VerticalAlignment.Top;
                mentionsBtn.Style  = Resources["FlatTab"] as Style;
                mentionsBtn.Height = 40;
                mentionsBtn.Margin = new Thickness(4, topMargin, 0, 0);
                mentionsBtn.Cursor = Cursors.Hand;
                this.sidebarGrid.Children.Add(mentionsBtn);
                if (twitterAccount.accessToken.Equals(MastodonAPIWrapper.sharedApiWrapper.selectedAccount.accessToken))
                {
                    topMargin += 50;
                }
                else
                {
                    mentionsBtn.Opacity = 0;
                }
                accountUIHandler.mentionsBtn = mentionsBtn;

                tabImage                     = new TabImage();
                tabImage.Height              = 30;
                tabImage.Width               = 38;
                tabImage.Source              = new BitmapImage(new Uri("Resources/sidebar_notifications.png", UriKind.Relative));
                tabImage.VerticalAlignment   = VerticalAlignment.Center;
                tabImage.HorizontalAlignment = HorizontalAlignment.Center;
                tabImage.Margin              = new Thickness(2, 1, 20, 1);
                mentionsBtn.Content          = tabImage;

                timelinePanel = new TimelinePanel();
                timelinePanel.twitterAccountToken = twitterAccount.accessToken;
                timelinePanel.setTitle(Strings.Mentions);
                timelinePanel.timelineType = "mentions";
                //timelinePanel.refreshTimeline();

                navController = new NavController(timelinePanel);

                navController.Margin = new Thickness(0);
                tabController.addControl(navController, mentionsBtn);

                #endregion
                #region Public
                Button publicBtn = new Button();
                publicBtn.HorizontalAlignment = HorizontalAlignment.Left;
                publicBtn.VerticalAlignment   = VerticalAlignment.Top;
                publicBtn.Style  = Resources["FlatTab"] as Style;
                publicBtn.Height = 40;
                publicBtn.Margin = new Thickness(4, topMargin, 0, 0);
                publicBtn.Cursor = Cursors.Hand;
                this.sidebarGrid.Children.Add(publicBtn);
                if (twitterAccount.accessToken.Equals(MastodonAPIWrapper.sharedApiWrapper.selectedAccount.accessToken))
                {
                    topMargin += 50;
                }
                else
                {
                    publicBtn.Opacity = 0;
                }
                accountUIHandler.publicBtn = publicBtn;

                tabImage                     = new TabImage();
                tabImage.Height              = 30;
                tabImage.Width               = 38;
                tabImage.Source              = new BitmapImage(new Uri("Resources/sidebar_public.png", UriKind.Relative));
                tabImage.VerticalAlignment   = VerticalAlignment.Center;
                tabImage.HorizontalAlignment = HorizontalAlignment.Center;
                tabImage.Margin              = new Thickness(2, 1, 20, 1);
                publicBtn.Content            = tabImage;

                timelinePanel = new TimelinePanel();
                timelinePanel.twitterAccountToken = twitterAccount.accessToken;
                timelinePanel.setTitle(Strings.PublicTimeline);
                timelinePanel.timelineType = "public";
                //timelinePanel.refreshTimeline();
                navController = new NavController(timelinePanel);

                navController.Margin = new Thickness(0);
                tabController.addControl(navController, publicBtn);

                #endregion
                #region Account
                Button userBtn = new Button();
                userBtn.HorizontalAlignment = HorizontalAlignment.Left;
                userBtn.VerticalAlignment   = VerticalAlignment.Top;
                userBtn.Style  = Resources["FlatTab"] as Style;
                userBtn.Height = 40;
                userBtn.Margin = new Thickness(4, topMargin, 0, 0);
                userBtn.Cursor = Cursors.Hand;
                this.sidebarGrid.Children.Add(userBtn);
                if (twitterAccount.accessToken.Equals(MastodonAPIWrapper.sharedApiWrapper.selectedAccount.accessToken))
                {
                    topMargin += 50;
                }
                else
                {
                    userBtn.Opacity = 0;
                }

                tabImage                     = new TabImage();
                tabImage.Height              = 30;
                tabImage.Width               = 38;
                tabImage.Source              = new BitmapImage(new Uri("Resources/sidebar_profile.png", UriKind.Relative));
                tabImage.VerticalAlignment   = VerticalAlignment.Center;
                tabImage.HorizontalAlignment = HorizontalAlignment.Center;
                tabImage.Margin              = new Thickness(2, 1, 20, 1);
                userBtn.Content              = tabImage;
                accountUIHandler.userButton  = userBtn;

                ProfilePanel profilePanel = new ProfilePanel();
                profilePanel.twitterAccountToken = twitterAccount.accessToken;
                //profilePanel.refreshProfile();

                navController = new NavController(profilePanel);

                navController.Margin = new Thickness(0);
                tabController.addControl(navController, userBtn);

                #endregion

                #region Search
                Button searchBtn = new Button();
                searchBtn.HorizontalAlignment = HorizontalAlignment.Left;
                searchBtn.VerticalAlignment   = VerticalAlignment.Top;
                searchBtn.Style  = Resources["FlatTab"] as Style;
                searchBtn.Height = 40;
                searchBtn.Margin = new Thickness(4, topMargin, 0, 0);
                searchBtn.Cursor = Cursors.Hand;
                this.sidebarGrid.Children.Add(searchBtn);
                if (twitterAccount.accessToken.Equals(MastodonAPIWrapper.sharedApiWrapper.selectedAccount.accessToken))
                {
                    topMargin += 50;
                }
                else
                {
                    searchBtn.Opacity = 0;
                }
                accountUIHandler.searchBtn = searchBtn;

                tabImage                     = new TabImage();
                tabImage.Height              = 30;
                tabImage.Width               = 38;
                tabImage.Source              = new BitmapImage(new Uri("Resources/sidebar_search.png", UriKind.Relative));
                tabImage.VerticalAlignment   = VerticalAlignment.Center;
                tabImage.HorizontalAlignment = HorizontalAlignment.Center;
                tabImage.Margin              = new Thickness(2, 1, 20, 1);
                searchBtn.Content            = tabImage;

                SearchPanel searchPanel = new SearchPanel();
                searchPanel.twitterAccountToken = twitterAccount.accessToken;
                navController = new NavController(searchPanel);

                navController.Margin = new Thickness(0);
                tabController.addControl(navController, searchBtn);
                #endregion

                accountUIHandlers.Add(accountUIHandler);
            }
        }