Beispiel #1
0
        public override bool Equals(object obj)
        {
            if (this == obj)
            {
                return(true);
            }
            else if (obj == null || GetType() != obj.GetType())
            {
                return(false);
            }
            else
            {
                var m = (ModuleElement)obj;

                return(FilesList.SequenceEqual(m.FilesList) && ClassCoverages.SequenceEqual(m.ClassCoverages));
            }
        }
        private void DoImageSearch(object sender, RoutedEventArgs e)
        {
            var finder = new FileFinder();

            finder.FindFiles("c:\\", "jpg");
            foreach (var f in finder.FoundFilesDictionary)
            {
                FilesList.AppendText(f.Key);

                /*
                 * create a hyperlink to the directories where pictures are.
                 * rank them by size of pics... a directory with large pics (over 1MB or so)
                 * would be ranked higher than one with smaller images, as this would probably be
                 * non-user generated content. when the user clicks on a directory link, the page will
                 * show the file name and metadata like exif, plus a thumb.
                 */
            }
        }
Beispiel #3
0
        /// <summary>
        /// look for xstr in each file
        /// </summary>
        private void FetchXstr()
        {
            List <string> compatibleFiles = FilesList.Where(x => !x.Contains("-lcl.tbm") && !x.Contains("-tlc.tbm") && !x.Contains("strings.tbl")).ToList();

            foreach (string file in compatibleFiles)
            {
                FileInfo fileInfo    = new(file);
                string   fileContent = File.ReadAllText(file);

                IEnumerable <Match> combinedResults = Utils.GetAllXstrFromFile(fileInfo, fileContent);

                foreach (Match match in combinedResults)
                {
                    //match.Groups[0] => entire line
                    //match.Groups[1] => text
                    //match.Groups[2] => id

                    if (int.TryParse(match.Groups[2].Value, out int id))
                    {
                        string text = match.Groups[1].Value;

                        // if id not existing, add a new line
                        if (id >= 0 && !Lines.Any(x => x.Id == id))
                        {
                            Lines.Add(new Xstr(id, text, fileInfo));
                        }
                        // if id already existing but value is different, then put it in another list that will be treated separately
                        else if (ManageDuplicates && (id < 0 || Lines.First(x => x.Id == id).Text != text))
                        {
                            Duplicates.Add(new Xstr(id, text, fileInfo, match.Value));
                        }
                    }
                    else
                    {
                        throw new Exception();
                    }
                }
            }

            int maxProgress = Lines.Count + (ManageDuplicates ? FilesList.Count + Duplicates.Count : 0);

            Parent.SetMaxProgress(maxProgress);
        }
Beispiel #4
0
 private void LoadMusicList(string File_path)
 {
     FilesList.Items.Clear();
     foreach (var item in Directory.GetFiles(VarEls.musicDir.SelectedPath, "*.mp3"))
     {
         try
         {
             WriteLog("File found:" + Path.GetFileNameWithoutExtension(item));
             FilesList.Items.Add(new ListBoxItem()
             {
                 Content = Path.GetFileNameWithoutExtension(item), Tag = item
             });
             if (item == File_path)
             {
                 FilesList.SelectedIndex = FilesList.Items.Count - 1;
             }
         }
         catch (Exception err) { lyrics.WriteErrLog(err.ToString()); }
     }
     FilesList.ScrollIntoView(FilesList.SelectedItem);
 }
        private void NewTemplateButton_Click(object sender, RoutedEventArgs e)
        {
            using (var dlg = new CommonSaveFileDialog())
            {
                dlg.Title            = "Create new template file";
                dlg.InitialDirectory = (string)TemplatesDirSelection.SelectedItem;

                dlg.AddToMostRecentlyUsedList = false;
                dlg.DefaultDirectory          = TemplateFactory.GetInstance().TemplatesDirectory;
                dlg.EnsurePathExists          = true;
                dlg.EnsureReadOnly            = false;
                dlg.EnsureValidNames          = true;
                dlg.ShowPlacesList            = true;
                dlg.DefaultExtension          = ".json";
                dlg.Filters.Add(new CommonFileDialogFilter("json", ".json"));
                if (dlg.ShowDialog() == CommonFileDialogResult.Ok)
                {
                    string path = dlg.FileName;
                    TemplateFactory.GetInstance().CreateNewTemplate(path);
                    SelectedTemplate = path;
                    FilesList.Focus();
                }
            }
        }
