Beispiel #1
0
        public void addNewChapperCollection(IChapperCollection collection, bool switchToThisTab = false)
        {
            string tabName = collection.id;

            if (!tabName.StartsWith("conversation"))
            {
                tabName = "channel_" + tabName;
            }
            string icon_source = null;

            if (collection.GetType() == typeof(PatterRoom))
            {
                icon_source = "header_patter";
            }
            else if (collection.GetType() == typeof(PrivateMessageChannel))
            {
                icon_source = "header_pms";
            }
            else
            {
                icon_source = "header_messageroom";
                System.Windows.Controls.TabItem tabitem = mainwindow.addTabControlWithListOfItems(collection.displayName, tabName, collection.items, iconSource: icon_source, showCloseButton: true);
                tabitem.DataContext = collection;
                if (switchToThisTab)
                {
                    mainwindow.tabControl_main.SelectedItem = tabitem;
                }
            }
        }
Beispiel #2
0
        private void button_delete_Click(object sender, RoutedEventArgs e)
        {
            Item item = this.DataContext as Item;

            if (item != null)
            {
                if (item.apnMessage != null)
                {
                    Messages.delete(AppController.Current.account.accessToken, item.apnMessage.channel_id, item.apnMessage.id);
                    try
                    {
                        if (AppController.Current.account.privateMessages.Contains(item))
                        {
                            AppController.Current.account.privateMessages.Remove(item);
                        }
                        else
                        {
                            IChapperCollection collection = AppController.Current.account.allNonPrivateMessagesChannels.Where(i => i.id == item.apnMessage.channel_id).First();
                            if (collection != null)
                            {
                                collection.items.Remove(item);
                            }
                        }
                    }
                    catch { }
                }
                else if (item.apnPost != null)
                {
                    Posts.delete(AppController.Current.account.accessToken, item.apnPost.id);
                    try
                    {
                        if (AppController.Current.account.myStream.Contains(item))
                        {
                            AppController.Current.account.myStream.Remove(item);
                        }
                        if (AppController.Current.account.mentions.Contains(item))
                        {
                            AppController.Current.account.mentions.Remove(item);
                        }
                    }
                    catch { }
                }
            }
        }
Beispiel #3
0
        public void updateCurrentTarget(bool dontDetectTab = false)
        {
            TabItem tabitem = tabControl_main.SelectedItem as TabItem;

            if (tabitem != null)
            {
                textblock_enterPostHere.Text = "Enter your post...";
                if (currentPostTarget.isPm)
                {
                    textblock_enterPostHere.Text = "Enter your private message...";
                }
                textblock_composeOverlay.Text = "";
                lastTab    = currentTab;
                currentTab = tabitem;
                if (tabitem.Name.StartsWith("user_") && !dontDetectTab && string.IsNullOrEmpty(textbox_postText.textBoxContent.Text))
                {
                    User user = tabitem.DataContext as User;
                    textbox_postText.textBoxContent.Text = "@" + user.username + " ";
                }
                else if (tabitem.Name.StartsWith("channel_") && !dontDetectTab)
                {
                    IChapperCollection collection = tabitem.DataContext as IChapperCollection;
                    currentPostTarget.channelName = collection.displayName;
                    currentPostTarget.channelId   = tabitem.Name;
                    textblock_composeOverlay.Text = "Send message to " + collection.displayName;
                    textblock_enterPostHere.Text  = "Enter your message...";
                }
                else if (tabitem.Name == "tabItem_patter" && !dontDetectTab)
                {
                    PatterRoom patterRoom = combobox_patterrooms.SelectedItem as PatterRoom;
                    if (patterRoom != null)
                    {
                        currentPostTarget.channelName = patterRoom.displayName;
                        currentPostTarget.channelId   = patterRoom.id;
                        textblock_composeOverlay.Text = "Send message to Patter room " + patterRoom.displayName;
                        textblock_enterPostHere.Text  = "Enter your message...";
                    }
                    else
                    {
                        textblock_composeOverlay.Text = "Error getting channel name";
                    }
                }
                else if (tabitem.Name == "tabItem_pm" && !dontDetectTab)
                {
                    PrivateMessageChannel privateMessageChannel = combobox_private_message_channel.SelectedItem as PrivateMessageChannel;
                    if (privateMessageChannel != null)
                    {
                        currentPostTarget.channelName = privateMessageChannel.displayName;
                        currentPostTarget.channelId   = privateMessageChannel.id;
                        textblock_composeOverlay.Text = "Send private message to " + privateMessageChannel.displayName;
                        textblock_enterPostHere.Text  = "Enter your message...";
                    }
                    else
                    {
                        textblock_composeOverlay.Text = "Error getting channel name";
                    }
                }
                else
                {
                    currentPostTarget.channelName = null;
                    currentPostTarget.channelId   = null;
                    if (currentPostTarget.pmToUser != null)
                    {
                        textblock_composeOverlay.Text = "Write private message to @" + currentPostTarget.pmToUser.username;
                        textblock_enterPostHere.Text  = "Enter your message...";
                    }
                    if (currentPostTarget.replyToItem != null)
                    {
                        textblock_composeOverlay.Text = "Write reply post to @" + currentPostTarget.replyToItem.user.username;
                    }
                    else
                    {
                        textblock_composeOverlay.Text = "";
                    }
                }

                if (currentPostTarget.channelName != null)
                {
                    maxNumberOfChars = AppController.Current.account.configuration.message.text_max_length;
                }
                else
                {
                    maxNumberOfChars = AppController.Current.account.configuration.post.text_max_length;
                }

                textbox_postText_TextChanged_1(null, null);
            }
        }