public override FILEERROR Save(BaseSceneSaver node, Filename name, BaseDocument doc, SCENEFILTER filterflags)
        {
            BaseDocument polyDoc = doc.Polygonize();

            Logger.Debug("Fuseefy Me!");

            SceneContainer root = new SceneContainer()
            {
                Header = new SceneHeader()
                {
                    CreatedBy = "",
                    Generator = "FUSEE Export Plugin for Cinema4D",
                    Version = 1
                },
                Children = FuseefyOb(polyDoc.GetFirstObject())
            };

            var ser = new Serializer();
            using (var file = File.Create(name.GetString()))
            {
                ser.Serialize(file, root);
            }

            return FILEERROR.FILEERROR_NONE;
        }
Exemplo n.º 2
0
    static void Main(string[] args)
    {
        int N = int.Parse(Console.ReadLine()); // Number of elements which make up the association table.
        int Q = int.Parse(Console.ReadLine()); // Number Q of file names to be analyzed.

        Dictionary<string, Mime> mimes = new Dictionary<string, Mime>();
        List<String> result = new List<String>();

        for (int i = 0; i < N; i++)
        {
            Mime m = new Mime(Console.ReadLine().Split(' '));
            mimes.Add(m.extension.ToUpper(), m);
        }

        for (int i = 0; i < Q; i++)
        {
            Filename entry = new Filename(Console.ReadLine());
            result.Add(entry.ext != String.Empty && mimes.ContainsKey(entry.ext) ? mimes[entry.ext].type : UNKNOWN);
        }

        foreach (string item in result)
        {
            Console.WriteLine(item);
        }
    }
Exemplo n.º 3
0
        public SimpleExecutableProfile(string executableName)
        {
            ExecutableName = executableName;

            Name = new Filename(this.GetType().Assembly.Location).Name;

            Watcher = new ProcessWatcher(Program.Scheduler, executableName);
        }
Exemplo n.º 4
0
        public void CreatedFireNode1()
        {
            var           filename = new Filename(@"FireEmpty.xml");
            BulletPattern pattern  = new BulletPattern();

            pattern.ParseXML(filename.File);

            //get teh child action node
            ActionNode testActionNode = pattern.RootNode.GetChild(ENodeName.action) as ActionNode;

            Assert.IsNotNull(testActionNode);
            Assert.IsNotNull(testActionNode.GetChild(ENodeName.fire));
        }
Exemplo n.º 5
0
        public void bulletCreated()
        {
            var filename = new Filename(@"FireSpeed.xml");

            pattern.ParseXML(filename.File);
            Mover mover = (Mover)manager.CreateBullet();

            mover.InitTopNode(pattern.RootNode);
            mover.Speed = 100;

            manager.Update();
            Assert.AreEqual(manager.movers.Count, 2);
        }
Exemplo n.º 6
0
        public void GotActionRefNode4()
        {
            var           filename = new Filename(@"ActionRefEmpty.xml");
            BulletPattern pattern  = new BulletPattern();

            pattern.ParseXML(filename.File);

            ActionNode testActionNode = pattern.RootNode.GetChild(ENodeName.action) as ActionNode;
            FireNode   testFireNode   = testActionNode.GetChild(ENodeName.fire) as FireNode;
            BulletNode testBulletNode = testFireNode.GetChild(ENodeName.bullet) as BulletNode;

            Assert.IsNotNull(testBulletNode.GetChild(ENodeName.actionRef) as ActionRefNode);
        }
Exemplo n.º 7
0
        public void CreatedDirectionNode2()
        {
            var           filename = new Filename(@"FireDirection.xml");
            BulletPattern pattern  = new BulletPattern();

            pattern.ParseXML(filename.File);

            ActionNode testActionNode = pattern.RootNode.GetChild(ENodeName.action) as ActionNode;
            FireNode   testFireNode   = testActionNode.GetChild(ENodeName.fire) as FireNode;

            Assert.IsNotNull(testFireNode.GetChild(ENodeName.direction));
            Assert.IsNotNull(testFireNode.GetChild(ENodeName.direction) as DirectionNode);
        }
