示例#1
0
        public TitledList(string title, ConnectedInterface connected, Func <int, Tuple <int, Label> > entryPrefix, Label titlePrefix, int titleOffsetFromPrefix, Action <int> selectCallback, Func <int, bool> checkShouldWhite)
        {
            checkShouldWhiteCallback = checkShouldWhite;

            Controls.Add(titlePrefix);
            InitializeComponent();
            this.title.Text      = title;
            this.title.Font      = new Font(CustomFonts.Fonts.Families[1], 10);
            this.title.ForeColor = Color.FromArgb(0xab, 0x9b, 0xa9);
            entryPrefixCallback  = entryPrefix;
            this.titlePrefix     = titlePrefix;
            if (this.titlePrefix != null)
            {
                this.titlePrefix.Location  = new Point(0, this.title.Location.Y);
                this.titlePrefix.Size      = new Size(this.titlePrefix.PreferredSize.Width + 16, this.title.Height);
                this.titlePrefix.TextAlign = ContentAlignment.MiddleRight;
                this.title.Location        = new Point(titlePrefix.Right + titleOffsetFromPrefix, this.title.Location.Y);
            }
            else
            {
                this.title.Location = new Point(16, this.title.Location.Y);
            }
            this.title.Width = 180 - this.title.Location.X;

            this.selectCallback = selectCallback;
        }
示例#2
0
        void AuthSignIn()
        {
            EventWaitHandle wait = new EventWaitHandle(false, EventResetMode.ManualReset);
            SlackSocketClient client = new SlackSocketClient(token);
            client.OnHello += () =>
            {
                wait.Set();
            };
            client.Connect((l) =>
            {

                if (!l.ok) return;

                BeginInvoke(new Action(() =>
                {
                    connected = new ConnectedInterface(client, l);
                    connected.Dock = DockStyle.Fill;

                    Controls.Add(connected);

                    password.Visible = false;
                }));
            });
            wait.WaitOne();
        }
示例#3
0
        void AuthSignIn()
        {
            EventWaitHandle   wait   = new EventWaitHandle(false, EventResetMode.ManualReset);
            SlackSocketClient client = new SlackSocketClient(token);

            client.OnHello += () =>
            {
                wait.Set();
            };
            client.Connect((l) =>
            {
                if (!l.ok)
                {
                    return;
                }

                BeginInvoke(new Action(() =>
                {
                    connected      = new ConnectedInterface(client, l);
                    connected.Dock = DockStyle.Fill;

                    Controls.Add(connected);

                    password.Visible = false;
                }));
            });
            wait.WaitOne();
        }
示例#4
0
        public SlackChannelList(ConnectedInterface connected)
        {
            parent = connected;

            starred = new TitledList(
                "STARRED",
                connected, (c) => GetLabel(parent.Client.starredChannels[c]),
                new Label()
            {
                Text      = "\uF005",
                Font      = new Font(CustomFonts.Fonts.Families[0], 10),
                ForeColor = Color.FromArgb(0xab, 0x9b, 0xa9)
            },
                -2,
                (i) => SelectCallback(parent.Client.starredChannels[i]),
                (i) => true
                );

            channels = new TitledList(
                "CHANNELS",
                connected,
                (i) => GetLabel(parent.Client.Channels[i].id),
                null,
                0,
                (i) => SelectCallback(connected.Client.Channels[i].id),
                (i) => true
                );

            users = new TitledList(
                "DIRECT MESSAGES",
                connected,
                (i) => GetUserLabel(connected.Client.UserLookup[connected.Client.DirectMessages[i].user]),
                null,
                0,
                (i) => SelectCallback(connected.Client.DirectMessages[i].id),
                (i) => connected.Client.Users[i].presence.Equals("active", StringComparison.InvariantCultureIgnoreCase)
                );

            groups = new TitledList(
                "PRIVATE GROUPS",
                connected, (i) => GetLabel(connected.Client.Groups[i].id),
                null,
                0,
                (i) => SelectCallback(connected.Client.Groups[i].id),
                (i) => true
                );

            Controls.AddRange(new Control[] { starred, channels, users, groups });

            FlushDimensions();

            this.AutoScroll = true;

            parent.Client.BindCallback <PresenceChange>((r) =>
                                                        BeginInvoke(new Action(UpdatePresences))
                                                        );
        }
示例#5
0
        public SlackChannelList(ConnectedInterface connected)
        {
            parent = connected;

            starred = new TitledList(
                "STARRED",
                connected, (c) => GetLabel(parent.Client.starredChannels[c]),
                new Label()
                {
                    Text = "\uF005",
                    Font = new Font(CustomFonts.Fonts.Families[0], 10),
                    ForeColor = Color.FromArgb(0xab, 0x9b, 0xa9)
                },
                -2,
                (i) => SelectCallback(parent.Client.starredChannels[i]),
                (i) => true
            );

            channels = new TitledList(
                "CHANNELS",
                connected,
                (i) => GetLabel(parent.Client.Channels[i].id),
                null,
                0,
                (i) => SelectCallback(connected.Client.Channels[i].id),
                (i) => true
            );

            users = new TitledList(
                "DIRECT MESSAGES",
                connected,
                (i) => GetUserLabel(connected.Client.UserLookup[connected.Client.DirectMessages[i].user]),
                null,
                0,
                (i) => SelectCallback(connected.Client.DirectMessages[i].id),
                (i) => connected.Client.Users[i].presence.Equals("active", StringComparison.InvariantCultureIgnoreCase)
            );

            groups = new TitledList(
                "PRIVATE GROUPS",
                connected, (i) => GetLabel(connected.Client.Groups[i].id),
                null,
                0,
                (i) => SelectCallback(connected.Client.Groups[i].id),
                (i) => true
            );

            Controls.AddRange(new Control[] { starred, channels, users, groups });

            FlushDimensions();

            this.AutoScroll = true;

            parent.Client.BindCallback<PresenceChange>((r) =>
                BeginInvoke(new Action(UpdatePresences))
            );
        }
