public void AddLookup(object instance, INodeInfo nodeInfo) { if (instance != null && !nodeLookup.ContainsKey(instance)) { var notifyPropertyChanged = instance as INotifyPropertyChanged; if (notifyPropertyChanged != null) notifyPropertyChanged.PropertyChanged += NotifyPropertyChangedOnPropertyChanged; nodeLookup.Add(instance, nodeInfo); } }
public bool Create(INodeInfo nodeInfo, INode host) { return(false); }
public void ParseNodeEntry(System.Xml.XmlReader xmlReader, INodeInfo nodeInfo) { }
public bool Equals(INodeInfo other) { return(other != null && this.Id == other.Id); }
protected override bool CreateNode(INodeInfo nodeInfo, IInternalPluginHost pluginHost) { if (nodeInfo.Type != NodeType.Dynamic) { return(false); } var project = nodeInfo.UserData as FXProject; /*if (!project.IsLoaded) * project.Load();*/ //compile shader FIncludeHandler.ParentPath = Path.GetDirectoryName(nodeInfo.Filename); string code = File.ReadAllText(nodeInfo.Filename); DX11Effect shader; //create or update plugin if (pluginHost.Plugin == null) { nodeInfo.AutoEvaluate = false; nodeInfo.Arguments = typeof(T).ToString(); var pluginContainer = new PluginContainer(pluginHost, FIORegistry, FParentContainer, FNodeInfoFactory, FDotNetFactory, typeof(T), nodeInfo); pluginHost.Plugin = pluginContainer; FPluginContainers[pluginContainer.PluginBase] = pluginContainer; IDX11ShaderNodeWrapper shaderNode = pluginContainer.PluginBase as IDX11ShaderNodeWrapper; shaderNode.Source = nodeInfo; shaderNode.WantRecompile += new EventHandler(shadernode_WantRecompile); shader = DX11Effect.FromString(code, FIncludeHandler, shaderNode.Macros); shaderNode.SetShader(shader, true, nodeInfo.Filename); if (this.PluginCreated != null) { this.PluginCreated(pluginContainer, pluginHost); } } else { PluginContainer container = pluginHost.Plugin as PluginContainer; var shaderNode = container.PluginBase as IDX11ShaderNodeWrapper; shader = DX11Effect.FromString(code, FIncludeHandler, shaderNode.Macros); shaderNode.SetShader(shader, false, nodeInfo.Filename); } //now the effect is compiled in vvvv and we can access the errors string e = shader.ErrorMessage;//effectHost.GetErrors(); if (string.IsNullOrEmpty(e)) { e = ""; } this.ParseErrors(e, project, shader); //and the input pins string f = "";// effectHost.GetParameterDescription(); if (string.IsNullOrEmpty(f)) { f = ""; } project.ParameterDescription = f; return(true); }
private int SortNodeInfo(INodeInfo n1, INodeInfo n2) { var s1 = NodeInfoToDisplayName(n1); var s2 = NodeInfoToDisplayName(n2); //Workaround: Following code assumes s1 and s2 are either a filename //or include an opening parenthesis. Since node info rework there're //also systemnames without any parenthesis. So for now add one if missing. if (s1.IndexOf('(') < 0) { s1 = s1 + "()"; } if (s2.IndexOf('(') < 0) { s2 = s2 + "()"; } //create a weighting index depending on the indices the tags appear in the nodenames //earlier appearance counts more int w1 = int.MaxValue, w2 = int.MaxValue; string t = ""; foreach (string tag in FTags) { t = tag.TrimStart(new char[1] { '.' }); if (s1.ToLower().IndexOf(t) > -1) { w1 = Math.Min(w1, s1.ToLower().IndexOf(t)); } if (s2.ToLower().IndexOf(t) > -1) { w2 = Math.Min(w2, s2.ToLower().IndexOf(t)); } } if (w1 != w2) { if (w1 < w2) { return(-1); } else { return(1); } } //if weights are equal, compare the nodenames string name1 = s1.Substring(0, s1.IndexOf('(')); string name2 = name2 = s2.Substring(0, s2.IndexOf('(')); //compare only the nodenames int comp = name1.CompareTo(name2); //if names are equal if (comp == 0) { //compare categories Match match = null; match = FCatRegExp.Match(s1); string cat1 = match.Success ? match.Groups[1].Value : string.Empty; match = FCatRegExp.Match(s2); string cat2 = match.Success ? match.Groups[1].Value : string.Empty; int v1, v2; //special sorting for categories if (cat1.Contains("Value")) { v1 = 99; } else if (cat1.ToUpper().Contains("2D")) { v1 = 98; } else if (cat1.ToUpper().Contains("3D")) { v1 = 97; } else if (cat1.ToUpper().Contains("4D")) { v1 = 96; } else if (cat1.Contains("Spreads")) { v1 = 95; } else if (cat1.Contains("Animation")) { v1 = 94; } else if (cat1.Contains("EX9")) { v1 = 93; } else if (cat1.Contains("DX9")) { v1 = 92; } else if (cat1.Contains("File")) { v1 = 91; } else if (cat1.Contains("SVG")) { v1 = 90; } else if (cat1.Contains("TTY")) { v1 = 89; } else if (cat1.Contains("GDI")) { v1 = 88; } else if (cat1.Contains("Flash")) { v1 = 87; } else if (cat1.Contains("Transform")) { v1 = 86; } else if (cat1.Contains("Quaternion")) { v1 = 85; } else if (cat1.Contains("Octonion")) { v1 = 84; } else if (cat1.Contains("String")) { v1 = 83; } else if (cat1.Contains("Color")) { v1 = 82; } else if (cat1.Contains("DShow9")) { v1 = 81; } else { v1 = 0; } if (cat2.Contains("Value")) { v2 = 99; } else if (cat2.ToUpper().Contains("2D")) { v2 = 98; } else if (cat2.ToUpper().Contains("3D")) { v2 = 97; } else if (cat2.ToUpper().Contains("4D")) { v2 = 96; } else if (cat2.Contains("Spreads")) { v2 = 95; } else if (cat2.Contains("Animation")) { v2 = 94; } else if (cat2.Contains("EX9")) { v2 = 93; } else if (cat2.Contains("DX9")) { v2 = 92; } else if (cat2.Contains("File")) { v2 = 91; } else if (cat2.Contains("SVG")) { v2 = 90; } else if (cat2.Contains("TTY")) { v2 = 89; } else if (cat2.Contains("GDI")) { v2 = 88; } else if (cat2.Contains("Flash")) { v2 = 87; } else if (cat2.Contains("Transform")) { v2 = 86; } else if (cat2.Contains("Quaternion")) { v2 = 85; } else if (cat2.Contains("Octonion")) { v2 = 84; } else if (cat2.Contains("String")) { v2 = 83; } else if (cat2.Contains("Color")) { v2 = 82; } else if (cat2.Contains("DShow9")) { v2 = 81; } else { v2 = 0; } if (v1 > v2) { return(-1); } else if (v1 < v2) { return(1); } else //categories are the same, compare versions { if ((cat1.Length > cat2.Length) && (cat1.Contains(cat2))) { return(1); } else if ((cat2.Length > cat1.Length) && (cat2.Contains(cat1))) { return(-1); } else { return(cat1.CompareTo(cat2)); } } } else { return(comp); } }
protected override bool CloneNode(INodeInfo nodeInfo, string path, string name, string category, string version, out string newFilename) { string className = string.Format("{0}{1}{2}Node", version, category, name); className = Regex.Replace(className, @"[^a-zA-Z0-9]+", "_"); var regexp = new Regex(@"^[0-9]+"); if (regexp.IsMatch(className)) { className = string.Format("C{0}", className); } // Find a suitable project name var newProjectName = string.Format("{0}{1}{2}", version, category, name);; var newProjectPath = path.ConcatPath(newProjectName).ConcatPath(newProjectName + ".csproj"); int i = 1; string tmpNewProjectName = newProjectName; string tmpClassName = className; while (File.Exists(newProjectPath)) { newProjectName = tmpNewProjectName + i; className = tmpClassName + i++; newProjectPath = path.ConcatPath(newProjectName).ConcatPath(newProjectName + ".csproj"); } var filename = nodeInfo.Filename; var project = CreateProject(filename); project.SaveTo(newProjectPath); using (var newProject = new CSProject(newProjectPath)) { foreach (var doc in newProject.Documents) { var csDoc = doc as CSDocument; if (csDoc != null) { // Rename the CSDocument if (ContainsNodeInfo(csDoc, nodeInfo)) { var newDocName = string.Format("{0}.cs", Path.GetFileNameWithoutExtension(className)); csDoc.Name = newDocName; csDoc.Rename(newDocName); break; } } } foreach (var doc in newProject.Documents) { // Now scan the document for possible plugin infos. // If we find one, update its properties and rename the class. var csDoc = doc as CSDocument; if (csDoc != null) { var parserResults = csDoc.Parse(true); var compilationUnit = parserResults.CompilationUnit; // Write new values to plugin info and remove all other plugin infos. var pluginInfoTransformer = new PluginClassTransformer(nodeInfo, name, category, version, className); compilationUnit.AcceptVisitor(pluginInfoTransformer, null); var outputVisitor = new CSharpOutputVisitor(); var specials = parserResults.Specials; using (SpecialNodesInserter.Install(specials, outputVisitor)) { outputVisitor.VisitCompilationUnit(compilationUnit, null); } csDoc.TextContent = outputVisitor.Text; } } // Save the project. newProject.Save(); newFilename = newProject.LocalPath; return(true); } }
public void Add(INodeInfo nodeInfo) { FSystemNameDict[nodeInfo.Systemname] = nodeInfo; }
public Platformer2DGrid(int x, int y, int z, Cell3D polygon, INodeInfo fill) : base(x, y, z, polygon, fill) { }
public Grid3D(int x, int y, int z, Cell3D polygon, INodeInfo fill) { Init(polygon); Create(x, y, z, polygon, fill); }
/// <summary> /// Creates new grid of specefic size /// </summary> /// <param name="sizeX">X size parameter</param> /// <param name="sizeY">Y size parameter</param> /// <param name="sizeZ">Z size parameter</param> public void Create(int sizeX, int sizeY, int sizeZ, Cell3D polygon, INodeInfo fill = null) { SizeX = sizeX; SizeY = sizeY; SizeZ = sizeZ; Nodes = new ArrayEx<Cell>(new int[] { SizeX, SizeY, SizeZ }); for (int k = 0; k < SizeZ; k++) { for (int j = 0; j < SizeY; j++) { for (int i = 0; i < SizeX; i++) { //_nodes[i, j, k] = new Node3D<T>(i * Polygon.Bounds.SizeX, j * Polygon.Bounds.SizeY, k * Polygon.Bounds.SizeZ, Polygon); Nodes[i, j, k] = new Cell(i, j, k, Polygon, this, fill); } } } }
/// <summary> /// Applies the specified node configuration to the node in question. /// </summary> /// <param name="nodeInfo">Information on the node currently being inspected.</param> /// <param name="nodeConfig">The expression for node configuration.</param> public void Apply(INodeInfo nodeInfo, INodeExpression nodeConfig) { nodeConfig.WithFillColor(Color.Gainsboro).WithStyle(NodeStyle.Filled); }
public Cell(Vector3 v, IPolygon polygon, Grid3D graph, INodeInfo info = null) { Init(v.X, v.Y, v.Z, polygon, graph, info); }
public Cell(double x, double y, double z, IPolygon polygon, Grid3D graph, INodeInfo info = null) { Init(x, y, z, polygon, graph, info); }
public bool GetNodeListAttribute(INodeInfo nodeInfo, out string name, out string value) { name = ""; value = ""; return(false); }
public CellEdge(INodeInfo info) { Info = info; }
/// <summary> /// Determines whether the configuration in the Apply method should be applied to this node instance. /// </summary> /// <param name="nodeInfo">Information on the node currently being inspected.</param> /// <returns></returns> public bool ShouldApply(INodeInfo nodeInfo) { var tag = (int)nodeInfo.Tag; return tag.IsOdd(); }
public CellEdge(Cell from, Cell to, INodeInfo info) { From = from; To = to; Info = info; }
/// <param name="cmd">Pushed command</param> /// <param name="component">INodeInfo component for searching</param> /// <param name="raw">Full raw string to finding</param> /// <returns></returns> protected IEnumerable <ICompletionData> find(KeysCommand cmd, INodeInfo component, string raw) { if (raw == null) { if (cmd == KeysCommand.CtrlSpace || cmd == KeysCommand.Space) { return(list(new NodeIdent(component.Name, null))); } return(ListNull); } if (cmd == KeysCommand.Space) { return(ListNull); } string ident = (new StringHandler()).protectMixedQuotes(raw.Trim()); if (_isLatest('.', ident)) { ident = ident.Substring(0, ident.Length - 1); if (cmd == KeysCommand.CtrlSpace) { cmd = KeysCommand.LevelByDot; } } if (cmd == KeysCommand.CtrlSpace) { if (Regex.IsMatch(raw, @"(?: \s+ | \([^.)]*? | \) )$", RegexOptions.IgnorePatternWhitespace)) { return(ListNull); } } string[] parts = Regex.Replace(ident, RPattern.RoundBracketsContent, "()", RegexOptions.IgnorePatternWhitespace ).Split('.'); NodeIdent id = new NodeIdent(component.Name, null); for (int i = 0; i < parts.Length; ++i) { parts[i] = parts[i].Trim(); if (cmd == KeysCommand.CtrlSpace && i == parts.Length - 1) { return(list(id, parts[i])); } INodeInfo info = infoBy(parts[i], id, (cmd == KeysCommand.LevelByDot)); if (info == null) { return(ListEmpty); } id = info.Link; } if (cmd == KeysCommand.LevelByDot) { return(list(id)); } return(ListEmpty); }
public bool ShouldApply(INodeInfo nodeInfo) { throw new System.NotImplementedException(); }
public void ShowHelpPatch(INodeInfo nodeInfo) { FVVVVHost.ShowHelpPatch(nodeInfo); }
public void Apply(INodeInfo nodeInfo, FluentDot.Expressions.Nodes.INodeExpression nodeConfig) { throw new System.NotImplementedException(); }
private void FilterNodesByTags() { if (NodeBrowser == null) { return; } // FNeedsUpdate = false; FSelectionList.Clear(); var nodeInfos = NodeBrowser.NodeInfoFactory.NodeInfos.Where(ni => ni.Ignore == false && NodeBrowser.CategoryFilter.CategoryVisible(ni.Category)); if (FShowInternal) { nodeInfos = nodeInfos.Where(ni => ni.Version.Contains("Internal")); } else { nodeInfos = nodeInfos.Where(ni => !ni.Version.Contains("Internal")); } // Cache current patch window nodeinfo and current dir var currentPatchWindow = NodeBrowser.CurrentPatchWindow; FCurrentPatchWindowNodeInfo = currentPatchWindow != null ? currentPatchWindow.Node.NodeInfo : null; FCurrentDir = NodeBrowser.CurrentDir; if (FNodeFilter == -1) { nodeInfos = nodeInfos.Where(nodeInfo => nodeInfo.Type == NodeType.Native || IsAvailableInActivePatch(nodeInfo)); } else if (FNodeFilter == -2) { nodeInfos = nodeInfos.Where(nodeInfo => nodeInfo.Type != NodeType.Native && IsAvailableInActivePatch(nodeInfo, false)); } else if (FNodeFilter == (int)NodeType.Native) { nodeInfos = nodeInfos.Where(nodeInfo => nodeInfo.Type == NodeType.Native); } else { NodeType nodeType = (NodeType)FNodeFilter; nodeInfos = nodeInfos.Where(nodeInfo => nodeInfo.Type == nodeType && IsAvailableInActivePatch(nodeInfo)); } FSelectionList = ExtractSubList(nodeInfos).ToList(); FSelectionList.Sort(SortNodeInfo); if (FNodeCountLabel.InvokeRequired) { FNodeCountLabel.Invoke(new MethodInvoker(() => { FNodeCountLabel.Text = "Matching Nodes: " + FSelectionList.Count.ToString(); })); } else { //FCategoryTreeViewer.Reload(); FNodeCountLabel.Text = "Matching Nodes: " + FSelectionList.Count.ToString(); } }
/// <param name="cmd">Pushed command</param> /// <param name="component">INodeInfo component for searching</param> /// <param name="raw">Full raw string to finding</param> /// <returns></returns> protected IEnumerable<ICompletionData> find(KeysCommand cmd, INodeInfo component, string raw) { if(raw == null) { if(cmd == KeysCommand.CtrlSpace || cmd == KeysCommand.Space) { return list(new NodeIdent(component.Name, null)); } return ListNull; } if(cmd == KeysCommand.Space) { return ListNull; } string ident = (new StringHandler()).protectMixedQuotes(raw.Trim()); if(_isLatest('.', ident)) { ident = ident.Substring(0, ident.Length - 1); if(cmd == KeysCommand.CtrlSpace) { cmd = KeysCommand.LevelByDot; } } if(cmd == KeysCommand.CtrlSpace) { if(Regex.IsMatch(raw, @"(?: \s+ | \([^.)]*? | \) )$", RegexOptions.IgnorePatternWhitespace)) { return ListNull; } } string[] parts = Regex.Replace(ident, RPattern.RoundBracketsContent, "()", RegexOptions.IgnorePatternWhitespace ).Split('.'); NodeIdent id = new NodeIdent(component.Name, null); for(int i = 0; i < parts.Length; ++i) { parts[i] = parts[i].Trim(); if(cmd == KeysCommand.CtrlSpace && i == parts.Length - 1) { return list(id, parts[i]); } INodeInfo info = infoBy(parts[i], id, (cmd == KeysCommand.LevelByDot)); if(info == null) { return ListEmpty; } id = info.Link; } if(cmd == KeysCommand.LevelByDot) { return list(id); } return ListEmpty; }
protected virtual bool GetAssemblyLocation(INodeInfo nodeInfo, out string assemblyLocation) { assemblyLocation = nodeInfo.Filename; return(true); }
/// <summary> /// Work with aliases to components and to definitions. /// </summary> /// <param name="node">Node with aliases</param> /// <param name="data">All nodes</param> protected void aliasesToNodeLevelA(INodeInfo node, List<INodeInfo> data) { if(node.Aliases == null || node.Aliases.Length < 1) { return; } InfoType aliasType = (node.Type == InfoType.Component)? InfoType.AliasToComponent : InfoType.AliasToDefinition; foreach(string alias in node.Aliases) { data.Add(new NodeInfo(alias, String.Format("Alias to '{0}' {1}\n{2}", node.Name, node.Type, node.Description), new NodeIdent(node.Name, null), aliasType)); } }
private void Init(double x, double y, double z, IPolygon polygon, Grid3D graph, INodeInfo info = null) { X = x; Y = y; Z = z; if (info != null) { Info = (INodeInfo)info.Clone(); } else { Info = new Empty(); } Polygon = polygon; Grid = graph; }
protected override bool DeleteNode(INodeInfo nodeInfo, IEffectHost host) { return(true); }
public bool Clone(INodeInfo nodeInfo, string path, string name, string category, string version, out INodeInfo newNodeInfo) { newNodeInfo = null; return(false); }
private async Task DownloadFileAsync(INode fileNode, Uri fileUri, INodeInfo fileNodeInfo, string path, bool overwrite, int retry = 0) //MegaApiClient is a mess, that's why we pass so many parameters { if (fileNode == null && fileNodeInfo == null) { throw new ArgumentException("fileNode or fileNodeInfo should be filled"); } if ((fileNodeInfo != null && fileUri == null) || fileNodeInfo == null && fileUri != null) { throw new ArgumentException("Both fileUri and fileNodeInfo should be filled"); } if (fileNode != null && fileNodeInfo != null) { throw new ArgumentException("Both fileNode and fileNodeInfo cannot be filled at the same time"); } INodeInfo nodeInfo = fileNode != null ? fileNode : fileNodeInfo; if (nodeInfo.Type != NodeType.File) { throw new Exception("Node is not a file"); } if (retry > 0) { try { if (File.Exists(path)) { File.Delete(path); } } catch (Exception fileDeleteException) { throw new Common.Exceptions.DownloadException($"Unable to delete corrupted file {path}", fileDeleteException); } if (retry >= _maxRetries) { throw new Common.Exceptions.DownloadException("Retries limit reached"); } await Task.Delay(retry * 2 * 1000); } _logger.Debug($"[MEGA] Downloading {nodeInfo.Name} to {path}"); long remoteFileSize = nodeInfo.Size; bool isFilesIdentical = false; if (File.Exists(path)) { if (remoteFileSize > 0) { _logger.Debug($"[MEGA] File {path} exists, size will be checked"); try { FileInfo fileInfo = new FileInfo(path); long fileSize = fileInfo.Length; if (fileSize != remoteFileSize) { string backupFilename = $"{Path.GetFileNameWithoutExtension(path)}_old_{DateTimeOffset.UtcNow.ToUnixTimeSeconds()}{Path.GetExtension(path)}"; _logger.Warn($"[MEGA] Local and remote file sizes does not match, file {nodeInfo.Id} will be redownloaded. Old file will be backed up as {backupFilename}. Remote file size: {remoteFileSize}, local file size: {fileSize}"); File.Move(path, Path.Combine(fileInfo.DirectoryName, backupFilename)); } else { _logger.Debug($"[MEGA] File size for {path} matches"); isFilesIdentical = true; } } catch (Exception ex) { _logger.Error(ex, $"[MEGA] Error during file comparison: {ex}"); isFilesIdentical = true; //we assume that local file is identical if we can't check remote file size } } if (isFilesIdentical) { if (!overwrite) { _logger.Warn($"[MEGA] File {path} already exists and has the same file size as remote file (or remote file is not available). Skipping..."); return; } else { _logger.Warn($"[MEGA] File {path} already exists, will be overwriten!"); try { File.Delete(path); } catch (Exception ex) { throw new Common.Exceptions.DownloadException($"Unable to delete file {path}", ex); } } } } try { //warning: returns '' in drive's root if (!Directory.Exists(path)) { Directory.CreateDirectory(new FileInfo(path).DirectoryName); } } catch (Exception ex) { throw new Common.Exceptions.DownloadException($"Unable to create directory for file {path}", ex); } try { IProgress <double> progressHandler = new Progress <double>(x => _logger.Trace("Mega download progress: {0}%", x)); if (fileNode != null) { await _client.DownloadFileAsync(fileNode, path, progressHandler); } else { await _client.DownloadFileAsync(fileUri, path, progressHandler); } FileInfo fileInfo = new FileInfo(path); long fileSize = fileInfo.Length; fileInfo = null; if (remoteFileSize > 0 && fileSize != remoteFileSize) { _logger.Warn($"Downloaded file size differs from the size returned by server. Local size: {fileSize}, remote size: {remoteFileSize}. File {path} will be redownloaded."); File.Delete(path); retry++; await DownloadFileAsync(fileNode, fileUri, fileNodeInfo, path, overwrite, retry); return; } _logger.Debug($"File size check passed for: {path}"); } catch (Exception ex) { retry++; _logger.Debug(ex, $"Encountered error while trying to download {nodeInfo.Id}, retrying in {retry * 2} seconds ({_maxRetries - retry} retries left)... The error is: {ex}"); await DownloadFileAsync(fileNode, fileUri, fileNodeInfo, path, overwrite, retry); } }
public bool Delete(INodeInfo nodeInfo, INode host) { return(false); }
protected override bool DeleteNode(INodeInfo nodeInfo, INode nodeHost) { // Will never get called. return(true); }
protected virtual string GetAssemblyLocation(INodeInfo nodeInfo) { return(nodeInfo.Filename); }
/// <summary> /// Applies the specified node configuration to the node in question. /// </summary> /// <param name="nodeInfo">Information on the node currently being inspected.</param> /// <param name="nodeConfig">The expression for node configuration.</param> public void Apply(INodeInfo nodeInfo, INodeExpression nodeConfig) { nodeConfig.WithFillColor(Color.LightSteelBlue).WithStyle(NodeStyle.Filled); }
public static void DownloadReferenceUrl(Launcher.Game game, bool clearCache = true) { string displayName; if (game.Name.Length > 0) { displayName = game.Name; } else { displayName = game.ID; } string workingDir = ""; if (game.Root == "roms" || game.Root == "data") { workingDir = Path.Combine(Launcher.rootDir, "nulldc-1-0-4-en-win", game.Root); } else { Console.WriteLine("no valid root found in reference entry"); return; } var di = new DirectoryInfo(workingDir); di.Attributes |= FileAttributes.Normal; var zipPath = Path.Combine(workingDir, $"{Path.GetFileNameWithoutExtension(game.ReferenceUrl)}.zip"); if (!File.Exists(zipPath)) { Console.WriteLine($"Downloading {displayName}..."); var referenceUri = new Uri(game.ReferenceUrl); if (referenceUri.Host == "mega.nz") { MegaApiClient client = new MegaApiClient(); client.LoginAnonymous(); INodeInfo node = client.GetNodeFromLink(referenceUri); Console.WriteLine($"Downloading {node.Name}"); client.DownloadFile(referenceUri, zipPath); client.Logout(); } else { using (WebClient client = new WebClient()) { Console.WriteLine($"Downloading {Path.GetFileName(referenceUri.LocalPath)}"); client.DownloadFile(referenceUri, zipPath); } } Console.WriteLine($"Download Complete"); } Console.WriteLine($"Extracting...\n"); string extractPath; if (game.Root == "roms") { extractPath = Path.Combine(workingDir, displayName); Directory.CreateDirectory(extractPath); } else { extractPath = workingDir; } using (ZipArchive archive = ZipFile.OpenRead(zipPath)) { List <Launcher.Asset> files = game.Assets; foreach (ZipArchiveEntry entry in archive.Entries) { try { var fileEntry = files.Where(f => f.Name == entry.Name).First(); if (fileEntry != null) { var destinationFile = Path.Combine(extractPath, fileEntry.LocalName()); entry.ExtractToFile(destinationFile, true); Console.WriteLine(fileEntry.VerifyFile(destinationFile)); } } catch (Exception) { } } } if (clearCache) { File.Delete(zipPath); } Console.WriteLine($"\nPress any key to continue."); Console.ReadKey(); }
public void Remove(INodeInfo nodeInfo) { FSystemNameDict.Remove(nodeInfo.Systemname); }
/// <summary> /// Determines whether the configuration in the Apply method should be applied to this node instance. /// </summary> /// <param name="nodeInfo">Information on the node currently being inspected.</param> /// <returns></returns> public bool ShouldApply(INodeInfo nodeInfo) { return nodeInfo.Tag != null; }
/// <param name="data">Where to find</param> /// <param name="offset">Position in data to begin viewing</param> /// <param name="cmd">Pushed command</param> /// <returns>Complete list for code completion</returns> public IEnumerable <ICompletionData> find(string data, int offset, KeysCommand cmd) { if (cmd == KeysCommand.Default) { return(ListEmpty); } if (cmd == KeysCommand.MSBuildContainer) // '#[' - root of the MSBuild container { return(listMSBuildProperties(null)); } if (cmd == KeysCommand.Container) // '#[' - root of the SBE container { return(listComponents(null)); } data = region(data, offset); // '$( '<-- if (Regex.IsMatch(data, @"\$\(\s*\w*$")) { return((cmd == KeysCommand.CtrlSpace)? listMSBuildProperties() : ListNull); } // '#[ '<-- Match root = Regex.Match(data, @"\#\[ (?: (?'data'\S+) | \s* )$", RegexOptions.IgnorePatternWhitespace); if (root.Success) { return((cmd == KeysCommand.CtrlSpace)? listComponents(root.Groups["data"].Value) : ListNull); } // '#[...' --> Match m = Regex.Match(data, @"^\#\[ \s* (\S+) #1 - Component \s* (.+)? #2 - properties/methods etc. (optional)", RegexOptions.IgnorePatternWhitespace); if (!m.Success) { return(ListNull); } INodeInfo component = findComponent(data); if (component == null) { // hidden components: //Match hc = Regex.Match(data, @"^\s*\#\[(\S+)"); //if(hc.Groups[1].Success) { // return list(new NodeIdent(hc.Groups[1].Value, null)); //} return(ListNull); } return(find(cmd, component, (m.Groups[2].Success)? m.Groups[2].Value : null)); }
/// <summary> /// Applies the specified node configuration to the node in question. /// </summary> /// <param name="nodeInfo">Information on the node currently being inspected.</param> /// <param name="nodeConfig">The expression for node configuration.</param> public void Apply(INodeInfo nodeInfo, INodeExpression nodeConfig) { nodeConfig.WithLabel(nodeInfo.Tag.ToString()); }
private static bool ContainsNodeInfo(CSDocument document, INodeInfo nodeInfo) { var parseInfo = document.ParseInfo; var compilationUnit = parseInfo.MostRecentCompilationUnit; if (compilationUnit == null) { return(false); } foreach (var clss in compilationUnit.Classes) { foreach (var attribute in clss.Attributes) { var attributeType = attribute.AttributeType; var pluginInfoName = typeof(PluginInfoAttribute).Name; var pluginInfoShortName = pluginInfoName.Replace("Attribute", ""); if (attributeType.Name == pluginInfoName || attributeType.Name == pluginInfoShortName) { // Check name string name = null; if (attribute.NamedArguments.ContainsKey("Name")) { name = (string)attribute.NamedArguments["Name"]; } else if (attribute.PositionalArguments.Count >= 0) { name = (string)attribute.PositionalArguments[0]; } if (name != nodeInfo.Name) { continue; } // Check category string category = null; if (attribute.NamedArguments.ContainsKey("Category")) { category = (string)attribute.NamedArguments["Category"]; } else if (attribute.PositionalArguments.Count >= 1) { category = (string)attribute.PositionalArguments[1]; } if (category != nodeInfo.Category) { continue; } // Possible match bool match = true; // Check version if (!string.IsNullOrEmpty(nodeInfo.Version)) { string version = null; if (attribute.NamedArguments.ContainsKey("Version")) { version = (string)attribute.NamedArguments["Version"]; } else if (attribute.PositionalArguments.Count >= 2) { version = (string)attribute.PositionalArguments[2]; } match = version == nodeInfo.Version; } if (match) { return(true); } } } } return(false); }
protected virtual async Task <bool> DownloadBinaryPost(TumblrPost downloadItem) { string url = Url(downloadItem); if (!CheckIfFileExistsInDB(url)) { string blogDownloadLocation = blog.DownloadLocation(); string fileLocationUrlList = FileLocationLocalized(blogDownloadLocation, downloadItem.TextFileLocation); DateTime postDate = PostDate(downloadItem); string fileName = FileName(downloadItem); string fileLocation = FileLocation(blogDownloadLocation, fileName); if (url.Contains("https://mega.nz/#")) { Uri link = new Uri(url); Crawler.MegaLinkType linkType = Crawler.MegaLinkType.Single; //Determines if the MEGA link is a folder or single file based on if the url is mega.nz/#! or mega.nz/#F Regex regType = new Regex("(http[A-Za-z0-9_/:.]*mega.nz/#(.*)([A-Za-z0-9_]*))"); foreach (Match rmatch in regType.Matches(url)) { string subStr = rmatch.Groups[2].Value[0].ToString(); if (subStr == "!") { linkType = Crawler.MegaLinkType.Single; } if (subStr == "F") { linkType = Crawler.MegaLinkType.Folder; } } MegaApiClient client = new MegaApiClient(); client.LoginAnonymous(); switch (linkType) { case Crawler.MegaLinkType.Single: INodeInfo nodeInfo = client.GetNodeFromLink(link); fileName = nodeInfo.Name; fileLocation = FileLocation(blogDownloadLocation, fileName); UpdateProgressQueueInformation(Resources.ProgressDownloadImage, fileName); if (await DownloadBinaryFile(fileLocation, fileLocationUrlList, url)) { updateBlog(fileLocation, postDate, downloadItem, fileName); return(true); } client.Logout(); return(false); case Crawler.MegaLinkType.Folder: //If the link is a folder, download all files from it. IEnumerable <INode> nodes = client.GetNodesFromLink(link); List <INode> allFiles = nodes.Where(n => n.Type == NodeType.File).ToList(); foreach (INode node in allFiles) { fileName = node.Name; fileLocation = FileLocation(blogDownloadLocation, fileName); UpdateProgressQueueInformation(Resources.ProgressDownloadImage, fileName); if (await DownloadBinaryFile(fileLocation, fileLocationUrlList, url, node)) { updateBlog(fileLocation, postDate, downloadItem, fileName); } } client.Logout(); return(false); default: throw new ArgumentOutOfRangeException(); } } if (url.Contains("https://drive.google.com/")) { UserCredential credentials = Authenticate(); DriveService service = OpenService(credentials); RequestInfo(service, url, blogDownloadLocation + "\\"); } UpdateProgressQueueInformation(Resources.ProgressDownloadImage, fileName); if (await DownloadBinaryFile(fileLocation, fileLocationUrlList, url)) { updateBlog(fileLocation, postDate, downloadItem, fileName); return(true); } return(false); } else { string fileName = FileName(downloadItem); UpdateProgressQueueInformation(Resources.ProgressSkipFile, fileName); } return(true); }
public void ShowNodeReference(INodeInfo nodeInfo) { FVVVVHost.ShowNodeReference(nodeInfo); }
/// <summary> /// Returns a node of the original input graph that corresponds /// to the provided node of the <see cref="LayoutGraph"/> returned by the /// multi-page layout. /// </summary> /// <remarks> /// As the multi-page layout introduces auxiliary nodes, this method /// might return <see langword="null"/>. /// </remarks> protected INode GetModelNode(Node layoutNode) { INodeInfo nodeInfo = result.GetNodeInfo(layoutNode); return(nodeInfo.Id as INode); }
private bool IsAvailableInActivePatch(INodeInfo nodeInfo) { return(IsAvailableInActivePatch(nodeInfo, true)); }
public bool Clone(INodeInfo nodeInfo, string path, string name, string category, string version, out INodeInfo newNodeInfo) { newNodeInfo = null; return false; }
private int SortNodeInfo(INodeInfo n1, INodeInfo n2) { var s1 = NodeInfoToDisplayName(n1).ToLower(); var s2 = NodeInfoToDisplayName(n2).ToLower(); //Workaround: Following code assumes s1 and s2 are either a filename //or include an opening parenthesis. Since node info rework there're //also systemnames without any parenthesis. So for now add one if missing. if (s1.IndexOf('(') < 0) { s1 = s1 + "()"; } if (s2.IndexOf('(') < 0) { s2 = s2 + "()"; } //create a weighting index depending on the indices the tags appear in the nodenames //earlier appearance counts more int w1 = int.MaxValue, w2 = int.MaxValue; string t = ""; foreach (string tag in FTags) { t = tag.TrimStart(new char[1] { '.' }); w1 = Weight(w1, s1, t); w2 = Weight(w2, s2, t); } if (w1 != w2) { if (w1 < w2) { return(-1); } else { return(1); } } //if weights are equal, compare the nodenames string name1 = s1.Substring(0, s1.IndexOf('(')); string name2 = name2 = s2.Substring(0, s2.IndexOf('(')); //compare only the nodenames int comp = name1.CompareTo(name2); //if names are equal if (comp == 0) { //compare categories Match match = null; match = FCatRegExp.Match(s1); string cat1 = match.Success ? match.Groups[1].Value : string.Empty; match = FCatRegExp.Match(s2); string cat2 = match.Success ? match.Groups[1].Value : string.Empty; int v1, v2; //special sorting for categories v1 = FCategoryPriorities.IndexOf(cat1.Split(' ')[0].ToUpper()); v2 = FCategoryPriorities.IndexOf(cat2.Split(' ')[0].ToUpper()); if (v1 > v2) { return(-1); } else if (v1 < v2) { return(1); } else //categories are the same, compare versions { if ((cat1.Length > cat2.Length) && (cat1.Contains(cat2))) { return(1); } else if ((cat2.Length > cat1.Length) && (cat2.Contains(cat1))) { return(-1); } else { return(cat1.CompareTo(cat2)); } } } else { return(comp); } }
public bool Create(INodeInfo nodeInfo, INode host) { return false; }
public IPluginBase CreatePlugin(INodeInfo nodeInfo, IPluginHost2 pluginHost) { IPluginBase plugin = null; string assemblyLocation = string.Empty; var isUpToDate = GetAssemblyLocation(nodeInfo, out assemblyLocation); // HACK: pluginHost is null in case of WindowSwitcher/NodeBrowser/etc. Fix this. if (pluginHost != null) { // Mark the node if old assembly was loaded and log warning. if (!isUpToDate) { pluginHost.Status |= StatusCode.HasInvalidData; FLogger.Log(LogType.Warning, string.Format("Plugin of node '{0}' (ID: {1}) is out of date and couldn't be recompiled. Check its source code for errors.", nodeInfo.Username, pluginHost.GetID())); } else { pluginHost.Status &= ~StatusCode.HasInvalidData; } } var assembly = Assembly.LoadFrom(assemblyLocation); //Check if need to start anything before rest is loaded FStartableRegistry.ProcessAssembly(assembly); var type = assembly.GetType(nodeInfo.Arguments); // type can be null if assembly is corrupt or doesn't contain cached node info anymore if (type != null) { var attribute = GetPluginInfoAttributeData(type); if (attribute != null) { var pluginContainer = new PluginContainer( pluginHost as IInternalPluginHost, FIORegistry, FParentContainer, FNodeInfoFactory, this, type, nodeInfo); // We intercept the plugin to manage IOHandlers. plugin = pluginContainer; FPluginContainers[pluginContainer.PluginBase] = pluginContainer; // HACK: FPluginHost is null in case of WindowSwitcher and friends if (pluginHost != null) { AssignOptionalPluginInterfaces(pluginHost as IInternalPluginHost, pluginContainer.PluginBase); } // Send event, clients are not interested in wrapping plugin, so send original here. if (this.PluginCreated != null) { this.PluginCreated(pluginContainer.PluginBase, pluginHost); } } else { var v1Plugin = (IPlugin)assembly.CreateInstance(nodeInfo.Arguments); v1Plugin.SetPluginHost(pluginHost); plugin = v1Plugin; // HACK: FPluginHost is null in case of WindowSwitcher and friends if (pluginHost != null) { AssignOptionalPluginInterfaces(pluginHost as IInternalPluginHost, plugin); } // Send event if (this.PluginCreated != null) { this.PluginCreated(plugin, pluginHost); } } } else { pluginHost.Status |= StatusCode.HasInvalidData; FLogger.Log(LogType.Warning, string.Format("Type '{0}' not found in assembly '{1}'. Failed to create plugin node {2} (ID: {3}).", nodeInfo.Arguments, assembly.FullName, nodeInfo.Username, pluginHost.GetID())); } return(plugin); }
public bool Delete(INodeInfo nodeInfo, INode host) { return false; }
public bool Equals(INodeInfo other) { return(this.node.Equals(other) && this.ShareId == (other as PublicNode)?.ShareId); }
public bool GetNodeListAttribute(INodeInfo nodeInfo, out string name, out string value) { name = ""; value = ""; return false; }
void CNode_Loaded(object sender, RoutedEventArgs e) { ManipulationMode = ManipulationModes.TranslateX | ManipulationModes.TranslateY | ManipulationModes.Scale | ManipulationModes.Rotate; NodeViewModel vm = this.DataContext as NodeViewModel; INodeInfo info = vm.Info as INodeInfo; //this.Padding = new Thickness(5); if (info.InNeighbors != null) { INode parent = info.InNeighbors.FirstOrDefault(); if (parent != null) { this.UpdateLayout(); //Dispatcher.RunAsync(CoreDispatcherPriority.High, () => { Point diff = new Point(parent.OffsetX - OffsetX, parent.OffsetY - OffsetY); CompositeTransform trans = RenderTransform as CompositeTransform; Point to = new Point(trans.TranslateX, trans.TranslateY); Point from = new Point(to.X + diff.X, to.Y + diff.Y); DoubleAnimation x = new DoubleAnimation(); x.EasingFunction = new ExponentialEase() { EasingMode = EasingMode.EaseOut, Exponent = 5 }; DoubleAnimation y = new DoubleAnimation(); y.EasingFunction = new ExponentialEase() { EasingMode = EasingMode.EaseOut, Exponent = 5 }; x.Duration = new Duration(TimeSpan.FromMilliseconds(200)); y.Duration = new Duration(TimeSpan.FromMilliseconds(200)); x.From = from.X; y.From = from.Y; //x.To = to.X; //y.To = to.Y; Storyboard.SetTarget(x, RenderTransform); Storyboard.SetTarget(y, RenderTransform); Storyboard.SetTargetProperty(x, "TranslateX"); Storyboard.SetTargetProperty(y, "TranslateY"); Storyboard sb = new Storyboard(); sb.Children.Add(x); sb.Children.Add(y); sb.Duration = new Duration(TimeSpan.FromMilliseconds(200)); sb.Begin(); } //); //Storyboard storyboard = new Storyboard(); //RepositionThemeAnimation xani = new RepositionThemeAnimation(); //xani.FromHorizontalOffset = parent.OffsetX - OffsetX; //xani.FromVerticalOffset = parent.OffsetY - OffsetY; //xani.Duration = new Duration(TimeSpan.FromMilliseconds(200)); //Storyboard.SetTarget(xani, this); //storyboard.Children.Add(xani); //storyboard.Begin(); } } if ((this.DataContext as CustomNode).NodeAnnotations != null) { (((IEnumerable <object>)(this.DataContext as CustomNode).NodeAnnotations).ElementAt(0) as CustomLabel).PropertyChanged += CNode_PropertyChanged; } }
/// <summary> /// Initializes a new instance of the <see cref="EdgeInfo"/> class. /// </summary> /// <param name="fromNode">From node.</param> /// <param name="toNode">To node.</param> /// <param name="tag">The tag.</param> public EdgeInfo(INodeInfo fromNode, INodeInfo toNode, object tag) { FromNode = fromNode; ToNode = toNode; Tag = tag; }