Exemple #1
0
        private void FillAddressList(int functionNodeId)
        {
            // To set the right window
            viewData.Items.Clear();
            foreach (IAddressNode addressLine in _mainTrainer.GetAddressList())
            {
                if (addressLine.ParentIndex != functionNodeId)
                {
                    continue;
                }

                viewData.Items.Add(new ListViewItem(
                                       new string[]
                {
                    addressLine.Caption,        // Caption
                    "",                         // Original value
                    ""                          // Modified value
                }));
                viewData.Items[viewData.Items.Count - 1].Tag = addressLine;
            }

            // To get memory content
            using (WindowsApi.ProcessMemory mem = new WindowsApi.ProcessMemory(_currentGameContext.ProcessId))
            {
                foreach (ListViewItem currentItem in viewData.Items)
                {
                    IAddressNode addressLine = currentItem.Tag as IAddressNode;
                    if (addressLine == null)
                    {
                        continue;
                    }

                    Object itemValue;
                    switch (addressLine.ValueType)
                    {
                    case AddressListValueType.Integer:
                        itemValue = mem.ReadInt32((IntPtr)addressLine.Address)
                                    / addressLine.ValueScale;
                        break;

                    case AddressListValueType.Float:
                        itemValue = mem.ReadFloat((IntPtr)addressLine.Address)
                                    / addressLine.ValueScale;
                        break;

                    case AddressListValueType.Char4:
                        itemValue = mem.ReadChar4((IntPtr)addressLine.Address);
                        break;

                    default:
                        itemValue = "";
                        break;
                    }
                    currentItem.SubItems[1].Text = itemValue.ToString();
                }
            }
        }
Exemple #2
0
        /// <summary>
        /// Creates a File System node with a given path
        /// </summary>
        /// <param name="path">Path that this node represents</param>
        /// <param name="depth">Integer represnting how deep in the hierarchy this node is</param>
        public FileSystemNode(string path, FileSystemNode parent)
        {
            //fill in the relevant details
            fullPath    = path;
            this.parent = parent;

            //get the icon
            GenerateNodeDisplayDetails();
        }
 private void GenerateRootNode()
 {
     if (children != null)
     {
         return;
     }
     this._entity = null;
     this.parent  = null;
     CreateChildNodes();
 }
        private SEAddressBarDropDown GetButtonDropDown(IAddressNode addressNode)
        {
            SEAddressBarDropDown dropDown = new SEAddressBarDropDown();

            if (this.DropDownRenderer != null)
            {
                dropDown.Renderer = this.DropDownRenderer;
            }

            dropDown.LayoutStyle = ToolStripLayoutStyle.Table;
            dropDown.MaximumSize = new Size(1000, 400);
            dropDown.Opening    += new CancelEventHandler(DropDown_Opening);

            /*
             * This is the primary bottleneck for this app, creating all the necessary drop-down menu items.
             *
             * To optimize performance of this control, this is the main area that needs tuning.
             */

            IAddressNode curNode = null;

            for (int i = 0; i < addressNode.Children.Length; i++)
            {
                curNode = (IAddressNode)addressNode.Children.GetValue(i);

                SEAddressBarDropDownItem tsb = null;

                tsb = new SEAddressBarDropDownItem(curNode.DisplayName, curNode.Icon, NodeButtonClicked);

                tsb.AddressNode = curNode;

                tsb.Overflow = ToolStripItemOverflow.AsNeeded;

                dropDown.Items.Add(tsb); //THIS IS THE BIGGEST BOTTLENECK. LOTS OF TIME SPENT IN/CALLING THIS METHOD!
            }

            addressNode.DropDownMenu = dropDown;

            dropDown.LayoutStyle = ToolStripLayoutStyle.Table;
            dropDown.MaximumSize = new Size(1000, 400);

            dropDown.AddressNode = addressNode;

            //不起作用
            dropDown.MouseWheel += new MouseEventHandler(ScrollDropDownMenu);
            dropDown.MouseEnter += new EventHandler(GiveToolStripDropDownMenuFocus);

            return(dropDown);
        }
