public async Task OpenProject(BatProject project) { if (project != null) { await _navigationService.OpenProject(project); } }
private async Task <StorageFolder> GetProjectFolder(BatProject project, bool allowRename = false) { IStorageFolder storageFolder = await GetProjectStorageFolder(); string newFolderName = InvalidFolderCharsRegex.Replace(project.Name, "_"); StorageFolder projectFolder = null; if (!string.IsNullOrWhiteSpace(project.FolderName)) { projectFolder = await storageFolder.GetFolderAsync(project.FolderName); } if (projectFolder == null) { projectFolder = await storageFolder.CreateFolderAsync(newFolderName, CreationCollisionOption.GenerateUniqueName); } else if (allowRename && !newFolderName.Equals(project.FolderName, StringComparison.OrdinalIgnoreCase)) { await projectFolder.RenameAsync(newFolderName, NameCollisionOption.GenerateUniqueName); } project.FolderName = projectFolder.Name; return(projectFolder); }
public NodeViewModel(BatProject project, BatNode batNode, NavigationService navigationService, ProjectViewModel parentViewModel) { _project = project; _batNode = batNode; _navigationService = navigationService; EditNodeCommand = new AsyncCommand(EditNode, parentViewModel); }
public ExistingProject(BatProject project, MainViewModel mainViewModel) { Project = project; _mainViewModel = mainViewModel; OpenCommand = new AsyncParameterCommand <ExistingProject>(Open, mainViewModel); DeleteFromMruCommand = new AsyncParameterCommand <ExistingProject>(Delete, mainViewModel); }
public async Task AnalyzeNode(BatProject project, BatNode node) { StorageFolder projectFolder = await GetProjectFolder(project); if (node.NodeData == null) { await LoadNodeData(project, node); } StorageFile rawDataFile = await projectFolder.GetFileAsync(Path.Combine(node.FolderName, RawFileName)); await AnalyzeNode(project, node, rawDataFile); }
public async Task LoadNodeData(BatProject project, BatNode node) { if (node.NodeData != null) { return; } StorageFolder projectFolder = await GetProjectFolder(project); StorageFile nodeFile = await projectFolder.GetFileAsync(Path.Combine(node.FolderName, NodeFileName)); node.NodeData = await DeserializeJson <BatNodeData>(nodeFile); }
public async Task Save(BatProject project) { StorageFolder projectFolder = await GetProjectFolder(project, true); await UpdateProjectFile(project, projectFolder); foreach (BatNode node in project.Nodes) { if (node.IsDirty) { await SaveNodeData(node, projectFolder); node.IsDirty = false; } } }
private async Task UpdateProjectFile(BatProject project, StorageFolder projectFolder) { StorageFile projectFile = await projectFolder.CreateFileAsync(ProjectFileName, CreationCollisionOption.ReplaceExisting); using (Stream stream = await projectFile.OpenStreamForWriteAsync()) { using (StreamWriter writer = new StreamWriter(stream)) { using (JsonTextWriter jsonWriter = new JsonTextWriter(writer)) { JsonSerializer s = new JsonSerializer(); s.Serialize(jsonWriter, project); } } } }
public async Task <IEnumerable <BatProject> > FindAllProjects() { IStorageFolder storageFolder = await GetProjectStorageFolder(); IReadOnlyList <StorageFolder> projectFolders = await storageFolder.GetFoldersAsync(); List <BatProject> projects = new List <BatProject>(); foreach (StorageFolder projectFolder in projectFolders) { BatProject batProject = await OpenProject(projectFolder); projects.Add(batProject); } _projects = projects; return(_projects); }
public ProjectViewModel(NavigationEventArgs parameter, BatNodeLogReader batNodeLogReader, LogAnalyzer logAnalyzer, NavigationService navigationService, BatProjectManager batProjectManager) : this() { _batNodeLogReader = batNodeLogReader; _logAnalyzer = logAnalyzer; _navigationService = navigationService; _batProjectManager = batProjectManager; if (parameter.Parameter != null) { _project = (BatProject)parameter.Parameter; } else { _project = new BatProject() { Name = "Neues Projekt" }; } }
public async Task <BatNode> AddNode(BatProject project, IStorageFile rawDataFile) { BatNode newNode = new BatNode(); newNode.NodeData = new BatNodeData(); project.AddNode(newNode); StorageFolder projectFolder = await GetProjectFolder(project); StorageFolder nodeFolder = await projectFolder.CreateFolderAsync(newNode.FolderName, CreationCollisionOption.FailIfExists); await rawDataFile.CopyAsync(nodeFolder, RawFileName, NameCollisionOption.ReplaceExisting); await AnalyzeNode(project, newNode, rawDataFile); StorageFile nodeFile = await nodeFolder.CreateFileAsync(NodeFileName, CreationCollisionOption.ReplaceExisting); await SerializeJson(newNode.NodeData, nodeFile); await UpdateProjectFile(project); return(newNode); }
public void Analyze(BatProject project, BatNode node, RawNodeData rawNodeData) { BatNodeData nodeData = node.NodeData; node.IsDirty = true; node.NodeId = rawNodeData.NodeId; node.LogStart = rawNodeData.LogStart; nodeData.Calls.Clear(); List <RawCall> rawCallsToMerge = new List <RawCall>(); BatCall currentCallData = new BatCall(); nodeData.Calls.Add(currentCallData); uint endCallTime = 0; foreach (RawCall call in rawNodeData.Calls) { if (endCallTime + 50 >= call.StartTimeMs || rawCallsToMerge.Count == 0) { rawCallsToMerge.Add(call); } else { nodeData.Calls.Add(Merge(rawCallsToMerge)); rawCallsToMerge.Clear(); } endCallTime = call.EndTimeMs; } if (rawCallsToMerge.Count > 0) { nodeData.Calls.Add(Merge(rawCallsToMerge)); } }
public async Task OpenProject(BatProject project) { await NavigateTo <ProjectView>(project); }
private NodeDetailViewModel(BatProject project, BatNode node) { _project = project; Node = node; }
private async Task AnalyzeNode(BatProject project, BatNode node, IStorageFile rawDataFile) { RawNodeData rawData = await _batNodeLogReader.Load(rawDataFile); _logAnalyzer.Analyze(project, node, rawData); }
private async Task UpdateProjectFile(BatProject project) { StorageFolder projectFolder = await GetProjectFolder(project, true); await UpdateProjectFile(project, projectFolder); }
public TimeLogsModel(BatProject project) { Logs = new ObservableCollection <TimeLogModel>(); _project = project; MaxBins = 100; }
public async Task ShowNodeDetails(BatNode node, BatProject project) { await NavigateTo <NodeDetailView>(new Tuple <BatProject, BatNode>(project, node)); }