Exemplo n.º 8
0
 public void OpenBdatViaFileBrowser()
 {
     Filename = OpenViaFileBrowser(".bdat", "BDAT Files (*.bdat)|*.bdat|All Files|*.*");
     if (Filename == null)
     {
         return;
     }
     OpenBdat(Filename);
     FileDisplayName = Filename.Split('\\')[Filename.Split('\\').Length - 1];
     CurrentTable    = null;
     EditingTable    = new DataTable();
     EditingTable.AcceptChanges();
 }
Exemplo n.º 9
0
        public void CorrectAction1()
        {
            var filename = new Filename(@"FireSpeed.xml");

            pattern.ParseXML(filename.File);
            Mover mover = (Mover)manager.CreateBullet();

            mover.InitTopNode(pattern.RootNode);
            BulletMLTask myTask = mover.Tasks[0];

            Assert.AreEqual(1, myTask.ChildTasks.Count);
            Assert.IsTrue(myTask.ChildTasks[0] is FireTask);
        }
Exemplo n.º 10
0
        public void BulletSpeedInitInitCorrect1()
        {
            var filename = new Filename(@"BulletSpeed.xml");

            pattern.ParseXML(filename.File);
            Mover mover = (Mover)manager.CreateBullet();

            mover.InitTopNode(pattern.RootNode);
            BulletMLTask myTask   = mover.Tasks[0];
            FireTask     testTask = myTask.ChildTasks[0] as FireTask;

            Assert.IsTrue(testTask.InitialSpeedTask is SetSpeedTask);
        }
Exemplo n.º 11
0
        public void CreatedTopLevelFireNode()
        {
            var           filename = new Filename(@"FireEmpty.xml");
            BulletPattern pattern  = new BulletPattern();

            pattern.ParseXML(filename.File);

            FireNode testFireNode = pattern.RootNode.GetChild(ENodeName.fire) as FireNode;

            Assert.IsNotNull(testFireNode);
            Assert.IsNotNull(testFireNode.BulletDescriptionNode);
            Assert.AreEqual("test", testFireNode.Label);
        }
Exemplo n.º 12
0
        public void DefineEntriesFromPath()
        {
            if (string.IsNullOrEmpty(Filename))
            {
                return;
            }

            var split = Filename.Split('.', '-', '_', '[', ']', ' ', '(', ')');

            ExtractName(split);
            ExtractRelease(split);
            ExtractEpisode();
        }
Exemplo n.º 13
0
        public void FoundBulletNode1()
        {
            var           filename = new Filename(@"BulletRef.xml");
            BulletPattern pattern  = new BulletPattern();

            pattern.ParseXML(filename.File);

            ActionNode    testActionNode = pattern.RootNode.GetChild(ENodeName.action) as ActionNode;
            FireNode      testFireNode   = testActionNode.GetChild(ENodeName.fire) as FireNode;
            BulletRefNode refNode        = testFireNode.GetChild(ENodeName.bulletRef) as BulletRefNode;

            Assert.IsNotNull(refNode.ReferencedBulletNode as BulletNode);
        }
Exemplo n.º 14
0
        public void NoBullet3()
        {
            var           filename = new Filename(@"ActionEmpty.xml");
            BulletPattern pattern  = new BulletPattern();

            pattern.ParseXML(filename.File);
            Mover mover = (Mover)manager.CreateBullet();

            mover.InitTopNode(pattern.RootNode);
            manager.FreeMovers();

            Assert.AreEqual(0, manager.movers.Count);
        }
Exemplo n.º 15
0
        public void RepeatNumMaxCorrect()
        {
            var           filename = new Filename(@"ActionRepeatMany.xml");
            BulletPattern pattern  = new BulletPattern();

            pattern.ParseXML(filename.File);
            Mover mover = (Mover)manager.CreateBullet();

            mover.InitTopNode(pattern.RootNode);
            ActionTask testTask = mover.FindTaskByLabel("test") as ActionTask;

            Assert.IsNotNull(testTask);
        }
