コード例 #1
0
 private static void AddAllDirectoriesChildren(TreeNode treeNode, CommonEntry dirEntry)
 {
     foreach (var subDirEntry in dirEntry.Children)
     {
         AddDirectoryChildren(treeNode, subDirEntry);
     }
 }
コード例 #2
0
ファイル: MainMenu.cs プロジェクト: cessnao3/CardClient
        private void ListGames_DoubleClick(object sender, EventArgs e)
        {
            CommonEntry entry = null;

            foreach (ListViewItem lvi in ListGames.SelectedItems)
            {
                entry = (CommonEntry)lvi.Tag;
            }

            if (entry != null)
            {
                // Hide the background form
                Hide();
                tmrLobbyCheck.Enabled = false;

                // Checkout Lobby Parameters
                game_window = new GameWindow(entry.id);
                game_window.ShowDialog(this);
                game_window = null;

                // Re-show the main form
                try
                {
                    tmrLobbyCheck.Enabled = true;
                    Show();
                }
                catch (ObjectDisposedException)
                {
                    // Do nothing, this object has already been disposed
                }
            }
        }
コード例 #3
0
 public int counter()
 {
     if (count == 0 && root != null)
     {
         count = CommonEntry.GetDirEntries(root).Count();
     }
     return(count);
 }
コード例 #4
0
 /// <summary>
 /// A node with children gets a dummy child node so Treeview shows node as expandable.
 /// </summary>
 private static void SetDummyChildNode(TreeNode treeNode, CommonEntry commonEntry)
 {
     if (commonEntry.Children != null &&
         commonEntry.Children.Any(entry => entry.IsDirectory))
     {
         treeNode.Nodes.Add(NewTreeNode(DummyNodeName));
     }
 }
コード例 #5
0
        public void SetDirectoryListView(CommonEntry commonEntry)
        {
            _directoryListCommonEntry = commonEntry;
            var directoryHelper = _clientForm.DirectoryListViewHelper;

            _directoryList = commonEntry.Children != null?commonEntry.Children.ToList() : null;

            directoryHelper.SetList(_directoryList);
            directoryHelper.SortList();
            _clientForm.SetDirectoryPathTextbox = commonEntry.FullPath;
        }
コード例 #6
0
        public void PerformanceTest_Compare_TraverseTree_With_DirEntryEnumerator()
        {
            var rootEntries = RootEntry.LoadCurrentDirCache();

            System.Threading.Thread.Sleep(200); // msec
            //_num = 0;
            _fileCount = 0;
            var sw = new Stopwatch();

            sw.Start();
            for (var i = 0; i < 100; ++i)
            {
                var deEnumerator = CommonEntry.GetDirEntries(rootEntries);
                foreach (var dirEntry in deEnumerator)
                {
                    //_num += (ulong)dirEntry.FullPath.Length;
                    ++_fileCount;
                    //if (Hack.BreakConsoleFlag)
                    //{
                    //    Console.WriteLine("\nBreak key detected exiting full TraverseTree inner.");
                    //    break;
                    //}
                }
            }
            sw.Stop();
            var ts          = sw.Elapsed;
            var elapsedTime = $"{ts.Hours:00}:{ts.Minutes:00}:{ts.Seconds:00}.{ts.Milliseconds/10:00}";

            Console.WriteLine($"Enumerator took : {elapsedTime}");
            Console.WriteLine($"Total files enumerated : {_fileCount}");
            //Console.WriteLine("Total path length : {0}", _num);

            var re = rootEntries.First();

            sw.Reset();
            sw.Start();
            //_num = 0;
            _fileCount = 0;
            for (var i = 0; i < 100; ++i)
            {
                re.TraverseTreePair((p, d) => { ++_fileCount; return(true); });
            }
            sw.Stop();
            ts          = sw.Elapsed;
            elapsedTime = $"{ts.Hours:00}:{ts.Minutes:00}:{ts.Seconds:00}.{ts.Milliseconds/10:00}";
            Console.WriteLine($"TraverseTreePair took : {elapsedTime}");
            Console.WriteLine($"Total files enumerated : {_fileCount}");
            //Console.WriteLine("Total path length : {0}", _num);
        }
コード例 #7
0
ファイル: Program.cs プロジェクト: CDEApp/CDE
        private static void PrintPathsHaveHashEnumerator()
        {
            var rootEntries = RootEntry.LoadCurrentDirCache();
            var pdee        = CommonEntry.GetPairDirEntries(rootEntries);

            foreach (var pairDirEntry in pdee)
            {
                var hash = pairDirEntry.ChildDE.IsHashDone ? "#" : " ";
                var bang = pairDirEntry.PathProblem ? "!" : " ";
                Console.WriteLine($"{hash}{bang}{pairDirEntry.FullPath}");
                if (Hack.BreakConsoleFlag)
                {
                    break;
                }
            }
        }
コード例 #8
0
        public long DoDirEntryEnumeratorCountTest(RootEntry root, int repeatCount)
        {
            var sw = new Stopwatch();

            sw.Start();
            var rootEntries = new List <RootEntry> {
                root
            };
            var dirEntries = CommonEntry.GetDirEntries(rootEntries);

            for (var i = 0; i < repeatCount; i++)
            {
                dirEntries.Count();
            }
            sw.Stop();
            return(sw.ElapsedMilliseconds);
        }
