private void buttonSendPost_Click(object sender, RoutedEventArgs e)
        {
            if (!string.IsNullOrEmpty(autoCompeteTextbox_post.textBoxContent.Text))
            {
                AccountAppDotNet account = comboBoxAccount.comboBoxAccounts.SelectedItem  as AccountAppDotNet;
                if (account != null)
                {
                    AppNetDotNet.Model.Entities entities = null;
                    string toBePostedText = autoCompeteTextbox_post.textBoxContent.Text;
                    if (autoCompeteTextbox_post.MarkdownLinksInText.Count() > 0)
                    {
                        entities          = new AppNetDotNet.Model.Entities();
                        entities.links    = new List <AppNetDotNet.Model.Entities.Link>();
                        entities.hashtags = null;
                        entities.mentions = null;
                        foreach (KeyValuePair <string, string> link in autoCompeteTextbox_post.MarkdownLinksInText)
                        {
                            AppNetDotNet.Model.Entities.Link linkEntity = new AppNetDotNet.Model.Entities.Link();
                            linkEntity.text = link.Value;
                            linkEntity.url  = link.Key;
                            int startPosition = toBePostedText.IndexOf(string.Format("[{0}]({1})", linkEntity.text, linkEntity.url));
                            linkEntity.pos = startPosition;
                            linkEntity.len = linkEntity.text.Length;
                            toBePostedText = toBePostedText.Replace(string.Format("[{0}]({1})", linkEntity.text, linkEntity.url), linkEntity.text);
                            entities.links.Add(linkEntity);
                        }
                    }

                    List <AppNetDotNet.Model.File> toBeAddedFiles = null;
                    if (!string.IsNullOrEmpty(path_to_be_uploaded_image))
                    {
                        if (System.IO.File.Exists(path_to_be_uploaded_image))
                        {
                            Tuple <AppNetDotNet.Model.File, ApiCallResponse> uploadedFile = AppNetDotNet.ApiCalls.Files.create(account.accessToken, local_file_path: path_to_be_uploaded_image, type: "de.li-ghun.nymphicus.image");
                            if (uploadedFile.Item2.success)
                            {
                                toBeAddedFiles = new List <File>();
                                toBeAddedFiles.Add(uploadedFile.Item1);
                            }
                        }
                    }

                    Tuple <Post, ApiCallResponse> response;

                    if (inReplyToId == 0)
                    {
                        response = Posts.create(account.accessToken, toBePostedText, entities: entities, parse_links: true, toBeEmbeddedFiles: toBeAddedFiles);
                    }
                    else
                    {
                        response = Posts.create(account.accessToken, toBePostedText, inReplyToId.ToString(), entities: entities, parse_links: true, toBeEmbeddedFiles: toBeAddedFiles);
                    }

                    if (response.Item2.success)
                    {
                        Close();
                    }
                }
            }
        }
예제 #2
0
        public UserInfo(AccountAppDotNet receivingAccount, User toBeShownUser)
        {
            InitializeComponent();
            user    = toBeShownUser;
            account = receivingAccount;

            initalizeAllData();
        }
예제 #3
0
        public UserInfo(AccountAppDotNet receivingAccount, string username)
        {
            InitializeComponent();
            Tuple <User, ApiCallResponse> userResponse = Users.getUserByUsernameOrId(receivingAccount.accessToken, username);

            if (userResponse.Item2.success)
            {
                user = userResponse.Item1;
            }
            account = receivingAccount;

            initalizeAllData();
        }
예제 #4
0
        void menuItemStarEntry_Click(object sender, RoutedEventArgs e)
        {
            MenuItem menuItem = sender as MenuItem;

            if (menuItem != null)
            {
                AccountAppDotNet apnAccount = menuItem.CommandParameter as AccountAppDotNet;
                if (apnAccount != null && parent_post != null)
                {
                    AppNetDotNet.ApiCalls.Posts.star(apnAccount.accessToken, parent_post.id);
                }
            }
        }
