예제 #1
0
 void CreateTab(string tabname, string lvname, GetItemDelegate gidel,GetCollection gcdel)
 {
     if (tabControl1.TabPages.ContainsKey(tabname))
     {
         currentView = (EnhancedListView)tabControl1.Controls[lvname];
     }
     else
     {
         if (gidel == null)
             return;
         TabPage newTP = new TabPage(tabname);
         newTP.Name = tabname;
         currentView = new EnhancedListView();
         currentView.FullRowSelect = true;
         currentView.GridLines = true;
         currentView.Name = lvname;
         currentView.TabIndex = 0;
         currentView.UseCompatibleStateImageBehavior = false;
         currentView.View = View.Details;
         currentView.VirtualMode = true;
         currentView.Dock = DockStyle.Fill;
         currentView.SetCallback(gidel);
         currentView.Tag = gcdel;
         currentView.ContextMenuStrip = contextMenuStrip1;
         newTP.Controls.Add(currentView);
         tabControl1.TabPages.Add(newTP);
     }
     tabControl1.SelectTab(tabname);
 }
        /// <summary>
        /// 信息展示窗体构造器
        /// </summary>
        /// <param name="EapCommonQuery">查询实体</param>
        /// <param name="getItemCallBack">获取EapItem的方法</param>
        /// <param name="filter">过滤器:不带where的条件语句</param>
        public frmShowEapItemList(EapCommonQuery EapCommonQuery, GetItemDelegate getItemCallBack, string filter)
        {
            InitializeComponent();
            this.EapCommonQuery = EapCommonQuery;
            this.sendEvent     += getItemCallBack;
            this.strWhere       = filter;

            Func.FormatForm(this);
        }
        internal static TItem GetItem <TItem>(Visual parent, string[] headerTexts, ShowNextItem <TItem> showNextItem) where TItem : Visual
        {
            GetItemDelegate <TItem, string> getItem = (visual, headerText) =>
            {
                IsMatch <TItem> isMatch = (item) => (GetItemText(item) == headerText);
                Next <TItem>    next    = null;
                next = (v) => GetItemCore(v, isMatch, next);
                return(GetItemCore(visual, isMatch, next));
            };

            return(GetItem <TItem, string>(parent, headerTexts, getItem, showNextItem));
        }
        internal static TItem GetItem <TItem>(Visual parent, int[] indices, ShowNextItem <TItem> showNextItem) where TItem : Visual
        {
            GetItemDelegate <TItem, int> getItem = (visual, index) =>
            {
                int             currentIndex = 0;
                IsMatch <TItem> isMatch      = (v) => (currentIndex++ == index);
                Next <TItem>    next         = null;
                next = (v) => GetItemCore(v, isMatch, next);
                return(GetItemCore(visual, isMatch, next));
            };

            return(GetItem <TItem, int>(parent, indices, getItem, showNextItem));
        }
예제 #5
0
        public static TransitType GetInstance(
            string ticket, GetItemDelegate functor, Cache cache, TimeSpan ts,
            string cacheticket)
        {
            if (cache == null)
            {
                return(functor(ticket));
            }
            string      key      = GetCacheKey(functor.Method.Name, cacheticket);
            TransitType instance = default(TransitType);

            if (!TryGet(cache, key, out instance))
            {
                instance = functor(ticket);
                Insert(cache, key, instance, ts);
            }
            return(instance);
        }
예제 #6
0
        /// <summary>
        /// 初始化.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void FormMain_Load(object sender, EventArgs e)
        {
            //增加列标题
            this.lvSourceData.Columns.Add("ID编号", 30, HorizontalAlignment.Center);
            this.lvSourceData.Columns.Add("名称", 50, HorizontalAlignment.Center);
            this.lvSourceData.Columns.Add("处理线程", 60, HorizontalAlignment.Center);
            this.lvSourceData.Columns.Add("处理状态", 100, HorizontalAlignment.Center);


            for (int i = 1; i <= 20; i++)
            {
                string[]     str  = new string[] { i.ToString(), "项目" + i, "", "" };
                ListViewItem item = new ListViewItem(str, 0);
                lvSourceData.Items.Add(item);
            }


            GetItem = this.GetFirstNotProcessItem;
        }
