private void ScanMtf(ScanningState state, CancellationToken token)
        {
            FileNodeIndexes[]      fileItemsLookup;
            List <FileNodeIndexes> fileItems = new List <FileNodeIndexes>();

            DriveInfo driveInfo = new DriveInfo(Path.GetPathRoot(state.RootPath));

            using (NtfsReader ntfs = new NtfsReader(driveInfo, RetrieveMode.StandardInformations)) {
                fileItemsLookup = new FileNodeIndexes[ntfs.NodeCount];
                ReadMft(state, ntfs, fileItemsLookup, fileItems, token);
            }

            foreach (FileNodeIndexes indexes in fileItems)
            {
                FileItemBase    item          = indexes.FileItem;
                FileNodeIndexes parentIndexes = fileItemsLookup[indexes.ParentNodeIndex];
                if (indexes.NodeIndex == indexes.ParentNodeIndex)
                {
                    // This must be the drive root
                }
                else if (parentIndexes != null)
                {
                    ((FolderItem)parentIndexes.FileItem).AddItem(item,
                                                                 ref parentIndexes.FileCollection, ref parentIndexes.FirstFile);
                }
                else
                {
                    // This must be the root
                }
                if (AsyncChecks(token))
                {
                    return;
                }
            }
        }
예제 #2
0
        private void ScanMtf(ScanningState state, CancellationToken token)
        {
            Dictionary <uint, FileNodeIndexes> fileNodes = new Dictionary <uint, FileNodeIndexes>();

            DriveInfo driveInfo = new DriveInfo(Path.GetPathRoot(state.RootPath));

            using (NtfsReader ntfs = new NtfsReader(driveInfo, RetrieveMode.StandardInformations)) {
                ReadMft(state, ntfs, fileNodes, token);
            }

            foreach (FileNodeIndexes indexes in fileNodes.Values)
            {
                FileNodeBase node = indexes.FileNode;
                //if (node.Type == FileNodeType.File)
                //	document.Extensions.Include(node.Extension, node.Size);
                if (indexes.NodeIndex == indexes.ParentNodeIndex)
                {
                    // This must be a root
                }
                else if (fileNodes.TryGetValue(indexes.ParentNodeIndex, out var parentIndexes))
                {
                    ((FolderNode)parentIndexes.FileNode).AddChild(node,
                                                                  ref parentIndexes.FileCollection, ref parentIndexes.SingleFile);
                }
                SuspendCheck();
                if (token.IsCancellationRequested)
                {
                    return;
                }
            }
        }
        /// <summary>Runs the actual scan on a single root path.</summary>
        ///
        /// <param name="rootPath">The single root path to scan.</param>
        /// <param name="token">The token for cleanly cancelling the operations.</param>
        private void Scan(string rootPath, CancellationToken token)
        {
            ScanningState state = CreateState(rootPath, true);

            scanningStates = new List <ScanningState>()
            {
                state
            };
            CanDisplayProgress = scanningStates[0].IsDrive;

            TotalSize      = state.TotalSize;
            TotalFreeSpace = state.FreeSpace;

            RootItem      = (RootItem)state.Root;
            ProgressState = ScanProgressState.Started;

            try {
                ScanMtf(state, token);
            }
            catch (Exception) {
                // We don't have permission, are not elevated, or path is not an NTFS drive
                // We'll scan this path normally instead
                ScanNative(token);
            }
            FinishScan(token);
        }
        private void RefreshFolders(Queue <FolderItem> subdirs, CancellationToken token)
        {
            scanningStates = new List <ScanningState>();
            foreach (FolderItem subdir in subdirs)
            {
                scanningStates.Add(CreateState(subdir));
            }

            // Master file tables cannot be scanned inline, so scan them one at a time first
            for (int i = 0; i < scanningStates.Count; i++)
            {
                ScanningState state = scanningStates[i];
                try {
                    ScanMtf(state, token);
                    scanningStates.RemoveAt(i--);
                }
                catch (Exception) {
                    // We don't have permission, are not elevated, or path is not an NTFS drive
                    // We'll scan this path normally instead
                }
            }

            if (scanningStates.Count > 0)
            {
                ScanNative(token);
            }

            scanningStates = null;
        }
예제 #5
0
        private void UpdateScanningState(ScanningState state, string message = null)
        {
            ScanningState = state;

            if (!string.IsNullOrEmpty(message))
            {
                ScanStatus = message;
            }
        }
