public static void AddPoint(IDEInterop ide, TreeManager treeManager, AspectManager Manager, TreeViewAdapter Adapter, TreeNode NewParent, Action Callback)
        {
            if (ide.GetCurrentDocumentFileName() == "")
            {
                return;
            }

            string Text = ide.GetCurrentLine().Trim();

            if (Text == "")
            {
                return;
            }

            List <PointOfInterest> points = FindPointUnderCursor(ide, treeManager);

            if (points != null)
            {
                foreach (PointOfInterest pt in points)
                {
                    pt.FileName = Manager.GetRelativePath(pt.FileName);
                    pt.Text     = Text;
                }
            }
            ShowPointDialog(Adapter, points, NewParent, true, Callback);
        }
        public static void EditPointAnchor(IDEInterop ide, TreeManager treeManager, AspectManager Manager, TreeViewAdapter Adapter, TreeNode Node, Action Callback)
        {
            if (ide.GetCurrentDocumentFileName() == "")
            {
                return;
            }

            string Text = ide.GetCurrentLine().Trim();

            if (Text == "")
            {
                return;
            }

            List <PointOfInterest> points        = FindPointUnderCursor(ide, treeManager);
            PointOfInterest        OriginalPoint = Adapter.GetPointByNode(Node);

            if (points != null)
            {
                foreach (PointOfInterest pt in points)
                {
                    pt.FileName = Manager.GetRelativePath(pt.FileName);
                    pt.Title    = OriginalPoint.Title;
                    pt.Note     = OriginalPoint.Note;
                    pt.Text     = Text;
                }
            }

            ShowPointDialog(Adapter, points, Node, false, Callback);
        }
Example #3
0
        private static void TakeSubsetFromFile(string inputFile, int size, bool filter = false)
        {
            AspectManager AM = new AspectManager();
            ParserWrapper pw = _parser._pool.GetParserWrapper();

            AM.WorkingAspect = AM.DeserializeAspect(inputFile, pw);
            System.Console.WriteLine("Reading finished");

            List <PointOfInterest> points = AM.WorkingAspect.Items;

            if (filter)
            {
                int AmbigRemoved = 0;
                int AmbigRemains = 0;
                int GoodRemoved  = 0;
                int GoodRemains  = 0;
                for (int i = 0; i < points.Count; ++i)
                {
                    if (points[i]?.Title?.StartsWith("+ ") ?? false)
                    {
                        if (points[i].Title.StartsWith("+ using"))
                        {
                            points.RemoveAt(i);
                            i           -= 1;
                            GoodRemoved += 1;
                        }
                        else
                        {
                            GoodRemains += 1;
                        }
                    }
                    else
                    {
                        if (points[i]?.Title?.StartsWith("using") ?? true)
                        {
                            points.RemoveAt(i);
                            i            -= 1;
                            AmbigRemoved += 1;
                        }
                        else
                        {
                            AmbigRemains += 1;
                        }
                    }
                }
                Console.WriteLine("Removed: " + GoodRemoved + " good, " + AmbigRemoved + " ambiguous results");
                Console.WriteLine("Remains: " + GoodRemains + " good, " + AmbigRemains + " ambiguous results");
            }

            if (points.Count > size)
            {
                Shuffle(points);
                points.RemoveRange(size, points.Count - size);
            }

            AM.SerializeAspect(inputFile, true);
            System.Console.WriteLine("Writing finished");
            _parser._pool.ReleaseParserWrapper(pw);
        }
Example #4
0
 void Load()
 {
     foreach (var filename in Directory.GetFiles("Background"))
     {
         Texture2D t = FileHelper.LoadImage(filename);
         Sprite    s = Sprite.Create(t, new Rect(0, 0, t.width, t.height), new Vector2(0.5f, 0.5f));
         sprites.Add(Path.GetFileNameWithoutExtension(filename), s);
     }
     SetBackground(AspectManager.GetAspect());
 }
Example #5
0
 private void Awake()
 {
     m_Instance = this;
 }
Example #6
0
 public void ToggleInventory()
 {
     m_Inventory = !m_Inventory;
     SetBackground(AspectManager.GetAspect());
 }