예제 #5
0
        void menuItemRepostEntry_Click(object sender, RoutedEventArgs e)
        {
            MenuItem menuItem = sender as MenuItem;

            if (menuItem != null)
            {
                AccountAppDotNet apnAccount = menuItem.CommandParameter as AccountAppDotNet;
                if (parent_post != null)
                {
                    if (apnAccount != null)
                    {
                        AppNetDotNet.ApiCalls.Posts.repost(apnAccount.accessToken, parent_post.id);
                    }
                    else
                    {
                        UserInterface.ComposeNewApnPost composeWindow = new ComposeNewApnPost();
                        composeWindow.autoCompeteTextbox_post.textBoxContent.Text       = " >> \"" + parent_post.text + "\" via @" + parent_post.user.username;
                        composeWindow.autoCompeteTextbox_post.textBoxContent.CaretIndex = 0;
                        composeWindow.Show();
                    }
                }
            }
        }
예제 #6
0
 void buttonApnAuthorize_Click(object sender, RoutedEventArgs e)
 {
     AppController.Current.Logger.addDebugMessage("App.net button clicked", "-", type: DebugMessage.DebugMessageTypes.FirstStartWizard);
     AccountAppDotNet.authorizeNewAccount();
 }
예제 #7
0
            public static TreeView CreateViewTreeView(View view, TreeView treeview, bool IncludeFilter)
            {
                treeview.Items.Clear();
                if (view == null)
                {
                    return(null);
                }

                foreach (IAccount iaccount in AppController.Current.AllAccounts)
                {
                    if (view.isTwitterOnlyView)
                    {
                        if (iaccount.GetType() == typeof(AccountTwitter))
                        {
                            #region Twitter
                            AccountTwitter account         = iaccount as AccountTwitter;
                            string         accountIdString = account.Login.Id.ToString();

                            TreeViewItem accountItem = new TreeViewItem();
                            accountItem.Name       = "account_" + accountIdString;
                            accountItem.ToolTip    = account.Login.NameAndLogin;
                            accountItem.Header     = "@" + account.Login.Username;
                            accountItem.IsExpanded = true;

                            CheckBox timeline = new CheckBox();
                            timeline.Name    = "timeline_" + accountIdString;
                            timeline.Content = "Timeline";
                            if (view.subscribedTimelines.Contains(account.Login.Id))
                            {
                                timeline.IsChecked = true;
                            }
                            accountItem.Items.Add(timeline);

                            CheckBox mentions = new CheckBox();
                            mentions.Name    = "mentions_" + accountIdString;
                            mentions.Content = "Mentions";
                            if (view.subscribedMentions.Contains(account.Login.Id))
                            {
                                mentions.IsChecked = true;
                            }
                            accountItem.Items.Add(mentions);

                            CheckBox directMessages = new CheckBox();
                            directMessages.Name    = "directMessages_" + accountIdString;
                            directMessages.Content = "Direct messages";
                            if (view.subscribedDirectMessages.Contains(account.Login.Id))
                            {
                                directMessages.IsChecked = true;
                            }
                            accountItem.Items.Add(directMessages);

                            CheckBox retweets = new CheckBox();
                            retweets.Name    = "retweets_" + accountIdString;
                            retweets.Content = "Retweets";
                            if (view.subscribedRetweets.Contains(account.Login.Id))
                            {
                                retweets.IsChecked = true;
                            }
                            accountItem.Items.Add(retweets);

                            CheckBox favorites = new CheckBox();
                            favorites.Name    = "favorites_" + accountIdString;
                            favorites.Content = "Favorites";
                            if (view.subscribedFavorites.Contains(account.Login.Id))
                            {
                                favorites.IsChecked = true;
                            }
                            accountItem.Items.Add(favorites);

                            if (account.Lists.Count > 0)
                            {
                                TreeViewItem lists = new TreeViewItem();
                                lists.Name       = "lists_" + accountIdString;
                                lists.Header     = "Lists";
                                lists.IsExpanded = true;

                                foreach (TweetList list in account.Lists)
                                {
                                    CheckBox listCheckbox = new CheckBox();
                                    listCheckbox.Name    = "list_" + list.Id.ToString();
                                    listCheckbox.Content = list.NameAndCreator;
                                    listCheckbox.ToolTip = list.Description;
                                    if (view.subscribedLists.Contains(list.Id))
                                    {
                                        listCheckbox.IsChecked = true;
                                    }
                                    lists.Items.Add(listCheckbox);
                                }
                                accountItem.Items.Add(lists);
                            }

                            if (account.Searches.Count > 0)
                            {
                                TreeViewItem searches = new TreeViewItem();
                                searches.Name       = "searches_" + accountIdString;
                                searches.Header     = "Searches";
                                searches.IsExpanded = true;
                                foreach (Search search in account.Searches)
                                {
                                    CheckBox searchCheckbox = new CheckBox();
                                    searchCheckbox.Name    = "search_" + search.Id.ToString();
                                    searchCheckbox.Content = search.name;
                                    if (view.subscribedSearches.Contains(search.Id))
                                    {
                                        searchCheckbox.IsChecked = true;
                                    }
                                    searches.Items.Add(searchCheckbox);
                                }
                                accountItem.Items.Add(searches);
                            }

                            treeview.Items.Add(accountItem);
                            #endregion
                        }
                    }
                    else
                    {
                        if (iaccount.GetType() == typeof(AccountFacebook))
                        {
                            #region Facebook
                            AccountFacebook account         = iaccount as AccountFacebook;
                            string          accountIdString = account.Id.ToString();

                            TreeViewItem accountItem = new TreeViewItem();
                            accountItem.Name       = "fbAccount_" + accountIdString;
                            accountItem.ToolTip    = account.username;
                            accountItem.Header     = "Facebook " + account.username;
                            accountItem.IsExpanded = true;

                            CheckBox statusMessages = new CheckBox();
                            statusMessages.Name    = "statusMessages_" + accountIdString;
                            statusMessages.Content = "Status Messages";
                            if (view.subscribedFbStatusMessages.Contains(account.Id))
                            {
                                statusMessages.IsChecked = true;
                            }
                            accountItem.Items.Add(statusMessages);

                            CheckBox links = new CheckBox();
                            links.Name    = "links_" + accountIdString;
                            links.Content = "Links";
                            if (view.subscribedFbLinks.Contains(account.Id))
                            {
                                links.IsChecked = true;
                            }
                            accountItem.Items.Add(links);

                            CheckBox videos = new CheckBox();
                            videos.Name    = "videos_" + accountIdString;
                            videos.Content = "Videos";
                            if (view.subscribedFbVideos.Contains(account.Id))
                            {
                                videos.IsChecked = true;
                            }
                            accountItem.Items.Add(videos);

                            CheckBox photos = new CheckBox();
                            photos.Name    = "photos_" + accountIdString;
                            photos.Content = "Photos";
                            if (view.subscribedFbPhotos.Contains(account.Id))
                            {
                                photos.IsChecked = true;
                            }
                            accountItem.Items.Add(photos);

                            CheckBox events = new CheckBox();
                            events.Name    = "events_" + accountIdString;
                            events.Content = "Events";
                            if (view.subscribedFbEvents.Contains(account.Id))
                            {
                                events.IsChecked = true;
                            }
                            accountItem.Items.Add(events);

                            CheckBox checkIns = new CheckBox();
                            checkIns.Name    = "checkIns_" + accountIdString;
                            checkIns.Content = "CheckIns";
                            if (view.subscribedFbCheckIns.Contains(account.Id))
                            {
                                checkIns.IsChecked = true;
                            }
                            accountItem.Items.Add(checkIns);

                            CheckBox notes = new CheckBox();
                            notes.Name    = "notes_" + accountIdString;
                            notes.Content = "Notes";
                            if (view.subscribedFbNotes.Contains(account.Id))
                            {
                                notes.IsChecked = true;
                            }
                            accountItem.Items.Add(notes);

                            treeview.Items.Add(accountItem);
                            #endregion
                        }
                        else if (iaccount.GetType() == typeof(AccountAppDotNet))
                        {
                            #region App.net
                            AccountAppDotNet account         = iaccount as AccountAppDotNet;
                            string           accountIdString = account.Id.ToString();

                            TreeViewItem accountItem = new TreeViewItem();
                            accountItem.Name       = "apnPersonalStream_" + accountIdString;
                            accountItem.ToolTip    = account.username;
                            accountItem.Header     = "App.net @" + account.username;
                            accountItem.IsExpanded = true;

                            CheckBox personalStream = new CheckBox();
                            personalStream.Name    = "apnPersonalStream_" + accountIdString;
                            personalStream.Content = "My stream";
                            if (view.subscribedApnPersonalStreams.Contains(account.Id))
                            {
                                personalStream.IsChecked = true;
                            }
                            accountItem.Items.Add(personalStream);

                            CheckBox privateMessages = new CheckBox();
                            privateMessages.Name    = "apnPrivateMessages_" + accountIdString;
                            privateMessages.Content = "Private Messages";
                            if (view.subscribedApnPrivateMessages.Contains(account.Id))
                            {
                                privateMessages.IsChecked = true;
                            }
                            accountItem.Items.Add(privateMessages);

                            CheckBox mentions = new CheckBox();
                            mentions.Name    = "apnMentions_" + accountIdString;
                            mentions.Content = "Mentions";
                            if (view.subscribedApnMentions.Contains(account.Id))
                            {
                                mentions.IsChecked = true;
                            }
                            accountItem.Items.Add(mentions);

                            CheckBox reposts = new CheckBox();
                            reposts.Name      = "apnReposts_" + accountIdString;
                            reposts.Content   = "Reposts";
                            reposts.IsEnabled = false;
                            if (false && view.subscribedApnPersonalStreams.Contains(account.Id))
                            {
                                personalStream.IsChecked = true;
                            }
                            accountItem.Items.Add(reposts);

                            treeview.Items.Add(accountItem);
                            #endregion
                        }

                        else if (iaccount.GetType() == typeof(AccountQuoteFM))
                        {
                            # region QUOTE.fm
                            AccountQuoteFM account         = iaccount as AccountQuoteFM;
                            string         accountIdString = account.User.Id.ToString();

                            TreeViewItem accountItem = new TreeViewItem();
                            accountItem.Name       = "account_" + accountIdString;
                            accountItem.ToolTip    = account.User.Fullname;
                            accountItem.Header     = "QUOTE.fm " + account.User.username;
                            accountItem.IsExpanded = true;

                            CheckBox recommendations = new CheckBox();
                            recommendations.Name    = "qfmRecos_" + accountIdString;
                            recommendations.Content = "Recommendations";
                            if (view.subscribedQuoteFmRecommendations.Contains(account.User.Id))
                            {
                                recommendations.IsChecked = true;
                            }
                            accountItem.Items.Add(recommendations);

                            treeview.Items.Add(accountItem);
                        }
                    }

                    if (AppController.Current.HasQuoteFmAccounts && QuoteFmCategories.Categories != null && !view.isTwitterOnlyView)
                    {
                        TreeViewItem categorytItem = new TreeViewItem();
                        categorytItem.Name       = "qfmCategories";
                        categorytItem.ToolTip    = "QUOTE.fm categories";
                        categorytItem.Header     = "QUOTE.fm categories";
                        categorytItem.IsExpanded = true;

                        foreach (QuoteSharp.Category category in QuoteFmCategories.Categories.catagories.entities)
                        {
                            CheckBox checkboxCategory = new CheckBox();
                            checkboxCategory.Name    = "qfmCat_" + category.id.ToString();
                            checkboxCategory.Content = category.name;
                            checkboxCategory.ToolTip = category.name;
                            if (view.subscribedQuoteFmCategories.Contains(category.id))
                            {
                                checkboxCategory.IsChecked = true;
                            }
                            categorytItem.Items.Add(checkboxCategory);
                        }

                        treeview.Items.Add(categorytItem);
                        #endregion
                    }
                }
예제 #8
0
        void backgroundWorkerBuildConversation_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
        {
            AccountAppDotNet account = startItem.receivingAccount;


            if (!startItem.isPrivateMessage)
            {
                Tuple <List <Post>, ApiCallResponse> postsInFuture = Posts.getRepliesById(account.accessToken, startItem.apnItem.reply_to);
                if (postsInFuture.Item2.success)
                {
                    foreach (Post post in postsInFuture.Item1)
                    {
                        ApnItem item = new ApnItem(post, startItem.receivingAccount);
                        if (item != null)
                        {
                            item.receivingAccount = account;
                            backgroundWorkerBuildConversation.ReportProgress(100, item);
                        }
                    }
                }
            }

            else
            {
                Tuple <List <Message>, ApiCallResponse> messages = Messages.getMessagesInChannel(account.accessToken, startItem.channelId);
                if (messages.Item2.success)
                {
                    foreach (Message message in messages.Item1)
                    {
                        ApnItem item = new ApnItem(message, startItem.receivingAccount);
                        if (item != null)
                        {
                            item.receivingAccount = account;
                            backgroundWorkerBuildConversation.ReportProgress(100, item);
                        }
                    }
                }
            }
            return;

            // old approach not needed in App.net API!
            #region Mention conversation
            string currentStatusId = startItem.apnItem.reply_to;
            while (!string.IsNullOrEmpty(currentStatusId))
            {
                if (account.PersonalStream.Where(i => i.Id.ToString() == currentStatusId).Count() > 0)
                {
                    ApnItem knownMention = account.PersonalStream.Where(i => i.Id.ToString() == currentStatusId).First() as ApnItem;
                    if (knownMention != null)
                    {
                        currentStatusId = "";
                        currentStatusId = knownMention.apnItem.reply_to;
                        backgroundWorkerBuildConversation.ReportProgress(100, knownMention);
                    }
                }
                else if (account.PersonalStream.Where(i => i.Id.ToString() == currentStatusId).Count() > 0)
                {
                    ApnItem knownTimeline = account.PersonalStream.Where(i => i.Id.ToString() == currentStatusId).First() as ApnItem;
                    if (knownTimeline != null)
                    {
                        currentStatusId = "";
                        currentStatusId = knownTimeline.apnItem.reply_to;
                        backgroundWorkerBuildConversation.ReportProgress(100, knownTimeline);
                    }
                }
                else
                {
                    Tuple <Post, ApiCallResponse> newPost = Posts.getById(account.accessToken, currentStatusId);
                    currentStatusId = "";
                    if (newPost.Item2.success)
                    {
                        ApnItem newItem = new ApnItem(newPost.Item1, startItem.receivingAccount);
                        if (newItem != null)
                        {
                            backgroundWorkerBuildConversation.ReportProgress(100, newItem);
                            currentStatusId = newItem.apnItem.reply_to;
                        }
                    }
                }
            }

            // future entries
            currentStatusId = startItem.apnItem.id;

            List <ApnItem> allItems = new List <ApnItem>();
            foreach (ApnItem item in account.PersonalStream)
            {
                allItems.Add(item);
            }

            List <string> multipleQueue = new List <string>();

            while (!string.IsNullOrEmpty(currentStatusId))
            {
                if (allItems.Where(i => i.apnItem.reply_to == currentStatusId).Count() > 0)
                {
                    IEnumerable <ApnItem> knownItems = allItems.Where(i => i.apnItem.reply_to == currentStatusId);
                    currentStatusId = "";
                    foreach (ApnItem item in knownItems)
                    {
                        if (item != null)
                        {
                            backgroundWorkerBuildConversation.ReportProgress(100, item);
                            if (string.IsNullOrEmpty(currentStatusId))
                            {
                                currentStatusId = item.apnItem.id;
                            }
                            else
                            {
                                multipleQueue.Add(item.apnItem.reply_to);
                            }
                        }
                    }
                }
                else
                {
                    currentStatusId = "";
                }



                if (string.IsNullOrEmpty(currentStatusId) && multipleQueue.Count() > 0)
                {
                    currentStatusId = multipleQueue.First();
                    multipleQueue.RemoveAt(0);
                }
            }
            #endregion
        }
예제 #9
0
 private void buttonAddNewAccountApn_Click_1(object sender, RoutedEventArgs e)
 {
     AccountAppDotNet.authorizeNewAccount();
 }