コード例 #1
0
        protected override void OnDragDrop(DragEventArgs drgevent)
        {
            base.OnDragDrop(drgevent);
            if (DesignView.Context == null)
            {
                return;
            }

            if (m_ghosts.Count > 0)
            {
                foreach (DomNode ghost in m_ghosts)
                {
                    ghost.RemoveFromParent();
                }

                var dragDropTarget = TargetGame();
                ApplicationUtil.Insert(
                    dragDropTarget,
                    dragDropTarget,
                    m_ghosts,
                    "Drag and Drop",
                    null);

                m_ghosts.Clear();
                DesignView.InvalidateViews();
            }
        }
コード例 #2
0
        protected override void OnDragDrop(DragEventArgs drgevent)
        {
            base.OnDragDrop(drgevent);
            if (DesignView.Context == null)
            {
                return;
            }

            if (m_ghosts.Count > 0)
            {
                IGame             dragDropTarget = TargetGame();
                IGameObjectFolder rootFolder     = dragDropTarget.RootGameObjectFolder;

                foreach (DomNode ghost in m_ghosts)
                {
                    rootFolder.GameObjects.Remove(ghost.As <IGameObject>());
                }
                ApplicationUtil.Insert(
                    dragDropTarget,
                    rootFolder.Cast <DomNode>(),
                    m_ghosts,
                    "Drag and Drop",
                    null);

                m_ghosts.Clear();
                DesignView.InvalidateViews();
            }
        }
コード例 #3
0
        /// <summary>
        /// Method called on Drop events</summary>
        /// <param name="e">DragEventArgs containing event information</param>
        protected override void OnDrop(DragEventArgs e)
        {
            object target = GetDropTarget(e);

            if (!ApplicationUtil.CanInsert(AssociatedObject.DataContext, target, e.Data))
            {
                return;
            }

            IDataObject dataObject = e.Data;

            if ((e.AllowedEffects & DragDropEffects.Copy) > 0 &&
                (e.KeyStates & DragDropKeyStates.ControlKey) > 0)
            {
                var registry = Composer.Current.Container.GetExportedValueOrDefault <IContextRegistry>();
                if (registry != null)
                {
                    // Attempt to get context which was the source of this drag operation
                    var ctx = registry.GetActiveContext <IInstancingContext>();
                    if (ctx != null && ctx.CanCopy())
                    {
                        object rawObject = ctx.Copy();
                        dataObject = rawObject as IDataObject ?? new DataObject(rawObject);
                    }
                }
            }

            var statusService = Composer.Current.Container.GetExportedValueOrDefault <IStatusService>();

            ApplicationUtil.Insert(AssociatedObject.DataContext, target, dataObject, "Drag Drop".Localize(), statusService);

            e.Effects = DragDropEffects.None;
            e.Handled = true;
        }
コード例 #4
0
ファイル: XLEEnvAdapter.cs プロジェクト: trizdreaming/XLE
        void ICommandClient.DoCommand(object commandTag)
        {
            if (!(commandTag is Command))
            {
                return;
            }

            switch ((Command)commandTag)
            {
            case Command.AddAmbientSettings:
                ApplicationUtil.Insert(
                    DomNode.GetRoot(), this,
                    new DomNode(Schema.ambientSettingsType.Type),
                    "Add Ambient Settings", null);
                break;

            case Command.AddToneMapSettings:
                ApplicationUtil.Insert(
                    DomNode.GetRoot(), this,
                    new DomNode(Schema.toneMapSettingsType.Type),
                    "Add Tone Map Settings", null);
                break;

            case Command.AddSun:
            {
                // the "Sun" is just a directional light with the name "Sun"
                var sun = new DomNode(Schema.directionalLightType.Type);
                sun.SetAttribute(Schema.envObjectType.nameAttribute, "Sun");
                ApplicationUtil.Insert(DomNode.GetRoot(), this, sun, "Add Sun", null);
                ApplicationUtil.Insert(
                    DomNode.GetRoot(), this,
                    new DomNode(Schema.envUtilityType.Type),
                    "Add Environment Utility", null);
                break;
            }

            case Command.AddAreaLight:
                ApplicationUtil.Insert(
                    DomNode.GetRoot(), this,
                    new DomNode(Schema.areaLightType.Type),
                    "Add Area Light", null);
                break;

            case Command.AddDirectionalLight:
                ApplicationUtil.Insert(
                    DomNode.GetRoot(), this,
                    new DomNode(Schema.directionalLightType.Type),
                    "Add Directional Light", null);
                break;

            case Command.AddShadowSettings:
                ApplicationUtil.Insert(
                    DomNode.GetRoot(), this,
                    new DomNode(Schema.envSettingsType.Type),
                    "Add Environment Settings", null);
                break;
            }
        }
コード例 #5
0
 /// <summary>
 /// Event fired when an item is dropped onto the control</summary>
 /// <param name="e">Event args</param>
 protected override void OnDrop(DragEventArgs e)
 {
     if (ApplicationUtil.CanInsert(AssociatedObject.DataContext, null, e.Data))
     {
         var statusService = Composer.Current.Container.GetExportedValueOrDefault <IStatusService>();
         ApplicationUtil.Insert(AssociatedObject.DataContext, null, e.Data, "Drag Drop".Localize(), statusService);
         e.Effects = DragDropEffects.None;
         e.Handled = true;
     }
 }
