Beispiel #1
0
        protected override void OnEnter(EventArgs e)
        {
            bool flag = true;

            base.OnEnter(e);
            if (_layout != null)
            {
                if (_layout.NodeCount > 0)
                {
                    ServerLabel serverLabel = _layout.LabelArray[_layout.FocusedServerIndex - 1];
                    if (serverLabel.Parent == this)
                    {
                        serverLabel.Focus();
                        flag = false;
                    }
                }
            }
            else
            {
                ServerBase serverBase = ServerTree.Instance.SelectedNode as ServerBase;
                if (serverBase != null)
                {
                    serverBase.Focus();
                    flag = false;
                }
            }
            if (flag)
            {
                Focus();
            }
        }
Beispiel #2
0
 public void HideGroup(GroupBase group)
 {
     if (_layout != null)
     {
         if (_layout.Group != group)
         {
             return;
         }
         _groupScrollPosition[group] = _verticalScrollBar.Value;
         try
         {
             ServerLabel   serverLabel = Program.TheForm.ActiveControl as ServerLabel;
             ServerLabel[] labelArray  = _layout.LabelArray;
             foreach (ServerLabel serverLabel2 in labelArray)
             {
                 if (serverLabel == serverLabel2)
                 {
                     Program.TheForm.ActiveControl = this;
                 }
                 serverLabel2.Server.Hide();
                 base.Controls.Remove(serverLabel2);
             }
         }
         finally
         {
             _layout = null;
         }
     }
     _verticalScrollBar.Hide();
 }
Beispiel #3
0
        private static void MenuPopup(object sender, CancelEventArgs e)
        {
            _menu.Items.Clear();
            ServerLabel serverLabel = (sender as ContextMenuStrip).SourceControl as ServerLabel;
            ServerBase  server      = serverLabel.AssociatedNode;

            MenuHelper.AddSessionMenuItems(_menu, server);
            _menu.Items.Add("-");
            _menu.Items.Add(new DelegateMenuItem("E&xpand", MenuNames.SessionExpand, delegate
            {
                ServerTree.Instance.SelectedNode = server;
                if (server.IsConnected)
                {
                    server.Focus();
                }
            }));
            MenuHelper.AddDockingMenuItems(_menu, server);
            _menu.Items.Add("-");
            MenuHelper.AddMaintenanceMenuItems(_menu, server);
            Program.PluginAction(delegate(IPlugin p)
            {
                p.OnContextMenu(_menu, server);
            });
            e.Cancel = false;
        }
Beispiel #4
0
        private List <ServerLabel> CreateThumbnailList()
        {
            List <ServerLabel> labelList = new List <ServerLabel>();
            HashSet <Server>   set       = new HashSet <Server>();
            bool useActualNode           = Group is VirtualGroup;

            Group.VisitNodes(delegate(RdcTreeNode node)
            {
                GroupBase groupBase = node as GroupBase;
                if (groupBase != null)
                {
                    groupBase.InheritSettings();
                }
                else
                {
                    ServerBase serverBase = node as ServerBase;
                    Server serverNode     = serverBase.ServerNode;
                    if (!set.Contains(serverNode))
                    {
                        groupBase = (serverNode.Parent as GroupBase);
                        if (groupBase != null)
                        {
                            groupBase.InheritSettings();
                            if (groupBase.DisplaySettings.ShowDisconnectedThumbnails.Value || serverNode.IsConnected)
                            {
                                ServerLabel item = new ServerLabel(useActualNode ? serverBase : serverNode);
                                labelList.Add(item);
                                set.Add(serverNode);
                            }
                        }
                    }
                }
            });
            return(labelList);
        }
Beispiel #5
0
        private void ComputeThumbnailPosition(ServerLabel label)
        {
            int value          = label.Server.DisplaySettings.ThumbnailScale.Value;
            int width          = _thumbnailUnitWidth * value + 8 * (value - 1);
            int serverHeight   = GetServerHeight(value);
            int thumbnailIndex = label.ThumbnailIndex;
            int num            = _layout.ServerTileY[thumbnailIndex];
            int num2           = _layout.ServerTileX[thumbnailIndex];
            int x = (num2 + 1) * 8 + num2 * _thumbnailUnitWidth;
            int y = (num + 1) * 6 + num * (_thumbnailUnitHeight + ThumbnailLabelHeight);

            _layout.SetThumbnailAbsoluteBounds(thumbnailIndex, x, y, width, serverHeight);
        }
Beispiel #6
0
 private void DrawThumbnails(int oldValue, int newValue, int height)
 {
     foreach (int item in GetUndrawnServersInViewport(newValue, height))
     {
         _thumbnailDrawn[item - 1] = true;
         ServerLabel label = _layout.LabelArray[item - 1];
         if (!_layout.IsServerPositionComputed(item))
         {
             ComputeThumbnailPosition(label);
         }
         DrawThumbnail(label, oldValue);
     }
 }