示例#6
0
        public ChatInterface(MessagesAdapter adapter, ConnectedInterface connected)
        {
            this.connected = connected;
            this.adapter   = adapter;
            entries        = new List <MessageEntry>();
            Id             = adapter.GetId();

            messages   = new Font(CustomFonts.Fonts.Families[1], 11);
            timestamps = new Font(CustomFonts.Fonts.Families[1], 9);

            InitializeComponent();

            uploadFile.Font = new Font(CustomFonts.Fonts.Families[0], 18);
            textInput.Font  = new Font(CustomFonts.Fonts.Families[1], 11);

            string title = adapter.GetTitle();
            string topic = adapter.GetTopic();

            Label titleLabel = new Label();

            titleLabel.Text      = title;
            titleLabel.Location  = new Point(24, 0);
            titleLabel.Font      = new Font(CustomFonts.Fonts.Families[1], 16, FontStyle.Bold);
            titleLabel.Size      = new Size(titleLabel.PreferredWidth, 53);
            titleLabel.TextAlign = ContentAlignment.MiddleLeft;
            channelTitle.Controls.Add(titleLabel);

            sizes = new Dictionary <int, int>();

            MessageHistory history = adapter.GetMessages(null, null, null);

            lastTimeStamp = history.latest;

            bool firstFetch = lastMessage == null;

            foreach (SlackAPI.Message message in history.messages.Reverse())
            {
                AddMessage(message);
            }

            connected.Client.BindCallback <NewMessage>(Client_OnMessageReceived);
            //BeginInvoke(new Action(() => chatContent.AutoScrollPosition = new Point(lastMessage.Left, chatContent.DisplayRectangle.Height)));
        }
示例#7
0
        public ChatInterface(MessagesAdapter adapter, ConnectedInterface connected)
        {
            this.connected = connected;
            this.adapter = adapter;
            entries = new List<MessageEntry>();
            Id = adapter.GetId();

            messages = new Font(CustomFonts.Fonts.Families[1], 11);
            timestamps = new Font(CustomFonts.Fonts.Families[1], 9);

            InitializeComponent();

            uploadFile.Font = new Font(CustomFonts.Fonts.Families[0], 18);
            textInput.Font = new Font(CustomFonts.Fonts.Families[1], 11);

            string title = adapter.GetTitle();
            string topic = adapter.GetTopic();

            Label titleLabel = new Label();
            titleLabel.Text = title;
            titleLabel.Location = new Point(24, 0);
            titleLabel.Font = new Font(CustomFonts.Fonts.Families[1], 16, FontStyle.Bold);
            titleLabel.Size = new Size(titleLabel.PreferredWidth, 53);
            titleLabel.TextAlign = ContentAlignment.MiddleLeft;
            channelTitle.Controls.Add(titleLabel);

            sizes = new Dictionary<int, int>();

            MessageHistory history = adapter.GetMessages(null, null, null);

            lastTimeStamp = history.latest;

            bool firstFetch = lastMessage == null;
            foreach (SlackAPI.Message message in history.messages.Reverse())
                AddMessage(message);

            connected.Client.BindCallback<NewMessage>(Client_OnMessageReceived);
            //BeginInvoke(new Action(() => chatContent.AutoScrollPosition = new Point(lastMessage.Left, chatContent.DisplayRectangle.Height)));
        }
示例#8
0
        public TitledList(string title, ConnectedInterface connected, Func<int, Tuple<int, Label>> entryPrefix, Label titlePrefix, int titleOffsetFromPrefix, Action<int> selectCallback, Func<int, bool> checkShouldWhite)
        {
            checkShouldWhiteCallback = checkShouldWhite;

            Controls.Add(titlePrefix);
            InitializeComponent();
            this.title.Text = title;
            this.title.Font = new Font(CustomFonts.Fonts.Families[1], 10);
            this.title.ForeColor = Color.FromArgb(0xab, 0x9b, 0xa9);
            entryPrefixCallback = entryPrefix;
            this.titlePrefix = titlePrefix;
            if (this.titlePrefix != null)
            {
                this.titlePrefix.Location = new Point(0, this.title.Location.Y);
                this.titlePrefix.Size = new Size(this.titlePrefix.PreferredSize.Width + 16, this.title.Height);
                this.titlePrefix.TextAlign = ContentAlignment.MiddleRight;
                this.title.Location = new Point(titlePrefix.Right + titleOffsetFromPrefix, this.title.Location.Y);
            }
            else
                this.title.Location = new Point(16, this.title.Location.Y);
            this.title.Width = 180 - this.title.Location.X;

            this.selectCallback = selectCallback;
        }