예제 #1
0
        public TimelinePanel createCopy()
        {
            TimelinePanel panelCopy = new TimelinePanel();

            panelCopy.twitterAccountToken   = this.twitterAccountToken;
            panelCopy.timelineType          = this.timelineType;
            panelCopy.profileID             = this.profileID;
            panelCopy.isConversation        = this.isConversation;
            panelCopy.conversationStartToot = this.conversationStartToot;
            panelCopy.isSearch    = this.isSearch;
            panelCopy.searchQuery = this.searchQuery;
            panelCopy.setTitle(this.title.Text);
            return(panelCopy);
        }
예제 #2
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);
            }
        }