Beispiel #1
0
        void Select(UCTopologyItem top)
        {
            if (top == null)
            {
                if (cmItems.SelectedItem != null && cmItems.SelectedItem is UCTopologyItem)
                {
                    ((UCTopologyItem)cmItems.SelectedItem).Selected = false;
                }

                propertyGrid1.SelectedObject = _Vars.Designer;
                propertyGrid1.ExpandAllGridItems();
                cmItems.SelectedItem = null;
                _Current             = new ConnectedLine();
                pItems.Invalidate();
            }
            else
            {
                cmItems.SelectedItem         = top;
                propertyGrid1.SelectedObject = top.Item;
                propertyGrid1.ExpandAllGridItems();
                top.Selected = true;
            }

            propertyGrid1.Update();
        }
Beispiel #2
0
        void pictureBox1_MouseDown(object sender, MouseEventArgs e)
        {
            UCTopologyItem top = (UCTopologyItem)sender;

            MouseDownLocation = e.Location;
            Select(top);

            switch (e.Button)
            {
            default:
            {
                if (_Current.From != null)
                {
                    goto case MouseButtons.Right;
                }
                break;
            }

            case MouseButtons.Right:
            {
                if (_Current.From == null)
                {
                    _Current.From = top;
                    pItems.Invalidate();
                }
                else
                {
                    if (_Current.IsAllowed(top))
                    {
                        if (_Current.Apply(top))
                        {
                            _Lines.Add(_Current);
                            _Current = new ConnectedLine();
                            pItems.Invalidate();
                        }
                        else
                        {
                            _Current.To   = null;
                            _Current.From = null;
                            pItems.Invalidate();
                        }
                    }
                    else
                    {
                        _Current.To   = null;
                        _Current.From = null;
                        pItems.Invalidate();
                    }
                }
                break;
            }
            }
        }
Beispiel #3
0
        void NewTopology()
        {
            if (_InPlay)
            {
                // Stop-it
                playToolStripMenuItem_Click(null, null);
            }

            LastFile = "";

            _Lines.Clear();
            _Current = new ConnectedLine();
            Select(null);
            _Vars.Clear();
            _VariableCache.Clear();
            generateExeToolStripMenuItem.Enabled = false;
            LasterHelper.SetEnvironmentPath(null);

            foreach (UCTopologyItem u in _List.ToArray())
            {
                Delete(u);
            }
        }
Beispiel #4
0
        void FEditTopology_KeyDown(object sender, KeyEventArgs e)
        {
            switch (e.KeyCode)
            {
            case Keys.Escape:
            {
                if (_Current.From != null)
                {
                    _Current.From = null;
                    _Current.To   = null;
                    pItems.Invalidate();

                    e.Handled          = true;
                    e.SuppressKeyPress = true;
                }
                break;
            }

            case Keys.Delete:
            {
                if (ActiveControl == propertyGrid1)
                {
                    return;
                }
                if (_Current.From != null)
                {
                    goto case Keys.Escape;
                }

                UCTopologyItem uc = (UCTopologyItem)cmItems.SelectedItem;
                if (uc != null)
                {
                    bool entra = false;

                    for (int x = _Lines.Count - 1; x >= 0; x--)
                    {
                        ConnectedLine c = _Lines[x];
                        if (c.From == uc || c.To == uc)
                        {
                            _Lines.Remove(c);
                            c.FromItem.Process.Remove(c.ToItem);
                            entra = true;
                        }
                    }

                    if (!entra)
                    {
                        Delete(uc);

                        foreach (UCTopologyItem c in pItems.Controls)
                        {
                            Select(c);
                            break;
                        }
                    }

                    pItems.Invalidate();
                    propertyGrid1.Update();

                    e.Handled          = true;
                    e.SuppressKeyPress = true;
                }
                break;
            }
            }
        }