Exemplo n.º 16
0
        public void CorrectNumberOfBullets()
        {
            dude.pos.X = 100.0f;
            dude.pos.Y = 0.0f;
            var filename = new Filename(@"Aim.xml");

            pattern.ParseXML(filename.File);
            Mover mover = (Mover)manager.CreateBullet();

            mover.InitTopNode(pattern.RootNode);

            Assert.AreEqual(1, manager.movers.Count);
        }
Exemplo n.º 17
0
        public void CorrectNode()
        {
            var           filename = new Filename(@"ActionOneTop.xml");
            BulletPattern pattern  = new BulletPattern();

            pattern.ParseXML(filename.File);
            Mover mover = (Mover)manager.CreateBullet();

            mover.InitTopNode(pattern.RootNode);

            Assert.IsNotNull(mover.Tasks[0].Node);
            Assert.IsNotNull(mover.Tasks[0].Node is ActionNode);
        }
Exemplo n.º 18
0
        public void WaitTwoTaskTest3()
        {
            var filename = new Filename(@"WaitTwo.xml");

            pattern.ParseXML(filename.File);
            Mover mover = (Mover)manager.CreateBullet();

            mover.InitTopNode(pattern.RootNode);
            manager.Update();
            manager.Update();
            manager.Update();
            Assert.AreEqual(0, manager.movers.Count);
        }
Exemplo n.º 19
0
        public void CorrectAction()
        {
            var           filename = new Filename(@"ActionRepeatOnce.xml");
            BulletPattern pattern  = new BulletPattern();

            pattern.ParseXML(filename.File);
            Mover mover = (Mover)manager.CreateBullet();

            mover.InitTopNode(pattern.RootNode);
            BulletMLTask myTask = mover.Tasks[0];

            Assert.AreEqual(1, myTask.ChildTasks.Count);
        }
Exemplo n.º 20
0
        public void CorrectNumberOfBullets()
        {
            var filename = new Filename(@"DoubleRepeat.xml");

            pattern.ParseXML(filename.File);
            Mover mover = (Mover)manager.CreateBullet();

            mover.InitTopNode(pattern.RootNode);
            manager.Update();

            //there should be 20 bullets
            Assert.AreEqual(20, manager.movers.Count);
        }
Exemplo n.º 21
0
    public void RenameFile(string newFilename)
    {
#if !UNITY_WEBGL
        IOUtils.SafeMove(Filename, newFilename);
        if (Filename.EndsWith(BIN_EXTENSION))
        {
            var oldBinFile = Path.ChangeExtension(Filename, CSV_EXTENSION);
            var newBinFile = Path.ChangeExtension(newFilename, CSV_EXTENSION);
            IOUtils.SafeMove(oldBinFile, newBinFile);
        }
#endif
        SetFilename(newFilename);
    }
Exemplo n.º 22
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = ProjectNumber;
         hashCode = (hashCode * 397) ^ (Filename != null ? Filename.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ Line;
         hashCode = (hashCode * 397) ^ Column;
         hashCode = (hashCode * 397) ^ (Text != null ? Text.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ ErrorType.GetHashCode();
         return(hashCode);
     }
 }
Exemplo n.º 23
0
        protected override void Execute(CodeActivityContext context)
        {
            var key      = Key.Get(context);
            var queue    = Queue.Get(context);
            var filename = Filename.Get(context);

            filename = Environment.ExpandEnvironmentVariables(filename);
            var res     = SimpleRequests.HttpUploadFile(queue + "/upload", filename, key, "content", "image/jpeg");
            var o       = JObject.Parse(res);
            var fileurl = o["results"][0]["annotation"].ToString();

            context.SetValue(Result, fileurl);
        }
