/// <summary> /// 添加新项; /// </summary> protected void AddNewItem() { if (this.TheFactory == null || this.TheFactory.TempWizard == null) { return; } this.TheFactory.TempWizard.RunCreateFileWizard(this.FullPath, this.Type, (file, type) => { ViFileInfo child = ViFileInfo.CreateFile(type, file); this.AddChild(child); }); }
public override void ExecutedCommand(object sender, System.Windows.Input.ExecutedRoutedEventArgs e) { if (e.Command == ViCommands.AddNewItem) { this.TheFactory.TempWizard.RunCreateFileWizard(this.DirectoryPath, this.Type, (file, type) => { this.AddChild(ViFileInfo.CreateFile(type, file)); }); } else if (e.Command == ViCommands.AddExistingItem) { } base.ExecutedCommand(sender, e); }
public override bool LoadElement(XmlElement element) { if (element == null || !Constants.TAG.CPU.Equals(element.Name, StringComparison.OrdinalIgnoreCase)) { return(false); } bool bValue; int iValue; this.Name = element.GetAttribute(Constants.Attribute.Name); String sActive = element.GetAttribute(Constants.Attribute.IsActive); this.IsActive = Boolean.TryParse(sActive, out bValue) && bValue; foreach (XmlNode groupElement in element.ChildNodes) { // Settings if (Constants.TAG.Settings.Equals(groupElement.Name, StringComparison.OrdinalIgnoreCase)) { this.HardwareType = (groupElement as XmlElement).GetAttribute(Constants.Attribute.HwType); String hasShm = (groupElement as XmlElement).GetAttribute(Constants.Attribute.HasShmVars); if (Boolean.TryParse(hasShm, out bValue)) { this.HasShmVars = bValue; } foreach (XmlNode itemElement in groupElement.ChildNodes) { // connection if (Constants.TAG.Connection.Equals(itemElement.Name)) { this.TcpPort = (itemElement as XmlElement).GetAttribute(Constants.Attribute.TcpPort); this.TcpIp = (itemElement as XmlElement).GetAttribute(Constants.Attribute.TcpIp); } } } // Tasks else if (Constants.TAG.Tasks.Equals(groupElement.Name, StringComparison.OrdinalIgnoreCase)) { foreach (XmlNode itemElement in groupElement.ChildNodes) { // Task if (Constants.TAG.Task.Equals(itemElement.Name)) { String name = (itemElement as XmlElement).GetAttribute(Constants.Attribute.Name); String type = (itemElement as XmlElement).GetAttribute(Constants.Attribute.Type); String priority = (itemElement as XmlElement).GetAttribute(Constants.Attribute.Priority); ViTaskInfo task = ViTaskInfo.CreateTaskInfo(type, name, Int32.TryParse(priority, out iValue) ? iValue : 0); if (task != null) { this.Tasks.SortedAdd(task); } task.LoadElement(itemElement as XmlElement); } } } // Files else if (Constants.TAG.Files.Equals(groupElement.Name, StringComparison.OrdinalIgnoreCase)) { foreach (XmlNode fileElement in groupElement.ChildNodes) { var fileType = (fileElement as XmlElement).GetAttribute(Constants.Attribute.FileType); var filePath = (fileElement as XmlElement).GetAttribute(Constants.Attribute.FilePath); var fileLinked = (fileElement as XmlElement).GetAttribute(Constants.Attribute.Linked); ViFileInfo fileInfo = ViFileInfo.CreateFile(fileType, filePath); if (fileInfo != null) { if (Boolean.TryParse(fileLinked, out bValue)) { fileInfo.Linked = bValue; } this.AddChild(fileInfo); } } } } return(true); }