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
        private void button_send_Click(object sender, RoutedEventArgs e)
        {
            if (!string.IsNullOrEmpty(autoCompeteTextbox_post.textBoxContent.Text))
            {
                Account account = combobox_accounts.SelectedItem as Account;
                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);
                        }
                    }


                    if (account.send_post(toBePostedText, path_to_be_uploaded_image, entities: entities))
                    {
                        AppController.last_used_account = account;
                        Close();
                    }
                }
            }
        }
示例#3
0
        private void button_send_Click(object sender, RoutedEventArgs e)
        {
            if (!string.IsNullOrEmpty(autoCompeteTextbox_post.textBoxContent.Text))
            {
                Account account = combobox_accounts.SelectedItem as Account;
                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);
                        }
                    }

                    if (account.send_post(toBePostedText, path_to_be_uploaded_image, entities:entities))
                    {
                        AppController.last_used_account = account;
                        Close();
                    }
                }
            }
        }
示例#4
0
        private void button_sendPost_Click_1(object sender, RoutedEventArgs e)
        {
            if (!string.IsNullOrEmpty(textbox_postText.Text))
            {
                AppNetDotNet.Model.Entities entities = null;
                string toBePostedText = textbox_postText.textBoxContent.Text;
                if (textbox_postText.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 textbox_postText.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<IAnnotation> annotations = null;
                if (!string.IsNullOrEmpty(Properties.Settings.Default.language_posts))
                {
                    /* annotations = new List<IAnnotation>();
                     * AppNetDotNet.Model.Annotations.Language language_annotation = new AppNetDotNet.Model.Annotations.Language();
                     * language_annotation.language = Properties.Settings.Default.language_posts;
                     * annotations.Add(language_annotation); */
                }


                if (currentPostTarget.pmToUser == null && currentPostTarget.channelName == null)
                {
                    List <File> toBeAddedFiles = null;
                    if (!string.IsNullOrEmpty(currentPostTarget.filePathOfToBeAddedFile))
                    {
                        if (System.IO.File.Exists(currentPostTarget.filePathOfToBeAddedFile))
                        {
                            Tuple <File, ApiCallResponse> uploadedFile = AppNetDotNet.ApiCalls.Files.create(AppController.Current.account.accessToken, currentPostTarget.filePathOfToBeAddedFile, type: "com.nymphicusapp.chapper.image");
                            if (uploadedFile.Item2.success)
                            {
                                toBeAddedFiles = new List <File>();
                                toBeAddedFiles.Add(uploadedFile.Item1);
                            }
                        }
                    }


                    Tuple <Post, ApiCallResponse> response;
                    if (currentPostTarget.replyToItem != null)
                    {
                        if (currentPostTarget.replyToItem.apnPost == null)
                        {
                            currentPostTarget.replyToItem = null;
                        }
                    }
                    if (currentPostTarget.replyToItem == null)
                    {
                        response = Posts.create(AppController.Current.account.accessToken, toBePostedText, toBeEmbeddedFiles: toBeAddedFiles, entities: entities, parse_links: true);
                    }
                    else
                    {
                        response = Posts.create(AppController.Current.account.accessToken, toBePostedText, currentPostTarget.replyToItem.id, toBeEmbeddedFiles: toBeAddedFiles, entities: entities, parse_links: true);
                    }
                    if (response.Item2.success)
                    {
                        AppController.Current.account.updateItems();
                        clear_postbox();
                        if (string.IsNullOrEmpty(currentPostTarget.channelName))
                        {
                            textblock_composeOverlay.Text = "";
                        }
                    }
                    else
                    {
                        showErrorMessage(response.Item2);
                    }
                }
                else
                {
                    Tuple <Message, ApiCallResponse> response;
                    List <string> receiver = new List <string>();
                    if (currentPostTarget.pmToUser != null)
                    {
                        receiver.Add("@" + currentPostTarget.pmToUser.username);
                    }

                    if (receiver.Count == 0 && currentPostTarget.replyToItem != null)
                    {
                        receiver.Add("@" + currentPostTarget.replyToItem.user.username);
                    }

                    if (currentPostTarget.replyToItem != null)
                    {
                        if (currentPostTarget.replyToItem.apnMessage == null)
                        {
                            currentPostTarget.replyToItem = null;
                        }
                    }

                    if (currentPostTarget.replyToItem != null)
                    {
                        if (currentPostTarget.replyToItem.isPrivateMessage)
                        {
                            response = Messages.createPrivateMessage(AppController.Current.account.accessToken, toBePostedText, receiver, currentPostTarget.replyToItem.id, machineOnly: 0, entities: entities, parse_links: true);
                        }
                        else if (currentPostTarget.replyToItem.apnMessage != null)
                        {
                            {
                                response = Messages.create(AppController.Current.account.accessToken, toBePostedText, currentPostTarget.replyToItem.apnMessage.channel_id, receiver, machineOnly: 0, reply_to: currentPostTarget.replyToItem.id, entities: entities, parse_links: true);
                            }
                        }
                        else
                        {
                            response = Messages.createPrivateMessage(AppController.Current.account.accessToken, toBePostedText, receiver, currentPostTarget.replyToItem.id, machineOnly: 0, entities: entities, parse_links: true);
                        }
                    }
                    else
                    {
                        if (currentPostTarget.channelId != null)
                        {
                            string channelId = currentPostTarget.channelId;
                            response = Messages.create(AppController.Current.account.accessToken, textbox_postText.Text, channelId, receiver, machineOnly: 0, parse_links: true);
                        }
                        else
                        {
                            response = Messages.createPrivateMessage(AppController.Current.account.accessToken, textbox_postText.Text, receiver, machineOnly: 0, parse_links: true);
                        }
                    }
                    if (response.Item2.success)
                    {
                        clear_postbox();
                    }
                    else
                    {
                        showErrorMessage(response.Item2);
                    }
                }
            }
        }