예제 #7
0
        /// <summary>
        /// 初始化.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void FormMain_Load(object sender, EventArgs e)
        {
            //增加列标题
            this.lvSourceData.Columns.Add("ID编号", 30, HorizontalAlignment.Center);
            this.lvSourceData.Columns.Add("名称", 50, HorizontalAlignment.Center);
            this.lvSourceData.Columns.Add("处理线程", 60, HorizontalAlignment.Center);
            this.lvSourceData.Columns.Add("处理状态", 100, HorizontalAlignment.Center);

            
            for (int i = 1; i <= 20; i++)
            {
                string[] str = new string[] { i.ToString(), "项目" + i, "", "" };
                ListViewItem item = new ListViewItem(str, 0);
                lvSourceData.Items.Add(item);
            }


            GetItem = this.GetFirstNotProcessItem;
        }
예제 #8
0
        public static TransitType GetInstance <TypeArg1>(
            string ticket, TypeArg1 arg1, GetItemDelegate <TypeArg1> functor, Cache cache, TimeSpan ts,
            string cacheticket)
        {
            if (cache == null)
            {
                return(functor(ticket, arg1));
            }
            object[]    args     = { arg1 };
            string      key      = GetCacheKey(functor.Method.Name, args, cacheticket);
            TransitType instance = default(TransitType);

            if (!TryGet(cache, key, out instance))
            {
                instance = functor(ticket, arg1);
                Insert(cache, key, instance, ts);
            }
            return(instance);
        }
        static TItem GetItem <TItem, T>(Visual parent, T[] indices, GetItemDelegate <TItem, T> getItem, ShowNextItem <TItem> showNextItem)
            where TItem : Visual
        {
            Visual v = parent;

            for (int i = 0; i < indices.Length; i++)
            {
                var item = getItem(v, indices[i]);
                if (item == null)
                {
                    throw new NotSupportedException(ResourcesLocal3.Instance.ErrorNotFoundItem);
                }
                if (i == indices.Length - 1)
                {
                    return(item);
                }
                showNextItem(item);
                v = item;
            }
            return(null);
        }
예제 #10
0
        internal static TItem GetItem <TItem>(Visual parent, object[] indices, ShowNextItem <TItem> showNextItem) where TItem : Visual
        {
            GetItemDelegate <TItem, object> getItem = (visual, obj) =>
            {
                int             currentIndex = 0;
                IsMatch <TItem> isMatch      = (v) =>
                {
                    if (obj is int)
                    {
                        return(currentIndex++ == (int)obj);
                    }
                    else if (obj is string)
                    {
                        return(GetItemText(v) == (string)obj);
                    }
                    throw new NotSupportedException();
                };
                Next <TItem> next = null;
                next = (v) => GetItemCore(v, isMatch, next);
                return(GetItemCore(visual, isMatch, next));
            };

            return(GetItem <TItem, object>(parent, indices, getItem, showNextItem));
        }
예제 #11
0
        public SpreadsheetViewModel(Extensions extensions, ModuleBuilder mb, int rows, int cols)
        {
            Type rowType = RowViewModelBase.Initialize(mb, cols);
            Type gt = typeof(ObservableCollection<>);
            Type cgt = gt.MakeGenericType(rowType);

            _getItem = CreateGetItemDelegate(cgt);
            _add = CreateAddDelegate(cgt, rowType);

            _rows = Activator.CreateInstance(cgt);
            _model = new SpreadsheetModel(extensions);

            for (int i = 0; i < rows; i++) {
                RowViewModelBase row = RowViewModelBase.Create(mb, this, i + 1, cols);
                _add(_rows, row);
            }
        }
예제 #12
0
 public void SetCallback(GetItemDelegate del)
 {
     GetItem = del;
 }