Exemple #1
0
        public TreeItemViewModel(
            TextSpan textSpan,
            SourceText sourceText,
            DocumentId documentId,
            string fileName,
            Glyph glyph,
            ImmutableArray <ClassifiedSpan> classifiedSpans,
            ValueTrackingTreeViewModel treeViewModel,
            IGlyphService glyphService,
            IThreadingContext threadingContext,
            Workspace workspace,
            ImmutableArray <TreeItemViewModel> children)
        {
            FileName         = fileName;
            TextSpan         = textSpan;
            _sourceText      = sourceText;
            ClassifiedSpans  = classifiedSpans;
            TreeViewModel    = treeViewModel;
            ThreadingContext = threadingContext;

            _glyph        = glyph;
            _glyphService = glyphService;
            Workspace     = workspace;
            DocumentId    = documentId;

            if (!children.IsDefaultOrEmpty)
            {
                foreach (var child in children)
                {
                    ChildItems.Add(child);
                }
            }

            sourceText.GetLineAndOffset(textSpan.Start, out var lineStart, out var _);
            sourceText.GetLineAndOffset(textSpan.End, out var lineEnd, out var _);
            LineSpan = LineSpan.FromBounds(lineStart, lineEnd);

            PropertyChanged += (s, e) =>
            {
                if (e.PropertyName == nameof(IsLoading))
                {
                    NotifyPropertyChanged(nameof(ShowGlyph));
                }
            };

            TreeViewModel.PropertyChanged += (s, e) =>
            {
                if (e.PropertyName == nameof(TreeViewModel.HighlightBrush))
                {
                    // If the highlight changes we need to recalculate the inlines so the
                    // highlighting is correct
                    NotifyPropertyChanged(nameof(Inlines));
                }
            };
        }
Exemple #2
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();
        }
Exemple #3
0
 public MenuItem this[int index]
 {
     get
     {
         if (ChildItems.Any())
         {
             return(ChildItems[index]);
         }
         return(null);
     }
 }
Exemple #4
0
 public int GetMaxItemId()
 {
     if (ChildItems.Count == 0)
     {
         return(Id);
     }
     else
     {
         return(Math.Max(ChildItems.Select(x => x.GetMaxItemId()).ToList().Max(), Id));
     }
 }
Exemple #5
0
 public BookmarkItem GetItemById(int id)
 {
     if (Id == id)
     {
         return(this);
     }
     else
     {
         return(ChildItems.FirstOrDefault(x => x.Id == id));
     }
 }
Exemple #6
0
        /// <summary>
        /// Pres the save.
        /// </summary>
        /// <param name="dbContext">The database context.</param>
        /// <param name="state">The state.</param>
        public override void PreSaveChanges(Data.DbContext dbContext, System.Data.Entity.EntityState state)
        {
            var channel = this.ContentChannel;

            if (state == System.Data.Entity.EntityState.Deleted)
            {
                ChildItems.Clear();
                ParentItems.Clear();
            }

            base.PreSaveChanges(dbContext, state);
        }
Exemple #7
0
 public bool Equals(NavigationBarItem?other)
 {
     return(other != null &&
            Text == other.Text &&
            Glyph == other.Glyph &&
            Bolded == other.Bolded &&
            Grayed == other.Grayed &&
            Indent == other.Indent &&
            ChildItems.SequenceEqual(other.ChildItems) &&
            Spans.SequenceEqual(other.Spans) &&
            EqualityComparer <TextSpan?> .Default.Equals(NavigationSpan, other.NavigationSpan));
 }
Exemple #8
0
 /// <summary>
 /// Cuts all the single-child root, returning the first child that has more than 1 child of its own.
 /// If the first node has 0 childs, returns itself.
 /// Doesn't set the new root node parent to null.
 /// </summary>
 public ObservableCollection <ModelTreeItem> Trim()
 {
     if (this.ChildItems.Count == 1)
     {
         return(ChildItems[0].Trim());
     }
     else if (!ChildItems.Any(ci => ci.HasData))
     {
         return(new ObservableCollection <ModelTreeItem>(ChildItems.SelectMany(ci => ci.Trim())));
     }
     return(new ObservableCollection <ModelTreeItem>(new ModelTreeItem[] { this }));
 }