コード例 #6
0
        void ICommandClient.DoCommand(object commandTag)
        {
            if (!(commandTag is Command))
            {
                return;
            }

            switch ((Command)commandTag)
            {
            case Command.AddVegetationSpawnMaterial:
            {
                var mat = VegetationSpawnMaterialItem.Create(GetNextMaterialId());
                ApplicationUtil.Insert(DomNode.GetRoot(), this, mat, "Add Decoration Material", null);
            }
            break;
            }
        }
コード例 #7
0
        /// <summary>
        /// Handle Drop event</summary>
        /// <param name="e">Drag event arguments</param>
        protected override void OnDrop(DragEventArgs e)
        {
            var pos    = e.GetPosition(AssociatedObject);
            var parent = AssociatedObject.GetItemAtPoint(pos);

            if (parent == null)
            {
                parent = AssociatedObject.DataContext;
            }

            if (ApplicationUtil.CanInsert(AssociatedObject.DataContext, parent, e.Data))
            {
                var statusService = Composer.Current.Container.GetExportedValueOrDefault <IStatusService>();
                ApplicationUtil.Insert(AssociatedObject.DataContext, parent, e.Data, "Drag Drop".Localize(), statusService);
                e.Effects = DragDropEffects.None;
                e.Handled = true;
            }
        }
コード例 #8
0
        private void CreateTerrainBtnClick(object sender, EventArgs e)
        {
            using (var dlg = new CreateTerrainDlg(Globals.ResourceRoot.LocalPath))
            {
                if (dlg.ShowDialog(this) == DialogResult.OK)
                {
                    TerrainGob terrain   = TerrainGob.Create(dlg.TerrainName, dlg.HeightMapPath, dlg.CellSize);
                    var        xformable = terrain.As <ITransformable>();
                    xformable.Translation = new Vec3F(-dlg.CellSize * (dlg.HmapCols - 1) / 2.0f, 0.0f, -dlg.CellSize * (dlg.HmapRows - 1) / 2.0f);
                    xformable.UpdateTransform();

                    ApplicationUtil.Insert(GameContext,
                                           GameContext.RootGameObjectFolder,
                                           terrain,
                                           "Add Terrain",
                                           null);
                }
            }
        }
コード例 #9
0
ファイル: TerrainMaterial.cs プロジェクト: trizdreaming/XLE
        void ICommandClient.DoCommand(object commandTag)
        {
            if (!(commandTag is Command))
            {
                return;
            }

            switch ((Command)commandTag)
            {
            case Command.AddTerrainTextureMaterial:
            {
                var mat = TerrainBaseTextureMaterial.Create(GetNextMaterialId());
                ApplicationUtil.Insert(
                    DomNode.GetRoot(), this, mat,
                    "Add Terrain Material", null);
            }
            break;
            }
        }
コード例 #10
0
        void ICommandClient.DoCommand(object commandTag)
        {
            if (!(commandTag is Command))
            {
                return;
            }

            switch ((Command)commandTag)
            {
            case Command.CreateBaseTexture:
            {
                ApplicationUtil.Insert(
                    DomNode.GetRoot(), this, new DomNode(Schema.terrainBaseTextureType.Type),
                    "Create Terrain Texturing", null);
                break;
            }

            case Command.CreateVegetationSpawn:
            {
                ApplicationUtil.Insert(
                    DomNode.GetRoot(), this, new DomNode(Schema.vegetationSpawnConfigType.Type),
                    "Create Vegetation Config", null);
                break;
            }

            case Command.Configure:
            {
                DoModalConfigure();
                break;
            }

            case Command.GenerateShadows:
            {
                DoGenerateShadows();
                break;
            }

            case Command.FlushToDisk:
            {
                DoFlushToDisk();
                break;
            }

            case Command.RebuildCellFiles:
            {
                DoRebuildCellFiles();
                break;
            }

            case Command.Reload:
            {
                Reload();
                break;
            }

            case Command.Unload:
            {
                Unload();
                break;
            }

            case Command.ExportToTiff:
                DoExportHeights();
                break;

            case Command.AddShadows:
            case Command.AddAO:
            case Command.AddBaseMaterialCoverage:
            case Command.AddDecorationCoverage:
            {
                var layerId = AssociatedLayerId((Command)commandTag);
                if (!HasCoverageLayer(layerId))
                {
                    var layer = XLETerrainCoverage.CreateWithConfigure(this, layerId).As <XLETerrainCoverage>();
                    if (layer != null)
                    {
                        if (!HasCoverageLayer(layer.LayerId))
                        {
                            CoverageLayers.Add(layer);
                            Reconfigure();
                        }
                        else
                        {
                            MessageBox.Show(
                                "Layer id conflicts with existing id. You can't have 2 layers with the same id. Try using a unique id", "Error adding layer",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
                        }
                    }
                }
                break;
            }

            case Command.AddGenericCoverage:
            {
                var layerId = 1003u;
                while (HasCoverageLayer(layerId))
                {
                    ++layerId;
                }

                var layer = XLETerrainCoverage.CreateWithConfigure(this, layerId).As <XLETerrainCoverage>();
                if (layer != null)
                {
                    if (!HasCoverageLayer(layer.LayerId))
                    {
                        CoverageLayers.Add(layer);
                        Reconfigure();
                    }
                    else
                    {
                        MessageBox.Show(
                            "Layer id conflicts with existing id. You can't have 2 layers with the same id. Try using a unique id", "Error adding layer",
                            MessageBoxButtons.OK,
                            MessageBoxIcon.Error);
                    }
                }
                break;
            }
            }
        }