private void tvImport_AfterSelect(object sender, TreeViewEventArgs e) { ImportVariable impVar = tvImport.SelectedNode.Tag as ImportVariable; propDestination.SelectedObject = impVar != null ? impVar.Destination : null; propSource.SelectedObject = impVar != null ? impVar.Source : null; }
private void AddImportNode(TreeNode node, IBaseNode baseNode) { ImportVariable iv = node.Tag as ImportVariable; if (iv != null) { IBaseNode importNode = null; switch (iv.ImportAction) { case eImportAction.Mine: importNode = iv.Destination; break; case eImportAction.Skip: break; case eImportAction.Theirs: int index = baseNode.Nodes.IndexOf(iv.Destination); baseNode.Nodes.Remove(iv.Destination); baseNode.Nodes.Insert(index, iv.Source); importNode = iv.Source; importNode.Tree = baseNode.Tree; importNode.Parent = baseNode; break; case eImportAction.Default: if (iv.Destination != null) { iv.Destination.MergeNode(iv.Source); importNode = iv.Destination; } else { baseNode.Nodes.Add(iv.Source); importNode = iv.Source; importNode.Tree = baseNode.Tree; importNode.Parent = baseNode; } break; } if (importNode != null) { foreach (TreeNode n in node.Nodes) { AddImportNode(n, importNode); } } } }
private void AddLinkNode(TreeNode node, ref List <IBaseNode> result) { ImportVariable iv = node.Tag as ImportVariable; if (iv != null && iv.ImportAction == eImportAction.Mine) { result.Add(iv.Source); } foreach (TreeNode n in node.Nodes) { AddLinkNode(n, ref result); } }
private void AddTemplateNode(TreeNode node, List <IBaseNode> result, IBaseNode parent) { ImportVariable iv = node.Tag as ImportVariable; if (iv != null) { IBaseNode importNode = null; switch (iv.ImportAction) { case eImportAction.Mine: importNode = iv.Destination.Clone();; importNode.Reference = iv.Destination.Reference; importNode.Tree = parent.Tree; importNode.Parent = parent; break; case eImportAction.Theirs: importNode = iv.Source.Clone(); importNode.Reference = iv.Source.Reference; importNode.Tree = parent.Tree; importNode.Parent = parent; break; case eImportAction.Default: if (iv.Destination != null) { iv.Destination.MergeNode(iv.Source); importNode = iv.Destination; } else { importNode = iv.Source.Clone(); importNode.Reference = iv.Source.Reference; importNode.Tree = parent.Tree; importNode.Parent = parent; } break; } if (importNode != null) { result.Add(importNode); foreach (TreeNode n in node.Nodes) { AddTemplateNode(n, importNode.Nodes, importNode); } } } }
private void tvConflicts_DrawNode(object sender, DrawTreeNodeEventArgs e) { TreeView tv = sender as TreeView; if (e.Node == null || e.Node.Tag == null) { e.DrawDefault = true; return; } ImportVariable tvItem = e.Node.Tag as ImportVariable; int offs = e.Node.Level * tv.Indent; Rectangle bounds = e.Bounds; bounds.X += offs; if ((e.State & TreeNodeStates.Selected) == TreeNodeStates.Selected) { e.Graphics.FillRectangle(new SolidBrush(SystemColors.MenuHighlight), bounds); e.Graphics.DrawImage(imageList.Images[tvItem.ImageIndex], bounds.X, bounds.Y, tv.ItemHeight, tv.ItemHeight); //e.Graphics.DrawString(tvItem.Name, tv.Font, new SolidBrush(SystemColors.ButtonHighlight), bounds.X + tv.ItemHeight, bounds.Y); } else { e.Graphics.FillRectangle(new SolidBrush(SystemColors.Window), bounds); e.Graphics.DrawImage(imageList.Images[tvItem.ImageIndex], bounds.X, bounds.Y, tv.ItemHeight, tv.ItemHeight); e.Graphics.DrawString(tvItem.Name, tv.Font, new SolidBrush(SystemColors.MenuText), bounds.X + tv.ItemHeight, bounds.Y); } int imageIndex = 0; switch (tvItem.ImportAction) { case eImportAction.Mine: imageIndex = 5; break; case eImportAction.Theirs: imageIndex = 6; break; case eImportAction.Skip: imageIndex = 7; break; } if (imageIndex > 0) { e.Graphics.DrawImage(imageList.Images[imageIndex], bounds.X, bounds.Y, tv.ItemHeight, tv.ItemHeight); } //e.DrawFocusRectangle(); }
private void ExecuteUnskip(TreeNode node) { ImportVariable impVar = node != null ? node.Tag as ImportVariable : null; if (impVar != null) { impVar.UnskipImportAction(); node.ImageIndex = impVar.ImageIndex; node.SelectedImageIndex = impVar.ImageIndex; foreach (TreeNode n in node.Nodes) { ExecuteUnskip(n); } } }
private void AddLevel(TreeNode node, IBaseNode destination, IBaseNode source) { if (destination != null) { foreach (IBaseNode dest in destination.Nodes) { ImportVariable iv = new ImportVariable(dest); iv.Source = FindNode(source, dest); TreeNode newNode = iv.GetTreeNode(); node.Nodes.Add(newNode); if (!iv.Equality.HasEqualityType(eVariableEquality.equal)) { node.Expand(); } if (iv.Destination.NodeType == eNodeType.DomainObject) { AddLevel(newNode, iv.Destination, iv.Source); } } } if (source != null) { foreach (IBaseNode src in source.Nodes) { if (FindNode(destination, src) == null) { ImportVariable iv = new ImportVariable(); iv.Source = src; TreeNode newNode = iv.GetTreeNode(); node.Nodes.Add(newNode); if (iv.Source.NodeType == eNodeType.DomainObject) { AddLevel(newNode, iv.Destination, iv.Source); } } } } }
private void mnuImportMine_Click(object sender, EventArgs e) { ImportVariable impVar = tvImport.SelectedNode.Tag as ImportVariable; if (impVar != null) { if (impVar.CanUseMine) { impVar.ToggleImportAction(eImportAction.Mine, impVar.CanUseTheirs ? eImportAction.Theirs : eImportAction.Default); } tvImport.SelectedNode.ImageIndex = impVar.ImageIndex; tvImport.SelectedNode.SelectedImageIndex = impVar.ImageIndex; tvImport.Refresh(); btnOk.Enabled = CanImport; } }
private void mnuImportSkip_Click(object sender, EventArgs e) { ImportVariable impVar = tvImport.SelectedNode.Tag as ImportVariable; if (impVar != null) { if (impVar.ImportAction == eImportAction.Skip) { ExecuteUnskip(tvImport.SelectedNode); } else { ExecuteSkip(tvImport.SelectedNode); } tvImport.Refresh(); btnOk.Enabled = CanImport; } }
private ImportVariable GetImportVariable(IBaseNode dest) { ImportVariable result = null; switch (ImportMode) { case eImportMode.Import: result = new ImportVariable(dest); break; case eImportMode.Link: result = new LinkVariable(dest); break; case eImportMode.Template: result = new TemplateVariable(dest); break; } return(result); }
private void Listbox_DrawItem(object sender, DrawItemEventArgs e) { ListBox lbx = sender as ListBox; ImportVariable lbItem = lbx.Items[e.Index] as ImportVariable; if ((e.State & DrawItemState.Selected) == DrawItemState.Selected) { e.Graphics.FillRectangle(new SolidBrush(SystemColors.MenuHighlight), e.Bounds); e.Graphics.DrawImage(imageList.Images[lbItem.ImageIndex], e.Bounds.X, e.Bounds.Y, lbx.ItemHeight, lbx.ItemHeight); e.Graphics.DrawString(lbItem.Name, lbx.Font, new SolidBrush(SystemColors.ButtonHighlight), e.Bounds.X + lbx.ItemHeight, e.Bounds.Y); } else { e.Graphics.FillRectangle(new SolidBrush(SystemColors.Window), e.Bounds); e.Graphics.DrawImage(imageList.Images[lbItem.ImageIndex], e.Bounds.X, e.Bounds.Y, lbx.ItemHeight, lbx.ItemHeight); e.Graphics.DrawString(lbItem.Name, lbx.Font, new SolidBrush(SystemColors.MenuText), e.Bounds.X + lbx.ItemHeight, e.Bounds.Y); } int imageIndex = 0; switch (lbItem.ImportAction) { case eImportAction.Mine: imageIndex = 5; break; case eImportAction.Theirs: imageIndex = 6; break; case eImportAction.Skip: imageIndex = 7; break; } if (imageIndex > 0) { e.Graphics.DrawImage(imageList.Images[imageIndex], e.Bounds.X, e.Bounds.Y, lbx.ItemHeight, lbx.ItemHeight); } e.DrawFocusRectangle(); }
private void mnuImportTheirs_Click(object sender, EventArgs e) { ImportVariable impVar = tvImport.SelectedNode.Tag as ImportVariable; if (impVar != null) { if (impVar.ImportAction == eImportAction.Skip) { ExecuteUnskip(tvImport.SelectedNode); } if (impVar.CanUseTheirs) { impVar.ToggleImportAction(eImportAction.Theirs, impVar.CanUseMine ? eImportAction.Mine : eImportAction.Default); } tvImport.SelectedNode.ImageIndex = impVar.ImageIndex; tvImport.SelectedNode.SelectedImageIndex = impVar.ImageIndex; tvImport.Refresh(); btnOk.Enabled = CanImport; } }
private void tvImport_MouseDown(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Right) { TreeNode currentNode = tvImport.GetNodeAt(e.Location); tvImport.SelectedNode = currentNode; switch (ImportMode) { case eImportMode.Import: case eImportMode.Template: ImportVariable lbItem = currentNode.Tag as ImportVariable; if (lbItem != null) { mnuImportMine.Enabled = lbItem.CanUseMine; mnuImportTheirs.Enabled = lbItem.CanUseTheirs; mnuImportSkip.Enabled = !lbItem.CanUseMine; mnuImport.Show(tvImport.PointToScreen(e.Location)); } break; } } }