コード例 #1
0
ファイル: VixenPlusForm.cs プロジェクト: ctmal956/vplus
        private void OpenSequence(string fileName)
        {
            var fileIOHandler = FileIOHelper.GetByExtension(fileName);

            if (fileIOHandler == null)
            {
                MessageBox.Show(Resources.VixenPlusForm_NoKnowEditor, Vendor.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Hand);
                return;
            }

            if (!fileIOHandler.CanOpen())
            {
                MessageBox.Show(string.Format("Sorry, we can only export {0} files.", fileIOHandler.Name()), Vendor.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Hand);
                return;
            }

            AddToFileHistory(fileName);

            var plugInInterface = (IUIPlugIn)Activator.CreateInstance(_registeredFileTypes[".vix"].GetType());

            plugInInterface.Sequence = fileIOHandler.OpenSequence(fileName);

            ((Form)plugInInterface).Text = plugInInterface.Sequence.Name + " - " + plugInInterface.Sequence.FileIOHandler.Name();
            var uiBase = plugInInterface as UIBase;

            if (uiBase != null)
            {
                uiBase.DirtyChanged += plugin_DirtyChanged;
            }

            plugInInterface.MdiParent = this;
            plugInInterface.Show();
        }
コード例 #2
0
ファイル: AutoPlay.cs プロジェクト: egold555/Comet
            public bool Play()
            {
                error = null;

                try {
                    if (!File.Exists(path))
                    {
                        error = string.Format("File '{0}' does not exist.", path);
                        return(false);
                    }

                    var           fileIOHandler = FileIOHelper.GetByExtension(path);
                    EventSequence sequence      = fileIOHandler.OpenSequence(path);
                    numberOfChannels = sequence.FullChannelCount;

                    object executionIfaceObj;
                    if (!Interfaces.Available.TryGetValue("IExecution", out executionIfaceObj))
                    {
                        error = "IExecution interface not available.";
                        return(false);
                    }

                    executionInterface = (IExecution)executionIfaceObj;
                    contextHandle      = executionInterface.RequestContext(true, false, null);
                    executionInterface.SetSynchronousContext(contextHandle, sequence);

                    executionInterface.ExecutePlay(contextHandle, 0, 0);

                    return(true);
                }
                catch (Exception e) {
                    error = e.Message;
                    return(false);
                }
            }
コード例 #3
0
ファイル: VixenHTTPServer.cs プロジェクト: egold555/Comet
        public override void handleGETRequest(HttpProcessor p)
        {
            string[] args = p.http_url.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries);
            p.writeSuccess();

            if (args == null || args.Length == 0)
            {
                showHelp(p);
                return;
            }

            if (args[0] == "files")
            {
                string path = string.Join("\\", args.Skip(1).ToArray());
                p.serveFile(path);
                return;
            }
            else if (args[0] == "sequence")
            {
                string fullPath = Path.Combine(VixenPlusCommon.Paths.SequencePath, Uri.UnescapeDataString(args[1]));
                object obj2;
                if (sequences.Contains(fullPath))
                {
                    //Sequence exists
                    if (Interfaces.Available.TryGetValue("IExecution", out obj2))
                    {
                        var fileIOHandler = FileIOHelper.GetByExtension(fullPath);
                        sequence = fileIOHandler.OpenSequence(fullPath);

                        _executionInterface     = (IExecution)obj2;
                        _executionContextHandle = _executionInterface.RequestContext(false, true, null);
                        _executionInterface.SetAsynchronousContext(_executionContextHandle, sequence);

                        try {
                            if (_channelLevels == null)
                            {
                                _channelLevels = new byte[sequence.FullChannelCount];
                            }


                            if (args.Length == 2)
                            {
                                p.writeLine("Successfully selected sequence!");
                                p.writeLine("<br>");
                                p.writeLine("Commands: <br>");
                                p.writeLine("   /play/ <br>");
                                p.writeLine("   /play/ms/ <br>");
                                p.writeLine("   /pause/ <br>");
                                p.writeLine("   /stop/ <br>");
                                p.writeLine("   /channels/ <br>");
                                return;
                            }

                            if (args[2] == "channels")
                            {
                                int maxChannels = sequence.FullChannelCount;
                                if (args.Length == 3)
                                {
                                    p.writeLine("/set/channelnum/0-255");
                                    p.writeLine("<br>");
                                    p.writeLine("/get/channelnum/");
                                    p.writeLine("<br>");
                                    p.writeLine("Max channels: " + maxChannels);
                                    return;
                                }

                                if (args[3] == "set")
                                {
                                    int  channel = int.Parse(args[4]);
                                    byte value   = byte.Parse(args[5]);
                                    _channelLevels[channel] = value;
                                    updateChannels();
                                    p.writeLine("Executed command: " + args[2]);
                                }

                                if (args[3] == "get")
                                {
                                    int channel = int.Parse(args[4]);
                                    p.writeLine("" + _channelLevels[channel]);
                                }
                            }
                        } finally {
                            _executionInterface.ReleaseContext(_executionContextHandle);
                        }
                    }
                }
                else
                {
                    //Error and say that their sequence they selected doesnt exist.
                    p.writeLine(args[1] + " Does not exist.");
                    p.writeLine("<br>");
                    p.writeLine("Selectable sequences: ");
                    p.writeLine("<br>");
                    printoutVixenSequences(p, "<br>");
                }
            }
            else if (args[0] == "listseq")
            {
                printoutVixenSequences(p, null);
            }
            else
            {
                showHelp(p);
            }
        }