Exemple #5
0
        // To apply the modifications
        private void ApplyModify()
        {
            using (WindowsApi.ProcessMemory mem = new WindowsApi.ProcessMemory(_currentGameContext.ProcessId))
            {
                foreach (ListViewItem currentItem in viewData.Items)
                {
                    string itemValueString = currentItem.SubItems[2].Text;
                    if (String.IsNullOrEmpty(itemValueString))
                    {
                        // Not modified
                        continue;
                    }

                    IAddressNode addressLine = currentItem.Tag as IAddressNode;
                    if (addressLine == null)
                    {
                        continue;
                    }

                    switch (addressLine.ValueType)
                    {
                    case AddressListValueType.Integer:
                        Int32 intValue;
                        if (!Int32.TryParse(itemValueString, out intValue))
                        {
                            intValue = 0;
                        }
                        intValue = unchecked (intValue * addressLine.ValueScale);
                        mem.WriteInt32((IntPtr)addressLine.Address, intValue);
                        break;

                    case AddressListValueType.Float:
                        float floatValue;
                        if (!float.TryParse(itemValueString, out floatValue))
                        {
                            floatValue = 0;
                        }
                        floatValue = unchecked (floatValue * addressLine.ValueScale);
                        mem.WriteFloat((IntPtr)addressLine.Address, floatValue);
                        break;

                    case AddressListValueType.Char4:
                        mem.WriteChar4((IntPtr)addressLine.Address, itemValueString);
                        break;
                    }
                    currentItem.SubItems[2].Text = "";
                }
            }
        }
        /// <summary>
        /// Method to handle when a mode is double clicked
        /// </summary>
        /// <param name="sender">Sender of this event</param>
        /// <param name="e">Event arguments</param>
        private void NodeDoubleClickHandler(Object sender, EventArgs e)
        {
            //check we are handlign the double click event
            if (NodeDoubleClick != null && sender.GetType() == typeof(SEAddressBarButton))
            {
                //get the node from the tag
                _currentNode = ((SEAddressBarDropDownItem)sender).AddressNode;

                //create the node changed event arguments
                NodeChangedArgs nca = new NodeChangedArgs(_currentNode.UniqueID);

                //fire the event
                NodeDoubleClick(this, nca);
            }
        }
Exemple #7
0
        /// <summary>
        /// Method to handle when a node is double clicked
        /// </summary>
        /// <param name="sender">Sender of this event</param>
        /// <param name="e">Event arguments</param>
        private void NodeDoubleClickHandler(Object sender, EventArgs e)
        {
            //check we are handlign the double click event
            if (NodeDoubleClick != null && sender.GetType() == typeof(ToolStripButton))
            {
                //get the node from the tag
                currentNode = (IAddressNode)((ToolStripButton)sender).Tag;

                //create the node changed event arguments
                NodeChangedArgs nca = new NodeChangedArgs(currentNode.UniqueID);

                //fire the event
                NodeDoubleClick(this, nca);
            }
        }
Exemple #8
0
        private void SelectOldNode(IAddressNode currentNode)
        {
            if (currentNode == null)
            {
                return;
            }

            IAddressNode selectedNode = _layersRoot.GetChild(currentNode.UniqueID, true);

            if (selectedNode != null)
            {
                _editAddressBar.CurrentNode = selectedNode;
                return;
            }
            if (currentNode.Parent == null)
            {
                _editAddressBar.CurrentNode = _layersRoot;
                return;
            }
            selectedNode = _layersRoot.GetChild(currentNode.Parent.UniqueID, true);
            if (selectedNode == null)
            {
                _editAddressBar.CurrentNode = _layersRoot;
                return;
            }
            //We found the old node's parent, but not the node itself, so it was probably renamed.
            //To find the renamed item, we need to find the item that doesn't exist in the old tree.
            foreach (IAddressNode child in selectedNode.Children)
            {
                bool foundChild = false;
                foreach (IAddressNode oldChild in currentNode.Parent.Children)
                {
                    if (oldChild.UniqueID.Equals(child.UniqueID))
                    {
                        foundChild = true;
                        break;
                    }
                }
                if (!foundChild)
                {
                    _editAddressBar.CurrentNode = child;
                    return;
                }
            }
            //We didn't find any missing node, lets at least select the parent
            _editAddressBar.CurrentNode = selectedNode;
        }