Exemple #9
0
        public ResourceListViewItem(IResourceInfo resource, bool multiEngine)
        {
            Resource    = resource;
            MultiEngine = multiEngine;

            //初始化结构
            Text = resource.Title.GetSubString(100);
            SubItems.AddRange(new[]
            {
                "",
                "",
                resource.HasSubResources ? "(多个资源)" : resource.DownloadSizeValue == null ? (resource.DownloadSizeCalcauted == 0L ? resource.DownloadSize.DefaultForEmpty("<未知>") : resource.DownloadSizeCalcauted.ToSizeDescription()) : resource.DownloadSizeValue.Value.ToSizeDescription(),
                resource.FileCount == null ? "----" : resource.FileCount.Value.ToString("N0"),
                "",
                resource.UpdateTime.HasValue ? resource.UpdateTime.Value.ToString("yyyy-MM-dd") : resource.UpdateTimeDesc
            });
            Resource_PreviewTypeChanged(this, null);

            UseItemStyleForSubItems = true;
            ImageKey = resource.HasSubResources ? "multiresource" : multiEngine ? "e_" + resource.Provider.Info.Name : GetImageKey(resource);

            //初始化标记
            RefreshItemMask();
            if (!resource.IsHashLoaded)
            {
                Resource.DetailLoaded += Resource_DetailLoaded;
            }
            else
            {
                RefreshDownloadStatus();
                RefreshIllegalStatus();
            }
            resource.PreviewTypeChanged += Resource_PreviewTypeChanged;

            CheckRowStyle();

            IsExpanded = false;
            if (resource.HasSubResources)
            {
                //多个资源项
                if (resource.SubResources == null)
                {
                    ChildItems.Add(new PaddingLoadingItem());
                    resource.SubResourceLoaded += (s, e) => AppContext.UiInvoke(LoadSubResources);
                }
                else
                {
                    LoadSubResources();
                    IsExpanded = true;
                }
            }
        }
Exemple #10
0
        public BookmarkItem(Bookmarks.BookmarkItem bookmarkItem, int level)
        {
            Level = level;
            Core  = bookmarkItem;

            if (bookmarkItem.ChildItems != null)
            {
                foreach (var childItem in bookmarkItem.ChildItems)
                {
                    ChildItems.Add(new BookmarkItem(childItem, Level + 1));
                }
            }
        }
Exemple #11
0
        public BurgerMenuItem GetChildItemByKey(string key)
        {
            IEnumerable <BurgerMenuItem> matchingChildren = ChildItems.Where(bmi => bmi.Key.EndsWith(key));

            if (matchingChildren.Any())
            {
                return(matchingChildren.First());
            }
            else
            {
                return(null);
            }
        }
Exemple #12
0
        /// <summary>
        /// 标记安全状态
        /// </summary>
        public void RefreshIllegalStatus()
        {
            if (/*!AppContext.Instance.Options.EnableCloudSaftyCheckOverride || */ Resource.Downloaded)
            {
                return;
            }

            AppContext.UiInvoke(() =>
            {
                ListView?.BeginUpdate();

                SubItems[2].Image = null;

                switch (Resource.VerifyState)
                {
                case VerifyState.Unknown:
                    break;

                case VerifyState.None:
                    break;

                case VerifyState.Verified:
                    SubItems[2].Image = Properties.Resources.tick_shield;
                    break;

                case VerifyState.Reported:
                    SubItems[2].Image = Properties.Resources.exclamation_shield;
                    break;

                case VerifyState.Illegal:
                case VerifyState.Fake:
                    SubItems[2].Image = Properties.Resources.cross_shield;
                    break;

                case VerifyState.AutoFake:
                case VerifyState.AutoIllegal:
                    SubItems[2].Image = Properties.Resources.minus_shield;
                    break;

                default:
                    break;
                }

                ChildItems.OfType <ResourceListViewItem>().ForEach(s =>
                {
                    s.Resource.ChangeVerifyState(Resource.VerifyState, Resource.ReportNum);
                    s.RefreshIllegalStatus();
                });
                ListView?.EndUpdate();
            });
        }