예제 #6
0
        private void ReadMft(ScanningState state, NtfsReader ntfs, Dictionary <uint, FileNodeIndexes> fileNodes,
                             CancellationToken token)
        {
            foreach (INtfsNode node in ntfs.EnumerateNodes(state.RootPath))
            {
                string fullPath = PathUtils.TrimSeparatorDotEnd(node.FullName);
                bool   isRoot   = (node.NodeIndex == node.ParentNodeIndex);
                if (!isRoot && SkipFile(state, Path.GetFileName(fullPath), fullPath))
                {
                    continue;
                }
                FileNodeBase child;
                if (isRoot)
                {
                    child = state.Root;

                    /*state.Root = new RootNode(document, node, IsSingle);
                     * child = state.Root;
                     * // Let the user know that the root was found
                     * SetupRoot(state.Root, rootSetup);*/
                }
                else if (node.Attributes.HasFlag(FileAttributes.Directory))
                {
                    if (!state.IsDrive && state.RootPath == node.FullName.ToUpperInvariant())
                    {
                        child = state.Root;

                        /*state.Root = new RootNode(document, node, IsSingle);
                         * child = state.Root;
                         * // Let the user know that the root was found
                         * SetupRoot(state.Root, rootSetup);*/
                    }
                    else
                    {
                        child = new FolderNode(node);
                    }
                }
                else
                {
                    FileNode file = new FileNode(node);
                    child = file;
                    if (!node.Attributes.HasFlag(FileAttributes.ReparsePoint))
                    {
                        state.ScannedSize += child.Size;
                        totalScannedSize  += child.Size;
                    }
                    file.extRecord = extensions.Include(GetExtension(file.Name), child.Size);
                }
                fileNodes[node.NodeIndex] = new FileNodeIndexes(child, node);
                SuspendCheck();
                if (token.IsCancellationRequested)
                {
                    return;
                }
            }
        }
예제 #7
0
 private static void StuckScanning(object sender, System.Timers.ElapsedEventArgs e)
 {
     if (currentState != ScanningState.Stuck)
     {
         currentState = ScanningState.Stuck;
         MainForm.mainForm.Invoke((MethodInvoker) delegate {
             MainForm.mainForm.SetScanningImage("scanningbar-gray.gif", "Waiting, possibly stuck...", false);
         });
     }
 }
        private void ReadMft(ScanningState state, NtfsReader ntfs, FileNodeIndexes[] fileItemsLookup,
                             List <FileNodeIndexes> fileItems, CancellationToken token)
        {
            foreach (INtfsNode node in ntfs.EnumerateNodes(state.RootPath))
            {
                string fullPath = PathUtils.TrimSeparatorDotEnd(node.FullName);
                bool   isRoot   = (node.NodeIndex == node.ParentNodeIndex);
                if (!isRoot && SkipFile(state, Path.GetFileName(fullPath), fullPath))
                {
                    continue;
                }
                FileItemBase child;
                bool         reparsePoint = node.Attributes.HasFlag(FileAttributes.ReparsePoint);
                if (isRoot)
                {
                    child = state.Root;
                }
                else if (node.Attributes.HasFlag(FileAttributes.Directory))
                {
                    if (!state.IsDrive && state.RootPath == node.FullName.ToUpperInvariant())
                    {
                        child = state.Root;
                    }
                    else
                    {
                        child = new FolderItem(new ScanFileInfo(node));
                    }
                }
                else
                {
                    ExtensionItem extension = Extensions.GetOrAddFromPath(node.Name);
                    FileItem      file      = new FileItem(new ScanFileInfo(node), extension);
                    child = file;
                    if (!reparsePoint)
                    {
                        TotalScannedSize += child.Size;
                    }
                }
                FileNodeIndexes indexes = new FileNodeIndexes(child, node);
                fileItemsLookup[node.NodeIndex] = indexes;

                if (!reparsePoint)
                {
                    fileItems.Add(indexes);
                }

                if (AsyncChecks(token))
                {
                    return;
                }
            }
        }
        public static bool ToBool(this ScanningState scanningState)
        {
            switch (scanningState)
            {
            case ScanningState.NotScanning:
                return(false);

            case ScanningState.Scanning:
                return(true);

            default:
                throw new ArgumentException("Scanning state not convertable to boolean");
            }
        }
예제 #10
0
        public static void StartScanning()
        {
            BackgroundWorker mainScanner = new BackgroundWorker();

            mainScanner.DoWork += ScanMemory;
            mainScanner.RunWorkerAsync();

            BackgroundWorker missingChunkScanner = new BackgroundWorker();

            missingChunkScanner.DoWork += ScanMissingChunks;
            missingChunkScanner.RunWorkerAsync();

            currentState = ScanningState.NoTibia;
        }
        /// <summary>Runs the actual scan on any number of root paths.</summary>
        ///
        /// <param name="rootPaths">The root paths to scan.</param>
        /// <param name="token">The token for cleanly cancelling the operations.</param>
        protected void Scan(string[] rootPaths, CancellationToken token)
        {
            // See if we can perform a single scan
            if (rootPaths.Length == 1)
            {
                Scan(rootPaths[0], token);
                return;
            }

            scanningStates     = rootPaths.Select(p => CreateState(p, false)).ToList();
            CanDisplayProgress = !scanningStates.Any(s => !s.IsDrive);

            TotalSize      = scanningStates.Sum(s => s.TotalSize);
            TotalFreeSpace = scanningStates.Sum(s => s.FreeSpace);

            // Computer Root
            RootItem computerRoot = new RootItem(this);

            foreach (ScanningState state in scanningStates)
            {
                computerRoot.AddItem(state.Root);
            }

            RootItem      = computerRoot;
            ProgressState = ScanProgressState.Started;

            // Master file tables cannot be scanned inline, so scan them one at a time first
            for (int i = 0; i < scanningStates.Count; i++)
            {
                ScanningState state = scanningStates[i];
                try {
                    ScanMtf(state, token);
                    scanningStates.RemoveAt(i--);
                }
                catch (Exception) {
                    // We don't have permission, are not elevated, or path is not an NTFS drive
                    // We'll scan this path normally instead
                }
            }

            // Are there any leftover states to work on?
            if (scanningStates.Any())
            {
                ScanNative(token);
            }

            FinishScan(token);
        }
