Beispiel #1
0
        /// <summary>
        /// Gets the increase cell count command.
        /// </summary>
        /// <param name="panel">The panel that the child panel should be inserted next to.</param>
        /// <param name="insertOnLeft">True if the panel should be inserted to the left of panel, otherwise false.</param>
        /// <returns>The complete relay command.</returns>
        public PsiCommand CreateIncreaseCellCountCommand(VisualizationPanel panel, bool insertOnLeft)
        {
            int panelIndex = this.panels.IndexOf(panel);

            PsiCommand command = new PsiCommand(
                () => this.IncreaseCellCount(insertOnLeft ? panelIndex : panelIndex + 1),
                this.Panels.Count < MaxCells);

            return(command);
        }
Beispiel #2
0
        /// <summary>
        /// Removes a cell specified by the panel it contains.
        /// </summary>
        /// <param name="panel">The panel whose cell should be removed.</param>
        public void RemoveCell(VisualizationPanel panel)
        {
            // Get the index of the panel to remove.
            int panelIndex = this.Panels.IndexOf(panel);

            // Unhook and remove the child panel
            panel.PropertyChanged -= this.ChildVisualizationPanel_PropertyChanged;
            panel.Clear();
            this.Panels.Remove(panel);
            this.UpdateChildPanelMargins();
        }
 private void ChildVisualizationPanel_PropertyChanged(object sender, PropertyChangedEventArgs e)
 {
     // If the child panel has no more visualizations in it, replace it with a placeholder panel
     if (e.PropertyName == nameof(VisualizationPanel.VisualizationObjects))
     {
         VisualizationPanel childPanel = sender as VisualizationPanel;
         if (childPanel.VisualizationObjects.Count <= 0)
         {
             this.ReplaceChildVisualizationPanel(childPanel, new InstantVisualizationPlaceholderPanel());
         }
     }
 }
        /// <summary>
        /// Replaces an instant visualization placeholder panel with an instant visualization panel.
        /// </summary>
        /// <param name="oldPanel">The visualization panel to replace.</param>
        /// <param name="newPanel">The visualization panel to replace it with.</param>
        public void ReplaceChildVisualizationPanel(VisualizationPanel oldPanel, VisualizationPanel newPanel)
        {
            if (oldPanel == null)
            {
                throw new ArgumentNullException(nameof(oldPanel));
            }

            if (newPanel == null)
            {
                throw new ArgumentNullException(nameof(newPanel));
            }

            // Make sure the placeholder panel being replaced is really a child of this container
            int placeholderPanelIndex = this.Panels.IndexOf(oldPanel);

            if (placeholderPanelIndex < 0)
            {
                throw new ArgumentException("placeholderPanel is not a member of the Panels collection");
            }

            // Disconnect the placeholder panel
            oldPanel.PropertyChanged -= this.ChildVisualizationPanel_PropertyChanged;
            oldPanel.SetParentContainer(null);

            // Wire up the new panel
            newPanel.SetParentContainer(this.Container);
            newPanel.ParentPanel      = this;
            newPanel.Width            = oldPanel.Width;
            newPanel.PropertyChanged += this.ChildVisualizationPanel_PropertyChanged;

            // Replace the panel
            this.Panels[placeholderPanelIndex] = newPanel;
            this.UpdateChildPanelMargins();

            // If the current visualization panel is the one we just replaced,
            // then set it instead to the new panel we replaced it with.
            if (this.Container?.CurrentPanel == oldPanel)
            {
                this.Container.CurrentPanel = newPanel;
            }
        }
Beispiel #5
0
 /// <summary>
 /// Gets the decrease cell count command.
 /// </summary>
 /// <param name="panel">The child panel to remove.</param>
 /// <returns>The complete relay command.</returns>
 public PsiCommand CreateRemoveCellCommand(VisualizationPanel panel) =>
 new PsiCommand(() => this.RemoveCell(panel), true);