Exemple #1
0
        /// <summary>
        /// Contructor
        /// </summary>
        /// <param name="flowChartCtlBasic"></param>
        /// <param name="flowContainer"></param>
        /// <param name="offsetY"></param>
        public SMContainerPanel(SMFlowChartCtlBasic flowChartCtlBasic, SMFlowContainer flowContainer, int offsetY)
            : base()
        {
            InitializeComponent();

            DoubleBuffered     = true;
            _flowChartCtlBasic = flowChartCtlBasic;
            _flowContainer     = flowContainer;
            Name        = flowContainer.Nickname;
            TabIndex    = 0;
            MouseMove  += new System.Windows.Forms.MouseEventHandler(this.OnMouseMove);
            MouseClick += new System.Windows.Forms.MouseEventHandler(this.OnLeftClick);
            MouseDown  += new System.Windows.Forms.MouseEventHandler(this.OnMouseDown);
            MouseUp    += new System.Windows.Forms.MouseEventHandler(this.OnMouseUp);
            Paint      += new PaintEventHandler(OnPaint);


            _flowItemCursor = CustomCursor.Create(global::MCore.Comp.SMLib.SMFlowChart.Properties.Resources.FlowItemCursor);
            BackgroundImage = global::MCore.Comp.SMLib.SMFlowChart.Properties.Resources.NoGridBackground;

            GridSize = BackgroundImage.Size;

            // Set the size of the panel
            Size = GridToPixel(_flowContainer.GridSize);

            // Set the location of the panel
            Point ptLoc = GridToPixel(_flowContainer.GridCorner);

            ptLoc.Offset(0, offsetY);
            Location = ptLoc;
            Rebuild();
        }
 public void ApplyPathDelay(SMFlowContainer parentContainer)
 {
     if (TimeToEnableTargetID == 0 && PathOutDelayMS > 0)
     {
         parentContainer.EnterPathDelay(PathOutDelayMS);
         TimeToEnableTargetID = U.DateTimeNow + U.MSToTicks(PathOutDelayMS);
     }
 }
 /// <summary>
 /// Remove this subroutine panel
 /// </summary>
 /// <param name="subroutine"></param>
 public void RemoveFlowContainer(SMFlowContainer flowContainer)
 {
     if (flowContainer != null && Controls.ContainsKey(flowContainer.Nickname))
     {
         SMContainerPanel containerPanel = Controls[flowContainer.Nickname] as SMContainerPanel;
         //this.Controls.Remove(containerPanel);
         this.smFlowPanel.Controls.Remove(containerPanel);
         containerPanel.Dispose();
     }
 }
        /// <summary>
        /// Show this panel and create or show the subroutine panel
        /// </summary>
        /// <param name="subroutine"></param>
        public void ShowFlowContainer(SMFlowContainer flowContainer)
        {
            if (_currentContainerPanel != null)
            {
                if (_currentContainerPanel.Name == flowContainer.Nickname)
                {
                    _currentContainerPanel.PreventEdit = !_enableSMOperation;
                    return;
                }
                _currentContainerPanel.Hide();
            }

            //if (!Controls.ContainsKey(flowContainer.Nickname))
            if (!this.smFlowPanel.Controls.ContainsKey(flowContainer.Nickname))
            {
                // Constructor will rebuild
                //SMContainerPanel subPanel = new SMContainerPanel(this, flowContainer, lblHeader.Size.Height);
                SMContainerPanel subPanel = new SMContainerPanel(this, flowContainer, 0);
                //this.Controls.Add(subPanel);
                this.smFlowPanel.Controls.Add(subPanel);
            }
            //_currentContainerPanel = this.Controls[flowContainer.Nickname] as SMContainerPanel;
            _currentContainerPanel = this.smFlowPanel.Controls[flowContainer.Nickname] as SMContainerPanel;
            _currentContainerPanel.Show();
            _currentFlowContainer = flowContainer;
            lblHeader.Text        = _currentFlowContainer.PathText;
            tbSubroutineName.Text = _currentFlowContainer.Text;
            UpdateAutoScope();

            tbSubroutineName.Hide();
            if (_currentFlowContainer is SMStateMachine)
            {
                if (_currentFlowContainer.IsEditing(_currentContainerPanel.Name))
                {
                    btnClose.Text    = "X";
                    btnClose.Enabled = true;
                }
                else
                {
                    btnClose.Text    = string.Empty;
                    btnClose.Enabled = false;
                }
            }
            else
            {
                btnClose.Text    = "X";
                btnClose.Enabled = true;
            }

            _currentContainerPanel.PreventEdit = !_enableSMOperation;
            lblHeader.BringToFront();
            btnClose.BringToFront();
        }
 private void btnClose_Click(object sender, EventArgs e)
 {
     _currentContainerPanel.EditMode = false;
     if (_currentFlowContainer is SMStateMachine)
     {
         btnClose.Text    = string.Empty;
         btnClose.Enabled = false;
     }
     else
     {
         SMFlowContainer currentFlowContainer = _currentFlowContainer as SMFlowContainer;
         _currentFlowContainer.Text = tbSubroutineName.Text;
         ShowFlowContainer(_currentFlowContainer.Parent as SMFlowContainer);
         //_currentContainerPanel.Redraw(currentFlowContainer);
     }
 }