예제 #12
0
        public static void StartScanning()
        {
            scanTimer          = new System.Timers.Timer(10000);
            scanTimer.Elapsed += StuckScanning;

            int initialScanSpeed = SettingsManager.getSettingInt("ScanSpeed") * 15 + 1;

            missingChunkScanTimer = new SafeTimer(initialScanSpeed, ScanMissingChunksTimer);
            missingChunkScanTimer.Start();

            initialScanSpeed = SettingsManager.getSettingInt("ScanSpeed") * 5 + 1;
            mainScanTimer    = new SafeTimer(initialScanSpeed, MainScanTimer);
            mainScanTimer.Start();

            currentState = ScanningState.NoTibia;
        }
        /// <summary>Checks if we should ignore this file in the scan.</summary>
        ///
        /// <param name="state">The scan state for this file.</param>
        /// <param name="name">The name of the file.</param>
        /// <param name="path">The full path of the file.</param>
        /// <returns>True if the file should be skipped.</returns>
        private bool SkipFile(ScanningState state, string name, string path)
        {
            if (name.Length == 0)
            {
                Console.WriteLine("WHAT");
            }
            // We still want to see all those delicious files that were thrown away
            if (name[0] == '$' && !path.StartsWith(state.RecycleBinPath))
            {
                return(true);
            }

            // Certified spam
            //if (string.Compare(name, "desktop.ini", true) == 0)
            //	return true;

            return(false);
        }
예제 #14
0
 private static void ScanMemory(object sender, DoWorkEventArgs e)
 {
     while (true)
     {
         if (scanTimer == null)
         {
             scanTimer          = new System.Timers.Timer(10000);
             scanTimer.Elapsed += StuckScanning;
             scanTimer.Enabled  = true;
         }
         bool success = false;
         try {
             success = ScanMemory();
         } catch (Exception ex) {
             MainForm.mainForm.BeginInvoke((MethodInvoker) delegate {
                 MainForm.mainForm.DisplayWarning(String.Format("Database Scan Error (Non-Fatal): {0}", ex.Message));
                 Console.WriteLine(ex.Message);
             });
         }
         scanTimer.Dispose();
         scanTimer = null;
         if (success)
         {
             if (currentState != ScanningState.Scanning)
             {
                 currentState = ScanningState.Scanning;
                 MainForm.mainForm.BeginInvoke((MethodInvoker) delegate {
                     MainForm.mainForm.SetScanningImage("scanningbar.gif", "Scanning Memory...", true);
                 });
             }
         }
         else
         {
             if (currentState != ScanningState.NoTibia)
             {
                 currentState = ScanningState.NoTibia;
                 MainForm.mainForm.BeginInvoke((MethodInvoker) delegate {
                     MainForm.mainForm.SetScanningImage("scanningbar-red.gif", "No Tibia Client Found...", true);
                 });
             }
         }
     }
 }
        /// <summary>
        /// Creates a <see cref="ScanningState"/> for the specified <see cref="FolderItem"/>.
        /// </summary>
        ///
        /// <param name="folder">The folder to create the state for.</param>
        /// <returns>The newly created and initialized <see cref="ScanningState"/>.</returns>
        private ScanningState CreateState(FolderItem folder)
        {
            string        rootPath = folder.FullName;
            string        pathRoot = Path.GetPathRoot(rootPath);
            ScanningState state    = new ScanningState {
                IsDrive        = PathUtils.IsSamePath(pathRoot, rootPath),
                RecycleBinPath = Path.Combine(pathRoot, "$Recycle.Bin"),
                Root           = folder,
                RootPath       = rootPath.ToUpperInvariant(),
            };

            if (state.IsDrive)
            {
                Win32.GetDiskFreeSpaceEx(rootPath, out _, out ulong totalSize, out ulong freeSpace);
                state.TotalSize = (long)totalSize;
                state.FreeSpace = (long)freeSpace;
            }
            return(state);
        }
        /// <summary>Creates a <see cref="ScanningState"/> for the specified root path.</summary>
        ///
        /// <param name="rootPath">The path to create a state for.</param>
        /// <param name="single">
        /// True if the there is only one state.<para/>
        /// This means this is the absolute root item instead of Computer.
        /// </param>
        /// <returns>The newly created and initialized <see cref="ScanningState"/>.</returns>
        private ScanningState CreateState(string rootPath, bool single)
        {
            rootPath = Path.GetFullPath(rootPath);
            string        pathRoot = Path.GetPathRoot(rootPath);
            ScanningState state    = new ScanningState {
                IsDrive        = PathUtils.IsSamePath(pathRoot, rootPath),
                RecycleBinPath = Path.Combine(pathRoot, "$Recycle.Bin"),
                Root           = new RootItem(this, new DirectoryInfo(rootPath), single),
                RootPath       = rootPath.ToUpperInvariant(),
            };

            if (state.IsDrive)
            {
                Win32.GetDiskFreeSpaceEx(rootPath, out _, out ulong totalSize, out ulong freeSpace);
                state.TotalSize = (long)totalSize;
                state.FreeSpace = (long)freeSpace;
            }
            return(state);
        }
