示例#1
0
 /// <summary>
 /// Caller method for the ScanComplete event.
 /// </summary>
 /// <param name="args"></param>
 protected virtual void OnScanCompleted(Hit[] readings)
 {
     ScanComplete?.Invoke(this, new ScanEventArgs()
     {
         Readings = readings, Timestamp = DateTime.Now.Ticks
     });
 }
示例#2
0
        //if the ping is succsessful then run an nmap scan and display the resutls in the results page
        public string LoadNmapScanInBackground(Action completionCallback)
        {
            if (State.SuccessfulPing)
            {
                var DisplayNmap = new NMapScan();
                NmapScanResults = DisplayNmap.RunScan(State.IPAddress).Result;
                //completionCallback();
                ScanComplete.Invoke(this, null);
                return(ScanResult.ToString());
            }

            else
            {
                return("Ping unsuccessful");
            }
        }
示例#3
0
        /// <summary>
        /// Scan the market
        /// </summary>
        private async void ScanMarket()
        {
            var url        = MarketURL;
            var httpClient = new HttpClient();
            var resp       = await httpClient.GetAsync(url);

            dynamic coinModel;

            if (resp.IsSuccessStatusCode)
            {
                var jsondata = await resp.Content.ReadAsStringAsync();

                coinModel = JsonConvert.DeserializeObject <CoinModel>(jsondata);
                ScanComplete?.Invoke(this, new MarketScannerEventArgs(coinModel));
            }
        }
示例#4
0
        private void ListCameras(IEnumerable <ManufacturersManufacturer> m, ref List <Uri> lp)
        {
            foreach (var s in m)
            {
                var cand = s.url.ToList();
                cand = cand.OrderBy(p => p.Source).ToList();

                foreach (var u in cand)
                {
                    Uri addr;
                    Uri audioUri          = null;
                    int audioSourceTypeID = -1;
                    addr = Conf.GetAddr(u, Uri, Channel, Username, Password);
                    if (!lp.Contains(addr))
                    {
                        lp.Add(addr);
                        URLScan?.Invoke(addr, EventArgs.Empty);

                        bool found = Helper.TestAddress(addr, u, Username, Password);
                        if (found)
                        {
                            if (!string.IsNullOrEmpty(u.AudioSource))
                            {
                                audioUri          = Conf.GetAddr(u, Uri, Channel, Username, Password, true);
                                audioSourceTypeID = Conf.GetSourceType(u.AudioSource, 1);
                            }
                            ManufacturersManufacturerUrl u1 = u;

                            URLFound?.Invoke(this,
                                             new ConnectionOptionEventArgs(new ConnectionOption(addr, audioUri,
                                                                                                Conf.GetSourceType(u1.Source, 2), audioSourceTypeID, u1)));
                        }
                    }
                    if (Quiturlscanner)
                    {
                        ScanComplete?.Invoke(this, EventArgs.Empty);
                        return;
                    }
                }
            }
            ScanComplete?.Invoke(this, EventArgs.Empty);
        }
示例#5
0
        private void ListCameras(IEnumerable <ManufacturersManufacturer> mm, string model)
        {
            model = (model ?? "").ToLowerInvariant();
            //find http port
            _discoverer = new URLDiscovery(Uri);

            foreach (var m in mm)
            {
                //scan selected model first
                var cand = m.url.Where(p => p.version.ToLowerInvariant() == model).ToList();
                Scan(cand);
                cand = m.url.Where(p => p.version.ToLowerInvariant() != model).ToList();
                Scan(cand);
                if (_quit)
                {
                    break;
                }
            }

            ScanComplete?.Invoke(this, EventArgs.Empty);
            Finished.Set();
        }
示例#6
0
        public void Scan(bool syncAfterScan = false)
        {
            Files.Clear();

            foreach (var dir in Dirs)
            {
                if (!IO.Directory.Exists(dir))
                {
                    continue;
                }

                foreach (var path in IO.Directory.EnumerateFiles(dir))
                {
                    AddFile(path);
                }
            }

            ScanComplete?.Invoke(this);

            if (syncAfterScan)
            {
                SyncFiles();
            }
        }