Exemple #9
0
        private void layer_OnSelectedItemChanged(object sender, SelectedRoomItemEventArgs e)
        {
            IRoomEditorFilter layer = sender as IRoomEditorFilter;

            if (layer == null)
            {
                SelectLayer(null); return;
            }
            IAddressNode node = _editAddressBar.RootNode.GetChild(GetLayerItemUniqueID(layer, e.Item), true);

            if (node == null)
            {
                SelectLayer(null); return;
            }
            _editAddressBar.CurrentNode = node;
            SelectLayer(layer);
            //selecting hotspot from designer Panel, then cant Draw more hotspots...
        }
        /// <summary>
        /// Method to handle when a child has been selected from a node
        /// </summary>
        /// <param name="sender">Sender of this Event</param>
        /// <param name="e">Event Arguments</param>
        private void NodeButtonClicked(Object sender, EventArgs e)
        {
            if (sender.GetType() == typeof(SEAddressBarDropDownItem) || sender.GetType() == typeof(SEAddressBarButton))
            {
                IAddressNode addressNode;

                if (sender.GetType() == typeof(SEAddressBarDropDownItem))
                {
                    SEAddressBarDropDownItem tsb = (SEAddressBarDropDownItem)sender;
                    addressNode = tsb.AddressNode;
                }
                else
                {
                    SEAddressBarButton tsb = (SEAddressBarButton)sender;
                    addressNode = tsb.AddressNode;
                }

                //set the current node
                _currentNode = addressNode;

                //cxs
                //用不着整个都重新加载,在当前最后一个Item后面加上点的这个就行了
                //但是要额外考虑点击的是哪个下拉按钮,如果是中间的,还是要整个刷
                ResetBar();
                //if (sender.GetType().Equals(typeof(SEAddressBarButton)))
                //{
                //    UpdateBar();
                //}
                //else
                //{
                //    AddToolStripItemUpdate(ref _currentNode,ButtonPosition.Behind);
                //}

                //if the selection changed event is handled
                if (SelectionChange != null)
                {
                    NodeChangedArgs args = new NodeChangedArgs(_currentNode.UniqueID);
                    SelectionChange(this, args);
                }

                return;
            }
        }
