Exemplo n.º 1
0
        public async void bilgileriIsle(string s1, string s2)
        {
            await System.Threading.Tasks.Task.Run(() =>
            {
                try
                {
                    lArray.Clear(); lArray_.Clear();
                    switch (s1)
                    {
                    case "IKISIDE":
                        listView1.Items.Clear();
                        listView2.Items.Clear();
                        break;

                    case "CIHAZ":
                        listView1.Items.Clear();     //lArray.Clear();
                        break;

                    case "SDCARD":
                        listView2.Items.Clear();     //lArray_.Clear();
                        break;
                    }
                    if (listView1.Items.Contains(dizin_yukari) == false)
                    {
                        listView1.Items.Add(dizin_yukari);
                    }
                    if (listView2.Items.Contains(dizin_yukari_) == false)
                    {
                        listView2.Items.Add(dizin_yukari_);
                    }

                    if (s2 == "BOS")
                    {
                        switch (s1)
                        {
                        case "IKISIDE":
                            listView1.BackgroundImageLayout = ImageLayout.Zoom;
                            listView1.BackgroundImage       =
                                Properties.Resources.nothing;
                            listView2.BackgroundImageLayout = ImageLayout.Zoom;
                            listView2.BackgroundImage       =
                                Properties.Resources.nothing;
                            break;

                        case "CIHAZ":
                            listView1.BackgroundImageLayout = ImageLayout.Zoom;
                            listView1.BackgroundImage       =
                                Properties.Resources.nothing;
                            break;

                        case "SDCARD":
                            listView2.BackgroundImageLayout = ImageLayout.Zoom;
                            listView2.BackgroundImage       =
                                Properties.Resources.nothing;
                            break;
                        }
                    }
                    else
                    {
                        string[] lines = s2.Split('<');
                        //MessageBox.Show(lines.Length.ToString());
                        foreach (string line in lines)
                        {
                            string[] parse = line.Split('=');
                            try
                            {
                                ListViewItem lv = new ListViewItem(parse[0]);
                                lv.SubItems.Add(parse[1]);
                                lv.SubItems.Add(parse[2].Replace("XX_FOLDER_XX", "Folder"));
                                lv.SubItems.Add(parse[3]);
                                lv.SubItems.Add(parse[4].Replace("CİHAZ", "Device"));
                                if (parse[2] == "XX_FOLDER_XX")
                                {
                                    lv.ImageKey = "folder";
                                    lv.Tag      = "folder";
                                }
                                else
                                {
                                    if (string.IsNullOrEmpty(parse[2].ToLower()))
                                    {
                                        parse[2] = ".null";
                                    }
                                    if (!ımageList1.Images.ContainsKey(parse[2].ToLower()))
                                    {
                                        ımageList1.Images.Add(parse[2].ToLower(), FileIcon.GetFileIcon(parse[2].ToLower(), FileIcon.IconSize.SHGFI_SMALLICON));
                                    }
                                    lv.ImageKey = parse[2].ToLower();

                                    switch (parse[2].ToLower())
                                    {
                                    case ".html":
                                    case ".htm":
                                    case ".txt":
                                    case ".js":
                                    case ".cs":
                                    case ".php":
                                    case ".h":
                                        lv.Tag = "text";
                                        break;

                                    case ".jpeg":
                                    case ".jpg":
                                    case ".png":
                                    case ".gif":
                                        lv.Tag = "image";
                                        break;

                                    case ".mp3":
                                    case ".wav":
                                    case ".ogg":
                                    case ".3gp":
                                    case ".m4a":
                                    case ".aac":
                                    case ".amr":
                                    case ".flac":
                                    case ".ota":
                                        lv.Tag = "music";
                                        break;

                                    default:
                                        lv.Tag = "null";
                                        break;
                                    }
                                }

                                if (parse[4] == "CİHAZ")
                                {
                                    //listView1.Items.Add(lv);
                                    lArray.Add(lv);
                                    textBox1.Text = parse[5];
                                }
                                else
                                {
                                    if (parse[4] == "SDCARD")
                                    {
                                        //listView2.Items.Add(lv);
                                        lArray_.Add(lv);
                                        textBox2.Text = parse[5];
                                    }
                                }
                            }
                            catch (Exception) { }
                            System.Threading.Tasks.Task.Delay(1).Wait();
                        }
                        listView1.Items.AddRange(lArray.ToArray());

                        listView2.Items.AddRange(lArray_.ToArray());
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
            });

            label7.Text = "Count SD Card: " + (listView2.Items.Count - 1).ToString();
            label6.Text = "Count Device:   " + (listView1.Items.Count - 1).ToString();
        }
Exemplo n.º 2
0
        public async void bilgileriIsle(string s1, string s2)
        {
            await System.Threading.Tasks.Task.Run(() =>
            {
                try
                {
                    lArray.Clear(); lArray_.Clear();
                    switch (s1)
                    {
                    case "IKISIDE":
                        listView1.Items.Clear();
                        listView2.Items.Clear();
                        break;

                    case "CIHAZ":
                        listView1.Items.Clear();     //lArray.Clear();
                        break;

                    case "SDCARD":
                        listView2.Items.Clear();     //lArray_.Clear();
                        break;
                    }
                    if (listView1.Items.Contains(dizin_yukari) == false)
                    {
                        listView1.Items.Add(dizin_yukari);
                    }
                    if (listView2.Items.Contains(dizin_yukari_) == false)
                    {
                        listView2.Items.Add(dizin_yukari_);
                    }

                    if (s2 == "BOS")
                    {
                        switch (s1)
                        {
                        case "IKISIDE":
                            ShowToolTip("EMPTY STORAGE.");
                            break;

                        case "CIHAZ":
                            ShowToolTip("THIS FOLDER IS EMPTY.");
                            break;

                        case "SDCARD":
                            ShowToolTip("THIS FOLDER IS EMPTY.");
                            break;
                        }
                    }
                    else
                    {
                        string[] lines = s2.Split('<');
                        for (int o = 0; o < lines.Length; o++)
                        {
                            string[] parse = lines[o].Split('?');
                            try
                            {
                                ListViewItem lv = new ListViewItem(parse[0]);
                                lv.SubItems.Add(parse[1]);
                                lv.SubItems.Add(parse[2].Replace("XX_FOLDER_XX", "Folder"));
                                lv.SubItems.Add(parse[3]);
                                lv.SubItems.Add(parse[4].Replace("CİHAZ", "Device"));
                                if (parse[2] == "XX_FOLDER_XX")
                                {
                                    lv.ImageKey = "folder";
                                    lv.Tag      = "folder";
                                }
                                else
                                {
                                    if (string.IsNullOrEmpty(parse[2].ToLower()))
                                    {
                                        parse[2] = ".null";
                                    }
                                    if (!ımageList1.Images.ContainsKey(parse[2].ToLower()))
                                    {
                                        ımageList1.Images.Add(parse[2].ToLower(), FileIcon.GetFileIcon(parse[2].ToLower(), FileIcon.IconSize.SHGFI_SMALLICON));
                                    }
                                    lv.ImageKey = parse[2].ToLower();

                                    switch (parse[2].ToLower())
                                    {
                                    case ".html":
                                    case ".htm":
                                    case ".txt":
                                    case ".js":
                                    case ".cs":
                                    case ".php":
                                    case ".h":
                                    case ".xml":
                                        lv.Tag = "text";
                                        break;

                                    case ".jpeg":
                                    case ".jpg":
                                    case ".png":
                                    case ".gif":
                                        lv.Tag = "image";
                                        break;

                                    case ".mp3":
                                    case ".wav":
                                    case ".ogg":
                                    case ".3gp":
                                    case ".m4a":
                                    case ".aac":
                                    case ".amr":
                                    case ".flac":
                                    case ".ota":
                                        lv.Tag = "music";
                                        break;

                                    default:
                                        lv.Tag = "null";
                                        break;
                                    }
                                }

                                if (parse[4] == "CİHAZ")
                                {
                                    //listView1.Items.Add(lv);
                                    lArray.Add(lv);
                                    textBox1.Text = parse[5];
                                }
                                else
                                {
                                    if (parse[4] == "SDCARD")
                                    {
                                        //listView2.Items.Add(lv);
                                        lArray_.Add(lv);
                                        textBox2.Text = parse[5];
                                    }
                                }
                            }
                            catch (Exception) { }
                            //Application.DoEvents();
                            //System.Threading.Tasks.Task.Delay(1).Wait();
                        }
                        listView1.Items.AddRange(lArray.ToArray());

                        listView2.Items.AddRange(lArray_.ToArray());
                    }
                }
                catch (Exception) { }
            });

            if (textBox1.Text != string.Empty)
            {
                label9.Text = "Current Folder (Device): " + textBox1.Text.Substring(textBox1.Text.LastIndexOf('/') + 1);
            }

            if (textBox2.Text != string.Empty)
            {
                label10.Text = "Current Folder (SD Card): " + textBox2.Text.Substring(textBox2.Text.LastIndexOf('/') + 1);
            }

            label7.Text = "Count SD Card: " + (listView2.Items.Count - 1).ToString();
            label6.Text = "Count Device:   " + (listView1.Items.Count - 1).ToString();
        }