예제 #17
0
        private static void ScanMemoryInternal()
        {
            scanTimer.Start();
            bool success = false;

            try
            {
                success = ScanMemory();
            } catch (Exception ex)
            {
                MainForm.mainForm.BeginInvoke((MethodInvoker) delegate {
                    MainForm.mainForm.DisplayWarning(String.Format("Database Scan Error (Non-Fatal): {0}", ex.Message));
                    Console.WriteLine(ex.Message);
                });
            }

            scanTimer.Stop();
            scanTimer.Start();

            if (success)
            {
                if (currentState != ScanningState.Scanning)
                {
                    currentState = ScanningState.Scanning;
                    MainForm.mainForm.BeginInvoke((MethodInvoker) delegate {
                        MainForm.mainForm.SetScanningImage("scanningbar.gif", "Scanning Memory...", true);
                    });
                }
            }
            else
            {
                if (currentState != ScanningState.NoTibia)
                {
                    currentState = ScanningState.NoTibia;
                    MainForm.mainForm.BeginInvoke((MethodInvoker) delegate {
                        MainForm.mainForm.SetScanningImage("scanningbar-red.gif", "No Tibia Client Found...", true);
                    });
                }
            }
        }
예제 #18
0
        public static void StartScanning()
        {
            scanTimer          = new System.Timers.Timer(10000);
            scanTimer.Elapsed += StuckScanning;

            int initialScanSpeed = SettingsManager.getSettingInt("ScanSpeed") * 15 + 1;

            missingChunkScanTimer           = new System.Timers.Timer(initialScanSpeed);
            missingChunkScanTimer.AutoReset = false;
            missingChunkScanTimer.Elapsed  += (o, e) => {
                ReadMemoryManager.ScanMissingChunks();
                int scanSpeed = SettingsManager.getSettingInt("ScanSpeed") * 15 + 1;
                if (scanSpeed != missingChunkScanTimer.Interval)
                {
                    missingChunkScanTimer.Interval = scanSpeed;
                }

                missingChunkScanTimer.Start();
            };
            missingChunkScanTimer.Start();

            initialScanSpeed        = SettingsManager.getSettingInt("ScanSpeed") * 5 + 1;
            mainScanTimer           = new System.Timers.Timer(initialScanSpeed);
            mainScanTimer.AutoReset = false;
            mainScanTimer.Elapsed  += (o, e) => {
                ScanMemory(o, null);
                int scanSpeed = SettingsManager.getSettingInt("ScanSpeed") * 5 + 1;
                if (scanSpeed != mainScanTimer.Interval)
                {
                    mainScanTimer.Interval = scanSpeed;
                }

                mainScanTimer.Start();
            };
            mainScanTimer.Start();

            currentState = ScanningState.NoTibia;
        }
예제 #19
0
        public MainForm()
        {
            Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture;
            mainForm = this;
            InitializeComponent();
            makeDraggable(this.Controls);
            this.InitializeTabs();
            switchTab(0);

            LootChanged += UpdateLootDisplay;

            if (!File.Exists(databaseFile)) {
                ExitWithError("Fatal Error", String.Format("Could not find database file {0}.", databaseFile));
            }

            if (!File.Exists(nodeDatabase)) {
                ExitWithError("Fatal Error", String.Format("Could not find database file {0}.", nodeDatabase));
            }

            conn = new SQLiteConnection(String.Format("Data Source={0};Version=3;", databaseFile));
            conn.Open();

            LootDatabaseManager.Initialize();

            StyleManager.InitializeStyle();

            NotificationForm.Initialize();

            prevent_settings_update = true;
            this.initializePluralMap();
            try {
                this.loadDatabaseData();
            } catch (Exception e) {
                ExitWithError("Fatal Error", String.Format("Corrupted database {0}.\nMessage: {1}", databaseFile, e.Message));
            }
            SettingsManager.LoadSettings(settingsFile);
            MainForm.initializeFonts();
            this.initializeHunts();
            this.initializeSettings();
            this.initializeMaps();
            this.initializeTooltips();
            try {
                Pathfinder.LoadFromDatabase(nodeDatabase);
            } catch (Exception e) {
                ExitWithError("Fatal Error", String.Format("Corrupted database {0}.\nMessage: {1}", nodeDatabase, e.Message));
            }
            prevent_settings_update = false;

            if (SettingsManager.getSettingBool("StartAutohotkeyAutomatically")) {
                startAutoHotkey_Click(null, null);
            }

            fileWriter = new StreamWriter(bigLootFile, true);

            ignoreStamp = createStamp();

            browseTypeBox.SelectedIndex = 0;

            this.Load += MainForm_Load;

            tibialyzerLogo.MouseDown += new System.Windows.Forms.MouseEventHandler(this.draggable_MouseDown);

            BackgroundWorker bw = new BackgroundWorker();
            bw.DoWork += bw_DoWork;
            bw.RunWorkerAsync();

            MaximumNotificationDuration = notificationDurationBox.Maximum;
            scan_tooltip.AutoPopDelay = 60000;
            scan_tooltip.InitialDelay = 500;
            scan_tooltip.ReshowDelay = 0;
            scan_tooltip.ShowAlways = true;
            scan_tooltip.UseFading = true;

            this.loadTimerImage.Image = StyleManager.GetImage("scanningbar-red.gif");
            this.current_state = ScanningState.NoTibia;
            this.loadTimerImage.Enabled = true;
            scan_tooltip.SetToolTip(this.loadTimerImage, "No Tibia Client Found...");
        }
 public ScanningStateEventArgs(ScanningState scanningState)
 {
     _scanningState = scanningState;
 }