Exemple #11
0
 public IAddressNode GetChild(object uniqueID, bool recursive)
 {
     foreach (IAddressNode child in Children)
     {
         if (child.UniqueID.Equals(uniqueID))
         {
             return(child);
         }
         if (recursive)
         {
             IAddressNode found = child.GetChild(uniqueID, recursive);
             if (found != null)
             {
                 return(found);
             }
         }
     }
     return(null);
 }
        /// <summary>
        /// 根据IAddressNode地址栏对象,创建并添加一个地址栏按钮
        /// </summary>
        /// <param name="node">The node to base the item on</param>
        /// <returns>Built SEAddressBarDropDownItem. Returns Null if method failed</returns>
        private void AddToolStripItemUpdate(IAddressNode node, ButtonPosition position)
        {
            SEAddressBarButton tsButton = null;

            node.CreateChildNodes();

            tsButton = new SEAddressBarButton(node.DisplayName, node.Icon, NodeButtonClicked);

            tsButton.AddressNode        = node;
            tsButton.ImageAlign         = ContentAlignment.MiddleCenter;
            tsButton.DoubleClickEnabled = true;
            tsButton.DoubleClick       += new EventHandler(NodeDoubleClickHandler);

            AddAddressBarButton(tsButton, position);

            if (IsManyNodes())
            {
                CreateOverflowDropDown();
            }
        }
        private void DropDown_Opening(object sender, CancelEventArgs e)
        {
            SEAddressBarDropDown dropDown = sender as SEAddressBarDropDown;

            //dropDown.Left = dropDown.Left - 20;

            #region 把当前选中项加粗

            IAddressNode nextAddressNode = null;
            for (int i = 0; i < _buttonList.Count; i++)
            {
                //如果是当前点击的向下箭头
                if (_buttonList[i].DropDownButton != null && _buttonList[i].DropDownButton.DropDown == dropDown)
                {
                    //拿出当前点的地址栏按钮向下箭头的下一个地址栏项目
                    //如果为空,则表示当前点的是最右边的了,那就不去匹配了,也没得匹配
                    if ((i + 1) < _buttonList.Count)
                    {
                        nextAddressNode = _buttonList[i + 1].AddressNode;
                        break;
                    }
                }
            }

            if (nextAddressNode != null)
            {
                foreach (SEAddressBarDropDownItem item in dropDown.Items)
                {
                    //在使用SetAddress逆向初始化节点时
                    //会出现item.AddressNode 和 nextAddressNode不是一个对象的情况
                    //所以需要UniqueID来判断
                    if (item.AddressNode.UniqueID.Equals(nextAddressNode.UniqueID))
                    {
                        item.Font = new Font(item.Font, this._selectedStyle);
                        break;
                    }
                }
            }

            #endregion
        }
        /// <summary>
        /// 初始化根节点
        /// </summary>
        /// <param name="rootNode"></param>
        public void InitializeRoot(IAddressNode rootNode)
        {
            //remove all items
            this.Items.Clear();
            this._rootNode = null;

            if (rootNode != null)
            {
                //create the root node
                this._rootNode = rootNode.Clone();

                //force update the node
                this._rootNode.CreateChildNodes();

                //set the current node to be the root
                this._currentNode = this._rootNode;

                //update the address bar
                ResetBar();
            }
        }
Exemple #15
0
        /// <summary>
        /// Initializes this AddressBarExt with a given root node
        /// </summary>
        /// <param name="rootNode"></param>
        public void InitializeRoot(IAddressNode rootNode)
        {
            //remove all items
            ts_bar.Items.Clear();
            this.rootNode = null;

            if (rootNode != null)
            {
                //create the root node
                this.rootNode = rootNode;//.Clone();

                //force update the node
                this.rootNode.UpdateNode();

                //set the current node to be the root
                this.currentNode = this.rootNode;

                //update the address bar
                UpdateBar();
            }
        }
Exemple #16
0
        private void RefreshLayersTree()
        {
            IAddressNode currentNode = _editAddressBar.CurrentNode;

            IAddressNode[]         layers = new IAddressNode[_layers.Count];
            VisibleLayerRadioGroup visibleLayerRadioGroup = new VisibleLayerRadioGroup();

            for (int layerIndex = 0; layerIndex < layers.Length; layerIndex++)
            {
                IRoomEditorFilter layer    = _layers[layerIndex];
                List <string>     names    = layer.GetItemsNames();
                IAddressNode[]    children = new IAddressNode[names.Count];
                for (int index = 0; index < names.Count; index++)
                {
                    string name = names[index];
                    children[index] = new RoomEditNode(GetLayerItemUniqueID(layer, name), name, new IAddressNode[0], true, false)
                    {
                    };
                }
                RoomEditNode node = new RoomEditNode(layer.DisplayName, children, layer.VisibleByDefault);
                node.Layer = layer;
                if (layer is BaseAreasEditorFilter)
                {
                    node.VisibleGroup = visibleLayerRadioGroup;
                }
                foreach (IAddressNode child in children)
                {
                    child.Parent = node;
                }
                layers[layerIndex] = node;
            }
            _layersRoot = new RoomEditNode("Room", layers, true);
            foreach (IAddressNode layer in layers)
            {
                layer.Parent = _layersRoot;
            }
            _editAddressBar.InitializeRoot(_layersRoot);

            SelectOldNode(currentNode);
        }
