Exemplo n.º 1
0
 public MyCash()
 {
     listInvoiceItem = new DataTable();
     invoiceTotal = new DataTable();
     InitializeComponent();
     multi_selected = true;
     SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
     position = 0;
     pos_scroll_begin = 1;
     track = false;
     int n_rows = (vScrollBar1.Height-myItem1.Height)/myItem1.Height+2;
     hash=new Hashtable();
     pos_sroll_present = 0;
     for (i = 1; i < n_rows; i++)
     {
         MyItem item = new MyItem(myItem1.Width, myItem1.Height);
         item.Id = i;
         item.Text = "myitems" + i;
         item.Name = item.Text;
         item.Location = new System.Drawing.Point(0,panel_Ban.Height+Label_Ban.Height+ i * myItem1.Height);
         this.Controls.Add(item);
         hash.Add(i,item);
     }
     i--;
     pos_scroll_end = i;
 }
Exemplo n.º 2
0
 public void invadiate_NonMultiSelected(MyItem item)
 {
     if(item.Add)
     {
         for (int k = 1; k <= hash.Count; k++)
         {
             MyItem tmp = (MyItem)hash[k];
             if (tmp.Add)
             {
                 if (tmp.Id == item.Id)
                 {
                     tmp.Set_selected(true);
                 }
                 else
                 {
                     tmp.Set_selected(false);
                     tmp.Click = false;
                 }
                 tmp.Invalidate();
             }
         } 
     }
     
 }
Exemplo n.º 3
0
 private MyItem findRow(int id)
 {
     MyItem r = (MyItem)hash[id];
     if(r==null)
     {
         MyItem item = new MyItem(myItem1.Width, myItem1.Height);
         item.Id = id + 1;
         return item; 
     }
     return r;   
 }
Exemplo n.º 4
0
 public void addRow(string mota, string sl, string gia)
 {
     position ++;
     if(position> pos_scroll_end)
     {
         if(position>i)
         {
             i++;
             MyItem item = new MyItem(myItem1.Width,myItem1.Height);
             item.Text = "myitems" + i;
             item.Name = item.Text;
             item.addRow(i, mota, sl, gia);
             item.Set_selected();
             hash.Add(position, item);
         }
         else
         {
             MyItem tmp = findRow(position);
             tmp.addRow(tmp.Id, mota, sl, gia);
             tmp.Set_selected();
             hash.Remove(position);
             hash.Add(position, tmp);
         }
     }
     else
     {
         MyItem tmp = findRow(position);
         tmp.addRow(position, mota, sl, gia);
         tmp.Set_selected();
         hash.Remove(position);
         hash.Add(position, tmp);
     }        
 }
Exemplo n.º 5
0
        private void ThumbTrack(ScrollEventArgs e)
        {
            if (e.OldValue == 91)
            {
                //MessageBox.Show("maxx");
            }
            else if (e.OldValue <= 0)
            {
                //MessageBox.Show("min");
            }
            else
            {
                if (e.NewValue > pos_sroll_present)
                {
                    int n = e.NewValue - pos_sroll_present;
                    for (int j = 0; j < n; j++)
                    {
                        pos_scroll_begin++;
                        pos_scroll_end++;
                        if (pos_scroll_end > i)
                        {
                            i++;
                            MyItem item = new MyItem(myItem1.Width, myItem1.Height);
                            item.Text = "myitems" + i;
                            item.Id = i;
                            item.Name = item.Text;
                            hash.Add(i, item);
                        }

                        Controls.Remove(findRow(pos_scroll_begin - 1));
                    }
                    drawItems(myItem1.Height, pos_scroll_begin, pos_scroll_end);
                    pos_sroll_present = e.NewValue;
                }
                else
                {
                    int n = pos_sroll_present - e.NewValue;
                    for (int j = 0; j < n; j++)
                    {
                        Controls.Remove(findRow(pos_scroll_end));
                        pos_scroll_begin--;
                        if (pos_scroll_begin < 1)
                        {
                            pos_scroll_begin = 1;
                            break;
                        }
                        pos_scroll_end--;
                    }
                    drawItems(myItem1.Height, pos_scroll_begin, pos_scroll_end);
                    pos_sroll_present = e.NewValue;
                }
            }
        }
Exemplo n.º 6
0
        private void LargeIncrement(ScrollEventArgs e)
        {
            if (e.OldValue == 91)
            {
            }
            else
            {
                for (int j = 0; j < 10; j++)
                {
                    pos_scroll_begin++;
                    pos_scroll_end++;
                    if (pos_scroll_end > i)
                    {
                        i++;
                        MyItem item = new MyItem(myItem1.Width, myItem1.Height);
                        item.Text = "myitems" + i;
                        item.Name = item.Text;
                        item.Id = i;
                        hash.Add(i, item);
                    }

                    Controls.Remove(findRow(pos_scroll_begin - 1));
                }
                drawItems(myItem1.Height, pos_scroll_begin, pos_scroll_end);
                pos_sroll_present = e.NewValue;
            }
        }
Exemplo n.º 7
0
 public void start()
 {
     listInvoiceItem = new DataTable();
     invoiceTotal = new DataTable();
     multi_selected = true;
     SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
     position = 0;
     pos_scroll_begin = 1;
     track = false;
     vScrollBar1.Value = 0;
     int n_rows = (vScrollBar1.Height - myItem1.Height) / myItem1.Height + 2;
     
     int count = this.Controls.Count - 1;
     for (int j = count; j >= 0; j--)
     {
         if(this.Controls[j] is MyItem)
         {
             if (this.Controls[j].Name != "myItem1")
             {
                 var a = this.Controls[j];
                 this.Controls.Remove(this.Controls[j]);
                 a.Dispose();
             }
         }
         //if (this.Controls[j].Name.StartsWith("myitems"))
         //{
         //    var a = this.Controls[j];
         //    this.Controls.Remove(this.Controls[j]);
         //    a.Dispose();
         //    //j--;
         //}
     }
     this.Invalidate();
     hash.Clear();
     hash = new Hashtable();
     pos_sroll_present = 0;
     for (i = 1; i < n_rows; i++)
     {
         MyItem item = new MyItem(myItem1.Width, myItem1.Height);
         item.Id = i;
         item.Text = "myitems" + i;
         item.Name = item.Text;
         item.Location = new System.Drawing.Point(0, panel_Ban.Height + Label_Ban.Height + i * myItem1.Height);
         this.Controls.Add(item);
         hash.Add(i, item);
     }
     i--;
     pos_scroll_end = i;
 }