Пример #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="T:DropboxV2ApiSampleiOS.RootFoldersTableViewController"/> class.
        /// </summary>
        /// <param name="folder">Folder.</param>
        public RootFoldersTableViewController(DropBoxItem folder) : base()
        {
            this.TableView.Source = new DropBoxFolderSource(folder.Path)
            {
                HandleSelection = HandleSelection,
            };

            Title = folder.Name;
        }
Пример #2
0
        public void HandleSelection(DropBoxItem item)
        {
            if (item.ItemType == DropBoxItemType.Folder)
            {
                //mavigate to sub-folder
                var newDbVc = new RootFoldersTableViewController(item);

                NavigationController.PushViewController(newDbVc, true);
            }
        }
Пример #3
0
        private void listView1_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            DropBoxItem boxitem = (DropBoxItem)listView1.SelectedItems[0].Tag;

            if (boxitem.IsFolder)
            {
                path = boxitem.PathDisplay;
                if (!backgroundWorker1.IsBusy)
                {
                    this.UseWaitCursor = true;
                    token = tbtoken.Text;
                    backgroundWorker1.RunWorkerAsync();
                }
            }
        }
Пример #4
0
        private async void connect(object sender, DoWorkEventArgs e)
        {
            dbx = new DropboxClient(token);

            try {
                fullAccount = await dbx.Users.GetCurrentAccountAsync();

                boxItems.Clear();
                this.Invoke((MethodInvoker) delegate() {
                    linfo.Text = "Name:" + fullAccount.Name.DisplayName + "  Email:" + fullAccount.Email;
                    listView1.Items.Clear();
                });

                var list = await dbx.Files.ListFolderAsync(path);

                foreach (var item in list.Entries.Where(i => i.IsFolder))
                {
                    DropBoxItem boxitem = new DropBoxItem();
                    boxitem.Name                = item.Name;
                    boxitem.IsDeleted           = item.IsDeleted;
                    boxitem.IsFile              = item.IsFile;
                    boxitem.IsFolder            = item.IsFolder;
                    boxitem.ParentShareFolderId = item.ParentSharedFolderId;
                    boxitem.PathDisplay         = item.PathDisplay;
                    boxitem.PathLower           = item.PathLower;
                    boxitem.Tag = item;
                    int          imageindex = 0;
                    ListViewItem listItem   = new ListViewItem(boxitem.Name, imageindex);
                    listItem.Tag = boxitem;

                    this.Invoke((MethodInvoker) delegate() {
                        listView1.Items.Add(listItem);
                    });

                    boxItems.Add(boxitem);
                }

                foreach (var item in list.Entries.Where(i => i.IsFile))
                {
                    DropBoxItem boxitem = new DropBoxItem();
                    boxitem.Name                = item.Name;
                    boxitem.IsDeleted           = item.IsDeleted;
                    boxitem.IsFile              = item.IsFile;
                    boxitem.IsFolder            = item.IsFolder;
                    boxitem.ParentShareFolderId = item.ParentSharedFolderId;
                    boxitem.PathDisplay         = item.PathDisplay;
                    boxitem.PathLower           = item.PathLower;
                    boxitem.Size                = (int)(item.AsFile.Size / 8);
                    boxitem.Tag = item;

                    int          imageindex = 1;
                    ListViewItem listItem   = new ListViewItem(boxitem.Name, imageindex);
                    listItem.Tag = boxitem;
                    listItem.SubItems.Add(boxitem.Size.ToString());

                    this.Invoke((MethodInvoker) delegate() {
                        listView1.Items.Add(listItem);
                    });
                    boxItems.Add(boxitem);
                }

                this.UseWaitCursor = false;
            }
            catch (Exception ex)
            {
                this.UseWaitCursor = false;
                MessageBox.Show(ex.Message);
            }
        }
