Пример #1
0
        public MainWindow(IMessageContainer groupChat, CacheSession cacheSession, IPluginUIIntegration uiIntegration, bool classicStyle)
        {
            this.InitializeComponent();

            this.GroupChat     = groupChat;
            this.CacheSession  = cacheSession;
            this.UIIntegration = uiIntegration;
            this.ClassicStyle  = classicStyle;

            this.MessagesWithAttachments =
                this.CacheSession.CacheForGroupOrChat
                .AsEnumerable()
                .Where(m => m.Attachments.Count > 0)
                .OrderByDescending(m => m.CreatedAtTime);

            this.HttpListener = new HttpListener();
            this.HttpListener.Prefixes.Add($"http://+:80/Temporary_Listen_Addresses/{this.ServerId}/");
            this.HttpListener.Start();

            this.CancellationTokenSource = new CancellationTokenSource();
            Task.Run(this.RunServer, this.CancellationTokenSource.Token);

            Debug.WriteLine($"http://+:80/Temporary_Listen_Addresses/{this.ServerId}/");

            this.ScriptingHelper = new ObjectForScriptingHelper(this);
            this.webBrowser.ObjectForScripting = this.ScriptingHelper;

            this.webBrowser.Navigate($"http://127.0.0.1:80/Temporary_Listen_Addresses/{this.ServerId}/gallery.html");

            this.Title = $"Image Gallery for {this.GroupChat.Name}";
        }
        public MainWindowViewModel(IMessageContainer groupChat, CacheSession cacheSession, IPluginUIIntegration uIIntegration)
        {
            this.GroupChat     = groupChat;
            this.CacheSession  = cacheSession;
            this.UIIntegration = UIIntegration;

            var mostRecentGroupMessage  = this.CacheSession.CacheForGroupOrChat.OrderByDescending(m => m.CreatedAtUnixTime).First();
            var mostRecentGlobalMessage = this.CacheSession.GlobalCache.OrderByDescending(m => m.CreatedAtUnixTime).First();

            this.MaxNumWords           = 100;
            this.outputText            = "";
            this.phraseDictionary      = new Dictionary <GlobalUser, Dictionary <string, List <string> > >();
            this.phraseDictionaryLocal = new Dictionary <GlobalUser, Dictionary <string, List <string> > >();
            this.RegenerateOutput      = new RelayCommand(this.RegenerateChain);
            this.CopyOutput            = new RelayCommand(this.CopyOutputChain);
        }
Пример #3
0
        public Task Activated(IMessageContainer groupOrChat, CacheSession cacheSession, IPluginUIIntegration integration, Action <CacheSession> cleanup)
        {
            MainWindow mainWindow = new MainWindow(groupOrChat, cacheSession, integration, false);

            mainWindow.Closed += (s, e) =>
            {
                cleanup(cacheSession);
            };

            System.Windows.Application.Current.Dispatcher.Invoke(() =>
            {
                mainWindow.Show();
            });

            return(Task.CompletedTask);
        }
        public Task Activated(IMessageContainer groupOrChat, CacheSession cacheSession, IPluginUIIntegration integration, Action <CacheSession> cleanup)
        {
            var dataContext = new MainWindowViewModel(groupOrChat, cacheSession, integration);
            var window      = new MainWindow
            {
                DataContext = dataContext,
            };

            window.Closing += (s, e) =>
            {
                cleanup(cacheSession);
            };

            System.Windows.Application.Current.Dispatcher.Invoke(() =>
            {
                window.Show();
            });

            return(Task.CompletedTask);
        }
        public Task Activated(IMessageContainer groupOrChat, CacheSession cacheSession, IPluginUIIntegration integration, Action <CacheSession> cleanup)
        {
            var mainWindow = new MainWindow(); // application entry point
            var vm         = new MainWindowViewModel(groupOrChat, cacheSession);

            mainWindow.DataContext = vm;

            System.Windows.Application.Current.Dispatcher.Invoke(() =>
            {
                mainWindow.ShowDialog();
            });

            mainWindow.Closing += (s, e) =>
            {
                cleanup(cacheSession);
            };

            return(Task.CompletedTask);
        }