Click here to Skip to main content
15,886,689 members
Home / Discussions / C#
   

C#

 
Questionclosing tcp where socket is connected Pin
A_A1-Mar-09 17:49
A_A1-Mar-09 17:49 
AnswerRe: closing tcp where socket is connected Pin
Bharat Jain1-Mar-09 20:42
Bharat Jain1-Mar-09 20:42 
JokeRe: closing tcp where socket is connected Pin
A_A2-Mar-09 3:37
A_A2-Mar-09 3:37 
Questionadd image into image list using image index ( problem) Pin
S K Y1-Mar-09 15:11
S K Y1-Mar-09 15:11 
AnswerRe: add image into image list using image index ( problem) Pin
Luc Pattyn1-Mar-09 16:22
sitebuilderLuc Pattyn1-Mar-09 16:22 
GeneralRe: add image into image list using image index ( problem) Pin
S K Y1-Mar-09 21:07
S K Y1-Mar-09 21:07 
AnswerRe: add image into image list using image index ( problem) Pin
Luc Pattyn2-Mar-09 2:24
sitebuilderLuc Pattyn2-Mar-09 2:24 
QuestionDrag Drop Problem Pin
S K Y1-Mar-09 14:28
S K Y1-Mar-09 14:28 
im doing drag drop to listview imagelist images....selected images.my drag drop part cannot work...i tried so many type of coding but could't now im tring....creat another image list in listview 2 and add those selected items images in to that list view...i can add item text but cannot add image....anyone if can pl help me.....

thanks a lot here is my code...

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Diagnostics;

namespace Project_import_1
{
    public partial class ImportForm : Form
    {
        public ImportForm()
        {
            InitializeComponent();
        }
        OpenFileDialog dlg = new OpenFileDialog();
        