コード例 #9
0
ファイル: Program.cs プロジェクト: CDEApp/CDE
        private static void FindPouplous(int minimumCount)
        {
            var rootEntries  = RootEntry.LoadCurrentDirCache();
            var entries      = CommonEntry.GetDirEntries(rootEntries);
            var largeEntries = entries
                               .Where(e => e.Children != null && e.Children.Count > minimumCount)
                               .ToList();

            largeEntries.Sort(CompareDirEntries);

            foreach (var e in largeEntries.Where(e => e.Children != null && e.Children.Count > minimumCount))
            {
                Console.WriteLine($"{e.FullPath} {e.Children.Count}");
                if (Hack.BreakConsoleFlag)
                {
                    break;
                }
            }
        }
コード例 #10
0
        public void TraverseAllTrees_TreeHeirarchy_CallsActionOnAllChildrenOnBothRoots()
        {
            DirEntry de2a;
            DirEntry de2b;
            DirEntry de2c;
            DirEntry de3a;
            DirEntry de4a;
            var      re1 = NewTestRootEntry(out de2a, out de2b, out de2c, out de3a, out de4a);

            DirEntry bde2a;
            DirEntry bde2b;
            DirEntry bde2c;
            DirEntry bde3a;
            DirEntry bde4a;
            var      re2 = NewTestRootEntry(out bde2a, out bde2b, out bde2c, out bde3a, out bde4a);

            // same structure as re1 with a different root path
            re2.Path = "2";

            var mockAction = MockRepository.GenerateMock <TraverseFunc>();

            using (mockAction.GetMockRepository().Ordered())
            {
                mockAction.Expect(x => x(re1, de2c)).Repeat.Times(1).Return(true);
                mockAction.Expect(x => x(re1, de2a)).Repeat.Times(1).Return(true);
                mockAction.Expect(x => x(re1, de2b)).Repeat.Times(1).Return(true);
                mockAction.Expect(x => x(de2b, de3a)).Repeat.Times(1).Return(true);
                mockAction.Expect(x => x(de3a, de4a)).Repeat.Times(1).Return(true);

                mockAction.Expect(x => x(re2, bde2c)).Repeat.Times(1).Return(true);
                mockAction.Expect(x => x(re2, bde2a)).Repeat.Times(1).Return(true);
                mockAction.Expect(x => x(re2, bde2b)).Repeat.Times(1).Return(true);
                mockAction.Expect(x => x(bde2b, bde3a)).Repeat.Times(1).Return(true);
                mockAction.Expect(x => x(bde3a, bde4a)).Repeat.Times(1).Return(true);
            }

            CommonEntry.TraverseTreePair(new List <RootEntry> {
                re1, re2
            }, mockAction);

            mockAction.VerifyAllExpectations();
        }
コード例 #11
0
            public void BeforeAllTests()
            {
                RootSmall = RootEntry.LoadDirCache(TestCatalog200K);
                if (RootSmall == null)
                {
                    Assert.Inconclusive("TestData not Found" + TestCatalog200K);
                }
                var e1 = CommonEntry.GetDirEntries(RootSmall);

                RootSmallCount = e1.Count();

                RootLarge = RootEntry.LoadDirCache(TestCatalog1_2M);
                if (RootSmall == null)
                {
                    Assert.Inconclusive("TestData not Found" + TestCatalog1_2M);
                }
                var e2 = CommonEntry.GetDirEntries(RootLarge);

                RootLargeCount = e2.Count();
            }
コード例 #12
0
ファイル: MainMenu.cs プロジェクト: cessnao3/CardClient
        private void ListLobbies_DoubleClick(object sender, EventArgs e)
        {
            CommonEntry entry = null;

            foreach (ListViewItem lvi in ListLobbies.SelectedItems)
            {
                entry = (CommonEntry)lvi.Tag;
            }

            if (entry != null)
            {
                // Checkout Lobby Parameters
                lobby_window = new JoinLobby(entry.id);
                lobby_window.ShowDialog();
                lobby_window = null;

                // Recheck game parameters
                tmrLobbyCheck_Tick(null, null);
            }
        }
