private void mMenSortAscending_Click(object sender, EventArgs e) { tvConnections.BeginUpdate(); ConnectionTree.Sort(tvConnections.Nodes[0], SortOrder.Ascending); tvConnections.EndUpdate(); Runtime.SaveConnectionsBG(); }
private void cMenTreeToolsSortDescending_Click(object sender, EventArgs e) { tvConnections.BeginUpdate(); ConnectionTree.Sort(tvConnections.SelectedNode, SortOrder.Descending); tvConnections.EndUpdate(); Runtime.SaveConnectionsBG(); }
public void Setup() { _filter = new ConnectionTreeSearchTextFilter(); _connectionTree = new ConnectionTree { UseFiltering = true }; }
private void ConnectionTree_MouseUp(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Right) { // Select the clicked node ConnectionTree.SelectedNode = ConnectionTree.GetNodeAt(e.X, e.Y); } }
public void Setup() { _connectionTreeModel = CreateConnectionTreeModel(); _connectionTree = new ConnectionTree { PostSetupActions = new IConnectionTreeDelegate[] { new RootNodeExpander() } }; }
public static void NewConnections(string filename) { try { ConnectionList = new ConnectionList(); ContainerList = new ContainerList(); ConnectionsLoader connectionsLoader = new ConnectionsLoader(); if (filename == GetDefaultStartupConnectionFileName()) { Settings.Default.LoadConsFromCustomLocation = false; } else { Settings.Default.LoadConsFromCustomLocation = true; Settings.Default.CustomConsPath = filename; } var dirname = GetDirectoryName(filename); if (dirname != null) { Directory.CreateDirectory(dirname); } // Use File.Open with FileMode.CreateNew so that we don't overwrite an existing file using (FileStream fileStream = File.Open(filename, FileMode.CreateNew, FileAccess.Write, FileShare.None)) { using (XmlTextWriter xmlTextWriter = new XmlTextWriter(fileStream, System.Text.Encoding.UTF8)) { xmlTextWriter.Formatting = Formatting.Indented; xmlTextWriter.Indentation = 4; xmlTextWriter.WriteStartDocument(); xmlTextWriter.WriteStartElement("Connections"); // Do not localize xmlTextWriter.WriteAttributeString("Name", Language.strConnections); xmlTextWriter.WriteAttributeString("Export", "", "False"); xmlTextWriter.WriteAttributeString("Protected", "", "GiUis20DIbnYzWPcdaQKfjE2H5jh//L5v4RGrJMGNXuIq2CttB/d/BxaBP2LwRhY"); xmlTextWriter.WriteAttributeString("ConfVersion", "", "2.5"); xmlTextWriter.WriteEndElement(); xmlTextWriter.WriteEndDocument(); xmlTextWriter.Close(); } } connectionsLoader.ConnectionList = ConnectionList; connectionsLoader.ContainerList = ContainerList; ConnectionTree.ResetTree(); connectionsLoader.RootTreeNode = Windows.treeForm.tvConnections.Nodes[0]; // Load config connectionsLoader.ConnectionFileName = filename; connectionsLoader.LoadConnections(false); Windows.treeForm.tvConnections.SelectedNode = connectionsLoader.RootTreeNode; } catch (Exception ex) { MessageCollector.AddExceptionMessage(Language.strCouldNotCreateNewConnectionsFile, ex); } }
private void tvConnections_MouseMove(object sender, MouseEventArgs e) { try { ConnectionTree.SetNodeToolTip(e, DescriptionTooltip); } catch (Exception ex) { Runtime.MessageCollector.AddMessage(MessageClass.ErrorMsg, "tvConnections_MouseMove (UI.Window.ConnectionTreeWindow) failed" + Environment.NewLine + ex.Message, true); } }
private void mMenViewCollapseAllFolders_Click(object sender, EventArgs e) { if (tvConnections.SelectedNode != null) { if (tvConnections.SelectedNode.IsEditing) { tvConnections.SelectedNode.EndEdit(false); } } ConnectionTree.CollapseAllNodes(); }
private void tvConnections_MouseMove(object sender, MouseEventArgs e) { try { ConnectionTree.SetNodeToolTip(e, DescriptionTooltip); } catch (Exception ex) { Runtime.MessageCollector.AddExceptionStackTrace("tvConnections_MouseMove (UI.Window.ConnectionTreeWindow) failed", ex); } }
private void tvConnections_AfterLabelEdit(object sender, NodeLabelEditEventArgs e) { try { cMenTreeDelete.ShortcutKeys = Keys.Delete; ConnectionTree.FinishRenameSelectedNode(e.Label); Windows.configForm.pGrid_SelectedObjectChanged(); ShowHideTreeContextMenuItems(e.Node); Runtime.SaveConnectionsBG(); } catch (Exception ex) { Runtime.MessageCollector.AddMessage(MessageClass.ErrorMsg, "tvConnections_AfterLabelEdit (UI.Window.ConnectionTreeWindow) failed" + Environment.NewLine + ex.Message, true); } }
private void tvConnections_AfterLabelEdit(object sender, NodeLabelEditEventArgs e) { try { cMenTreeDelete.ShortcutKeys = Keys.Delete; ConnectionTree.FinishRenameSelectedNode(e.Label); Windows.configForm.pGrid_SelectedObjectChanged(); ShowHideTreeContextMenuItems(e.Node); Runtime.SaveConnectionsBG(); } catch (Exception ex) { Runtime.MessageCollector.AddExceptionStackTrace("tvConnections_AfterLabelEdit (UI.Window.ConnectionTreeWindow) failed", ex); } }
public static void AddSessionsToTree() { TreeView treeView = ConnectionTree.TreeView; if (treeView == null) { return; } if (treeView.InvokeRequired) { treeView.Invoke(new AddSessionsToTreeDelegate(AddSessionsToTree)); return; } foreach (Provider provider in Providers) { TreeNode rootTreeNode = provider.RootTreeNode; bool inUpdate = false; List <ConnectionInfo> savedSessions = new List <ConnectionInfo>(provider.GetSessions()); if (!IsProviderEnabled(provider) || savedSessions == null || savedSessions.Count == 0) { if (rootTreeNode != null && treeView.Nodes.Contains(rootTreeNode)) { treeView.BeginUpdate(); treeView.Nodes.Remove(rootTreeNode); treeView.EndUpdate(); } continue; } if (!treeView.Nodes.Contains(rootTreeNode)) { if (!inUpdate) { treeView.BeginUpdate(); inUpdate = true; } treeView.Nodes.Add(rootTreeNode); } List <TreeNode> newTreeNodes = new List <TreeNode>(); foreach (PuttySessionInfo sessionInfo in savedSessions) { TreeNode treeNode = default(TreeNode); bool isNewNode = false; if (rootTreeNode.Nodes.ContainsKey(sessionInfo.Name)) { treeNode = rootTreeNode.Nodes[sessionInfo.Name]; isNewNode = false; } else { treeNode = ConnectionTreeNode.AddNode(TreeNodeType.PuttySession, sessionInfo.Name); if (treeNode == null) { continue; } treeNode.Name = treeNode.Text; treeNode.ImageIndex = (int)TreeImageType.ConnectionClosed; treeNode.SelectedImageIndex = (int)TreeImageType.ConnectionClosed; isNewNode = true; } sessionInfo.RootPuttySessionsInfo = provider.RootInfo; sessionInfo.TreeNode = treeNode; //sessionInfo.IInheritable.TurnOffInheritanceCompletely(); treeNode.Tag = sessionInfo; if (isNewNode) { newTreeNodes.Add(treeNode); } } foreach (TreeNode treeNode in rootTreeNode.Nodes) { if (!savedSessions.Contains((ConnectionInfo)treeNode.Tag)) { if (!inUpdate) { treeView.BeginUpdate(); inUpdate = true; } rootTreeNode.Nodes.Remove(treeNode); } } if (!(newTreeNodes.Count == 0)) { if (!inUpdate) { treeView.BeginUpdate(); inUpdate = true; } rootTreeNode.Nodes.AddRange(newTreeNodes.ToArray()); } if (inUpdate) { ConnectionTree.Sort(rootTreeNode, SortOrder.Ascending); rootTreeNode.Expand(); treeView.EndUpdate(); } } }
private void txtSearch_TextChanged(object sender, EventArgs e) { tvConnections.SelectedNode = ConnectionTree.Find(tvConnections.Nodes[0], txtSearch.Text); }
private void mMenViewExpandAllFolders_Click(object sender, EventArgs e) { ConnectionTree.ExpandAllNodes(); }
private static void cMenTreeMoveDown_Click(object sender, EventArgs e) { ConnectionTree.MoveNodeDown(); Runtime.SaveConnectionsBG(); }
private static void cMenTreeDelete_Click(object sender, EventArgs e) { ConnectionTree.DeleteSelectedNode(); Runtime.SaveConnectionsBG(); }
private void mMenFileRename_Click(object sender, EventArgs e) { ConnectionTree.StartRenameSelectedNode(); Runtime.SaveConnectionsBG(); }
public static void LoadConnections(bool withDialog = false, bool update = false) { var connectionsLoader = new ConnectionsLoader(); try { // disable sql update checking while we are loading updates SQLConnProvider?.Disable(); if (ConnectionList != null && ContainerList != null) { PreviousConnectionList = ConnectionList.Copy(); PreviousContainerList = ContainerList.Copy(); } ConnectionList = new ConnectionList(); ContainerList = new ContainerList(); if (!Settings.Default.UseSQLServer) { if (withDialog) { var loadDialog = Tools.Controls.ConnectionsLoadDialog(); if (loadDialog.ShowDialog() != DialogResult.OK) { return; } connectionsLoader.ConnectionFileName = loadDialog.FileName; } else { connectionsLoader.ConnectionFileName = GetStartupConnectionFileName(); } CreateBackupFile(Convert.ToString(connectionsLoader.ConnectionFileName)); } connectionsLoader.ConnectionList = ConnectionList; connectionsLoader.ContainerList = ContainerList; if (PreviousConnectionList != null && PreviousContainerList != null) { connectionsLoader.PreviousConnectionList = PreviousConnectionList; connectionsLoader.PreviousContainerList = PreviousContainerList; } if (update) { connectionsLoader.PreviousSelected = LastSelected; } ConnectionTree.ResetTree(); connectionsLoader.RootTreeNode = Windows.treeForm.tvConnections.Nodes[0]; connectionsLoader.UseDatabase = Settings.Default.UseSQLServer; connectionsLoader.DatabaseHost = Settings.Default.SQLHost; connectionsLoader.DatabaseName = Settings.Default.SQLDatabaseName; connectionsLoader.DatabaseUsername = Settings.Default.SQLUser; var cryptographyProvider = new LegacyRijndaelCryptographyProvider(); connectionsLoader.DatabasePassword = cryptographyProvider.Decrypt(Convert.ToString(Settings.Default.SQLPass), GeneralAppInfo.EncryptionKey); connectionsLoader.DatabaseUpdate = update; connectionsLoader.LoadConnections(false); if (Settings.Default.UseSQLServer) { LastSqlUpdate = DateTime.Now; } else { if (connectionsLoader.ConnectionFileName == GetDefaultStartupConnectionFileName()) { Settings.Default.LoadConsFromCustomLocation = false; } else { Settings.Default.LoadConsFromCustomLocation = true; Settings.Default.CustomConsPath = connectionsLoader.ConnectionFileName; } } // re-enable sql update checking after updates are loaded SQLConnProvider?.Enable(); } catch (Exception ex) { if (Settings.Default.UseSQLServer) { MessageCollector.AddExceptionMessage(Language.strLoadFromSqlFailed, ex); var commandButtons = string.Join("|", Language.strCommandTryAgain, Language.strCommandOpenConnectionFile, string.Format(Language.strCommandExitProgram, Application.ProductName)); CTaskDialog.ShowCommandBox(Application.ProductName, Language.strLoadFromSqlFailed, Language.strLoadFromSqlFailedContent, MiscTools.GetExceptionMessageRecursive(ex), "", "", commandButtons, false, ESysIcons.Error, ESysIcons.Error); switch (CTaskDialog.CommandButtonResult) { case 0: LoadConnections(withDialog, update); return; case 1: Settings.Default.UseSQLServer = false; LoadConnections(true, update); return; default: Application.Exit(); return; } } if (ex is FileNotFoundException && !withDialog) { MessageCollector.AddExceptionMessage(string.Format(Language.strConnectionsFileCouldNotBeLoadedNew, connectionsLoader.ConnectionFileName), ex, MessageClass.InformationMsg); NewConnections(Convert.ToString(connectionsLoader.ConnectionFileName)); return; } MessageCollector.AddExceptionMessage(string.Format(Language.strConnectionsFileCouldNotBeLoaded, connectionsLoader.ConnectionFileName), ex); if (connectionsLoader.ConnectionFileName != GetStartupConnectionFileName()) { LoadConnections(withDialog, update); } else { MessageBox.Show(frmMain.Default, string.Format(Language.strErrorStartupConnectionFileLoad, Environment.NewLine, Application.ProductName, GetStartupConnectionFileName(), MiscTools.GetExceptionMessageRecursive(ex)), "Could not load startup file.", MessageBoxButtons.OK, MessageBoxIcon.Error); Application.Exit(); } } }