protected override void OnStartup(StartupEventArgs e) { PropertyGridHelper.RegisterEditor <MyColorEditor>(DataObjectType.Color); PropertyGridHelper.RegisterEditor <SelectorEditor>(DataObjectType.Selectable); base.OnStartup(e); }
public void Init(ReportDesigner mainForm) { MainForm = mainForm; Model.InitReferences(); Model.InitEditor(); ModelGrid.SelectedObject = Model; ElementGrid.SelectedObject = null; SelectedButton = null; initTreeView(); ElementsToPanels(); restrictionsPanel.Init(this); aggregateRestrictionsPanel.Init(this); RestrictionGrid.SelectedObject = null; _LINQwarningDone = false; resizeControls(); if (Model.IsLINQ && Model.LINQSubTables.Count == 0 && Model.LINQSubModels.Count == 0) { UpdateLINQModel(); } //adjust description height PropertyGridHelper.ResizeDescriptionArea(ModelGrid, 3); }
public NamedObjectSave AddNewNamedObjectToSelectedElement(AddObjectViewModel addObjectViewModel) { MembershipInfo membershipInfo = NamedObjectSaveExtensionMethodsGlue.GetMemberMembershipInfo(addObjectViewModel.ObjectName); var newNos = NamedObjectSaveExtensionMethodsGlue.AddNewNamedObjectToSelectedElement(addObjectViewModel.ObjectName, membershipInfo, false); if (addObjectViewModel.SourceClassType != NoType && !string.IsNullOrEmpty(addObjectViewModel.SourceClassType)) { newNos.SourceType = addObjectViewModel.SourceType; newNos.SourceClassType = addObjectViewModel.SourceClassType; newNos.SourceFile = addObjectViewModel.SourceFile; newNos.SourceName = addObjectViewModel.SourceNameInFile; newNos.UpdateCustomProperties(); EditorLogic.CurrentElementTreeNode.UpdateReferencedTreeNodes(); } else if (!string.IsNullOrEmpty(addObjectViewModel.SourceFile)) { newNos.SourceType = addObjectViewModel.SourceType; newNos.SourceFile = addObjectViewModel.SourceFile; newNos.SourceName = addObjectViewModel.SourceNameInFile; newNos.UpdateCustomProperties(); EditorLogic.CurrentElementTreeNode.UpdateReferencedTreeNodes(); } newNos.SourceClassGenericType = addObjectViewModel.SourceClassGenericType; var ati = newNos.GetAssetTypeInfo(); if (ati != null && ati.DefaultPublic) { newNos.HasPublicProperty = true; } var currentEntity = GlueState.Self.CurrentElement as EntitySave; if (currentEntity != null && currentEntity.CreatedByOtherEntities && currentEntity.PooledByFactory) { bool wasAnythingAdded = FlatRedBall.Glue.Factories.FactoryManager.AddResetVariablesFor(newNos); if (wasAnythingAdded) { PluginManager.ReceiveOutput("Added reset variables for " + newNos); } } PluginManager.ReactToNewObject(newNos); MainGlueWindow.Self.PropertyGrid.Refresh(); PropertyGridHelper.UpdateNamedObjectDisplay(); ElementViewWindow.GenerateSelectedElementCode(); // it may already be selected, so force select it MainGlueWindow.Self.ElementTreeView.SelectedNode = null; MainGlueWindow.Self.ElementTreeView.SelectedNode = GlueState.Self.Find.NamedObjectTreeNode(newNos); GluxCommands.Self.SaveGlux(); return(newNos); }
private static void HandleCreatedByOtherEntitiesSet(EntitySave entitySave) { if (entitySave.CreatedByOtherEntities == true) { FactoryCodeGenerator.AddGeneratedPerformanceTypes(); FactoryCodeGenerator.UpdateFactoryClass(entitySave); ProjectManager.SaveProjects(); } else { FactoryCodeGenerator.RemoveFactory(entitySave); ProjectManager.SaveProjects(); } List<EntitySave> entitiesToRefresh = ObjectFinder.Self.GetAllEntitiesThatInheritFrom(entitySave); entitiesToRefresh.AddRange(entitySave.GetAllBaseEntities()); entitiesToRefresh.Add(entitySave); // We need to re-generate all objects that use this Entity foreach (EntitySave entityToRefresh in entitiesToRefresh) { List<NamedObjectSave> namedObjects = ObjectFinder.Self.GetAllNamedObjectsThatUseEntity(entityToRefresh.Name); foreach (NamedObjectSave nos in namedObjects) { IElement namedObjectContainer = nos.GetContainer(); if (namedObjectContainer != null) { CodeWriter.GenerateCode(namedObjectContainer); } } } PropertyGridHelper.UpdateDisplayedPropertyGridProperties(); }
protected override void OnExecute(EventArgs e) { if (ActiveTextBox != null) { // PropertyGrids handle copy/paste on their own - below check fixes issue #20 if (!PropertyGridHelper.IsPropertyGridControl(ActiveTextBox.Parent)) { ActiveTextBox.Paste(); } } else if (SelectedNodes != null && UIController.Current.ClipboardObjects != null) { var pasteItems = UIController.Current.ClipboardObjects; var inserted = UIController.Current.Handler.Actions.InsertObjects(pasteItems, SelectedNodes[0].Tag as ITabularNamedObject); foreach (var item in inserted.OfType <ITabularPerspectiveObject>()) { item.Vis(); } if (inserted.Count > 0) { UIController.Current.Goto(inserted[0] as ITabularNamedObject); UIController.Current.Elements.TreeView.BeginUpdate(); foreach (var item in inserted) { var node = UIController.Current.Elements.TreeView.FindNodeByTag(item); if (node != null) { node.IsSelected = true; } } UIController.Current.Elements.TreeView.EndUpdate(); } } base.OnExecute(e); }
public void Init(ReportDesigner mainForm) { MainForm = mainForm; Model.InitReferences(); Model.InitEditor(); ModelGrid.SelectedObject = Model; ElementGrid.SelectedObject = null; SelectedButton = null; initTreeView(); elementTreeView.MouseUp += elementTreeView_MouseUp; ElementsToPanels(); restrictionsPanel.Init(this); aggregateRestrictionsPanel.Init(this); initNoSQL(); RestrictionGrid.SelectedObject = null; resizeControls(); //adjust description height PropertyGridHelper.ResizeDescriptionArea(ModelGrid, 3); }
private static IPropertySource CreatePropertySource(object instance) { if (instance == null) { return(null); } return(instance as IPropertySource ?? PropertyGridHelper.CreatePropertySource(instance)); }
private void OnInspect(object sender, RoutedEventArgs eventArgs) { if (MyPropertyGrid.SelectedProperty == null) { return; } // Push old source to history stack. _history.Push(MyPropertyGrid.PropertySource); MyPropertyGrid.PropertySource = PropertyGridHelper.CreatePropertySource(MyPropertyGrid.SelectedProperty.Value); eventArgs.Handled = true; }
public ModelPanel() { RowPanel = new ElementPanel(this, PivotPosition.Row); DataPanel = new ElementPanel(this, PivotPosition.Data); PagePanel = new ElementPanel(this, PivotPosition.Page); ColumnPanel = new ElementPanel(this, PivotPosition.Column); PanelList = new List <ElementPanel>() { PagePanel, ColumnPanel, RowPanel, DataPanel }; InitializeComponent(); aggregateRestrictionsPanel.IsAggregate = true; ModelGrid.Dock = DockStyle.Fill; ModelGrid.PropertyValueChanged += Grid_PropertyValueChanged; ModelGrid.ToolbarVisible = false; ModelGrid.HelpVisible = true; ModelGrid.PropertySort = PropertySort.Categorized; ModelGrid.LineColor = SystemColors.ControlLight; modelSourceSplitContainer.Panel1.Controls.Add(ModelGrid); PropertyGridHelper.AddResetMenu(ModelGrid); ElementGrid.Dock = DockStyle.Fill; ElementGrid.PropertyValueChanged += Grid_PropertyValueChanged; ElementGrid.ToolbarVisible = false; ElementGrid.PropertySort = PropertySort.Categorized; ElementGrid.LineColor = SystemColors.ControlLight; elementsContainer.Panel2.Controls.Add(ElementGrid); foreach (var panel in PanelList) { elementsContainer.Panel1.Controls.Add(panel); } PropertyGridHelper.AddResetMenu(ElementGrid); RestrictionGrid.Dock = DockStyle.Fill; RestrictionGrid.PropertyValueChanged += Grid_PropertyValueChanged; RestrictionGrid.SelectedObjectsChanged += new EventHandler(RestrictionGrid_SelectedObjectsChanged); RestrictionGrid.ToolbarVisible = false; RestrictionGrid.PropertySort = PropertySort.Categorized; RestrictionGrid.LineColor = SystemColors.ControlLight; restrictionsContainer.Panel2.Controls.Add(RestrictionGrid); PropertyGridHelper.AddResetMenu(RestrictionGrid); elementTreeView.MouseUp += elementTreeView_MouseUp; }
protected override void OnExecute(EventArgs e) { var ctr = UIHelper.GetFocusedControl(Application.OpenForms[0]); if (ctr is TextBoxBase && PropertyGridHelper.IsPropertyGridControl(ctr) && (ctr as TextBoxBase).CanUndo) { // Property grids handle undo/redo on their own } else if (ctr is FastColoredTextBoxNS.FastColoredTextBox) { if (Kind == UndoRedo.Undo) { (ctr as FastColoredTextBoxNS.FastColoredTextBox).Undo(); } else { (ctr as FastColoredTextBoxNS.FastColoredTextBox).Redo(); } } else if (ctr is TextBoxBase) { if (Kind == UndoRedo.Undo) { (ctr as TextBoxBase).Undo(); } else { (ctr as RichTextBox)?.Redo(); } } else { using (new Hourglass()) { if (Kind == UndoRedo.Undo) { Handler.UndoManager.Undo(); } else { Handler.UndoManager.Redo(); } } } base.OnExecute(e); }
public PropertyGridTest() { InitializeComponent(); MyPropertyGrid.PropertySource = PropertyGridHelper.CreatePropertySource(MyButton); MyPropertyGrid2.PropertySource = new PropertySource() { Name = "Custom Name", TypeName = "Custom Type", Properties = { new CustomProperty("Name", "StringValue dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd") { Description = "Description of Property0", Category = null, DefaultValue = "Default", CanReset = true, }, new CustomProperty("Property 2", true) { Description = "Description of Property 2", PropertyType = typeof(bool), DefaultValue = false, CanReset = true, }, new CustomProperty("Float", 666.666f) { PropertyType = typeof(float), }, new CustomProperty("Long", 1234567L) { Name = "Long", PropertyType = typeof(long), DefaultValue = 666L, CanReset = true, }, new CustomProperty("WpfColor", Colors.BlueViolet) { PropertyType = typeof(Color), DefaultValue = Colors.Black, CanReset = true, }, }, }; }
private void InspectEditor() { Logger.Debug("Inspecting editor."); var inspectionService = Editor.Services.GetInstance <IPropertiesService>().WarnIfMissing(); if (inspectionService != null) { // Important: The order of ActivateItem and PropertySource.set matters. // Make Properties window active before changing the property source. Otherwise, // document may think they are still in control of the properties window and change // the content. Editor.ActivateItem(inspectionService.PropertiesViewModel); inspectionService.PropertySource = PropertyGridHelper.CreatePropertySource(Editor); } }
private static void ReactToChangedBaseEntity(object oldValue, EntitySave entitySave) { bool isValidBase = GetIfCurrentEntityBaseIsValid(entitySave); if (isValidBase == false) { entitySave.BaseEntity = (string)oldValue; MainGlueWindow.Self.PropertyGrid.Refresh(); } else { List <CustomVariable> variablesBefore = new List <CustomVariable>(); variablesBefore.AddRange(entitySave.CustomVariables); entitySave.UpdateFromBaseType(); AskToPreserveVariables(entitySave, variablesBefore); } PropertyGridHelper.UpdateEntitySaveDisplay(); }
protected override void OnExecute(EventArgs e) { if (ActiveTextBox != null) { // PropertyGrids handle copy/paste on their own - below check fixes issue #20 if (!PropertyGridHelper.IsPropertyGridControl(ActiveTextBox.Parent)) { ActiveTextBox.Copy(); } } else if (SelectedNodes != null) { // Copy objects represented by selected nodes to clipboard var json = Serializer.SerializeObjects(UIController.Current.Selection.OfType <TabularNamedObject>(), Preferences.Current.Copy_IncludeTranslations, Preferences.Current.Copy_IncludePerspectives, Preferences.Current.Copy_IncludeRLS, Preferences.Current.Copy_IncludeOLS, includeInstanceID: true ); Clipboard.SetText(json, TextDataFormat.UnicodeText); } base.OnExecute(e); }
protected override void OnExecute(EventArgs e) { if (ActiveTextBox != null) { // PropertyGrids handle copy/paste on their own - below check fixes issue #20 if (!PropertyGridHelper.IsPropertyGridControl(ActiveTextBox.Parent)) { ActiveTextBox.Paste(); } } else if (SelectedNodes != null && UIController.Current.ClipboardObjects != null) { var pasteItems = UIController.Current.ClipboardObjects; var inserted = UIController.Current.Handler.Actions.InsertObjects(pasteItems, SelectedNodes[0].Tag as ITabularNamedObject); if (inserted.Count > 0) { UIController.Current.Goto(inserted[0] as ITabularNamedObject); } } base.OnExecute(e); }
/// <summary> /// Raises the <see cref="E:System.Windows.Forms.Form.Load"/> event. /// </summary> /// <param name="e">An <see cref="T:System.EventArgs"/> that contains the event data.</param> protected override void OnLoad(EventArgs e) { base.OnLoad(e); // Don't try to load stuff when in design mode if (DesignMode) { return; } Show(); Refresh(); // Create the database connection _dbController = GlobalState.Instance.DbController; // If the GrhDatas have no been loaded, we will have to load them. Otherwise, we won't get our // pretty little pictures. :( if (!GrhInfo.IsLoaded) { var cm = ContentManager.Create(); GrhInfo.Load(ContentPaths.Dev, cm); } if (_dbController == null) { Close(); return; } // Process all the PropertyGrids foreach (var pg in this.GetControls().OfType <PropertyGrid>()) { PropertyGridHelper.AttachRefresherEventHandler(pg); PropertyGridHelper.AttachShrinkerEventHandler(pg); PropertyGridHelper.SetContextMenuIfNone(pg); } }
private void OnOutlineSelectedItemsChanged(object sender, NotifyCollectionChangedEventArgs eventArgs) { // The selection has changed. --> Update Properties window. if (_propertiesService == null) { return; } if (_outlineService == null) { return; } // Do nothing if the Outline window is displaying a different outline. if (_outlineService.Outline != Outline) { return; } // Per default, we show the general model info. _currentPropertySource = _modelPropertySource; // If something in the Outline window is selected, we show the selected item. if (Outline.SelectedItems.Count > 0) { var selectedItem = Outline.SelectedItems[0]; var userData = selectedItem.UserData; if (userData != null) { _currentPropertySource = PropertyGridHelper.CreatePropertySource( selectedItem.UserData, selectedItem.Text); } } _propertiesService.PropertySource = _currentPropertySource; }
private void SkillForm_Load(object sender, EventArgs e) { InitLua(); TryLoadTree(); m_pghelper = new PropertyGridHelper(MainForm.m_strconn, m_strsql, "tbl_skills", new string[] { "SkillID" }); m_pghelper2 = new PropertyGridHelper(MainForm.m_strconn, m_strsql2, "tbl_skill_caster", new string[] { "SkillID", "SkillLevel" }); DoScript("#");//执行表函数体 //CustomClass dynaobj = m_pghelper.GetDynamicClass(new object[] {0}); //dynaobj.DataValidate += new CustomClass.PropertyChangeEventHandler(PropertyChanged); propertyGrid1.SelectedObject = null;// dynaobj; propertyGrid1.Refresh(); propertyGrid2.SelectedObject = null; propertyGrid2.Refresh(); }
public void ReactToCustomVariableChangedValue(string changedMember, CustomVariable customVariable, object oldValue) { #region Name if (changedMember == nameof(CustomVariable.Name)) { ReactToChangedCustomVariableName((string)oldValue, customVariable); } #endregion #region SetByDerived if (changedMember == nameof(CustomVariable.SetByDerived)) { bool didErrorOccur = false; if (customVariable.SetByDerived && customVariable.IsShared) { MessageBox.Show("Variables that are IsShared cannot be SetByDerived"); didErrorOccur = true; } if (didErrorOccur) { customVariable.SetByDerived = (bool)oldValue; } else { ProjectManager.UpdateAllDerivedElementFromBaseValues(true); } } #endregion #region IsShared else if (changedMember == nameof(CustomVariable.IsShared)) { HandleIsSharedVariableSet(customVariable, oldValue); } #endregion #region SouceObjectProperty else if (changedMember == nameof(CustomVariable.SourceObjectProperty)) { // See if there is already a NOS that uses this SourceObject/SourceObjectProperty combo IElement currentElement = EditorLogic.CurrentElement; CustomVariable currentVariable = customVariable; if (!string.IsNullOrEmpty(currentVariable.SourceObject) && !string.IsNullOrEmpty(currentVariable.SourceObjectProperty)) { foreach (CustomVariable variableInLoop in currentElement.CustomVariables) { if (variableInLoop != currentVariable && !string.IsNullOrEmpty(variableInLoop.SourceObject) && currentVariable.SourceObject == variableInLoop.SourceObject && !string.IsNullOrEmpty(variableInLoop.SourceObjectProperty) && currentVariable.SourceObjectProperty == variableInLoop.SourceObjectProperty) { MessageBox.Show("There is already a variable that is modifying " + currentVariable.SourceObjectProperty + " on " + currentVariable.SourceObject); currentVariable.SourceObjectProperty = (string)oldValue; } } } } #endregion #region DefaultValue else if (changedMember == nameof(CustomVariable.DefaultValue)) { customVariable.FixEnumerationTypes(); var currentElement = GlueState.Self.CurrentElement; if (!string.IsNullOrEmpty(customVariable.SourceObject)) { // See if the source NamedObjectSave has // this variable exposed, and if so, set that // variable too so the two mirror each other... // or make it null if this is a recasted variable. NamedObjectSave nos = currentElement.GetNamedObjectRecursively(customVariable.SourceObject); if (nos != null) { CustomVariableInNamedObject cvino = nos.GetCustomVariable(customVariable.SourceObjectProperty); // If the cvino is null, that means that the NOS doesn't have this exposed, so we don't // need to do anything. if (cvino != null) { if (string.IsNullOrEmpty(customVariable.OverridingPropertyType)) { cvino.Value = customVariable.DefaultValue; } else { cvino.Value = null; } } } } Plugins.PluginManager.ReactToElementVariableChange(currentElement, customVariable); } #endregion #region HasAccompanyingVelocityProperty else if (changedMember == nameof(CustomVariable.HasAccompanyingVelocityProperty)) { ReactToChangedHasAccompanyingVelocityProperty(customVariable); } #endregion #region OverridingPropertyType else if (changedMember == nameof(CustomVariable.OverridingPropertyType)) { if (customVariable.OverridingPropertyType != null) { customVariable.SetDefaultValueAccordingToType(customVariable.OverridingPropertyType); } GlueCommands.Self.RefreshCommands.RefreshPropertyGrid(); } #endregion #region Type else if (changedMember == nameof(CustomVariable.Type)) { customVariable.SetDefaultValueAccordingToType(customVariable.Type); // If the type changed, the Property Grid needs to be re-made so that the new // grid will have the right type for the DefaultValue cell: PropertyGridHelper.UpdateDisplayedPropertyGridProperties(); } #endregion }
/// <summary> /// Constructs a new <c>ConnectionPropertiesGrid</c> instance. /// </summary> public ConnectionPropertiesGrid() : base() { SelectedObject = m_builder; PropertyGridHelper.SelectItem(this, "Protocol"); }
public void ReactToNamedObjectChangedValue(string changedMember, string parent, object oldValue) { string combinedMember; if (string.IsNullOrEmpty(parent)) { combinedMember = changedMember; } else { combinedMember = parent + "." + changedMember; } NamedObjectSave namedObjectSave = EditorLogic.CurrentNamedObject; IElement element = EditorLogic.CurrentElement; if (PropertiesToMethods.ContainsKey(changedMember)) { PropertiesToMethods[changedMember](namedObjectSave, oldValue); } #region SourceType changed else if (changedMember == "SourceType") { bool didErrorOccur = false; if (didErrorOccur) { namedObjectSave.SourceType = (SourceType)oldValue; } else { if (namedObjectSave.SourceType == SourceType.Entity) { namedObjectSave.AddToManagers = true; } else if (namedObjectSave.SourceType == SourceType.File && namedObjectSave.GetContainerType() == ContainerType.Screen) { namedObjectSave.AddToManagers = false; } } } #endregion #region SourceClassType changed else if (changedMember == "SourceClassType") { ReactToChangedSourceClassType(namedObjectSave, oldValue); } #endregion #region SourceFile changed else if (changedMember == "SourceFile") { if (namedObjectSave.SourceFile != (string)oldValue) { // See if the current SourceName is valid or not List <string> availableSourceNames = AvailableNameablesStringConverter.GetAvailableNamedObjectSourceNames(namedObjectSave); bool isSourceNameValid = availableSourceNames.Contains(namedObjectSave.SourceName); if (!isSourceNameValid) { namedObjectSave.SourceName = "<NONE>"; } } } #endregion #region SourceName else if (changedMember == "SourceName") { // This needs to happen before we update custom properties ReactToChangedNosSourceName(namedObjectSave, oldValue as string); namedObjectSave.UpdateCustomProperties(); } #endregion #region InstanceName changed else if (changedMember == "InstanceName") { ReactToNamedObjectChangedInstanceName(namedObjectSave, oldValue); } #endregion #region SetByDerived Changed else if (changedMember == "SetByDerived") { if (namedObjectSave.SourceType == SourceType.Entity && !string.IsNullOrEmpty(namedObjectSave.SourceClassType)) { if (ProjectManager.VerifyReferenceGraph(ObjectFinder.Self.GetEntitySave(namedObjectSave.SourceClassType)) == ProjectManager.CheckResult.Failed) { namedObjectSave.SetByDerived = !namedObjectSave.SetByDerived; } } if (namedObjectSave.SetByDerived && namedObjectSave.ExposedInDerived) { // The user has just set SetByDerived to true, but ExposedInDerived means that // the derived expects that the base instantiates. We need to tell the user that // both values can't be true at the same time, and that ExposedInDerived will be set // to false. MessageBox.Show("You have set SetByDerived to true, but ExposedInDerived is also true. Both cannot be true at the same time " + "so Glue will set ExposedInDerived to false."); namedObjectSave.ExposedInDerived = false; } if (namedObjectSave.SourceType == SourceType.FlatRedBallType && namedObjectSave.IsList && namedObjectSave.SetByDerived == true && namedObjectSave.ContainedObjects.Count != 0) { MessageBox.Show("This list is not empty, so it can't be set to \"Set By Derived\". You must first empty the list", "Invalid Setting"); namedObjectSave.SetByDerived = false; } else { ProjectManager.UpdateAllDerivedElementFromBaseValues(false, true); } } #endregion #region ExposedInDerived Changed else if (changedMember == "ExposedInDerived") { if (namedObjectSave.SetByDerived && namedObjectSave.ExposedInDerived) { // See comment in ExposedByDerived block on why this occurs MessageBox.Show("You have set ExposedInDerived to true, but SetByDerived is also true. Both cannot be true at the same time " + "so Glue will set SetByDerived to false."); namedObjectSave.SetByDerived = false; } SetExposedByDerivedRecursively(namedObjectSave, oldValue); ProjectManager.UpdateAllDerivedElementFromBaseValues(false, true); } #endregion #region SourceClassGenericType else if (changedMember == "SourceClassGenericType") { ReactToSourceClassGenericType(namedObjectSave, oldValue); } #endregion #region IsDisabled else if (changedMember == "IsDisabled") { GlueState.Self.Find.ElementTreeNode(EditorLogic.CurrentElement).UpdateReferencedTreeNodes(); } #endregion #region SetByContainer Changed else if (changedMember == "SetByContainer") { if (namedObjectSave.SourceType == SourceType.Entity && !string.IsNullOrEmpty(namedObjectSave.SourceClassType)) { if (ProjectManager.VerifyReferenceGraph(ObjectFinder.Self.GetEntitySave(namedObjectSave.SourceClassType)) == ProjectManager.CheckResult.Failed) { namedObjectSave.SetByContainer = !namedObjectSave.SetByContainer; } } List <IElement> derivedElements = ObjectFinder.Self.GetAllElementsThatInheritFrom( EditorLogic.CurrentElement.Name); foreach (IElement derived in derivedElements) { foreach (NamedObjectSave nos in derived.NamedObjects) { if (nos.InstanceName == namedObjectSave.InstanceName) { nos.SetByContainer = namedObjectSave.SetByContainer; } } } if (EditorLogic.CurrentEntitySave != null) { List <NamedObjectSave> entityNamedObjects = ObjectFinder.Self.GetAllNamedObjectsThatUseEntity(EditorLogic.CurrentEntitySave.Name); foreach (NamedObjectSave nos in entityNamedObjects) { nos.UpdateCustomProperties(); } } } #endregion #region AddToManagers Changed else if (changedMember == "AddToManagers") { if (namedObjectSave.AddToManagers && namedObjectSave.GetContainerType() == ContainerType.Screen && namedObjectSave.SourceType == SourceType.File) { ScreenSave screenSave = namedObjectSave.GetContainer() as ScreenSave; ReferencedFileSave rfs = screenSave.GetReferencedFileSave(namedObjectSave.SourceFile); if (rfs != null && !rfs.IsSharedStatic) { System.Windows.Forms.MessageBox.Show("This object comes from a file. Files which are part of Screens " + "are automatically added to the engine managers. " + "Adding this object would result in double-membership in the engine which may cause unexpected results. " + "\n\nGlue will now set this value back to false."); namedObjectSave.AddToManagers = false; } } } #endregion #region LayerOn else if (changedMember == "LayerOn") { if (namedObjectSave.IsList) { DialogResult result = DialogResult.No; if (string.IsNullOrEmpty(namedObjectSave.LayerOn)) { result = MessageBox.Show("Do you want to remove every object in the List " + namedObjectSave.InstanceName + " from its Layer?", "Remove all from Layer?", MessageBoxButtons.YesNo); } else { result = MessageBox.Show("Do you want to add every object contained in the List " + namedObjectSave.InstanceName + " to the Layer " + namedObjectSave.LayerOn + "?", "Add all to Layer?", MessageBoxButtons.YesNo); } if (result == DialogResult.Yes) { namedObjectSave.SetLayerRecursively(namedObjectSave.LayerOn); } } } #endregion #region IsContainer else if (changedMember == "IsContainer") { HandleChangedIsContainer(namedObjectSave, element); } #endregion #region AttachToCamera else if (changedMember == "AttachToCamera") { if (namedObjectSave.IsList) { DialogResult result = DialogResult.No; if (namedObjectSave.AttachToCamera) { result = MessageBox.Show("Do you want to attach every object contained in the list " + namedObjectSave.InstanceName + " to the Camera?", "Attach all to Camera?", MessageBoxButtons.YesNo); } else { result = MessageBox.Show("Do you want to detach every object contained in the list " + namedObjectSave.InstanceName + " from the Camera?", "Detach all from the Camera?", MessageBoxButtons.YesNo); } if (result == DialogResult.Yes) { namedObjectSave.SetAttachToCameraRecursively(namedObjectSave.AttachToCamera); } } } #endregion #region DestinationRectangle.Y (for Layers) else if (parent == "DestinationRectangle" && changedMember == "Y") { // If the Y is odd, we should warn the user that it should be even // or else text will draw incorrectly if (namedObjectSave.DestinationRectangle.HasValue && namedObjectSave.DestinationRectangle.Value.Y % 2 == 1) { MessageBox.Show("Setting an odd value to the DestinationRectangle's Y may cause text to render improperly. An " + "even value is recommended"); } } #endregion #region RemoveFromManagersWhenInvisible else if (changedMember == "RemoveFromManagersWhenInvisible") { // is this an Entity instance? if (namedObjectSave.SourceType == SourceType.Entity && namedObjectSave.RemoveFromManagersWhenInvisible) { var entitySave = ObjectFinder.Self.GetEntitySave(namedObjectSave.SourceClassType); if (entitySave != null) { // Is this CreatedByOtherEntities? if (!entitySave.CreatedByOtherEntities) { MessageBox.Show("The Entity " + entitySave + " should have its CreatedByOtherEntities set to true to enable " + "visibility-based removal to work properly"); } } } } #endregion else if (namedObjectSave?.GetCustomVariable(changedMember) != null) { // See if this variable is tunneled into in this element. // If so, set that value too. CustomVariableInNamedObject cvino = namedObjectSave.GetCustomVariable(changedMember); object value = cvino.Value; foreach (CustomVariable customVariable in EditorLogic.CurrentElement.CustomVariables) { if (customVariable.SourceObject == namedObjectSave.InstanceName && customVariable.SourceObjectProperty == changedMember) { // The custom variable may have a different type: if (!string.IsNullOrEmpty(customVariable.OverridingPropertyType)) { // it does, so convert Type overridingType = TypeManager.GetTypeFromString(customVariable.OverridingPropertyType); customVariable.DefaultValue = System.Convert.ChangeType(value, overridingType); } else { customVariable.DefaultValue = value; } break; } } } // If we changed BitmapFont and if the NOS is marked as PixelPerfect // and if it's a Text object, then we should set the Scale, Spacing, and // NewLineDistance according to the set BitmapFont // We don't do an else because there could be a CustomVariable by the name // of BitmapFont as well, and we dont' want to eliminate that. if (changedMember == "Font" && namedObjectSave.SourceType == SourceType.FlatRedBallType && namedObjectSave.SourceClassType == "Text" && namedObjectSave.IsPixelPerfect) { ReactToFontSet(namedObjectSave, oldValue); } PropertyGridHelper.UpdateNamedObjectDisplay(); PluginManager.ReactToNamedObjectChangedValue(changedMember, oldValue); }
public void RefreshPropertyGrid() { MainGlueWindow.Self.BeginInvoke(new EventHandler(delegate { MainGlueWindow.Self.PropertyGrid.Refresh(); })); PropertyGridHelper.UpdateDisplayedPropertyGridProperties(); }
public NamedObjectSave AddNewNamedObjectTo(AddObjectViewModel addObjectViewModel, IElement element, NamedObjectSave namedObject) { if (element == null) { throw new ArgumentNullException(nameof(element)); } MembershipInfo membershipInfo = NamedObjectSaveExtensionMethodsGlue.GetMemberMembershipInfo(addObjectViewModel.ObjectName); var newNos = NamedObjectSaveExtensionMethodsGlue.AddNewNamedObjectTo(addObjectViewModel.ObjectName, membershipInfo, element, namedObject, false); if (addObjectViewModel.SourceClassType != NoType && !string.IsNullOrEmpty(addObjectViewModel.SourceClassType)) { newNos.SourceType = addObjectViewModel.SourceType; newNos.SourceClassType = addObjectViewModel.SourceClassType; newNos.SourceFile = addObjectViewModel.SourceFile; newNos.SourceName = addObjectViewModel.SourceNameInFile; newNos.UpdateCustomProperties(); GlueCommands.Self.RefreshCommands.RefreshUi(element); } else if (!string.IsNullOrEmpty(addObjectViewModel.SourceFile)) { newNos.SourceType = addObjectViewModel.SourceType; newNos.SourceFile = addObjectViewModel.SourceFile; newNos.SourceName = addObjectViewModel.SourceNameInFile; newNos.UpdateCustomProperties(); GlueCommands.Self.RefreshCommands.RefreshUi(element); } newNos.SourceClassGenericType = addObjectViewModel.SourceClassGenericType; var ati = newNos.GetAssetTypeInfo(); if (ati != null && ati.DefaultPublic) { newNos.HasPublicProperty = true; } var entity = element as EntitySave; if (entity != null && entity.CreatedByOtherEntities && entity.PooledByFactory) { bool wasAnythingAdded = FlatRedBall.Glue.Factories.FactoryManager.AddResetVariablesFor(newNos); if (wasAnythingAdded) { PluginManager.ReceiveOutput("Added reset variables for " + newNos); } } PluginManager.ReactToNewObject(newNos); MainGlueWindow.Self.PropertyGrid.Refresh(); PropertyGridHelper.UpdateNamedObjectDisplay(); GlueCommands.Self.GenerateCodeCommands.GenerateElementCode(element); GluxCommands.Self.SaveGlux(); return(newNos); }
public ServerManager() { /* if (Properties.Settings.Default.CallUpgrade) * { * Properties.Settings.Default.Upgrade(); * Properties.Settings.Default.CallUpgrade = false; * Properties.Settings.Default.Save(); * }*/ InitializeComponent(); mainPropertyGrid.PropertySort = PropertySort.Categorized; mainPropertyGrid.LineColor = SystemColors.ControlLight; PropertyGridHelper.AddResetMenu(mainPropertyGrid); sourceHelper = new TreeViewEditorHelper() { sortColumnAlphaOrderToolStripMenuItem = sortColumnAlphaOrderToolStripMenuItem, sortColumnSQLOrderToolStripMenuItem = sortColumnSQLOrderToolStripMenuItem, addFromToolStripMenuItem = addFromToolStripMenuItem, addToolStripMenuItem = addToolStripMenuItem, removeToolStripMenuItem = removeToolStripMenuItem, copyToolStripMenuItem = copyToolStripMenuItem, removeRootToolStripMenuItem = removeRootToolStripMenuItem, treeContextMenuStrip = treeContextMenuStrip, mainTreeView = mainTreeView }; toolStripHelper = new ToolStripEditorHelper() { MainToolStrip = mainToolStrip, MainPropertyGrid = mainPropertyGrid, EntityHandler = this, MainTreeView = mainTreeView }; toolsHelper = new ToolsHelper() { EntityHandler = this }; toolsHelper.InitHelpers(toolsToolStripMenuItem, false); HelperEditor.HandlerInterface = this; configureMenuItem.Click += configureClick; configurationToolStripMenuItem.DropDownItems.Add(configureMenuItem); configureMenuItem.ShortcutKeys = (Keys.Control | Keys.C); configurationToolStripMenuItem.DropDownItems.Add(new ToolStripSeparator()); publishWebMenuItem.Click += configureClick; configurationToolStripMenuItem.DropDownItems.Add(publishWebMenuItem); publishWebMenuItem.ShortcutKeys = (Keys.Control | Keys.P); configurationToolStripMenuItem.DropDownItems.Add(new ToolStripSeparator()); securityMenuItem.Click += securityClick; configurationToolStripMenuItem.DropDownItems.Add(securityMenuItem); securityMenuItem.ShortcutKeys = (Keys.Control | Keys.W); ShowIcon = true; Icon = Properties.Resources.serverManager; //Repository management, should be part of the installation _repository = Repository.Create(); if (_repository == null) { _repository = new Repository(); MessageBox.Show("No repository has been defined or found for this installation. Reports will not be rendered. Please modify the .configuration file to set a RepositoryPath containing at least a Views subfolder", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } //handle program args string[] args = Environment.GetCommandLineArgs(); bool open = (args.Length >= 2 && args[1].ToLower() == "/o"); string fileToOpen = null; if (args.Length >= 3 && File.Exists(args[2])) { fileToOpen = args[2]; } //and last used file if (!open && File.Exists(Properties.Settings.Default.LastUsedFile)) { open = true; fileToOpen = Properties.Settings.Default.LastUsedFile; } if (open && HasValidRepositoryDirectory(fileToOpen)) { openFile(fileToOpen); } else { IsModified = false; init(); } }
private void _personDemo_CollectionEditCompleted(object sender, EventArgs e) { PropertyGridHelper.SetSelectedObject(propertyGrid1, null); //PropertyGridHelper.SetSelectedObject(propertyGrid1, _personDemo); }
private void FTestPRopertyGrid_FormClosing(object sender, FormClosingEventArgs e) { PropertyGridHelper.SetSelectedObject(propertyGrid1, null); }
private object selectObject(PropertyGridHelper pgHelper, object[] objKeys) { object objReturn = null; CustomClass selectedObj = pgHelper.GetDynamicClass(objKeys); if (selectedObj != null) { object[] events = new object[] { new CustomClass.PropertyChangeEventHandler(BeforePropertyChanged), new CustomClass.PropertyAfterChangeEventHandler(AfterPropertyChanged), new CustomClass.CustomEditValueEventHandler(OnCustomEditorEditValue), new CustomClass.TreeValueEventHandler(OnGetTreeValue), }; selectedObj.SetEvents(events); /* selectedObj.DataValidate -= new CustomClass.PropertyChangeEventHandler(BeforePropertyChanged); selectedObj.AfterDataValidate -= new CustomClass.PropertyAfterChangeEventHandler(AfterPropertyChanged); selectedObj.OnEditValue -= new CustomClass.CustomEditValueEventHandler(OnCustomEditorEditValue); selectedObj.OnGetTreeValue -= new CustomClass.TreeValueEventHandler(OnGetTreeValue); selectedObj.DataValidate += new CustomClass.PropertyChangeEventHandler(BeforePropertyChanged); selectedObj.AfterDataValidate += new CustomClass.PropertyAfterChangeEventHandler(AfterPropertyChanged); selectedObj.OnEditValue += new CustomClass.CustomEditValueEventHandler(OnCustomEditorEditValue); selectedObj.OnGetTreeValue += new CustomClass.TreeValueEventHandler(OnGetTreeValue); */ objReturn = selectedObj; } return objReturn; }