Exemple #17
0
        /// <summary>
        /// Update the breadcrumb navigation bar, make all nodes correspond to the design-time state
        /// of the room layers and items.
        /// </summary>
        /// TODO: currently this is the only way to sync navbar with the design-time properties.
        /// find a better solution, perhaps tie each DesignTimeProperties object to a bar node.
        public void RefreshLayersTree()
        {
            IAddressNode currentNode = _editAddressBar.CurrentNode;

            IAddressNode[]         layers = new IAddressNode[_layers.Count];
            VisibleLayerRadioGroup visibleLayerRadioGroup = new VisibleLayerRadioGroup();

            for (int layerIndex = 0; layerIndex < layers.Length; layerIndex++)
            {
                IRoomEditorFilter layer    = _layers[layerIndex];
                IAddressNode[]    children = new IAddressNode[layer.DesignItems.Count];
                int index = 0;
                foreach (var item in layer.DesignItems)
                {
                    string id   = item.Key;
                    string name = layer.GetItemName(id);
                    children[index++] = new RoomEditNode(GetLayerItemUniqueID(layer, name), name, id,
                                                         new IAddressNode[0], item.Value.Visible, item.Value.Locked, false);
                }
                RoomEditNode node = new RoomEditNode(layer.DisplayName, children, layer.Visible, layer.Locked);
                node.Layer = layer;
                if (layer is BaseAreasEditorFilter)
                {
                    node.VisibleGroup = visibleLayerRadioGroup;
                }
                foreach (IAddressNode child in children)
                {
                    child.Parent = node;
                }
                layers[layerIndex] = node;
            }
            _layersRoot = new RoomEditNode("Room", layers, true, false);
            foreach (IAddressNode layer in layers)
            {
                layer.Parent = _layersRoot;
            }
            _editAddressBar.InitializeRoot(_layersRoot);

            SelectOldNode(currentNode);
        }
        /// <summary>
        /// 创建指定地址栏项的子级(如果需要)
        /// </summary>
        /// <param name="button"></param>
        private void BuildChildItem(SEAddressBarButton button)
        {
            IAddressNode addressNode = button.AddressNode;

            SEAddressBarDropDownButton dropDownButton = null;

            //SEAddressBarDropDown dropDown = null;

            if (addressNode.Children != null && addressNode.Children.Length > 0)
            {
                dropDownButton        = new SEAddressBarDropDownButton(String.Empty);
                button.DropDownButton = dropDownButton;

                //check if we have any tag data (we cache already built drop down items in the node TAG data.
                if (addressNode.DropDownMenu == null)
                {
                    addressNode.DropDownMenu = GetButtonDropDown(addressNode);
                }
                else
                {
                    if (addressNode.DropDownMenu.GetType() == typeof(SEAddressBarDropDown))
                    {
                        //dropDown = (SEAddressBarDropDown)addressNode.DropDownMenu;

                        foreach (SEAddressBarDropDownItem tsmi in addressNode.DropDownMenu.Items)
                        {
                            if (tsmi.Font.Style != _baseFont.Style)
                            {
                                tsmi.Font = _baseFont;
                            }
                        }
                    }
                }

                dropDownButton.DropDown     = addressNode.DropDownMenu;
                dropDownButton.DisplayStyle = ToolStripItemDisplayStyle.None;
                dropDownButton.ImageAlign   = ContentAlignment.MiddleCenter;
            }
        }
        /// <summary>
        /// 刷新(重新加载)整个地址栏
        /// </summary>
        private void ResetBar()
        {
            _buttonList.Clear();

            this.Items.Clear();

            //check we have a valid root
            if (_currentNode == null && _rootNode == null)
            {
                return;
            }

            //update the current node, if it doesn't exist
            if (_currentNode == null)
            {
                _currentNode = _rootNode;
            }

            IAddressNode tempNode = _currentNode;

            //从当前节点向上逐级添加
            //while (tempNode.Parent != null)
            while (tempNode != null)
            {
                AddToolStripItemUpdate(tempNode, ButtonPosition.Front);

                if (tempNode.Parent == null)
                {
                    _rootNode = tempNode;
                }

                tempNode = tempNode.Parent;
            }

            //添加根节点
            //if (_rootNode != null && _rootNode.UniqueID != tempNode.UniqueID)
            //    AddToolStripItemUpdate(_rootNode, ButtonPosition.Front);
        }