Exemple #13
0
        public override void AddItem(IScreenItem item)
        {
            var childItem = item as TreeItem <T>;

            if (childItem != null)
            {
                //if this is child tree item, add it special
                ChildItems.Add(childItem);
            }
            else
            {
                base.AddItem(item);
            }
        }
Exemple #14
0
        public BurgerMenuCommandItem AddChildCommandItem(string key,
                                                         string menuTitle,
                                                         CachyFont.Glyph glyph,
                                                         string methodName)
        {
            BurgerMenuCommandItem commandItem = new BurgerMenuCommandItem(string.Format("{0}.{1}", Key, key),
                                                                          menuTitle,
                                                                          glyph,
                                                                          this,
                                                                          methodName);

            ChildItems.Add(commandItem);
            return(commandItem);
        }
Exemple #15
0
        /// <summary>
        /// 更新组下所有设备的参数 位置  增删改等
        /// </summary>
        private void UpdateChildPara()
        {
            var para = Wlst.Sr.SlusglInfoHold.Services.SluSglFieldGrpHold.MySlef.Get(FileId, NodeId);

            if (para == null)
            {
                this.ChildItems.Clear();
                return;
            }

            //delete
            var dlt = (from t in ChildItems where para.CtrlLst.Contains(t.NodeId) == false select t).ToList();

            foreach (var f in dlt)
            {
                if (ChildItems.Contains(f))
                {
                    ChildItems.Remove(f);
                }
            }

            var dic = new List <int>();

            //update setinfo
            foreach (var f in ChildItems)
            {
                f.UpdateShowInfo();
                dic.Add(f.NodeId);
            }

            //newadd
            foreach (var f in para.CtrlLst)
            {
                if (dic.Contains(f))
                {
                    continue;
                }
                ChildItems.Add(new CtrlNodeItem(FileId, f));
            }
            this.Sort(para.CtrlLst);

            ////add  and  sort
            //for (int i = 0; i < para.CtrlLst.Count; i++)
            //{
            //    int cur = para.CtrlLst[i];
            //    if (ChildItems.Count < i + 1) ChildItems.Add(dic[cur]);
            //    else if (ChildItems[i].NodeId != cur) ChildItems.Insert(i, dic[cur]);
            //}
        }
Exemple #16
0
        void LoadSubResources()
        {
            Array.ForEach(ChildItems.OfType <PaddingLoadingItem>().ToArray(), s => s.Remove());

            //appnd sub items
            ListView?.BeginUpdate();

            foreach (var item in ChildItems.OfType <PaddingLoadingItem>().ToArray())
            {
                item.Remove();
            }
            ChildItems.AddRange(Resource.SubResources.Select(s => new ResourceListViewItem(s, false)));

            ListView?.EndUpdate();
        }
Exemple #17
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;
            }
        }
Exemple #18
0
        public BurgerMenuViewItem AddChildViewItem(string key,
                                                   string menuTitle,
                                                   CachyFont.Glyph glyph,
                                                   string pageTitle,
                                                   Type pageViewType,
                                                   bool clearInstanceOnNavigate)
        {
            BurgerMenuViewItem viewItem = new BurgerMenuViewItem(string.Format("{0}.{1}", Key, key),
                                                                 menuTitle,
                                                                 glyph,
                                                                 pageTitle,
                                                                 pageViewType,
                                                                 clearInstanceOnNavigate);

            ChildItems.Add(viewItem);
            return(viewItem);
        }
Exemple #19
0
        /// <summary>
        /// Pres the save.
        /// </summary>
        /// <param name="dbContext">The database context.</param>
        /// <param name="state">The state.</param>
        public override void PreSaveChanges(Data.DbContext dbContext, EntityState state)
        {
            var channel = this.ContentChannel;

            if (state == EntityState.Deleted)
            {
                ChildItems.Clear();
                ParentItems.Clear();

                DeleteRelatedSlugs(dbContext);
            }
            else
            {
                AssignItemGlobalKey(dbContext);
            }

            base.PreSaveChanges(dbContext, state);
        }
