public SignalInItem(ISolutionItem parent, NodeSignalIn signalIn) : base(parent, string.Empty) { ContextMenu = extensionService.Sort(contextMenu); SignalIn = signalIn; runtimeService.SignalChanged += new SignalChangedHandler(runtimeService_SignalChanged); }
/// <summary> /// method executes via interface call when the attached view is loaded. /// </summary> void IDocumentCanUnload.OnViewLoaded() { lock (lockObject) { DocumentViewIsLoaded = true; if (this.ActionOnLoad == RequestActionOnLoad.LoadItems) { this.ActionOnLoad = RequestActionOnLoad.None; var pageViewmodel = CurrentEditPage as EditTranslationsDocumentViewModel; if (pageViewmodel != null) { ISolutionItem selectedParent = null; if (SolutionSelectedItem != null) { selectedParent = SolutionSelectedItem.GetParent(); } if (selectedParent != null) { LoadEditPage(pageViewmodel, selectedParent.ItemPathName, SolutionSelectedItem.ItemPathName); } } } } }
public static void DoPaste(ISolutionFolderNode folderNode) { System.Windows.IDataObject dataObject = SD.Clipboard.GetDataObject(); if (!DoEnablePaste(folderNode.Folder, dataObject)) { LoggingService.Warn("SolutionFolderNode.DoPaste: Pasting was not enabled."); return; } ExtTreeNode folderTreeNode = (ExtTreeNode)folderNode; if (dataObject.GetDataPresent(typeof(ISolutionItem).ToString())) { Guid guid = Guid.Parse(dataObject.GetData(typeof(ISolutionItem).ToString()).ToString()); ISolutionItem solutionItem = folderNode.Solution.GetItemByGuid(guid); if (solutionItem != null) { MoveItem(solutionItem, folderNode.Folder); ExtTreeView treeView = (ExtTreeView)folderTreeNode.TreeView; foreach (ExtTreeNode node in treeView.CutNodes) { ExtTreeNode oldParent = node.Parent as ExtTreeNode; node.Remove(); node.InsertSorted(folderTreeNode); if (oldParent != null) { oldParent.Refresh(); } } ProjectService.SaveSolution(); } } folderTreeNode.Expand(); }
/// <summary> /// Standard Constructor. /// </summary> public ProjectViewModel() { mParent = null; mTargetFiles = new ObservableCollection <ISolutionItem>(); mProjectModel = null; }
private void AddItem(ISolutionItem item) { var viewModel = new SolutionItemViewModel(itemNameRegistry, item, this); _children.Add(viewModel); _itemToViewmodel.Add(item, viewModel); }
/// <summary> /// Creates a new viewmodel for a given combination of parent and child <seealso cref="ISolutionItem"/>s. /// </summary> /// <param name="parent"></param> /// <param name="child"></param> /// <returns></returns> private DocumentViewModelBase CreateDocumentPageViewModel(ISolutionItem parent, ISolutionItem child, IProcessItems processItems) { if (child is ProjectViewModel) { return(new EditProjectDocumentViewModel(processItems, RequestedAction)); } if (child is SolutionRootViewModel) { return(new EditSolutionDocumentViewModel(processItems)); } // Is a target file under a project currently selected? var project = parent as ProjectViewModel; var fileref = child as FileReferenceViewModel; if (project != null && fileref != null) { var vm = new EditTranslationsDocumentViewModel(processItems); var optionsEngine = GetService <ISettingsManager>().Options; var group = optionsEngine.GetOptionGroup("Options"); vm.InitializeSettings(group); return(vm); } throw new System.NotImplementedException(string.Format("No default view available for {0} with child: {1}", (parent == null ? "(null)" : parent.GetType().ToString()), (child == null ? "(null)" : child.GetType().ToString()))); }
internal void CheckSolutionState(ISolutionItem item) { if (item == null) { return; } var itemExists = item as ISolutionItemExists; if (itemExists != null) { if (System.IO.File.Exists(item.ItemPathName) == true) { itemExists.SetExists(ItemExisits.DoesExist); } else { itemExists.SetExists(ItemExisits.DoesNotExist); } } foreach (var item1 in item.Children) { CheckSolutionState(item1); } }
public ProjectConfigurationPlatformMatching(IProject pProject, string configuration, string platform, SolutionItem solutionItem) { project = pProject; this.Configuration = configuration; this.Platform = platform; this.SolutionItem = solutionItem; }
private void ItemsOnCollectionChanged(object sender, NotifyCollectionChangedEventArgs notifyCollectionChangedEventArgs) { IList?newItems = notifyCollectionChangedEventArgs.NewItems; IList?oldItems = notifyCollectionChangedEventArgs.OldItems; if (newItems != null) { foreach (object varitem in newItems) { ISolutionItem item = varitem as ISolutionItem; if (item.Items != null) { item.Items.CollectionChanged += ItemsOnCollectionChanged; } } } if (oldItems != null) { foreach (object varitem in oldItems) { ISolutionItem item = varitem as ISolutionItem; if (item.Items != null) { item.Items.CollectionChanged -= ItemsOnCollectionChanged; } } } Save(); }
private void AddItemToRoot(ISolutionItem item) { var viewModel = new SolutionItemViewModel(itemNameRegistry, item); _itemToViewmodel.Add(item, viewModel); Root.Add(viewModel); }
public PageCollectionItem(ISolutionItem parent, NodePageCollection pageCollection) : base(parent, pageCollection.PageCollectionName.ToString()) { ContextMenu = extensionService.Sort(contextMenu); PageCollection = pageCollection; SetIconFromBitmap(Resources.Images.PageCollection); }
public DeviceItem(ISolutionItem parent, NodeDevice device) : base(parent, device.DeviceName.ToString()) { ContextMenu = extensionService.Sort(contextMenu); Device = device; HeaderIsEditable = true; }
public Task ReloadSolutionRemotelyTask(ISolutionItem item) { var itemName = solutionItemNameRegistry.GetName(item); return(taskRunner.ScheduleTask($"Reload {itemName} on server", async progress => { var commands = remoteCommandGenerator.GenerateCommand(item); var reduced = remoteConnectorService.Merge(commands); if (reduced.Count == 0) { progress.ReportFinished(); return; } try { for (int i = 0; i < reduced.Count; ++i) { progress.Report(i, reduced.Count, reduced[i].GenerateCommand()); await remoteConnectorService.ExecuteCommand(reduced[i]); } } catch (CouldNotConnectToRemoteServer) { // we are fine with that } progress.ReportFinished(); })); }
static bool DoEnablePaste(ISolutionFolder container, System.Windows.IDataObject dataObject) { if (dataObject == null) { return(false); } if (dataObject.GetDataPresent(typeof(ISolutionItem).ToString())) { Guid guid = Guid.Parse(dataObject.GetData(typeof(ISolutionItem).ToString()).ToString()); ISolutionItem solutionItem = container.ParentSolution.GetItemByGuid(guid); if (solutionItem == null || solutionItem == container) { return(false); } if (solutionItem is ISolutionFolder) { return(solutionItem.ParentFolder != container && !((ISolutionFolder)solutionItem).IsAncestorOf(container)); } else { return(solutionItem.ParentFolder != container); } } return(false); }
/// <summary> /// Assumes the memento is the Node ID (FieldGuid) /// </summary> /// <param name="memento"></param> /// <returns></returns> public override IDocument CreateDocument(string memento) { if (memento == null) { throw new ArgumentNullException(); } if (!m_docs.ContainsKey(memento)) { ISolutionItem item = null; if (FieldGuid.CheckSyntax(memento)) { item = solutionPad.FindItemByNodeId(new Guid(memento)) as ISolutionItem; } if (item != null && item is PageItem) { var pe = new PageEditor(item as PageItem); // adds itself to m_docs } else { return(null); } } return(m_docs[memento]); }
protected void FireInsertAfterEvent(ISolutionItem newItem) { if (runtimeService.DisconnectDialog(this)) { InsertAfter(this, newItem); } }
private void DoAddItem(ISolutionItem item) { var existing = HasSolutionItem(Root, item); if (existing == null) { if (selected == null) { solutionManager.Items.Add(item); } else if (selected.Item.Items != null && selected.Item.IsContainer) { selected.Item.Items.Add(item); } else if (selected.Parent != null) { var indexOf = selected.Parent.Item.Items?.IndexOf(selected.Item) ?? -1; if (indexOf != -1) { selected.Parent.Item.Items !.Insert(indexOf + 1, item); } } } else { SelectedItem = existing; item = existing.Item; } if (item is not SolutionFolderItem) { ea.GetEvent <EventRequestOpenItem>().Publish(item); } }
public void WriteSolutionItem(ISolutionItem item) { ISolutionFolder folder = item as ISolutionFolder; IProject project = item as IProject; if (folder != null) { WriteProjectHeader(ProjectTypeGuids.SolutionFolder, folder.Name, folder.Name, folder.IdGuid); // File items are represented as nodes in the tree, but they're actually // saved as properties on their containing folder. SolutionSection section = new SolutionSection("SolutionItems", "preProject"); foreach (var file in folder.Items.OfType <ISolutionFileItem>()) { string location = FileUtility.GetRelativePath(basePath, file.FileName); section.Add(location, location); } WriteProjectSection(section); writer.WriteLine("EndProject"); } else if (project != null) { string location = FileUtility.GetRelativePath(basePath, project.FileName); WriteProjectHeader(project.TypeGuid, project.Name, location, project.IdGuid); foreach (var section in project.ProjectSections) { WriteProjectSection(section); } writer.WriteLine("EndProject"); } }
private Task SaveSolutionToDatabaseTask(ISolutionItem item, ISolutionItemDocument?document, Func <ISolutionItem, ISolutionItemDocument?, Task <IQuery> > queryGenerator) { if (!CanSaveToDatabase) { return(Task.CompletedTask); } var itemName = solutionItemNameRegistry.GetName(item); return(taskRunner.ScheduleTask($"Export {itemName} to database", async progress => { progress.Report(0, 2, "Generate query"); var query = await queryGenerator(item, document); progress.Report(1, 2, "Execute query"); try { await sqlExecutor.ExecuteSql(query); } catch (IMySqlExecutor.QueryFailedDatabaseException e) { statusBar.PublishNotification(new PlainNotification(NotificationType.Error, "Couldn't apply SQL: " + e.Message)); throw; } progress.ReportFinished(); })); }
void LoadAndExpandToNode(FileName fileName) { IProject project = null; if (!SD.ProjectService.IsSolutionOrProjectFile(fileName)) { project = SD.ProjectService.FindProjectContainingFile(fileName); } Stack <ISolutionItem> itemsToExpand = new Stack <ISolutionItem>(); ISolutionItem item = project; if (project == null) { item = SD.ProjectService.CurrentSolution.AllItems .OfType <ISolutionFileItem>().FirstOrDefault(i => i.FileName.Equals(fileName)); } while (item != null) { itemsToExpand.Push(item); item = item.ParentFolder; } AbstractProjectBrowserTreeNode current = null; var currentChildren = treeView.Nodes; while (itemsToExpand.Any()) { var currentItem = itemsToExpand.Pop(); current = currentChildren.OfType <AbstractProjectBrowserTreeNode>().FirstOrDefault(n => n.Tag == currentItem); if (current == null) { break; } current.Expand(); currentChildren = current.Nodes; } if (project != null) { var fileItem = project.FindFile(fileName); var virtualPath = fileItem.VirtualName; if (!string.IsNullOrWhiteSpace(fileItem.DependentUpon)) { int index = virtualPath.LastIndexOf('\\') + 1; virtualPath = virtualPath.Insert(index, fileItem.DependentUpon + "\\"); } string[] relativePath = virtualPath.Split('\\'); for (int i = 0; i < relativePath.Length; i++) { current = currentChildren.OfType <AbstractProjectBrowserTreeNode>() .FirstOrDefault(n => n.Text.Equals(relativePath[i], StringComparison.OrdinalIgnoreCase)); if (current == null) { break; } current.Expand(); currentChildren = current.Nodes; } } treeView.SelectedNode = current; }
internal Section(ISolutionItem container, string name, string step, Dictionary <string, PropertyLine> lines) { Debug.Assert(lines != null); _container = container; Name = name; Step = step; _propertyLines = lines; }
public PageItem(ISolutionItem parent, NodePage page) : base(parent, page.PageName.ToString()) { ContextMenu = extensionService.Sort(contextMenu); Page = page; HeaderIsEditable = true; SetIconFromBitmap(Resources.Images.Page); }
public void RemoveItem(ISolutionItem item) { if (item is IProject project) { Items.Remove(project); ProjectReferences.Remove(CurrentDirectory.MakeRelativePath(project.Location).ToAvalonPath()); } }
public RuntimeApplicationItem(ISolutionItem parent, NodeRuntimeApplication runtimeApplication) : base(parent, runtimeApplication.Code.ToString()) { ContextMenu = extensionService.Sort(contextMenu); RuntimeApplication = runtimeApplication; SetItems(); SetIconFromBitmap(Resources.Images.Disconnected); }
private void New() { ISolutionItem item = container.Resolve <INewItemService>().GetNewSolutionItem(); if (item != null) { container.Resolve <ISolutionManager>().Items.Add(item); } }
protected override bool QueryCanDrop(ISolutionItem source) { bool canDrop = (source is PageItem); if (canDrop) { IsSelected = true; // gives some nice visual feedback to the user } return(canDrop); }
public AbstractSolutionItem(ISolutionItem parent, string header, System.Drawing.Bitmap icon) : base(parent) { if (icon == null) { throw new ArgumentNullException(m_IconName); } Header = header; SetIconFromBitmap(icon); }
protected override void OnDrop(ISolutionItem source) { base.OnDrop(source); var sourcePage = source as PageItem; if (sourcePage != null) { FireInsertAfterEvent(sourcePage); } }
internal static void MoveItem(ISolutionItem solutionItem, ISolutionFolder folder) { // Use a batch update to move the item without causing projects // be removed from the solution (and thus disposed). using (solutionItem.ParentFolder.Items.BatchUpdate()) { using (folder.Items.BatchUpdate()) { solutionItem.ParentFolder.Items.Remove(solutionItem); folder.Items.Add(solutionItem); } } }
public DiscreteOutputItem(ISolutionItem parent, NodeDiscreteOutput discreteOutput) : base(parent, string.Empty) { SetIconFromBitmap(Resources.Images.On); onIcon = Icon; SetIconFromBitmap(Resources.Images.Off); offIcon = Icon; ContextMenu = extensionService.Sort(contextMenu); DiscreteOutput = discreteOutput; runtimeService.ValueChanged += new ValueChangedHandler(runtimeService_ValueChanged); }
internal static void SetParentInternal(this ISolutionItem item, ISolutionFolder parent) { if (item.Parent != null) { item.Parent.Items.Remove(item); } item.Parent = parent; parent?.Items.InsertSorted(item); }
private ISmartScriptProjectItem?TrySerialize(ISolutionItem item) { try { return(serializer.Serialize(item)); } catch (Exception) { return(null); } }
protected override bool QueryCanDrop(ISolutionItem source) { bool canDrop = (source is PageItem); if (canDrop) { IsSelected = true; // gives some nice visual feedback to the user } return canDrop; }
public AnalogInputItem(ISolutionItem parent, NodeAnalogInput analogInput) : base(parent, string.Empty) { ContextMenu = extensionService.Sort(contextMenu); AnalogInput = analogInput; }
public StringInputItem(ISolutionItem parent, NodeStringInput stringInput) : base(parent, string.Empty) { ContextMenu = extensionService.Sort(contextMenu); StringInput = stringInput; }
public void WriteSolutionItem(ISolutionItem item) { ISolutionFolder folder = item as ISolutionFolder; IProject project = item as IProject; if (folder != null) { WriteProjectHeader(ProjectTypeGuids.SolutionFolder, folder.Name, folder.Name, folder.IdGuid); // File items are represented as nodes in the tree, but they're actually // saved as properties on their containing folder. SolutionSection section = new SolutionSection("SolutionItems", "preProject"); foreach (var file in folder.Items.OfType<ISolutionFileItem>()) { string location = FileUtility.GetRelativePath(basePath, file.FileName); section.Add(location, location); } WriteProjectSection(section); writer.WriteLine("EndProject"); } else if (project != null) { string location = FileUtility.GetRelativePath(basePath, project.FileName); WriteProjectHeader(project.TypeGuid, project.Name, location, project.IdGuid); foreach (var section in project.ProjectSections) { WriteProjectSection(section); } writer.WriteLine("EndProject"); } }
protected override bool QueryCanDrop(ISolutionItem source) { bool canDrop = (source is PageItem || source is PageCollectionItem); if (canDrop) { // Make sure we're not a child of the node being dropped var sourcePageCollection = source as PageCollectionItem; if (sourcePageCollection != null) { if (sourcePageCollection.PageCollection.GetChildrenRecursive().ContainsKey(PageCollection.ID)) { canDrop = false; } } } if (canDrop) { IsSelected = true; // gives some nice visual feedback to the user } return canDrop; }
void Page_InsertAfter(ISolutionItem sender, ISolutionItem newItem) { var senderPage = sender as PageItem; var dropPage = newItem as PageItem; if (senderPage != null && dropPage != null && senderPage != dropPage) { var page = dropPage.Page; dropPage.Delete(); Items.Add(dropPage); HookupHandlers(dropPage); PageCollection = PageCollection.NodePageChildren.InsertAfter(senderPage.Page, page); } }
public SolutionFolderEventArgs(ISolutionItem solutionFolder) { this.solutionFolder = solutionFolder; }
protected override void OnDrop(ISolutionItem source) { base.OnDrop(source); if (source != this) { if (runtimeService.DisconnectDialog(this)) { var sourcePage = source as PageItem; var sourcePageCollection = source as PageCollectionItem; if (sourcePage != null) { var page = sourcePage.Page; sourcePage.DeleteConditional(false); Items.Add(sourcePage); HookupHandlers(sourcePage); if (PageCollection.NodePageChildren.Count > 0) { PageCollection = PageCollection.NodePageChildren.InsertBefore( PageCollection.NodePageChildren.Items[0], page); } else { PageCollection = PageCollection.NodePageChildren.Append(page); } } if (sourcePageCollection != null) { var pageCollection = sourcePageCollection.PageCollection; sourcePageCollection.Delete(); Items.Add(sourcePageCollection); HookupHandlers(sourcePageCollection); if (PageCollection.NodePageCollectionChildren.Count > 0) { PageCollection = PageCollection.NodePageCollectionChildren.InsertBefore( PageCollection.NodePageCollectionChildren.Items[0], pageCollection); } else { PageCollection = PageCollection.NodePageCollectionChildren.Append(pageCollection); } } } } }