Exemple #20
0
        /// <summary>
        /// Attempts to select room node following the given path item by item.
        /// Path elements are compared with RoomItemID or UniqueID if former is not set.
        /// </summary>
        public bool TrySelectNodeUsingDesignIDPath(string[] path)
        {
            if (path.Length < 1)
            {
                return(false);
            }
            if (path[0].CompareTo(_layersRoot.UniqueID) != 0)
            {
                return(false);
            }
            IAddressNode node = _layersRoot;

            for (int i = 1; i < path.Length; ++i)
            {
                foreach (IAddressNode child in node.Children)
                {
                    var roomNode = child as RoomEditNode;
                    if (roomNode != null && !string.IsNullOrEmpty(roomNode.RoomItemID))
                    {
                        if (roomNode.RoomItemID.CompareTo(path[i]) == 0)
                        {
                            node = roomNode;
                            continue;
                        }
                    }
                    else
                    {
                        if (child.UniqueID.ToString().CompareTo(path[i]) == 0)
                        {
                            node = child;
                            continue;
                        }
                    }
                }
            }
            _editAddressBar.CurrentNode = node;
            return(true);
        }
Exemple #21
0
        /// <summary>
        /// Creates a new tool strip menu item based on a given node
        /// </summary>
        /// <param name="node">The node to base the item on</param>
        /// <returns>Built ToolStripItem. Returns Null if method failed</returns>
        private void AddToolStripItemUpdate(ref IAddressNode node, int position)
        {
            //variables needed for our toolstrip
            ToolStripButton         tsButton   = null;
            ToolStripDropDownButton tsddButton = null;
            ToolStripDropDownMenu   tsDropDown = null;

            //update the node
            node.UpdateNode();

            if (node.Icon != null)
            {
                tsButton = new ToolStripButton(node.DisplayName, node.Icon.ToBitmap(), NodeButtonClicked);
            }
            else
            {
                tsButton = new ToolStripButton(node.DisplayName, null, NodeButtonClicked);
            }

            //AGS: match the padding on the dropdown buttons
            tsButton.Padding = new Padding(1, 0, 1, 0);

            //attach the node as the tag
            tsButton.Tag = node;

            //align the image
            tsButton.ImageAlign = ContentAlignment.TopCenter;

            //enable double clicks
            tsButton.DoubleClickEnabled = true;

            //add the double click handler
            tsButton.DoubleClick += new EventHandler(NodeDoubleClickHandler);

            if (position < 0)
            {
                ts_bar.Items.Add(tsButton);
            }
            else
            {
                ts_bar.Items.Insert(0, tsButton);
            }

            try
            {
                //if we have any children
                if (node.Children.Length > 0)
                {
                    //create the drop down button
                    //tsddButton = new ToolStripDropDownButton("");

                    //AGS: use some text to pickup text layout styling
                    //and provide a bigger target to click on
                    tsddButton = new ToolStripDropDownButton("иии");
                    tsddButton.ShowDropDownArrow = false;

                    //check if we have any tag data (we cache already built drop down items in the node TAG data.
                    if (node.Tag == null)
                    {
                        IAddressNode curNode = null;

                        //create the drop down menu
                        tsDropDown           = new ToolStripDropDownMenu();
                        tsDropDown.BackColor = DropDownBackColor;
                        tsDropDown.ForeColor = DropDownForeColor;

                        //Some variables to let the drawing happen smoothly
                        tsDropDown.LayoutStyle     = ToolStripLayoutStyle.VerticalStackWithOverflow;
                        tsDropDown.MaximumSize     = new Size(1000, 400);
                        tsDropDown.ShowImageMargin = false;
                        tsDropDown.ShowCheckMargin = false;

                        /*
                         * This is the primary bottleneck for this app, creating all the necessary drop-down menu items.
                         *
                         * To optimize performance of this control, this is the main area that needs tuning.
                         */

                        //for all child nodes
                        for (int i = 0; i < node.Children.Length; i++)
                        {
                            curNode = (IAddressNode)node.Children.GetValue(i);

                            ToolStripItem tsb = curNode.CreateNodeUI(NodeButtonClicked);
                            //assign the child node as the tag
                            tsb.Tag = curNode;

                            //if the node we are working on is the current node
                            if (curNode == currentNode)
                            {
                                //set the font to indicate it is selected
                                tsb.Font = new Font(tsb.Font, this.selectedStyle);
                            }

                            //enable overflow on the buttons
                            ToolStripMenuItem menuItem = tsb as ToolStripMenuItem;
                            if (menuItem != null)
                            {
                                menuItem.Overflow = ToolStripItemOverflow.AsNeeded;
                            }

                            //add the item to the drop down list
                            tsDropDown.Items.Add(tsb); //THIS IS THE BIGGEST BOTTLENECK. LOTS OF TIME SPENT IN/CALLING THIS METHOD!
                        }

                        //assign the tag
                        node.Tag = tsDropDown;

                        //Some variables to let the drawing happen smoothly
                        tsDropDown.LayoutStyle = ToolStripLayoutStyle.Table;
                        tsDropDown.MaximumSize = new Size(1000, 400);

                        //assign the parent
                        tsDropDown.Tag = tsddButton;

                        //add the method handler for the mouse wheel scrolling
                        tsDropDown.MouseWheel += new MouseEventHandler(ScrollDropDownMenu);

                        //handle the mouse entering/leaving the control
                        tsDropDown.MouseEnter += new EventHandler(GiveToolStripDropDownMenuFocus);
                    }
                    else
                    {
                        if (node.Tag.GetType() == typeof(ToolStripDropDownMenu))
                        {
                            tsDropDown = (ToolStripDropDownMenu)node.Tag;

                            foreach (ToolStripItem tsmi in tsDropDown.Items)
                            {
                                if (tsmi.Font.Style != baseFont.Style)
                                {
                                    tsmi.Font = baseFont;
                                }
                            }
                        }
                    }

                    //assign the drop down list
                    tsddButton.DropDown = tsDropDown;

                    //set it to ignore text rendering
                    //tsddButton.DisplayStyle = ToolStripItemDisplayStyle.None;

                    //AGS: use text stlying for dropdown menu to match the vertical
                    //offset of other text inside the ToolStrip overflow
                    tsddButton.DisplayStyle = ToolStripItemDisplayStyle.Text;

                    //align the image
                    tsddButton.ImageAlign = ContentAlignment.TopCenter;

                    //giving right margin to avoid drop down hiding itself when accidentally slightly moving the cursor to the button on the right
                    //tsddButton.Margin = new Padding(0, 0, 5, 0);

                    //AGS: prefer padding over margin to get a bigger click target
                    //and reduce the amount of unclickable gaps
                    tsddButton.Padding = new Padding(1, 0, 1, 0);

                    //add it to the bar
                    if (position < 0)
                    {
                        ts_bar.Items.Add(tsddButton);
                    }
                    else
                    {
                        ts_bar.Items.Insert(1, tsddButton);
                    }
                }
            }
            catch (System.NullReferenceException nrex)
            {
                System.Console.Error.WriteLine(nrex.Message);
            }
        }
