Exemplo n.º 1
0
        private void _AddGThread(GThread gThread)
        {
            GLItem item = new GLItem();

            item.Tag = gThread;

            GLSubItem itemName = new GLSubItem();

            itemName.Text = gThread.Name;

            ProgressBar pb        = new ProgressBar();
            GLSubItem   itemUsage = new GLSubItem();

            GLSubItem itemPercent = new GLSubItem();

            itemUsage.Control = pb;
            pb.Minimum        = 0;
            pb.Maximum        = 100;

            item.SubItems.Add(itemName);
            item.SubItems.Add(itemUsage);
            item.SubItems.Add(itemPercent);

            glGTreadList.Items.Add(item);
        }
Exemplo n.º 2
0
        void subItemLen_ChangedEvent(object source, ChangedEventArgs e)
        {
            if (lvGroups.SelectedItems.Count == 0)
            {
                return;
            }
            KnownGroup kg = (KnownGroup)(((GLItem)lvGroups.SelectedItems[0]).Tag);
            GLSubItem  si = (GLSubItem)source;

            kg.NumBytes = Int32.Parse(si.Text);
        }
Exemplo n.º 3
0
        void subItemAddr_ChangedEvent(object source, ChangedEventArgs e)
        {
            if (lvGroups.SelectedItems.Count == 0)
            {
                return;
            }
            KnownGroup kg = (KnownGroup)(((GLItem)lvGroups.SelectedItems[0]).Tag);
            GLSubItem  si = (GLSubItem)source;

            kg.Address = si.Text;
        }
Exemplo n.º 4
0
        private void Form1_Load(object sender, EventArgs e)
        {
            pib_Status.Image = XMouse.Properties.Resources.green;
            GLSubItem sub1, sub2;
            GLItem    gli;
            Icon      ic;

            trb_Speed.Value = settings.ISpeed;
            trb_Speed.Update();
            lbl_Speed.Text = trb_Speed.Value.ToString();
            foreach (string s in settings.PrgList)
            {
                try
                {
                    if (s != "" && s != null)
                    {
                        sub2      = new GLSubItem();
                        sub2.Text = s;
                        ic        = Icon.ExtractAssociatedIcon(s);
                        iList.Images.Add(sub2.Text, ic.ToBitmap());
                        sub1            = new GLSubItem();
                        sub1.ImageIndex = iList.Images.IndexOfKey(sub2.Text);
                        gli             = new GLItem();
                        gli.SubItems.AddRange(new GLSubItem[] { sub1, sub2 });
                        gla_Apps.Items.Add(gli);
                        sub1 = null;
                        sub2 = null;
                        gli  = null;
                    }
                }
                catch (Exception ee)
                {
                    MessageBox.Show(ee.Message + Environment.NewLine + ee.Source);
                }
            }
            Graphics g             = this.CreateGraphics();
            Double   startingPoint = (this.Width / 2) - (g.MeasureString(this.Text.Trim(), this.Font).Width / 2);
            Double   widthOfASpace = g.MeasureString(" ", this.Font).Width;
            String   tmp           = " ";
            Double   tmpWidth      = 0;

            while ((tmpWidth + widthOfASpace) < startingPoint)
            {
                tmp      += " ";
                tmpWidth += widthOfASpace;
            }

            this.Text   = tmp + this.Text.Trim();
            tContrllers = new Thread(CheckControllers);
            tContrllers.Start();
        }
Exemplo n.º 5
0
        public Test()
        {
            this.InitializeComponent();

            this.listview.Columns.Add("Name", 100);
            this.listview.Columns.Add("Value", 300);

            GLItem    item    = this.listview.Items.Add("No.1");
            GLSubItem subItem = item.SubItems.Add("v0");

            subItem.Control = new Controls.StringEditor();

            item            = this.listview.Items.Add("No.2");
            subItem         = item.SubItems.Add("v1");
            subItem.Control = new Controls.ValueEditor();
        }
Exemplo n.º 6
0
        private void btn_add_Click(object sender, EventArgs e)
        {
            Add_App AddForm = new Add_App();

            AddForm.ShowDialog(this);
            if (File.Exists(AddForm.Path))
            {
                settings.PrgList.Add(AddForm.Path);
                GLSubItem sub1 = new GLSubItem();
                iList.Images.Add(AddForm.Path, AddForm.appIcon.ToBitmap());
                sub1.ImageIndex = iList.Images.IndexOfKey(AddForm.Path);
                GLSubItem sub2 = new GLSubItem();
                sub2.Text = AddForm.Path;
                GLItem itm = new GLItem();
                itm.SubItems.AddRange(new GlacialComponents.Controls.GLSubItem[] { sub1, sub2 });
                gla_Apps.Items.Add(itm);
                gla_Apps.Update();
                gla_Apps.Invalidate();
            }
        }
