public TabStripCreated(TabFactory itemFactory, string tabStripName, HtmlHelper html, object model = null) { this.TabStripName = tabStripName; this.Html = html; this.Model = model; this.ItemFactory = itemFactory; }
public void GivenExistingTabThatShouldBeUpdated_UpdateTabDefinitions_UpdatesTab() { MockRepository fakes = new MockRepository(); TabDefinitionUpdater tabDefinitionUpdater = TabDefinitionUpdaterFactory.PartialMock(fakes); List <Tab> tabs = new List <Tab>(); Tab existingTab = new TestTab(); tabs.Add(existingTab); tabDefinitionUpdater.Stub(updater => updater.UpdateTabDefinition(Arg <TabDefinition> .Is.Anything, Arg <Tab> .Is.Anything)); TabFactory fakeTabFactory = fakes.Stub <TabFactory>(); tabDefinitionUpdater.TabFactory = fakeTabFactory; TabDefinition existingTabDefinition = TabDefinitionUpdaterTestsUtility.CreateTabDefinition(existingTab); tabDefinitionUpdater.TabFactory.Stub(factory => factory.GetTabDefinition(existingTab.Name)).Return(existingTabDefinition); tabDefinitionUpdater.TabFactory.Stub(factory => factory.SaveTabDefinition(Arg <TabDefinition> .Is.Anything)); tabDefinitionUpdater.TabFactory.Replay(); tabDefinitionUpdater.Stub(updater => updater.TabDefinitionShouldBeUpdated(existingTabDefinition, existingTab)).Return(true); tabDefinitionUpdater.Replay(); tabDefinitionUpdater.UpdateTabDefinitions(tabs); tabDefinitionUpdater.AssertWasCalled(updater => updater.UpdateTabDefinition(existingTabDefinition, existingTab)); tabDefinitionUpdater.TabFactory.AssertWasCalled(factory => factory.SaveTabDefinition(existingTabDefinition)); }
private TabDefinition GetTabDefinition(Tab tab) { TabDefinition tabDefinition = TabFactory.GetTabDefinition(tab.Name); if (tabDefinition == null) { tabDefinition = new TabDefinition(); } return(tabDefinition); }
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { TabInfo item = value as TabInfo; Grid g = new Grid(); Tab tab = ApplicationState.Stash[ApplicationState.CurrentLeague].Tabs.Find(t => t.i == item.ID); var tabControl = TabFactory.GenerateTab(tab, new List <IFilter>()); g.Children.Add(tabControl); return(g); }
public TabStripCreated(TabStripTagHelper tabStrip, TagHelperContext context) { Guard.NotNull(tabStrip, nameof(tabStrip)); TabStrip = tabStrip; TabFactory = new TabFactory(tabStrip, context); TabStripName = tabStrip.Id; Html = tabStrip.HtmlHelper; Model = tabStrip.ViewContext.ViewData.Model; }
public virtual void UpdateTabDefinitions(IEnumerable <Tab> tabs) { foreach (Tab tab in tabs) { TabDefinition tabDefinition = GetTabDefinition(tab); if (TabDefinitionShouldBeUpdated(tabDefinition, tab)) { UpdateTabDefinition(tabDefinition, tab); TabFactory.SaveTabDefinition(tabDefinition); } } }
private TabHostItemsSourceGenerator([NotNull] TabHost tabHost) { Should.NotBeNull(tabHost, "tabHost"); _tabHost = tabHost; _tabHost.Setup(); _tabToContent = new Dictionary <string, TabInfo>(); _tabFactory = new TabFactory(this); _itemTemplateProvider = new DataTemplateProvider(tabHost, AttachedMemberConstants.ItemTemplate, AttachedMemberConstants.ItemTemplateSelector); _contentTemplateProvider = new DataTemplateProvider(tabHost, AttachedMemberConstants.ContentTemplate, AttachedMemberConstants.ContentTemplateSelector); _selectedItemMember = BindingServiceProvider .MemberProvider .GetBindingMember(tabHost.GetType(), AttachedMemberConstants.SelectedItem, false, false); TryListenActivity(tabHost.Context); _tabHost.TabChanged += TabHostOnTabChanged; }
public MainW() { InitializeComponent(); tabs.AddPage(TabFactory.GetNewTabPage("管理目录", TabType.Content)); FileInfo info = new FileInfo("WorkDirectory.db"); if (info.Exists) { StreamReader r = info.OpenText(); workDirectory = r.ReadLine(); r.Close(); } //rjf.Clear(); }
//Todo: Get this to handle the premium tabs public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { if (value == null) { return(null); } cache = cache ?? new Dictionary <string, Grid>(); Item item = value as Item; string key = getKey(item); if (cache.ContainsKey(key)) { return(cache[key]); } int inventoryId = int.Parse(item.InventoryId.Replace("Stash", "")) - 1; Grid g = new Grid(); Tab tab = ApplicationState.Stash[ApplicationState.CurrentLeague].Tabs.Find(t => t.i == inventoryId); var tabControl = TabFactory.GenerateTab(tab, new List <IFilter>() { new ItemFilter(item) }); Image tabImage = getImage(tab, true); RowDefinition imageRow = new RowDefinition(); imageRow.Height = new GridLength(26); g.RowDefinitions.Add(imageRow); g.RowDefinitions.Add(new RowDefinition()); tabImage.SetValue(Grid.RowProperty, 0); tabControl.SetValue(Grid.RowProperty, 1); g.Children.Add(tabImage); g.Children.Add(tabControl); cache.Add(key, g); tabControl.ForceUpdate(); return(g); }
public void GivenExistingTab_UpdateTabDefinitions_DoesNotSaveTab() { MockRepository fakes = new MockRepository(); TabDefinitionUpdater tabDefinitionUpdater = TabDefinitionUpdaterFactory.Create(); List <Tab> tabs = new List <Tab>(); Tab existingTab = new TestTab(); tabs.Add(existingTab); TabFactory fakeTabFactory = fakes.Stub <TabFactory>(); tabDefinitionUpdater.TabFactory = fakeTabFactory; TabDefinition existingTabDefinition = TabDefinitionUpdaterTestsUtility.CreateTabDefinition(existingTab); tabDefinitionUpdater.TabFactory.Stub(factory => factory.GetTabDefinition(existingTab.Name)).Return(existingTabDefinition); tabDefinitionUpdater.TabFactory.Replay(); tabDefinitionUpdater.UpdateTabDefinitions(tabs); tabDefinitionUpdater.TabFactory.AssertWasNotCalled(factory => factory.SaveTabDefinition(Arg <TabDefinition> .Is.Anything)); }
public void GivenNewTab_UpdateTabDefinitions_SavesNewTabDefinition() { MockRepository fakes = new MockRepository(); TabDefinitionUpdater tabDefinitionUpdater = TabDefinitionUpdaterFactory.PartialMock(fakes); List <Tab> tabs = new List <Tab>(); Tab newTab = new TestTab(); tabs.Add(newTab); tabDefinitionUpdater.Stub(updater => updater.UpdateTabDefinition(Arg <TabDefinition> .Is.Anything, Arg <Tab> .Is.Anything)); tabDefinitionUpdater.Replay(); TabFactory fakeTabFactory = fakes.Stub <TabFactory>(); tabDefinitionUpdater.TabFactory = fakeTabFactory; tabDefinitionUpdater.TabFactory.Stub(factory => factory.GetTabDefinition(newTab.Name)).Return(null); tabDefinitionUpdater.TabFactory.Stub(factory => factory.SaveTabDefinition(Arg <TabDefinition> .Is.Anything)); tabDefinitionUpdater.TabFactory.Replay(); tabDefinitionUpdater.UpdateTabDefinitions(tabs); tabDefinitionUpdater.AssertWasCalled(updater => updater.UpdateTabDefinition(Arg <TabDefinition> .Is.NotNull, Arg <Tab> .Matches(tab => tab == newTab))); tabDefinitionUpdater.TabFactory.AssertWasCalled(factory => factory.SaveTabDefinition(Arg <TabDefinition> .Is.NotNull)); }
public static IHtmlContent LocalizedEditor <TModel, TLocalizedModelLocal>(this IHtmlHelper <TModel> helper, string name, Func <int, HelperResult> localizedTemplate, Func <TModel, HelperResult> masterTemplate) where TModel : ILocalizedModel <TLocalizedModelLocal> where TLocalizedModelLocal : ILocalizedLocaleModel { var locales = helper.ViewData.Model.Locales; var hasMasterTemplate = masterTemplate != null; if (locales.Count > 1) { var services = helper.ViewContext.HttpContext.RequestServices; var db = services.GetRequiredService <SmartDbContext>(); var languageService = services.GetRequiredService <ILanguageService>(); var localizationService = services.GetRequiredService <ILocalizationService>(); var tabs = new List <TabItem>(locales.Count + 1); var languages = new List <Language>(locales.Count + 1); // Create the parent tabstrip var strip = new TabStripTagHelper { ViewContext = helper.ViewContext, Id = name, SmartTabSelection = false, Style = TabsStyle.Tabs, PublishEvent = false }; if (hasMasterTemplate) { var masterLanguage = db.Languages.FindById(languageService.GetMasterLanguageId(), false); languages.Add(masterLanguage); // Add the first default tab for the master template tabs.Add(new TabItem { Selected = true, Text = localizationService.GetResource("Admin.Common.Standard") }); } // Add all language specific tabs for (var i = 0; i < locales.Count; i++) { var locale = locales[i]; var language = db.Languages.FindById(locale.LanguageId, false); languages.Add(language); tabs.Add(new TabItem { Selected = !hasMasterTemplate && i == 0, Text = language.Name, ImageUrl = "~/images/flags/" + language.FlagImageFileName }); } // Create TagHelperContext for tabstrip. var stripContext = new TagHelperContext("tabstrip", new TagHelperAttributeList(), new Dictionary <object, object>(), CommonHelper.GenerateRandomDigitCode(10)); // Must init tabstrip, otherwise "Parent" is null inside tab helpers. strip.Init(stripContext); // Create tab factory var tabFactory = new TabFactory(strip, stripContext); // Create AttributeList for tabstrip var stripOutputAttrList = new TagHelperAttributeList { new TagHelperAttribute("class", "nav-locales") }; // Emulate tabstrip output var stripOutput = new TagHelperOutput("tabstrip", stripOutputAttrList, (_, _) => { // getChildContentAsync for tabstrip for (var i = 0; i < tabs.Count; i++) { var isMaster = hasMasterTemplate && i == 0; var language = languages[i]; tabFactory.AddAsync(builder => { builder.Item = tabs[i]; builder .Content(isMaster ? masterTemplate(helper.ViewData.Model) : localizedTemplate(i - 1)) .HtmlAttributes("title", language.Name, !isMaster) .ContentHtmlAttributes(new { @class = "locale-editor-content", data_lang = language.LanguageCulture, data_rtl = language.Rtl.ToString().ToLower() }); }).GetAwaiter().GetResult(); } // We don't need the child content for tabstrip. It builds everything without any child content. return(Task.FromResult <TagHelperContent>(new DefaultTagHelperContent())); }); // Process parent tabstrip strip.ProcessAsync(stripContext, stripOutput).GetAwaiter().GetResult(); var wrapper = new TagBuilder("div"); wrapper.Attributes.Add("class", "locale-editor"); return(stripOutput.WrapElementWith(wrapper)); } else if (hasMasterTemplate) { return(masterTemplate(helper.ViewData.Model)); } return(HtmlString.Empty); }
internal TabHostItemsSourceGenerator([NotNull] TabHost tabHost) { Should.NotBeNull(tabHost, "tabHost"); TabHost = tabHost; TabHost.Setup(); _tabToContent = new Dictionary<string, TabInfo>(); _tabFactory = new TabFactory(this); _itemTemplateProvider = new DataTemplateProvider(tabHost, AttachedMemberConstants.ItemTemplate, AttachedMemberConstants.ItemTemplateSelector); _contentTemplateProvider = new DataTemplateProvider(tabHost, AttachedMemberConstants.ContentTemplate, AttachedMemberConstants.ContentTemplateSelector); _selectedItemMember = BindingServiceProvider .MemberProvider .GetBindingMember(tabHost.GetType(), AttachedMemberConstants.SelectedItem, false, false); TryListenActivity(tabHost.Context); TabHost.TabChanged += TabHostOnTabChanged; }
protected override void ExecuteTest() { tabFactory = new TabFactory(); result = tabFactory.CreateAllTabs(GetProvidedDataState()); }
private void 查重窗口ToolStripMenuItem_Click(object sender, EventArgs e) { tabs.AddPage(TabFactory.GetNewTabPage("查重窗口", TabType.Duplicate)); }
private void 目录窗口ToolStripMenuItem_Click(object sender, EventArgs e) { tabs.AddPage(TabFactory.GetNewTabPage("草草草草草草草草草草", TabType.Content)); }