private void HandleExposeEventClick(object sender, System.Windows.RoutedEventArgs e) { TextInputWindow tiw = new TextInputWindow(); InstanceMember instanceMember = ((System.Windows.Controls.MenuItem)sender).Tag as InstanceMember; tiw.Message = "Enter name to expose as:"; tiw.Result = SelectedState.Self.SelectedInstance.Name + instanceMember.DisplayName; var dialogResult = tiw.ShowDialog(); if (dialogResult == System.Windows.Forms.DialogResult.OK) { string nameWithDot = SelectedState.Self.SelectedInstance.Name + "." + instanceMember.DisplayName; EventSave eventSave = SelectedState.Self.SelectedElement.Events.FirstOrDefault(item => item.Name == nameWithDot); if (eventSave == null) { eventSave = new EventSave(); eventSave.Name = nameWithDot; SelectedState.Self.SelectedElement.Events.Add(eventSave); } eventSave.ExposedAsName = tiw.Result; if (SelectedState.Self.SelectedElement != null) { GumCommands.Self.FileCommands.TryAutoSaveCurrentElement(); GumCommands.Self.GuiCommands.RefreshPropertyGrid(true); } } }
public EventInstanceMember(ElementSave element, InstanceSave instance, EventSave eventSave) { mElementSave = element; mEventSave = eventSave; if (!string.IsNullOrEmpty(eventSave.ExposedAsName)) { this.Name = eventSave.ExposedAsName; } else { this.Name = eventSave.Name; } if (instance != null) { this.DisplayName = eventSave.GetRootName(); } this.CustomSetEvent += HandlePropertyChanged; this.CustomGetEvent += HandlePropertyGet; this.CustomGetTypeEvent += HandleGetType; }
public void HandleRename(ElementSave containerElement, EventSave eventSave, string oldName) { List<ElementSave> elements = new List<ElementSave>(); elements.AddRange(ProjectManager.Self.GumProjectSave.Screens); elements.AddRange(ProjectManager.Self.GumProjectSave.Components); foreach (var possibleElement in elements) { foreach (var instance in possibleElement.Instances.Where(item=>item.IsOfType(containerElement.Name))) { foreach (var eventToRename in possibleElement.Events.Where(item => item.GetSourceObject() == instance.Name)) { if (eventToRename.GetRootName() == oldName) { eventToRename.Name = instance.Name + "." + eventSave.ExposedAsName; } } } } }
private void RefreshEventsForInstance(InstanceSave selectedInstance, ElementSave selectedElement) { var instanceElement = ObjectFinder.Self.GetElementSave(SelectedState.Self.SelectedInstance.BaseType); if (instanceElement != null) { foreach (var eventSaveInBase in instanceElement.Events.Where(item => item.Enabled && (string.IsNullOrEmpty(item.GetSourceObject()) || !string.IsNullOrEmpty(item.ExposedAsName)) )) { var eventSave = selectedElement.Events.FirstOrDefault(item => item.Name == selectedInstance.Name + "." + eventSaveInBase.GetExposedOrRootName()); if (eventSave == null) { eventSave = new EventSave(); eventSave.Name = selectedInstance.Name + "." + eventSaveInBase.GetExposedOrRootName(); // I don't think we want to add this here yet do we? // We should add it only if the user checks it //selectedElement.Events.Add(eventSave); } EventInstanceMember instanceMember = new EventInstanceMember( selectedElement, selectedInstance, eventSave); if (!string.IsNullOrEmpty(eventSave.ExposedAsName)) { instanceMember.DisplayName = eventSave.GetRootName() + " (exposed as " + eventSave.ExposedAsName + ")"; } mEventsDataGrid.Categories[0].Members.Add(instanceMember); } } // Now loop through all objects and give them an Expose right click option foreach (var category in mEventsDataGrid.Categories) { foreach (var member in category.Members) { string rawName = member.Name; if(member.DisplayName.Contains(" (exposed")) { rawName = member.DisplayName.Substring(0, member.DisplayName.IndexOf(" (exposed")); } var eventSave = selectedElement.Events.FirstOrDefault(item => item.Name == selectedInstance.Name + "." + rawName); bool isAlreadyExposed = eventSave != null && !string.IsNullOrEmpty(eventSave.ExposedAsName); if (isAlreadyExposed) { member.ContextMenuEvents.Add("Un-expose Event", delegate { eventSave.ExposedAsName = null; if (SelectedState.Self.SelectedElement != null) { GumCommands.Self.FileCommands.TryAutoSaveCurrentElement(); GumCommands.Self.GuiCommands.RefreshPropertyGrid(true); } } ); } else { member.ContextMenuEvents.Add("Expose Event", HandleExposeEventClick); } } } }