Exemple #22
0
        /// <summary>
        /// Updates the address bar
        /// </summary>
        private void UpdateBar()
        {
            //check we have a valid root
            if (rootNode != null)
            {
                //update the current node, if it doesn't exist
                if (currentNode == null)
                {
                    currentNode = rootNode;
                }

                //now we know we have a root node, we need to build a relationship all the way from the current node, to the root.
                IAddressNode tempNode = currentNode;
                int          steps    = 1;

                //we step up through each parent until we hit a root node
                while (true)
                {
                    //check we aren't root
                    if (tempNode.Parent != null)
                    {
                        tempNode = tempNode.Parent;
                        steps++;
                    }
                    else
                    {
                        break;
                    }
                }

                //check we have a valid traversal
                if (tempNode != rootNode)
                {
                    //traversal was invalid, so we set the current node to be the root node, and we traverse again
                    currentNode = rootNode;

                    //recursive call
                    UpdateBar();
                }
                else
                {
                    //set the current node
                    tempNode = currentNode;

                    //remove all the items
                    ts_bar.Items.Clear();

                    //we had a valid node, so we can start adding elements to the view
                    for (int i = 0; i < steps; i++)
                    {
                        //add it to the beginning of the bar ;)
                        AddToolStripItemUpdate(ref tempNode, 0);

                        if (tempNode.Parent == null)
                        {
                            rootNode = tempNode;
                        }

                        tempNode = tempNode.Parent;
                    }

                    //check if we have too many nodes
                    if (TooManyNodes())
                    {
                        //create the drop down menu for the overflow
                        CreateOverflowDropDown();
                        AddOrUpdateOverflow();
                    }
                }
            }
        }
