Esempio n. 1
0
        public PresentationGuiCommands(Lazy <IViewService> viewServiceLazy,
                                       IToolService toolService, IToolFactory toolFactory, IUndoRedoService undoRedoService, IAmDiBasedObjectFactory objectFactory)
        {
            this.toolService     = toolService;
            this.toolFactory     = toolFactory;
            this.undoRedoService = undoRedoService;
            this.objectFactory   = objectFactory;
            this.viewServiceLazy = viewServiceLazy;

            //LayoutHere = GuiCommandsHelper.Create("Layout Here", ExecLayoutHere);
            Move                 = new GuiCommand("Move", KeyModifiers.Control, Key.T, ExecMove);
            Move3D               = new GuiCommand("Move3D", KeyModifiers.Control | KeyModifiers.Shift, Key.T, ExecMove3D);
            Rotate               = new GuiCommand("Rotate", KeyModifiers.Control, Key.R, ExecRotate);
            Scale                = new GuiCommand("Scale", KeyModifiers.Control, Key.E, ExecScale);
            Cut                  = new GuiCommand("Cut", KeyModifiers.Control, Key.X, ExecCut);
            Copy                 = new GuiCommand("Copy", KeyModifiers.Control, Key.C, ExecCopy);
            Paste                = new GuiCommand("Paste", KeyModifiers.Control, Key.V, ExecPaste);
            Duplicate            = new GuiCommand("Duplicate", KeyModifiers.Control, Key.D, ExecDuplicate);
            Delete               = new GuiCommand("Delete", Key.Delete, ExecDelete);
            FocusView            = new GuiCommand("Focus View", KeyModifiers.Control, Key.Enter, ExecFocusView);
            AddNewAdaptiveLayout = new GuiCommand("Adaptive Layout", ExecNewAdaptiveLayout);
            MoveUp               = new GuiCommand("Move Up", KeyModifiers.Control, Key.Up, ExecMoveUp);
            MoveDown             = new GuiCommand("Move Down", KeyModifiers.Control, Key.Down, ExecMoveDown);
            SetBorderCurve       = new GuiCommand("Set Border Curve", ExecSetBorderCurve);
            MakeScenePortal      = new GuiCommand("Make Scene Portal", ExecMakeScenePortal);
        }
Esempio n. 2
0
        public static ISceneNode CreateWorldNodeWithComponent <TComponent>(this IAmDiBasedObjectFactory factory, out TComponent component)
            where TComponent : ISceneNodeComponent
        {
            var node = factory.Create <SceneNode>();

            component = factory.Create <TComponent>();
            node.Components.Add(component);
            return(node);
        }
 public DefaultStateInitializer(IViewService viewService, IWorldTreeService worldTreeService, Lazy <IAppModeService> appModeServiceLazy,
                                ICommonNodeFactory commonNodeFactory, IAmDiBasedObjectFactory objectFactory, IStoryService storyService, IGui gui)
 {
     this.viewService        = viewService;
     this.worldTreeService   = worldTreeService;
     this.appModeServiceLazy = appModeServiceLazy;
     this.commonNodeFactory  = commonNodeFactory;
     this.objectFactory      = objectFactory;
     this.storyService       = storyService;
     this.gui = gui;
 }
 public AmSerializationNecessitiesProvider(IAmDiBasedObjectFactory objectFactory)
 {
     SerializationTypes = new[]
     {
         SaveLoadConstants.BasicSerializationType,
         SaveLoadConstants.WorldSerializationType
     };
     Families = new ITrwSerializationHandlerFamily[]
     {
         new AmObjectSerializationHandlerFamily(objectFactory),
     };
     TypeRedirects = new ITrwSerializationTypeRedirect[]
     {
         new AmTrwTypeRedirect(),
     };
 }
Esempio n. 5
0
        public AddRectangleTool(IToolService toolService, IUndoRedoService undoRedo,
                                ICommonNodeFactory commonNodeFactory, IAmDiBasedObjectFactory objectFactory, IImage image, IMovie movie, bool text)
        {
            this.toolService = toolService;
            this.undoRedo    = undoRedo;
            if (text)
            {
                entity = commonNodeFactory.RichTextRectangle(objectFactory.Create <RichText>());
            }
            else if (movie != null)
            {
                entity = commonNodeFactory.MovieRectangleNode(movie);
            }
            else if (image != null)
            {
                entity = commonNodeFactory.ImageRectangleNode(image);
            }
            else
            {
                entity = commonNodeFactory.ColorRectangleNode(GetRandomSaturatedColor());
            }
            rectangleComponent = entity.GetComponent <IRectangleComponent>();

            if (movie != null)
            {
                aspectRatio         = (float)movie.Width / Math.Max(movie.Height, 1);
                preserveAspectRatio = true;
            }
            else if (image != null)
            {
                aspectRatio         = (float)image.Size.Width / Math.Max(image.Size.Height, 1);
                preserveAspectRatio = true;
            }

            state = State.Ready;
        }
Esempio n. 6
0
 public AmObjectSerializationHandlerFamily(IAmDiBasedObjectFactory objectFactory)
 {
     this.objectFactory = objectFactory;
 }
Esempio n. 7
0
 public CommonNodeFactory(IAmDiBasedObjectFactory objectFactory)
 {
     this.objectFactory = objectFactory;
 }
