Exemplo n.º 1
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;
        }
Exemplo n.º 2
0
        private void Account_Click(object sender, RoutedEventArgs e)
        {
            Button accountButton = (Button)sender;

            AccountUIHandler accountUIHandler = null;

            foreach (AccountUIHandler uiHandler in accountUIHandlers)
            {
                if (uiHandler.accountButton == accountButton)
                {
                    accountUIHandler = uiHandler;
                    break;
                }
            }
            if (accountUIHandler.twitterAccount.accessToken.Equals(MastodonAPIWrapper.sharedApiWrapper.selectedAccount.accessToken))
            {
                return;
            }

            MastodonAPIWrapper.sharedApiWrapper.selectedAccount = accountUIHandler.twitterAccount;

            foreach (AccountUIHandler accountUI in accountUIHandlers)
            {
                Account twitterAccount = accountUI.twitterAccount;

                DoubleAnimation accountAnimOpacity = new DoubleAnimation();
                Storyboard.SetTarget(accountAnimOpacity, accountUI.accountImage);
                Storyboard.SetTargetProperty(accountAnimOpacity, new PropertyPath(UserControl.OpacityProperty));
                accountAnimOpacity.From = accountUI.accountImage.Opacity;
                if (twitterAccount.accessToken.Equals(MastodonAPIWrapper.sharedApiWrapper.selectedAccount.accessToken))
                {
                    accountAnimOpacity.To = 1.0;
                }
                else
                {
                    accountAnimOpacity.To = 0.5;
                }

                Storyboard storyboard = new Storyboard();
                //storyboard.Children.Add(accountAnim);
                storyboard.Children.Add(accountAnimOpacity);
                storyboard.SpeedRatio *= 5;
                storyboard.Begin();
            }
        }