        private void import(object sender, EventArgs e)
        {            
            ImageList imageList = new ImageList();
            imageList.ImageSize = new Size(100, 80);
            imageList.ColorDepth = ColorDepth.Depth32Bit;

            int i = 0;
            string[] files = dlg.FileNames;
            string[] pathes = new string[files.Length];

            foreach (string file in files)
            {
                pathes[i] = file;
                i++;
            }

            foreach (string path in pathes)
            {
                //Image img1 = Image.FromFile(path);
                //imageList.Images.Add(getThumbnaiImage(imageList.ImageSize.Width, img1));
                
                FileInfo fileInfo = new FileInfo(path);
                String strDir = fileInfo.Name;
                listView1.Items.Add(strDir);
                imageList.Images.Add(Bitmap.FromFile(path));
                listView1.TileSize = new System.Drawing.Size(100, 80);

            }
            for (int j = 0; j < pathes.Length; j++)
            {
                //this.listView1.Items.Add("Picture"+(j+1));
                this.listView1.Items[j].ImageIndex = j;
            }
            this.listView1.View = View.LargeIcon;
            this.listView1.LargeImageList = imageList;

        }

        
        private void btnImport_Click(object sender, EventArgs e)
        {
            dlg.Filter = "All Image Files|*.bmp;*.ico;*.gif;*.jpeg;*.jpg;" +
                                "*.jfif;*.png;*.tif;*.tiff;*.wmf;*.emf|" +
                         "Windows Bitmap (*.bmp)|*.bmp|" +
                         "Windows Icon (*.ico)|*.ico|" +
                         "Graphics Interchange Format (*.gif)|*.gif|" +
                         "JPEG File Interchange Format (*.jpg)|" +
                                "*.jpg;*.jpeg;*.jfif|" +
                         "Portable Network Graphics (*.png)|*.png|" +
                         "Tag Image File Format (*.tif)|*.tif;*.tiff|" +
                         "Windows Metafile (*.wmf)|*.wmf|" +
                         "Enhanced Metafile (*.emf)|*.emf|" +
                         "All Files (*.*)|*.*";
            dlg.InitialDirectory = @"C:\Documents and Settings\All Users\Desktop\";
            dlg.Multiselect = true;

            try
            {
                if (dlg.ShowDialog() == DialogResult.OK)
                {
                    import(sender, e);
                }
                dlg.Reset();
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }

        private void btnsave_Click_1(object sender, EventArgs e)
        {
            try
            {
                SaveFileDialog dlgSave = new SaveFileDialog();
                saveFileDialog1.Filter = "*.jpg|*.jpg|*.bmp|*.bmp|*.gif|*.gif";

                saveFileDialog1.ShowDialog();
                if (dlgSave.ShowDialog() == DialogResult.OK)
                {
                    if (dlgSave.FileName != "")
                    {
                        
                    }
                }
            catch
            {
                MessageBox.Show("there is no Pic selected please select a Pic first", "Dear " + System.Environment.UserDomainName);
            }
        }

        private void listView1_ItemDrag(object sender, ItemDragEventArgs e)
        {
            
            this.listView1.DoDragDrop(this.listView1.SelectedItems[0], DragDropEffects.Copy);
        }

        private void listView1_DragEnter(object sender, DragEventArgs e)
        {
            if (e.Data.GetDataPresent(typeof(ListViewItem)))
            {
                e.Effect = DragDropEffects.Copy;
            }
            else
            {
                e.Effect = DragDropEffects.None;
            }
        }

        private void listView2_ItemDrag(object sender, ItemDragEventArgs e)
        {
            this.listView2.DoDragDrop(this.listView2.SelectedItems[0], DragDropEffects.Copy);
        }

        private void listView2_DragEnter(object sender, DragEventArgs e)
        {
            if (e.Data.GetDataPresent(typeof(ListViewItem)))
            {
                e.Effect = DragDropEffects.Copy;
            }
            else
            {
                e.Effect = DragDropEffects.None;
            }
        }

        private void listView2_DragDrop(object sender, DragEventArgs e)
        {           
            ListViewItem item = e.Data.GetData(typeof(ListViewItem)) as ListViewItem;
                      
            this.listView2.View = View.LargeIcon;
            ImageList imageList = new ImageList();
            imageList.ImageSize = new Size(100, 100);
            imageList.ColorDepth = ColorDepth.Depth32Bit;
          
                foreach (ListViewItem each in listView1.SelectedItems)
                { 
                    listView2.Items.Add(item.Text, item.ImageIndex);

                    imageList.Images.Add(Bitmap.FromFile(

*********** HOW CAN I TAKE SELECTED IMAGES TO HERE*********************));

                    listView2.TileSize = new System.Drawing.Size(100, 80);
                }     
            for (int j = 0; j < listView1.SelectedItems.Count; j++)
            {
                this.listView1.Items[j].ImageIndex = j;               
            }
            this.listView2.View = View.LargeIcon;
            this.listView2.LargeImageList = imageList;
                       foreach (ListViewItem removeItem in listView1.SelectedItems)
            {
                listView1.Items.Remove(removeItem);
            }
        }

               private void listView1_MouseDown(object sender, MouseEventArgs e)
        {
            ListViewItem item = e.Data.GetData(typeof(ListViewItem)) as ListViewItem;
            
            DirectoryInfo dir = new DirectoryInfo(Directory.GetCurrentDirectory());
            
            //System.Diagnostics.FileVersionInfo = System.Diagnostics.FileVersionInfo.GetVersionInfo(dir);
            //FileInfo file = new FileInfo(dir());
            //FileInfo fileInfo = new FileInfo(listView1.);
                String strDir = fileInfo.Name;
                listView1.Items.Add(strDir);
            tbxPath.Text = dir.FullName;
            
        }
        protected void DisplayFileInfo(FileInfo TheFile)
        {
            
            //tbCreationTime.Text = TheFile.CreationTime.ToLongTimeString();
            //tbLastAccessTime.Text = TheFile.LastAccessTime.ToLongDateString();
            //tbLastWriteTime.Text = TheFile.LastWriteTime.ToLongDateString();
           //tbxFileName.Text = TheFile.Length.ToString() + " Bytes";
        }
        }
}

AnswerRe: Drag Drop Problem Pin
STeAlth-S1-Mar-09 18:15
STeAlth-S1-Mar-09 18:15 
GeneralRe: Drag Drop Problem Pin
S K Y1-Mar-09 20:49
S K Y1-Mar-09 20:49 
GeneralRe: Drag Drop Problem Pin
STeAlth-S1-Mar-09 23:03
STeAlth-S1-Mar-09 23:03 
GeneralRe: Drag Drop Problem Pin
S K Y2-Mar-09 2:03
S K Y2-Mar-09 2:03 
QuestionWhat the heck? Pin
Paul Brower1-Mar-09 14:15
Paul Brower1-Mar-09 14:15 
AnswerRe: What the heck? Pin
Luc Pattyn1-Mar-09 14:23
sitebuilderLuc Pattyn1-Mar-09 14:23 
QuestionIndexOf returns wrong value if the string to search for contains characters from the Latin Extended-C range Pin
Gerard van Wilgen1-Mar-09 9:34
Gerard van Wilgen1-Mar-09 9:34 
AnswerRe: IndexOf returns wrong value if the string to search for contains characters from the Latin Extended-C range Pin
Luc Pattyn1-Mar-09 13:18
sitebuilderLuc Pattyn1-Mar-09 13:18 
GeneralRe: IndexOf returns wrong value if the string to search for contains characters from the Latin Extended-C range Pin
Gerard van Wilgen2-Mar-09 10:32
Gerard van Wilgen2-Mar-09 10:32 
Questionproblems creating setup for C# application Pin
laziale1-Mar-09 8:28
laziale1-Mar-09 8:28 
AnswerRe: problems creating setup for C# application Pin
Frank Kerrigan1-Mar-09 9:37
Frank Kerrigan1-Mar-09 9:37 
GeneralRe: problems creating setup for C# application Pin
laziale1-Mar-09 9:59
laziale1-Mar-09 9:59 
Questionvirtual node algorithm Pin
sunnyk861-Mar-09 7:43
sunnyk861-Mar-09 7:43 
AnswerRe: virtual node algorithm Pin
Alan N1-Mar-09 8:02
Alan N1-Mar-09 8:02 
GeneralRe: virtual node algorithm Pin
sunnyk861-Mar-09 8:36
sunnyk861-Mar-09 8:36 
Questiondelegate Pin
sheemap1-Mar-09 5:54
sheemap1-Mar-09 5:54 
AnswerRe: delegate Pin
Calin Tatar1-Mar-09 6:01
Calin Tatar1-Mar-09 6:01 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.