Beispiel #7
0
        private void DrawThumbnail(ServerLabel label, int windowTop)
        {
            Rectangle thumbnailAbsoluteBounds = _layout.GetThumbnailAbsoluteBounds(label.ThumbnailIndex);
            int       num    = thumbnailAbsoluteBounds.Top - windowTop;
            int       top    = num + ThumbnailLabelHeight - 1;
            Server    server = label.Server;

            server.SetThumbnailView(thumbnailAbsoluteBounds.X, top, thumbnailAbsoluteBounds.Width, thumbnailAbsoluteBounds.Height);
            label.Size     = new Size(thumbnailAbsoluteBounds.Width, ThumbnailLabelHeight);
            label.Location = new Point(thumbnailAbsoluteBounds.X, num);
            base.Controls.Add(label);
            label.Show();
            server.Show();
            if (Program.TheForm.ActiveControl == this && label.ThumbnailIndex == _layout.FocusedServerIndex)
            {
                label.Focus();
                _layout.FocusedServerIndex = 0;
            }
        }
Beispiel #8
0
        public void ScrollServerIntoView(ServerLabel label)
        {
            int thumbnailIndex = label.ThumbnailIndex;

            if (!_layout.IsServerPositionComputed(thumbnailIndex))
            {
                ComputeThumbnailPosition(label);
            }
            Rectangle thumbnailAbsoluteBounds = _layout.GetThumbnailAbsoluteBounds(thumbnailIndex);
            int       num    = thumbnailAbsoluteBounds.Bottom + ServerLabel.Height;
            int       height = base.ClientSize.Height;

            if (thumbnailAbsoluteBounds.Top < _verticalScrollBar.Value || num > _verticalScrollBar.Value + height - 1)
            {
                int value          = _verticalScrollBar.Value;
                int scrollPosition = (value >= thumbnailAbsoluteBounds.Top) ? thumbnailAbsoluteBounds.Top : (num - height + 1);
                SetScrollPosition(scrollPosition);
                DrawAndScroll(value, _verticalScrollBar.Value);
            }
        }
Beispiel #9
0
        protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
        {
            ServerLabel serverLabel = Program.TheForm.ActiveControl as ServerLabel;

            if (serverLabel == null)
            {
                if (_layout == null || Program.TheForm.ActiveControl != this)
                {
                    return(base.ProcessCmdKey(ref msg, keyData));
                }
                serverLabel = _layout.LabelArray[_layout.FocusedServerIndex - 1];
            }
            _layout.EnsureTabIndex();
            int value          = serverLabel.Server.DisplaySettings.ThumbnailScale.Value;
            int thumbnailIndex = serverLabel.ThumbnailIndex;
            int num            = _layout.ServerTileX[thumbnailIndex];
            int num2           = _layout.ServerTileY[thumbnailIndex];
            int tabIndex       = serverLabel.TabIndex;

            switch (keyData)
            {
            case Keys.Tab:
            case Keys.LButton | Keys.Back | Keys.Shift:
                ServerTree.Instance.Focus();
                return(true);

            case Keys.Left:
                if (--tabIndex == 0)
                {
                    return(true);
                }
                thumbnailIndex = _layout.TabIndexToServerIndex[tabIndex];
                num            = _layout.ServerTileX[thumbnailIndex];
                num2           = _layout.ServerTileY[thumbnailIndex];
                break;

            case Keys.Right:
                if (++tabIndex > _layout.NodeCount)
                {
                    return(true);
                }
                thumbnailIndex = _layout.TabIndexToServerIndex[tabIndex];
                num            = _layout.ServerTileX[thumbnailIndex];
                num2           = _layout.ServerTileY[thumbnailIndex];
                break;

            case Keys.Up:
                if (--num2 < 0)
                {
                    return(true);
                }
                break;

            case Keys.Down:
                num2 += value;
                if (num2 > _layout.LowestTileY)
                {
                    return(true);
                }
                break;

            case Keys.Home:
                num  = 0;
                num2 = 0;
                break;

            case Keys.End:
                num  = _layout.ServerLayoutToIndex.GetUpperBound(1);
                num2 = _layout.LowestTileY;
                break;

            case Keys.Prior:
            {
                if (num2 == 0)
                {
                    return(true);
                }
                int val3 = (int)Math.Floor((double)serverLabel.Top / (double)UnitHeight);
                int val4 = base.Height / UnitHeight;
                int num4 = Math.Max(val3, val4);
                num2 = Math.Max(0, num2 - num4);
                break;
            }

            case Keys.Next:
            {
                if (num2 == _layout.LowestTileY)
                {
                    return(true);
                }
                int val  = (int)Math.Floor((double)(serverLabel.Top + GetServerHeight(value)) / (double)UnitHeight);
                int val2 = base.Height / UnitHeight;
                int num3 = Math.Max(val, val2);
                num2 = Math.Min(_layout.LowestTileY, num2 + num3);
                break;
            }

            default:
                return(base.ProcessCmdKey(ref msg, keyData));
            }
            while (true)
            {
                thumbnailIndex = _layout.ServerLayoutToIndex[num2, num];
                if (thumbnailIndex != 0)
                {
                    break;
                }
                num--;
            }
            serverLabel = _layout.LabelArray[thumbnailIndex - 1];
            ScrollServerIntoView(serverLabel);
            serverLabel.Focus();
            return(true);
        }