Exemplo n.º 3
0
        private void Account_Click(object sender, RoutedEventArgs e)
        {
            Button accountButton = (Button)sender;

            AccountUIHandler accountUIHandler = null;

            foreach (AccountUIHandler uiHandler in accountUIHandlers)
            {
                if (uiHandler.accountButton == accountButton)
                {
                    accountUIHandler = uiHandler;
                    break;
                }
            }
            if (accountUIHandler.twitterAccount.accessToken.Equals(MastodonAPIWrapper.sharedApiWrapper.selectedAccount.accessToken))
            {
                return;
            }

            MastodonAPIWrapper.sharedApiWrapper.selectedAccount = accountUIHandler.twitterAccount;
            tabController.setSelectedControl(tabController.buttons.IndexOf(accountUIHandler.homeBtn));

            int topMargin = 43;

            foreach (AccountUIHandler accountUI in accountUIHandlers)
            {
                Account twitterAccount = accountUI.twitterAccount;

                ThicknessAnimation accountAnim = new ThicknessAnimation();
                Storyboard.SetTarget(accountAnim, accountUI.accountButton);
                Storyboard.SetTargetProperty(accountAnim, new PropertyPath(UserControl.MarginProperty));
                accountAnim.From = accountUI.accountButton.Margin;
                accountAnim.To   = new Thickness(13, topMargin, 0, 0);

                DoubleAnimation accountAnimOpacity = new DoubleAnimation();
                Storyboard.SetTarget(accountAnimOpacity, accountUI.accountImage);
                Storyboard.SetTargetProperty(accountAnimOpacity, new PropertyPath(UserControl.OpacityProperty));
                accountAnimOpacity.From = accountUI.accountImage.Opacity;
                if (twitterAccount.accessToken.Equals(MastodonAPIWrapper.sharedApiWrapper.selectedAccount.accessToken))
                {
                    accountAnimOpacity.To = 1.0;
                }
                else
                {
                    accountAnimOpacity.To = 0.5;
                }
                topMargin += 60;

                ThicknessAnimation homeButtonAnim = new ThicknessAnimation();
                Storyboard.SetTarget(homeButtonAnim, accountUI.homeBtn);
                Storyboard.SetTargetProperty(homeButtonAnim, new PropertyPath(UserControl.MarginProperty));
                homeButtonAnim.From = accountUI.homeBtn.Margin;
                homeButtonAnim.To   = new Thickness(4, topMargin, 0, 0);

                DoubleAnimation homeButtonAnimOpacity = new DoubleAnimation();
                Storyboard.SetTarget(homeButtonAnimOpacity, accountUI.homeBtn);
                Storyboard.SetTargetProperty(homeButtonAnimOpacity, new PropertyPath(UserControl.OpacityProperty));
                homeButtonAnimOpacity.From = accountUI.homeBtn.Opacity;

                if (twitterAccount.accessToken.Equals(MastodonAPIWrapper.sharedApiWrapper.selectedAccount.accessToken))
                {
                    topMargin += 50;
                    homeButtonAnimOpacity.To = 1;
                }
                else
                {
                    homeButtonAnimOpacity.To = 0;
                }

                ThicknessAnimation mentionsBtnAnim = new ThicknessAnimation();
                Storyboard.SetTarget(mentionsBtnAnim, accountUI.mentionsBtn);
                Storyboard.SetTargetProperty(mentionsBtnAnim, new PropertyPath(UserControl.MarginProperty));
                mentionsBtnAnim.From = accountUI.mentionsBtn.Margin;
                mentionsBtnAnim.To   = new Thickness(4, topMargin, 0, 0);

                DoubleAnimation mentionsBtnAnimOpacity = new DoubleAnimation();
                Storyboard.SetTarget(mentionsBtnAnimOpacity, accountUI.mentionsBtn);
                Storyboard.SetTargetProperty(mentionsBtnAnimOpacity, new PropertyPath(UserControl.OpacityProperty));
                mentionsBtnAnimOpacity.From = accountUI.mentionsBtn.Opacity;

                if (twitterAccount.accessToken.Equals(MastodonAPIWrapper.sharedApiWrapper.selectedAccount.accessToken))
                {
                    topMargin += 50;
                    mentionsBtnAnimOpacity.To = 1;
                }
                else
                {
                    mentionsBtnAnimOpacity.To = 0;
                }

                ThicknessAnimation messagesBtnAnim = new ThicknessAnimation();
                Storyboard.SetTarget(messagesBtnAnim, accountUI.publicBtn);
                Storyboard.SetTargetProperty(messagesBtnAnim, new PropertyPath(UserControl.MarginProperty));
                messagesBtnAnim.From = accountUI.publicBtn.Margin;
                messagesBtnAnim.To   = new Thickness(4, topMargin, 0, 0);

                DoubleAnimation messagesBtnAnimOpacity = new DoubleAnimation();
                Storyboard.SetTarget(messagesBtnAnimOpacity, accountUI.publicBtn);
                Storyboard.SetTargetProperty(messagesBtnAnimOpacity, new PropertyPath(UserControl.OpacityProperty));
                messagesBtnAnimOpacity.From = accountUI.publicBtn.Opacity;

                if (twitterAccount.accessToken.Equals(MastodonAPIWrapper.sharedApiWrapper.selectedAccount.accessToken))
                {
                    topMargin += 50;
                    messagesBtnAnimOpacity.To = 1;
                }
                else
                {
                    messagesBtnAnimOpacity.To = 0;
                }

                ThicknessAnimation userButtonAnim = new ThicknessAnimation();
                Storyboard.SetTarget(userButtonAnim, accountUI.userButton);
                Storyboard.SetTargetProperty(userButtonAnim, new PropertyPath(UserControl.MarginProperty));
                userButtonAnim.From = accountUI.userButton.Margin;
                userButtonAnim.To   = new Thickness(4, topMargin, 0, 0);

                DoubleAnimation userButtonAnimOpacity = new DoubleAnimation();
                Storyboard.SetTarget(userButtonAnimOpacity, accountUI.userButton);
                Storyboard.SetTargetProperty(userButtonAnimOpacity, new PropertyPath(UserControl.OpacityProperty));
                userButtonAnimOpacity.From = accountUI.userButton.Opacity;

                if (twitterAccount.accessToken.Equals(MastodonAPIWrapper.sharedApiWrapper.selectedAccount.accessToken))
                {
                    topMargin += 50;
                    userButtonAnimOpacity.To = 1;
                }
                else
                {
                    userButtonAnimOpacity.To = 0;
                }

                ThicknessAnimation searchBtnAnim = new ThicknessAnimation();
                Storyboard.SetTarget(searchBtnAnim, accountUI.searchBtn);
                Storyboard.SetTargetProperty(searchBtnAnim, new PropertyPath(UserControl.MarginProperty));
                searchBtnAnim.From = accountUI.searchBtn.Margin;
                searchBtnAnim.To   = new Thickness(4, topMargin, 0, 0);

                DoubleAnimation searchBtnAnimOpacity = new DoubleAnimation();
                Storyboard.SetTarget(searchBtnAnimOpacity, accountUI.searchBtn);
                Storyboard.SetTargetProperty(searchBtnAnimOpacity, new PropertyPath(UserControl.OpacityProperty));
                searchBtnAnimOpacity.From = accountUI.searchBtn.Opacity;

                if (twitterAccount.accessToken.Equals(MastodonAPIWrapper.sharedApiWrapper.selectedAccount.accessToken))
                {
                    topMargin += 50;
                    searchBtnAnimOpacity.To = 1;
                }
                else
                {
                    searchBtnAnimOpacity.To = 0;
                }

                Storyboard storyboard = new Storyboard();
                storyboard.Children.Add(accountAnim);
                storyboard.Children.Add(accountAnimOpacity);

                storyboard.Children.Add(homeButtonAnim);
                storyboard.Children.Add(homeButtonAnimOpacity);

                storyboard.Children.Add(mentionsBtnAnim);
                storyboard.Children.Add(mentionsBtnAnimOpacity);

                storyboard.Children.Add(messagesBtnAnim);
                storyboard.Children.Add(messagesBtnAnimOpacity);

                storyboard.Children.Add(userButtonAnim);
                storyboard.Children.Add(userButtonAnimOpacity);

                storyboard.Children.Add(searchBtnAnim);
                storyboard.Children.Add(searchBtnAnimOpacity);
                storyboard.SpeedRatio *= 5;
                storyboard.Begin();
            }
        }
Exemplo n.º 4
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);
            }
        }