/// <summary> /// /// </summary> public void InitializeEditor(ILog log) { try { _editor = Editor.Create(_projectFactory.GetProject(), _renderers); if (log != null) { _editor.Log = log; _editor.Log.Initialize("Test2d.log"); } _commands = new EditorCommands(); _commands.NewCommand = Command<object>.Create( (item) => OnNew(item), (item) => IsEditMode()); _commands.CloseCommand = Command.Create( () => OnClose(), () => IsEditMode()); _commands.ExitCommand = Command.Create( () => OnExit(), () => true); _commands.UndoCommand = Command.Create( () => OnUndo(), () => IsEditMode() /* && CanUndo() */); _commands.RedoCommand = Command.Create( () => OnRedo(), () => IsEditMode() /* && CanRedo() */); _commands.CutCommand = Command<object>.Create( (item) => OnCut(item), (item) => IsEditMode() /* && CanCopy() */); _commands.CopyCommand = Command<object>.Create( (item) => OnCopy(item), (item) => IsEditMode() /* && CanCopy() */); _commands.PasteCommand = Command<object>.Create( (item) => OnPaste(item), (item) => IsEditMode() /* && CanPaste() */); _commands.DeleteCommand = Command<object>.Create( (item) => OnDelete(item), (item) => IsEditMode() /* && _editor.IsSelectionAvailable() */); _commands.SelectAllCommand = Command.Create( () => OnSelectAll(), () => IsEditMode()); _commands.DeselectAllCommand = Command.Create( () => OnDeselectAll(), () => IsEditMode()); _commands.ClearAllCommand = Command.Create( () => OnClearAll(), () => IsEditMode()); _commands.GroupCommand = Command.Create( () => _editor.GroupSelected(), () => IsEditMode() /* && _editor.IsSelectionAvailable() */); _commands.UngroupCommand = Command.Create( () => _editor.UngroupSelected(), () => IsEditMode() /* && _editor.IsSelectionAvailable() */); _commands.BringToFrontCommand = Command.Create( () => _editor.BringToFrontSelected(), () => IsEditMode() /* && _editor.IsSelectionAvailable() */); _commands.SendToBackCommand = Command.Create( () => _editor.SendToBackSelected(), () => IsEditMode() /* && _editor.IsSelectionAvailable() */); _commands.BringForwardCommand = Command.Create( () => _editor.BringForwardSelected(), () => IsEditMode() /* && _editor.IsSelectionAvailable() */); _commands.SendBackwardCommand = Command.Create( () => _editor.SendBackwardSelected(), () => IsEditMode() /* && _editor.IsSelectionAvailable() */); _commands.MoveUpCommand = Command.Create( () => _editor.MoveUpSelected(), () => IsEditMode() /* && _editor.IsSelectionAvailable() */); _commands.MoveDownCommand = Command.Create( () => _editor.MoveDownSelected(), () => IsEditMode() /* && _editor.IsSelectionAvailable() */); _commands.MoveLeftCommand = Command.Create( () => _editor.MoveLeftSelected(), () => IsEditMode() /* && _editor.IsSelectionAvailable() */); _commands.MoveRightCommand = Command.Create( () => _editor.MoveRightSelected(), () => IsEditMode() /* && _editor.IsSelectionAvailable() */); _commands.ToolNoneCommand = Command.Create( () => OnToolNone(), () => IsEditMode()); _commands.ToolSelectionCommand = Command.Create( () => OnToolSelection(), () => IsEditMode()); _commands.ToolPointCommand = Command.Create( () => OnToolPoint(), () => IsEditMode()); _commands.ToolLineCommand = Command.Create( () => OnToolLine(), () => IsEditMode()); _commands.ToolArcCommand = Command.Create( () => OnToolArc(), () => IsEditMode()); _commands.ToolBezierCommand = Command.Create( () => OnToolBezier(), () => IsEditMode()); _commands.ToolQBezierCommand = Command.Create( () => OnToolQBezier(), () => IsEditMode()); _commands.ToolPathCommand = Command.Create( () => OnToolPath(), () => IsEditMode()); _commands.ToolRectangleCommand = Command.Create( () => OnToolRectangle(), () => IsEditMode()); _commands.ToolEllipseCommand = Command.Create( () => OnToolEllipse(), () => IsEditMode()); _commands.ToolTextCommand = Command.Create( () => OnToolText(), () => IsEditMode()); _commands.ToolImageCommand = Command.Create( () => OnToolImage(), () => IsEditMode()); _commands.ToolMoveCommand = Command.Create( () => OnToolMove(), () => IsEditMode()); _commands.DefaultIsStrokedCommand = Command.Create( () => OnToggleDefaultIsStroked(), () => IsEditMode()); _commands.DefaultIsFilledCommand = Command.Create( () => OnToggleDefaultIsFilled(), () => IsEditMode()); _commands.DefaultIsClosedCommand = Command.Create( () => OnToggleDefaultIsClosed(), () => IsEditMode()); _commands.DefaultIsSmoothJoinCommand = Command.Create( () => OnToggleDefaultIsSmoothJoin(), () => IsEditMode()); _commands.SnapToGridCommand = Command.Create( () => OnToggleSnapToGrid(), () => IsEditMode()); _commands.TryToConnectCommand = Command.Create( () => OnToggleTryToConnect(), () => IsEditMode()); _commands.AddDatabaseCommand = Command.Create( () => OnAddDatabase(), () => IsEditMode()); _commands.RemoveDatabaseCommand = Command<object>.Create( (db) => OnRemoveDatabase(db), (db) => IsEditMode()); _commands.AddColumnCommand = Command<object>.Create( (owner) => OnAddColumn(owner), (owner) => IsEditMode()); _commands.RemoveColumnCommand = Command<object>.Create( (parameter) => OnRemoveColumn(parameter), (parameter) => IsEditMode()); _commands.AddRecordCommand = Command.Create( () => OnAddRecord(), () => IsEditMode()); _commands.RemoveRecordCommand = Command.Create( () => OnRemoveRecord(), () => IsEditMode()); _commands.ResetRecordCommand = Command<object>.Create( (owner) => OnResetRecord(owner), (owner) => IsEditMode()); _commands.AddBindingCommand = Command<object>.Create( (owner) => OnAddBinding(owner), (owner) => IsEditMode()); _commands.RemoveBindingCommand = Command<object>.Create( (parameter) => OnRemoveBinding(parameter), (parameter) => IsEditMode()); _commands.AddPropertyCommand = Command<object>.Create( (owner) => OnAddProperty(owner), (owner) => IsEditMode()); _commands.RemovePropertyCommand = Command<object>.Create( (parameter) => OnRemoveProperty(parameter), (parameter) => IsEditMode()); _commands.AddGroupLibraryCommand = Command.Create( () => OnAddGroupLibrary(), () => IsEditMode()); _commands.RemoveGroupLibraryCommand = Command.Create( () => OnRemoveGroupLibrary(), () => IsEditMode()); _commands.AddGroupCommand = Command.Create( () => OnAddGroup(), () => IsEditMode()); _commands.RemoveGroupCommand = Command.Create( () => OnRemoveGroup(), () => IsEditMode()); _commands.AddLayerCommand = Command.Create( () => OnAddLayer(), () => IsEditMode()); _commands.RemoveLayerCommand = Command.Create( () => OnRemoveLayer(), () => IsEditMode()); _commands.AddStyleLibraryCommand = Command.Create( () => OnAddStyleLibrary(), () => IsEditMode()); _commands.RemoveStyleLibraryCommand = Command.Create( () => OnRemoveStyleLibrary(), () => IsEditMode()); _commands.AddStyleCommand = Command.Create( () => OnAddStyle(), () => IsEditMode()); _commands.RemoveStyleCommand = Command.Create( () => OnRemoveStyle(), () => IsEditMode()); _commands.RemoveShapeCommand = Command.Create( () => OnRemoveShape(), () => IsEditMode()); _commands.AddTemplateCommand = Command.Create( () => OnAddTemplate(), () => IsEditMode()); _commands.RemoveTemplateCommand = Command.Create( () => OnRemoveTemplate(), () => IsEditMode()); _commands.EditTemplateCommand = Command.Create( () => OnEditTemplate(), () => IsEditMode()); _commands.ApplyTemplateCommand = Command<object>.Create( (item) => OnApplyTemplate(item), (item) => true); _commands.SelectedItemChangedCommand = Command<object>.Create( (item) => OnSelectedItemChanged(item), (item) => IsEditMode()); _commands.AddContainerCommand = Command<object>.Create( (item) => OnAddContainer(item), (item) => IsEditMode()); _commands.InsertContainerBeforeCommand = Command<object>.Create( (item) => OnInsertContainerBefore(item), (item) => IsEditMode()); _commands.InsertContainerAfterCommand = Command<object>.Create( (item) => OnInsertContainerAfter(item), (item) => IsEditMode()); _commands.AddDocumentCommand = Command<object>.Create( (item) => OnAddDocument(item), (item) => IsEditMode()); _commands.InsertDocumentBeforeCommand = Command<object>.Create( (item) => OnInsertDocumentBefore(item), (item) => IsEditMode()); _commands.InsertDocumentAfterCommand = Command<object>.Create( (item) => OnInsertDocumentAfter(item), (item) => IsEditMode()); } catch (Exception ex) { if (_editor != null && _editor.Log != null) { _editor.Log.LogError("{0}{1}{2}", ex.Message, Environment.NewLine, ex.StackTrace); } else { Debug.WriteLine(ex.Message); Debug.WriteLine(ex.StackTrace); } } }