Exemplo n.º 7
0
 public void LoadData()
 {
     if (Groups == null)
     {
         return;
     }
     foreach (var item in Groups.List)
     {
         GLItem    i       = new GLItem();
         GLSubItem si_addr = new GLSubItem();
         si_addr.Text          = item.Address;
         si_addr.ChangedEvent += new ChangedEventHandler(subItemAddr_ChangedEvent);
         GLSubItem si_len = new GLSubItem();
         si_len.ChangedEvent += new ChangedEventHandler(subItemLen_ChangedEvent);
         si_len.Text          = item.NumBytes.ToString();
         i.SubItems.Add(si_addr);
         i.SubItems.Add(si_len);
         i.Tag = item;
         this.lvGroups.Items.Add(i);
     }
 }
Exemplo n.º 8
0
        public bool GLLoad(GLItem item, GLSubItem subItem, GlacialList listctrl)
        {
            this.Format = DateTimePickerFormat.Long;
            try
            {
                m_item = item;
                m_subItem = subItem;
                m_Parent = listctrl;

                this.Text = subItem.Text;

                //this.Value = subItem.Text;
            }
            catch ( Exception ex )
            {
                Debug.WriteLine( ex.ToString() );

                this.Text = DateTime.Now.ToString();
            }

            return true;
        }
Exemplo n.º 9
0
        private void btnAddGroup_Click(object sender, EventArgs e)
        {
            GLItem    i       = new GLItem();
            GLSubItem si_addr = new GLSubItem();

            si_addr.Text          = "0/0/0";
            si_addr.ChangedEvent += new ChangedEventHandler(subItemAddr_ChangedEvent);

            GLSubItem si_len = new GLSubItem();

            si_len.Text          = "1";
            si_len.ChangedEvent += new ChangedEventHandler(subItemLen_ChangedEvent);

            i.SubItems.Add(si_addr);
            i.SubItems.Add(si_len);
            KnownGroup kg = new KnownGroup();

            kg.Address  = "0/0/0";
            kg.NumBytes = 1;
            i.Tag       = kg;
            this.lvGroups.Items.Add(i);
        }
Exemplo n.º 10
0
        private void _AddGThread(GThread gThread)
        {
            GLItem item = new GLItem();
            item.Tag = gThread;

            GLSubItem itemName = new GLSubItem();
            itemName.Text = gThread.Name;

            ProgressBar pb = new ProgressBar();
            GLSubItem itemUsage = new GLSubItem();

            GLSubItem itemPercent = new GLSubItem();

            itemUsage.Control = pb;
            pb.Minimum = 0;
            pb.Maximum = 100;

            item.SubItems.Add(itemName);
            item.SubItems.Add(itemUsage);
            item.SubItems.Add(itemPercent);

            glGTreadList.Items.Add(item);
        }
Exemplo n.º 11
0
        /// <summary>
        /// Instance the activated embeddec control for this item/column
        /// </summary>
        /// <param name="nColumn"></param>
        /// <param name="item"></param>
        /// <param name="subItem"></param>
        protected void ActivateEmbeddedControl( int nColumn, GLItem item, GLSubItem subItem )
        {
            if ( this.m_ActivatedEmbeddedControl != null )
            {
                this.m_ActivatedEmbeddedControl.Dispose();
                this.m_ActivatedEmbeddedControl = null;
            }

            /*
            using activator.createinstance
            typeof()/GetType
            Type t = obj.GetType()
             */

            if ( Columns[nColumn].ActivatedEmbeddedControlTemplate == null )
                return;

            Type type = Columns[nColumn].ActivatedEmbeddedControlTemplate.GetType();
            Control control = (Control)Activator.CreateInstance( type );
            GLEmbeddedControl icontrol = (GLEmbeddedControl)control;

            if ( icontrol == null )
                throw new Exception( @"Control does not implement the GLEmbeddedControl interface, can't start" );

            icontrol.GLLoad( item, subItem, this );

            //control.LostFocus += new EventHandler( ActivatedEmbbed_LostFocus );
            control.KeyPress += new KeyPressEventHandler(tb_KeyPress);

            control.Parent = this;
            this.ActivatedEmbeddedControl = control;
            //subItem.Control = control;							// seed the control

            int nYOffset = (subItem.LastCellRect.Height - m_ActivatedEmbeddedControl.Bounds.Height) / 2;
            Rectangle controlBounds;

            if ( this.GridLineStyle == GLGridLineStyles.gridNone )
            {
                // add 1 to x to give border, add 2 to Y because to account for possible grid that you must cover up
                controlBounds = new Rectangle( subItem.LastCellRect.X+1, subItem.LastCellRect.Y+1, subItem.LastCellRect.Width-3, subItem.LastCellRect.Height-2 );
            }
            else
            {
                // add 1 to x to give border, add 2 to Y because to account for possible grid that you must cover up
                controlBounds = new Rectangle( subItem.LastCellRect.X+1, subItem.LastCellRect.Y+2, subItem.LastCellRect.Width-3, subItem.LastCellRect.Height-3 );
            }
            //control.Bounds = subItem.LastCellRect;	//new Rectangle( subItem.LastCellRect.X, subItem.LastCellRect.Y + nYOffset, subItem.LastCellRect.Width, subItem.LastCellRect.Height );
            control.Bounds = controlBounds;

            control.Show();
            control.Focus();
        }
