Ejemplo n.º 1
0
        private void StartPlugin()
        {
            this.Controls.Clear();

            tip = new ToolTip();

            Settings.LoadSettings();

            noticePanel = new NoticePanel();
            this.Controls.Add(noticePanel);

            ts = new TwittwerService("822113440844148738-s7MLex2gcSFKxzKZfBDwcwJqvJYk0LA", "8UYP6Ahmn5GjJXkr0bN3Jy2XmKBX8jT3Slxk8EhzLCEmO"); //   (Settings.ast, Settings.atn);

            ts.onAuthorized += (s1, s2) => {
                Settings.ast = s1;
                Settings.atn = s2;
            };

            if (!ts.Connected)
            {
                connectionPanel           = new ConnectionPanel();
                connectionPanel.OnConnect = OnConnect;
                Controls.Add(connectionPanel);
            }
            else
            {
                this.Controls.Add(CreateTweetPanel());
                AutoTweet.Run(PlatformEngine);
            }
        }
Ejemplo n.º 2
0
        public TweetPanel(User tweetUser, NETSDK platformEngine, Dictionary <EventType, bool> set)
        {
            this.DoubleBuffered = true;

            PlatformEngine = platformEngine;
            this.user      = tweetUser;
            this.Dock      = DockStyle.Fill;

            ctss = new System.Threading.CancellationTokenSource();
            ct   = ctss.Token;

            if (set != null)
            {
                settings = Settings.Set;
            }

            Populate();

            tweetBtn.Click += (o, e) =>
            {
                if (OnTweet != null)
                {
                    MM();
                }
            };

            tweetText.KeyDown += MessageText_KeyDown;

            tweetText.TextChanged += (o, e) =>
            {
                var length = tweetText.TextLength;
                tweetBtn.Text      = BTN_TEXT + " [" + (length) + "]";
                tweetBtn.Enabled   = length > 0 && length <= MAX_TWEET_LENGTH;
                tweetBtn.BackColor = (tweetBtn.Enabled) ? Settings.mainFontColor : Color.Gray;
            };

            statusPanel.onLogoutClicked = () =>
            {
                if (OnLogout != null)
                {
                    OnLogout.Invoke();
                }
            };

            statusPanel.onSettingsClicked = () =>
            {
                settingsPanel.ShowSet();
                // await M();
            };

            statusPanel.onAutoTweetClicked = () =>
            {
                if (!settingsPanel.HasEvents)
                {
                    statusPanel.AutoTweet = false;
                    ShowNotice("There is no events to tweet!");
                    return;
                }

                statusPanel.AutoTweet = !statusPanel.AutoTweet;

                if (OnAutoTweetToggle != null)
                {
                    OnAutoTweetToggle.Invoke(statusPanel.AutoTweet);
                }

                ShowNotice((statusPanel.AutoTweet) ? "AutoTweet Enabled!" : "AutoTweet Disabled!");

                if (statusPanel.AutoTweet)
                {
                    AutoTweet.OnAutoTweetSend    += ShowNotice;
                    AutoTweet.OnAutoTweetRespond += ShowNotice;
                }
                else
                {
                    AutoTweet.OnAutoTweetSend    -= ShowNotice;
                    AutoTweet.OnAutoTweetRespond -= ShowNotice;
                }
            };

            settingsPanel.OnApply = () =>
            {
                AutoTweet.LinkEvents();

                if (!settingsPanel.HasEvents)
                {
                    statusPanel.AutoTweet = false;
                    ShowNotice("AutoTweet Stopped!");
                    return;
                }

                foreach (EventType item in Enum.GetValues(typeof(EventType)))
                {
                    settings[item] = settingsPanel[item];
                }

                if (OnSettingsApplied != null)
                {
                    OnSettingsApplied.Invoke(settings);
                }

                ShowNotice("Settings applied!");
            };

            picPanel.OnMaxPics = () =>
            {
                ShowNotice("Only 4 pics are allowed for one tweet!");
            };
        }