Exemplo n.º 24
0
        public void DirectionNodeSequence()
        {
            var           filename = new Filename(@"FireDirectionSequence.xml");
            BulletPattern pattern  = new BulletPattern();

            pattern.ParseXML(filename.File);

            ActionNode    testActionNode    = pattern.RootNode.GetChild(ENodeName.action) as ActionNode;
            FireNode      testFireNode      = testActionNode.GetChild(ENodeName.fire) as FireNode;
            DirectionNode testDirectionNode = testFireNode.GetChild(ENodeName.direction) as DirectionNode;

            Assert.AreEqual(ENodeType.sequence, testDirectionNode.NodeType);
        }
Exemplo n.º 25
0
        public void GotParamNode2()
        {
            var           filename = new Filename(@"BulletRefParam.xml");
            BulletPattern pattern  = new BulletPattern();

            pattern.ParseXML(filename.File);

            ActionNode    testActionNode = pattern.RootNode.GetChild(ENodeName.action) as ActionNode;
            FireNode      testFireNode   = testActionNode.GetChild(ENodeName.fire) as FireNode;
            BulletRefNode refNode        = testFireNode.GetChild(ENodeName.bulletRef) as BulletRefNode;

            Assert.IsNotNull(refNode.GetChild(ENodeName.param) as ParamNode);
        }
Exemplo n.º 26
0
        public void TestManyTop()
        {
            var           filename = new Filename(@"ActionManyTop.xml");
            BulletPattern pattern  = new BulletPattern();

            pattern.ParseXML(filename.File);

            ActionNode testNode = pattern.RootNode.FindLabelNode("top1", ENodeName.action) as ActionNode;

            Assert.IsNotNull(testNode);
            testNode = pattern.RootNode.FindLabelNode("top2", ENodeName.action) as ActionNode;
            Assert.IsNotNull(testNode);
        }
Exemplo n.º 27
0
        public void TaskFinishedFlag()
        {
            var           filename = new Filename(@"ActionOneTop.xml");
            BulletPattern pattern  = new BulletPattern();

            pattern.ParseXML(filename.File);
            Mover mover = (Mover)manager.CreateBullet();

            mover.InitTopNode(pattern.RootNode);
            mover.Tasks[0].Run(mover);

            Assert.IsTrue(mover.Tasks[0].TaskFinished);
        }
Exemplo n.º 28
0
        public void BulletSpeedInitCorrect()
        {
            var filename = new Filename(@"BulletSpeed.xml");

            pattern.ParseXML(filename.File);
            Mover mover = (Mover)manager.CreateBullet();

            mover.InitTopNode(pattern.RootNode);
            BulletMLTask myTask   = mover.Tasks[0];
            FireTask     testTask = myTask.ChildTasks[0] as FireTask;

            Assert.AreEqual(10.0f, testTask.FireSpeed);
        }
        /// <summary>
        /// Validates the data contained in the DTO and throws an exception if there is a problem.
        /// </summary>
        /// <returns></returns>
        /// <exception cref="Exception">
        /// Filename cannot be null or empty.
        /// or
        /// Filename is missing extension.
        /// or
        /// PortId cannot be longer than 50 characters.
        /// or
        /// AppOwnerName cannot be longer than 50 characters.
        /// or
        /// Filename cannot be longer than 500 characters.
        /// or
        /// Expiration in days cannot be less than one.
        /// </exception>
        public bool ValidateAndThrow()
        {
            //Nulls
            if (string.IsNullOrEmpty(Filename))
            {
                throw new Exception("Filename cannot be null or empty.");
            }

            //Bad format
            if (!Path.HasExtension(Filename))
            {
                throw new Exception("Filename is missing extension.");
            }

            //Lengths
            if (string.IsNullOrWhiteSpace(PortId))
            {
                PortId = null;
            }
            if (PortId != null && PortId.Length > 50)
            {
                throw new Exception("PortId cannot be longer than 50 characters.");
            }
            if (AppOwnerName != null && AppOwnerName.Length > 50)
            {
                throw new Exception("AppOwnerName cannot be longer than 50 characters.");
            }
            if (Filename.Length > 500)
            {
                throw new Exception("Filename cannot be longer than 500 characters.");
            }

            //Min/max
            if (ExpirationInDays.HasValue && ExpirationInDays.Value <= 0)
            {
                throw new Exception("Expiration in days cannot be less than one.");
            }

            //Mode
            if (Mode != FileVaultFileMode.ReadOnly && Mode != FileVaultFileMode.ReadWrite && Mode != FileVaultFileMode.PrivateReadOnly && Mode != FileVaultFileMode.PrivateReadWrite)
            {
                throw new Exception("Mode cannot be set to " + Mode);
            }

            //Clean
            Filename     = Filename?.Trim();
            PortId       = PortId?.Trim();
            AppOwnerName = AppOwnerName?.Trim();

            return(true);
        }
