예제 #1
0
        public void UpdateBreadCrumbs()
        {
            foreach (var item in MainToolStrip.Items.OfType <ToolStripSplitButton>().ToArray())
            {
                MainToolStrip.Items.Remove(item);
            }

            /*var label = new ToolStripLabel("Viewing: ");
             * label.Font = new Font("Segoe UI", 9F, FontStyle.Bold);
             * MainToolStrip.Items.Add(label);*/

            List <XNodeIn> crumbs = new List <XNodeIn>();

            // iterate up tree
            var node = Model.CurrentRoot.XNode;

            while (node != null)
            {
                crumbs.Insert(0, node);

                node = node.Parent as XNodeIn;
            }

            // add crumbs
            foreach (var crumb in crumbs)
            {
                var uiNode    = Model.NodeModels[crumb.ID];
                var crumbName = (crumb.ObjType == XObjType.Root) ? "View" : crumb.Name;

                var button = new ToolStripSplitButton(crumbName);
                button.ButtonClick += (s, e) => Model.SetRoot(uiNode);
                button.Font         = new Font("Segoe UI", 9F, FontStyle.Bold);
                button.ForeColor    = Model.XColors.ObjColors[(int)crumb.ObjType];
                MainToolStrip.Items.Add(button);

                button.DropDownOpening += (s1, e1) =>
                {
                    button.DropDownItems.Clear();

                    foreach (var sub in uiNode.Nodes.OrderBy(n => n, new CompareNodes()))
                    {
                        var subCopy = sub;

                        var item = new ToolStripMenuItem(sub.Name, null, (s2, e2) => Model.SetRoot(subCopy));
                        item.Font      = new Font("Segoe UI", 9F, FontStyle.Bold);
                        item.ForeColor = Model.XColors.ObjColors[(int)sub.ObjType];

                        // freezing with more than 100 items..
                        //if (button.DropDownItems.Count > 100)
                        //    break;

                        button.DropDownItems.Add(item);
                    }
                };
            }

            BackButton.Enabled    = (Model.CurrentHistory != null && Model.CurrentHistory.Previous != null);
            ForwardButton.Enabled = (Model.CurrentHistory != null && Model.CurrentHistory.Next != null);
        }
예제 #2
0
        public MainForm()
        {
            InitializeComponent();

            Model = new ViewModel(this, new BrightColorProfile());

            InitRenderers();
            SetRenderer(typeof(GdiRenderer));

            Model.SetRoot(Model.CurrentRoot); // init first node in history


            RedrawTimer.Interval = 1000 / XRay.TargetFps;
            RedrawTimer.Enabled  = true;

            RevalueTimer.Interval = 1000;
            RevalueTimer.Enabled  = true;

            InstanceTab.Init(this);
            DisplayTab.Init(this);
            ConsoleTab.Init(this);
            CodeTab.Init(this);
            NamespaceTab.Init(this);
            SettingsTab.Init(this);

            CodeTab.Visible      = false;
            InstanceTab.Visible  = false;
            NamespaceTab.Visible = false;

            //var x = Assembly.GetEntryAssembly();
            //Text = Path.GetFileNameWithoutExtension(Assembly.GetEntryAssembly().Location) + " Code Perspective";
            //Text = Path.GetFileName(Process.GetCurrentProcess().MainModule.FileName) + " Code Perspective";

            Text = "Code Perspective";

            if (XRay.Remote != null && XRay.Remote.RemoteDatHash != null)
            {
                Text = "Remote " + Text;
            }

            if (Pro.Verified)
            {
                Text += " Pro";
            }

            Show();
            WindowState = FormWindowState.Normal;
            BringToFront();
        }
예제 #3
0
        private void DoSelectionPass()
        {
            // turn off lighting and draw world as flat colored objects who's color corresponds to their node id
            GLUtils.SafeDisable(EnableCap.Lighting, () =>
            {
                // reset vbo
                Nodes.Reset();

                // call render
                Model.Render();

                // load vbo
                Nodes.Load();

                // draw node vbo
                Nodes.Draw(BeginMode.Triangles);

                // read pixel at cursor
                byte[] rgb = new byte[3];
                GL.ReadPixels(SelectionPoint.X, Height - SelectionPoint.Y, 1, 1, PixelFormat.Rgb, PixelType.UnsignedByte, rgb);

                // convert to color int
                int id = (rgb[0] << 24) | (rgb[1] << 16) | rgb[2];

                // look up in map
                NodeModel node;
                SelectionMap.TryGetValue(id, out node);

                if (SelectionMode == SelectionModes.Single)
                {
                    Model.ClickNode(node);
                }
                else
                {
                    Model.SetRoot(node);
                }
            });

            // clear buffer
            GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);

            // turn off selection mode
            SelectionMode = SelectionModes.None;
        }