示例#7
0
        public MainWindow()
        {
            InitializeComponent();


            bool isFirst;

            mtx = new System.Threading.Mutex
                      (true, "zjdd ", out isFirst);

            #region Background color
            this.Background              = new SolidColorBrush(Color.FromRgb(188, 99, 163));
            this.mainPanel.Background    = this.Background;
            this.fileListView.Background = new SolidColorBrush(Color.FromRgb(213, 133, 191));
            this.about.Background        = new SolidColorBrush(Color.FromRgb(213, 133, 191));
            this.lrcBox.Background       = new SolidColorBrush(Color.FromRgb(213, 133, 191));
            this.lrcList.Background      = new SolidColorBrush(Color.FromRgb(213, 133, 191));
            this.directoryTreeView.TreeViewBackground = new SolidColorBrush(Color.FromRgb(213, 133, 191));
            #endregion

            #region Initialize directory treeview contexmenu
            dirViewContextMenu = new ContextMenu();
            MenuItem menu = new MenuItem();
            menu.Header = "Add This Folder";
            menu.Click += new RoutedEventHandler(menu_Click);
            dirViewContextMenu.Items.Add(menu);
            MenuItem open = new MenuItem();
            open.Header = "Open Folder in Windows Explorer";
            open.Click += new RoutedEventHandler(open_Click);
            dirViewContextMenu.Items.Add(open);
            MenuItem properties = new MenuItem();
            properties.Header = "Properties";
            properties.Click += new RoutedEventHandler(properties_Click);
            dirViewContextMenu.Items.Add(properties);
            this.directoryTreeView.TreeViewContextMenu = dirViewContextMenu;
            #endregion

            #region Initialize mainwindow icon
            defaultPath = Settings.Settings.Default.lrcDirectory;//
            if ("" == defaultPath.Trim())
            {
                defaultPath = System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "ZDLRC\\";
                Settings.Settings.Default.lrcDirectory = defaultPath;
            }
            MemoryStream stream = new MemoryStream();
            Properties.Resources.lrc.Save(stream, System.Drawing.Imaging.ImageFormat.Png);
            ImageSourceConverter imageSourceConverter = new ImageSourceConverter();
            this.Icon = (ImageSource)imageSourceConverter.ConvertFrom(stream);



            Image image = new Image();
            image.Source = ImageHelper.ToBitmapSource(Properties.Resources.lrc);
            image.Height = image.Width = 64;


            #endregion

            #region delegate and thread
            fileList                             = new List <MusicFile>();
            lrcDownload                          = new LRCDownload();
            updateStatus                         = new UpdateStatus(UpdateSearchStatus);
            addLrcSelect                         = new AddLrcSelect(AddSearchLrc);
            addLrc                               = new AddLrc(AddDownloadLRC);
            failedList                           = new List <MusicFile>();
            searchLrcByZLP                       = new SearchLrcByZPL(SearchFromZLP);
            listViewFileList                     = new List <MusicFile>();
            fileList                             = new List <MusicFile>();
            lrcDownload                          = new LRCDownload();
            selectLRCBase                        = new LRCBase();
            scanComplete                         = new ScanComplete(ScanFinish);
            addFileToListView                    = new AddFileToListView(UpdateScanResult);
            backgroundWorker                     = new BackgroundWorker();
            backgroundWorker.DoWork             += new DoWorkEventHandler(backgroundWorker_DoWork);
            backgroundWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(backgroundWorker_RunWorkerCompleted);
            #endregion

            #region Initialize aboutBox and load settings
            autoSelect.IsChecked = Settings.Settings.Default.autoSave;

            about.AppendText("LRC Download 1.0.0.1\n\n");
            about.AppendText("This is a free soft made by ZJ.\n");
            about.AppendText("If you have questions,please send me email:[email protected].\n");
            about.AppendText("Copyright© 2010-2012 of ZJSoft\n");
            new InlineUIContainer(image, about.Document.ContentEnd);
            #endregion

            #region Initialize lrcBox contexmenu
            InitLrcBoxContextMenu();
            #endregion

            #region Initialize fileListViewContextmenu
            fileListViewContextMenu = new ContextMenu();
            MenuItem clear = new MenuItem();
            clear.Header = "Remove All Files";
            clear.Click += new RoutedEventHandler(clear_Click);
            fileListViewContextMenu.Items.Add(clear);
            fileListViewContextMenu.Opened += new RoutedEventHandler(fileListViewContextMenu_Opened);
            fileListView.ContextMenu        = fileListViewContextMenu;
            #endregion

            ps    = new PipeServer(this);
            psSer = new Thread(new ThreadStart(ps.StartPipeServer));
            psSer.Start();
            //MessageBox.Show(App.args);
            if (!String.IsNullOrEmpty(App.args))
            {
                string[] pas = App.args.Split('|');
                if (pas.Length >= 3)
                {
                    if (pas[0].Trim() == "0xFFFF")
                    {
                        pas[0] = "";
                    }
                    if (pas[1].Trim() == "0xFFFF")
                    {
                        pas[1] = "";
                    }

                    SearchFromZLP(pas[0], pas[1], pas[2]);
                }
            }
        }
 protected virtual void OnScanComplete()
 {
     ScanComplete?.Invoke(this, EventArgs.Empty);
 }
