Beispiel #1
0
        /// <summary>
        /// 添加子项
        /// </summary>
        /// <param name="resource"></param>
        public void AppendSubResult(IResourceInfo resource)
        {
            if (ChildItems.Cast <ResourceListViewItem>().Any(s => s.Resource.Provider == resource) || (Resource != null && Resource.Provider == resource.Provider))
            {
                return;
            }

            if (!_subItemCreated)
            {
                _subItemCreated = true;

                var res = Resource;
                ChildItems.Add(new ResourceListViewItem(res, true));

                //重置图标
                ImageKey = "torrent_multi";
                IsBold   = true;
            }

            //设置资源大小
            if (Resource.DownloadSizeCalcauted == 0L)
            {
                Resource.DownloadSize      = resource.DownloadSize;
                Resource.DownloadSizeValue = resource.DownloadSizeValue;
                SubItems[3].Text           = resource.DownloadSizeValue == null ? (resource.DownloadSizeCalcauted == 0L ? resource.DownloadSize.DefaultForEmpty("<未知>") : resource.DownloadSizeCalcauted.ToSizeDescription()) : resource.DownloadSizeValue.Value.ToSizeDescription();
            }
            if (Resource.SupportPreivewType == PreviewType.None)
            {
                Resource.PreviewInfo        = Resource.PreviewInfo ?? resource.PreviewInfo;
                Resource.SupportPreivewType = resource.SupportPreivewType;
                Resource_PreviewTypeChanged(this, null);
            }

            //状态
            if (Resource.VerifyState == VerifyState.Unknown || Resource.VerifyState == VerifyState.None)
            {
                if (resource.VerifyState != VerifyState.Unknown && resource.VerifyState != VerifyState.None)
                {
                    Resource.ChangeVerifyState(resource.VerifyState, resource.ReportNum);
                }
            }
            else
            {
                resource.ChangeVerifyState(Resource.VerifyState, Resource.ReportNum);
            }
            if (resource.Downloaded || Resource.Downloaded)
            {
                resource.ChangeDownloadedStatus(true);
                Resource.ChangeDownloadedStatus(true);
            }

            ChildItems.Add(new ResourceListViewItem(resource, true));
            CheckRowStyle();
        }
Beispiel #2
0
        void CheckRowStyle()
        {
            if (Resource?.ResourceType == ResourceType.MultiResource)
            {
                ForeColor = Color.BlueViolet;
                IsBold    = true;
                return;
            }

            var hasPreferDownloadr = Resource?.PreferDownloadProvider != null || ChildItems.Cast <ResourceListViewItem>().Any(s => s.Resource.PreferDownloadProvider != null);

            if (hasPreferDownloadr)
            {
                ForeColor = Color.RoyalBlue;
                IsBold    = true;
            }
        }
Beispiel #3
0
        /// <summary>
        /// 应用样式
        /// </summary>
        /// <param name="maskName"></param>
        /// <param name="e"></param>
        public void ApplyMark(string maskName, HashMark e)
        {
            if (e != null)
            {
                ForeColor = e.Color;
                BackColor = e.BackColor;
            }
            else
            {
                ForeColor = SystemColors.WindowText;
                BackColor = SystemColors.Window;

                CheckRowStyle();
            }
            SubItems[5].Text = maskName ?? "";

            if (ChildItems != null)
            {
                ChildItems.Cast <ResourceListViewItem>().ForEach(s => s.ApplyMark(maskName, e));
            }
        }