Exemplo n.º 30
0
        /// <summary>
        /// Creates a backup file
        /// </summary>
        /// <param name="filename"></param>
        public void AutoSaveAsync(string filename = null)
        {
            if (AutoSaveDocuments)
            {
                if (_IsSaving)
                {
                    return;
                }

                Task.Run(() =>
                {
                    filename = Filename;

                    if (filename == "untitled")
                    {
                        return;
                    }

                    Save(filename, true);
                });
            }
            else if (AutoSaveBackups)
            {
                // fire and forget
                Task.Run(() =>
                {
                    if (string.IsNullOrEmpty(filename))
                    {
                        filename = BackupFilename;
                    }

                    if (Filename.Contains("saved.bak"))
                    {
                        return;
                    }

                    if (Filename == "untitled")
                    {
                        filename = Path.Combine(Path.GetTempPath(), "untitled.saved.md");
                    }

                    try
                    {
                        File.WriteAllText(filename, CurrentText, Encoding);
                    }
                    catch
                    { /* ignore save error, write next cycle */ }
                });
            }
        }
Exemplo n.º 31
0
        public void SaveBackup()
        {
            if (string.IsNullOrWhiteSpace(Filename))
            {
                return;
            }

            var backupName = Filename;

            backupName = backupName.Insert(Filename.LastIndexOf("."), $".{DateTime.Now:yyyy-MM-dd HH.mm.ss}");
            backupName = Path.Combine(Session.BackupDirectory, Path.GetFileName(backupName));

            Write(backupName, isBackup: true);
        }
Exemplo n.º 32
0
        public void ChangeDirectionAimSetupCorrect()
        {
            var filename = new Filename(@"ChangeDirectionAim.xml");

            pattern.ParseXML(filename.File);
            dude.pos = new Vector2(100.0f, 0.0f);
            Mover mover = (Mover)manager.CreateBullet();

            mover.InitTopNode(pattern.RootNode);

            float direction = mover.Direction * 180 / (float)Math.PI;

            Assert.AreEqual(0, (int)direction);
        }
Exemplo n.º 33
0
        public void ChangeDirectionSeq()
        {
            var filename = new Filename(@"ChangeDirectionSeq.xml");

            pattern.ParseXML(filename.File);
            Mover mover = (Mover)manager.CreateBullet();

            mover.InitTopNode(pattern.RootNode);

            manager.Update();
            float direction = mover.Direction * 180 / (float)Math.PI;

            Assert.AreEqual(90, (int)direction);
        }
Exemplo n.º 34
0
        public override FILEERROR Save(BaseSceneSaver node, Filename name, BaseDocument doc, SCENEFILTER filterflags)
        {
            List<string> textureFiles;
            string fileName = name.GetString();
            string sceneRoot = Path.GetDirectoryName(fileName);
            var root = new FusConverter().FuseefyScene(doc, sceneRoot, out textureFiles);

            var ser = new Serializer();
            using (var file = File.Create(fileName))
            {
                ser.Serialize(file, root);
            }

            return FILEERROR.FILEERROR_NONE;
        }
