public async void TestMoveDown() { await SetUp(); var item = new ModulesItem(null); item.Name = "test"; item.Type = "test1"; item.IsManaged = true; _feature.AddItem(item); var last = 44; var previous = last - 1; _feature.SelectedItem = _feature.Items[previous]; var expected = "test"; Assert.Equal(expected, _feature.Items[last].Name); var original = "ScriptModule-4.0"; Assert.Equal(original, _feature.Items[previous].Name); _feature.MoveDown(); Assert.NotNull(_feature.SelectedItem); Assert.Equal(original, _feature.SelectedItem.Name); Assert.Equal(expected, _feature.Items[previous].Name); Assert.Equal(original, _feature.Items[last].Name); const string Expected = @"expected_up1.site.config"; const string ExpectedMono = @"expected_up.site.mono.config"; XmlAssert.Equal(Path.Combine("Modules", Helper.IsRunningOnMono() ? ExpectedMono : Expected), Current); XmlAssert.Equal(Path.Combine("Website1", "original.config"), Path.Combine("Website1", "web.config")); }
public void TestRevert() { SetUp(); const string Expected = @"expected_add.site.config"; var document = XDocument.Load(Current); document.Root?.Add( new XElement("location", new XAttribute("path", "WebSite1"), new XElement("system.webServer"))); document.Save(Expected); var item = new ModulesItem(null); item.Name = "test"; item.Type = "test1"; item.IsManaged = true; _feature.AddItem(item); _feature.Revert(); Assert.Null(_feature.SelectedItem); Assert.Equal(44, _feature.Items.Count); XmlAssert.Equal(Expected, Current); XmlAssert.Equal(Path.Combine("Website1", "original.config"), Path.Combine("Website1", "web.config")); }
void AddPublicModules(ModulesItem modulesItem) { if ((modulesItem.Type != ModulesType.Pubilc && modulesItem.Type != ModulesType.Keys) || CurrentPublicModules.Contains(modulesItem)) { return; } CurrentPublicModules.Add(modulesItem); var keyModulesItem = GetKeyModulesItem(modulesItem); if (keyModulesItem != null) { try { Generic.HotKeyHelper.Current.Set(keyModulesItem); MainWindowModules.Current.SetKeys(keyModulesItem); } catch (NotImplementedException ex) { MessageBoxDialog.Show(ex.Message); } catch (Exception) { } } }
public void TestAdd() { SetUp(); const string Expected = @"expected_add.site.config"; var document = XDocument.Load(Current); var node = new XElement("location"); node.SetAttributeValue("path", "WebSite1"); document.Root?.Add(node); var web = new XElement("system.webServer"); node.Add(web); var content = new XElement("modules"); web.Add(content); var add = new XElement("add"); add.SetAttributeValue("name", "test"); add.SetAttributeValue("type", "test1"); content.Add(add); document.Save(Expected); var item = new ModulesItem(null); item.Name = "test"; item.Type = "test1"; item.IsManaged = true; _feature.AddItem(item); Assert.NotNull(_feature.SelectedItem); Assert.Equal("test", _feature.SelectedItem.Name); XmlAssert.Equal(Expected, Current); XmlAssert.Equal(Path.Combine("Website1", "original.config"), Path.Combine("Website1", "web.config")); }
public void TestAdd() { SetUp(); const string Expected = @"expected_add.config"; var document = XDocument.Load(Current); var node = document.Root?.XPathSelectElement("/configuration/location[@path='']/system.webServer/modules"); node?.FirstNode?.Remove(); // remove comment node?.Add( new XElement("add", new XAttribute("name", "test"), new XAttribute("type", "test"))); document.Save(Expected); var item = new ModulesItem(null); item.Name = "test"; item.Type = "test"; item.IsManaged = true; _feature.AddItem(item); Assert.NotNull(_feature.SelectedItem); Assert.Equal("test", _feature.SelectedItem.Name); Assert.Equal(45, _feature.Items.Count); XmlAssert.Equal(Expected, Current); }
public async void TestEdit() { await this.SetUp(); var item = new ModulesItem(null); item.Name = "test"; item.Type = "test2"; item.IsManaged = true; _feature.AddItem(item); Assert.Equal("test", _feature.SelectedItem.Name); Assert.Equal(45, _feature.Items.Count); item.Type = "test"; _feature.EditItem(item); Assert.NotNull(_feature.SelectedItem); Assert.Equal("test", _feature.SelectedItem.Type); Assert.Equal(45, _feature.Items.Count); const string Expected = @"expected_edit1.site.config"; const string ExpectedMono = @"expected_edit1.site.mono.config"; XmlAssert.Equal(Path.Combine("Modules", Helper.IsRunningOnMono() ? ExpectedMono : Expected), Current); XmlAssert.Equal(Path.Combine("Website1", "original.config"), Path.Combine("Website1", "web.config")); }
public void TestRemove() { SetUp(); const string Expected = @"expected_add.site.config"; var document = XDocument.Load(Current); var node = new XElement("location"); node.SetAttributeValue("path", "WebSite1"); document.Root?.Add(node); document.Save(Expected); var item = new ModulesItem(null); item.Name = "test"; _feature.AddItem(item); Assert.Equal("test", _feature.SelectedItem.Name); Assert.Equal(45, _feature.Items.Count); _feature.Remove(); Assert.Null(_feature.SelectedItem); Assert.Equal(44, _feature.Items.Count); XmlAssert.Equal(Expected, Current); XmlAssert.Equal(Path.Combine("Website1", "original.config"), Path.Combine("Website1", "web.config")); }
public void TestMoveDown() { SetUp(); const string Expected = @"expected_add.site.config"; var document = XDocument.Load(Current); var node = new XElement("location"); node.SetAttributeValue("path", "WebSite1"); document.Root.Add(node); var web = new XElement("system.webServer"); node.Add(web); var content = new XElement("modules"); web.Add(content); var clear = new XElement("remove"); clear.SetAttributeValue("name", "ScriptModule-4.0"); content.Add(clear); var add = new XElement("add"); add.SetAttributeValue("name", "test"); add.SetAttributeValue("type", "test1"); content.Add(add); var one = new XElement("add"); one.SetAttributeValue("preCondition", "managedHandler,runtimeVersionv4.0"); one.SetAttributeValue("name", "ScriptModule-4.0"); one.SetAttributeValue("type", "System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"); content.Add(one); document.Save(Expected); var item = new ModulesItem(null); item.Name = "test"; item.Type = "test1"; item.IsManaged = true; _feature.AddItem(item); var last = 44; var previous = last - 1; _feature.SelectedItem = _feature.Items[previous]; var expected = "test"; Assert.Equal(expected, _feature.Items[last].Name); var original = "ScriptModule-4.0"; Assert.Equal(original, _feature.Items[previous].Name); _feature.MoveDown(); Assert.NotNull(_feature.SelectedItem); Assert.Equal(original, _feature.SelectedItem.Name); Assert.Equal(expected, _feature.Items[previous].Name); Assert.Equal(original, _feature.Items[last].Name); XmlAssert.Equal(Expected, Current); XmlAssert.Equal(Path.Combine("Website1", "original.config"), Path.Combine("Website1", "web.config")); }
private void InitPublicModules() { //隐藏全部窗体 var modulesItem_HideAllWindows = new ModulesItem(this, PublicModulesKeys.HideAllWindows, string.Format("{0}{1}", TextResource.Hide, TextResource.AllWindow)); modulesItem_HideAllWindows.Type = ModulesType.Keys; modulesItem_HideAllWindows.Register(HideAllWindows); PublicModules.Current.Add(modulesItem_HideAllWindows); //显示全部窗体 var modulesItem_ShowAllWindows = new ModulesItem(this, PublicModulesKeys.ShowAllWindows, string.Format("{0}{1}", TextResource.Show, TextResource.AllWindow)); modulesItem_ShowAllWindows.Type = ModulesType.Keys; modulesItem_ShowAllWindows.Register(ShowAllWindows); PublicModules.Current.Add(modulesItem_ShowAllWindows); //显示隐藏全部窗体 var modulesItem_ChangeAllWindowsByMainWindow = new ModulesItem(this, PublicModulesKeys.ChangeAllWindowsByMainWindow, string.Format("{0}/{1}{2}", TextResource.Show, TextResource.Hide, TextResource.AllWindow)); modulesItem_ChangeAllWindowsByMainWindow.Register(ChangeAllWindowsByMainWindow); PublicModules.Current.Add(modulesItem_ChangeAllWindowsByMainWindow); //切换tabs var modulesItem_ChangeTabs = new ModulesItem(this, PublicModulesKeys.ChangeTabs, TextResource.ChangeTabs); modulesItem_ChangeTabs.Type = ModulesType.Keys; modulesItem_ChangeTabs.Register(WindowViewModules.Current.WindowViewHelper.ChangeTabs); PublicModules.Current.Add(modulesItem_ChangeTabs); //开关声音 var modulesItem_ToggleMute = new ModulesItem(this, PublicModulesKeys.ToggleMute, TextResource.ToggleMute); modulesItem_ToggleMute.Type = ModulesType.Keys; modulesItem_ToggleMute.Register(ToggleMute); PublicModules.Current.Add(modulesItem_ToggleMute); //截图 var modulesItem_TakeScreenshot = new ModulesItem(this, PublicModulesKeys.TakeScreenshot, TextResource.Screenshot); modulesItem_TakeScreenshot.Type = ModulesType.Keys; modulesItem_TakeScreenshot.Register(TakeScreenshot); PublicModules.Current.Add(modulesItem_TakeScreenshot); //舰娘一览 var modulesItem_ShowShipCatalog = new ModulesItem(this, PublicModulesKeys.ShowShipCatalog, TextResource.ShowShipCatalog); modulesItem_ShowShipCatalog.Register(ShowShipCatalog); PublicModules.Current.Add(modulesItem_ShowShipCatalog); //装备一览 var modulesItem_ShowSlotItemCatalog = new ModulesItem(this, PublicModulesKeys.ShowSlotItemCatalog, TextResource.ShowSlotItemCatalog); modulesItem_ShowSlotItemCatalog.Register(ShowSlotItemCatalog); PublicModules.Current.Add(modulesItem_ShowSlotItemCatalog); }
public Models.KeyModulesItem GetKeyModulesItem(ModulesItem modulesItem) { var key = modulesItem.ModulesKey; var keySetting = Setting.Get(key) ?? new Models.KeySetting { ModulesKey = key, IsNotSetKey = true }; return(new Models.KeyModulesItem { ModulesItem = modulesItem, KeySetting = keySetting }); }
public Models.KeyModulesItem GetKeyModulesItem(ModulesItem modulesItem) { var key = modulesItem.ModulesKey; var keySetting = Setting.Get(key) ?? new Models.KeySetting { ModulesKey = key, IsNotSetKey = true }; return new Models.KeyModulesItem { ModulesItem = modulesItem, KeySetting = keySetting }; }
void InitPublicModules() { var modulesItem_EnableSimpleFleet = new ModulesItem( this, PublicModulesKeys.EnableSimpleFleet, string.Format("{0}/{1}{2}", TextResource.Show, TextResource.Hide, TextResource.SimpleFleet)); modulesItem_EnableSimpleFleet.Register(ShowHideSimpleFleet); PublicModules.Current.Add(modulesItem_EnableSimpleFleet); var modulesItem_GhostSimpleFleet = new ModulesItem( this, PublicModulesKeys.GhostSimpleFleet, string.Format("{0}{1}", TextResource.SimpleFleet, TextResource.ChangeGhostMode)); modulesItem_GhostSimpleFleet.Register(GhostSimpleFleet); PublicModules.Current.Add(modulesItem_GhostSimpleFleet); }
public async void TestAdd() { await this.SetUp(); const string Expected = @"expected_add.config"; const string ExpectedMono = @"expected_add.mono.config"; var item = new ModulesItem(null); item.Name = "test"; item.Type = "test"; item.IsManaged = true; _feature.AddItem(item); Assert.NotNull(_feature.SelectedItem); Assert.Equal("test", _feature.SelectedItem.Name); Assert.Equal(45, _feature.Items.Count); XmlAssert.Equal( Helper.IsRunningOnMono() ? Path.Combine("Modules", ExpectedMono) : Path.Combine("Modules", Expected), Current); }
void AddPublicModules(ModulesItem modulesItem) { if ((modulesItem.Type != ModulesType.Pubilc && modulesItem.Type != ModulesType.NotifyIcon) || CurrentPublicModules.Contains(modulesItem)) { return; } CurrentPublicModules.Add(modulesItem); var menuItem = new winforms.MenuItem { Text = modulesItem.ModulesName, Tag = modulesItem.ModulesKey }; menuItem.Click += (sender, e) => MessagerModules.Current.Send(modulesItem.MessageKey); modulesItem.RegisterEnabelChangeCallbck(isenabel => menuItem.Enabled = isenabel); contextMenu.MenuItems.Add(menuItem); //-,-为了将退出项移到最后一个 contextMenu.MenuItems.Remove(exitItem); contextMenu.MenuItems.Add(exitItem); }