Exemple #20
0
        public void OrderChildsByDataAndText(bool recursive)
        {
            var orderedChildItems = this.ChildItems.OrderBy(c => c.Text).OrderBy(c => c.Data != null).ToArray();

            ChildItems.Clear();
            foreach (var childItem in orderedChildItems)
            {
                this.ChildItems.Add(childItem);
            }

            if (recursive)
            {
                foreach (var child in ChildItems)
                {
                    child.OrderChildsByDataAndText(recursive);
                }
            }
        }
Exemple #21
0
        public void RemoveCollectionsRecursive()
        {
            if (this.IsVirtual)
            {
                this.ParentItem?.ChildItems.Remove(this);
                foreach (var child in ChildItems)
                {
                    this.ParentItem?.ChildItems.Add(child);
                }
            }

            var childs = ChildItems.ToArray();

            foreach (var child in childs)
            {
                child.RemoveCollectionsRecursive();
            }
        }
 public void LoadWorkItemStates()
 {
     WorkItemStates = new List <string>();
     if (WorkItemTypes != null)
     {
         foreach (WorkItemType workItemType in WorkItemTypes)
         {
             FieldDefinition stateFieldDefintion = workItemType.FieldDefinitions[CoreField.State];
             foreach (string allowedValue in stateFieldDefintion.AllowedValues)
             {
                 if (!WorkItemStates.Contains(allowedValue) && ChildItems.Contains(workItemType.Name))
                 {
                     WorkItemStates.Add(allowedValue);
                 }
             }
         }
     }
     OnPropertyChanged("WorkItemStates");
 }
Exemple #23
0
 private void SearchChild()
 {
     if (string.IsNullOrWhiteSpace(XPath.SelectItem) == false)
     {
         List <HtmlNode> nodes = null;
         ControlExtended.SafeInvoke(
             () => nodes = HtmlDoc.DocumentNode.SelectNodesPlus(XPath.SelectItem, SelectorFormat.XPath).ToList());
         ChildItems.Clear();
         if (nodes == null)
         {
             XLogSys.Print.Info(GlobalHelper.Get("key_665"));
             return;
         }
         nodes.Execute(d => ChildItems.Add(new CrawlItem
         {
             XPath       = d.XPath,
             SampleData1 = d.InnerHtml
         }));
     }
 }
Exemple #24
0
        public BookmarkItem GetParentItem(int id)
        {
            if (ChildItems.Exists(x => x.Id == id))
            {
                return(this);
            }
            else
            {
                foreach (var childItem in ChildItems)
                {
                    var bookmarkItem = childItem.GetParentItem(id);
                    if (bookmarkItem != null)
                    {
                        return(bookmarkItem);
                    }
                }

                return(null);
            }
        }
Exemple #25
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));
            }
        }
Exemple #26
0
 /// <summary>
 /// Used to convert member of old Configuration class to ConfigurationV2
 /// </summary>
 /// <param name="configOld1">old member of Configuration</param>
 public void CopyFromConfigurationOld1(Configuration configOld1)
 {
     TeamProjectCollection = configOld1.TeamProjectCollection;
     TeamProject           = configOld1.TeamProject;
     ChildItems.AddRange(configOld1.ChildItems);
     BacklogItems.AddRange(configOld1.BacklogItems);
     foreach (var state in configOld1.States)
     {
         States.Add(state.Clone() as ICustomState);
     }
     SortFieldName          = configOld1.SortFieldName;
     SortDirection          = configOld1.SortDirection;
     RowSummaryFieldName    = configOld1.RowSummaryFieldName;
     ColumnSummaryFieldName = configOld1.ColumnSummaryFieldName;
     LinkType = configOld1.LinkType;
     QueryId  = configOld1.QueryId;
     ReportId = configOld1.ReportId;
     ReportParameters.AddRange(configOld1.ReportParameters);
     IsAutoRefreshChecked = defaultIsAutoRefreshChecked;
     AutoRefreshDelay     = defaultAutoRefreshDelay;
 }
