private void CreateShape(System.Windows.Forms.DragEventArgs e) { Nullable <SpriteDropData> data = GetData(e); if (data != null) { SpriteShape entity = new SpriteShape(data.Value._name); entity.SpriteSheetFilename = data.Value._sheet; entity.ShoeBoxData = data.Value._xml; entity.SetHint(ShapeBase.HintFlags_e.RetainPositionAtCreation, true); _dummyShape = entity; } }
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { if (context != null && context.Instance != null && provider != null) { SpriteShape shape = (SpriteShape)context.Instance; // get the editor service editorService = provider.GetService(typeof(IWindowsFormsEditorService)) as IWindowsFormsEditorService; if (editorService != null) { // Create a ListBox and populate it with all (allowed) the enum values listBox = new ListBox(); listBox.BorderStyle = BorderStyle.None; listBox.MouseUp += new MouseEventHandler(this.OnMouseUp); listBox.MouseMove += new MouseEventHandler(this.OnMouseMoved); listBox.KeyDown += new KeyEventHandler(this.OnKeyDown); // create a tooltip tooltipControl = new ToolTip(); tooltipControl.ShowAlways = true; FillListBox(shape, context, provider, value, listBox); listBox.IntegralHeight = false; int items = listBox.Items.Count; if (items > 10) { items = 10; } listBox.Height = items * listBox.ItemHeight; // reset cancel edit cancelEdit = false; // Show our listbox as a DropDownControl. // this methods returns when the dropdowncontrol is closed editorService.DropDownControl(listBox); // if the editing has been canceled if (cancelEdit) { // return the old value return(value); } // return the selected enum value return(listBox.SelectedItem.ToString()); } } return(value); }
/// <summary> /// Overridable that is called to fill the combobox with data. The default implementation parses the enum values /// </summary> /// <param name="context"></param> /// <param name="provider"></param> /// <param name="value"></param> /// <param name="list"></param> public virtual void FillListBox(SpriteShape shape, ITypeDescriptorContext context, IServiceProvider provider, object value, ListBox list) { string[] names = shape.EngineNode.GetStateNames(); string currentState = shape.EngineNode.GetCurrentState(); foreach (string name in names) { // Creates a clbItem that stores the name, the int value and the tooltip int added = list.Items.Add(new ListItem(name, 0, "")); if (name == currentState) { list.SelectedIndex = added; } } }
public override void DragDrop(object sender, System.Windows.Forms.DragEventArgs e) { CreateShape(e); // Clones the dummy and places it correctly into the scene. EditorManager.ActiveView.DropObject(_dummyShape, e); EditorManager.ActiveView.Focus(); Vector3F position = GetPosition(e); SpriteShape newShape = EditorManager.ActiveView.Gizmo.Shapes[0] as SpriteShape; newShape.SetCenterPosition(position.X, position.Y); EditorManager.ActiveView.Gizmo.Position = position; //EditorManager.ActiveView.Gizmo // Cleanup DragLeave(); }
/// <summary> /// Constructor /// </summary> /// <param name="owner"></param> /// <param name="fSize"></param> public HotSpot2D(SpriteShape owner, float fSize) : base(owner, null, VisionColors.White, HotSpotBase.PickType.Circle, fSize) { _fSize = fSize; }