Esempio n. 8
0
        public DefaultMainForm(IUndoRedoService undoRedoService, IToolFactory toolFactory, IToolService toolService,
                               RenderControl renderControl, IAppModesCommands appModesCommands,
                               ISaveLoadGuiCommands saveLoadGuiCommands, ISceneTreeGui sceneTreeGui, /*IPropsGui propsGui,*/ IFluentGuiService fluentGuiService,
                               IAmDiBasedObjectFactory objectFactory, IAssetService assetService, IEmbeddedResources embeddedResources,
                               IResourceExplorerGui resourceExplorerGui, IReadOnlyList <IToolMenuItem> toolMenuItems, IStoryGraphGui storyGraphGui,
                               IReadOnlyList <IAssetLoader> assetLoaders, IViewService viewService, ICommonGuiObjects commonGuiObjects,
                               ISceneNodeContextMenuBuilder sceneNodeContextMenuBuilder)
        {
            this.storyGraphGui = storyGraphGui;
            ClientSize         = new Size(1280, 720);
            Title = "Clarity Worlds";

            var assetOpenFileDialog = new OpenFileDialog();

            assetOpenFileDialog.Filters.Add(new FileDialogFilter("All Assets", assetLoaders.SelectMany(x => x.FileExtensions).Distinct().ToArray()));
            foreach (var assetLoader in assetLoaders)
            {
                assetOpenFileDialog.Filters.Add(new FileDialogFilter(assetLoader.AssetTypeString,
                                                                     assetLoader.FileExtensions.ToArray()));
            }

            var toolCommands = new Command[]
            {
                new ToolCommand("Cube", toolService, () =>
                {
                    var entity  = objectFactory.Create <SceneNode>();
                    entity.Name = "NewCube";
                    entity.Components.Add(PresentationComponent.Create());
                    var modelComponent   = objectFactory.Create <ModelComponent>();
                    modelComponent.Model = embeddedResources.CubeModel();
                    modelComponent.Color = GetRandomSaturatedColor();
                    entity.Components.Add(modelComponent);
                    return(toolFactory.MoveEntity(entity, true));
                }),
                new ToolCommand("Sphere", toolService, () =>
                {
                    var entity  = objectFactory.Create <SceneNode>();
                    entity.Name = "NewSphere";
                    entity.Components.Add(PresentationComponent.Create());
                    var modelComponent   = objectFactory.Create <ModelComponent>();
                    modelComponent.Model = embeddedResources.SphereModel(64);
                    modelComponent.Color = GetRandomSaturatedColor();
                    entity.Components.Add(modelComponent);
                    return(toolFactory.MoveEntity(entity, true));
                }),
                new ToolCommand("Rectangle", toolService, toolFactory.AddRectangle),
                new ToolCommand("Text", toolService, toolFactory.AddText),
                new ToolCommand("Asset", toolService, () =>
                {
                    assetOpenFileDialog.ShowDialog(this);
                    var loadPath = assetOpenFileDialog.FileName;
                    if (loadPath == null)
                    {
                        return(null);
                    }
                    var loadInfo = new AssetLoadInfo
                    {
                        FileSystem    = ActualFileSystem.Singleton,
                        LoadPath      = loadPath,
                        ReferencePath = loadPath,
                        StorageType   = AssetStorageType.CopyLocal
                    };
                    var assetLoadResult = assetService.Load(loadInfo);
                    if (!assetLoadResult.Successful)
                    {
                        MessageBox.Show(assetLoadResult.Message);
                        return(null);
                    }

                    var asset = assetLoadResult.Asset;
                    IResource resource;
                    if (asset.Resource == null)
                    {
                        MessageBox.Show($"The asset contains no resource.");
                        return(null);
                    }
                    if (asset.Resource is ResourcePack pack)
                    {
                        resource = pack.MainSubresource;
                        if (resource == null)
                        {
                            MessageBox.Show($"The asset is a pack with no main subresource.");
                            return(null);
                        }
                    }
                    else
                    {
                        resource = asset.Resource;
                    }

                    switch (resource)
                    {
                    case IImage image:
                        return(toolFactory.AddImage(image));

                    case IMovie movie:
                        return(toolFactory.AddMovie(movie));

                    case IFlexibleModel fModel:
                        {
                            var entity  = AmFactory.Create <SceneNode>();
                            entity.Name = "NewModel";
                            entity.Components.Add(PresentationComponent.Create());
                            var modelComponent   = AmFactory.Create <ModelComponent>();
                            modelComponent.Model = fModel;
                            modelComponent.Color = GetRandomSaturatedColor();
                            entity.Components.Add(modelComponent);
                            return(toolFactory.MoveEntity(entity, true));
                        }

                    case SpherePackingResult spherePackingResult:
                        {
                            var entity  = AmFactory.Create <SceneNode>();
                            entity.Name = "NewModel";
                            entity.Components.Add(PresentationComponent.Create());
                            var modelComponent = AmFactory.Create <SpherePackingComponent>();
                            modelComponent.SpherePackingResult = spherePackingResult;
                            modelComponent.Color = GetRandomSaturatedColor();
                            entity.Components.Add(modelComponent);
                            return(toolFactory.MoveEntity(entity, true));
                        }

                    default:
                        MessageBox.Show($"Unable to instantiate an asset of type '{resource.GetType().Name}'.");
                        return(null);
                    }
                })
            }
Esempio n. 9
0
 public static void Initialize(IAmDiBasedObjectFactory actualFactory)
 {
     factory = actualFactory;
 }
Esempio n. 10
0
 public AmObjectTrwHandler(IAmDiBasedObjectFactory objectFactory)
 {
     instantiator = objectFactory.GetInstantiator <TObj>();
 }