public IActionResult Setup(SetupModel model) { using (var context = new AdminPanelContext()) { context.Database.Migrate(); } _siteInformationManager.Add(new AddSiteInformationModel() { ProjectName = model.ProjectName, SmtPort = model.SmtPort, SmtpPassword = model.SmtpPassword, SmtpServer = model.SmtpServer, SmtpEnableSsl = model.SmtpEnableSsl, SmtpUserName = model.SmtpUserName, }); model.SelectedLanguages.ForEach(x => { _languageManager.Add(GetLang(x)); }); _userManager.Add(new AddUserModel() { Email = model.UserEmail, Name = model.UserName, Password = model.UserPassword, PasswordControl = model.UserPassword, Role = Role.Support, }); return(Ok(new { Redirect = Url.Action("Index") })); }
private void NewViewModel() { _context = new ModelContext(); _model = new SetupModel(_context); _viewModel = new SetupViewModel(_model, _context); _viewModel.RefreshPage(); }
public async Task <IActionResult> Execute([FromBody] SetupModel model) { var recipes = await _setupService.GetSetupRecipesAsync(); var setupContext = new SetupContext() { AdminEmail = model.Email, AdminPassword = model.Password, AdminUsername = model.UserName, SiteName = model.SiteName, SiteTimeZone = model.SiteTimeZone, Recipe = recipes.FirstOrDefault(e => e.Name == model.RecipeName), EnabledFeatures = null, ShellSettings = _shellSettings, Errors = new Dictionary <string, string>() }; if (!string.IsNullOrEmpty(_shellSettings["ConnectionString"])) { setupContext.DatabaseConnectionString = _shellSettings["ConnectionString"]; setupContext.DatabaseProvider = _shellSettings["DatabaseProvider"]; setupContext.DatabaseTablePrefix = _shellSettings["TablePrefix"]; } else { setupContext.DatabaseConnectionString = model.ConnectionString; setupContext.DatabaseProvider = model.DatabaseProvider; setupContext.DatabaseTablePrefix = model.TablePrefix; } var result = await _setupService.SetupAsync(setupContext); return(Json(new { result })); }
public MainWindow() { InitializeComponent(); setup = new SetupModel(); monitor = new MonitorModel(); statistics = new StatisticsModel(); listItems = new List <menuItem>(); listItems.Add(new menuItem() { enabled = true, text = "Border Setup" }); listItems.Add(new menuItem() { enabled = false, text = "Room Monitor" }); listItems.Add(new menuItem() { enabled = false, text = "Statistics" }); listItems.Add(new menuItem() { enabled = true, text = "Quit App" }); lbMenu.ItemsSource = listItems; }
public Setup(uint setupID) { // make simple setup if gfxobj if (setupID >> 24 == 0x1) { MakeSimpleSetup(setupID); BuildBoundingBox(); return; } _setup = DatManager.PortalDat.ReadFromDat <SetupModel>(setupID); Parts = new List <GfxObj>(); foreach (var part in _setup.Parts) { Parts.Add(GfxObjCache.Get(part)); } PlacementFrames = new List <Matrix>(); foreach (var placementFrame in _setup.PlacementFrames[0].AnimFrame.Frames) { PlacementFrames.Add(placementFrame.ToXna()); } BuildBoundingBox(); }
public async Task DoSetup([FromForm] SetupModel model) { if (Request.Form.Files.Count <= 0) { throw new Exception("未选择任何项目文件"); } var setupContext = new SetupContext { Name = string.IsNullOrEmpty(_engineSettings.Name) ? model.Name : _engineSettings.Name, EnabledFeatures = null,// 回头加上默认的 AdminUsername = model.UserName, AdminEmail = model.Email, AdminPassword = model.Password, Errors = new Dictionary <string, string>(), DatabaseConnectionString = string.IsNullOrEmpty(_engineSettings.ConnectionString) ? model.ConnectionString : _engineSettings.ConnectionString, DatabaseProvider = string.IsNullOrEmpty(_engineSettings.DatabaseProvider) ? model.DatabaseProvider : _engineSettings.DatabaseProvider, DatabaseTablePrefix = string.IsNullOrEmpty(_engineSettings.TablePrefix) ? model.TablePrefix : _engineSettings.TablePrefix, Project = await Task.FromResult(_projectReader.ReadDescriptor(new FormFileInfo(Request.Form.Files[0]))) }; await _setupService.SetupAsync(setupContext); if (setupContext.Errors.Any()) { foreach (var error in setupContext.Errors) { ModelState.AddModelError(error.Key, error.Value); } throw this.Exception(ModelState); } }
public override void OnUse(Player player) { string serverMessage = null; // validate within use range, taking into account the radius of the model itself, as well SetupModel csetup = SetupModel.ReadFromDat(PhysicsData.CSetup); float radiusSquared = (GameData.UseRadius + csetup.Radius) * (GameData.UseRadius + csetup.Radius); if (player.Location.SquaredDistanceTo(Location) >= radiusSquared) { serverMessage = "Your way to far away to trust, come closer and buy something or leave me alone!"; } else { // create the outbound server message serverMessage = "You Break it, you bought it!"; } // give player starting money var money = new GameMessagePrivateUpdatePropertyInt(player.Session, PropertyInt.CoinValue, 5000); player.Session.Network.EnqueueSend(money); var welcomemsg = new GameMessageSystemChat(serverMessage, ChatMessageType.Tell); // always send useDone event var sendUseDoneEvent = new GameEventUseDone(player.Session); player.Session.Network.EnqueueSend(welcomemsg, sendUseDoneEvent); player.Session.Network.EnqueueSend(new GameEventApproachVendor(player.Session, this.Guid.Full)); }
private void macEntered(object sender, KeyEventArgs e) { TextBox box = sender as TextBox; Regex rxMacAddress = new Regex(@"^[0-9a-fA-F]{2}(((:[0-9a-fA-F]{2}){5})|((:[0-9a-fA-F]{2}){5}))$"); SetupModel sm = (SetupModel)(this.DataContext); if (e.Key == Key.Return) { if ((!rxMacAddress.IsMatch(box.Text) || sm.macRepeated(box.Text.ToString())) && box.Text.Length != 0) { Storyboard redFlash = box.TryFindResource("redFlash") as Storyboard; box.Text = ""; redFlash.Begin(box); } else { BindingExpression binding = box.GetBindingExpression(TextBox.TextProperty); Keyboard.ClearFocus(); binding.UpdateSource(); sm.checkMacs(); } } }
public ActionResult Setup(SetupModel model) { if (ModelState.IsValid) { try { SettingsFile.WriteToFile(this.HttpContext.Server.MapPath("~/App_Data"), "amp_settings.cfg", new { ConnectionString = model.ConnectionString, ConnectionStringName = model.ConnectionStringName,IsConfigured=true }); AmphiprionCMSInitializer.Configuration.RefreshFileSettings(); if(model.ExecuteSql) _installer.Install(); _auth.AssignCMSAdministrator(model.Username, model.Password, model.EmailAddress); return Redirect(VirtualPathUtility.ToAbsolute("~/")); } catch (Exception ex) { ModelState.AddModelError("",ex); } } return View(model); }
public IActionResult Setup() { if (_isConfigured) { return(RedirectToAction("Index", "Home")); } var model = new SetupModel(); var(provider, connectionString) = _configuration.GetConnectionStringInfo(); model.DataBaseType = provider; model.DatabaseConnectionString = connectionString; model.SysAdminProfile = new SetupProfileModel { FirstName = "admin", Email = "*****@*****.**", LastName = "admin", Password = "******", ConfirmPassword = "******", UserName = "******" }; model.Organization = new SetupOrganizationViewModel { Name = "Indrivo" }; return(View(model)); }
public void NewAlgorithmModel() { NewModel(); SetupModel setupModel = _model.NewSetupModel(); setupModel.Initialize(); ParticipantsModel participantsModel = _model.NewParticipantsModel(); participantsModel.Initialize(); PreferencesModel preferencesModel = _model.NewPreferencesModel(); preferencesModel.Initialize(); AlgorithmModel algorithmModel = _model.NewAlgorithmModel(); algorithmModel.Initialize(); _context.AlgorithmsChanged = false; algorithmModel.CreateGaleShapleyAlgorithm(); Assert.AreEqual(1, _context.Algorithms.Count()); AlgorithmVisitor _visitor = new AlgorithmVisitor(null, () => Assert.Fail()); _visitor.Visit(_context.Algorithms[0].Element); Assert.IsTrue(_context.AlgorithmsChanged); }
private async Task <SetupResModel> Setup2Proxys(SetupModel setup) { SetupResModel res = new SetupResModel() { token = setup.token, code = 0, msg = "success", }; if (setup.changeType == ChangeType.Delete) { res.code = 3; res.msg = "B接口没有删除接口"; return(res); } // transProtocolId为key对group分类 // var proxyGroups = Util.RoutePageing(20, setup, g => g.transProtocolId); List <string> failedGroups = new List <string>(); var msgs = string.Empty; if (setup.objects.Length == 0) { return(res); } bool isSuccess = await SetupChangedEvent(setup); if (!isSuccess) { res.code = 1; res.msg += $"\r\n{cfg.AppSettings["MqttClientId"]}:failed," + msgs; } return(res); }
public override void OnUse(Player player) { string serverMessage = null; // validate within use range, taking into account the radius of the model itself, as well SetupModel csetup = SetupModel.ReadFromDat(this.PhysicsData.CSetup); float radiusSquared = (this.GameData.UseRadius + csetup.Radius) * (this.GameData.UseRadius + csetup.Radius); var motionSanctuary = new UniversalMotion(MotionStance.Standing, new MotionItem(MotionCommand.Sanctuary)); var animationEvent = new GameMessageUpdateMotion(player, player.Session, motionSanctuary); // This event was present for a pcap in the training dungeon.. Why? The sound comes with animationEvent... var soundEvent = new GameMessageSound(this.Guid, Sound.LifestoneOn, 1); if (player.Location.SquaredDistanceTo(this.Location) >= radiusSquared) { serverMessage = "You wandered too far to attune with the Lifestone!"; } else { player.SetCharacterPosition(PositionType.Sanctuary, player.Location); // create the outbound server message serverMessage = "You have attuned your spirit to this Lifestone. You will resurrect here after you die."; player.EnqueueMovementEvent(motionSanctuary, player.Guid); player.Session.Network.EnqueueSend(soundEvent); } var lifestoneBindMessage = new GameMessageSystemChat(serverMessage, ChatMessageType.Magic); // always send useDone event var sendUseDoneEvent = new GameEventUseDone(player.Session); player.Session.Network.EnqueueSend(lifestoneBindMessage, sendUseDoneEvent); }
private void NewModel() { _context = new ModelContext(); _model = new SetupModel(_context); _model.Initialize(); _context.SetupChanged = false; }
public void LoadData() { SaveData data; NewModel(); SetupModel setupModel = new SetupModel(_context); setupModel.Initialize(); ParticipantsModel participantsModel = new ParticipantsModel(_context); participantsModel.Initialize(); PreferencesModel preferencesModel = new PreferencesModel(_context); preferencesModel.Initialize(); AlgorithmModel algorithmModel = new AlgorithmModel(_context); algorithmModel.Initialize(); _model.SaveAsData(""); data = _persistence.MockData; NewModel(); _persistence.MockData = data; _model.LoadData(""); Assert.AreEqual(data, _persistence.Data); }
public ActionResult LoadMetaDataForm(SetupModel model) { if (model.SelectedMetadataStructureId == -1) { ModelState.AddModelError("SelectedMetadataStructureId", "Please select a metadata structure."); } if (ModelState.IsValid) { using (var metadataStructureManager = new MetadataStructureManager()) using (var entityManager = new EntityManager()) using (var researchPlanManager = new ResearchPlanManager()) { var md = metadataStructureManager.Repo.Get(a => a.Id == model.SelectedMetadataStructureId).FirstOrDefault(); //get entitytype var entityType = entityManager.FindByName("Publication"); if (md != null) { CreateTaskmanager taskManager = new CreateTaskmanager(); taskManager.AddToBus(CreateTaskmanager.METADATASTRUCTURE_ID, md.Id); taskManager.AddToBus(CreateTaskmanager.SAVE_WITH_ERRORS, true); taskManager.AddToBus(CreateTaskmanager.NO_IMPORT_ACTION, true); taskManager.AddToBus(CreateTaskmanager.INFO_ON_TOP_TITLE, "Edit Publication"); taskManager.AddToBus(CreateTaskmanager.INFO_ON_TOP_DESCRIPTION, "<p>Here you can enter metadata for your new dataset. The form varies according to the metadata structure you selected in the first step. Mandatory fields are indicated with an red asterisk. You can add, remove, or re - order elements(e.g.multiple Creators) using the buttons at the right.</p>"); // get existing researchPlan string researchPlanName = "Research plan"; ResearchPlan researchPlan = researchPlanManager.Repo.Get(r => researchPlanName.Equals(r.Title)).FirstOrDefault(); taskManager.AddToBus(CreateTaskmanager.RESEARCHPLAN_ID, researchPlan.Id); //create unstructured datastructure DataStructure dataStructure = CreateDataStructure("Publication") as UnStructuredDataStructure; taskManager.AddToBus(CreateTaskmanager.DATASTRUCTURE_ID, dataStructure.Id); HttpContext.Session["CreateDatasetTaskmanager"] = taskManager; setAdditionalFunctions(); var view = this.Render("DCM", "Form", "StartMetadataEditor", new RouteValueDictionary() { }); return(Content(view.ToHtmlString(), "text/html")); } else { return(Content("Metadata structure not exsits")); } } } else { return(Content("Metadata structure not exsits")); } }
// GET: Home public ActionResult Index() { SetupModel setup = new SetupModel(); setup.setUpSystem(); return(View()); }
public ActionResult Setup() { var setupModel = new SetupModel { HasAdminAccount = sqlMembership.HasAdminAccount() }; return(View(setupModel)); }
private void deleteMac(object obj, RoutedEventArgs e) { Button b = obj as Button; Board board = b.DataContext as Board; board.MAC = ""; SetupModel sm = (SetupModel)(this.DataContext); sm.checkMacs(); }
public Setup(uint setupID, FileTypes.ObjDesc objDesc, Dictionary <int, uint> customPaletteColors) { // make simple setup if gfxobj. These don't have if (setupID >> 24 == 0x1) { MakeSimpleSetup(setupID); BuildBoundingBox(); return; } _setup = DatManager.PortalDat.ReadFromDat <SetupModel>(setupID); Parts = new List <GfxObj>(); for (byte i = 0; i < _setup.Parts.Count; i++) { GfxObj gfxObj; if (objDesc.AnimPartChanges.TryGetValue(i, out var apChange)) { var gfxObjID = apChange.PartID; gfxObj = new GfxObj(gfxObjID, false); objDesc.TextureChanges.TryGetValue(i, out var tmChanges); gfxObj.LoadTextures(tmChanges, customPaletteColors, false); gfxObj.BuildPolygons(); } else { var gfxObjID = _setup.Parts[i]; gfxObj = new GfxObj(gfxObjID, false); gfxObj.LoadTextures(null, customPaletteColors); gfxObj.BuildPolygons(); } Parts.Add(gfxObj); } PlacementFrames = new List <Matrix>(); if (!_setup.PlacementFrames.TryGetValue((int)Placement.Resting, out var placementFrames)) { _setup.PlacementFrames.TryGetValue((int)Placement.Default, out placementFrames); } foreach (var placementFrame in placementFrames.AnimFrame.Frames) { PlacementFrames.Add(placementFrame.ToXna()); } BuildBoundingBox(); }
public IActionResult Index(SetupModel model = null) { if (CurrentSettings.IsInitialized) { return(RedirectToAction("Index", "Account")); } _setupManager.Initialize(); return(View(model ?? new SetupModel())); }
public async Task <IActionResult> Setup(SetupModel model) { var installResponse = await _installerService.InstallAsync(model); if (installResponse.IsSuccess) { return(RedirectToAction("Index", "Home")); } ModelState.AppendResultModelErrors(installResponse.Errors); return(View(model)); }
private void NewViewModel() { _context = new ModelContext(); _model = new ParticipantsModel(_context); _viewModel = new ParticipantsViewModel(_model, _context); SetupModel setupModel = new SetupModel(_context); setupModel.Initialize(); _viewModel.RefreshPage(); }
internal SetupModel CopyWithFile(string file) { var copy = new SetupModel { Fullname = Fullname, SortOrder = SortOrder, Name = Name, Description = string.Format("{0}\nFile: {1}", Description, file), SetupData = file }; return(copy); }
internal SetupModel CopyWithFile(string file) { var copy = new SetupModel { Fullname = Fullname, SortOrder = SortOrder, Name = Name, Description = $"{Description}\nFile: {file}", SetupData = file }; return(copy); }
public ActionResult Setup(SetupModel model) { if (model == null) { ViewBag.Records = "Something went wrong. Please try again."; return(RedirectToAction("Index", "Home")); } using (var db = new ginoEntities1()) { userpref dd = new userpref(); db.userprefs.Add(dd); dd.addictiontype = model.AddictionType; dd.cost = model.Costperday; dd.units = model.Nmbrperday; dd.userId = model.UserId; dd.stopDate = DateTime.UtcNow; dd.Deleted = false; dd.sharing = true; dd.substituteUser = model.UsingSubstitute; //dd.addictionproducttype = model.ProductPost; //Hårdkodat produktval tills väljare funkar bra. if (model.AddictionType == 1) { dd.addictionproducttype = 1; } else if (model.AddictionType == 2) { dd.addictionproducttype = 2; } db.SaveChanges(); if (model.UsingSubstitute == true) { substitute s = new substitute(); db.substitutes.Add(s); s.amount = model.Substituteamount; s.unit = "mg"; s.deleted = false; s.updated = DateTime.UtcNow; s.userprefId = dd.Id; db.SaveChanges(); } } return(RedirectToAction("Index", "User")); }
public void MakeSimpleSetup(uint gfxObjID) { _setup = SetupModel.CreateSimpleSetup(); Parts = new List <GfxObj>(1); var gfxObj = GfxObjCache.Get(gfxObjID); Parts.Add(gfxObj); // always identity? PlacementFrames = new List <Matrix>(1); PlacementFrames.Add(Matrix.Identity); }
public Setup(uint setupID, FileTypes.ObjDesc objDesc, Dictionary <int, uint> customPaletteColors) { // make simple setup if gfxobj. These don't have if (setupID >> 24 == 0x1) { MakeSimpleSetup(setupID); BuildBoundingBox(); return; } _setup = DatManager.PortalDat.ReadFromDat <SetupModel>(setupID); Parts = new List <GfxObj>(); for (var i = 0; i < _setup.Parts.Count; i++) { uint gfxObjID; GfxObj gfxObj; var apChange = objDesc.AnimPartChanges.Where(s => s.PartIndex == i).FirstOrDefault(); if (apChange != null) { gfxObjID = apChange.PartID; gfxObj = new GfxObj(gfxObjID, false); List <ACE.DatLoader.Entity.TextureMapChange> tmChanges = objDesc.TextureChanges.FindAll(s => s.PartIndex == i); gfxObj.LoadTextures(tmChanges, customPaletteColors); gfxObj.BuildPolygons(); } else { gfxObjID = _setup.Parts[i]; gfxObj = new GfxObj(gfxObjID, false); gfxObj.LoadTextures(null, null); gfxObj.BuildPolygons(); } Parts.Add(gfxObj); } PlacementFrames = new List <Matrix>(); foreach (var placementFrame in _setup.PlacementFrames[0].AnimFrame.Frames) { PlacementFrames.Add(placementFrame.ToXna()); } BuildBoundingBox(); }
public void NewParticipantsModel() { NewModel(); SetupModel setupModel = _model.NewSetupModel(); setupModel.Initialize(); ParticipantsModel participantsModel = _model.NewParticipantsModel(); participantsModel.Initialize(); _context.ParticipantsChanged = false; participantsModel.EditParticipant(0, "test"); Assert.AreEqual("test", _context.Participants[0].Name); Assert.IsTrue(_context.ParticipantsChanged); }
public ActionResult Setup() { if (!User.Identity.IsAuthenticated) { return(RedirectToAction("LogIn", "Account")); } var model = new SetupModel(); using (var db = new ginoEntities1()) { var typeQuery = (from t in db.addictiontypes where t.Deleted == false orderby t.Name ascending select new { t.Id, t.Name }); model.AddicitionTypes.AddRange( typeQuery.ToList().Select( x => new AddictionTypesModel() { Id = x.Id, Name = x.Name })); var productQuery = (from p in db.products where p.deleted == false orderby p.Producttype ascending select new { p.Producttype, p.Id, p.Name }); model.ProductListing.AddRange( productQuery.ToList().Select( x => new ProductListingModel() { Id = x.Id, Name = x.Name, ProductType = x.Producttype } )); } return(View(model)); }
public float GetWorldObjectEffectiveUseRadius(ObjectGuid objectId) { WorldObject wo; Log($"Getting WorldObject Effective Use Radius {objectId.Full:X}"); lock (objectCacheLocker) { wo = worldObjects.ContainsKey(objectId) ? worldObjects[objectId] : null; } if (wo != null) { var csetup = SetupModel.ReadFromDat(wo.PhysicsData.CSetup); return((float)Math.Pow((wo.GameData.UseRadius + csetup.Radius + 1.5), 2)); } return(0.00f); }
public static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); // Create main disposer var mainDisposer = new Disposer(); // var random = new Random(1415926535); #region demo setup // show setup dialog and get setup values var title = "Mash Room by Jolt"; var setupView = new StartupView(title); var setupModel = new SetupModel(); var presenter = new SetupPresenter(setupView, setupModel); setupModel.TryLoadSettings(); setupModel.SelectAdapter(0); var dialogResult = setupView.ShowDialog(); if (dialogResult != DialogResult.OK) return; #if DEBUG setupModel.SaveSettings(); // todo: remove save in release mode #endif #endregion // Create Device and SwapChain var demo = new Demo().Init(setupModel, title); var inputHandler = new InputHandler().Bind(demo); #region audio // var audioDeviceType = (setupModel.UseAudio) ? AudioDeviceType.Bass : AudioDeviceType.Silent; var audioDeviceManager = new AudioDeviceManager(); var audioDevice = mainDisposer.Add(audioDeviceManager.CreateDevice(audioDeviceType)); // if (setupModel.UseAudio) { // BassNet.Registration( setupModel.BassRegistrationEmail ?? "", setupModel.BassRegistrationKey ?? ""); // 140 bpm // delay 3.428 (dvs 2 takter i 140 bpm) var bpm = 140; var audioName = "Mashup_v1.00.mp3"; var audioAsset = mainDisposer.Add(demo.AudioManager[audioName]); // init and load audio audioDevice.Init(); audioDevice.Load(audioAsset.Value); audioDevice.PlayPosition = setupModel.StartTime; audioDevice.Bpm = bpm; // use the audio device as timer demo.Timer = audioDevice; } #endregion #region sync demo.SyncManager = new SyncManager().Init(setupModel.SyncRecordMode, demo.Timer.Bpm, 4); demo.SyncManager.TimerDevice = demo.Timer; #endregion #region shaders var planeVertexShader = demo.ShaderManager["plane.vs.cso"].VertexShader; var planePixelShader = demo.ShaderManager["plane.ps.cso"].PixelShader; var postPixelShader = demo.ShaderManager["post.ps.cso"].PixelShader; var postVertexShader = demo.ShaderManager["post.vs.cso"].VertexShader; var vanillaEffect = mainDisposer.Add(new VanillaEffect(demo).Init()); var vanillaLayout = mainDisposer.Add(vanillaEffect.InputLayout.InputLayout); #endregion #region models // load all models demo.ModelManager.LoadAll(); // make all models white (todo: why) foreach (var model in demo.ModelManager) { model.Color = new Color(255, 255, 255, 255); model.ReCreateBuffer(demo.Device); } #endregion #region textures Texture2D backBuffer = null; Texture2D depthBuffer = null; DepthStencilView depthView = null; // 1D texture for scanline distortion var distortionTexture = new Texture1D(demo.Device, new Texture1DDescription { CpuAccessFlags = CpuAccessFlags.None, Format = Format.R8G8B8A8_UNorm, Usage = ResourceUsage.Default, Width = 1080, ArraySize = 1, MipLevels = 1, BindFlags = BindFlags.ShaderResource, OptionFlags = ResourceOptionFlags.None }); var distortionData = new byte[4 * distortionTexture.Description.Width]; var distortionSRV = new ShaderResourceView(demo.Device, distortionTexture); // foreground texture var foregroundTexture = new Texture2D(demo.Device, new Texture2DDescription { CpuAccessFlags = CpuAccessFlags.None, Format = Format.R8_UNorm, Usage = ResourceUsage.Default, Width = 1920, Height = 1080, ArraySize = 1, MipLevels = 1, BindFlags = BindFlags.ShaderResource, OptionFlags = ResourceOptionFlags.None, SampleDescription = new SampleDescription(1, 0), }); var foregroundSRV = new ShaderResourceView(demo.Device, foregroundTexture); var foregroundData = new byte[foregroundTexture.Description.Width * foregroundTexture.Description.Height]; // noise texture var noiseTexture = new Texture2D(demo.Device, new Texture2DDescription { CpuAccessFlags = CpuAccessFlags.None, Format = Format.R8_UNorm, Usage = ResourceUsage.Default, Width = 1920 / 5, Height = 1080 / 5, ArraySize = 1, MipLevels = 1, BindFlags = BindFlags.ShaderResource, OptionFlags = ResourceOptionFlags.None, SampleDescription = new SampleDescription(1, 0), }); var noiseSRV = new ShaderResourceView(demo.Device, noiseTexture); var noiseData = new byte[noiseTexture.Description.Width * noiseTexture.Description.Height]; #endregion #region acts var act0 = mainDisposer.Add(new Act0(demo).Init()); #endregion #region effects //var fractalCityEffect = mainDisposer.Add(new FractalCityEffect(demo).Init()); //var oceanEffect = mainDisposer.Add(new OceanEffect(demo).Init()); //var dustEffect = mainDisposer.Add(new DustEffect(demo).Init()); //var cloudEffect = mainDisposer.Add(new CloudEffect(demo).Init()); //var mandelbulbEffect = mainDisposer.Add(new MandelbulbEffect(demo).Init()); //var redPlanetEffect = mainDisposer.Add(new Effect(demo).Init(new EffectDescription //{ // PixelShaderName = "redPlanet.ps.cso", // TextureNames = "redPlanet0.png,redPlanet1.jpg".Split(',') //})); //var pseudoKleinianEffect = mainDisposer.Add(new Effect(demo).Init(new EffectDescription //{ // PixelShaderName = "pseudoKleinian.ps.cso", //})); //var nonameEffect00 = mainDisposer.Add(new Effect(demo).Init(new EffectDescription { PixelShaderName = "noname00.ps.cso", TextureNames = "tex09.jpg".Split(',') })); //var nonameEffect01 = mainDisposer.Add(new Effect(demo).Init(new EffectDescription { PixelShaderName = "noname01.ps.cso" })); //var nonameEffect02 = mainDisposer.Add(new Effect(demo).Init(new EffectDescription { PixelShaderName = "noname02.ps.cso", TextureNames = "tex09.jpg,tex07.jpg".Split(',') })); //var nonameEffect03 = mainDisposer.Add(new Effect(demo).Init(new EffectDescription { PixelShaderName = "noname03.ps.cso" })); //var nonameEffect04 = mainDisposer.Add(new Effect(demo).Init(new EffectDescription { PixelShaderName = "noname04.ps.cso", TextureNames = "noise256.png".Split(',') })); //var nonameEffect05 = mainDisposer.Add(new Effect(demo).Init(new EffectDescription { PixelShaderName = "noname05.ps.cso" })); //var nonameEffect06 = mainDisposer.Add(new Effect(demo).Init(new EffectDescription { PixelShaderName = "noname06.ps.cso" })); //var nonameEffect07 = mainDisposer.Add(new Effect(demo).Init(new EffectDescription { PixelShaderName = "noname07.ps.cso" })); //var nonameEffect08 = mainDisposer.Add(new Effect(demo).Init(new EffectDescription { PixelShaderName = "noname08.ps.cso" })); //var nonameEffect09 = mainDisposer.Add(new Effect(demo).Init(new EffectDescription { PixelShaderName = "noname09.ps.cso" })); //var nonameEffect10 = mainDisposer.Add(new Effect(demo).Init(new EffectDescription { PixelShaderName = "noname10.ps.cso" })); #endregion var fillStateMsaadesc = RasterizerStateDescription.Default(); fillStateMsaadesc.IsMultisampleEnabled = true; var msaaFillState = new RasterizerState(demo.Device, fillStateMsaadesc); var fillState = new RasterizerState(demo.Device, RasterizerStateDescription.Default()); var vanillaRenderContext = null as RenderContext; var postRenderContext = null as RenderContext; var planeRenderContext = null as RenderContext; // Main loop using (var renderDisposer = new Disposer()) { RenderLoop.Run(demo.Form, () => { if (demo.SyncManager.RowIndex == 0x000006d0) { demo.Form.Close(); return; } // TODO refactor: move the resize code #region resize if (demo.OutputWasResized) { demo.OutputWasResized = false; renderDisposer.DisposeAll(); // dispose old swapchain if (demo.SwapChain != null) { demo.SwapChain.Dispose(); } // create new swapchain demo.SwapChain = renderDisposer.Add(new SwapChain(setupModel.Factory, demo.Device, new SwapChainDescription { BufferCount = 1, ModeDescription = setupModel.Mode, IsWindowed = !setupModel.FullScreen, OutputHandle = demo.Form.Handle, //SampleDescription = new SampleDescription(setupModel.MultiSampleCount, setupModel.MultiSampleQuality), SampleDescription = new SampleDescription(1, 0), SwapEffect = SwapEffect.Discard, Usage = Usage.RenderTargetOutput })); if (setupModel.FullScreen) { demo.SwapChain.SetFullscreenState(true, setupModel.Output); } // var postOutputRenderTarget = new RenderTarget(demo.Device, demo.SwapChain); // Get the backbuffer from the swapchain backBuffer = renderDisposer.Add(demo.SwapChain.GetBackBuffer<Texture2D>(0)); // Setup targets and viewport for rendering var postInputRenderTarget = new RenderTarget( device: demo.Device, width: setupModel.Mode.Width / 1, // todo: introduce a scalefactor height: setupModel.Mode.Height / 1, // todo: introduce a scalefactor sampleCount: 1, // todo: use setupModel.MultiSampleCount, sampleQuality: 0, // todo: use setupModel.MultiSampleQuality, format: Format.R8G8B8A8_UNorm // todo: use setupModel.Format ); // Create the depth buffer depthBuffer = renderDisposer.Add(new Texture2D(demo.Device, new Texture2DDescription { Format = Format.D32_Float_S8X24_UInt, ArraySize = 1, MipLevels = 1, Width = postInputRenderTarget.Width, Height = postInputRenderTarget.Height, SampleDescription = postInputRenderTarget.Texture.Description.SampleDescription, Usage = ResourceUsage.Default, BindFlags = BindFlags.DepthStencil, CpuAccessFlags = CpuAccessFlags.None, OptionFlags = ResourceOptionFlags.None })); // Create the depth buffer view depthView = renderDisposer.Add(new DepthStencilView(demo.Device, depthBuffer)); vanillaRenderContext = renderDisposer.Add(new RenderContext { PrimitiveTopology = PrimitiveTopology.TriangleList, InputLayout = vanillaLayout, VertexShader = null, PixelShader = null, RasterizerState = msaaFillState, DepthStencilView = depthView, RenderTarget = postInputRenderTarget, }); postRenderContext = renderDisposer.Add(new RenderContext { PrimitiveTopology = PrimitiveTopology.TriangleList, InputLayout = vanillaLayout, VertexShader = postVertexShader, PixelShader = postPixelShader, RasterizerState = fillState, DepthStencilView = null, RenderTarget = postOutputRenderTarget, }); planeRenderContext = new RenderContext { PrimitiveTopology = PrimitiveTopology.TriangleList, InputLayout = vanillaLayout, VertexShader = planeVertexShader, PixelShader = planePixelShader, RasterizerState = fillState, DepthStencilView = null, RenderTarget = postOutputRenderTarget, }; // todo: remove this hack if (!setupModel.SyncRecordMode) { demo.Timer.StartPlaying(); } if (setupModel.FullScreen) { Cursor.Hide(); } } #endregion // todo: remove demo.SyncManager.Update(demo.Timer.Time); var syncRow = new { demo.SyncManager.Data.Part, demo.SyncManager.Data.Lead, }; // Present! // a crash here is quite common when VertexShader or PixelShader is null demo.SwapChain.Present(setupModel.UseVerticalSync ? 1 : 0, PresentFlags.None); // horizontal distortion and color separation random.NextBytes(distortionData); demo.DeviceContext.UpdateSubresource(distortionData, distortionTexture); // static noise random.NextBytes(noiseData); demo.DeviceContext.UpdateSubresource(noiseData, noiseTexture, 0, noiseTexture.Description.Width); // setup for normal rendering { // use normal rendering demo.DeviceContext.PixelShader.SetShaderResource(0, null); demo.RenderContext = vanillaRenderContext; // clear demo.DeviceContext.ClearDepthStencilView(demo.RenderContext.DepthStencilView, DepthStencilClearFlags.Depth, 1.0f, 0); demo.DeviceContext.ClearRenderTargetView(demo.RenderContext.RenderTarget.RenderTargetView, Color.Black); } // render act act0.Render(); // demo.DeviceContext.ClearRenderTargetView(postRenderContext.RenderTarget.RenderTargetView, Color.Black); // render plane to screen if (true) { // TODO is this really needed ? demo.DeviceContext.OutputMerger.ResetTargets(); demo.DeviceContext.VertexShader.SetConstantBuffer(0, null); // use post rendering demo.RenderContext = postRenderContext; // set textures demo.DeviceContext.PixelShader.SetShaderResource(0, vanillaRenderContext.RenderTarget.ShaderResourceView); demo.DeviceContext.PixelShader.SetShaderResource(1, distortionSRV); demo.DeviceContext.PixelShader.SetShaderResource(2, noiseSRV); // use plane model var model = demo.ModelManager["plane2"]; // todo: make sure we have no z-buffer conflicts (might be hw dependent) var camera = new NoCamera(); demo.Draw(model, camera); } }); } // dispose Disposer.Dispose(ref mainDisposer); }