Beispiel #6
0
        private void DoUpdate()
        {
            NewFilesList.Clear();
            List <string> lstLinks = new List <string>();

            HtmlAgilityPack.HtmlDocument htmlDocument = new HtmlAgilityPack.HtmlDocument();
            WebRequest request = WebRequest.Create(HTMLLink);

            htmlDocument.Load(request.GetResponse().GetResponseStream());
            string             buildNewLink = null;
            bool               moveToRoot   = false;
            HtmlNodeCollection links        = htmlDocument.DocumentNode.SelectNodes("//a");

            foreach (HtmlNode link in links)
            {
                HtmlAttribute att = link.Attributes["href"];

                if (att == null)
                {
                    continue;
                }
                string newLink = att.Value;
                if (!MatchUpdateSign(newLink))
                {
                    continue;
                }
                if (!newLink.StartsWith("http://"))
                {
                    if (newLink.StartsWith("/"))
                    {
                        newLink    = newLink.Remove(0, 1);
                        moveToRoot = true;
                    }
                    if (newLink.StartsWith("wenxue"))
                    {
                        newLink = newLink.Substring(newLink.LastIndexOf("/") + 1);
                    }

                    if (!moveToRoot)
                    {
                        buildNewLink = HTMLLink.Substring(0, HTMLLink.LastIndexOf("/") + 1) + newLink;
                    }
                    else
                    {
                        buildNewLink = HTMLLink.Substring(0, HTMLLink.IndexOf("/", 7) + 1) + newLink;
                        moveToRoot   = false;
                    }
                }
                else
                {
                    buildNewLink = newLink;
                }

                if (!FilesList.Contains(buildNewLink))
                {
                    NewFilesList.Add(buildNewLink);
                }
            }

            if (SortBeforeDownload)
            {
                NewFilesList = DoSort(NewFilesList);
            }
            PreviousStepCount = GetPreviousStepCount();
        }
Beispiel #7
0
 public void Clear()
 {
     FilesList.Clear();
     NewFilesList.Clear();
     ProcessQueue.Clear();
 }
Beispiel #8
0
 public void AddAndSelect(FileViewModel item)
 {
     FilesList.Add(item);
     SelectedIndex = FilesList.IndexOf(item);
 }
Beispiel #9
0
 public bool HasFile(string path) => FilesList.Any(x => x.Path.Equals(path));
 public virtual void OnNext(File value)
 {
     MessageBox.Show(@"New file: " + value.FileName + @" is downloaded");
     FilesList.Add(value);
 }
Beispiel #11
0
 public CopyHandle()
 {
     State         = CopyHandleState.NotStarted;
     DiscoverdList = new FilesList();
     Errors        = new List <Error>();
 }
Beispiel #12
0
        public ActionResult ViewFiles()
        {
            FilesList files = new FilesList();

            return(View(files));
        }
Beispiel #13
0
 public bool CheckFile(string path)
 {
     return(FilesList.Any(file => file.FilePath.Equals(path)));
 }
Beispiel #14
0
 public void AddFile(File newFile)
 {
     FilesList.Add(newFile);
     SelectedTab = FilesList.IndexOf(newFile);
 }
