コード例 #1
0
ファイル: TabContextShould.cs プロジェクト: GProulx/Glimpse
 public void Dispose()
 {
     RequestContext = null;
     PluginStoreMock = null;
     TabContext = null;
     Inspectors = null;
     LoggerMock = null;
 }
コード例 #2
0
ファイル: TabContextShould.cs プロジェクト: GProulx/Glimpse
        public void Construct()
        {
            var pluginStoreObj = PluginStoreMock.Object;
            var locator = new TabContext(RequestContext, pluginStoreObj, LoggerMock.Object, MessageBroker.Object);

            Assert.Equal(RequestContext, locator.GetRequestContext<DummyObjectContext>());
            Assert.Equal(pluginStoreObj, locator.TabStore);
        }
コード例 #3
0
        private void TabManager_OnTabChanged(TabManager sender, TabContext oldTab, TabContext newTab)
        {
            if (oldTab != null)
            {
                foreach (var toolbar in oldTab.Toolbars)
                {
                    ViewModel.ToolbarTray.Toolbars.Remove(toolbar);
                }
            }

            if (newTab != null)
            {
                foreach (var toolbar in newTab.Toolbars)
                {
                    ViewModel.ToolbarTray.Toolbars.Add(toolbar);
                }

                TabBindings[newTab].Select();
            }
        }
コード例 #4
0
        private void TabManager_OnAddedTab(TabManager sender, TabContext tabContext)
        {
            var tabViewModel = new TabCardViewModel()
            {
                Name = tabContext.Name, TabContent = tabContext.TabInternalControl
            };

            TabBindings[tabContext] = tabViewModel;

            tabViewModel.OnSelected += new TabCardViewModel.TabEventHandler(_ =>
            {
                ApplicationContext.TabManager.CurrentTab = tabContext;
            });
            tabViewModel.OnClose += new TabCardViewModel.TabEventHandler(_ =>
            {
                ApplicationContext.TabManager.Remove(tabContext);
            });

            ViewModel.TabManager.Tabs.Add(tabViewModel);
        }
コード例 #5
0
        /// <summary>
        /// Helper method to create a deep link to a given tab name.
        ///
        /// For more information, see: https://msdn.microsoft.com/en-us/microsoft-teams/deeplinks#generating-a-deep-link-to-your-tab-for-use-in-a-bot-or-connector-message
        ///
        /// </summary>
        /// <param name="context"></param>
        /// <param name="activity"></param>
        /// <param name="tabName"></param>
        /// <returns></returns>
        private async Task SendDeeplink(IDialogContext context, Activity activity, string tabName)
        {
            var teamsChannelData = activity.GetChannelData <TeamsChannelData>();
            var teamId           = teamsChannelData.Team.Id;
            var channelId        = teamsChannelData.Channel.Id;

            // The app ID, stored in the web.config file, should be the appID from your manifest.json file.
            var appId      = System.Configuration.ConfigurationManager.AppSettings["TeamsAppId"];
            var entity     = $"todotab-{tabName}-{teamId}-{channelId}"; // Match the entity ID we setup when configuring the tab
            var tabContext = new TabContext()
            {
                ChannelId = channelId,
                CanvasUrl = "https://teams.microsoft.com"
            };

            var url = $"https://teams.microsoft.com/l/entity/{HttpUtility.UrlEncode(appId)}/{HttpUtility.UrlEncode(entity)}?label={HttpUtility.UrlEncode(tabName)}&context={HttpUtility.UrlEncode(JsonConvert.SerializeObject(tabContext))}";

            var text = $"I've created a deep link to {tabName}! Click [here]({url}) to navigate to the tab.";
            await context.PostAsync(text);
        }
コード例 #6
0
        public void OpenBookmarkTab(ApplicationContext context)
        {
            var bookmarksTab = context.TabManager.Tabs.FirstOrDefault(t => t.TabControlType == Enums.TabControlType.Bookmarks);

            if (bookmarksTab == null)
            {
                bookmarksTab = new TabContext()
                {
                    Name               = "Bookmarks",
                    TabControlType     = Enums.TabControlType.Bookmarks,
                    FilePath           = null,
                    TabInternalControl = new BookmarksControl()
                    {
                        DataContext = new BookmarksViewModel(context)
                    },
                };
                context.TabManager.Add(bookmarksTab);
            }

            context.TabManager.CurrentTab = bookmarksTab;
        }