Exemplo n.º 12
0
        /// <summary>
        /// Draw Sub Item (Cell) at location specified
        /// </summary>
        /// <param name="graphicsSubItem"></param>
        /// <param name="rectSubItem"></param>
        /// <param name="item"></param>
        /// <param name="subItem"></param>
        /// <param name="nColumn"></param>
        public virtual void DrawSubItem( Graphics graphicsSubItem, Rectangle rectSubItem, GLItem item, GLSubItem subItem, int nColumn )
        {
            DW("DrawSubItem");

            // precheck to make sure this is big enough for the things we want to do inside it
            Rectangle subControlRect = new Rectangle( rectSubItem.X, rectSubItem.Y, rectSubItem.Width, rectSubItem.Height );

            if ( ( subItem.Control != null ) && (!subItem.ForceText ) )
            {	// custom embedded control here

                Control control = subItem.Control;

                if ( control.Parent != this )		// *** CRUCIAL *** this makes sure the parent is the list control
                    control.Parent = this;

                //				Rectangle subrc = new Rectangle(
                //					subControlRect.X+this.CellPaddingSize,
                //					subControlRect.Y+this.CellPaddingSize,
                //					subControlRect.Width-this.CellPaddingSize*2,
                //					subControlRect.Height-this.CellPaddingSize*2 );

                Rectangle subrc = new Rectangle(
                    subControlRect.X,
                    subControlRect.Y+1,
                    subControlRect.Width,
                    subControlRect.Height-1 );

                Type tp = control.GetType();
                PropertyInfo pi = control.GetType().GetProperty( "PreferredHeight" );
                if ( pi != null )
                {
                    int PreferredHeight = (int)pi.GetValue( control, null );

                    if ( ( (PreferredHeight + this.CellPaddingSize*2)> this.ItemHeight ) && AutoHeight )
                        this.ItemHeight = PreferredHeight + this.CellPaddingSize*2;

                    subrc.Y = subControlRect.Y + ((subControlRect.Height - PreferredHeight)/2);
                }

                NewLiveControls.Add( control );						// put it in the new list, remove from old list
                if ( LiveControls.Contains( control ) )				// make sure its in the old list first
                {
                    LiveControls.Remove( control );			// remove it from list so it doesn't get put down
                }

                if ( control.Bounds.ToString() != subrc.ToString() )
                    control.Bounds = subrc;							// this will force an invalidation

                if ( control.Visible != true )
                    control.Visible = true;
            }
            else	// not control based
            {
                // if the sub item color is not the same as the back color fo the control, AND the item is not selected, then color this sub item background

                if ( ( subItem.BackColor.ToArgb() != this.BackColor.ToArgb() ) && (!item.Selected) && ( subItem.BackColor != Color.White ) )
                {
                    SolidBrush bbrush = new SolidBrush( subItem.BackColor );
                    graphicsSubItem.FillRectangle( bbrush, rectSubItem );
                    bbrush.Dispose();
                }

                // do we need checkboxes in this column or not?
                if ( this.Columns[ nColumn ].CheckBoxes )
                    rectSubItem = DrawCheckBox( graphicsSubItem, rectSubItem, subItem.Checked );

                // if there is an image, this routine will RETURN with exactly the space left for everything else after the image is drawn (or not drawn due to lack of space)
                if ( (subItem.ImageIndex > -1) && (ImageList != null) && (subItem.ImageIndex < this.ImageList.Images.Count) )
                    rectSubItem = DrawCellGraphic( graphicsSubItem, rectSubItem, this.ImageList.Images[ subItem.ImageIndex ], subItem.ImageAlignment );

                // deal with text color in a box on whether it is selected or not
                Color textColor;
                if ( item.Selected && this.Selectable )
                    textColor = this.SelectedTextColor;
                else
                {
                    textColor = this.ForeColor;
                    if ( item.ForeColor.ToArgb() != this.ForeColor.ToArgb() )
                        textColor = item.ForeColor;
                    else if ( subItem.ForeColor.ToArgb() != this.ForeColor.ToArgb() )
                        textColor = subItem.ForeColor;
                }

                DrawCellText( graphicsSubItem, rectSubItem, subItem.Text, Columns[nColumn].TextAlignment, textColor, item.Selected, ItemWordWrap );

                subItem.LastCellRect = rectSubItem;			// important to ONLY catch the area where the text is drawn
            }
        }