Beispiel #15
0
        public async Task DeployFile()
        {
            bool success = false;

            // get only selected files
            IEnumerable <DeployFile> deployList = FilesList.ToArray().Where(s => s.Selected == true);

            // sanity check
            if (deployList.Count() <= 0)
            {
                return;
            }

            List <StorageFile> sigfiles = new List <StorageFile>(deployList.Count());

            // show busy
            BusySrv.ShowBusy();

            try
            {
                foreach (DeployFile file in deployList)
                {
                    // sanity checks
                    if (file.DFile.Path.Trim().Length == 0)
                    {
                        continue;
                    }
                    if (!file.DFile.IsAvailable)
                    {
                        BusySrv.HideBusy();
                        var dummy = await DialogSrv.ShowMessageAsync(String.Format(Res.GetString("DP_CantOpenFile"), file.DFile.DisplayName));

                        return;
                    }

                    // add to sigFiles list, if exists
                    var sigFile = await GetSignatureFileName(file.DFile);

                    if (sigFile == null)
                    {
                        var dummy = await DialogSrv.ShowMessageAsync(String.Format(Res.GetString("DP_CanOpenSigFile"), file.DFile.DisplayName));

                        return;
                    }
                    sigfiles.Add(sigFile);
                }

                // the code to deploy file goes here...

                // fazer ping
                bool fMicroBooter = (await MainVM.SelectedDevice.PingAsync() == PingConnectionType.NanoBooter);
                if (fMicroBooter)
                {
                    await MainVM.SelectedDevice.DebugEngine.PauseExecutionAsync();
                }

                List <uint> executionPoints = new List <uint>();
                int         cnt             = 0;
                foreach (DeployFile file in deployList)
                {
                    WindowWrapper.Current().Dispatcher.Dispatch(() =>
                    {
                        CurrentDeploymentTokenSource = new CancellationTokenSource();
                    });
                    CancellationToken cancellationToken = CurrentDeploymentTokenSource.Token;

                    if (Path.GetExtension(file.DFile.Path).ToLower() == ".nmf")
                    {
                        if (!await MainVM.SelectedDevice.DeployUpdateAsync(file.DFile, cancellationToken,
                                                                           new Progress <ProgressReport>((value) =>
                        {
                            // update busy message according to deployment progress
                            BusySrv.ChangeBusyText(value.Status);
                        })
                                                                           ))
                        {
                            // fail
                            var dummy = await DialogSrv.ShowMessageAsync(String.Format(Res.GetString("DP_CantDeploy"), file.DFile.DisplayName));

                            return;
                        }
                    }
                    else
                    {
                        var tpl = await MainVM.SelectedDevice.DeployAsync(file.DFile, sigfiles[cnt++], cancellationToken,
                                                                          new Progress <ProgressReport>((value) =>
                        {
                            // update busy message according to deployment progress
                            BusySrv.ChangeBusyText(value.Status);
                        })
                                                                          );

                        if (!tpl.Item2)
                        {
                            // fail
                            var dummy = await DialogSrv.ShowMessageAsync(String.Format(Res.GetString("DP_CantDeploy"), file.DFile.DisplayName));

                            return;
                        }
                        if (tpl.Item1 != 0)
                        {
                            executionPoints.Add(tpl.Item1);
                        }
                    }
                }

                executionPoints.Add(0);

                if (!fMicroBooter)
                {
                    for (int i = 0; i < 10; i++)
                    {
                        if (await MainVM.SelectedDevice.DebugEngine.ConnectAsync(1, 500, true))
                        {
                            break;
                        }
                    }
                }

                // update busy message according to deployment progress
                BusySrv.ChangeBusyText(Res.GetString("DP_ExecutingApp"));

                foreach (uint addr in executionPoints)
                {
                    WindowWrapper.Current().Dispatcher.Dispatch(() =>
                    {
                        CurrentDeploymentTokenSource = new CancellationTokenSource();
                    });
                    CancellationToken cancellationToken = CurrentDeploymentTokenSource.Token;
                    if (await MainVM.SelectedDevice.ExecuteAync(addr, cancellationToken))
                    {
                        break;
                    }
                }


                success = true;
            }
            catch { /* TBD */ }
            finally
            {
                // resume execution
                if (MainVM.SelectedDevice.DebugEngine != null)
                {
                    try
                    {
                        if (MainVM.SelectedDevice.DebugEngine.IsConnected && MainVM.SelectedDevice.DebugEngine.ConnectionSource == nanoFramework.Tools.Debugger.WireProtocol.ConnectionSource.NanoCLR)
                        {
                            await MainVM.SelectedDevice.DebugEngine.ResumeExecutionAsync();
                        }
                    }
                    catch
                    {
                    }
                }

                // end busy
                BusySrv.HideBusy();

                // show result to user
                if (success)
                {
                    await DialogSrv.ShowMessageAsync(deployList.Count() > 1?Res.GetString("DP_FilesDeployed") : Res.GetString("DP_FileDeployed"));
                }
                else
                {
                    await DialogSrv.ShowMessageAsync(deployList.Count() > 1?Res.GetString("DP_FailToDeployFiles") : Res.GetString("DP_FailToDeployFile"));
                }
            }
        }
        /// <summary>
        /// Make a shadow copy of the element at the current state which stays available even the element is gone.
        /// </summary>
        /// <returns>A shadow copy of the current element.</returns>
        public new BasicOpenFileDialogData GetDataCopy()
        {
            var data = new BasicOpenFileDialogData();

            FillData(data);

            data.InputComboBox = GetSafeData(() =>
            {
                if (InputComboBox == null)
                {
                    return(null);
                }
                return(InputComboBox.GetDataCopy());
            });

            data.BreadCrumbBar = GetSafeData(() =>
            {
                if (BreadCrumbBar == null)
                {
                    return(null);
                }
                return(BreadCrumbBar.GetDataCopy());
            });

            data.BreadCrumbTextBox = GetSafeData(() =>
            {
                if (BreadCrumbTextBox == null)
                {
                    return(null);
                }
                return(BreadCrumbTextBox.GetDataCopy());
            });

            data.FilterComboBox = GetSafeData(() =>
            {
                if (FilterComboBox == null)
                {
                    return(null);
                }
                return(FilterComboBox.GetDataCopy());
            });

            data.CancelButton = GetSafeData(() =>
            {
                if (CancelButton == null)
                {
                    return(null);
                }
                return(CancelButton.GetDataCopy());
            });

            data.OpenButton = GetSafeData(() =>
            {
                if (OpenButton == null)
                {
                    return(null);
                }
                return(OpenButton.GetDataCopy());
            });

            data.FilesList = GetSafeData(() =>
            {
                if (FilesList == null)
                {
                    return(null);
                }
                return(FilesList.GetDataCopy());
            });

            data.SearchTextBox = GetSafeData(() =>
            {
                if (SearchTextBox == null)
                {
                    return(null);
                }
                return(SearchTextBox.GetDataCopy());
            });

            data.SearchButton = GetSafeData(() =>
            {
                if (SearchButton == null)
                {
                    return(null);
                }
                return(SearchButton.GetDataCopy());
            });

            data.FolderTree = GetSafeData(() =>
            {
                if (FolderTree == null)
                {
                    return(null);
                }
                return(FolderTree.GetDataCopy());
            });

            data.ToolBar = GetSafeData(() =>
            {
                if (ToolBar == null)
                {
                    return(null);
                }
                return(ToolBar.GetDataCopy());
            });

            data.ChangeViewButton = GetSafeData(() =>
            {
                if (ChangeViewButton == null)
                {
                    return(null);
                }
                return(ChangeViewButton.GetDataCopy());
            });

            data.ShowPreviewButton = GetSafeData(() =>
            {
                if (ShowPreviewButton == null)
                {
                    return(null);
                }
                return(ShowPreviewButton.GetDataCopy());
            });

            data.HelpButton = GetSafeData(() =>
            {
                if (HelpButton == null)
                {
                    return(null);
                }
                return(HelpButton.GetDataCopy());
            });

            return(data);
        }
 public SiteCoreFileChecker()
 {
     BaseDirectory = null;
     ResultList    = new FilesList();
 }
