CommandList

Namespace: SharpDX.Direct2D1
We found 10 examples in language CSharp for this search. You will see 45 fragments of code.
		[SetUp]
		public void Initialize()
		{
			commandList = new CommandList();
		}

		[Test]
		public void CheckStatusOfEmptyList()
		{
			commandList.GetCommands();
			Assert.AreEqual(0, commandList.NumberOfCommands);
			Assert.AreEqual(0, commandList.GetAllTriggers("Jump").Count);
		}

		[Test]
		public void AddTriggerOfNonExistingCommand()
		{
			Assert.Throws<CommandList.CommandDoesNotExist>(
				() => commandList.AddTrigger("Jump", MouseButton.Left, State.Pressed));
			CheckStatusOfEmptyList();
		}

		[Test]
		public void AddFireCommandWithAllPossibleTrigger()
		{
			commandList.AddCommand("Fire");
			Assert.AreEqual(1, commandList.NumberOfCommands);
			commandList.AddTrigger("Fire", MouseButton.Left, State.Pressed);
			commandList.AddTrigger("Fire", Key.B, State.Pressed);
			commandList.AddTrigger("Fire", GamePadButton.B, State.Pressed);
			commandList.AddTrigger("Fire", State.Pressed);
			Assert.AreEqual(4, commandList.GetNumberOfTriggers("Fire"));
		}

		[Test]
		public void AddAndRemoveCommand()
		{
			commandList.AddCommand("Click");
			Assert.AreEqual(1, commandList.NumberOfCommands);
			commandList.RemoveCommand("Click");
			Assert.AreEqual(0, commandList.NumberOfCommands);
		}

		[Test]
		public void AddTwoCommandsWithTriggers()
		{
			commandList.AddCommand("Fire");
			commandList.AddCommand("Jump");
			Assert.AreEqual(2, commandList.NumberOfCommands);
			commandList.AddTrigger("Fire", MouseButton.Middle, State.Pressed);
			Assert.AreEqual(1, commandList.GetNumberOfTriggers("Fire"));
			commandList.AddTrigger("Jump", MouseButton.Right, State.Pressed);
			Assert.AreEqual(1, commandList.GetNumberOfTriggers("Jump"));
		}

		[SetUp]
		public void Initialize()
		{
			commandList = new CommandList();
		}

		[Test]
		public void CheckStatusOfEmptyList()
		{
			commandList.GetCommands();
			Assert.AreEqual(0, commandList.NumberOfCommands);
			Assert.AreEqual(0, commandList.GetAllTriggers("Jump").Count);
		}

		[Test]
		public void AddTriggerOfNonExistingCommand()
		{
			Assert.Throws<CommandList.CommandDoesNotExist>(
				() => commandList.AddTrigger("Jump", MouseButton.Left, State.Pressed));
			CheckStatusOfEmptyList();
		}

		[Test]
		public void AddFireCommandWithAllPossibleTrigger()
		{
			commandList.AddCommand("Fire");
			Assert.AreEqual(1, commandList.NumberOfCommands);
			commandList.AddTrigger("Fire", MouseButton.Left, State.Pressed);
			commandList.AddTrigger("Fire", Key.B, State.Pressed);
			commandList.AddTrigger("Fire", GamePadButton.B, State.Pressed);
			commandList.AddTrigger("Fire", State.Pressed);
			Assert.AreEqual(4, commandList.GetNumberOfTriggers("Fire"));
		}

		[Test]
		public void AddAndRemoveCommand()
		{
			commandList.AddCommand("Click");
			Assert.AreEqual(1, commandList.NumberOfCommands);
			commandList.RemoveCommand("Click");
			Assert.AreEqual(0, commandList.NumberOfCommands);
		}

		[Test]
		public void AddTwoCommandsWithTriggers()
		{
			commandList.AddCommand("Fire");
			commandList.AddCommand("Jump");
			Assert.AreEqual(2, commandList.NumberOfCommands);
			commandList.AddTrigger("Fire", MouseButton.Middle, State.Pressed);
			Assert.AreEqual(1, commandList.GetNumberOfTriggers("Fire"));
			commandList.AddTrigger("Jump", MouseButton.Right, State.Pressed);
			Assert.AreEqual(1, commandList.GetNumberOfTriggers("Jump"));
		}


        public override void ReactToEvent(AbstractActor self, MyEventArgs args)
        {
            switch (args.EventName)
            {
                case "clientSpawned":
                    GroupActor newClients = ((GroupActor)args.Arg);
                    newClients.Target = self;
                    newClients.CommandList.Add(new CommandMove(newClients));
                    break;
            }
        }


		public bool Init()
		{
			return CommandList.Orbital_Video_D3D12_CommandList_Init(handle, CommandListType.Rasterize) != 0;
		}

		public override void Dispose()
		{
			if (handle != IntPtr.Zero)
			{
				CommandList.Orbital_Video_D3D12_CommandList_Dispose(handle);
				handle = IntPtr.Zero;
			}
		}

		public override void Start(int nodeIndex)
		{
			CommandList.Orbital_Video_D3D12_CommandList_Start(handle, nodeIndex);
		}

		public override void Finish()
		{
			CommandList.Orbital_Video_D3D12_CommandList_Finish(handle);
			lastRenderState = null;
		}

		public override void BeginRenderPass(RenderPassBase renderPass)
		{
			lastRenderPass = (RenderPass)renderPass;
			CommandList.Orbital_Video_D3D12_CommandList_BeginRenderPass(handle, lastRenderPass.handle);
		}

		public override void EndRenderPass()
		{
			CommandList.Orbital_Video_D3D12_CommandList_EndRenderPass(handle, lastRenderPass.handle);
			lastRenderPass = null;
		}


        public void Initialize(GraphicsDevice graphicsDevice)
        {
            ThrowIfFailed(graphicsDevice.device.CreateCommandList(0, CommandListType.Direct, graphicsDevice.GetCommandAllocator(), null, out commandList));
            commandList.Close();
            this.graphicsDevice = graphicsDevice;
        }

        public void DrawIndexedInstanced(int indexCountPerInstance, int instanceCount, int startIndexLocation, int baseVertexLocation, int startInstanceLocation)
        {
            commandList.SetPipelineState(pipelineStateObject.GetState(graphicsDevice, psoDesc, currentRootSignature, unnamedInputLayout));
            commandList.DrawIndexedInstanced(indexCountPerInstance, instanceCount, startIndexLocation, baseVertexLocation, startInstanceLocation);
        }

        public void SetDescriptorHeapDefault()
        {
            commandList.SetDescriptorHeaps(1, new[] { graphicsDevice.cbvsrvuavHeap.heap });
        }

        public void SetRootSignature(RootSignature rootSignature)
        {
            currentRootSignature = rootSignature;
            commandList.SetGraphicsRootSignature(rootSignature.rootSignature);
        }

        public void SetComputeRootSignature(RootSignature rootSignature)
        {
            currentRootSignature = rootSignature;
            commandList.SetComputeRootSignature(rootSignature.rootSignature);
        }

        public void SetRenderTargetScreen()
        {
            commandList.RSSetViewport(new Viewport(0, 0, graphicsDevice.width, graphicsDevice.height, 0.0f, 1.0f));
            commandList.RSSetScissorRect(new Rectangle(0, 0, graphicsDevice.width, graphicsDevice.height));
            commandList.OMSetRenderTargets(graphicsDevice.GetRenderTargetScreen());
        }




        // Event Editor Stuffz Also includes event functions from the map editor (copy/paste/delete)

        public static void CopyEvent_Map(int x, int y)
        {
            int count;
            int i;

            count = E_Types.Map.EventCount;
            if (count == 0)
                return;
            var loopTo = count;
            for (i = 1; i <= loopTo; i++)
            {
                if (E_Types.Map.Events[i].X == x && E_Types.Map.Events[i].Y == y)
                {
                    // copy it
                    CopyEvent = E_Types.Map.Events[i];
                    // exit
                    return;
                }
            }
        }

        public static void PasteEvent_Map(int x, int y)
        {
            int count;
            int i;
            int eventNum = 0;

            count = E_Types.Map.EventCount;
            if (count > 0)
            {
                var loopTo = count;
                for (i = 1; i <= loopTo; i++)
                {
                    if (E_Types.Map.Events[i].X == x && E_Types.Map.Events[i].Y == y)
                        // already an event - paste over it
                        eventNum = i;
                }
            }

            // couldn't find one - create one
            if (eventNum == 0)
            {
                // increment count
                AddEvent(x, y, true);
                eventNum = count + 1;
            }

            // copy it
            E_Types.Map.Events[eventNum] = CopyEvent;
            // set position
            E_Types.Map.Events[eventNum].X = x;
            E_Types.Map.Events[eventNum].Y = y;
        }

        public static void DeleteEvent(int x, int y)
        {
            int count;
            int i;
            int lowindex = 0;

            if (!E_Globals.InMapEditor)
                return;
            if (frmEvents.Default.Visible == true)
                return;
            count = E_Types.Map.EventCount;
            var loopTo = count;
            for (i = 1; i <= loopTo; i++)
            {
                if (E_Types.Map.Events[i].X == x && E_Types.Map.Events[i].Y == y)
                {
                    // delete it
                    ClearEvent(i);
                    lowindex = i;
                    break;
                }
            }
            // not found anything
            if (lowindex == 0)
                return;
            var loopTo1 = count - 1;
            // move everything down an index
            for (i = lowindex; i <= loopTo1; i++)
                E_Types.Map.Events[i] = E_Types.Map.Events[i + 1];
            // delete the last index
            ClearEvent(count);
            // set the new count
            E_Types.Map.EventCount = count - 1;
            E_Types.Map.CurrentEvents = count - 1;
        }

        public static void AddEvent(int x, int y, bool cancelLoad = false)
        {
            int count;
            int pageCount;
            int i;

            count = E_Types.Map.EventCount + 1;
            // make sure there's not already an event
            if (count - 1 > 0)
            {
                var loopTo = count - 1;
                for (i = 1; i <= loopTo; i++)
                {
                    if (E_Types.Map.Events[i].X == x && E_Types.Map.Events[i].Y == y)
                    {
                        // already an event - edit it
                        if (!cancelLoad)
                            EventEditorInit(i);
                        return;
                    }
                }
            }
            // increment count
            E_Types.Map.EventCount = count;
            var oldEvents = E_Types.Map.Events;
            E_Types.Map.Events = new EventRec[count + 1];
            if (oldEvents != null)
                Array.Copy(oldEvents, E_Types.Map.Events, Math.Min(count + 1, oldEvents.Length));
            // set the new event
            E_Types.Map.Events[count].X = x;
            E_Types.Map.Events[count].Y = y;
            // give it a new page
            pageCount = E_Types.Map.Events[count].PageCount + 1;
            E_Types.Map.Events[count].PageCount = pageCount;
            var oldPages = E_Types.Map.Events[count].Pages;
            E_Types.Map.Events[count].Pages = new EventPageRec[pageCount + 1];
            if (oldPages != null)
                Array.Copy(oldPages, E_Types.Map.Events[count].Pages, Math.Min(pageCount + 1, oldPages.Length));
            // load the editor
            if (!cancelLoad)
                EventEditorInit(count);
        }

        public static void ClearEvent(int eventNum)
        {
            if (eventNum > E_Types.Map.EventCount || eventNum > Information.UBound(E_Types.Map.MapEvents))
                return;
            {
                E_Types.Map.Events[eventNum].Name = "";
                E_Types.Map.Events[eventNum].PageCount = 0;
                E_Types.Map.Events[eventNum].Pages = new EventPageRec[1];
                E_Types.Map.Events[eventNum].Globals = 0;
                E_Types.Map.Events[eventNum].X = 0;
                E_Types.Map.Events[eventNum].Y = 0;
            }
            {
                E_Types.Map.MapEvents[eventNum].Name = "";
                E_Types.Map.MapEvents[eventNum].Dir = 0;
                E_Types.Map.MapEvents[eventNum].ShowDir = 0;
                E_Types.Map.MapEvents[eventNum].GraphicNum = 0;
                E_Types.Map.MapEvents[eventNum].GraphicType = 0;
                E_Types.Map.MapEvents[eventNum].GraphicX = 0;
                E_Types.Map.MapEvents[eventNum].GraphicX2 = 0;
                E_Types.Map.MapEvents[eventNum].GraphicY = 0;
                E_Types.Map.MapEvents[eventNum].GraphicY2 = 0;
                E_Types.Map.MapEvents[eventNum].MovementSpeed = 0;
                E_Types.Map.MapEvents[eventNum].Moving = 0;
                E_Types.Map.MapEvents[eventNum].X = 0;
                E_Types.Map.MapEvents[eventNum].Y = 0;
                E_Types.Map.MapEvents[eventNum].XOffset = 0;
                E_Types.Map.MapEvents[eventNum].YOffset = 0;
                E_Types.Map.MapEvents[eventNum].Position = 0;
                E_Types.Map.MapEvents[eventNum].Visible = 0;
                E_Types.Map.MapEvents[eventNum].WalkAnim = 0;
                E_Types.Map.MapEvents[eventNum].DirFix = 0;
                E_Types.Map.MapEvents[eventNum].WalkThrough = 0;
                E_Types.Map.MapEvents[eventNum].ShowName = 0;
                E_Types.Map.MapEvents[eventNum].Questnum = 0;
            }
        }

        public static void EventEditorInit(int eventNum)
        {
            // Dim i As Integer

            EditorEvent = eventNum;

            TmpEvent = E_Types.Map.Events[eventNum];
            InitEventEditorForm = true;
        }

    public void Use(bool a,bool bullet = false)
    {
        if (!circleEnable && bullet == false)
        {
            resetCount++;
            circleEnable = true;
        }
        Enter = a;

    }
    public GroupString Copy()
    {
        return (GroupString)this.MemberwiseClone();
    }

    public DynamicParmCurve Copy() {
        return (DynamicParmCurve)this.MemberwiseClone();
    }

    [ButtonGroup]
    public void AutoCreateFrameSetting()
    {
        for (int i = 0; i != Curve.keys.Length; ++i)
        {
            frameSetting.Add(new FrameSetting(i));
        }
    }
    [ButtonGroup]
    public void Reorder()
    {
        frameSetting.Sort(delegate (FrameSetting p1, FrameSetting p2)
        {
            return p1.KeyIndex.CompareTo(p2.KeyIndex);
        });
    }

    public void GetInfusionMethod(float time, Bullet Target)
    {
        if (index != -1)
            ParmIndex = index;

        if (frameSetting.Count == 0)
            return;

        int Key = 0;
        for (int i = 0; i != frameSetting.Count; ++i)
        {
            frameSetting[i].Use(false,true);
          
        }
        // Debug.Log("当前时间点" + time.ToString());
        for (int i = 0; i != frameSetting.Count; ++i)
        {

            if (Curve.keys[frameSetting[i].KeyIndex].time > time)
            {
                Target.CommandList[OrderIndex].MinIndex = i;
                if (i - 1 == 0)
                {
                    foreach (var r in Target.CommandList)
                    {
                        r.Enable = true;
                    }
                }
                frameSetting[Target.CommandList[OrderIndex].MinIndex].Use(true,true);
                Target.CommandList[OrderIndex].UseTime++;
                Key = frameSetting[Target.CommandList[OrderIndex].MinIndex].KeyIndex;
                break;
            }

        }
        //  Debug.Log("MinIndex 为" + MinIndex.ToString());
        List<FrameSetting> muitiConditon = new List<FrameSetting>();
        for (int i = 0; i != frameSetting.Count; ++i)
        {
            if (frameSetting[i].KeyIndex == Key)
                muitiConditon.Add(frameSetting[i]);

        }
        // Debug.Log("检测到有" + muitiConditon.Count.ToString() + "个条件");
        List<bool> muitiConditonChecking = new List<bool>();
        for (int i = 0; i != muitiConditon.Count; ++i)
        {
            bool t = CanEnterFrame(time, muitiConditon[i], Target);
            muitiConditonChecking.Add(t);
            if (t && muitiConditon[i].OnlyOr)
            {
                Target.CommandList[OrderIndex].CaluateMethod = frameSetting[Target.CommandList[OrderIndex].MinIndex].infusion;
                Target.CommandList[OrderIndex].DefaultValue = frameSetting[Target.CommandList[OrderIndex].MinIndex].DefaultValue;
                Target.CommandList[OrderIndex].ResultDefaultValue = frameSetting[Target.CommandList[OrderIndex].MinIndex].ResultDefaultValue;
                Target.CommandList[OrderIndex].Const = frameSetting[Target.CommandList[OrderIndex].MinIndex].Const;
                Target.CommandList[OrderIndex].compareShooting = frameSetting[Target.CommandList[OrderIndex].MinIndex].compareShooting;
                return;
            }
        }
        bool allTrue = true;

        for (int i = 0; i != muitiConditonChecking.Count; ++i)
        {
            if (muitiConditonChecking[i] == false)
                allTrue = false;
            if (allTrue)
            {
                Target.CommandList[OrderIndex].CaluateMethod = frameSetting[Target.CommandList[OrderIndex].MinIndex].infusion;
                Target.CommandList[OrderIndex].DefaultValue = frameSetting[Target.CommandList[OrderIndex].MinIndex].DefaultValue;
                Target.CommandList[OrderIndex].ResultDefaultValue = frameSetting[Target.CommandList[OrderIndex].MinIndex].ResultDefaultValue;
                Target.CommandList[OrderIndex].Const = frameSetting[Target.CommandList[OrderIndex].MinIndex].Const;
                Target.CommandList[OrderIndex].compareShooting = frameSetting[Target.CommandList[OrderIndex].MinIndex].compareShooting;

            }
            else
                Target.CommandList[OrderIndex].CaluateMethod = FrameSetting.Infusion.NONE;

        }

        //  Debug.Log("最终被修改成了" + CaluateMethod);
    }


        public void addCommand(TreeNode tnode ,string type)
        {
            switch (type)
            {
                case "remove":
                    _current++;
                    if (commandList.Count > 0)
                    {
                        commandList.RemoveRange(_current, (commandList.Count - _current));
                    }
                    commandList.Add(new RemoveNode(tnode));
                    break;
                case "add":
                    _current++;
                    if (commandList.Count > 0)
                    {
                        commandList.RemoveRange(_current, (commandList.Count - _current));
                    }
                    commandList.Add(new AddNode(tnode));
                    break;
                case "edit":
                    _current++;
                    if (commandList.Count > 0)
                    {
                        commandList.RemoveRange(_current, (commandList.Count - _current));
                    }
                    commandList.Add(new EditNode(tnode));
                    break;
            }
        }

        public void Undo()
        {
            if (_current == -1) return;
            commandList[_current].UnExecute();
            _current--;
        }

        public void Redo()
        {
            if (commandList.Count == _current + 1) return;
            _current++;
            commandList[_current].Execute();
        }

        static void Main(string[] args)
        {
            Dictionary<string, List<string>> bandsMembers = new Dictionary<string, List<string>>();
            Dictionary<string, int> bandsTimes = new Dictionary<string, int>();
            while (true)
            {
                string input = Console.ReadLine();
                if (input == "start of concert")
                {
                    break;
                }
                else
                {
                    List<string> commandList = input.Split("; ").ToList();
                    string command = commandList[0];
                    string bandNAme = commandList[1];

                    if (command == "Add")
                    {
                        string[] members = commandList[2].Split(", ");
                        commandList.RemoveAt(2);

                        for (int i = 0; i < members.Length; i++)
                        {
                            commandList.Add(members[i]);
                        }


                        if (!bandsMembers.ContainsKey(commandList[1]))
                        {
                            bandsMembers.Add(commandList[1], new List<string>());
                            bandsTimes.Add(commandList[1], 0);
                        }

                        for (int i = 2; i < commandList.Count; i++)
                        {
                            if (!bandsMembers[commandList[1]].Contains(commandList[i]))
                            {
                                bandsMembers[commandList[1]].Add(commandList[i]);
                            }
                        }
                    }

                    else if (command == "Play")
                    {
                        if (!bandsMembers.ContainsKey(commandList[1]))
                        {
                            bandsMembers.Add(commandList[1], new List<string>());
                            bandsTimes.Add(commandList[1], 0);
                        }
                        bandsTimes[commandList[1]] += int.Parse(commandList[2]);
                    }
                }
            }

            string bandToBeWriten = Console.ReadLine();

            Console.WriteLine($"Total time: {bandsTimes.Values.Sum()}");

            foreach (var kvp in bandsTimes.OrderByDescending(x => x.Value).ThenBy(x => x.Key))
            {
                Console.WriteLine($"{kvp.Key} -> {kvp.Value}");
            }


            Console.WriteLine(bandToBeWriten);

            foreach (var member in bandsMembers[bandToBeWriten])
            {
                Console.WriteLine($"=> {member}");
            }
        }


        public override void Dispose()
        {
            base.Dispose();

            Renderer.GraphicsDevice.WaitForIdle();
            CommandList?.Dispose();
            ModelBuffer?.Dispose();
            ModelResourceSet?.Dispose();
        }

        public Veldrid.CommandList BuildStandardCommandList()
        {
            if(CommandList == null)
            {
                CommandList = Renderer.VeldridFactory.CreateCommandList();
            }

            CommandList.Begin();
            CommandList.SetFramebuffer(Renderer.GraphicsDevice.SwapchainFramebuffer);

            if(ClearColor.HasValue)
            {
                float[] Floats = ClearColor.Value.GetFloats();
                CommandList.ClearColorTarget(0, new RgbaFloat(Floats[0], Floats[1], Floats[2], Floats[3]));
            }

            if (VertexBuffer != null)
            { 
                if(!VertexBuffer.Bound)
                {
                    VertexBuffer.Bind();
                }
                VeldridCamera vCam = Camera as VeldridCamera;
                vCam.Update();

                UpdateModelBuffer();

                VeldridTexture texture = Texture as VeldridTexture;

                CommandList.SetVertexBuffer(0, (VertexBuffer as VeldridVertexBuffer).VertexBuffer);
                CommandList.SetIndexBuffer((VertexBuffer as VeldridVertexBuffer).IndexBuffer, IndexFormat.UInt16);
                if(texture != null)
                {
                    CommandList.SetPipeline((Material as VeldridMaterial).TexturedPipeline);
                }
                else
                {
                    CommandList.SetPipeline((Material as VeldridMaterial).UntexturedPipeline);
                }
                CommandList.SetGraphicsResourceSet(0, vCam.ProjectionViewResourceSet);
                CommandList.SetGraphicsResourceSet(1, ModelResourceSet);

                if (texture != null)
                {
                    CommandList.SetGraphicsResourceSet(2, texture.GetTextureResourceSet());
                }

                CommandList.DrawIndexed((uint)NumIndicies, 1, (uint)StartIndex, 0, 0);
                
            }

            CommandList.End();

            return CommandList;
        }

        private void CreateModelBuffer()
        {
            ModelBuffer = Renderer.VeldridFactory.CreateBuffer(new BufferDescription(sizeof(float) * 16, BufferUsage.UniformBuffer | BufferUsage.Dynamic));
            ModelResourceSet = Renderer.VeldridFactory.CreateResourceSet(new ResourceSetDescription(ModelResourceLayout, ModelBuffer));
        }
        private void UpdateModelBuffer()
        {
            if(ModelBuffer == null)
            {
                CreateModelBuffer();
            }
            Renderer.GraphicsDevice.UpdateBuffer(ModelBuffer, 0, Transform.ToBytes());
        }

SharpDX.Direct2D1.CommandList : IDisposable, ICallbackable, IUnknown

Constructors :

public CommandList(DeviceContext deviceContext = )
public CommandList(IntPtr nativePtr = )

Methods :

public static CommandList op_Explicit(IntPtr nativePtr = )
public Void Stream(CommandSink sink = )
public Void Close()
public Factory get_Factory()
public Void QueryInterface(Guid guid = , IntPtr& outPtr = )
public IntPtr QueryInterfaceOrNull(Guid guid = )
public T QueryInterface()
public T QueryInterfaceOrNull()
public Object get_Tag()
public Void set_Tag(Object value = )
public IntPtr get_NativePointer()
public Void set_NativePointer(IntPtr value = )
public Void add_Disposing(EventHandler<EventArgs> value = )
public Void remove_Disposing(EventHandler<EventArgs> value = )
public Void add_Disposed(EventHandler<EventArgs> value = )
public Void remove_Disposed(EventHandler<EventArgs> value = )
public Boolean get_IsDisposed()
public Void Dispose()
public Type GetType()
public String ToString()
public Boolean Equals(Object obj = )
public Int32 GetHashCode()