Exemple #1
0
        public bool RemoveClient(Client client)
        {
            var mayInd = ClientList.FindIndex(c => c.Hwnd == client.Hwnd);

            if (mayInd != -1)
            {
                // アイコンが生成されないとインデックスが不一致になる
                Logger.Info($"removed {client.Title}");
                ClientList.RemoveAt(mayInd);

                if (mayInd < IconList.Count)
                {
                    var icon = IconList[mayInd];
                    RemoveIcon(mayInd);
                    icon?.Dispose( );
                }
                else
                {
                    Logger.Warn($" can't find {mayInd} in Icon ");
                }
                Logger.Warn($"all Client {ClientTitles.ToJson( ) }");
                return(true);
            }
            return(false);
        }
Exemple #2
0
        public void PaintIcon(List <ListBox> clientTitleList, PaintEventArgs e, TagType SelectedTag)
        {
            int selectedIntTag = int.Parse(SelectedTag);

            for (int i = 0; i < TagClientDic.Count; i++)
            {
                var tagMan  = TagClientDic.ElementAt(i).Value;
                var listBox = clientTitleList[i];
                // 現在のタグの上に今のタグを確認するための青い四角を書く
                // todo コンストラクタでリストボックス受け取りたい
                int       tagName = i + 1;
                Rectangle bounds  = listBox.Bounds;
                if (tagName == selectedIntTag)
                {
                    int x = bounds.X;
                    int y = 0;
                    int w = bounds.Width;
                    int h = 12;
                    e.Graphics.FillRectangle(CurrentTagRectBrush, x, y, w, h);
                }
                e.Graphics.DrawString(tagName.ToString( ), NumberFont, NumberBrush, bounds.X + bounds.Width / 4, bounds.Y - 13);
                List <Icon> iconList = tagMan.IconList;
                for (int j = 0; j < iconList.Count; j++)
                {
                    var icon = iconList[j];
                    var size = 12;
                    var rect = new Rectangle(listBox.Left - 16, listBox.Top + j * size + 2, size, size);
                    if (icon != null && icon.Width > 0)
                    {
                        // なんかnullや破棄されていることがあった
                        e.Graphics.DrawIcon(icon, rect);
                    }
                    else
                    {
                        tagMan.RemoveIcon(j);
                        Logger.Warn($"icon {j} removed illegal");
                    }
                }
            }
        }