コード例 #7
0
ファイル: GlimpseRuntime.cs プロジェクト: rodius/Glimpse
        private void ExecuteTabs(RuntimeEvent runtimeEvent)
        {
            var runtimeContext = Configuration.FrameworkProvider.RuntimeContext;
            var frameworkProviderRuntimeContextType = runtimeContext.GetType();
            var messageBroker = Configuration.MessageBroker;

            // Only use tabs that either don't specify a specific context type, or have a context type that matches the current framework provider's.
            var runtimeTabs =
                Configuration.Tabs.Where(
                    tab =>
                    tab.RequestContextType == null ||
                    frameworkProviderRuntimeContextType.IsSubclassOf(tab.RequestContextType) ||
                    tab.RequestContextType == frameworkProviderRuntimeContextType);

            var supportedRuntimeTabs = runtimeTabs.Where(p => p.ExecuteOn.HasFlag(runtimeEvent));
            var tabResultsStore = TabResultsStore;
            var logger = Configuration.Logger;

            foreach (var tab in supportedRuntimeTabs)
            {
                TabResult result;
                var key = CreateKey(tab);
                try
                {
                    var tabContext = new TabContext(runtimeContext, GetTabStore(key), logger, messageBroker);
                    var tabData = tab.GetData(tabContext);

                    var tabSection = tabData as TabSection;
                    if (tabSection != null)
                    {
                        tabData = tabSection.Build();
                    }

                    result = new TabResult(tab.Name, tabData);
                }
                catch (Exception exception)
                {
                    result = new TabResult(tab.Name, exception.ToString());
                    logger.Error(Resources.ExecuteTabError, exception, key);
                }

                if (tabResultsStore.ContainsKey(key))
                {
                    tabResultsStore[key] = result;
                }
                else
                {
                    tabResultsStore.Add(key, result);
                }
            }
        }
コード例 #8
0
ファイル: GlimpseRuntime.cs プロジェクト: rodius/Glimpse
        private void ExecuteDisplays()
        {
            var runtimeContext = Configuration.FrameworkProvider.RuntimeContext;
            var messageBroker = Configuration.MessageBroker;

            var displayResultsStore = DisplayResultsStore;
            var logger = Configuration.Logger;

            foreach (var display in Configuration.Displays)
            {
                TabResult result; // TODO: Rename now that it is no longer *just* tab results
                var key = CreateKey(display);
                try
                {
                    var displayContext = new TabContext(runtimeContext, GetTabStore(key), logger, messageBroker); // TODO: Do we need a DisplayContext?
                    var displayData = display.GetData(displayContext);

                    result = new TabResult(display.Name, displayData);
                }
                catch (Exception exception)
                {
                    result = new TabResult(display.Name, exception.ToString());
                    logger.Error(Resources.ExecuteTabError, exception, key);
                }

                if (displayResultsStore.ContainsKey(key))
                {
                    displayResultsStore[key] = result;
                }
                else
                {
                    displayResultsStore.Add(key, result);
                }
            }
        }
コード例 #9
0
 private void TabManager_OnTabChanged(TabManager sender, TabContext oldTab, TabContext newTab)
 {
     CanExecuteChanged?.Invoke(this, new EventArgs());
 }
コード例 #10
0
 private void TabManager_OnRemovedTab(TabManager sender, TabContext tab)
 {
     ViewModel.TabManager.Tabs.Remove(TabBindings[tab]);
     TabBindings.Remove(tab);
 }
コード例 #11
0
ファイル: StartPageViewModel.cs プロジェクト: Aviuz/JsonFlier
 public void SetDeletionOnNewTab_OnTabAdded(TabManager tabManager, TabContext newTab)
 {
     tabManager.Remove(tabContext);
     tabManager.OnAddedTab -= SetDeletionOnNewTab_OnTabAdded;
 }
コード例 #12
0
ファイル: StartPageViewModel.cs プロジェクト: Aviuz/JsonFlier
 public void SetDeletionOnNewTab(TabManager tabManager, TabContext startPageTabContext)
 {
     tabManager.OnAddedTab += SetDeletionOnNewTab_OnTabAdded;
     tabContext             = startPageTabContext;
 }