示例#9
0
 public abstract void StartScan(ProgressUpdate callback, ScanComplete complete, CancelComplete cancelComplete,
     bool fixAfterScan);
示例#10
0
 /// <summary>
 /// Starts scanning
 /// </summary>
 /// <param name="callback"><see cref="ProgressUpdate"/> callback</param>
 /// <param name="complete"><see cref="ScanComplete"/> callback</param>
 /// <param name="cancelComplete"><see cref="CancelComplete"/> callback</param>
 /// <param name="fixAfterScan">A bool flag that determines is the fixing needed after finishing the scan</param>
 public override void StartScan(ProgressUpdate callback, ScanComplete complete, CancelComplete cancelComplete, bool fixAfterScan)
 {
     Thread.CurrentThread.CurrentUICulture = new CultureInfo(CfgFile.Get("Lang"));
     if (SelectedRegistryCategoriesCount() > 0)
     {
         this.callback = callback;
         this.complete = complete;
         this.cancelComplete = cancelComplete;
         this.fixAfterScan = fixAfterScan;
         Reset();
         ABORT = false;
         ScanStart();
     }
     else
     {
         MessageBox.Show(Resources.SelectAtLeastOneItem,
                         Resources.InvalidSelection,
                         MessageBoxButton.OK, MessageBoxImage.Exclamation);
     }
 }