Пример #5
0
    // 初始化
    public void InitDataStruct()
    {
        mDropGroups = new Dictionary <int, DropGroup>();
        System.Type           grouptype = typeof(DropGroupTableItem);
        IDictionaryEnumerator itr       = DataManager.DropGroupTable.GetEnumerator();

        while (itr.MoveNext())
        {
            DropGroupTableItem res       = itr.Value as DropGroupTableItem;
            DropGroup          dropgroup = new DropGroup();
            dropgroup.items = new ArrayList();
            dropgroup.id    = res.id;

            for (int i = 0; i < DropGroupTableItem.MAX_ITEM_NUM; ++i)
            {
                System.Reflection.FieldInfo fieldid = grouptype.GetField("dropBoxId" + i.ToString());
                int dropboxid = (int)fieldid.GetValue(res);

                System.Reflection.FieldInfo fieldweight = grouptype.GetField("dropBoxWeight" + i.ToString());
                int dropboxweight = (int)fieldweight.GetValue(res);

                if (dropboxid < 0 || dropboxweight < 1)
                {
                    break;
                }

                DropGroupItem item = new DropGroupItem();
                item.dropboxid     = dropboxid;
                item.dropboxweight = dropboxweight;

                dropgroup.items.Add(item);
            }

            mDropGroups.Add(res.id, dropgroup);
        }
//      foreach (DropGroupTableItem res in DataManager.DropGroupTable.Values)
//      {
//          DropGroup dropgroup = new DropGroup();
//          dropgroup.items = new ArrayList();
//          dropgroup.id = res.id;
//
//          for (int i = 0; i < DropGroupTableItem.MAX_ITEM_NUM; ++i)
//          {
//              System.Reflection.FieldInfo fieldid = grouptype.GetField("dropBoxId" + i.ToString());
//              int dropboxid = (int)fieldid.GetValue(res);
//
//              System.Reflection.FieldInfo fieldweight = grouptype.GetField("dropBoxWeight" + i.ToString());
//              int dropboxweight = (int)fieldweight.GetValue(res);
//
//              if (dropboxid < 0 || dropboxweight < 1)
//              {
//                  break;
//              }
//
//              DropGroupItem item = new DropGroupItem();
//              item.dropboxid = dropboxid;
//              item.dropboxweight = dropboxweight;
//
//              dropgroup.items.Add(item);
//          }
//
//          mDropGroups.Add(res.id, dropgroup);
//      }

        mDropBoxes = new Dictionary <int, DropBox>();

        System.Type type = typeof(DropBoxTableItem);
        itr = DataManager.DropBoxTable.GetEnumerator();
        while (itr.MoveNext())
        {
            DropBoxTableItem res     = itr.Value as DropBoxTableItem;
            DropBox          dropbox = new DropBox();
            dropbox.items = new ArrayList();
            dropbox.id    = res.id;
            dropbox.desc  = res.desc;

            for (int i = 0; i < DropBoxTableItem.MAX_ITEM_NUM; ++i)
            {
                System.Reflection.FieldInfo fieldid = type.GetField("itemid" + i.ToString());
                int itemid = (int)fieldid.GetValue(res);

                System.Reflection.FieldInfo fieldnum = type.GetField("itemnum" + i.ToString());
                int itemnum = (int)fieldnum.GetValue(res);

                System.Reflection.FieldInfo fieldweight = type.GetField("itemweight" + i.ToString());
                int itemweight = (int)fieldweight.GetValue(res);

                if (itemid < 0 || itemnum < 1 || itemweight < 1)
                {
                    break;
                }

                DropBoxItem item = new DropBoxItem();
                item.itemid            = itemid;
                item.itemnum           = itemnum;
                item.itemweight        = itemweight;
                item.isItemOrCondition = res.isItemId > 0;

                dropbox.items.Add(item);
            }

            mDropBoxes.Add(res.id, dropbox);
        }
//      foreach(DropBoxTableItem res in DataManager.DropBoxTable.Values)
//      {
//
//      }
    }
Пример #6
0
    /// <summary>
    /// 随机生成掉落道具ID。可以直接调该方法,在掉落包内随机掉落道具,不需要在掉落包间随机。
    /// </summary>
    /// <param name="dropboxId">dropbox.txt的Id</param>
    /// <param name="droplist">输出生成的DropItem列表</param>
    /// <param name="dropnum">需要生成几个道具,-1表示不限制个数,按表规则掉落</param>
    /// <returns></returns>
    public bool GenerateDropBox(int dropboxId, out ArrayList droplist, int dropnum = -1)
    {
        droplist = null;

        if (!mDropBoxes.ContainsKey(dropboxId) || !DataManager.DropBoxTable.ContainsKey(dropboxId))
        {
            return(false);
        }

        DropBoxTableItem res = DataManager.DropBoxTable[dropboxId] as DropBoxTableItem;

        DropBox box = mDropBoxes[dropboxId] as DropBox;

        if (box == null)
        {
            return(false);
        }

        droplist = new ArrayList();

        if (dropnum > 0)
        {        // 在dropnum次随机中 不允许重复掉落 在掉落组中整体随机
            while (droplist.Count < dropnum)
            {
                int rand   = Random.Range(0, MAX_WEIGHT);
                int weight = 0;
                for (int i = 0; i < box.items.Count; ++i)
                {
                    DropBoxItem item = box.items[i] as DropBoxItem;

                    if ((item.itemweight + weight) > rand)
                    {
                        if (!droplist.Contains(item))
                        {
                            droplist.Add(item);
                        }

                        break;
                    }

                    weight += item.itemweight;
                }
            }
        }
        else
        {        // 未指定掉落个数 不允许重复掉落 每个道具单独随机
            int maxnum = res.maxnum;
            if (maxnum > box.items.Count)
            {
                maxnum = box.items.Count;
            }

            for (int i = 0; i < box.items.Count; ++i)
            {
                int         rand = Random.Range(0, MAX_WEIGHT);
                DropBoxItem item = box.items[i] as DropBoxItem;
                if ((item.itemweight) > rand)
                {
                    if (!droplist.Contains(item))
                    {
                        droplist.Add(item);
                    }
                }

                if (droplist.Count >= maxnum)
                {
                    break;
                }
            }
        }

        return(true);
    }