Beispiel #18
0
 protected override void OnLoad(EventArgs e)
 {
     FilesList.DataSource = Files;
     FilesList.DataBind();
 }
Beispiel #19
0
        protected CopyRoutineResult CopyRoutine(FilesList files, bool fastMove)
        {
            //System.IO.DirectoryInfo sysDirInfo = null;
            //FileAttributes sysAtt;
            //Alphaleonis.Win32.Filesystem.DirectoryInfo di = null;
            //FileAttributes att;

            for (; DiscoverdList.Index < DiscoverdList.Count; DiscoverdList.Index++)
            {
                try
                {
                    if (State == CopyHandleState.Canceled)
                    {
                        return(CopyRoutineResult.Canceled);
                    }

                    //Get the file to copy.
                    if (DiscoverdList.Count == 0 || DiscoverdList.Index >= DiscoverdList.Count)
                    {
                        return(CopyRoutineResult.Error);
                    }
                    CurrentFile           = DiscoverdList.Files[DiscoverdList.Index];
                    CurrentFile.CopyState = CopyState.Processing;

                    //Create the Directories.

                    try
                    {
                        //di = new Alphaleonis.Win32.Filesystem.DirectoryInfo(Alphaleonis.Win32.Filesystem.Path.GetDirectoryName(CurrentFile.FullName));
                        //att = di.Attributes;
                        LongPath.Directory.CreateDirectoriesInPath(CurrentFile.DestinyDirectoryPath);
                        //di=new Alphaleonis.Win32.Filesystem.DirectoryInfo(CurrentFile.DestinyDirectoryPath);
                        //di.Attributes = att;
                    }
                    catch (Exception)
                    {
                    }
                    finally
                    {
                        //This is a copy actions wich deals with file collisions.
                        FileCollisionAction.Invoke(fastMove);

                        //If the File was Processed succefully=============================
                        //Set the currentFile copy state as Copied.
                        CurrentFile.CopyState = affeterOperationState;

                        //Status.
                        CopiedsFiles++;
                    }
                }
                catch (Exception ex)
                {
                    opt = ErrorsCheck(ex);

                    if (opt == AffterErrorAction.Cancel)
                    {
                        return(CopyRoutineResult.Canceled);
                    }
                    else if (opt == AffterErrorAction.Try)
                    {
                        //Try to process the same file
                        DiscoverdList.Index--;
                        FileCopier.TotalBytesTransferred -= FileCopier.FileBytesTransferred;
                        FileCopier.FileBytesTransferred   = 0;
                    }
                    else if (!(ex is ThreadAbortException))
                    {
                        CurrentFile.CopyState = CopyState.Error;
                    }
                }
            }

            return(CopyRoutineResult.Ok);
        }