示例#11
0
        private void ListCameras(IEnumerable <ManufacturersManufacturer> mm, string model)
        {
            model = (model ?? "").ToLowerInvariant();
            //find http port
            _discoverer = new URLDiscovery(Uri);

            //check for onvif support first
            int i = 0;

            try
            {
                var httpUri = _discoverer.BaseUri.SetPort(_discoverer.HttpPort);

                //check for this devices
                foreach (var d in Discovery.DiscoveredDevices)
                {
                    if (d.DnsSafeHost == Uri.DnsSafeHost)
                    {
                        httpUri = _discoverer.BaseUri.SetPort(d.Port);
                        break;
                    }
                }

                var onvifurl = httpUri + "onvif/device_service";
                var dev      = new ONVIFDevice(onvifurl, Username, Password);
                if (dev.Profiles != null)
                {
                    foreach (var p in dev.Profiles)
                    {
                        var b = p?.VideoEncoderConfiguration?.Resolution;
                        if (b != null && b.Width > 0)
                        {
                            dev.SelectProfile(i);
                            var co = new ConnectionOption(onvifurl, null, 9, -1, null)
                            {
                                MediaIndex = i
                            };
                            URLFound?.Invoke(this,
                                             new ConnectionOptionEventArgs(co));
                        }
                        i++;
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.LogException(ex);
            }

            foreach (var m in mm)
            {
                //scan selected model first
                var cand = m.url.Where(p => p.version.ToLowerInvariant() == model).ToList();
                Scan(cand);
                cand = m.url.Where(p => p.version.ToLowerInvariant() != model).ToList();
                Scan(cand);
                if (_quit)
                {
                    break;
                }
            }

            ScanComplete?.Invoke(this, EventArgs.Empty);
            Finished.Set();
        }
示例#12
0
        private void ListCameras(IEnumerable <ManufacturersManufacturer> m, ref List <Uri> lp)
        {
            foreach (var s in m)
            {
                var cand = s.url.ToList();
                cand = cand.OrderBy(p => p.Source).ToList();

                foreach (var u in cand)
                {
                    Uri addr;
                    Uri audioUri          = null;
                    int audioSourceTypeID = -1;
                    switch (u.prefix.ToUpper())
                    {
                    default:
                        addr = Conf.GetAddr(u, Uri, Channel, Username, Password);
                        if (!lp.Contains(addr))
                        {
                            lp.Add(addr);
                            URLScan?.Invoke(addr, EventArgs.Empty);
                            if (Helper.TestHttpurl(addr.ToString(), u.cookies, Username, Password))
                            {
                                if (!string.IsNullOrEmpty(u.AudioSource))
                                {
                                    audioUri          = Conf.GetAddr(u, Uri, Channel, Username, Password, true);
                                    audioSourceTypeID = Conf.GetSourceType(u.AudioSource, 1);
                                }

                                ManufacturersManufacturerUrl u1 = u;
                                URLFound?.Invoke(this,
                                                 new ConnectionOptionEventArgs(new ConnectionOption(addr, audioUri, Conf.GetSourceType(u1.Source, 2), audioSourceTypeID, u1)));
                            }
                        }

                        break;

                    case "RTSP://":
                        addr = Conf.GetAddr(u, Uri, Channel, Username, Password);
                        if (!lp.Contains(addr))
                        {
                            lp.Add(addr);
                            URLScan?.Invoke(addr, EventArgs.Empty);
                            if (Helper.TestRtspurl(addr, Username, Password))
                            {
                                if (!string.IsNullOrEmpty(u.AudioSource))
                                {
                                    audioUri          = Conf.GetAddr(u, Uri, Channel, Username, Password, true);
                                    audioSourceTypeID = Conf.GetSourceType(u.AudioSource, 1);
                                }
                                ManufacturersManufacturerUrl u1 = u;

                                URLFound?.Invoke(this,
                                                 new ConnectionOptionEventArgs(new ConnectionOption(addr, audioUri,
                                                                                                    Conf.GetSourceType(u1.Source, 2), audioSourceTypeID, u1)));
                            }
                        }
                        break;
                    }
                    if (Quiturlscanner)
                    {
                        break;
                    }
                }
                if (Quiturlscanner)
                {
                    break;
                }
            }
            ScanComplete?.Invoke(this, EventArgs.Empty);
        }
示例#13
0
 /// <summary>
 /// start scanning
 /// </summary>
 /// <param name="callback"></param>
 /// <param name="complete"></param>
 /// <param name="cancelComplete"></param>
 /// <param name="fixAfterScan"></param>
 public override void StartScan(ProgressUpdate callback, ScanComplete complete, CancelComplete cancelComplete,
     bool fixAfterScan)
 {
     FrmTrackSel.Callback = callback;
     FrmTrackSel.Complete = complete;
     FrmTrackSel.CancelComplete = cancelComplete;
     FrmTrackSel.ScanFiles(fixAfterScan);
 }
示例#14
0
        /// <summary>
        /// start scanning
        /// </summary>
        /// <param name="callback"></param>
        /// <param name="complete"></param>
        /// <param name="cancelComplete"></param>
        /// <param name="fixAfterScan"></param>
        public override void StartScan(ProgressUpdate callback, ScanComplete complete, CancelComplete cancelComplete,
            bool fixAfterScan)
        {
            ABORT = false;

            try
            {
                TmpFiles = new List<FileInfo>();
                WinFiles = new List<FileInfo>();
                IEFiles = new List<FileInfo>();
                FFFiles = new List<FileInfo>();
                ChromeFiles = new List<FileInfo>();

                TmpSize = 0;
                WinSize = 0;
                IESize = 0;
                FFSize = 0;
                ChromeSize = 0;

                this.callback = callback;
                this.complete = complete;
                this.cancelComplete = cancelComplete;
                this.fixAfterScan = fixAfterScan;

                string winTempPath = Environment.GetEnvironmentVariable("Temp");
                string IETempPath = Environment.GetFolderPath(Environment.SpecialFolder.InternetCache);
                string ffCachePath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) +
                                     "\\Mozilla\\Firefox\\Profiles";
                string chromeCachePath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) +
                                         "\\Google\\Chrome\\User Data\\Default";

                DirectoryInfo windowsTemp = Directory.Exists(winTempPath) ? new DirectoryInfo(winTempPath) : null;
                DirectoryInfo IETemp = Directory.Exists(IETempPath) ? new DirectoryInfo(IETempPath) : null;
                DirectoryInfo ffCahce = Directory.Exists(ffCachePath) ? new DirectoryInfo(ffCachePath) : null;
                DirectoryInfo chromeCache = Directory.Exists(chromeCachePath) ? new DirectoryInfo(chromeCachePath) : null;

                int WinFilesCount = windowsTemp != null ? windowsTemp.GetDirectories().Length + windowsTemp.GetFiles().Length : 0;
                int IETempCount = IETemp != null ? IETemp.GetDirectories().Length + IETemp.GetFiles().Length : 0;
                int ffCahceCount = ffCahce != null ? ffCahce.GetDirectories().Length + ffCahce.GetFiles().Length : 0;
                int chromeCacheCount = chromeCache != null ? chromeCache.GetDirectories().Length + chromeCache.GetFiles().Length : 0;

                int filesCount = WinFilesCount + IETempCount + ffCahceCount + chromeCacheCount;

                List<DriveInfo> drives = null;
                try
                {
                    drives = DriveInfo.GetDrives().Where(drive => drive.IsReady && (drive.DriveType == DriveType.Fixed || drive.DriveType == DriveType.Removable)).ToList();
                }
                catch (IOException)
                {
                }
                catch (UnauthorizedAccessException)
                {
                }

                if (drives != null)
                {
                    filesCount += drives.Count;
                    scannedFilesCount = 0;

                    foreach (DriveInfo drive in drives)
                    {
                        if (ABORT)
                        {
                            cancelComplete();
                            return;
                        }
                        try
                        {
                            FileInfo[] tmpFiles = drive.RootDirectory.GetFiles("*.tmp");
                            TmpFiles.AddRange(tmpFiles);
                        }
                        catch
                        {
                        }
                        scannedFilesCount++;
                        callback((int)((scannedFilesCount / (float)filesCount) * 100), drive.RootDirectory.FullName);
                    }
                }

                if (windowsTemp != null)
                {
                    if (ABORT)
                    {
                        cancelComplete();
                        return;
                    }

                    CollectFiles(windowsTemp, "win");

                    int firstLevelSubDirectoriesCount = windowsTemp.GetDirectories().Count() + 1;

                    if (firstLevelSubDirectoriesCount < WinFilesCount)
                    {
                        int filesPerSubDirectory = WinFilesCount / firstLevelSubDirectoriesCount;
                        int filesPerSubDirectoryMod = WinFilesCount % firstLevelSubDirectoriesCount;

                        for (int i = 0; i < firstLevelSubDirectoriesCount - 1; i++)
                        {
                            scannedFilesCount += filesPerSubDirectory;
                            callback((int)((scannedFilesCount / (float)filesCount) * 100), windowsTemp.FullName);
                            Thread.Sleep(20);
                        }
                        scannedFilesCount += filesPerSubDirectory + filesPerSubDirectoryMod;
                        callback((int)((scannedFilesCount / (float)filesCount) * 100), windowsTemp.FullName);
                    }
                    else
                    {
                        scannedFilesCount += WinFilesCount;
                        callback((int)((scannedFilesCount / (float)filesCount) * 100), windowsTemp.FullName);
                    }
                }

                if (IETemp != null)
                {
                    if (ABORT)
                    {
                        cancelComplete();
                        return;
                    }

                    CollectFiles(IETemp, "ie");
                    scannedFilesCount += IETempCount;
                    callback((int)((scannedFilesCount / (float)filesCount) * 100), windowsTemp.FullName);
                }

                if (ffCahce != null)
                {
                    if (ABORT)
                    {
                        cancelComplete();
                        return;
                    }

                    CollectFiles(ffCahce, "ff");
                    scannedFilesCount += ffCahceCount;
                    callback((int)((scannedFilesCount / (float)filesCount) * 100), windowsTemp.FullName);
                }

                if (chromeCache != null)
                {
                    if (ABORT)
                    {
                        cancelComplete();
                        return;
                    }

                    CollectFiles(chromeCache, "chrome");
                    scannedFilesCount += chromeCacheCount;
                    callback((int)((scannedFilesCount / (float)filesCount) * 100), windowsTemp.FullName);
                }
            }
            catch (Exception)
            {
                // ToDo: send exception details via SmartAssembly bug reporting!
            }

            complete(fixAfterScan);
        }
