示例#1
0
        private void DropItems([NotNull] IEnumerable <IItem> items)
        {
            Debug.ArgumentNotNull(items, nameof(items));

            var favorites = FavoriteManager.GetFavorites();

            var index = favorites.IndexOf(Favorite);

            if (adorner.LastPosition == ControlDragAdornerPosition.Bottom)
            {
                index++;
            }

            ((FavoriteRootTreeViewItem)Parent).AddFavorites(items, index);
        }
示例#2
0
        private void DropFavorites([NotNull] List <BaseTreeViewItem> items)
        {
            Debug.ArgumentNotNull(items, nameof(items));

            var favorites = FavoriteManager.GetFavorites();

            var inserts = new List <Favorite>();

            foreach (var item in items)
            {
                var favoriteItem = (FavoriteTreeViewItem)item;

                inserts.Add(favoriteItem.Favorite);

                favorites.Remove(favoriteItem.Favorite);
            }

            inserts.Reverse();

            var index = favorites.IndexOf(Favorite);

            if (adorner.LastPosition == ControlDragAdornerPosition.Bottom)
            {
                index++;
            }

            if (index < 0)
            {
                index = 0;
            }

            foreach (var favorite in inserts)
            {
                favorites.Insert(index, favorite);
            }

            FavoriteManager.Save();

            var parent = (ItemsControl)Parent;

            for (var i = 0; i < items.Count; i++)
            {
                var item = (FavoriteTreeViewItem)items[i];

                parent.Items.Remove(item);
                parent.Items.Insert(index, item);
            }
        }
示例#3
0
        public void AddFavorites([NotNull] IEnumerable <IItem> baseItems, int index)
        {
            Assert.ArgumentNotNull(baseItems, nameof(baseItems));

            if (Items.Count == 1 && Items[0] == DummyTreeViewItem.Instance)
            {
                Expand(false);
            }

            var favorites = FavoriteManager.GetFavorites();

            if (index < 0 || index > favorites.Count())
            {
                index = favorites.Count();
            }

            foreach (var item in baseItems)
            {
                var fullPath         = item.Name;
                var itemTreeViewItem = item as ItemTreeViewItem;
                if (itemTreeViewItem != null)
                {
                    fullPath = itemTreeViewItem.GetPath();
                }

                var favorite = new Favorite
                {
                    Name           = item.Name,
                    ItemVersionUri = new ItemVersionUri(item.ItemUri, LanguageManager.CurrentLanguage, Version.Latest),
                    FullPath       = fullPath,
                    Icon           = item.Icon
                };

                favorites.Insert(index, favorite);

                var favoriteTreeViewItem = new FavoriteTreeViewItem
                {
                    Text = favorite.Name
                };

                favoriteTreeViewItem.Initialize(favorite);

                Items.Insert(index, favoriteTreeViewItem);
            }

            FavoriteManager.Save();
        }
        public IEnumerable <IItem> GetItems(DatabaseUri databaseUri)
        {
            Assert.ArgumentNotNull(databaseUri, nameof(databaseUri));

            foreach (var favorite in FavoriteManager.GetFavorites())
            {
                if (favorite.ItemVersionUri.DatabaseUri != databaseUri)
                {
                    continue;
                }

                var item = new FavoriteTreeViewItem();
                item.Initialize(favorite);

                yield return(item);
            }
        }
示例#5
0
        public override bool GetChildren(GetChildrenDelegate callback, bool async)
        {
            Assert.ArgumentNotNull(callback, nameof(callback));

            var result = new List <BaseTreeViewItem>();

            var favorites = FavoriteManager.GetFavorites();

            foreach (var favorite in favorites)
            {
                var favoriteTreeViewItem = new FavoriteTreeViewItem
                {
                    Text = favorite.Name
                };

                favoriteTreeViewItem.Initialize(favorite);

                result.Add(favoriteTreeViewItem);
            }

            callback(result);

            return(true);
        }
示例#6
0
文件: Process.cs 项目: radtek/EMIP
        public virtual JObject GetFavoriteProcesses(HttpContext context)
        {
            //System.Threading.Thread.Sleep(3000);
            YZRequest    request = new YZRequest(context);
            string       path    = request.GetString("path", null);
            BPMPermision perm    = request.GetEnum <BPMPermision>("perm", BPMPermision.Execute);
            string       uid     = YZAuthHelper.LoginUserAccount;

            FavoriteCollection favirites;

            using (IYZDbProvider provider = YZDbProviderManager.DefaultProvider)
            {
                using (IDbConnection cn = provider.OpenConnection())
                {
                    favirites = FavoriteManager.GetFavorites(provider, cn, uid, YZResourceType.Process);
                }
            }

            BPMProcessCollection processes;

            using (BPMConnection cn = new BPMConnection())
            {
                cn.WebOpen();
                processes = cn.GetProcessList(path, favirites.ResIDs, perm);
            }

            //将数据转化为Json集合
            JObject rv = new JObject();

            rv[YZJsonProperty.total] = processes.Count;

            JArray children = new JArray();

            rv[YZJsonProperty.children] = children;

            foreach (BPMProcess process in processes)
            {
                if (!process.Property.MobileInitiation)
                {
                    continue;
                }

                JObject item = new JObject();
                children.Add(item);

                item["ProcessName"]    = process.Name;
                item["Active"]         = process.Active;
                item["ProcessVersion"] = process.Version.ToString(2);
                item["Description"]    = process.Property.Description;
                item["RelatedFile"]    = process.Property.RelatedFile;

                item["ShortName"] = process.Property.ShortName;
                item["Color"]     = process.Property.Color;

                if (String.IsNullOrEmpty(process.Property.ShortName))
                {
                    item["ShortName"] = YZStringHelper.GetProcessDefaultShortName(process.Name);
                }
            }

            return(rv);
        }