public SchemaLoader(PropertyEditor propertyEditor) { m_propertyEditor = propertyEditor; // set resolver to locate embedded .xsd file SchemaResolver = new ResourceStreamResolver(Assembly.GetExecutingAssembly(), "FsmEditorSample/schemas"); Load("FSM_customized.xsd"); }
/// <summary> /// Raises the <see cref="E:System.Windows.Forms.Control.MouseMove"></see> event. /// </summary> /// <param name="e">A <see cref="T:System.Windows.Forms.MouseEventArgs"></see> that contains the event data.</param> protected override void OnMouseMove(MouseEventArgs e) { if (DesignView.Context != null) { Size dragBoxSize = SystemInformation.DragSize; CurrentMousePoint = new Point(e.X, e.Y); int dx = CurrentMousePoint.X - FirstMousePoint.X; int dy = CurrentMousePoint.Y - FirstMousePoint.Y; if (!m_dragOverThreshold) { if (Math.Abs(dx) > dragBoxSize.Width || Math.Abs(dy) > dragBoxSize.Height) { m_dragOverThreshold = true; if (m_mouseDownAction == MouseDownAction.Manipulating) DesignView.Manipulator.OnBeginDrag(); } } if (m_mouseDownAction == MouseDownAction.Picking) { Invalidate(); } else if (m_mouseDownAction == MouseDownAction.ControllingCamera) { CameraController.MouseMove(this, e); } else if (m_mouseDownAction == MouseDownAction.Manipulating) { if (m_dragOverThreshold) { DesignView.Manipulator.OnDragging(this, e.Location); GameLoop.Update(); GameLoop.Render(); if (m_propEditor == null) m_propEditor = Globals.MEFContainer.GetExportedValue<PropertyEditor>(); m_propEditor.PropertyGrid.RefreshProperties(); } } else if (DesignView.Manipulator != null) { bool picked = DesignView.Manipulator.Pick(this, e.Location); this.Cursor = picked ? Cursors.SizeAll : Cursors.Default; DesignView.InvalidateViews(); } else if (this.Cursor != Cursors.Default) { this.Cursor = Cursors.Default; } } if(m_dragOverThreshold) m_hitIndex = -1; base.OnMouseMove(e); }
public ClonedPropertyEditor(PropertyEditor propEditor) { var editingContext = propEditor.PropertyGrid.PropertyGridView.EditingContext; // there is no reason to clone empty property editor. if (editingContext == null) throw new ArgumentException("propEditor"); // don't create cloned property editor // if there is nothing to edit if (editingContext.PropertyDescriptors == null || !editingContext.PropertyDescriptors.Any()) return; if(editingContext is SelectionPropertyEditingContext) m_context = ((SelectionPropertyEditingContext)editingContext).SelectionContext; else m_context = editingContext; m_propertyEditor = propEditor; m_propertyEditor.Configure(out m_propertyGrid, out m_controlInfo); m_selectionButton = new ToolStripButton(); m_selectionButton.DisplayStyle = ToolStripItemDisplayStyle.Image; m_selectionButton.Image = ResourceUtil.GetImage16(Resources.SelectionFindImage); m_selectionButton.Name = "selectionButton"; m_selectionButton.Size = new Size(29, 22); m_selectionButton.ToolTipText = "Select bound object(s)".Localize(); m_selectionButton.Click += (sender, e) => { // select bound object ISelectionContext selCntx = m_context.As<ISelectionContext>(); var edCntx = m_propertyGrid.PropertyGridView.EditingContext; if (selCntx != null && edCntx != null) { selCntx.SetRange(edCntx.Items); } }; m_propertyGrid.ToolStrip.Items.Add(m_selectionButton); m_propertyGrid.PropertyGridView.ContextRegistry = propEditor.ContextRegistry; m_controlInfo.Name = propEditor.m_controlInfo.DisplayName + "_" + ++s_cloneId; m_controlInfo.Group = PropertyEditor.ClonedEditorGroup; m_controlInfo.UnregisterOnClose = true; m_propertyEditor.ControlHostService.RegisterControl(m_propertyGrid, m_controlInfo, this); m_propertyEditingContext = new CustomPropertyEditingContext(editingContext); m_propertyGrid.Bind(m_propertyEditingContext); m_propertyGrid.PropertySorting = propEditor.PropertyGrid.PropertySorting; // copy expansion state var zip = propEditor.PropertyGrid.PropertyGridView.Categories.Zip(m_propertyGrid.PropertyGridView.Categories, (src, dest) => new { src, dest }); foreach (var pair in zip) { if (pair.dest.Name == pair.src.Name) pair.dest.Expanded = pair.src.Expanded; } m_propertyGrid.MouseUp += (sender, e) => OnPropertyGridMouseUp(e); // subscribe to events. // It is necessary to unsubscribe to allow this object to be garbage collected. if (m_propertyEditor.DocumentRegistry != null) { m_propertyEditor.DocumentRegistry.DocumentRemoved += DocumentRegistry_DocumentRemoved; m_propertyEditor.DocumentRegistry.ActiveDocumentChanged += DocumentRegistry_ActiveDocumentChanged; } m_observableContext = m_context.As<IObservableContext>(); m_validationContext = m_context.As<IValidationContext>(); if (m_observableContext != null) { m_observableContext.ItemChanged += observableContext_ItemChanged; m_observableContext.ItemInserted += observableContext_ItemInserted; m_observableContext.ItemRemoved += observableContext_ItemRemoved; } if (m_validationContext != null) { m_validationContext.Beginning += validationContext_Beginning; m_validationContext.Ended += validationContext_Ended; m_validationContext.Cancelled += validationContext_Cancelled; } }