private void FileSystemWatcherOnCreated(object sender, FileSystemEventArgs fileSystemEventArgs)
        {
            Dispatcher.Invoke(new Action(delegate
            {
                lblItemName.Content = "Fetching...";
                lblItemName.ToolTip = string.Empty;

                if (cbAutoCopy.IsChecked != null && (bool)cbAutoCopy.IsChecked)
                {
                    var img = new BitmapImage();
                    img.BeginInit();
                    img.UriSource = new Uri("pack://application:,,,/Elinor;component/Images/38_16_195.png");
                    img.EndInit();
                    imgCopyStatus.Source = img;
                }
            }));

            _lastEvent = fileSystemEventArgs;
            while (MiscTools.IsFileLocked(new FileInfo(fileSystemEventArgs.FullPath)))
            {
                Thread.Sleep(25);
            }
            if (fileSystemEventArgs.ChangeType == WatcherChangeTypes.Created &&
                fileSystemEventArgs.Name.EndsWith(".txt"))
            {
                ProcessData(fileSystemEventArgs.FullPath);
            }

            Dispatcher.Invoke(new Action(delegate
            {
                if (cbAutoCopy.IsChecked != null && (bool)cbAutoCopy.IsChecked)
                {
                    bool isSell = rbSell.IsChecked != null && (bool)rbSell.IsChecked;

                    if (rbSell.IsChecked != null && (bool)rbSell.IsChecked)
                    {
                        ClipboardTools.SetClipboardWrapper(
                            ClipboardTools.GetSellPrice(_sell, profile));
                    }
                    else if (rbBuy.IsChecked != null && (bool)rbBuy.IsChecked)
                    {
                        ClipboardTools.SetClipboardWrapper(
                            ClipboardTools.GetBuyPrice(_buy, profile));
                    }


                    var img = new BitmapImage();
                    img.BeginInit();
                    img.UriSource = (isSell && _sell > 0) || (!isSell && _buy > 0)
                            ? new Uri("pack://application:,,,/Elinor;component/Images/38_16_193.png")
                            : new Uri("pack://application:,,,/Elinor;component/Images/38_16_194.png");
                    img.EndInit();
                    imgCopyStatus.Source = img;
                }
            }));

            UpdateStatus();
        }
Example #2
0
 internal static void ClearMarketLogs(DirectoryInfo logdir)
 {
     foreach (FileInfo fi in logdir.GetFiles())
     {
         if (!MiscTools.IsFileLocked(fi))
         {
             fi.Delete();
         }
     }
 }