Beispiel #10
0
 public void RecordLastFocusedServerLabel(ServerLabel label)
 {
     _layout.FocusedServerIndex = label.ThumbnailIndex;
 }
Beispiel #11
0
        public void Compute(int numAcross)
        {
            using (Helpers.Timer("computing thumbnail layout"))
            {
                List <ServerLabel> list = CreateThumbnailList();
                LabelArray = list.ToArray();
            }
            if (NodeCount == 0)
            {
                return;
            }
            using (Helpers.Timer("sorting {0} thumbnails", NodeCount))
            {
                Array.Sort(LabelArray, new LayoutComparer());
            }
            SetThumbnailIndex();
            FocusedServerIndex = 1;
            _maxNodeIndex      = NodeCount + 1;
            int num = 0;
            List <List <ServerLabel> > list2 = new List <List <ServerLabel> >();
            List <ServerLabel>         list3 = null;

            ServerLabel[] labelArray = LabelArray;
            int           value;

            foreach (ServerLabel serverLabel in labelArray)
            {
                value = serverLabel.Server.DisplaySettings.ThumbnailScale.Value;
                if (list3 != null && num == value)
                {
                    list3.Add(serverLabel);
                    continue;
                }
                list3 = new List <ServerLabel>();
                list3.Add(serverLabel);
                list2.Add(list3);
                num = value;
            }
            value = LabelArray[0].Server.DisplaySettings.ThumbnailScale.Value;
            ServerLayoutToIndex       = new int[NodeCount * value, Math.Max(numAcross, value)];
            _isServerPositionComputed = new bool[_maxNodeIndex];
            _thumbnailAbsoluteBounds  = new Rectangle[_maxNodeIndex];
            ServerTileX = new int[_maxNodeIndex];
            ServerTileY = new int[_maxNodeIndex];
            using (Helpers.Timer("laying out {0} thumbnails", NodeCount))
            {
                int num2 = 0;
                int num3 = 0;
                while (list2.Count > 0)
                {
                    bool flag = false;
                    int  num4 = -1;
                    for (int j = 0; j < list2.Count; j++)
                    {
                        list3 = list2[j];
                        ServerLabel serverLabel2 = list3[0];
                        value = serverLabel2.Server.DisplaySettings.ThumbnailScale.Value;
                        if (num4 != -1 && value > num4)
                        {
                            break;
                        }
                        bool flag2 = false;
                        if (num2 == 0 || num2 + value <= numAcross)
                        {
                            int  num5  = Math.Min(value, numAcross);
                            bool flag3 = true;
                            for (int k = 0; k < num5; k++)
                            {
                                for (int l = 0; l < value; l++)
                                {
                                    if (ServerLayoutToIndex[num3 + l, num2 + k] != 0)
                                    {
                                        num4  = k;
                                        flag3 = false;
                                        break;
                                    }
                                }
                                if (!flag3)
                                {
                                    break;
                                }
                            }
                            if (flag3)
                            {
                                flag2 = true;
                            }
                        }
                        if (flag2)
                        {
                            int thumbnailIndex = serverLabel2.ThumbnailIndex;
                            for (int m = 0; m < value; m++)
                            {
                                for (int n = 0; n < value; n++)
                                {
                                    ServerLayoutToIndex[num3 + n, num2 + m] = thumbnailIndex;
                                }
                            }
                            ServerTileX[thumbnailIndex] = num2;
                            ServerTileY[thumbnailIndex] = num3;
                            LowestTileY = Math.Max(LowestTileY, num3 + value - 1);
                            flag        = true;
                            list3.Remove(serverLabel2);
                            if (list3.Count == 0)
                            {
                                list2.Remove(list3);
                            }
                            num2 += value;
                            if (num2 >= numAcross)
                            {
                                num2 = 0;
                                num3++;
                            }
                            break;
                        }
                    }
                    if (!flag && ++num2 >= numAcross)
                    {
                        num2 = 0;
                        num3++;
                    }
                }
            }
        }