Exemple #1
0
        private void OnPreviewFile(object sender, System.EventArgs e)
        {
            if (SelectedItems.Count == 0)
            {
                return;
            }
            sFileDetails FileInfo      = (sFileDetails)krnGateway.GetFileDetails(((InterfaceFile)SelectedItems[0].Tag).strHash);
            string       fileExtension = CUtils.GetExtension(FileInfo.FileName);

            if (CUtils.IsVideo(FileInfo.FileName))
            {
                string player = eAntForm.preferences.GetString("PreviewPlayer");
                if ((player == null) || (player == ""))
                {
                    MessageBox.Show(eAntForm.Globalization["LBL_NOPLAYER"], "Ant", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
                try
                {
                    Process.Start("\"" + player + "\"", "\"" + FileInfo.DiskFileName + "\"");
                }
                catch {}
            }
            else             //not a video file, try to open the default application for the extension
            {
                try
                {
                    RegistryKey key = Registry.ClassesRoot.OpenSubKey(fileExtension);
                    if (key == null)
                    {
                        return;
                    }
                    string type = (string)key.GetValue("");
                    if (type.Length == 0)
                    {
                        return;
                    }
                    key = Registry.ClassesRoot.OpenSubKey(type + "\\shell\\open\\command");
                    if (key == null)
                    {
                        return;
                    }
                    string command = (string)key.GetValue("");
                    if (command.Length == 0)
                    {
                        return;
                    }
                    string exeCommand;
                    if (command.IndexOf("%1") > 0)
                    {
                        exeCommand = command.Replace("%1", FileInfo.DiskFileName);
                    }
                    else
                    {
                        exeCommand = command.Replace("%L", FileInfo.DiskFileName);
                    }
                    string parameters;

                    if (exeCommand.StartsWith("\""))
                    {
                        parameters = exeCommand.Substring(exeCommand.IndexOf("\"", 2) + 2);
                        exeCommand = exeCommand.Substring(0, exeCommand.IndexOf("\"", 2) + 1);
                    }
                    else
                    {
                        parameters = exeCommand.Substring(exeCommand.IndexOf(" ", 2) + 2);
                        exeCommand = exeCommand.Substring(0, exeCommand.IndexOf(" ", 2) + 1);
                    }
                    if (!parameters.StartsWith("\""))
                    {
                        parameters = "\"" + parameters + "\"";
                    }
                    Debug.WriteLine(exeCommand);
                    Debug.WriteLine(parameters);
                    Process.Start(exeCommand, parameters);
                }
                catch (Exception ex)
                {
                    Debug.WriteLine(ex);
                }
            }
        }
Exemple #2
0
        private void CalculateFilterSummary(InterfaceFile[] files)
        {
            ResetFiterSummary();
            string        category;
            int           i = 0;
            bool          isCategoryFiltered;
            InterfaceFile file;

            while (i < files.Length)
            {
                file = files[i];
                i++;
                if (file == null)
                {
                    continue;
                }
                category = "";
                switch (file.Status)
                {
                case 0:
                case 8:
                case 9:
                    category = "Started";
                    break;

                case 1:
                case 2:
                    category = "Stopped";
                    break;
                }
                CFilterSummary filterSummary;

                isCategoryFiltered = false;
                if (CurrentCategoryFilter == "LBL_VIDEO")
                {
                    isCategoryFiltered = (!CUtils.IsVideo(file.Name));
                }
                else if (CurrentCategoryFilter == "LBL_AUDIO")
                {
                    isCategoryFiltered = (!CUtils.IsAudio(file.Name));
                }
                else if (CurrentCategoryFilter == "LBL_FILE")
                {
                    isCategoryFiltered = (!CUtils.IsFile(file.Name));
                }
                else
                {
                    isCategoryFiltered = ((CurrentCategoryFilter.Length != 0) && (CurrentCategoryFilter != file.Category));
                }

                if (!isCategoryFiltered)
                {
                    if (category.Length > 0)
                    {
                        filterSummary            = ((CFilterSummary)FilterSummary[category]);
                        filterSummary.TotalSize += file.Size / 1024 / 1024;
                        filterSummary.Items++;
                    }

                    filterSummary            = ((CFilterSummary)FilterSummary["All"]);
                    filterSummary.TotalSize += file.Size / 1024 / 1024;
                    filterSummary.Items++;
                }
            }
            if (OnSummaryFilterChanged != null)
            {
                OnSummaryFilterChanged(this, null);
            }
        }