Exemple #27
0
        private async void DeleteButton_Clicked(object sender, EventArgs e)
        {
            var btn            = sender as IconButton;
            var deleteItemArgs = new DeleteItemEventArgs()
            {
                Id   = btn.Tag as String,
                Type = Field.Name.ToPropertyName()
            };

            var obj = ChildItems as Object;

            if (obj is System.Collections.IList)
            {
                if (await SLWIOC.Get <LagoVista.Core.PlatformSupport.IPopupServices>().ConfirmAsync(XPlatResources.Msg_ConfirmDeleteItemTitle, XPlatResources.Msg_ConfirmDeleteItem))
                {
                    var childList       = ChildItems as System.Collections.IList;
                    var itemToBeDeleted = ChildItems.Where(itm => itm.ToEntityHeader().Id == btn.Tag as string).FirstOrDefault();
                    childList.Remove(itemToBeDeleted);
                    Deleted?.Invoke(sender, deleteItemArgs);
                    Refresh();
                }
            }
        }
        public void Sort(List <int> sortlst)
        {
            var slsdfs = (from t in ChildItems where sortlst.Contains(t.NodeId) select t.NodeId).ToList();
            var st     = (from t in sortlst where slsdfs.Contains(t) select t).Distinct().ToList();
            var notex  = (from t in ChildItems where st.Contains(t.NodeId) == false select t).ToList();

            foreach (var f in notex)
            {
                if (ChildItems.Contains(f))
                {
                    ChildItems.Remove(f);
                }
            }


            for (int i = 0; i < ChildItems.Count; i++)
            {
                if (ChildItems[i].NodeId == st[i])
                {
                    continue;
                }
                foreach (var l in ChildItems)
                {
                    if (l.NodeId == st[i])
                    {
                        var tmp = l;
                        ChildItems.Remove(l);
                        ChildItems.Insert(i, tmp);
                        break;
                    }
                }
            }
            foreach (var f in notex)
            {
                ChildItems.Add(f);
            }
        }
Exemple #29
0
        public Ship(World world, Vector2 position, float rotation, Faction faction, int id)
            : base(world)
        {
            //初始化数据
            base.Position = position;
            positionl     = position;
            base.Rotation = rotation;
            this.faction  = faction;
            this.id       = id;

            //如果要将Ship类作为抽象类并创建多个种类的船则删除以下信息
            maxSpeed     = 25f;
            acceleration = 10f;
            ChildItems.Add(new Sail(world, this, new Vector2(0, 0), faction, 1f));
            //ChildItems.Add(new Sail(world, this, new Vector2(0,-109),faction,0.5f));
            //ChildItems.Add(new Sail(world, this, new Vector2(0, 34), faction, 0.75f));
            this.Texture   = @"Ship";
            Scale          = 0.15f;
            boundingRadius = 15f;
            angularRate    = 45f;
            rangeOfView    = 400f;
            addWaveSpan    = 1f;

            ChildItems.Add(new Cannon(world, this, 90));
            cannons.Add((Cannon)ChildItems.LatestAddedItem);
            ChildItems.Add(new Cannon(world, this, -90));
            cannons.Add((Cannon)ChildItems.LatestAddedItem);

            selectionRadius        = 50f;
            selectionTexture       = GameOperators.Content.Load <Texture2D>(@"Circle1");
            selectionTextureCenter = new Vector2(selectionTexture.Width / 2, selectionTexture.Height / 2);
            if (selectionTexture.Width > 0)
            {
                selectionTextureScale = selectionRadius / selectionTexture.Width * 1.3f;
            }
        }
Exemple #30
0
        /// <summary>
        /// 标记为已下载
        /// </summary>
        public void RefreshDownloadStatus(bool initialCall = true)
        {
            AppContext.UiInvoke(() =>
            {
                ListView?.BeginUpdate();
                SubItems[2].Image = null;

                if (Resource.Downloaded)
                {
                    SubItems[2].Image = Properties.Resources.down_16;
                }
                else if (Resource.VerifyState != VerifyState.Unknown && initialCall)
                {
                    RefreshIllegalStatus();
                }

                ChildItems.OfType <ResourceListViewItem>().ForEach(s =>
                {
                    s.Resource.ChangeDownloadedStatus(Resource.Downloaded);
                    s.RefreshDownloadStatus(false);
                });
                ListView?.EndUpdate();
            });
        }