public void OpenModel(string path) { //var persistModel = new PersistedDataModel(); //using (var fs = new FileStream(path, FileMode.Open, FileAccess.ReadWrite)) //{ // var reader = new StreamReader(fs); // var jsonText = reader.ReadToEnd(); // var serializerSettings = new JsonSerializerSettings { TypeNameHandling = TypeNameHandling.Auto }; // persistModel = JsonConvert.DeserializeObject<PersistedDataModel>(jsonText, serializerSettings); //} //_model = new DataModel(); //_model.ModelDetails = persistModel.ModelDetails; //_model.Source = SourceTreeviewNode.LoadFromData(persistModel.Source); //tvSource.Nodes.Clear(); //tvSource.Nodes.Add(_model.Source); //_model.Destination = DestinationTreeviewNode.LoadFromData(persistModel.Destination, tvSource.Nodes); //tvDestination.Nodes.Clear(); //tvDestination.Nodes.Add(_model.Destination); _model = DataModel.LoadFrom(path, tvSource.Nodes, tvDestination.Nodes); _clickedSourceNode = null; _clickedDestinationNode = null; tvSource.ExpandAll(); tvDestination.ExpandAll(); RefreshMapPanelLines(); MessageBox.Show("The model has been successfully opened"); }
private void tvSource_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e) { _logger.LogDebug($"{MethodBase.GetCurrentMethod().Name} started"); _clickedSourceNode = (SourceTreeviewNode)e.Node; if (e.Button == MouseButtons.Right) { //Manipulate Context Menu Buttons contextMenuStrip1.Items.ChangeAllItemsVisibility(true); if (_clickedSourceNode.Parent == null) { contextMenuStrip1.Items.ChangeMenuOptionVisibility("Add Before", false); contextMenuStrip1.Items.ChangeMenuOptionVisibility("Add After", false); } ; contextMenuStrip1.Show(tvSource, e.Location); } else if (e.Button == MouseButtons.Left) { _mapLinesManager.UpdateLinesToHighlight(_clickedSourceNode); RedrawMapPanelLines(); } }
private void contextMenuStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e) { _logger.LogDebug($"{MethodBase.GetCurrentMethod().Name} started"); if (_clickedSourceNode == null) { return; } if (e.ClickedItem.Text == "Add Child") { var newTreeNode = new SourceTreeviewNode(); _clickedSourceNode.Nodes.Add(newTreeNode); _clickedSourceNode.Expand(); newTreeNode.BeginEdit(); } if (e.ClickedItem.Text == "Add Multiple Children") { var form = _serviceProvider.GetRequiredService <AddMultipleChildNodesForm>(); form.Initialize(_clickedSourceNode, this); form.ShowDialog(); } if (e.ClickedItem.Text == "Move Down") { tvDestination.MoveNode(_clickedSourceNode, false); } if (e.ClickedItem.Text == "Move Up") { tvDestination.MoveNode(_clickedSourceNode, true); } if (e.ClickedItem.Text == "Remove Node") { var parentNode = (SourceTreeviewNode)_clickedSourceNode.Parent; parentNode.Nodes.Remove(_clickedSourceNode); tvDestination.RecurseivlyRemoveLinksToSourceNode(_clickedSourceNode); _clickedDestinationNode = null; } RedrawMapPanelLines(); }
public void ClearSourceTree() { _logger.LogDebug($"{MethodBase.GetCurrentMethod().Name} started"); //var savedExpansionState = tvSource.Nodes.GetExpansionState(); //tvSource.BeginUpdate(); var treeNode = new SourceTreeviewNode() { Text = "Source Entities" }; tvSource.Nodes.Clear(); tvSource.Nodes.Add(treeNode); //tvSource.Nodes.SetExpansionState(savedExpansionState); tvSource.EndUpdate(); }
private void MenuItem_New_Clicked(object sender, EventArgs e) { var dr = MessageBox.Show("Would you like to clear the model and create a new empty one", "New", MessageBoxButtons.YesNo); if (dr == DialogResult.Yes) { _model = new DataModel(); _clickedSourceNode = null; _clickedDestinationNode = null; _mapLinesManager = new MapLinesManager(); ClearSourceTree(); ClearDestinationTree(); RefreshMapPanelLines(); //Open Model Details form so details of new model can be specified var form = _serviceProvider.GetRequiredService <ModelDetailsForm>(); form.Initialize(_model, this); form.ShowDialog(this); } }
private void tvSource_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e) { _logger.LogDebug($"{MethodBase.GetCurrentMethod().Name} started"); TreeView tree = (TreeView)sender; TreeNode node = tree.GetNodeAt(e.X, e.Y); tree.SelectedNode = node; _clickedSourceNode = node as SourceTreeviewNode; if (node != null) { _logger.LogDebug($"Mouse down on source tree node: {node.Tag} - {node.FullPath}"); _clickedSourceNode = (SourceTreeviewNode)node; if (e.Button == MouseButtons.Left) { _mapLinesManager.UpdateLinesToHighlight(_clickedSourceNode); RedrawMapPanelLines(); tree.DoDragDrop(node, DragDropEffects.Link); } } }