internal void UpdateConnectionBetween(VirtualArchivePanel startPanel, VirtualArchivePanel nextPanel) { Point startPanelPosition = new Point((double)startPanel.GetValue(System.Windows.Controls.Canvas.LeftProperty), (double)startPanel.GetValue(System.Windows.Controls.Canvas.TopProperty)); Point nextPanelPosition = new Point((double)nextPanel.GetValue(System.Windows.Controls.Canvas.LeftProperty), (double)nextPanel.GetValue(System.Windows.Controls.Canvas.TopProperty)); LineGeometry line = null; // Change exsiting foreach (PanelConnection connection in Connections) { if (connection.StartPanel == startPanel) { line = connection.Line; break; } } // Extablish a new one if (line == null) { line = new LineGeometry(); Connectors.Children.Add(line); Connections.Add(new PanelConnection(startPanel, nextPanel, line)); } // Update line.StartPoint = new Point(startPanelPosition.X + startPanel.ActualWidth, startPanelPosition.Y + startPanel.ActualHeight / 2); line.EndPoint = new Point(nextPanelPosition.X, nextPanelPosition.Y + nextPanel.ActualHeight / 2); }
internal void UpdateContent(VirtualArchivePanel virtualArchivePanel, ArchiveNodeRepresentation node) { ContentEditorBorder.DataContext = node.Node; if (CurrentArchive.IsReal == false) { ContentEditorBorder.Visibility = Visibility.Visible; } }
internal void AddNextPanelFor(VirtualArchivePanel startPanel, VirtualArchivePanel nextPanel) { // Get location double xPositionOffset = startPanel.ActualWidth * 1.5; Point startPanelPosition = new Point((double)startPanel.GetValue(System.Windows.Controls.Canvas.LeftProperty), (double)startPanel.GetValue(System.Windows.Controls.Canvas.TopProperty)); Point nextPanelPosition = new Point((double)startPanel.GetValue(System.Windows.Controls.Canvas.LeftProperty) + xPositionOffset, (double)startPanel.GetValue(System.Windows.Controls.Canvas.TopProperty)); // Show next panel System.Windows.Controls.Canvas.SetLeft(nextPanel, nextPanelPosition.X); System.Windows.Controls.Canvas.SetTop(nextPanel, nextPanelPosition.Y); VirtualArchiveCanvas.Children.Add(nextPanel); // Update this.UpdateLayout(); UpdateConnectionBetween(startPanel, nextPanel); }
internal CollectionCreatorWindow(Window owner, Archive archive) { InitializeComponent(); Owner = owner; // If we are holding SHIFT, then open a new one // Null opening handlings if ((Keyboard.Modifiers & ModifierKeys.Shift) == ModifierKeys.Shift) { CurrentArchive = null; } // Create one if not supplied if (archive == null) { if (CurrentArchive == null) { CurrentArchive = Home.Current.CreateDocument(DocumentType.VirtualArchive) as Archive; } } else { CurrentArchive = archive; } // Populate default panels double verticalDisplacement = 600; for (int i = 0; i < CurrentArchive.Roots.Count; i++) { ArchiveNode root = CurrentArchive.Roots[i]; VirtualArchivePanel rootPanel = new VirtualArchivePanel(new ArchiveNodeRepresentation(root)); System.Windows.Controls.Canvas.SetLeft(rootPanel, 300); System.Windows.Controls.Canvas.SetTop(rootPanel, 200 + i * verticalDisplacement); VirtualArchiveCanvas.Children.Add(rootPanel); } // Extra bits of interface initialization Connections = new List <PanelConnection>(); // UI Update NotifyPropertyChanged("DocumentName"); }
//internal void RemovePanelsFor(VirtualArchivePanel nextPanel) // Not working, and I don't think it's very userful //{ // // Find any exsiting // PanelConnection connectionToRemove = null; // foreach (PanelConnection connection in Connections) // { // if (connection.StartPanel == nextPanel) // { // connectionToRemove = connection; // break; // We know there will only be one line so we can break now, but if we want there be more lines we can comment this line // } // } // if (connectionToRemove != null) // { // Connectors.Children.Remove(connectionToRemove.Line); // Connections.Remove(connectionToRemove); // RemovePanelsFor(connectionToRemove.EndPanel); // } //} internal void UpdateConnection(VirtualArchivePanel endPanel) { Point nextPanelPosition = new Point((double)endPanel.GetValue(System.Windows.Controls.Canvas.LeftProperty), (double)endPanel.GetValue(System.Windows.Controls.Canvas.TopProperty)); // Find any exsiting foreach (PanelConnection connection in Connections) { if (connection.EndPanel == endPanel) { Point startPanelPosition = new Point((double)connection.StartPanel.GetValue(System.Windows.Controls.Canvas.LeftProperty), (double)connection.StartPanel.GetValue(System.Windows.Controls.Canvas.TopProperty)); // Update connection.Line.StartPoint = new Point(startPanelPosition.X + connection.StartPanel.ActualWidth, startPanelPosition.Y + connection.StartPanel.ActualHeight / 2); connection.Line.EndPoint = new Point(nextPanelPosition.X, nextPanelPosition.Y + endPanel.ActualHeight / 2); break; // We know there will only be one line so we can break now, but if we want there be more lines we can comment this line } } }
private void Window_MouseDoubleClick(object sender, MouseButtonEventArgs e) { if (Keyboard.IsKeyDown(Key.LeftShift)) { if (CurrentArchive.IsReal == false) { // When clicked in emepty area, create a new root node ArchiveNode newNode = CurrentArchive.AddRootNode(DefaultNodeName); // Create a new panel at location VirtualArchivePanel newPanel = new VirtualArchivePanel(new ArchiveNodeRepresentation(newNode)); Point mouse = e.GetPosition(VirtualArchiveCanvas); System.Windows.Controls.Canvas.SetLeft(newPanel, mouse.X); System.Windows.Controls.Canvas.SetTop(newPanel, mouse.Y); VirtualArchiveCanvas.Children.Add(newPanel); } else { (Owner as VirtualWorkspaceWindow).UpdateStatus("Cannot create new root node on an real archive."); } e.Handled = true; } }
public PanelConnection(VirtualArchivePanel start, VirtualArchivePanel end, LineGeometry line) { StartPanel = start; EndPanel = end; Line = line; }