private string[] ModifyEvents(ModifyModel modifyModel, string[] events) { if (events == null) { events = new string[0]; } switch (modifyModel.Modification.ModificationType) { case ModificationType.Add: return(events.Concat(new[] { modifyModel.Modification.NewValue.AssertTypeOf <string>() }) .ToArray()); case ModificationType.Remove: return(events.Except(new[] { modifyModel.Modification.OldValue.AssertTypeOf <string>() }) .ToArray()); case ModificationType.Change: return(events.Except(new[] { modifyModel.Modification.OldValue.AssertTypeOf <string>() }) .Concat(new[] { modifyModel.Modification.NewValue.AssertTypeOf <string>() }) .ToArray()); default: throw new InvalidOperationException($"What? {modifyModel.Modification.ModificationType}"); } }
private Guid[] ModifyMessages(ModifyModel modifyModel, Guid[] originalMessages) { switch (modifyModel.Modification.ModificationType) { case ModificationType.Add: return(AddMessage(originalMessages, modifyModel.Modification.NewValue.AssertTypeOf <Guid>())); case ModificationType.Remove: return(RemoveMessage(originalMessages, modifyModel.Modification.OldValue.AssertTypeOf <Guid>())); case ModificationType.Change: return(RemoveMessage(AddMessage(originalMessages, modifyModel.Modification.NewValue.AssertTypeOf <Guid>()), modifyModel.Modification.OldValue.AssertTypeOf <Guid>())); default: throw new InvalidOperationException($"What? {modifyModel.Modification.ModificationType}"); } Guid[] AddMessage(Guid[] messages, Guid addedMessage) { return(messages.Concat(new[] { addedMessage }).ToArray()); } Guid[] RemoveMessage(Guid[] messages, Guid removedMessage) { return(messages.Except(new[] { removedMessage }).ToArray()); } }
protected override void ExecuteCore(Message messageData) { ModifyModel modifyModel = messageData.Get <ModifyModel>(); if (modifyModel.Modification.Target is not CommunityModel) { return; } CommunityModel model = modifyModel.CurrentVersion; CommunityModel updatedModel; switch (modifyModel.Modification.Property) { case PackageMessagesProperty _: updatedModel = UpdateMessage(modifyModel.Modification.OldValue.AssertTypeOf <MessageModel>(), modifyModel.Modification.NewValue.AssertTypeOf <MessageModel>(), modifyModel.Modification.ModificationType, model); break; case PackageAgentsProperty _: updatedModel = UpdateAgent(modifyModel.Modification.OldValue.AssertTypeOf <AgentModel>(), modifyModel.Modification.NewValue.AssertTypeOf <AgentModel>(), modifyModel.Modification.ModificationType, model); break; default: throw new InvalidOperationException($"Property {modifyModel.Modification.Property} unknown for model."); } OnMessage(new ModificationResult(updatedModel, messageData)); }
private static void BackupBoxTimeline() { var modify = new ModifyModel(Selection.activeGameObject); modify.SetupAnimator(); modify.SavePrefab(); EditorCoroutine.Start(modify.BackupBoxTimeline()); }
protected override void ExecuteCore(Message messageData) { ModifyModel modifyModel = messageData.Get <ModifyModel>(); CommunityModel model = modifyModel.CurrentVersion; if (modifyModel.Modification.Target is not MessageModel messageModel) { return; } MessageModel updatedModel; switch (modifyModel.Modification.Property) { case MessageNameProperty _: updatedModel = messageModel.Clone(name: modifyModel.Modification.NewValue.AssertTypeOf <string>()); break; case MessageNamespaceProperty _: updatedModel = messageModel.Clone(@namespace: modifyModel.Modification.NewValue.AssertTypeOf <string>()); break; case MessageDecoratorDecoratedMessageProperty _: MessageDecoratorModel decoratorModel = (MessageDecoratorModel)messageModel; updatedModel = decoratorModel.Clone(modifyModel.Modification.NewValue.AssertTypeOf <Guid>()); break; default: throw new InvalidOperationException($"Property {modifyModel.Modification.Property} unknown for agent model."); } CommunityModel updatedCommunity = new(model.GeneratorSettings, model.Agents, ReplaceMessage()); OnMessage(new ModificationResult(updatedCommunity, messageData)); MessageModel[] ReplaceMessage() { MessageModel[] messages = new MessageModel[model.Messages.Length]; Array.Copy(model.Messages, messages, messages.Length); int messageIndex = Array.IndexOf(messages, messageModel); if (messageIndex < 0) { throw new InvalidOperationException("Could not find agent model in community."); } messages[messageIndex] = updatedModel; return(messages); } }
private void RestructureViewModels(ModifyModel modifyModel, CommunityViewModel changingViewModel) { AgentViewModel[] agents = changingViewModel.FindItemsByType <AgentViewModel>().ToArray(); MessageViewModel[] messages = changingViewModel.FindItemsByType <MessageViewModel>().ToArray(); foreach (AgentViewModel agent in agents) { changingViewModel.RemoveItem(agent); } foreach (MessageViewModel message in messages) { changingViewModel.RemoveItem(message); } string oldNamespace = modifyModel.Modification.OldValue.AssertTypeOf <string>() ?? string.Empty; string newNamespace = modifyModel.Modification.NewValue.AssertTypeOf <string>() ?? string.Empty; UpdateRelativeRootFolder(changingViewModel, oldNamespace, newNamespace); foreach (AgentViewModel agent in agents) { agent.FullName = UpdateFullName(agent.FullName, agent.RelativeNamespace); changingViewModel.AddItem(agent); } foreach (MessageViewModel message in messages) { message.FullName = UpdateFullName(message.FullName, message.RelativeNamespace); changingViewModel.AddItem(message); } string UpdateFullName(string oldFullName, string relativeNamespace) { if (!relativeNamespace.StartsWith(".")) { return(oldFullName); } string relativeFullName = oldFullName.Substring(oldNamespace.Length); if (!relativeFullName.StartsWith(".", StringComparison.Ordinal)) { relativeFullName = $".{relativeFullName}"; } return(string.IsNullOrEmpty(newNamespace) ? relativeFullName.Substring(1) : newNamespace + relativeFullName); } }
static void ProcessCharacter(GameObject model) { var go = GameObject.Instantiate(model); go.name = model.name; var modify = new ModifyModel(go); modify.Bootstrap(); var modify2 = new ModifyModel(go, true); modify2.Bootstrap(); GameObject.DestroyImmediate(go); AssetDatabase.SaveAssets(); }
public ActionResult Modify(ModifyModel modifymodel) { DbContext dbContext = new DbContext("NEWSEntities"); List <News> newsList = dbContext.Set <News>().ToList(); newsList[modifymodel.Index].Title = modifymodel.Title; newsList[modifymodel.Index].Author = modifymodel.Author; newsList[modifymodel.Index].Keyword = modifymodel.Keyword; newsList[modifymodel.Index].Type = modifymodel.Type; dbContext.SaveChanges(); dbContext.Dispose(); NewsListMessage newsListMessage = new NewsListMessage(); newsListMessage.NewsList = newsList; return(View("~/Views/My/Index.cshtml", newsListMessage)); }
private void ChangeEvents(ObservableCollection <string> events, ModifyModel modifyModel) { switch (modifyModel.Modification.ModificationType) { case ModificationType.Add: events.Add(modifyModel.Modification.NewValue.AssertTypeOf <string>()); break; case ModificationType.Remove: events.Remove(modifyModel.Modification.OldValue.AssertTypeOf <string>()); break; case ModificationType.Change: events.Remove(modifyModel.Modification.OldValue.AssertTypeOf <string>()); events.Add(modifyModel.Modification.NewValue.AssertTypeOf <string>()); break; } }
public async Task <IActionResult> ModifyPassword(ModifyModel model) { if (ModelState.IsValid) { string username = HttpContext.User.Identity.Name; var student = _userManager.Users.FirstOrDefault(s => s.UserName == username); var result = await _userManager.ChangePasswordAsync(student, model.OriginalPassword, model.ModifiedPassword); if (result.Succeeded) { await _signInManager.SignOutAsync(); return(View("ModifySuccess")); } ModelState.AddModelError("", "原密码输入错误"); } return(View(model)); }
private void ChangeMessages(ModifyModel modifyModel, CommunityViewModel changingViewModel) { switch (modifyModel.Modification.ModificationType) { case ModificationType.Add: AddMessage(); break; case ModificationType.Remove: RemoveMessage(); break; case ModificationType.Change: RemoveMessage(); AddMessage(); break; } void AddMessage() { MessageModel messageModel = modifyModel.Modification.NewValue.AssertTypeOf <MessageModel>(); MessageViewModel viewModel = messageModel.CreateViewModel(changingViewModel); changingViewModel.AddItem(viewModel); (changingViewModel.FindItemByType <AgentViewModel>()?.AvailableItems ?? changingViewModel.FindItemByType <MessageViewModel>()?.AvailableItems)?.AvailableMessages.Add(viewModel); } void RemoveMessage() { MessageModel messageModel = modifyModel.Modification.OldValue.AssertTypeOf <MessageModel>(); MessageViewModel viewModel = (MessageViewModel)changingViewModel.FindViewItemById(messageModel.Id); changingViewModel.RemoveItem(viewModel); (changingViewModel.FindItemByType <AgentViewModel>()?.AvailableItems ?? changingViewModel.FindItemByType <MessageViewModel>()?.AvailableItems)?.AvailableMessages.Remove(viewModel); } }
private static void FixAnimator() { var modify = new ModifyModel(Selection.activeGameObject); modify.SetupAnimator(); }
/// <summary> /// Method to perform file modification using Magick.Net /// </summary> /// <returns>Path to the new file ( modified )</returns> public async Task <DefaultServiceResponse> ModifyFile(ModifyModel model) { // Get last uploaded photo by the customer var lastUploadedImageName = DataContext.CustomerImageFiles.ToList().Where(imageFile => imageFile.CustomerId == model.UserId).OrderByDescending(orderBy => orderBy.UploadTime).Select(response => response.FullName); var intesivity = model.Intesivity; var editedFileName = ""; using (var image = new MagickImage(lastUploadedImageName.First())) { switch (model.SelectedOperation) { case "CycleColorMap": image.CycleColormap(intesivity); break; case "FloodFill": image.FloodFill(10, 10, 10); break; case "Flop": image.Flop(); break; case "GammaCorrect": image.GammaCorrect(intesivity); // gramma break; case "GausiianBlur": image.GaussianBlur(intesivity, intesivity); // double radius + double sigma break; case "MedianFilter": image.MedianFilter(intesivity); // radius break; case "MotionBlur": image.MotionBlur(10, 10, 10); break; case "Negate": image.Negate(); // simple negate break; default: break; } if (model.UseFrame) { image.Border(7, 7); } editedFileName = lastUploadedImageName.First().Replace(Path.GetFileNameWithoutExtension(lastUploadedImageName.First()), Path.GetFileNameWithoutExtension(lastUploadedImageName.First()) + "_modified").Replace(Path.GetExtension(lastUploadedImageName.First()), "." + model.OutputFileType.ToLower()); using (File.Create(editedFileName)) image.Write(editedFileName); } // Save file to the DB var originalImageId = DataContext.CustomerImageFiles.Where(imageData => imageData.CustomerId == model.UserId && imageData.FullName.Contains(Path.GetFileNameWithoutExtension(lastUploadedImageName.First()))).Select(result => result.Id).First(); await DataContext.CustomerEditedImageFiles.AddAsync(new ResultImageFIleModel { Id = new Guid(), CustomerId = model.UserId, FullName = editedFileName, OriginalImageId = originalImageId.ToString(), UploadTime = DateTime.Now }); await DataContext.SaveChangesAsync(); return(new DefaultServiceResponse { ResponseData = "../" + Path.Combine("CustomersImages", Path.GetFileName(editedFileName)) }); }
public IActionResult ModifyPassword() { ModifyModel model = new ModifyModel(); return(View(model)); }
public ModifyAnimator(ModifyModel cm) : base(cm) { }
protected override void ExecuteCore(Message messageData) { ModifyModel modifyModel = messageData.Get <ModifyModel>(); CommunityModel model = modifyModel.CurrentVersion; if (modifyModel.Modification.Target is not AgentModel agentModel) { return; } AgentModel updatedModel; switch (modifyModel.Modification.Property) { case AgentNameProperty _: updatedModel = agentModel.Clone(name: modifyModel.Modification.NewValue.AssertTypeOf <string>()); break; case AgentNamespaceProperty _: updatedModel = agentModel.Clone(@namespace: modifyModel.Modification.NewValue.AssertTypeOf <string>()); break; case AgentConsumingMessagesProperty _: updatedModel = agentModel.Clone(consumingMessages: ModifyMessages(modifyModel, agentModel.ConsumingMessages)); break; case AgentProducedMessagesProperty _: updatedModel = agentModel.Clone(producedMessages: ModifyMessages(modifyModel, agentModel.ProducedMessages)); break; case InterceptorAgentInterceptingMessagesProperty _: InterceptorAgentModel interceptorAgentModel = (InterceptorAgentModel)agentModel; updatedModel = interceptorAgentModel.Clone(ModifyMessages(modifyModel, interceptorAgentModel.InterceptingMessages)); break; case AgentIncomingEventsProperty _: updatedModel = agentModel.Clone(incomingEvents: ModifyEvents(modifyModel, agentModel.IncomingEvents)); break; case AgentProducedEventsProperty _: updatedModel = agentModel.Clone(producedEvents: ModifyEvents(modifyModel, agentModel.ProducedEvents)); break; default: throw new InvalidOperationException($"Property {modifyModel.Modification.Property} unknown for agent model."); } CommunityModel updatedCommunity = new(model.GeneratorSettings, ReplaceAgent(), model.Messages); OnMessage(new ModificationResult(updatedCommunity, messageData)); AgentModel[] ReplaceAgent() { AgentModel[] agents = new AgentModel[model.Agents.Length]; Array.Copy(model.Agents, agents, agents.Length); int agentIndex = agents.TakeWhile(a => a.Id != agentModel.Id).Count(); if (agentIndex == agents.Length) { throw new InvalidOperationException("Could not find agent model in community."); } agents[agentIndex] = updatedModel; return(agents); } }
private static void ClearTransitions() { var modify = new ModifyModel(Selection.activeGameObject); modify.ClearTransitions(); }
public ModifyBox(ModifyModel cm) : base(cm) { }
public ModifyBarrelAnimator(ModifyModel cm) : base(cm) { }
private static void OptimizeAnimations() { var modify = new ModifyModel(Selection.activeGameObject); modify.OptimizeAnimations(); }
public ModifyAnimation(ModifyModel cm) : base(cm) { }
private void ChangeMessages(ObservableCollection <MessageViewModel> messages, ModifyModel modifyModel, ObservableCollection <MessageViewModel> availableMessages) { switch (modifyModel.Modification.ModificationType) { case ModificationType.Add: { MessageViewModel viewModel = GetViewModel(modifyModel.Modification.NewValue); messages.Add(viewModel); break; } case ModificationType.Remove: { MessageViewModel viewModel = GetViewModel(modifyModel.Modification.OldValue); messages.Remove(viewModel); break; } case ModificationType.Change: { MessageViewModel addViewModel = GetViewModel(modifyModel.Modification.NewValue); messages.Add(addViewModel); MessageViewModel removeViewModel = GetViewModel(modifyModel.Modification.OldValue); messages.Remove(removeViewModel); break; } } MessageViewModel GetViewModel(object value) { return(availableMessages.First(m => m.ModelId == value.AssertTypeOf <Guid>())); } }
private static void ApplyBoxTimeline() { var modify = new ModifyModel(Selection.activeGameObject); EditorCoroutine.Start(modify.ApplyBoxTimeline()); }
public ModifyViewModel() { ModifyModelObject = new ModifyModel(); ContinueCommand = new MyICommand(Continue); }
private static void BootStrapModel() { var modify = new ModifyModel(Selection.activeGameObject); modify.Bootstrap(); }
private static void CreateDefaultParts() { var modify = new ModifyModel(Selection.activeGameObject); modify.CreateDefaultParts(); }
private static void FixWeaponScale() { var modify = new ModifyModel(Selection.activeGameObject); modify.FixWeaponScale(); }
public ModifyBase(ModifyModel cm) { this.cm = cm; }
public ModifyPrefab(ModifyModel cm) : base(cm) { }