Exemple #23
0
 public void SetAddress(IAddressNode addressNode)
 {
     addressBarStrip.SetAddress(addressNode);
 }
Exemple #24
0
 public void InitializeRoot(IAddressNode rootNode)
 {
     addressBarStrip.InitializeRoot(rootNode);
 }
Exemple #25
0
 /// <summary>
 /// Basic Constructor, initializes this node to start at the root of the first drive found on the disk. ONLY USE THIS FOR ROOT NODES
 /// </summary>
 public ConxNode(ConxGroupNode Dad, ConnectionInfo Conx)
 {
     parent = Dad;
     szDisplayName = Conx.Name;
     ThisConx = Conx;
 }
Exemple #26
0
 /// <summary>
 /// Basic Constructor, initializes this node to start at the root of the first drive found on the disk. ONLY USE THIS FOR ROOT NODES
 /// </summary>
 public ConxGroupNode(RootConxNode Dad, ConnectionGroup Conx)
 {
     parent = Dad;
     szDisplayName = Conx.Name;
     ThisGConx = Conx;
 }
Exemple #27
0
        /// <summary>
        /// Populates this node as a root node representing "My Computer"
        /// </summary>
        private void GenerateRootNode()
        {
            // if we have data, we can't become a root node.
            if (children != null)
                return;

            //get the display name of the first logical drive
            this.parent = null;

            UpdateNode();

            //get the icon
            GenerateNodeDisplayDetails();
        }
 public FolderAddressNode(WindowFolderEntity entity, FolderAddressNode parent)
 {
     _windowComponentService = ServiceUnity.Container.Resolve <IWindowComponentService>();
     this._entity            = entity;
     this.parent             = parent;
 }
Exemple #29
0
        /// <summary>
        /// Populates this node as a root node representing "My Computer"
        /// </summary>
        private void GenerateRootNode()
        {
            // if we have data, we can't become a root node.
            if (children != null)
                return;

            //get the display name of the first logical drive
            fullPath = "";
            this.parent = null;

            //get our drives
            string[] drives = Environment.GetLogicalDrives();

            //create space for the children
            children = new FileSystemNode[drives.Length];

            for (int i = 0; i < drives.Length; i++)
            {
                //create the child value
                children[i] = new FileSystemNode(drives[i], this);
            }

            //get the icon
            GenerateNodeDisplayDetails();
        }
Exemple #30
0
        /// <summary>
        /// Creates a File System node with a given path
        /// </summary>
        /// <param name="path">Path that this node represents</param>
        /// <param name="depth">Integer represnting how deep in the hierarchy this node is</param>
        public FileSystemNode(string path, FileSystemNode parent)
        {
            //fill in the relevant details
            fullPath = path;
            this.parent = parent;

            //get the icon
            GenerateNodeDisplayDetails();
        }
 public void SetAddress(IAddressNode addressNode)
 {
     _currentNode = addressNode;
     ResetBar();
 }