Example #7
0
        static void Main(string[] args)
        {
            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();
            try
            {
                BaseDirectory = GetDirectoryFromCommandLine(args);
                //if (BaseDirectory == "")

                Ratio      = GetRatioFromCommandLine(args);
                InputFile  = GetFileFromCommandLine(args, ParamInputFile);
                OutputFile = GetFileFromCommandLine(args, ParamOutputFile);
                ListFile   = GetFileFromCommandLine(args, ParamListFile);
                Ext        = GetFileFromCommandLine(args, ParamEnumerateOnly);
                SubSet     = GetFileFromCommandLine(args, ParamSubset);

                if (!string.IsNullOrWhiteSpace(Ext))
                {
                    int count = EnumerateFiles(BaseDirectory, Ext, ListFile);
                    Console.WriteLine("Total nodes: " + count);
                    return;
                }
                if (!string.IsNullOrWhiteSpace(SubSet))
                {
                    bool filter = args.Contains(ParamFilter);
                    int  subSetNum;
                    if (!int.TryParse(SubSet, out subSetNum))
                    {
                        throw new Exception("Subset size not specified");
                    }
                    else
                    {
                        if (string.IsNullOrWhiteSpace(InputFile) || !File.Exists(InputFile))
                        {
                            throw new Exception("Input file doesn not exist");
                        }
                        TakeSubsetFromFile(InputFile, subSetNum, filter);
                    }
                    Console.ReadKey();
                    return;
                }
                if (!string.IsNullOrWhiteSpace(OutputFile))
                {
                    if (!File.Exists(ListFile))
                    {
                        throw new Exception("List file doesn not exist");
                    }
                    PointOfInterest Tree = BuildOutputFile(ListFile, BaseDirectory);
                    AspectManager   AM   = new AspectManager();
                    AM.WorkingAspect = Tree;
                    AM.SerializeAspect(OutputFile);
                }
                if (!string.IsNullOrWhiteSpace(InputFile))
                {
                    ProcessInputFile(BaseDirectory, InputFile);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                //Console.ReadKey();
            }
            sw.Stop();
            Console.WriteLine("Finished in " + sw.ElapsedMilliseconds / 1000 + " seconds");
        }
Example #8
0
        private static void ProcessInputFile(string BaseDir, string inputFile)
        {
            AspectManager AM = new AspectManager();
            ParserWrapper pw = _parser._pool.GetParserWrapper();

            AM.WorkingAspect = AM.DeserializeAspect(inputFile, pw);
            _parser._pool.ReleaseParserWrapper(pw);
            int             TotalNodes = AM.WorkingAspect.Items.Count;
            int             NotFound   = 0;
            int             Errors     = 0;
            int             Found      = 0;
            int             NotChanged = 0;
            TreeManager     TM         = new TreeManager();
            PointOfInterest NewAspect  = new PointOfInterest();
            Semaphore       S          = new Semaphore(1, 1);
            int             counter    = 0;

            Parallel.For(0, AM.WorkingAspect.Items.Count, (i) =>
                         //for (int i = 0; i < AM.WorkingAspect.Items.Count; ++i)
            {
                Interlocked.Increment(ref counter);
                if (counter % 10 == 0)
                {
                    S.WaitOne();
                    Console.Write("\rNodes left: " + (AM.WorkingAspect.Items.Count - counter) + "        ");
                    S.Release();
                }
                try
                {
                    PointOfInterest Pt      = AM.WorkingAspect.Items[i];
                    PointOfInterest Root    = TM.GetTree(BaseDir + Pt.FileName);
                    string text             = TM.GetText(BaseDir + Pt.FileName);
                    TreeSearchResult Search = TreeSearchEngine.FindPointInTree2(Root, Pt, text);
                    if (Search.Count == 0)
                    {
                        Interlocked.Increment(ref NotFound);
                    }
                    else if (Search.Singular)
                    {
                        if (Search.GetNodeSimilarity(0) == 1)
                        {
                            Interlocked.Increment(ref NotChanged);
                            return;
                            //continue;
                        }
                        else
                        {
                            Interlocked.Increment(ref Found);
                            AM.WorkingAspect.Items[i].Title = "+ " + AM.WorkingAspect.Items[i].Title;
                        }
                    }
                    else
                    {
                        if (Search.Count >= 2)
                        {
                            float d1 = 1 - Search.GetNodeSimilarity(0);
                            float d2 = 1 - Search.GetNodeSimilarity(1);
                            //float near = Math.Max(Pt.NearG, Pt.NearL);
                            //float threshold = ((near + 4) / 5 + 1) /2 ; //hardcoded
                            //if (Search.GetNodeSimilarity(0) >= threshold && Search.GetNodeSimilarity(1) < threshold)
                            if (d2 != 0 && d2 >= d1 * 2)
                            {
                                Interlocked.Increment(ref Found);
                                AM.WorkingAspect.Items[i].Title = "+ " + AM.WorkingAspect.Items[i].Title;
                                //return;
                                //continue;
                            }
                        }
                    }
                    S.WaitOne();
                    NewAspect.Items.Add(AM.WorkingAspect.Items[i]);
                    S.Release();
                }
                catch (Exception e)
                {
                    S.WaitOne();
                    Console.WriteLine(e.Message);
                    Errors += 1;
                    S.Release();
                }
            }
                         );
            AM.WorkingAspect = NewAspect;
            int Ambiguous = AM.WorkingAspect.Items.Count - Found;

            AM.SerializeAspect(inputFile, true);
            File.WriteAllText(inputFile + ".report.txt", "Total: " + TotalNodes + ", Not changed: " + NotChanged + ", found: " + Found + ", Not found: " + NotFound + ", errors: " + Errors + ", ambiguous: " + Ambiguous);
            Console.Write("\rNodes left: 0        ");
            Console.WriteLine();
        }