示例#15
0
        /// <summary>
        /// Starts the scanning process
        /// </summary>
        /// <param name="callback">The callback method to update progress</param>
        public override void StartScan(ProgressUpdate callback, ScanComplete complete, CancelComplete cancelComplete,
            bool fixAfterScan)
        {
            this.callback = callback;
            this.complete = complete;
            this.cancelComplete = cancelComplete;
            this.fixAfterScan = fixAfterScan;

            isCancel = false;
            scanBackgroundWorker = new BackgroundWorker();
            scanBackgroundWorker.WorkerSupportsCancellation = true;
            scanBackgroundWorker.WorkerReportsProgress = true;
            scanBackgroundWorker.DoWork += ScanBackgroundWorkerDoWork;
            scanBackgroundWorker.RunWorkerCompleted += scanBackgroundWorker_RunWorkerCompleted;
            scanBackgroundWorker.ProgressChanged += scanBackgroundWorker_ProgressChanged;

            scanBackgroundWorker.RunWorkerAsync();
        }
示例#16
0
        /// <summary>
        /// start scanning
        /// </summary>
        /// <param name="callback"></param>
        /// <param name="complete"></param>
        /// <param name="cancelComplete"></param>
        /// <param name="fixAfterScan"></param>
        public override void StartScan(ProgressUpdate callback, ScanComplete complete, CancelComplete cancelComplete,
            bool fixAfterScan)
        {
            ABORT = false;

            try
            {
                this.callback = callback;
                this.complete = complete;
                this.cancelComplete = cancelComplete;
                this.fixAfterScan = fixAfterScan;

                List<ListViewItem> problems = new List<ListViewItem>();
                FrmSrtUpMan.FillListview();

                for (int i = 0; i < AppsToDelete.Count; i++)
                {
                    if (ABORT)
                    {
                        cancelComplete();
                        return;
                    }

                    callback((int)(i + 1 / (double)AppsToDelete.Count * 100), AppsToDelete[i]);

                    problems = FrmSrtUpMan.RemoveAppsFromReg(AppsToDelete[i]);
                    ProblemsCount = problems.Count;

                    LstVwItemLst = problems;
                    LstProblems = ConvertLists(problems);
                }
                FrmDetails = new FrmDetails(problems);
            }
            catch (Exception)
            {
                // ToDo: send exception details via SmartAssembly bug reporting!
            }
            complete(fixAfterScan);
        }
