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); }
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); } }
private void renderProfile(dynamic profile, dynamic relationship) { Account twitterAccount = MastodonAPIWrapper.sharedApiWrapper.accountWithToken(twitterAccountToken); if (profile == null) { MessageBox.Show("Error ??: Unknown Error.", "Error loading Profile", MessageBoxButton.OK); return; } if (profile["errors"] != null) { MessageBox.Show("Error " + profile["errors"][0]["code"] + ": " + profile["errors"][0]["message"] + ".", "Error loading Profile", MessageBoxButton.OK); return; } backgroundImg.Source = new BitmapImage((Uri)profile["header"]); profileUserID = (String)profile["id"]; try { accountImg.Source = new BitmapImage(new Uri((String)profile["avatar"], UriKind.Absolute)); } catch (Exception e) { } nameLabel.Content = profile["display_name"]; handleLabel.Content = "@" + profile["acct"]; if ((bool)profile["locked"] == true) { tootsProtected.Visibility = Visibility.Visible; } /*if ((bool)profile["verified"] == true) * { * verified.Visibility = Visibility.Visible; * }*/ int toots_count = (int)profile["statuses_count"]; String tootsCountStr = String.Format("{0:n0}", toots_count); if (toots_count > 9999999) { tootsCountStr = String.Format("{0:n1} M", (double)toots_count / 1000000.0); } else if (toots_count > 9999) { tootsCountStr = String.Format("{0:n1} K", (double)toots_count / 1000.0); } tootsCount.Content = tootsCountStr; int following_count = (int)profile["following_count"]; String followingCountStr = String.Format("{0:n0}", following_count); if (following_count > 999999) { followingCountStr = String.Format("{0:n1} M", (double)following_count / 1000000.0); } else if (following_count > 9999) { followingCountStr = String.Format("{0:n1} K", (double)following_count / 1000.0); } followingCount.Content = followingCountStr; int followers_count = (int)profile["followers_count"]; String followersCountStr = String.Format("{0:n0}", followers_count); if (followers_count > 999999) { followersCountStr = String.Format("{0:n1} M", (double)followers_count / 1000000.0); } else if (followers_count > 9999) { followersCountStr = String.Format("{0:n1} K", (double)followers_count / 1000.0); } followersCount.Content = followersCountStr; if (profileUserID.Equals(twitterAccount.accountID)) { profileActionBtn.Content = "Edit"; actionBtnType = 0; } else { bool isFollowing = (bool)relationship["following"]; if (isFollowing) { profileActionBtn.Content = "Unfollow"; actionBtnType = 1; } else { profileActionBtn.Content = "Follow"; actionBtnType = 2; } } TimelinePanel tootsPanel = new TimelinePanel(); tootsPanel.twitterAccountToken = twitterAccountToken; tootsPanel.navController = navController; tootsPanel.timelineType = "user"; tootsPanel.profileID = "" + (String)profile.id; tootsPanel.Height = contents.Height; tootsPanel.hideTopBar(); tootsPanel.refreshTimeline(); contents.Children.Add(tootsPanel); profileBio.Text = (String)profile.note; profileBio.Text = Regex.Replace(profileBio.Text, "<.*?>", String.Empty); if (profile["location"] != null && (string)profile["location"] != "") { location.Content = (String)profile["location"]; } if (profile["url"] != null && (string)profile["url"] != "") { //website.Content = (String)profile["entities"]["url"]["urls"][0]["display_url"]; } }