protected virtual void updateContextStatusBar(GISATreeNode node) { if (!(MasterPanel.isContextPanel(this))) { return; } if (node == null || node.NivelRow.RowState == DataRowState.Detached) { ((frmMain)TopLevelControl).StatusBarPanelHint.Text = string.Empty; } else { GISADataset.RelacaoHierarquicaRow rhRow = ((GISATreeNode)node).RelacaoHierarquicaRow; GISADataset.TipoNivelRelacionadoRow tnrRow = TipoNivelRelacionado.GetTipoNivelRelacionadoFromRelacaoHierarquica(rhRow); ArrayList pathEstrut = ControloNivelList.GetCodigoCompletoCaminhoUnico(node); if (pathEstrut.Count == 0) { ((frmMain)TopLevelControl).StatusBarPanelHint.Text = string.Format(" {0}: {1}", tnrRow.Designacao, node.NivelRow.Codigo); } else { ((frmMain)TopLevelControl).StatusBarPanelHint.Text = string.Format(" {0}: {1}", tnrRow.Designacao, Nivel.buildPath(pathEstrut)); } } }
protected virtual bool UpdateContext(GISATreeNode node) { // foi selecionado um nível estrutural bool successfulSave = false; GISADataset.NivelRow nRow = null; if (this.nivelNavigator1.SelectedNode != null) { node = this.nivelNavigator1.SelectedNode; nRow = ((GISATreeNode)node).NivelRow; successfulSave = UpdateContext(nRow); } else { nRow = null; successfulSave = UpdateContext(nRow); } if (successfulSave) { updateContextStatusBar(node); } return(successfulSave); }
public void CollapseNodes(ArrayList foundNodes) { try { GISATreeNode collapsableNode = null; foreach (GISATreeNode foundNode in foundNodes) { if (foundNode.Parent == null) { collapsableNode = foundNode; // para as relações com EDs } else { collapsableNode = (GISATreeNode)foundNode.Parent; // para as outras relações colapsar a relação pai de forma a contemplar o caso de não existirem filhos } collapsableNode.Collapse(); } // simular uma selecção do último nó colapsado, no caso de ter sido colapsado algum if (collapsableNode != null) { beforeNewSelection(collapsableNode); //, CurrentTreeView Is trVwSeries) afterNewSelection(collapsableNode); } } catch (Exception ex) { Trace.WriteLine(ex); Debug.Assert(false, ex.ToString()); throw ex; } }
// Actualiza o contexto de acordo com o nó actualmente selecionado public override bool UpdateContext() { if (this.nivelNavigator1.PanelToggleState == NivelNavigator.ToggleState.Estrutural) { if (this.nivelNavigator1.EPFilterMode) { ListViewItem item = null; if (this.nivelNavigator1.SelectedItems.Count > 0) { item = this.nivelNavigator1.SelectedItems[0]; } return(UpdateContext(item)); } else { GISATreeNode node = this.nivelNavigator1.SelectedNode; return(UpdateContext(node)); } } else { ListViewItem item = null; if (this.nivelNavigator1.SelectedItems.Count > 0) { item = this.nivelNavigator1.SelectedItems[0]; } return(UpdateContext(item)); } }
protected override void AcceptContents(object Value) { GISADataset.NivelRow nivelRow = null; GISATreeNode node = null; ListViewItem item = null; if (Value is GISADataset.NivelRow) { nivelRow = (GISADataset.NivelRow)Value; if (AcceptNivelRow != null) { AcceptNivelRow(nivelRow); } } else if (Value is GISATreeNode) { node = (GISATreeNode)Value; if (AcceptNode != null) { AcceptNode(node); } } else if (Value is ListViewItem) { item = (ListViewItem)Value; if (AcceptItem != null) { AcceptItem(item); } } }
private void afterNewSelection(GISATreeNode node) { if (UpdateToolBarButtonsEvent != null) UpdateToolBarButtonsEvent(new EventArgs()); if (node != null && node.NivelRow.RowState != DataRowState.Detached && node.Nodes.Count == 0) AddToTable(node); }
// constroi uma chave que permite indexar um nó na hashtable public static string getKey(GISATreeNode node) { if (node.NivelUpperRow == null) { return node.NivelRow.ID.ToString() + ":"; } else { return node.NivelRow.ID.ToString() + ":" + node.NivelUpperRow.ID.ToString(); } }
private GISADataset.NivelRow GetSelectedNivelRowED(GISATreeNode selectedNode) { GISATreeNode parentNode = selectedNode; while (parentNode.Parent != null) { parentNode = (GISATreeNode)parentNode.Parent; } return(parentNode.NivelRow); }
//INSTANT C# NOTE: C# does not support optional parameters. Overloaded method(s) are created above. //ORIGINAL LINE: Private Sub AddToTreeview(ByVal nodes As TreeNodeCollection, ByVal node As GISATreeNode, Optional ByVal insertAt As Integer = -1) private void AddToTreeview(TreeNodeCollection nodes, GISATreeNode node, int insertAt) { if (insertAt == -1) { nodes.Add(node); } else { nodes.Insert(insertAt, node); } AddToTable(node); }
private void trVwLocalizacao_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e) { // Find the node under the mouse. GISATreeNode currentNode = (GISATreeNode)(trVwLocalizacao.GetNodeAt(e.X, e.Y)); if (currentNode == trVwLocalizacao_MouseMove_previousNode) return; trVwLocalizacao_MouseMove_previousNode = currentNode; // See if we have a valid node under mouse pointer if (setToolTipEvent != null) setToolTipEvent(this, currentNode); }
//INSTANT C# NOTE: C# does not support optional parameters. Overloaded method(s) are created above. //ORIGINAL LINE: Public Sub RemoveFromTreeview(ByVal node As GISATreeNode, Optional ByVal key As String = null) public void RemoveFromTreeview(GISATreeNode node, string key) { Hashtable table = tableEstrutural; node.Remove(); if (table != null) { object somethingAlreadyThere = null; ArrayList nodesAlreadyThere = null; GISATreeNode nodeAlreadyThere = null; if (key == null) { somethingAlreadyThere = table[getKey(node)]; } else { somethingAlreadyThere = table[key]; } if (somethingAlreadyThere is GISATreeNode) { table.Remove(somethingAlreadyThere); } else // trata-se de um arraylist { Debug.Assert(somethingAlreadyThere is ArrayList); nodesAlreadyThere = (ArrayList)somethingAlreadyThere; //For Each nodeAlreadyThere As GISATreeNode In nodesAlreadyThere // If nodeAlreadyThere Is node Then // nodesAlreadyThere.Remove(nodeAlreadyThere) // End If //Next int i = 0; while (i < nodesAlreadyThere.Count) { nodeAlreadyThere = (GISATreeNode)(nodesAlreadyThere[i]); if (nodeAlreadyThere == node) { nodesAlreadyThere.Remove(nodeAlreadyThere); } else { i = i + 1; } } } } }
private void AddNivelDesignado(TreeNodeCollection TargetNodes, GISADataset.NivelRow nRow, GISADataset.NivelRow nUpperRow, GISADataset.TipoNivelRelacionadoRow tnrRow, IDbConnection connection) { GISATreeNode node = new GISATreeNode(Nivel.GetDesignacao(nRow)); node.NivelRow = nRow; node.NivelUpperRow = nUpperRow; if (node.RelacaoHierarquicaRow != null) { string data = FormatYearsInterval(node.RelacaoHierarquicaRow); if (data.Length > 0) node.Text = string.Format("{0} {1}", node.Text, data); } int iconIndex = 0; iconIndex = -1; if (tnrRow != null) iconIndex = System.Convert.ToInt32(tnrRow.GUIOrder); if (nRow.CatCode.Trim().Equals("CA")) node.ImageIndex = iconIndex == -1 ? SharedResourcesOld.CurrentSharedResources.NivelImageIncognitoControloAut() : SharedResourcesOld.CurrentSharedResources.NivelImageControloAut(iconIndex); else node.ImageIndex = iconIndex == -1 ? SharedResourcesOld.CurrentSharedResources.NivelImageIncognito() : SharedResourcesOld.CurrentSharedResources.NivelImageBase(iconIndex); node.SelectedImageIndex = node.ImageIndex; try { if (nUpperRow == null) { if (DBAbstractDataLayer.DataAccessRules.NivelRule.Current.getDirectChildCount(nRow.ID.ToString(), "rh.IDTipoNivelRelacionado != 11", connection) > 0) node.Nodes.Add("<A atualizar...>"); } else { long a = DateTime.Now.Ticks; if (DBAbstractDataLayer.DataAccessRules.NivelRule.Current.EstimateChildCount(nUpperRow.ID.ToString(), true, connection).Contains(nRow.ID)) node.Nodes.Add("<A atualizar...>"); long b = DateTime.Now.Ticks; accum += (b - a); } } catch (Exception ex) { Trace.WriteLine(ex); throw; } AddToTreeview(TargetNodes, node, -1); }
public static ArrayList GetCodigoCompletoCaminhoUnico(GISATreeNode currentNode) { GISADataset.RelacaoHierarquicaRow rhCurrentRow = null; ArrayList result = new ArrayList(); while (currentNode != null) { // prever o caso em que um dos nós do caminho foi eliminado (por // outro utilizador). nesse caso não é possível calcular o caminho if (currentNode.NivelRow.RowState == DataRowState.Detached) return null; rhCurrentRow = currentNode.RelacaoHierarquicaRow; if (rhCurrentRow != null) result.Insert(0, rhCurrentRow); currentNode = (GISATreeNode)currentNode.Parent; } return result; }
public void SelectParentNode(GISATreeNode parentNode) { // parentNode será nothing no caso de eliminarmos o último // nível apresentado (pode ser a ED na vista da estrutura ou // pode ser um nível de estrutura que seja usado como raiz // na vista de documentos) trVwLocalizacao.SelectedNode = parentNode; if (trVwLocalizacao.SelectedNode != null) { trVwLocalizacao.SelectedNode.Collapse(); if (trVwLocalizacao.SelectedNode.Nodes.Count == 0) { trVwLocalizacao.SelectedNode.Nodes.Add("<A atualizar...>"); } trVwLocalizacao.SelectedNode.Collapse(); trVwLocalizacao.SelectedNode.Expand(); } else { // Chegamos a este ponto se estivermos na vista estrutural e // se não existir um nó pai para selecionar após a eliminação // do nó actual. No entanto, na vista estrutural podemos ter // vários nós raiz (várias EDs), por isso ao eliminarmos uma // das raizes podemos tentar selecionar uma outra que possa existir if (trVwLocalizacao.Nodes.Count > 0) { trVwLocalizacao.SelectedNode = trVwLocalizacao.Nodes[0]; } else { // Apenas no caso de termos removido o último nó existente // é que se dará o caso de não existir uma selecção. // Colocar o SelectedNode a Nothing não é o suficiente // para provocar um BeforeSelect na treeview, por isso // forçamos um. TreeViewCancelEventArgs cea = null; cea = new TreeViewCancelEventArgs(null, false, TreeViewAction.Unknown); this.treeviews_BeforeSelect(this, cea); } } }
private void treeviews_BeforeSelect(object Sender, TreeViewCancelEventArgs e) { long start = 0; start = DateTime.Now.Ticks; GISATreeNode node = (GISATreeNode)e.Node; PermissoesHelper.UpdateNivelPermissions(node.NivelRow, SessionHelper.GetGisaPrincipal().TrusteeUserOperator.ID); try { bool selectionChange = beforeNewSelection(node); if (! selectionChange) e.Cancel = true; } catch (InvalidOperationException) { e.Cancel = true; } Debug.WriteLine("<<treeviews_BeforeSelect>>: " + new TimeSpan(DateTime.Now.Ticks - start).ToString()); }
private string GetCodigoCompleto(object element) { MasterPanelPermissoesPlanoClassificacao mpPPC = (MasterPanelPermissoesPlanoClassificacao)(((frmMain)this.TopLevelControl).MasterPanel); string nCod = null; if (element is GISATreeNode) { GISATreeNode node = (GISATreeNode)element; ArrayList pathEstrut = ControloNivelList.GetCodigoCompletoCaminhoUnico(node); if (pathEstrut.Count == 0) { nCod = node.NivelRow.Codigo; } else { nCod = Nivel.buildPath(pathEstrut); } } else if (element is ListViewItem) { ListViewItem item = (ListViewItem)element; GISADataset.RelacaoHierarquicaRow rhRow = (GISADataset.RelacaoHierarquicaRow)(GisaDataSetHelper.GetInstance().RelacaoHierarquica.Select(string.Format("ID={0} AND IDUpper={1}", ((GISADataset.NivelRow)item.Tag).ID, mpPPC.nivelNavigator1.ContextBreadCrumbsPathID))[0]); GISADataset.TipoNivelRelacionadoRow tnrRow = TipoNivelRelacionado.GetTipoNivelRelacionadoFromRelacaoHierarquica(rhRow); ArrayList pathEstrut = ControloNivelList.GetCodigoCompletoCaminhoUnico(mpPPC.nivelNavigator1.SelectedNode); ArrayList pathDoc = mpPPC.nivelNavigator1.GetCodigoCompletoCaminhoUnico(item); if (pathDoc.Count == 0 && pathEstrut.Count == 0) { nCod = tnrRow.Designacao; } else { nCod = string.Format("{0}/{1}", Nivel.buildPath(pathEstrut), Nivel.buildPath(pathDoc)); } } return(nCod); }
private bool beforeNewSelection(GISATreeNode node) { bool selectionChange = false; // prever a situações onde não se está dentro do frmMain this.Cursor = Cursors.WaitCursor; trVwLocalizacao.BeginUpdate(); try { BeforeNewSelectionEventArgs e = new BeforeNewSelectionEventArgs(null, null); if (node == null) { e.nivel = null; e.node = null; if (beforeNewSelectionEvent != null) beforeNewSelectionEvent(e); selectionChange = e.selectionChange; } else { GISADataset.NivelRow nRow = node.NivelRow; e.nivel = nRow; e.node = node; if (beforeNewSelectionEvent != null) beforeNewSelectionEvent(e); selectionChange = e.selectionChange; } } finally { trVwLocalizacao.EndUpdate(); this.Cursor = Cursors.Default; } return selectionChange; }
// Devolve todas as aparições de determinada relação na árvore. // Uma dada relação pode constar várias vezes no caso de um determinado nó // superior ter vários pais public ArrayList getNodeRepresentations(string ID, string IDUpper) { string key = getKey(ID, IDUpper); object somethingEstrutural = tableEstrutural[key]; GISATreeNode foundNode = null; ArrayList foundNodes = null; // Ignorar o nó se este não for encontrado em nenhuma das hashtables if (somethingEstrutural != null) { if (somethingEstrutural != null) { if (somethingEstrutural is GISATreeNode) { foundNode = (GISATreeNode)somethingEstrutural; } else { foundNodes = (ArrayList)somethingEstrutural; } } if (foundNode != null) { foundNodes = new ArrayList(); foundNodes.Add(foundNode); } } if (foundNodes == null) { foundNodes = new ArrayList(); } return foundNodes; }
private void AddToTreeview(TreeNodeCollection nodes, GISATreeNode node) { AddToTreeview(nodes, node, -1); }
public void RemoveFromTreeview(GISATreeNode node, string key) { this.controloNivelListEstrutural1.RemoveFromTreeview(node, key); }
private void ExpandNivel(GISATreeNode node) { GISADataset.NivelRow CurrentNivelUpperRow = node.NivelUpperRow; GISADataset.NivelRow CurrentNivelRow = node.NivelRow; long startTicks = 0; if (CurrentNivelRow == null || CurrentNivelRow.RowState == DataRowState.Detached) node.Nodes.Clear(); else { try { // prever a situações onde não se está dentro do frmMain this.Cursor = Cursors.WaitCursor; GisaDataSetHelper.HoldOpen ho = new GisaDataSetHelper.HoldOpen(GisaDataSetHelper.GetConnection()); try { GisaDataSetHelper.ManageDatasetConstraints(false); startTicks = DateTime.Now.Ticks; var filhos = DBAbstractDataLayer.DataAccessRules.NivelRule.Current.GetNivelChildren(CurrentNivelRow.ID, SessionHelper.GetGisaPrincipal().TrusteeUserOperator.ID, TipoNivelRelLimitExcl(), ho.Connection); DBAbstractDataLayer.DataAccessRules.NivelRule.Current.LoadNivelChildren(CurrentNivelRow.ID, true, GisaDataSetHelper.GetInstance(), ho.Connection); Debug.WriteLine("<<Get Tree Nodes>>: " + new TimeSpan(DateTime.Now.Ticks - startTicks).ToString()); GisaDataSetHelper.ManageDatasetConstraints(true); startTicks = DateTime.Now.Ticks; trVwLocalizacao.BeginUpdate(); node.Nodes.Clear(); accum = 0; int iconIndex = 0; foreach (DBAbstractDataLayer.DataAccessRules.NivelRule.MyNode filho in filhos) //DBAbstractDataLayer.DataAccessRules.NivelRule.Current.GetSortedData(CurrentNivelRow.ID, ho.Connection) { iconIndex = System.Convert.ToInt32(filho.TipoNivelRelacionado); GISATreeNode newNode = new GISATreeNode(filho.Designacao); if (filho.TipoNivel.Trim().Equals("CA")) newNode.ImageIndex = iconIndex == -1 ? SharedResourcesOld.CurrentSharedResources.NivelImageIncognitoControloAut() : SharedResourcesOld.CurrentSharedResources.NivelImageControloAut(iconIndex); else newNode.ImageIndex = iconIndex == -1 ? SharedResourcesOld.CurrentSharedResources.NivelImageIncognito() : SharedResourcesOld.CurrentSharedResources.NivelImageBase(iconIndex); newNode.SelectedImageIndex = newNode.ImageIndex; if (filho.AnoFim != null || filho.AnoInicio != null) { string data = FormatYearsInterval(filho.AnoInicio, filho.AnoFim); if (data.Length > 0) newNode.Text = string.Format("{0} {1}", newNode.Text, data); } try { long a = DateTime.Now.Ticks; if (filho.Age > 0) newNode.Nodes.Add("<A actualizar...>"); long b = DateTime.Now.Ticks; accum += (b - a); } catch (Exception ex) { Trace.WriteLine(ex); throw; } newNode.NivelRow = (GISADataset.NivelRow)(GisaDataSetHelper.GetInstance().Nivel.Select("ID = " + filho.IDNivel.ToString())[0]); newNode.NivelUpperRow = node.NivelRow; node.Nodes.Add(newNode); AddToTable(newNode); } trVwLocalizacao.EndUpdate(); Debug.WriteLine("<<EstimateChildCount>>: " + new TimeSpan(accum).ToString()); Debug.WriteLine("<<Populate Tree Nodes>>: " + new TimeSpan(DateTime.Now.Ticks - startTicks).ToString()); } catch (System.Data.ConstraintException ex) { Trace.WriteLine(ex); Debug.Assert(false, ex.ToString()); GisaDataSetHelper.FixDataSet(GisaDataSetHelper.GetInstance(), ho.Connection); } finally { ho.Dispose(); } } finally { this.Cursor = Cursors.Default; } } }
public itemDragSelectionEventArgs(GISATreeNode node, GISADataset.NivelRow nivel) { this.node = node; this.nivel = nivel; }
public BeforeNewSelectionEventArgs(GISATreeNode node, GISADataset.NivelRow nivel) : base() { this.node = node; this.nivel = nivel; }
private void AcceptNode(GISATreeNode node) { string codigoCompleto = GetCodigoCompleto(node); acceptAssociation(((GISATreeNode)node).NivelRow, codigoCompleto); }
private void SeleccaoActual(out GISADataset.NivelRow NivelRow, out GISADataset.TipoNivelRelacionadoRow TnrRow) { //Obter selecção actual GISATreeNode selectedNode = null; GISADataset.NivelRow nRow = null; GISADataset.NivelRow nUpperRow = null; GISADataset.RelacaoHierarquicaRow rhRow = null; GISADataset.TipoNivelRelacionadoRow tnrRow = null; // Estas variaveis identificam o contexto definido pelo breadcrumbspath da vista documental // (só são usadas quando a vista actual é a documental) GISADataset.NivelRow nRowBC = null; GISADataset.NivelRow nUpperRowBC = null; GISADataset.RelacaoHierarquicaRow rhRowBC = null; GISADataset.TipoNivelRelacionadoRow tnrRowBC = null; if (this.mPanelToggleState == ToggleState.Estrutural) { //vista estrutural if (mEPFilterMode) { var selItem = this.nivelEstruturalList1.SelectedItems.FirstOrDefault(); if (selItem != null) { nRow = selItem.Tag as GISADataset.NivelRow; } } else { selectedNode = (GISATreeNode)this.controloNivelListEstrutural1.SelectedNode; if (selectedNode != null && !(selectedNode.NivelRow.RowState == DataRowState.Detached)) { nRow = selectedNode.NivelRow; nUpperRow = selectedNode.NivelUpperRow; } } } else { //vista documental if (!(this.nivelDocumentalListNavigator1.SelectedItems.Count == 0)) { nRow = (GISADataset.NivelRow)(this.nivelDocumentalListNavigator1.SelectedItems[0].Tag); } if (nRow != null && !(nRow.RowState == DataRowState.Detached)) { nUpperRow = nRow.GetRelacaoHierarquicaRowsByNivelRelacaoHierarquica()[0].NivelRowByNivelRelacaoHierarquicaUpper; } } if (nRow != null && !(nRow.RowState == DataRowState.Detached) && nUpperRow == null) { if (this.mPanelToggleState == ToggleState.Estrutural && this.mEPFilterMode) { rhRow = nRow.GetRelacaoHierarquicaRowsByNivelRelacaoHierarquica().FirstOrDefault(); tnrRow = TipoNivelRelacionado.GetTipoNivelRelacionadoFromRelacaoHierarquica(rhRow); } else { tnrRow = TipoNivelRelacionado.GetTipoNivelRelacionadoFromRelacaoHierarquica(null); } } else if (nUpperRow != null && !(nUpperRow.RowState == DataRowState.Detached) && nRow != null && !(nRow.RowState == DataRowState.Detached)) { if (this.mPanelToggleState == ToggleState.Estrutural) { rhRow = selectedNode.RelacaoHierarquicaRow; // excluimos desta forma as relacoes hirarquicas entretanto eliminadas (as que seriam NULL mas cujo nó respectivo teria um NivelUpper) if (selectedNode.NivelUpperRow != null && rhRow != null) { tnrRow = TipoNivelRelacionado.GetTipoNivelRelacionadoFromRelacaoHierarquica(rhRow); } } else { //Documental if (nRow != null) { DataRow[] rhRows = GisaDataSetHelper.GetInstance().RelacaoHierarquica.Select(string.Format("ID={0} AND IDUpper={1}", nRow.ID.ToString(), nUpperRow.ID.ToString())); // A relação pode ter desaparecido por algum motivo (ie, concorrencia). if (rhRows.Length > 0) { rhRow = (GISADataset.RelacaoHierarquicaRow)(rhRows[0]); tnrRow = TipoNivelRelacionado.GetTipoNivelRelacionadoFromRelacaoHierarquica(rhRow); } } if (nRowBC != null && nUpperRowBC != null) { DataRow[] rhRowBCs = GisaDataSetHelper.GetInstance().RelacaoHierarquica.Select(string.Format("ID={0} AND IDUpper={1}", nRowBC.ID.ToString(), nUpperRowBC.ID.ToString())); // A relação pode ter desaparecido por algum motivo (ie, concorrencia). if (rhRowBCs.Length > 0) { rhRowBC = (GISADataset.RelacaoHierarquicaRow)(rhRowBCs[0]); tnrRowBC = TipoNivelRelacionado.GetTipoNivelRelacionadoFromRelacaoHierarquica(rhRowBC); } } } } NivelRow = nRow; TnrRow = tnrRow; }
public ArrayList AddNivel(TreeView trvw, GISADataset.NivelRow nRow, GISADataset.NivelRow nUpperRow, IDbConnection connection) { ArrayList result = new ArrayList(); GISATreeNode node = null; // Para as EDs (em relação às quais não existem níveis superiores) if (nUpperRow == null) { node = FindTreeNodeByNivelRow(trvw.Nodes, nRow); if (node == null) { node = new GISATreeNode(Nivel.GetDesignacao(nRow)); //Node.Tag = rhRow node.NivelRow = nRow; node.NivelUpperRow = null; GISADataset.TipoNivelRelacionadoRow tnrRow = null; int iconIndex = 0; tnrRow = TipoNivelRelacionado.GetTipoNivelRelacionadoFromRelacaoHierarquica(node.NivelRow, node.NivelUpperRow); iconIndex = -1; if (tnrRow != null) { iconIndex = System.Convert.ToInt32(tnrRow.GUIOrder); } if (nRow.CatCode.Trim().Equals("CA")) { if (iconIndex == -1) { node.ImageIndex = SharedResourcesOld.CurrentSharedResources.NivelImageIncognitoControloAut(); } else { node.ImageIndex = SharedResourcesOld.CurrentSharedResources.NivelImageControloAut(iconIndex); } } else { if (iconIndex == -1) { node.ImageIndex = SharedResourcesOld.CurrentSharedResources.NivelImageIncognito(); } else { node.ImageIndex = SharedResourcesOld.CurrentSharedResources.NivelImageBase(iconIndex); } } node.SelectedImageIndex = node.ImageIndex; trvw.Nodes.Add(node); } result.Add(node); } else { ArrayList ParentNodes = new ArrayList(); GISADataset.RelacaoHierarquicaRow[] TempParentRelations = Nivel.GetParentRelations(nRow, nUpperRow, connection); //Obter os nós pai com base nas rows pai if (TempParentRelations.Length == 0) { ArrayList nodes = null; nodes = AddNivel(trvw, nUpperRow, null, connection); ParentNodes.AddRange(nodes); } foreach (GISADataset.RelacaoHierarquicaRow parentRhRow in TempParentRelations) { ArrayList nodes = null; nodes = AddNivel(trvw, parentRhRow.NivelRowByNivelRelacaoHierarquica, parentRhRow.NivelRowByNivelRelacaoHierarquicaUpper, connection); ParentNodes.AddRange(nodes); } // Neste ponto ParentNodes contém todos os nós a que um nó de nRow deverá ser adicionado foreach (TreeNode parentNode in ParentNodes) { node = FindTreeNodeByNivelRow(parentNode.Nodes, nRow); if (node == null) { node = new GISATreeNode(Nivel.GetDesignacao(nRow)); //node.Tag = rhRow node.NivelRow = nRow; node.NivelUpperRow = nUpperRow; string data = FormatYearsInterval(node.RelacaoHierarquicaRow); if (data.Length > 0) { node.Text = string.Format("{0} {1}", node.Text, data); } if (nRow.CatCode.Trim().Equals("CA")) { node.ImageIndex = SharedResourcesOld.CurrentSharedResources.NivelImageControloAut(System.Convert.ToInt32(TipoNivelRelacionado.GetTipoNivelRelacionadoFromRelacaoHierarquica(node.RelacaoHierarquicaRow).GUIOrder)); } else { node.ImageIndex = SharedResourcesOld.CurrentSharedResources.NivelImageBase(System.Convert.ToInt32(TipoNivelRelacionado.GetTipoNivelRelacionadoFromRelacaoHierarquica(node.RelacaoHierarquicaRow).GUIOrder)); } node.SelectedImageIndex = node.ImageIndex; parentNode.Nodes.Add(node); } result.Add(node); } } return result; }
public void RemoveFromTreeview(GISATreeNode node) { RemoveFromTreeview(node, null); }
public void SelectParentNode(GISATreeNode parentNode) { this.controloNivelListEstrutural1.SelectParentNode(parentNode); }
private void AddToTable(GISATreeNode node) { Hashtable table = tableEstrutural; if (table != null) { string key = getKey(node); object somethingAlreadyThere = null; somethingAlreadyThere = table[key]; // se já existe um ou vários nós if (somethingAlreadyThere != null) { GISATreeNode nodeAlreadyThere = null; ArrayList nodesAlreadyThere = null; // se se tratar de um nó individual if (somethingAlreadyThere is GISATreeNode) { nodesAlreadyThere = new ArrayList(); nodeAlreadyThere = (GISATreeNode)somethingAlreadyThere; if (nodeAlreadyThere.TreeView != null) { nodesAlreadyThere.Add(nodeAlreadyThere); // adicionar o nó que já existia naquele ponto } nodesAlreadyThere.Add(node); // adicionar o novo nó table.Remove(key); // remover o nó individual que existia table.Add(key, nodesAlreadyThere); // adicionar a arraylist contendo o nó individual anterior e o novo nó a adicionar } else // trata-se de um arraylist { Debug.Assert(somethingAlreadyThere is ArrayList); nodesAlreadyThere = (ArrayList)somethingAlreadyThere; // remover os nós ainda incluidos na hashtable mas que já nao pertençam à treeview int i = 0; while (i < nodesAlreadyThere.Count) { nodeAlreadyThere = (GISATreeNode)(nodesAlreadyThere[i]); if (nodeAlreadyThere.TreeView == null) { nodesAlreadyThere.Remove(nodeAlreadyThere); } else { i = i + 1; } } if (nodesAlreadyThere.Count > 0) { nodesAlreadyThere.Add(node); } else { table.Remove(key); // remover a arraylist vazia table.Add(key, node); // adicionar o novo nó } } } else { table.Add(key, node); } } }
public override void UpdateToolBarButtons(ListViewItem item) { base.UpdateToolBarButtons(item); //Obter selecção actual GISATreeNode selectedNode = null; GISADataset.NivelRow nRow = null; GISADataset.NivelRow nUpperRow = null; GISADataset.RelacaoHierarquicaRow rhRow = null; GISADataset.TipoNivelRelacionadoRow tnrRow = null; // Estas variaveis identificam o contexto definido pelo breadcrumbspath da vista documental // (só são usadas quando a vista actual é a documental) GISADataset.NivelRow nRowBC = null; GISADataset.NivelRow nUpperRowBC = null; GISADataset.RelacaoHierarquicaRow rhRowBC = null; GISADataset.TipoNivelRelacionadoRow tnrRowBC = null; if (this.nivelNavigator1.PanelToggleState == NivelNavigator.ToggleState.Estrutural) { //vista estrutural if (this.nivelNavigator1.EPFilterMode) // modo filtro { if (item != null && item.ListView != null && !(((GISADataset.NivelRow)item.Tag).RowState == DataRowState.Detached)) { //contexto da listview nRow = (GISADataset.NivelRow)item.Tag; } } else //modo árvore { //vista estrutural selectedNode = (GISATreeNode)this.nivelNavigator1.SelectedNode; if (selectedNode != null && !(selectedNode.NivelRow.RowState == DataRowState.Detached)) { nRow = selectedNode.NivelRow; nUpperRow = selectedNode.NivelUpperRow; } } } else { //vista documental if (item != null && item.ListView != null && !(((GISADataset.NivelRow)item.Tag).RowState == DataRowState.Detached)) { //contexto da listview nRow = (GISADataset.NivelRow)item.Tag; nUpperRow = nRow.GetRelacaoHierarquicaRowsByNivelRelacaoHierarquica()[0].NivelRowByNivelRelacaoHierarquicaUpper; } //contexto do breadcrumbspath nRowBC = GisaDataSetHelper.GetInstance().Nivel.Cast <GISADataset.NivelRow>().SingleOrDefault(r => r.RowState != DataRowState.Deleted && r.ID == this.nivelNavigator1.ContextBreadCrumbsPathID); nUpperRowBC = GisaDataSetHelper.GetInstance().Nivel.Cast <GISADataset.NivelRow>().SingleOrDefault(r => r.RowState != DataRowState.Deleted && r.ID == this.nivelNavigator1.ContextBreadCrumbsPathIDUpper); } if (nRow != null && !(nRow.RowState == DataRowState.Detached) && nUpperRow == null) { tnrRow = TipoNivelRelacionado.GetTipoNivelRelacionadoFromRelacaoHierarquica(null); } else if (nUpperRow != null && !(nUpperRow.RowState == DataRowState.Detached) && nRow != null && !(nRow.RowState == DataRowState.Detached)) { if (this.nivelNavigator1.PanelToggleState == NivelNavigator.ToggleState.Estrutural) { rhRow = selectedNode.RelacaoHierarquicaRow; // excluimos desta forma as relacoes hirarquicas entretanto eliminadas (as que seriam NULL mas cujo nó respectivo teria um NivelUpper) if (selectedNode.NivelUpperRow != null && rhRow != null) { tnrRow = TipoNivelRelacionado.GetTipoNivelRelacionadoFromRelacaoHierarquica(rhRow); } } else { if (item != null && item.ListView != null) { DataRow[] rhRows = GisaDataSetHelper.GetInstance().RelacaoHierarquica.Select(string.Format("ID={0} AND IDUpper={1}", nRow.ID.ToString(), nUpperRow.ID.ToString())); // A relação pode ter desaparecido por algum motivo (ie, concorrencia). if (rhRows.Length > 0) { rhRow = (GISADataset.RelacaoHierarquicaRow)(rhRows[0]); tnrRow = TipoNivelRelacionado.GetTipoNivelRelacionadoFromRelacaoHierarquica(rhRow); } } if (nRowBC != null && nUpperRowBC != null) { DataRow[] rhRowBCs = GisaDataSetHelper.GetInstance().RelacaoHierarquica.Select(string.Format("ID={0} AND IDUpper={1}", nRowBC.ID.ToString(), nUpperRowBC.ID.ToString())); // A relação pode ter desaparecido por algum motivo (ie, concorrencia). if (rhRowBCs.Length > 0) { rhRowBC = (GISADataset.RelacaoHierarquicaRow)(rhRowBCs[0]); tnrRowBC = TipoNivelRelacionado.GetTipoNivelRelacionadoFromRelacaoHierarquica(rhRowBC); } } } } if (nRow == null && this.nivelNavigator1.PanelToggleState == NivelNavigator.ToggleState.Documental && nRowBC != null && nUpperRowBC != null) { GISADataset.RelacaoHierarquicaRow[] bcRHRow = (GISADataset.RelacaoHierarquicaRow[])(GisaDataSetHelper.GetInstance().RelacaoHierarquica.Select(string.Format("ID={0} AND IDUpper={1}", nRowBC.ID.ToString(), nUpperRowBC.ID.ToString()))); if (bcRHRow.Length > 0) { if (bcRHRow[0].IDTipoNivelRelacionado < TipoNivelRelacionado.SD) { ToolBarButtonCreateAny.Enabled = AllowCreate && PermissoesHelper.AllowCreate; } else { ToolBarButtonCreateAny.Enabled = false; } rhRowBC = (GISADataset.RelacaoHierarquicaRow)(GisaDataSetHelper.GetInstance().RelacaoHierarquica.Select(string.Format("ID={0} AND IDUpper={1}", nRowBC.ID.ToString(), nUpperRowBC.ID.ToString()))[0]); tnrRowBC = TipoNivelRelacionado.GetTipoNivelRelacionadoFromRelacaoHierarquica(rhRowBC); ConfigureContextMenu(nRowBC, nUpperRowBC, tnrRowBC, tnrRowBC); ToolBarButtonEdit.Enabled = false; ToolBarButtonRemove.Enabled = false; } else { ToolBarButtonCreateAny.Enabled = false; ToolBarButtonPaste.Enabled = false; } } else if (TipoNivel.isNivelDocumental(nRow)) { ToolBarButtonCreateAny.Enabled = AllowCreate && PermissoesHelper.AllowCreate; ConfigureContextMenu(nRowBC, nUpperRowBC, tnrRow, tnrRowBC); if (rhRow.IDTipoNivelRelacionado == TipoNivelRelacionado.D) { ToolBarButtonEdit.Enabled = AllowEdit && PermissoesHelper.AllowEdit; ToolBarButtonRemove.Enabled = NiveisHelper.isRemovable(nRow, nUpperRow, false) && AllowDelete && PermissoesHelper.AllowDelete; } else if (rhRow.IDTipoNivelRelacionado == TipoNivelRelacionado.SD) { ToolBarButtonEdit.Enabled = AllowEdit && PermissoesHelper.AllowEdit; ToolBarButtonRemove.Enabled = NiveisHelper.isRemovable(nRow, nUpperRow, false) && AllowDelete && PermissoesHelper.AllowDelete && PermissoesHelper.ObjDigAllowWrite; } else { ToolBarButtonEdit.Enabled = false; ToolBarButtonRemove.Enabled = false; } } else { ToolBarButtonCreateAny.Enabled = false; ToolBarButtonEdit.Enabled = false; ToolBarButtonRemove.Enabled = false; } }