示例#17
0
 protected virtual void OnScanComplete()
 {
     ScanComplete?.Invoke(null, null);
 }
示例#18
0
 private void RaiseScanCompleteEvent(List <ScanHost> hosts)
 {
     ScanComplete?.Invoke(hosts);
 }
示例#19
0
        /// <summary>
        /// start scanning
        /// </summary>
        /// <param name="callback"></param>
        /// <param name="complete"></param>
        /// <param name="cancelComplete"></param>
        /// <param name="fixAfterScan"></param>
        public override void StartScan(ProgressUpdate callback, ScanComplete complete, CancelComplete cancelComplete, bool fixAfterScan)
        {
            ABORT = false;

            BrokenShortcuts.Clear();

            this.callback = callback;
            this.complete = complete;
            this.cancelComplete = cancelComplete;
            this.fixAfterScan = fixAfterScan;

            string root = Path.GetPathRoot(Environment.SystemDirectory);
            string user = Environment.UserName;

            HashSet<string> places = new HashSet<string>();

            if (OSIsXP())
            {
                places.Add(root + @"Documents and Settings\All Users\Desktop");
                places.Add(root + @"Documents and Settings\All Users\Start Menu");
                places.Add(root + @"Documents and Settings\Default User\Desktop");
                places.Add(root + @"Documents and Settings\Default User\Start Menu");
                places.Add(root + @"Documents and Settings\" + user + @"\Desktop");
                places.Add(root + @"Documents and Settings\" + user + @"\Start Menu");
            }
            places.Add(root + @"ProgramData\Desktop");
            places.Add(root + @"ProgramData\Microsoft\Windows\Start Menu");
            places.Add(root + @"ProgramData\Start Menu");
            places.Add(root + @"Users\Default\AppData\Roaming\Microsoft\Windows\Start Menu");
            places.Add(root + @"Users\Default\Desktop");
            places.Add(root + @"Users\Default\Start Menu");
            places.Add(root + @"Users\Public\Desktop");
            places.Add(root + @"Users\" + user + @"\AppData\Roaming\Microsoft\Windows\Start Menu");
            places.Add(root + @"Users\" + user + @"\Desktop");
            places.Add(root + @"Users\" + user + @"\Start Menu");
            places.Add(GetSpecialFolderPath(CSIDL_COMMON_DESKTOPDIRECTORY));
            places.Add(GetSpecialFolderPath(CSIDL_COMMON_STARTMENU));
            places.Add(GetSpecialFolderPath(CSIDL_DESKTOP));
            places.Add(GetSpecialFolderPath(CSIDL_DESKTOPDIRECTORY));
            places.Add(GetSpecialFolderPath(CSIDL_STARTMENU));

            List<FileInfo> shortcutList = new List<FileInfo>();
            foreach (string s in places)
            {
                try
                {
                    DirectoryInfo dir = new DirectoryInfo(s);
                    FileAttributes att = dir.Attributes;
                    if ((att & FileAttributes.ReparsePoint) != FileAttributes.ReparsePoint)
                    {
                        shortcutList.AddRange(dir.GetFiles("*.lnk", SearchOption.AllDirectories));
                    }
                }
                catch { }
            }

            int shortcutsFound = shortcutList.Count;

            int shortcutsProcessed = 0;

            foreach (FileInfo shortcut in shortcutList)
            {
                if (ABORT)
                {
                    cancelComplete();
                    return;
                }

                try
                {
                    WshShellClass wshShellClass = new WshShellClass();
                    IWshShortcut shortcutInfo = (IWshShortcut)wshShellClass.CreateShortcut(shortcut.FullName);
                    string linkTarget = shortcutInfo.TargetPath;
                    string linkfile = linkTarget;
                    if (linkTarget.Contains("\\"))
                    {
                        linkfile = linkTarget.Substring(linkTarget.LastIndexOf("\\"));
                    }
                    if (string.IsNullOrEmpty(linkTarget))
                    {
                        continue;
                    }
                    var drive = new DriveInfo(linkTarget.Substring(0, 1));
                    if (drive.DriveType == DriveType.CDRom)
                    {
                        continue;
                    }
                    if (shortcutInfo.TargetPath.Contains("Program Files"))
                    {
                        IWshShortcut shortcutInfox86 = (IWshShortcut)wshShellClass.CreateShortcut(shortcut.FullName);
                        shortcutInfox86.TargetPath = shortcutInfox86.TargetPath.Replace(" (x86)", string.Empty);

                        if (!File.Exists(shortcutInfo.TargetPath) && !Directory.Exists(shortcutInfo.TargetPath)
                            && !File.Exists(shortcutInfox86.TargetPath.Replace(" (x86)", string.Empty)) && !Directory.Exists(shortcutInfox86.TargetPath.Replace(" (x86)", string.Empty)))
                        {
                            Shortcut brokenShortcut = new Shortcut
                                                    {
                                                        Name = shortcut.Name,
                                                        Target = shortcutInfox86.TargetPath,
                                                        Location = shortcut.DirectoryName,
                                                        Description = shortcutInfox86.Description
                                                    };

                            BrokenShortcuts.Add(brokenShortcut);
                            ProblemsCount++;
                        }
                    }
                    else
                    {
                        if (!string.IsNullOrEmpty(shortcutInfo.TargetPath) && !File.Exists(shortcutInfo.TargetPath) && !Directory.Exists(shortcutInfo.TargetPath)
                            && !File.Exists(Environment.ExpandEnvironmentVariables(@"%systemroot%\Sysnative") + "\\" + linkfile)
                            && !File.Exists(Environment.SystemDirectory + "\\" + linkfile)
                            && !File.Exists(Environment.GetFolderPath(Environment.SpecialFolder.System) + "\\" + linkfile))
                        {
                            var brokenShortcut = new Shortcut
                                                    {
                                                        Name = shortcut.Name,
                                                        Target = shortcutInfo.TargetPath,
                                                        Location = shortcut.DirectoryName,
                                                        Description = shortcutInfo.Description
                                                    };

                            BrokenShortcuts.Add(brokenShortcut);
                            ProblemsCount++;
                        }
                    }
                }
                catch (Exception)
                {
                    // ToDo: send exception details via SmartAssembly bug reporting!
                }

                shortcutsProcessed++;
                callback((int)((double)shortcutsProcessed / shortcutsFound * 100), shortcut.FullName);
            }
            complete(fixAfterScan);
        }
示例#20
0
 private void OnScanner_ScanComplete(object sender, EventArgs e)
 {
     ScanComplete?.Invoke(this, e);
 }
示例#21
0
        public MainWindow()
        {
            InitializeComponent();

            bool isFirst;
            mtx  = new System.Threading.Mutex
                                                               (true, "zjdd ", out   isFirst);

            #region Background color
            this.Background = new SolidColorBrush(Color.FromRgb(188, 99, 163));
            this.mainPanel.Background = this.Background;
            this.fileListView.Background = new SolidColorBrush(Color.FromRgb(213, 133, 191));
            this.about.Background = new SolidColorBrush(Color.FromRgb(213, 133, 191));
            this.lrcBox.Background = new SolidColorBrush(Color.FromRgb(213, 133, 191));
            this.lrcList.Background = new SolidColorBrush(Color.FromRgb(213, 133, 191));
            this.directoryTreeView.TreeViewBackground = new SolidColorBrush(Color.FromRgb(213, 133, 191));
            #endregion

            #region Initialize directory treeview contexmenu
            dirViewContextMenu = new ContextMenu();
            MenuItem menu = new MenuItem();
            menu.Header = "Add This Folder";
            menu.Click += new RoutedEventHandler(menu_Click);
            dirViewContextMenu.Items.Add(menu);
            MenuItem open = new MenuItem();
            open.Header = "Open Folder in Windows Explorer";
            open.Click += new RoutedEventHandler(open_Click);
            dirViewContextMenu.Items.Add(open);
            MenuItem properties = new MenuItem();
            properties.Header = "Properties";
            properties.Click += new RoutedEventHandler(properties_Click);
            dirViewContextMenu.Items.Add(properties);
            this.directoryTreeView.TreeViewContextMenu = dirViewContextMenu;
            #endregion

            #region Initialize mainwindow icon
            defaultPath = Settings.Settings.Default.lrcDirectory;//
            if ("" == defaultPath.Trim())
            {
                defaultPath = System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "ZDLRC\\";
                Settings.Settings.Default.lrcDirectory = defaultPath;
            }
            MemoryStream stream = new MemoryStream();
            Properties.Resources.lrc.Save(stream, System.Drawing.Imaging.ImageFormat.Png);
            ImageSourceConverter imageSourceConverter = new ImageSourceConverter();
            this.Icon = (ImageSource)imageSourceConverter.ConvertFrom(stream);

            Image image = new Image();
            image.Source = ImageHelper.ToBitmapSource(Properties.Resources.lrc);
            image.Height = image.Width = 64;

            #endregion

            #region delegate and thread
            fileList = new List<MusicFile>();
            lrcDownload = new LRCDownload();
            updateStatus = new UpdateStatus(UpdateSearchStatus);
            addLrcSelect = new AddLrcSelect(AddSearchLrc);
            addLrc = new AddLrc(AddDownloadLRC);
            failedList = new List<MusicFile>();
            searchLrcByZLP = new SearchLrcByZPL(SearchFromZLP);
            listViewFileList = new List<MusicFile>();
            fileList = new List<MusicFile>();
            lrcDownload = new LRCDownload();
            selectLRCBase = new LRCBase();
            scanComplete = new ScanComplete(ScanFinish);
            addFileToListView = new AddFileToListView(UpdateScanResult);
            backgroundWorker = new BackgroundWorker();
            backgroundWorker.DoWork += new DoWorkEventHandler(backgroundWorker_DoWork);
            backgroundWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(backgroundWorker_RunWorkerCompleted);
            #endregion

            #region Initialize aboutBox and load settings
            autoSelect.IsChecked = Settings.Settings.Default.autoSave;

            about.AppendText("LRC Download 1.0.0.1\n\n");
            about.AppendText("This is a free soft made by ZJ.\n");
            about.AppendText("If you have questions,please send me email:[email protected].\n");
            about.AppendText("Copyright© 2010-2012 of ZJSoft\n");
            new InlineUIContainer(image, about.Document.ContentEnd);
            #endregion

            #region Initialize lrcBox contexmenu
            InitLrcBoxContextMenu();
            #endregion

            #region Initialize fileListViewContextmenu
            fileListViewContextMenu = new ContextMenu();
            MenuItem clear = new MenuItem();
            clear.Header="Remove All Files";
            clear.Click += new RoutedEventHandler(clear_Click);
            fileListViewContextMenu.Items.Add(clear);
            fileListViewContextMenu.Opened += new RoutedEventHandler(fileListViewContextMenu_Opened);
            fileListView.ContextMenu = fileListViewContextMenu;
            #endregion

            ps = new PipeServer(this);
            psSer = new Thread(new ThreadStart(ps.StartPipeServer));
            psSer.Start();
            //MessageBox.Show(App.args);
            if (!String.IsNullOrEmpty(App.args))
            {
                string[] pas = App.args.Split('|');
                if (pas.Length >= 3)
                {
                    if (pas[0].Trim() == "0xFFFF")
                        pas[0] = "";
                    if (pas[1].Trim() == "0xFFFF")
                        pas[1] = "";

                    SearchFromZLP(pas[0], pas[1], pas[2]);
                }
            }
        }