Exemplo n.º 1
0
        TestResult RunTest(ITestCase testCase, INodeTree nodeTree, CancellationToken token)
        {
            Stopwatch  sw         = Stopwatch.StartNew();
            TestResult testResult = new TestResult();

            testResult.testCase = testCase;
            testResult.nodeTree = nodeTree;
            try
            {
                INodeTree clonedNodeTree = nodeTree.Clone();
                (testResult.successInsert, testResult.durationInsert) = RunTestInsert(clonedNodeTree, testCase, token);
                (testResult.successFind, testResult.durationFind)     = RunTestFind(clonedNodeTree, testCase, token);
                (testResult.successRemove, testResult.durationRemove) = RunTestRemove(clonedNodeTree, testCase, token);
            }
            catch (OperationCanceledException)
            {
                testResult.timeout = true;
            }
            catch (Exception)
            {
                testResult.exception = true;
            }
            sw.Stop();
            testResult.durationTest = sw.Elapsed.TotalSeconds;
            return(testResult);
        }
 public void ShowScriptEditor(INodeTree script)
 {
     MainControl = new ScriptEditor
     {
         DataContext = script,
     };
     PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(MainControl)));
 }
Exemplo n.º 3
0
        public bool AddSystem(string id, INodeTree nodeTree)
        {
            if (nodeTree == null)
            {
                return(false);
            }

            mFileSystems.Push(nodeTree);
            return(true);
        }
Exemplo n.º 4
0
        public void AddScriptInstance(INodeTree script)
        {
            (DataContext as MainWindowViewModel).CloseAddScriptsButton();
            IAdvancedScriptInstance newScript = App.LaminarInstance.Factory.GetImplementation <IAdvancedScriptInstance>();

            newScript.Script     = script;
            newScript.Name.Value = script.Name.Value;
            // aAanewScript.IsActive.Value = true;
            App.LaminarInstance.AllScripts.Scripts.Add(newScript);
        }
 // Treevoids
 /// <summary>
 /// Gets a tree at index with a certain type. If tree is not convertable to type null is returned
 /// </summary>
 /// <returns>The tree as.</returns>
 /// <param name="Index">Index.</param>
 /// <typeparam name="T">The 1st type parameter.</typeparam>
 public T GetTreeAs <T>(int Index) where T : class
 {
     if (HasTreeAtIndex(Index))
     {
         INodeTree Tree = NodeTrees [Index];
         if (CheckTreeDirectType <T> (Tree))
         {
             return((T)(object)Tree);
         }
     }
     return(null);
 }
        // search voids
        /// <summary>
        /// Searches a path from A to B with a given type
        /// </summary>
        /// <param name="TreeIndex">Index of the node tree to use for the search</param>
        /// <param name="From">From</param>
        /// <param name="To">To</param>
        /// <param name="OnCalculated">Callback that is invoked when the path is found</param>
        /// <param name="OnError">Callback that is invoked when an error has occured during the search</param>
        /// <param name="Modifiers">Modifiers that should be used on this path</param>
        /// <typeparam name="T">The type of the path you want to search</typeparam>
        public TrackerSearch <T> SearchPath <T>(int TreeIndex, T From, T To, System.Action <Stack <T> > OnCalculated, System.Action <string> OnError, IModifier <T>[] Modifiers, int CurrentRegion = -1, int?LastVisitedNode = null)
        {
            if (HasTreeAtIndex(TreeIndex))    // check if tree exists
            {
                INodeTree Tree = NodeTrees [TreeIndex];
                if (CheckTreeType <T>(Tree))
                {
                    TrackerSearch <T> SearchInstance = new TrackerSearch <T> (Tree); // initialize new
                    SearchInstance.FindPathAsync(From, To, (Stack <T> CalculatedPath) => {
                        if (Modifiers != null)                                       // check if there are any modifiers
                        {
                            for (int i = 0; i < Modifiers.Length; i++)
                            {
                                if (Modifiers[i] != null)  // null check modifier
                                {
                                    CalculatedPath = Modifiers[i].ModifyPath(CalculatedPath);
                                }
                            } // modify path
                        }

                        Dispatcher.Instance.Invoke(() => {                       // invoke to main thread
                            if (!SearchInstance.CancelationPending)
                            {
                                OnCalculated.Invoke(CalculatedPath);                                 // invoke calculated path
                            }
                        });
                    }, (string Error) => {
                        Dispatcher.Instance.Invoke(() => {                       // invoke to main thread
                            OnError.Invoke(Error);
                        });
                    }, CurrentRegion, LastVisitedNode);
                    return(SearchInstance);
                }
                else
                {
                    Dispatcher.Instance.Invoke(() => {                   // invoke to main thread
                        OnError.Invoke("Tree at index: " + TreeIndex + " could NOT be converted to an node tree of type (" + typeof(T) + ")");
                    });
                    return(null);                    // end void
                }
            }
            else
            {
                Dispatcher.Instance.Invoke(() => {               // invoke to main thread
                    OnError.Invoke("There is no tree at index: " + TreeIndex);
                });
                return(null);                // end void
            }
            return(null);
        }
Exemplo n.º 7
0
        public async Task AddScript()
        {
            string text = await TextPrompt.Show(this, "Script Maker", "Please enter the name of the script");

            if (text is null or "")
            {
                return;
            }

            INodeTree newTree = App.LaminarInstance.Factory.GetImplementation <INodeTree>();

            newTree.Name.Value = text;
            App.LaminarInstance.AllAdvancedScripts.Add(newTree);

            _needsScriptInstance = true;
            OpenScriptEditor(newTree);
        }
 private bool CheckTreeType <T>(INodeTree Tree)
 {
     return(typeof(ANodeTree <T>).IsAssignableFrom(Tree.GetType()));
 }
Exemplo n.º 9
0
 public void Add(INodeTree nodeTree)
 {
     nodeTrees.Add(nodeTree);
 }
Exemplo n.º 10
0
 public void OpenScriptEditor(INodeTree script)
 {
     (DataContext as MainWindowViewModel).ShowScriptEditor(script);
 }
        public const int MaxIterations = 1000;         // Maximal amount of iterations to be done
        #endregion

        #region Constructur
        /// <summary>
        /// Initializes a new instance of the <see cref="Tracker.Search.TrackerSearch`1"/> class.
        /// </summary>
        /// <param name="Tree">The node tree to search in</param>
        public TrackerSearch(INodeTree Tree)
        {
            this.Tree = Tree;
        }