Exemplo n.º 13
0
        // populate this control however you wish with item
        public bool GLLoad( GLItem item, GLSubItem subItem, GlacialList listctrl )
        {
            // set the styles you want for this
            this.BorderStyle = BorderStyle.None;
            this.AutoSize = false;

            m_item = item;
            m_subItem = subItem;
            m_Parent = listctrl;

            this.Text = subItem.Text;

            return true;					// we don't do any heavy processing in this ctrl so we just return true
        }
Exemplo n.º 14
0
        public bool GLLoad(GLItem item, GLSubItem subItem, GlacialList listctrl)
        {
            m_item = item;
            m_subItem = subItem;
            m_Parent = listctrl;

            this.Text = subItem.Text;

            this.Items.Add( "i1" );
            this.Items.Add( "i2" );
            this.Items.Add( "i3" );

            return true;
        }
Exemplo n.º 15
0
        void _logQueue_OnEntryAdded(LogEntry logEntry)
        {
            Async.UI(() => {
                GLItem item = new GLItem();
                item.Tag = logEntry;

                GLSubItem itemTime = new GLSubItem();
                itemTime.Text = logEntry.TimeStamp.ToString("yyyy-MM-dd H:mm:ss.fff");

                GLSubItem itemType = new GLSubItem();
                itemType.Text = logEntry.LogType.ToString();

                GLSubItem itemMesstage = new GLSubItem();
                itemMesstage.Text = logEntry.Message;

                GLSubItem itemParams = new GLSubItem();
                itemParams.Text = "";
                foreach (object o in logEntry.Params)
                    itemParams.Text += o.ToString() + "; ";

                item.SubItems.Add(itemTime);
                item.SubItems.Add(itemType);
                item.SubItems.Add(itemMesstage);
                item.SubItems.Add(itemParams);

                switch (logEntry.LogType) {
                    case LogEntry.LogTypes.Success:
                        item.ForeColor = Color.Green;
                        break;

                    case LogEntry.LogTypes.Warn:
                        item.BackColor = Color.Orange;
                        break;

                    case LogEntry.LogTypes.Debug:
                        item.ForeColor = Color.Gray;
                        break;

                    case LogEntry.LogTypes.Exception:
                        item.ForeColor = Color.Red;
                        break;

                    case LogEntry.LogTypes.Error:
                        item.BackColor = Color.Red;
                        break;

                    case LogEntry.LogTypes.Fatal:
                        item.BackColor = Color.DarkRed;
                        break;

                }

                _logItemMap.Add(logEntry, item);
                glLogList.Items.Add(item);

                if (glLogList.vPanelScrollBar.Visible && cbAutoscroll.Checked) glLogList.vPanelScrollBar.Value = glLogList.vPanelScrollBar.Maximum;
                if (!_doNotUpdate) {
                    glLogList.Invalidate();
                }
            }, glLogList, true);
        }
Exemplo n.º 16
0
        /// <summary>
        /// Changes in the columns, items or subitems
        /// </summary>
        /// <param name="ctType"></param>
        /// <param name="column"></param>
        /// <param name="item"></param>
        /// <param name="subItem"></param>
        public ChangedEventArgs( ChangedTypes ctType, GLColumn column, GLItem item, GLSubItem subItem )
        {
            m_Column = column;
            m_Item = item;
            m_SubItem = subItem;

            m_ctType = ctType;
        }