Esempio n. 1
0
 public void DeleteWatchVariable(LuaWatchVariable variable)
 {
     if (watchVariables.Remove(variable))
     {
         OnNodesRemoved(new TreeModelEventArgs(TreePath.Empty, new object[] { variable }));
     }
 }
Esempio n. 2
0
        public override bool IsLeaf(TreePath treePath)
        {
            LuaWatchVariable item = treePath.LastNode as LuaWatchVariable;

            if (item != null)
            {
                if (item.LuaValue is LuaTable)
                {
                    return(false);
                }
            }
            return(base.IsLeaf(treePath));
        }
Esempio n. 3
0
        private void treeViewAdvWatch_ItemDrag(object sender, ItemDragEventArgs e)
        {
            Aga.Controls.Tree.TreeNodeAdv[] items = e.Item as Aga.Controls.Tree.TreeNodeAdv[];
            if (items != null && items.Length == 1)
            {
                var    item     = items[0];
                string fullName = string.Empty;
                do
                {
                    string           subPart       = string.Empty;
                    LuaWatchVariable watchVariable = item.Tag as LuaWatchVariable;
                    if (watchVariable != null)
                    {
                        subPart = watchVariable.Name;
                    }
                    else
                    {
                        LuaVariableItem variableItem = item.Tag as LuaVariableItem;
                        if (variableItem != null)
                        {
                            LuaString keyString = variableItem.LuaKey as LuaString;
                            if (keyString != null)
                            {
                                subPart = keyString.Value;
                            }
                        }
                    }

                    if (subPart != string.Empty)
                    {
                        if (fullName == string.Empty)
                        {
                            fullName = subPart;
                        }
                        else
                        {
                            fullName = subPart + "." + fullName;
                        }
                    }

                    item = item.Parent;
                } while (item.Parent != null);
                if (!string.IsNullOrEmpty(fullName))
                {
                    DoDragDrop(fullName, DragDropEffects.Copy);
                }
            }
        }
Esempio n. 4
0
 private void watchKey_LabelChanged(object sender, Aga.Controls.Tree.NodeControls.LabelEventArgs e)
 {
     if (e.Subject == luaWatchModel.NewWatchVariable)
     {
         // New watch item
         AddWatchVariable(e.NewLabel.Trim());
     }
     else
     {
         // Existing watch item
         LuaWatchVariable variable = e.Subject as LuaWatchVariable;
         if (variable != null)
         {
             variable.Name     = e.NewLabel.Trim();
             variable.LuaValue = GetVariable(variable.Name);
             luaWatchModel.WatchVariableChanged(variable);
         }
     }
 }
Esempio n. 5
0
        public virtual System.Collections.IEnumerable GetChildren(TreePath treePath)
        {
            List <LuaVariableItem> children = new List <LuaVariableItem>();
            LuaTable currentTable           = null;

            if (treePath.IsEmpty())
            {
                currentTable = filteredLuaTable != null ? filteredLuaTable : filter < 0 ? rootLuaTable : null;
            }
            else
            {
                LuaVariableItem item = treePath.LastNode as LuaVariableItem;
                if (item != null)
                {
                    currentTable = item.LuaValue as LuaTable;
                }
                else
                {
                    LuaWatchVariable watchVariable = treePath.LastNode as LuaWatchVariable;
                    if (watchVariable != null)
                    {
                        currentTable = watchVariable.LuaValue as LuaTable;
                    }
                }
            }
            if (currentTable != null)
            {
                children.Capacity = currentTable.Value.Count;
                foreach (var kvp in currentTable.Value)
                {
                    LuaVariableItem item = new LuaVariableItem(kvp.Key, kvp.Value);
                    children.Add(item);
                }
            }
            // Sort items alphabetically by Key name
            children.Sort((x, y) => x.Key.CompareTo(y.Key));
            return(children);
        }
Esempio n. 6
0
 private void treeViewAdvWatch_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Delete)
     {
         var node = treeViewAdvWatch.SelectedNode;
         if (node != null)
         {
             LuaWatchVariable variable = node.Tag as LuaWatchVariable;
             if (variable != null)
             {
                 luaWatchModel.DeleteWatchVariable(variable);
             }
         }
     }
     else if (e.KeyCode >= Keys.A && e.KeyCode <= Keys.Z)
     {
         // If the user starts typing letters then enter edit mode and start with the letter he typed
         watchKey.BeginEdit();
         TextBox editor = treeViewAdvWatch.CurrentEditor as TextBox;
         if (editor != null)
         {
             int  index = e.KeyCode - Keys.A;
             char character;
             if (e.Shift)
             {
                 character = (char)('A' + index);
             }
             else
             {
                 character = (char)('a' + index);
             }
             editor.Text           = character.ToString();
             editor.SelectionStart = 1;
         }
         e.SuppressKeyPress = true;
     }
 }
Esempio n. 7
0
        private void AddWatchVariable(string name)
        {
            LuaWatchVariable watchVariable = new LuaWatchVariable(name, GetVariable(name));

            luaWatchModel.AddWatchVariable(watchVariable);
        }
Esempio n. 8
0
 public void WatchVariableChanged(LuaWatchVariable variable)
 {
     //OnNodesChanged(new TreeModelEventArgs(TreePath.Empty, new object[] { variable }));
     OnNodesRemoved(new TreeModelEventArgs(TreePath.Empty, new object[] { variable }));
     OnNodesInserted(new TreeModelEventArgs(TreePath.Empty, new int[] { watchVariables.IndexOf(variable) }, new object[] { variable }));
 }
Esempio n. 9
0
 public void AddWatchVariable(LuaWatchVariable variable)
 {
     watchVariables.Add(variable);
     OnNodesInserted(new TreeModelEventArgs(TreePath.Empty, new int[] { watchVariables.Count - 1 }, new object[] { variable }));
 }