Exemplo n.º 35
0
        public void CanCreatePreset()
        {
            // Positive test for input node

            // Create a valid input node
            var numberNode = new DoubleInput();
            numberNode.Value = "1";
            ViewModel.Model.CurrentWorkspace.AddAndRegisterNode(numberNode, false);

            // Verify the node was created and select it
            Assert.AreEqual(1, ViewModel.Model.CurrentWorkspace.Nodes.Count());
            DynamoSelection.Instance.Selection.Add(numberNode);

            // Check for input nodes in selection (should pass)
            Assert.AreEqual(true, ViewModel.GetInputNodesFromSelectionForPresets().Any());


            // Negative test for input node

            // Create a non-input node and select it
            var addNode = new DSFunction(ViewModel.Model.LibraryServices.GetFunctionDescriptor("+"));
            ViewModel.Model.CurrentWorkspace.AddAndRegisterNode(addNode, false);
            DynamoSelection.Instance.ClearSelection();
            DynamoSelection.Instance.Selection.Add(addNode);

            // Check for input nodes in selection (should fail)
            Assert.AreEqual(false, ViewModel.GetInputNodesFromSelectionForPresets().Any());


            // Re-test positive test for input node

            // Select the first created input node
            DynamoSelection.Instance.Selection.Add(numberNode);

            // Check for input nodes in selection (should pass)
            Assert.AreEqual(true, ViewModel.GetInputNodesFromSelectionForPresets().Any());


            // Positive test for File Path node

            // Create a File Path input node and select it
            var filePathNode = new Filename();
            filePathNode.Value = "C:\\foo.txt";
            ViewModel.Model.CurrentWorkspace.AddAndRegisterNode(filePathNode, false);
            DynamoSelection.Instance.ClearSelection();
            DynamoSelection.Instance.Selection.Add(filePathNode);

            // Check for input nodes in selection (should pass)
            Assert.AreEqual(true, ViewModel.GetInputNodesFromSelectionForPresets().Any());
        }
Exemplo n.º 36
0
        public override FILEERROR Save(BaseSceneSaver node, Filename name, BaseDocument doc, SCENEFILTER filterflags)
        {
            if (_newVersionExists)
            {
                if (!C4dApi.QuestionDialog(
                    "A newer version of the FUSEE export plugin is available at fusee3d.org/c4dexporter.\n\n" +
                    "Would you like to \n" +
                    " - complete this export operation using the existing plugin [Yes]\n" +
                    "or\n" +
                    " - cancel this export operation and download the newer version [No]?"))
                {
                    C4dApi.GeOpenHTML("http://fusee3d.org/c4dexporter");
                    return FILEERROR.FILEERROR_NONE;
                }
                _newVersionExists = false; // stop annoying the user...
            }
            List<string> textureFiles;
            string htmlFilePath = name.GetString();
            string htmlFileDir = Path.GetDirectoryName(htmlFilePath);
            string sceneRoot = Path.Combine(htmlFileDir, "Assets");
            string fuseePlayerDir = Path.Combine(GetThisPluginPath(), "Viewer");

            DirCopy.DirectoryCopy(fuseePlayerDir, htmlFileDir, true, true);

            string origHtmlFilePath = Path.Combine(htmlFileDir, "SceneViewer.html");
            if (File.Exists(htmlFilePath))
                File.Delete(htmlFilePath);

            File.Move(origHtmlFilePath, htmlFilePath);

            string sceneFileDir = Path.Combine(htmlFileDir, "Assets");
            string sceneFilePath = Path.Combine(sceneFileDir,  "Model.fus");

            var root = new FusConverter().FuseefyScene(doc, sceneFileDir, out textureFiles);

            var ser = new Serializer();
            using (var file = File.Create(sceneFilePath))
            {
                ser.Serialize(file, root);
            }

            for (int i = 0; i < textureFiles.Count; i++)
            {
                textureFiles[i] = Path.Combine("Assets", textureFiles[i]);
            }
            if (textureFiles != null)
                CreateAssetManifest(htmlFileDir, textureFiles);

            StartServer(htmlFileDir);
            C4dApi.GeOpenHTML("http://localhost:4655/" + Path.GetFileName(htmlFilePath));

            return FILEERROR.FILEERROR_NONE;
        }