Beispiel #20
0
        private void DoUpdate()
        {
            NewFilesList.Clear();
            NewChapterNamesList.Clear();
            List <string> lstLinks = new List <string>();

            //Trust all certificates
            System.Net.ServicePointManager.ServerCertificateValidationCallback = delegate { return(true); };
            HtmlAgilityPack.HtmlDocument htmlDocument = new HtmlAgilityPack.HtmlDocument();
            WebRequest request = WebRequest.Create(HTMLLink);

            htmlDocument.Load(request.GetResponse().GetResponseStream(), ContentEncoding);
            string             buildNewLink = null;
            bool               moveToRoot   = false;
            HtmlNodeCollection links        = htmlDocument.DocumentNode.SelectNodes("//a");

            foreach (HtmlNode link in links)
            {
                HtmlAttribute att = link.Attributes["href"];

                if (att == null)
                {
                    continue;
                }
                string newLink = att.Value;
                if (!MatchUpdateSign(newLink))
                {
                    continue;
                }
                if (!newLink.StartsWith("http://") && !newLink.StartsWith("https://"))
                {
                    if (newLink.StartsWith("/"))
                    {
                        newLink    = newLink.Remove(0, 1);
                        moveToRoot = true;
                    }
                    if (newLink.StartsWith("wenxue"))
                    {
                        newLink = newLink.Substring(newLink.LastIndexOf("/") + 1);
                    }

                    if (!moveToRoot)
                    {
                        buildNewLink = HTMLLink.Substring(0, HTMLLink.LastIndexOf("/") + 1) + newLink;
                    }
                    else
                    {
                        int startPoint = HTMLLink.StartsWith("https") ? 8 : 7;
                        buildNewLink = HTMLLink.Substring(0, HTMLLink.IndexOf("/", startPoint) + 1) + newLink;
                        moveToRoot   = false;
                    }
                }
                else
                {
                    buildNewLink = newLink;
                }

                if (!FilesList.Contains(buildNewLink))
                {
                    NewFilesList.Add(buildNewLink);
                    NewChapterNamesList.Add(GetUTF8Content(HTMLLink, link.InnerHtml, ContentEncoding));
                }
            }

            if (SortBeforeDownload)
            {
                NewFilesList = DoSort(NewFilesList);
            }
            PreviousStepCount = GetPreviousStepCount();
        }