コード例 #13
0
        public CommonInfoFile(string inFilename, byte[] rawData, byte[] subHeader, int[] ptrs, int baseAddr)
        {
            filename           = inFilename;
            header             = subHeader;
            calculatedPointers = ptrs;
            MemoryStream inputStream = new MemoryStream(rawData);
            BinaryReader inputReader = new BinaryReader(inputStream);

            inputStream.Seek(4, SeekOrigin.Begin);
            int origFilesize = inputReader.ReadInt32();
            int headerLoc    = inputReader.ReadInt32();

            inputStream.Seek(headerLoc, SeekOrigin.Begin);
            int mainListLoc       = inputReader.ReadInt32() - baseAddr;
            int mainListCountsLoc = inputReader.ReadInt32() - baseAddr;

            byte[] mainListLocs = new byte[15];
            inputStream.Seek(mainListCountsLoc, SeekOrigin.Begin);
            for (int i = 0; i < 15; i++)
            {
                mainListLocs[i] = inputReader.ReadByte();
                entries[i]      = new List <CommonEntry> [inputReader.ReadByte()][];
                totalEntries   += entries[i].Length;
            }
            for (int i = 0; i < 15; i++)
            {
                inputStream.Seek(mainListLoc + mainListLocs[i] * 16, SeekOrigin.Begin);
                for (int j = 0; j < entries[i].Length; j++)
                {
                    int   entryLocs       = inputReader.ReadInt32() - baseAddr;
                    short totalNumEntries = inputReader.ReadInt16();
                    short numSubcats      = inputReader.ReadInt16();
                    short expandSubcats   = numSubcats;
                    if (i == 0 && numSubcats < 0x1B)
                    {
                        expandSubcats = 0x1B;
                    }
                    int subcatLocsLoc    = inputReader.ReadInt32() - baseAddr;
                    int subcatLengthsLoc = inputReader.ReadInt32() - baseAddr;
                    entries[i][j] = new List <CommonEntry> [expandSubcats];
                    long  currLoc       = inputStream.Position;
                    int[] subcatLocs    = new int[expandSubcats];
                    int[] subcatLengths = new int [expandSubcats];
                    inputStream.Seek(subcatLocsLoc, SeekOrigin.Begin);
                    for (int k = 0; k < expandSubcats; k++)
                    {
                        if (k < numSubcats)
                        {
                            subcatLocs[k] = inputReader.ReadInt16();
                        }
                    }
                    inputStream.Seek(subcatLengthsLoc, SeekOrigin.Begin);
                    for (int k = 0; k < expandSubcats; k++)
                    {
                        if (k < numSubcats)
                        {
                            subcatLengths[k] = inputReader.ReadByte();
                        }
                    }
                    for (int k = 0; k < expandSubcats; k++)
                    {
                        if (k < numSubcats)
                        {
                            inputStream.Seek(entryLocs + subcatLocs[k] * 2, SeekOrigin.Begin);
                            entries[i][j][k] = new List <CommonEntry>(subcatLengths[k]);
                            for (int m = 0; m < subcatLengths[k]; m++)
                            {
                                CommonEntry temp = new CommonEntry();
                                temp.rarity    = inputReader.ReadByte();
                                temp.sortOrder = inputReader.ReadByte();
                                entries[i][j][k].Insert(m, temp);//inputReader.ReadBytes(subcatLengths[k] * 2);//new byte[subcatLengths[k] * 2];
                            }
                        }
                        else
                        {
                            entries[i][j][k] = new List <CommonEntry>(0);
                        }
                    }
                    inputStream.Seek(currLoc, SeekOrigin.Begin);
                }
            }
            //inputStream.Seek(mainListLocs
        }
コード例 #14
0
 private static TreeNode NewTreeNode(CommonEntry commonEntry)
 {
     return(NewTreeNode(commonEntry.Path, commonEntry));
 }
コード例 #15
0
ファイル: MainMenu.cs プロジェクト: cessnao3/CardClient
        private void tmrServerTick_Tick(object sender, EventArgs e)
        {
            // Read input messages
            int read_msg = 0;

            while (read_msg < 10)
            {
                MsgBase msg = Network.GameComms.ReceiveMessage();

                if (msg == null)
                {
                    break;
                }

                Console.WriteLine("Received " + msg.GetType().ToString());

                if (msg is MsgGameStatus)
                {
                    MsgGameStatus status = (MsgGameStatus)msg;

                    if (game_window != null)
                    {
                        game_window.UpdateGame(status);
                    }
                }
                else if (msg is MsgGameList)
                {
                    MsgGameList game_list = (MsgGameList)msg;

                    ListGames.Items.Clear();
                    foreach (MsgGameList.ListItem i in game_list.Games)
                    {
                        CommonEntry  gi  = new CommonEntry(id: i.GameIDValue, game_type: (GameTypes)i.GameType);
                        ListViewItem lvi = new ListViewItem(gi.ToString())
                        {
                            Tag = gi
                        };
                        ListGames.Items.Add(lvi);
                    }

                    ListLobbies.Items.Clear();
                    foreach (MsgGameList.ListItem i in game_list.Lobbies)
                    {
                        CommonEntry  li  = new CommonEntry(id: i.GameIDValue, game_type: (GameTypes)i.GameType);
                        ListViewItem lvi = new ListViewItem(li.ToString())
                        {
                            Tag = li
                        };
                        ListLobbies.Items.Add(lvi);
                    }
                }
                else if (msg is MsgLobbyStatus)
                {
                    MsgLobbyStatus status = (MsgLobbyStatus)msg;
                    if (lobby_window != null)
                    {
                        lobby_window.UpdateStatus(status);
                    }
                }

                read_msg += 1;
            }

            // Check for server failure
            if (Network.GameComms.Failed())
            {
#if DEBUG
                Application.Exit();
#else
                Application.Restart();
#endif
            }
        }