예제 #21
0
 private static void StuckScanning(object sender, System.Timers.ElapsedEventArgs e)
 {
     if (currentState != ScanningState.Stuck) {
         currentState = ScanningState.Stuck;
         MainForm.mainForm.Invoke((MethodInvoker)delegate {
             MainForm.mainForm.SetScanningImage("scanningbar-gray.gif", "Waiting, possibly stuck...", false);
         });
     }
 }
예제 #22
0
        public static void StartScanning()
        {
            BackgroundWorker mainScanner = new BackgroundWorker();
            mainScanner.DoWork += ScanMemory;
            mainScanner.RunWorkerAsync();

            BackgroundWorker missingChunkScanner = new BackgroundWorker();
            missingChunkScanner.DoWork += ScanMissingChunks;
            missingChunkScanner.RunWorkerAsync();

            currentState = ScanningState.NoTibia;
        }
 public FolderState(ScanningState state)
 {
     Folder = state.Root;
     State  = state;
 }
예제 #24
0
        public MainForm()
        {
            Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture;
            mainForm = this;
            InitializeComponent();
            makeDraggable(this.Controls);
            this.InitializeTabs();
            switchTab(0);

            if (!File.Exists(databaseFile)) {
                ExitWithError("Fatal Error", String.Format("Could not find database file {0}.", databaseFile));
            }

            if (!File.Exists(nodeDatabase)) {
                ExitWithError("Fatal Error", String.Format("Could not find database file {0}.", nodeDatabase));
            }

            conn = new SQLiteConnection(String.Format("Data Source={0};Version=3;", databaseFile));
            conn.Open();

            lootConn = new SQLiteConnection(String.Format("Data Source={0};Version=3;", lootDatabaseFile));
            lootConn.Open();

            back_image = LoadImage(@"Images\back.png");
            prevpage_image = LoadImage(@"Images\prevpage.png");
            nextpage_image = LoadImage(@"Images\nextpage.png");
            cross_image = LoadImage(@"Images\cross.png");
            tibia_image = LoadImage(@"Images\tibia.png");
            mapup_image = LoadImage(@"Images\mapup.png");
            mapdown_image = LoadImage(@"Images\mapdown.png");
            checkmark_no = LoadImage(@"Images\checkmark-no.png");
            checkmark_yes = LoadImage(@"Images\checkmark-yes.png");
            checkbox_yes = LoadImage(@"Images\checkbox-checked.png");
            checkbox_no = LoadImage(@"Images\checkbox-empty.png");
            infoIcon = LoadImage(@"Images\defaulticon.png");
            tibia_store_image = LoadImage(@"Images\tibiastore.png");
            nomapavailable = LoadImage(@"Images\nomapavailable.png");
            checkbox_yes = LoadImage(@"Images\checkbox-checked.png");
            utilityImages.Add("offline training", LoadImage(@"Images\offlinetraining.png"));
            utilityImages.Add("offline training melee", utilityImages["offline training"]);
            utilityImages.Add("offline training magic", LoadImage(@"Images\offlinetrainingmagic.png"));
            utilityImages.Add("offline training distance", LoadImage(@"Images\offlinetrainingdistance.png"));
            utilityImages.Add("potion", LoadImage(@"Images\potionstore.png"));
            utilityImages.Add("boat", LoadImage(@"Images\boat.png"));
            utilityImages.Add("depot", LoadImage(@"Images\depot.png"));
            utilityImages.Add("bank", LoadImage(@"Images\bank.png"));
            utilityImages.Add("temple", LoadImage(@"Images\temple.png"));
            utilityImages.Add("ore wagon", LoadImage(@"Images\orewagon.png"));
            utilityImages.Add("whirlpool", LoadImage(@"Images\whirlpool.png"));
            utilityImages.Add("post office", LoadImage(@"Images\postoffice.png"));

            item_background = LoadImage(@"Images\item_background.png");
            for (int i = 0; i < 10; i++) {
                image_numbers[i] = LoadImage(@"Images\" + i.ToString() + ".png");
            }

            vocationImages.Add("knight", LoadImage(@"Images\Knight.png"));
            vocationImages.Add("paladin", LoadImage(@"Images\Paladin.png"));
            vocationImages.Add("druid", LoadImage(@"Images\Druid.png"));
            vocationImages.Add("sorcerer", LoadImage(@"Images\Sorcerer.png"));

            NotificationForm.Initialize();
            CreatureStatsForm.InitializeCreatureStats();

            for (int i = 0; i < 5; i++) {
                star_image[i] = LoadImage(@"Images\star" + i + ".png");
                star_image_text[i] = LoadImage(@"Images\star" + i + "_text.png");
            }
            star_image[5] = LoadImage(@"Images\starunknown.png");
            star_image_text[5] = LoadImage(@"Images\starunknown_text.png");

            prevent_settings_update = true;
            this.initializePluralMap();
            try {
                this.loadDatabaseData();
            } catch (Exception e) {
                ExitWithError("Fatal Error", String.Format("Corrupted database {0}.\nMessage: {1}", databaseFile, e.Message));
            }
            SettingsManager.LoadSettings(settingsFile);
            MainForm.initializeFonts();
            this.initializeHunts();
            this.initializeSettings();
            this.initializeMaps();
            this.initializeTooltips();
            try {
                Pathfinder.LoadFromDatabase(nodeDatabase);
            } catch (Exception e) {
                ExitWithError("Fatal Error", String.Format("Corrupted database {0}.\nMessage: {1}", nodeDatabase, e.Message));
            }
            prevent_settings_update = false;

            if (SettingsManager.getSettingBool("StartAutohotkeyAutomatically")) {
                startAutoHotkey_Click(null, null);
            }

            fileWriter = new StreamWriter(bigLootFile, true);

            ignoreStamp = createStamp();

            browseTypeBox.SelectedIndex = 0;

            this.Load += MainForm_Load;

            tibialyzerLogo.MouseDown += new System.Windows.Forms.MouseEventHandler(this.draggable_MouseDown);

            BackgroundWorker bw = new BackgroundWorker();
            bw.DoWork += bw_DoWork;
            bw.RunWorkerAsync();

            MaximumNotificationDuration = notificationDurationBox.Maximum;
            scan_tooltip.AutoPopDelay = 60000;
            scan_tooltip.InitialDelay = 500;
            scan_tooltip.ReshowDelay = 0;
            scan_tooltip.ShowAlways = true;
            scan_tooltip.UseFading = true;

            this.loadingbar = LoadImage(@"Images\scanningbar.gif");
            this.loadingbarred = LoadImage(@"Images\scanningbar-red.gif");
            this.loadingbargray = LoadImage(@"Images\scanningbar-gray.gif");

            this.loadTimerImage.Image = this.loadingbarred;
            this.current_state = ScanningState.NoTibia;
            this.loadTimerImage.Enabled = true;
            scan_tooltip.SetToolTip(this.loadTimerImage, "No Tibia Client Found...");
        }
예제 #25
0
        public override List <Sample3D[]> GetSamples3D(float fidelity)
        {
            List <Sample3D[]> blankedPoints = new List <Sample3D[]>();

            List <Vector3> points        = new List <Vector3>();
            Vector3        point         = new Vector3(FrameOutput.DisplayProfile.AspectRatio * -1f, 1f, 0);
            ScanningState  state         = ScanningState.FirstUpper;
            bool           scanningRight = true;

            while (true)
            {
                points.Add(point);
                switch (state)
                {
                case ScanningState.FirstUpper:
                    state    = ScanningState.SecondUpper;
                    point.X += scanningRight ? StepSize : -1f * StepSize;
                    break;

                case ScanningState.SecondUpper:
                    state    = ScanningState.FirstBottom;
                    point.Y -= StepSize;
                    break;

                case ScanningState.FirstBottom:
                    state    = ScanningState.SecondBottom;
                    point.X += scanningRight ? StepSize : -1f * StepSize;
                    break;

                case ScanningState.SecondBottom:
                    state    = ScanningState.FirstUpper;
                    point.Y += StepSize;
                    break;
                }
                if (point.X > FrameOutput.DisplayProfile.AspectRatio || point.X < FrameOutput.DisplayProfile.AspectRatio * -1f)
                {
                    if (scanningRight)
                    {
                        point.X = FrameOutput.DisplayProfile.AspectRatio;
                    }
                    else
                    {
                        point.X = FrameOutput.DisplayProfile.AspectRatio * -1f;
                    }
                    scanningRight = !scanningRight;
                    points.Add(point);
                    point.Y -= StepSize;
                    points.Add(point);
                    if (state == ScanningState.FirstUpper || state == ScanningState.SecondUpper)
                    {
                        point.Y -= StepSize;
                        points.Add(point);
                    }
                    point.Y -= StepSize;
                }
                if (point.Y < -1f)
                {
                    point.Y = -1f;
                    points.Add(point);
                    break;
                }
            }

            for (int i = 0; i < points.Count() - 1; i++)
            {
                blankedPoints.Add(GetLineSegment(points[i], points[i + 1], fidelity));
            }

            List <Sample3D[]> result;

            if (BlankLineSegments)
            {
                result = blankedPoints;
            }
            else
            {
                result = new List <Sample3D[]>(0);
                int        lineSegmentLength = blankedPoints[0].Length;
                Sample3D[] bigArray          = new Sample3D[blankedPoints.Count() * lineSegmentLength];
                for (int i = 0; i < blankedPoints.Count(); i++)
                {
                    blankedPoints[i].CopyTo(bigArray, i * lineSegmentLength);
                }
                result.Add(bigArray);
            }
            return(result);
        }
예제 #26
0
 void bw_DoWork(object sender, DoWorkEventArgs e)
 {
     while (keep_working) {
         if (circleTimer == null) {
             circleTimer = new System.Timers.Timer(10000);
             circleTimer.Elapsed += circleTimer_Elapsed;
             circleTimer.Enabled = true;
         }
         bool success = false;
         try {
             success = ScanMemory();
         } catch (Exception ex) {
             this.BeginInvoke((MethodInvoker)delegate {
                 DisplayWarning(String.Format("Database Scan Error (Non-Fatal): {0}", ex.Message));
                 Console.WriteLine(ex.Message);
             });
         }
         circleTimer.Dispose();
         circleTimer = null;
         if (success) {
             if (this.current_state != ScanningState.Scanning) {
                 this.current_state = ScanningState.Scanning;
                 this.BeginInvoke((MethodInvoker)delegate {
                     this.loadTimerImage.Image = StyleManager.GetImage("scanningbar.gif");
                     this.loadTimerImage.Enabled = true;
                     scan_tooltip.SetToolTip(this.loadTimerImage, "Scanning Memory...");
                 });
             }
         } else {
             if (this.current_state != ScanningState.NoTibia) {
                 this.current_state = ScanningState.NoTibia;
                 this.BeginInvoke((MethodInvoker)delegate {
                     this.loadTimerImage.Image = StyleManager.GetImage("scanningbar-red.gif");
                     this.loadTimerImage.Enabled = true;
                     scan_tooltip.SetToolTip(this.loadTimerImage, "No Tibia Client Found...");
                 });
             }
         }
     }
 }
예제 #27
0
 private static void ScanMemory(object sender, DoWorkEventArgs e)
 {
     while (true) {
         if (scanTimer == null) {
             scanTimer = new System.Timers.Timer(10000);
             scanTimer.Elapsed += StuckScanning;
             scanTimer.Enabled = true;
         }
         bool success = false;
         try {
             success = ScanMemory();
         } catch (Exception ex) {
             MainForm.mainForm.BeginInvoke((MethodInvoker)delegate {
                 MainForm.mainForm.DisplayWarning(String.Format("Database Scan Error (Non-Fatal): {0}", ex.Message));
                 Console.WriteLine(ex.Message);
             });
         }
         scanTimer.Dispose();
         scanTimer = null;
         if (success) {
             if (currentState != ScanningState.Scanning) {
                 currentState = ScanningState.Scanning;
                 MainForm.mainForm.BeginInvoke((MethodInvoker)delegate {
                     MainForm.mainForm.SetScanningImage("scanningbar.gif", "Scanning Memory...", true);
                 });
             }
         } else {
             if (currentState != ScanningState.NoTibia) {
                 currentState = ScanningState.NoTibia;
                 MainForm.mainForm.BeginInvoke((MethodInvoker)delegate {
                     MainForm.mainForm.SetScanningImage("scanningbar-red.gif", "No Tibia Client Found...", true);
                 });
             }
         }
     }
 }
예제 #28
0
 void circleTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
 {
     if (this.current_state != ScanningState.Stuck) {
         this.current_state = ScanningState.Stuck;
         this.Invoke((MethodInvoker)delegate {
             this.loadTimerImage.Image = StyleManager.GetImage("scanningbar-gray.gif");
             scan_tooltip.SetToolTip(this.loadTimerImage, "Waiting, possibly stuck...");
             this.loadTimerImage.Enabled = false;
         });
     }
 }
 public FolderState(FolderNode folder, ScanningState state)
 {
     State  = state;
     Folder = folder;
 }
예제 #30
0
        private void ReadNative(Queue <FolderState> subdirs, CancellationToken token)
        {
            Win32FindData find        = new Win32FindData();
            FolderState   folderState = subdirs.Dequeue();
            ScanningState state       = folderState.State;
            FolderItem    parent      = folderState.Folder;
            bool          findResult;
            string        parentPath    = parent.FullName;
            string        searchPattern = PathUtils.CombineNoChecks(parentPath, "*");

            if (!searchPattern.StartsWith(@"\\?\"))
            {
                searchPattern = @"\\?\" + searchPattern;
            }
            IntPtr hFind = FindFirstFileEx(searchPattern,
                                           FindExInfoLevels.Basic, out find,
                                           FindExSearchOps.NameMatch, IntPtr.Zero,
                                           FindExFlags.LargeFetch);

            if (hFind == InvalidHandle)
            {
                return;
            }

            FolderItem fileCollection = null;
            FileItem   firstFile      = null;
            bool       subdirsAdded   = false;

            try {
                do
                {
                    string filePath = PathUtils.CombineNoChecks(parentPath, find.cFileName);
                    if (find.IsRelativeDirectory || SkipFile(state, find.cFileName, filePath))
                    {
                        // Skip these types of entries
                        findResult = FindNextFile(hFind, out find);
                        continue;
                    }
                    FileItemBase child;
                    if (find.IsDirectory)
                    {
                        FolderItem folder = new FolderItem(new WindowsScanFileInfo(find, filePath));
                        child = folder;
                        if (!find.IsSymbolicLink)
                        {
                            subdirsAdded = true;
                            subdirs.Enqueue(new FolderState(folder, state));
                        }
                    }
                    else
                    {
                        ExtensionItem extension = Extensions.GetOrAddFromPath(filePath);
                        FileItem      file      = new FileItem(new WindowsScanFileInfo(find, filePath), extension);
                        child = file;
                        if (!find.IsSymbolicLink)
                        {
                            TotalScannedSize += child.Size;
                        }
                    }
                    parent.AddItem(child, ref fileCollection, ref firstFile);

                    if (AsyncChecks(token))
                    {
                        return;
                    }

                    findResult = FindNextFile(hFind, out find);
                } while (findResult);

                if (!subdirsAdded)
                {
                    parent.Finish();
                }
                //if (parent.IsWatched)
                //	parent.RaiseChanged(FileItemAction.ChildrenDone);
            }
            finally {
                FindClose(hFind);
            }
        }
        private void ReadNative(Queue <FolderState> subdirs, CancellationToken token)
        {
            Win32FindData find        = new Win32FindData();
            FolderState   folderState = subdirs.Dequeue();
            ScanningState state       = folderState.State;
            FolderNode    parent      = folderState.Folder;
            bool          findResult;
            string        parentPath    = parent.Path;
            string        searchPattern = PathUtils.CombineNoChecks(parentPath, "*");

            if (!searchPattern.StartsWith(@"\\?\"))
            {
                searchPattern = @"\\?\" + searchPattern;
            }
            IntPtr hFind = FindFirstFileEx(searchPattern,
                                           FindExInfoLevels.Basic, out find,
                                           FindExSearchOps.NameMatch, IntPtr.Zero,
                                           FindExFlags.LargeFetch);

            if (hFind == InvalidHandle)
            {
                return;
            }

            FolderNode   fileCollection = null;
            FileNodeBase singleFile     = null;

            try {
                do
                {
                    string filePath = PathUtils.CombineNoChecks(parentPath, find.cFileName);
                    if (find.IsRelativeDirectory || SkipFile(state, find.cFileName, filePath))
                    {
                        // Skip these types of entries
                        findResult = FindNextFile(hFind, out find);
                        continue;
                    }
                    FileNodeBase child;
                    if (find.IsDirectory)
                    {
                        FolderNode folder = new FolderNode(find);
                        child = folder;
                        if (!find.IsSymbolicLink)
                        {
                            subdirs.Enqueue(new FolderState(folder, state));
                        }
                    }
                    else
                    {
                        FileNode file = new FileNode(find);
                        child = file;
                        if (!find.IsSymbolicLink)
                        {
                            state.ScannedSize += child.Size;
                            totalScannedSize  += child.Size;
                        }
                        file.extRecord = extensions.Include(GetExtension(file.Name), child.Size);
                    }
                    parent.AddChild(child, ref fileCollection, ref singleFile);

                    SuspendCheck();
                    if (token.IsCancellationRequested)
                    {
                        return;
                    }

                    findResult = FindNextFile(hFind, out find);
                } while (findResult);

                //if (parent.IsWatched)
                //	parent.RaiseChanged(FileNodeAction.ChildrenDone);
            }
            finally {
                FindClose(hFind);
            }
        }
예제 #32
0
 void bw_DoWork(object sender, DoWorkEventArgs e) {
     while (keep_working) {
         if (circleTimer == null) {
             circleTimer = new System.Timers.Timer(10000);
             circleTimer.Elapsed += circleTimer_Elapsed;
             circleTimer.Enabled = true;
         }
         bool success = false;
         try {
             success = ScanMemory();
         } catch (Exception ex) {
             if (errorVisible) {
                 errorVisible = false;
                 ExitWithError("Database Scan Error (Non-Fatal)", ex.Message, false);
             }
             Console.WriteLine(ex.Message);
         }
         circleTimer.Dispose();
         circleTimer = null;
         if (success) {
             if (this.current_state != ScanningState.Scanning) {
                 this.current_state = ScanningState.Scanning;
                 this.BeginInvoke((MethodInvoker)delegate {
                     this.loadTimerImage.Image = this.loadingbar;
                     this.loadTimerImage.Enabled = true;
                     scan_tooltip.SetToolTip(this.loadTimerImage, "Scanning Memory...");
                 });
             }
         } else {
             if (this.current_state != ScanningState.NoTibia) {
                 this.current_state = ScanningState.NoTibia;
                 this.BeginInvoke((MethodInvoker)delegate {
                     this.loadTimerImage.Image = this.loadingbarred;
                     this.loadTimerImage.Enabled = true;
                     scan_tooltip.SetToolTip(this.loadTimerImage, "No Tibia Client Found...");
                 });
             }
         }
     }
 }