private void SetType(Type controlType) { var uiControls = ParentEditor.Values; if (Presenter.Undo != null) { using (new UndoMultiBlock(Presenter.Undo, uiControls, "Set Control Type")) { for (int i = 0; i < uiControls.Count; i++) { var uiControl = (UIControl)uiControls[i]; uiControl.Control = (Control)Activator.CreateInstance(controlType); } } } else { for (int i = 0; i < uiControls.Count; i++) { var uiControl = (UIControl)uiControls[i]; uiControl.Control = (Control)Activator.CreateInstance(controlType); } } ParentEditor.RebuildLayout(); }
private void spriteBox_Paint(object sender, PaintEventArgs e) { using (Bitmap b = new Bitmap(width / zoom, height / zoom)) { ParentEditor.Sprite.Invalidate(); ParentEditor.DrawSprite(b, Sprite); e.Graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor; e.Graphics.DrawImage(b, 0, 0, width, height); } }
/// <inheritdoc /> public override void Refresh() { if (Values.Count == 1) { var scripts = ((Actor)ParentEditor.Values[0]).Scripts; if (!Utils.ArraysEqual(scripts, _scripts)) { ParentEditor.RebuildLayout(); return; } } base.Refresh(); }
/// <inheritdoc /> public override void Refresh() { base.Refresh(); // Check if type has been modified outside the editor (eg. from code) if (Type != _type) { if (ParentEditor != null) { ParentEditor.RebuildLayout(); } else { RebuildLayout(); } } }
/// <inheritdoc /> public override void Refresh() { if (Values.Count == 1) { var scripts = ((Actor)ParentEditor.Values[0]).Scripts; if (!Utils.ArraysEqual(scripts, _scripts)) { ParentEditor.RebuildLayout(); return; } for (int i = 0; i < _scriptToggles.Length; i++) { if (_scriptToggles[i] != null) { _scriptToggles[i].Checked = scripts[i].Enabled; } } } base.Refresh(); }
/// <summary> /// Clears the token assigned with <see cref="OnDirty"/> parameter. Called on merged undo action end (eg. users stops using slider). /// </summary> protected virtual void ClearToken() { ParentEditor.ClearToken(); }
/// <summary> /// Called when custom editor gets dirty (UI value has been modified). /// Allows to filter the event, block it or handle in a custom way. /// </summary> /// <param name="editor">The editor.</param> /// <param name="value">The value.</param> /// <param name="token">The source editor token used by the value setter to support batching Undo actions (eg. for sliders or color pickers).</param> /// <returns>True if allow to handle this event, otherwise false.</returns> protected virtual bool OnDirty(CustomEditor editor, object value, object token = null) { ParentEditor.OnDirty(editor, value, token); return(true); }
public Dictionary <string, STGenericTexture> GetTextures() { return(ParentEditor.GetTextures()); }
protected override void OnMouseDown(MouseEventArgs e) { this.Focus(); if (this.ParentEditor.SelectedCompositeKeyFrame != null) { if (e.Button == MouseButtons.Left) { // if click on an item if (this.HighlightedBone != null) { // new item to select if (!this.SelectedBones.Contains(this.HighlightedBone)) { // Checks to see that Control or Shift are not pressed if ((Control.ModifierKeys & Keys.Control) != Keys.Control && (Control.ModifierKeys & Keys.Shift) != Keys.Shift) { this.SelectedBones.Clear(); this.SelectedBones.Add(this.HighlightedBone); ParentEditor.IgnoreBoneTransformSelectionEvent = true; ParentEditor.SelectBoneTransformsOnTreeFromScene(); ParentEditor.IgnoreBoneTransformSelectionEvent = false; } // Multiple selection else { // add it to the selection this.SelectedBones.Add(this.HighlightedBone); ParentEditor.IgnoreBoneTransformSelectionEvent = true; ParentEditor.SelectBoneTransformsOnTreeFromScene(); ParentEditor.IgnoreBoneTransformSelectionEvent = false; } _isDraggingItem = false; } // if the item is already selected, start dragging if (this.SelectedBones.Contains(this.HighlightedBone)) { _dragItemStartPos = SceneMousePos; _isDraggingItem = true; } } // if click in the void else { this.SelectedBones.Clear(); ParentEditor.IgnoreBoneTransformSelectionEvent = true; ParentEditor.SelectBoneTransformsOnTreeFromScene(); ParentEditor.IgnoreBoneTransformSelectionEvent = false; _isDraggingItem = false; } } else if (e.Button == MouseButtons.Right) { _isDraggingScene = true; this.Cursor = Cursors.NoMove2D; _dragSceneStartPos = this.RealMousePos; } else if (e.Button == MouseButtons.Middle) { // if the item is already selected, set pivot if (this.SelectedBones.Contains(this.HighlightedBone)) { CompositeBoneTransform boneTransform = ParentEditor.SelectedCompositeKeyFrame.GetBoneTransformFromKeyFrame( ParentEditor.SelectedCompositeKeyFrame, this.HighlightedBone); SceneItem boneTransformSceneItem = boneTransform.GetSceneItem(); if (boneTransform.IsVisible == true && boneTransformSceneItem != null) { Rectangle boundingRect = boneTransformSceneItem.BoundingRect; Vector2 diff = new Vector2(SceneMousePos.X - boundingRect.X, SceneMousePos.Y - boundingRect.Y); Console.WriteLine("Diff " + boneTransformSceneItem.Name + "] " + diff); boneTransformSceneItem.Pivot = diff; boneTransformSceneItem.IsPivotRelative = false; } } } base.OnMouseDown(e); } }
protected override void Draw() { DrawingManager.ViewPortSize = new Point(this.Width, this.Height); ParentEditor.ZoomBox.Camera.Update(1 / 60f); GraphicsDevice.Clear(Color.CornflowerBlue); // Use SpriteSortMode.Immediate, so we can apply custom renderstates. _spriteBatch.Begin(SpriteBlendMode.AlphaBlend, SpriteSortMode.Immediate, SaveStateMode.SaveState); // Set the texture addressing mode to wrap, so we can repeat // many copies of our tiled checkerboard texture. GraphicsDevice.SamplerStates[0].AddressU = TextureAddressMode.Wrap; GraphicsDevice.SamplerStates[0].AddressV = TextureAddressMode.Wrap; Rectangle fullRect = new Rectangle(0, 0, this.Width, this.Height); // Draw a tiled checkerboard pattern in the background. _spriteBatch.Draw(_checkerTexture, fullRect, fullRect, new Color(64, 64, 92)); if (CompositeEntity == null) { _spriteBatch.End(); } else { _spriteBatch.End(); float gridSize = 100000; DrawingManager.DrawFilledRectangle(10, new Vector2(-gridSize, 0), new Vector2(gridSize * 2, 1), new Color(128, 128, 128, 40), DrawingBlendingType.Alpha); DrawingManager.DrawFilledRectangle(10, new Vector2(0, -gridSize), new Vector2(1, gridSize * 2), new Color(128, 128, 128, 40), DrawingBlendingType.Alpha); DrawingManager.DrawFilledRectangle(10, new Vector2(-gridSize, 213), new Vector2(gridSize * 2, 1), new Color(255, 0, 255, 0), DrawingBlendingType.Alpha); CompositeEntity.Position = new Vector2(0); if (ParentEditor.SelectedCompositeKeyFrame != null) { DrawKeyFrame(ParentEditor.SelectedCompositeKeyFrame); if (String.IsNullOrEmpty(this.HighlightedBone) == false) { DrawBoneSceneItemBoundingRect(this.HighlightedBone, Color.Gray); } foreach (String boneTransformRef in this.SelectedBones) { DrawBoneSceneItemBoundingRect(boneTransformRef, Color.Blue); } if (_refreshSceneItemProperties == true) { ParentEditor.propertyGridCompositeBoneTransform.SelectedObject = this.ParentEditor.SelectedCompositeBoneTransform; _refreshSceneItemProperties = false; } } MilkshakeForm.SwapCameraAndRenderScene(ParentEditor.ZoomBox.Camera); // draw Pivot if (String.IsNullOrEmpty(this.HighlightedBone) != true) { _spriteBatch.Begin(SpriteBlendMode.AlphaBlend, SpriteSortMode.Immediate, SaveStateMode.None); Vector2 offset = new Vector2(this.Width / 2f, this.Height / 2f); CompositeBoneTransform boneTransform = ParentEditor.SelectedCompositeKeyFrame.GetBoneTransformFromKeyFrame( ParentEditor.SelectedCompositeKeyFrame, this.HighlightedBone); SceneItem boneTransformSceneItem = boneTransform.GetSceneItem(); if (boneTransform.IsVisible == true && boneTransformSceneItem != null) { Rectangle boundingRect = boneTransformSceneItem.BoundingRect; Vector2 pivotPos = offset + boneTransformSceneItem.GetAbsolutePivot(true) + new Vector2(boundingRect.X, boundingRect.Y); _spriteBatch.Draw(_pivotTexture, pivotPos, null, Color.White, 0, new Vector2(6.5f), Vector2.One, SpriteEffects.None, 1); } _spriteBatch.End(); } } if (ParentEditor.UpdatePreview == true) { ParentEditor.UpdatePreview = false; ParentEditor.PreviewAnimation(); } ParentEditor.Update(1 / 60f); }
public void ReloadActions() { ActionGroupDesignerHolder holder = DesignerHolder as ActionGroupDesignerHolder; AB_Squential actions = holder.Actions; bool b = holder.DisableUndo; holder.DisableUndo = true; holder.ClearAllComponent(); Controls.Clear(); BranchList bl = actions.ActionList; LoadActions(bl); //load component icons List <ComponentIcon> iconList = IconList; if (iconList == null) { iconList = new List <ComponentIcon>(); } List <ComponentIcon> invalids = new List <ComponentIcon>(); foreach (ComponentIcon ci in iconList) { if (ci.ClassPointer == null) { invalids.Add(ci); } } foreach (ComponentIcon ci in invalids) { iconList.Remove(ci); } //find root ClassPointer root = holder.Designer.GetRootId(); List <IClass> objList; if (Method.IsStatic) { objList = new List <IClass>(); } else { objList = root.GetClassList(); } SubMethodInfoPointer smi = null; if (Method.SubMethod.Count > 0) { smi = Method.SubMethod.Peek() as SubMethodInfoPointer; } //initialize existing icons, creating ComponentIcon.ClassPointer foreach (ComponentIcon ic in iconList) { ic.SetDesigner(holder.Designer); ComponentIconPublic cip = ic as ComponentIconPublic; if (cip == null) { ComponentIconLocal lv = ic as ComponentIconLocal; if (lv != null) { lv.ReadOnly = true; if (!ParentEditor.LocalVariableDeclared(lv)) { lv.ScopeGroupId = actions.BranchId; } } else { } if (smi != null) { ParameterClassSubMethod sm = ic.ClassPointer as ParameterClassSubMethod; if (sm != null) { if (sm.ActionId == 0) { sm.ActionId = smi.ActionOwner.ActionId; } ParameterClass pc = ic.ClassPointer as ParameterClass; if (pc != null && pc.ObjectType != null) { if (pc.ObjectType.IsGenericParameter) { if (pc.ConcreteType == null) { if (smi.ActionOwner.MethodOwner != null) { CustomPropertyPointer cpp = smi.ActionOwner.MethodOwner.Owner as CustomPropertyPointer; if (cpp != null) { pc.ConcreteType = cpp.GetConcreteType(pc.ObjectType); } } } } } } } } else { } } //add new public component icons int x0 = 10; int y0 = 30; int x = x0; int y = y0; int dx = 10; int dy = 10; foreach (IClass c in objList) { bool bFound = false; foreach (ComponentIcon ic in iconList) { if (ic.ClassPointer == null) { } else { if (ic.ClassPointer.IsSameObjectRef(c)) { bFound = true; break; } } } if (!bFound) { ComponentIconPublic cip = new ComponentIconPublic(holder.Designer, c, Method); cip.Location = new Point(x, y); y += dy; y += cip.Height; if (y >= this.Height) { y = y0; x += dx; x += cip.Width; } iconList.Add(cip); } } //add new local component icons List <ComponentIcon> picons = ParentEditor.IconList; foreach (ComponentIcon lv in picons) { ComponentIconPublic cip0 = lv as ComponentIconPublic; if (cip0 == null) { bool bFound = false; foreach (ComponentIcon ic in iconList) { if (ic.ClassPointer.IsSameObjectRef(lv.ClassPointer)) { bFound = true; break; } } if (!bFound) { ComponentIcon cip = (ComponentIcon)lv.Clone(); cip.SetDesigner(holder.Designer); cip.ReadOnly = true; cip.Location = new Point(x, y); y += dy; y += cip.Height; if (y >= this.Height) { y = y0; x += dx; x += cip.Width; } iconList.Add(cip); } } } //add parameters if (Method.ParameterCount > 0) { foreach (ParameterClass c in Method.Parameters) { bool bFound = false; foreach (ComponentIcon ic in iconList) { if (ic.ClassPointer.IsSameObjectRef(c)) { bFound = true; break; } } if (!bFound) { ComponentIconParameter cip = new ComponentIconParameter(holder.Designer, c, Method); cip.Location = new Point(x, y); y += dy; y += cip.Height; if (y >= this.Height) { y = y0; x += dx; x += cip.Width; } iconList.Add(cip); } } } //add action parameters ISingleAction sa = actions as ISingleAction; if (sa != null && sa.ActionData != null && sa.ActionData.ActionMethod != null && sa.ActionData.ActionMethod.MethodPointed.MethodParameterTypes != null) { List <ParameterClass> plist = new List <ParameterClass>(); SubMethodInfoPointer smp = sa.ActionData.ActionMethod.MethodPointed as SubMethodInfoPointer; if (smp != null) { foreach (ParameterClassSubMethod p in smp.Parameters) { plist.Add(p); } } else { foreach (IParameter p in sa.ActionData.ActionMethod.MethodPointed.MethodParameterTypes) { ParameterClass c = p as ParameterClass; if (c == null) { try { c = sa.ActionData.ActionMethod.MethodPointed.GetParameterType(p.ParameterID) as ParameterClass; if (c == null) { DesignUtil.WriteToOutputWindowAndLog("Cannot get ParameterClass {0} for method {1} of {2}.", p.Name, sa.ActionData.ActionMethod.MethodName, sa.ActionData.ActionMethod.MethodPointed.GetType()); continue; } } catch (Exception errp) { DesignUtil.WriteToOutputWindowAndLog(errp, "Cannot get ParameterClass {0} for method {1} of {2}", p.Name, sa.ActionData.ActionMethod.MethodName, sa.ActionData.ActionMethod.MethodPointed.GetType()); continue; } } if (c != null) { plist.Add(c); } } } foreach (ParameterClass c in plist) { bool bFound = false; foreach (ComponentIcon ic in iconList) { if (ic.ClassPointer.IsSameObjectRef(c)) { ParameterClass c0 = ic.ClassPointer as ParameterClass; c0.ReadOnly = true; c0.Description = c.Description; bFound = true; break; } } if (!bFound) { ComponentIcon cip; ActionBranchParameter abp = c as ActionBranchParameter; if (abp != null) { cip = new ComponentIconActionBranchParameter(actions); cip.ClassPointer = abp; cip.SetDesigner(holder.Designer); } else { cip = new ComponentIconParameter(holder.Designer, c, Method); } cip.Location = new Point(x, y); y += dy; y += cip.Height; if (y >= this.Height) { y = y0; x += dx; x += cip.Width; } iconList.Add(cip); } } } //add icons holder.AddControlsToIconsHolder(iconList.ToArray()); foreach (ComponentIcon ic in iconList) { ComponentIconPublic cip = ic as ComponentIconPublic; if (cip == null) { if (ic.Left < 0) { ic.Left = 2; } if (ic.Top < 0) { ic.Top = 2; } ic.BringToFront(); ic.RefreshLabelPosition(); ic.RefreshLabelText(); ComponentIconLocal cil = ic as ComponentIconLocal; if (cil != null) { cil.HookNameChecker(); } } } //} InitializeInputTypes(); ValidateControlPositions(); holder.DisableUndo = b; }