Beispiel #1
0
        private void AddFoundConnections(IEnumerable<Info> iEnumerable)
        {
            try
            {
                var l = new List<EXImageListViewItem>();
                foreach (var info in iEnumerable)
                {
                    var item = new EXImageListViewItem { Tag = info };
                    item.SubItems.Add(new EXBoolListViewSubItem(true));
                    item.SubItems.Add(new EXImageListViewSubItem(Connection.Icon.FromString(info.Icon).ToBitmap()));
                    item.SubItems.Add(info.Description);
                    item.SubItems.Add(info.Protocol.ToString());
                    item.SubItems.Add(info.Hostname);
                    item.SubItems.Add(info.Port.ToString());
                    l.Add(item);
                }
                if (lvFoundConections.InvokeRequired)
                {
                    lvFoundConections.Invoke(new MethodInvoker(() =>
                                                                   {
                                                                       lvFoundConections.Items.AddRange(l.ToArray());
                                                                   }));
                }
                else
                {
                    lvFoundConections.Items.AddRange(l.ToArray());
                }
            }
            catch (Exception)
            {

            }
            
        }
Beispiel #2
0
        // Token: 0x0600002F RID: 47 RVA: 0x00003114 File Offset: 0x00001314
        private void this_DrawSubItem(object sender, DrawListViewSubItemEventArgs e)
        {
            e.DrawBackground();
            if (e.ColumnIndex == this._sortcol)
            {
                e.Graphics.FillRectangle(this._sortcolbrush, e.Bounds);
            }
            if ((e.ItemState & ListViewItemStates.Selected) != (ListViewItemStates)0)
            {
                e.Graphics.FillRectangle(this._highlightbrush, e.Bounds);
            }
            int fonty = e.Bounds.Y + e.Bounds.Height / 2 - e.SubItem.Font.Height / 2;
            int x     = e.Bounds.X + 2;

            if (e.ColumnIndex == 0)
            {
                EXListViewItem item = (EXListViewItem)e.Item;
                if (item.GetType() == typeof(EXImageListViewItem))
                {
                    EXImageListViewItem imageitem = (EXImageListViewItem)item;
                    if (imageitem.MyImage != null)
                    {
                        Image img  = imageitem.MyImage;
                        int   imgy = e.Bounds.Y + e.Bounds.Height / 2 - img.Height / 2;
                        e.Graphics.DrawImage(img, x, imgy, img.Width, img.Height);
                        x += img.Width + 2;
                    }
                }
                e.Graphics.DrawString(e.SubItem.Text, e.SubItem.Font, new SolidBrush(e.SubItem.ForeColor), (float)x, (float)fonty);
            }
            else
            {
                EXListViewSubItemAB subitem = e.SubItem as EXListViewSubItemAB;
                if (subitem == null)
                {
                    e.DrawDefault = true;
                }
                else
                {
                    x = subitem.DoDraw(e, x, base.Columns[e.ColumnIndex] as EXColumnHeader);
                    e.Graphics.DrawString(e.SubItem.Text, e.SubItem.Font, new SolidBrush(e.SubItem.ForeColor), (float)x, (float)fonty);
                }
            }
        }
                private void button1_Click(object sender, EventArgs e)
                {
                    try
                    {
                        /*if (AllFieldsSet() == false)
                        {
                            Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg,
                                                                Language.strPleaseFillAllFields);
                            return;
                        }*/

                        lvSSHFileBrowser.Items.Clear();
                        var ssh = new SftpClient(txtHost.Text, int.Parse(this.txtPort.Text), txtUser.Text, txtPassword.Text);
                        ssh.Connect();
                        var res = ssh.ListDirectory(txtRemoteFolderPath.Text).ToList().OrderBy(file => !file.IsDirectory).ThenBy(file => file.Name);
                        var l = new List<EXImageListViewItem>();
                        foreach (var item in res)
                        {
                            if (item.Name==".")
                            {
                                continue;
                            }
                            var imglstvitem = new EXImageListViewItem
                            {
                                MyImage =
                                    item.IsDirectory
                                        ? global::My.Resources.Resources.Folder
                                        : global::My.Resources.Resources.File,
                                MyValue = item.FullName,
                                Tag = item
                            };
                            imglstvitem.SubItems.Add(item.Name);
                            imglstvitem.SubItems.Add(item.IsDirectory ? "" : Tools.Misc.LengthToHumanReadable(item.Length));
                            l.Add(imglstvitem);
                        }
                        ssh.Disconnect();
                        lvSSHFileBrowser.Items.AddRange(l.ToArray());
                        lvSSHFileBrowser.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }
                private void btnLocalBrowserGo_Click(object sender, EventArgs e)
                {
                    try
                    {
                        var l = new List<EXImageListViewItem>();
                        lvLocalBrowser.Items.Clear();
                        if (txtLocalBrowserPath.Text == "")
                        {
                            foreach (string str in Directory.GetLogicalDrives())
                            {
                                var imglstvitem = new EXImageListViewItem
                                {
                                    MyImage = global::My.Resources.Resources.Folder,
                                    MyValue = str,
                                    Tag = "Folder"
                                };
                                imglstvitem.SubItems.Add(str);
                                imglstvitem.SubItems.Add("");
                                lvLocalBrowser.Items.Add(imglstvitem);
                            }
                            return;
                        }
                        EXImageListViewItem li = new EXImageListViewItem();
                        li.MyValue = txtLocalBrowserPath.Text;
                        li.Tag = "[..]";
                        li.SubItems.Add("[..]");
                        li.SubItems.Add("");
                        l.Add(li);
                        var d = Directory.GetDirectories(txtLocalBrowserPath.Text);
                        foreach (var s1 in d)
                        {
                            var imglstvitem = new EXImageListViewItem
                            {
                                MyImage = global::My.Resources.Resources.Folder,
                                MyValue = s1,
                                Tag = "Folder"
                            };
                            imglstvitem.SubItems.Add(Path.GetFileName(s1));
                            imglstvitem.SubItems.Add("");
                            l.Add(imglstvitem);
                        }
                        var s = Directory.GetFiles(txtLocalBrowserPath.Text);
                        
                        foreach (var s1 in s)
                        {
                            var imglstvitem = new EXImageListViewItem
                            {
                                MyImage = global::My.Resources.Resources.File,
                                MyValue = s1,
                                Tag = "File"
                            };
                            imglstvitem.SubItems.Add(Path.GetFileName(s1));
                            imglstvitem.SubItems.Add(Tools.Misc.LengthToHumanReadable(new FileInfo(s1).Length));
                            /*li.SubItems.Add()*/
                            l.Add(imglstvitem);
                        }

                        lvLocalBrowser.Items.AddRange(l.ToArray());
                        lvLocalBrowser.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
                        lvLocalBrowser.Refresh();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }

                }