public void AddItemToRender(GLItem item) { if (!m_ItemsToRender.Contains (item)) { m_ItemsToRender.Add (item); } }
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); }
public void AddItemToRender(GLItem item) { if (!m_ItemsToRender.Contains(item)) { m_ItemsToRender.Add(item); } }
private void torrentList_Click(object sender, EventArgs e) { if (torrentList.SelectedItems.Count != 0) { int selectedIndex = torrentList.Items.FindItemIndex((GLItem)torrentList.SelectedItems[0]); torrentNameLbl.Text = "Name: " + torrentFiles[selectedIndex].name; torrentSizeLbl.Text = "Size: " + (Math.Round(torrentFiles[selectedIndex].size / 1048576, 2)).ToString() + "MB"; torrentCommentLbl.Text = "Comment: " + torrentFiles[selectedIndex].comment; torrentPathLbl.Text = "Path: " + torrentFiles[selectedIndex].path; outPathLbl.Text = "Out path: " + torrentFiles[selectedIndex].savePath; torrentBar.Value = (int)torrentFiles[torrentList.Items.FindItemIndex((GLItem)torrentList.SelectedItems[0])].downloadProgress; torrentBar.PointToClient(torrentTabs.Location); filesList.Items.Clear(); torrentTabs.Enabled = true; foreach (MonoTorrent.Common.TorrentFile file in torrentFiles[selectedIndex].torrent.Files) { float fileLength = (float)Math.Round((double)file.Length / 1048576, 2); float downloaded = (float)Math.Round((double)file.BytesDownloaded / 1048576, 2); GLItem gl = filesList.Items.Add(file.Path); FProgressBar bar = new FProgressBar(); gl.SubItems[1].Control = bar; bar.Value = MathUtils.PercentageOf(downloaded, fileLength); } filesList.Refresh(); UpdateSizes(); } }
private void btnRemoveGroup_Click(object sender, EventArgs e) { if (lvGroups.SelectedItems != null && lvGroups.SelectedItems.Count == 1) { GLItem item = (GLItem)lvGroups.SelectedItems[0]; lvGroups.Items.Remove(item); } }
private void btnApply_Click(object sender, EventArgs e) { this.Groups = new KnownGroupsList(); foreach (var item in lvGroups.Items) { GLItem i = (GLItem)item; KnownGroup kg = (KnownGroup)i.Tag; this.Groups.List.Add(kg); } }
// ***************************************************************** // **** Event Handlers **** // ***************************************************************** // // // // **** OrderHub_BookChanged() **** // public void OrderHub_BookChanged(object sender, EventArgs eventArgs) { if (this.InvokeRequired) { this.Invoke(new EventHandler(OrderHub_BookChanged), new object[] { sender, eventArgs }); } else { OrderBookEventArgs eventArg = (OrderBookEventArgs)eventArgs; Order order = eventArg.Order; if (eventArg.EventType == OrderBookEventArgs.EventTypes.NewOrder) { m_OrderBook.TryAddOrder(order); GLItem item = new GLItem(); m_GList[order.Side].Items.Add(item); if (order.Side == 1) { item.SubItems[0].Text = order.IPrice.ToString(); item.SubItems[1].Text = order.Qty.ToString(); item.SubItems[2].ImageIndex = 0; //item.SubItems[2].ImageAlignment = HorizontalAlignment.Center; item.SubItems[3].Text = "Default"; } else { item.SubItems[3].Text = order.IPrice.ToString(); item.SubItems[2].Text = order.Qty.ToString(); item.SubItems[1].ImageIndex = 0; //item.SubItems[2].ImageAlignment = HorizontalAlignment.Center; item.SubItems[0].Text = "Default"; } } else if (eventArg.EventType == OrderBookEventArgs.EventTypes.DeletedOrder) { m_OrderBook.TryDeleteOrder(order.Tag, out order); GLItem foundItem = null; foreach (GLItem item in m_GList[order.Side].Items) { if (item.Text == order.Tag) { foundItem = item; } } if (foundItem != null) { m_GList[order.Side].Items.Remove(foundItem); } } else if (eventArg.EventType == OrderBookEventArgs.EventTypes.DeletedOrder) { //m_OrderBook.TryDeleteOrder(eventArg.Order); } } }//OrderHub_BookChanged()
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(); }
// Use this for initialization void Start() { //Calculate world co-ordinates //8 vertices for outline (determined from collider) Bounds bounds = GetComponent <Collider>().bounds; Vector3 center = bounds.center; float xExtent = bounds.extents.x; float yExtent = bounds.extents.y; float zExtent = bounds.extents.z; WorldVertices[0] = center + new Vector3(-xExtent, -yExtent, -zExtent); WorldVertices[1] = center + new Vector3(xExtent, -yExtent, -zExtent); WorldVertices[2] = center + new Vector3(xExtent, -yExtent, zExtent); WorldVertices[3] = center + new Vector3(-xExtent, -yExtent, zExtent); WorldVertices[4] = center + new Vector3(-xExtent, yExtent, -zExtent); WorldVertices[5] = center + new Vector3(xExtent, yExtent, -zExtent); WorldVertices[6] = center + new Vector3(xExtent, yExtent, zExtent); WorldVertices[7] = center + new Vector3(-xExtent, yExtent, zExtent); WorldHealthVertices[0] = new Vector3(WorldVertices[6].x, WorldVertices[6].y, WorldVertices[6].z); WorldHealthVertices[0].y -= 0.1f; WorldHealthVertices[0].z -= 0.1f; WorldHealthVertices[1] = new Vector3(WorldHealthVertices[0].x, WorldHealthVertices[0].y - m_HealthSize, WorldHealthVertices[0].z); WorldHealthVertices[2] = new Vector3(WorldHealthVertices[0].x, WorldHealthVertices[0].y - m_HealthSize, WorldHealthVertices[0].z - m_HealthSize); WorldHealthVertices[3] = new Vector3(WorldHealthVertices[0].x, WorldHealthVertices[0].y, WorldHealthVertices[0].z - m_HealthSize); WorldHealthVertices[4] = new Vector3(WorldVertices[7].x, WorldVertices[7].y, WorldVertices[7].z); WorldHealthVertices[4].y -= 0.1f; WorldHealthVertices[4].z -= 0.1f; WorldHealthVertices[5] = new Vector3(WorldHealthVertices[4].x, WorldHealthVertices[4].y - m_HealthSize, WorldHealthVertices[0].z); WorldHealthVertices[6] = new Vector3(WorldHealthVertices[4].x, WorldHealthVertices[4].y - m_HealthSize, WorldHealthVertices[0].z - m_HealthSize); WorldHealthVertices[7] = new Vector3(WorldHealthVertices[4].x, WorldHealthVertices[4].y, WorldHealthVertices[0].z - m_HealthSize); //Assign health width m_HealthWidth = Mathf.Abs(WorldHealthVertices[0].x - WorldHealthVertices[4].x); //Create GLItem m_GLItem = new GLItem(ExecuteFunction); //Resolve GLManager m_GLManager = ManagerResolver.Resolve <IGLManager>(); //Assign GL material m_GLMat = GLMatShader.GetGLMaterial(); //Assign building m_Building = GetComponent <Building>(); }
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(); }
private void AddItemToList(TransferEntry entry) { // Add to our fast-lookup collection. Transfers.Add(entry); // Add to UI. GLItem item = this.Items.Add(""); item.Tag = entry; item.SubItems[(int)ColumnIndex.Path].Control = entry.Path; item.SubItems[(int)ColumnIndex.Remaining].Control = entry.Remaining; item.SubItems[(int)ColumnIndex.Progress].Control = entry.Progress; entry.Item = item; // Invalidation is required in order to immediately display the control. this.Invalidate(); }
// Use this for initialization void Start() { Overlay = Overlays.CreateTexture(); IsSelected = false; FindMaxWorldSize(); m_MainMenuWidth = ManagerResolver.Resolve <IGUIManager>().MainMenuWidth; m_GLManager = ManagerResolver.Resolve <IGLManager>(); m_GLMat = GLMatShader.GetGLMaterial(); m_GLItem = new GLItem(GLExecuteFunction); //If this unit is land based subscribe to the path changed event LandMovement landMovement = GetComponent <LandMovement>(); if (landMovement != null) { landMovement.PathChangedEvent += PathChanged; } }
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(); } }
private void _EndGThread(GThread gThread) { GLItem itemToDelete = null; foreach (GLItem item in glGTreadList.Items) { if (item.Tag == gThread) { itemToDelete = item; break; } } if (itemToDelete == null) { Logging.Log.Warn("GThread not found", gThread); return; } glGTreadList.Items.Remove(itemToDelete); }
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); } }
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; }
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); }
/// <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(); }
/// <summary> /// This is an OPTIMIZED routine to see if an item is visible. /// /// The other method of just checking against the item index was slow becuase it had to walk the entire list, which would massively /// slow down the control when large numbers of items were added. /// </summary> /// <param name="item"></param> /// <returns></returns> public bool IsItemVisible( GLItem item ) { // TODO: change this to only walk to visible items list int nItemIndex = Items.FindItemIndex( item ); if ( ( nItemIndex >= this.vPanelScrollBar.Value ) && ( nItemIndex < this.vPanelScrollBar.Value+this.VisibleRowsCount ) ) return true; return false; }
/// <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 } }
/// <summary> /// Draw row at specified coordinates /// </summary> /// <param name="graphicsRow"></param> /// <param name="rectRow"></param> /// <param name="item"></param> /// <param name="nItemIndex"></param> public virtual void DrawRow( Graphics graphicsRow, Rectangle rectRow, GLItem item, int nItemIndex ) { DW("DrawRow"); // row background, if its selected, that trumps all, if not then see if we are using alternating colors, if not draw normal // note, this can all be overridden by the sub item background property // make sure anything can even be selected before drawing selection rects if ( item.Selected && this.Selectable ) { SolidBrush brushBK; brushBK = new SolidBrush( Color.FromArgb( 255, SelectionColor.R, SelectionColor.G, SelectionColor.B ) ); // need to check for full row select here if ( !FullRowSelect ) { // calculate how far into the control it goes int nWidthFR = -this.hPanelScrollBar.Value + Columns.Width; graphicsRow.FillRectangle( brushBK, this.RowsInnerClientRect.X, rectRow.Y, nWidthFR, rectRow.Height ); } else graphicsRow.FillRectangle( brushBK, this.RowsInnerClientRect.X, rectRow.Y, this.RowsInnerClientRect.Width, rectRow.Height ); brushBK.Dispose(); } else { // if the back color of the list doesn't match the back color of the item (AND) the back color isn't white, then override it if ( ( item.BackColor.ToArgb() != this.BackColor.ToArgb() ) && (item.BackColor != Color.White ) ) { SolidBrush brushBK = new SolidBrush( item.BackColor ); graphicsRow.FillRectangle( brushBK, this.RowsInnerClientRect.X, rectRow.Y, this.RowsInnerClientRect.Width, rectRow.Height ); brushBK.Dispose(); } // check for full row alternate color else if ( this.AlternatingColors ) { // alternating colors are only shown if the row isn't selected int nACItemIndex = Items.FindItemIndex( item ); if ( ( nACItemIndex % 2 ) > 0 ) { SolidBrush brushBK = new SolidBrush( this.AlternateBackground ); if ( !FullRowSelect ) { // calculate how far into the control it goes int nWidthFR = -this.hPanelScrollBar.Value + Columns.Width; graphicsRow.FillRectangle( brushBK, this.RowsInnerClientRect.X, rectRow.Y, nWidthFR, rectRow.Height ); } else graphicsRow.FillRectangle( brushBK, this.RowsInnerClientRect.X, rectRow.Y, this.RowsInnerClientRect.Width, rectRow.Height ); brushBK.Dispose(); } } } // draw the row of sub items int nXCursor = -this.hPanelScrollBar.Value + this.BorderPadding; for ( int nSubItem = 0; nSubItem < Columns.Count; nSubItem++ ) { Rectangle rectSubItem = new Rectangle( nXCursor, rectRow.Y, Columns[nSubItem].Width, rectRow.Height ); // avoid drawing items that are not in the visible region if ( ( rectSubItem.Right < 0 ) || ( rectSubItem.Left > this.RowsInnerClientRect.Right ) ) Debug.Write( "" ); else DrawSubItem( graphicsRow, rectSubItem, item, item.SubItems[nSubItem], nSubItem ); nXCursor += Columns[nSubItem].Width; } // post draw for focus rect and hot tracking if ( ( nItemIndex == this.HotItemIndex ) && HotItemTracking ) // handle hot tracking of items { Color transparentColor = Color.FromArgb( 75, this.HotTrackingColor.R, this.HotTrackingColor.G, this.HotTrackingColor.B ); // 182, 189, 210 ); Brush hotBrush = new SolidBrush(transparentColor); graphicsRow.FillRectangle( hotBrush, this.RowsInnerClientRect.X, rectRow.Y, this.RowsInnerClientRect.Width, rectRow.Height ); hotBrush.Dispose(); } // draw row borders if ( item.RowBorderSize > 0 ) { Pen penBorder = new Pen( item.RowBorderColor, item.RowBorderSize ); penBorder.Alignment = PenAlignment.Inset; graphicsRow.DrawRectangle( penBorder, rectRow ); penBorder.Dispose(); } // make sure anything can even be selected before drawing selection rects if ( this.Selectable ) if ( this.ShowFocusRect && (FocusedItem == item) ) // deal with focus rect ControlPaint.DrawFocusRectangle( graphicsRow, new Rectangle( this.RowsInnerClientRect.X+1, rectRow.Y, this.RowsInnerClientRect.Width-1, rectRow.Height ) ); }
// 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 }
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); }
// Use this for initialization void Start() { //Calculate world co-ordinates //8 vertices for outline (determined from collider) /*Bounds bounds = GetComponent<BoxCollider>().bounds; Vector3 center = bounds.center; float xExtent = bounds.extents.x; float yExtent = bounds.extents.y; float zExtent = bounds.extents.z; WorldVertices[0] = center + new Vector3(-xExtent, -yExtent, -zExtent); WorldVertices[1] = center + new Vector3(xExtent, -yExtent, -zExtent); WorldVertices[2] = center + new Vector3(xExtent, -yExtent, zExtent); WorldVertices[3] = center + new Vector3(-xExtent, -yExtent, zExtent); WorldVertices[4] = center + new Vector3(-xExtent, yExtent, -zExtent); WorldVertices[5] = center + new Vector3(xExtent, yExtent, -zExtent); WorldVertices[6] = center + new Vector3(xExtent, yExtent, zExtent); WorldVertices[7] = center + new Vector3(-xExtent, yExtent, zExtent); WorldHealthVertices[0] = new Vector3(WorldVertices[6].x, WorldVertices[6].y, WorldVertices[6].z); WorldHealthVertices[0].y -= 0.1f; WorldHealthVertices[0].z -= 0.1f; WorldHealthVertices[1] = new Vector3(WorldHealthVertices[0].x, WorldHealthVertices[0].y-m_HealthSize, WorldHealthVertices[0].z); WorldHealthVertices[2] = new Vector3(WorldHealthVertices[0].x, WorldHealthVertices[0].y-m_HealthSize, WorldHealthVertices[0].z-m_HealthSize); WorldHealthVertices[3] = new Vector3(WorldHealthVertices[0].x, WorldHealthVertices[0].y, WorldHealthVertices[0].z-m_HealthSize); WorldHealthVertices[4] = new Vector3(WorldVertices[7].x, WorldVertices[7].y, WorldVertices[7].z); WorldHealthVertices[4].y -= 0.1f; WorldHealthVertices[4].z -= 0.1f; WorldHealthVertices[5] = new Vector3(WorldHealthVertices[4].x, WorldHealthVertices[4].y-m_HealthSize, WorldHealthVertices[0].z); WorldHealthVertices[6] = new Vector3(WorldHealthVertices[4].x, WorldHealthVertices[4].y-m_HealthSize, WorldHealthVertices[0].z-m_HealthSize); WorldHealthVertices[7] = new Vector3(WorldHealthVertices[4].x, WorldHealthVertices[4].y, WorldHealthVertices[0].z-m_HealthSize); //Assign health width m_HealthWidth = Mathf.Abs (WorldHealthVertices[0].x - WorldHealthVertices[4].x);*/ //Create GLItem m_GLItem = new GLItem(ExecuteFunction); //Resolve GLManager m_GLManager = ManagerResolver.Resolve<IGLManager>(); //Assign GL material m_GLMat = GLMatShader.GetGLMaterial(); //Assign building m_Building = GetComponent<Building>(); }
public void RemoveItemToRender(GLItem item) { m_ItemsToRender.Remove(item); }
/// <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; }
// Use this for initialization void Start() { Overlay = Overlays.CreateTexture (); IsSelected = false; FindMaxWorldSize(); m_MainMenuWidth = ManagerResolver.Resolve<IGUIManager>().MainMenuWidth; m_GLManager = ManagerResolver.Resolve<IGLManager>(); m_GLMat = GLMatShader.GetGLMaterial (); m_GLItem = new GLItem(GLExecuteFunction); //If this unit is land based subscribe to the path changed event LandMovement landMovement = GetComponent<LandMovement>(); if (landMovement != null) { landMovement.PathChangedEvent += PathChanged; } }
void updateTorrents() { while (true) { try { Invoke((MethodInvoker) delegate() { int index = 0; foreach (TorrentFile file in torrentFiles) { (torrentList.Items[index].SubItems[1].Control as FProgressBar).Value = (int)file.downloadProgress; torrentList.Items[index].SubItems[2].Text = ((int)file.downloadSpeed / 1000).ToString() + "kB/s"; torrentList.Items[index].SubItems[3].Text = ((int)file.uploadSpeed / 1000).ToString() + "kB/s"; torrentList.Items[index].SubItems[4].Text = (Math.Round(file.size / 1048576, 2)).ToString() + "MB"; if (file.torrentState == TorrentState.Downloading) { (torrentList.Items[index].SubItems[1].Control as FProgressBar).ProgressBarColor = Color.YellowGreen; (torrentList.Items[index].SubItems[1].Control as FProgressBar).DisplayStyle = ProgressBarDisplayText.Percentage; } else if (file.torrentState == TorrentState.Paused) { (torrentList.Items[index].SubItems[1].Control as FProgressBar).ProgressBarColor = Color.Orange; (torrentList.Items[index].SubItems[1].Control as FProgressBar).DisplayStyle = ProgressBarDisplayText.CustomText; (torrentList.Items[index].SubItems[1].Control as FProgressBar).CustomText = "Paused"; } else if (file.torrentState == TorrentState.Error || file.torrentState == TorrentState.Stopped) { (torrentList.Items[index].SubItems[1].Control as FProgressBar).ProgressBarColor = Color.Red; (torrentList.Items[index].SubItems[1].Control as FProgressBar).DisplayStyle = ProgressBarDisplayText.CustomText; (torrentList.Items[index].SubItems[1].Control as FProgressBar).CustomText = "Stopped"; } else if (file.torrentState == TorrentState.Seeding) { if (!file.finishNotified) { file.finishNotified = true; taskBarIcon.ShowBalloonTip(5000, "Download completed!", file.name + " downloaded successfully.", ToolTipIcon.Info); } (torrentList.Items[index].SubItems[1].Control as FProgressBar).ProgressBarColor = Color.Yellow; (torrentList.Items[index].SubItems[1].Control as FProgressBar).DisplayStyle = ProgressBarDisplayText.CustomText; (torrentList.Items[index].SubItems[1].Control as FProgressBar).CustomText = "Seeding..."; } TimeSpan timeLeft = TimeSpan.FromSeconds(MathUtils.ETA(file.downloadedBytes, file.downloadSpeed, file.size)); torrentList.Items[index].SubItems[5].Text = timeLeft.ToString(); index++; } if (torrentList.SelectedItems.Count != 0) { torrentTabs.Enabled = true; filesList.Items.Clear(); int selectedIndex = torrentList.Items.FindItemIndex((GLItem)torrentList.SelectedItems[0]); foreach (MonoTorrent.Common.TorrentFile file in torrentFiles[selectedIndex].torrent.Files) { double fileLength = file.Length; double downloaded = file.BytesDownloaded; GLItem gl = filesList.Items.Add(file.Path); FProgressBar bar = new FProgressBar(); gl.SubItems[1].Control = bar; bar.Value = (int)((double)file.BytesDownloaded / (double)file.Length) * 100; } trackersList.Items.Clear(); foreach (TrackerTier tier in torrentFiles[selectedIndex].manager.TrackerManager) { foreach (Tracker t in tier.GetTrackers()) { GLItem item = trackersList.Items.Add(t.Uri.ToString()); item.SubItems[1].Text = t.Status.ToString(); } } try { peersList.Items.Clear(); foreach (PeerId p in torrentFiles[selectedIndex].manager.GetPeers()) { GLItem item = peersList.Items.Add(p.Connection.Uri.ToString()); item.SubItems[1].Text = ((int)p.Monitor.DownloadSpeed / 1024).ToString() + "kB/s"; item.SubItems[2].Text = ((int)p.Monitor.UploadSpeed / 1024).ToString() + "kB/s"; } } catch { } speedCounter.Series[0].Points.Add(torrentFiles[selectedIndex].manager.Monitor.DownloadSpeed / 1024); speedCounter.Series[1].Points.Add(torrentFiles[selectedIndex].manager.Monitor.UploadSpeed / 1024); } else { torrentTabs.Enabled = false; } if (Args.args != null) { foreach (string argument in Args.args) { if (File.Exists(argument) && argument.EndsWith(".torrent")) { using (addTorrent addTor = new addTorrent(argument)) { addTor.ShowDialog(); GLItem item; torrentFiles.Add(new TorrentFile(addTor.torrentPath, addTor.savePath, new IPEndPoint(IPAddress.Any, 6969))); item = torrentList.Items.Add(torrentFiles[torrentFiles.Count - 1].name); FProgressBar fbar = new FProgressBar(); fbar.DisplayStyle = ProgressBarDisplayText.Percentage; item.SubItems[1].Control = fbar; torrentFiles[torrentList.Count - 1].Start(); torrentList.Refresh(); } } } Args.args = null; } Refresh(); }); } catch { } Thread.Sleep(1000); } }
private bool CompareItems( GLItem item1, GLItem item2, CompareDirection direction ) { // add a numeric compare here also bool dir = false; if ( direction == CompareDirection.GreaterThan ) dir=true; if ( this.SortDirection == SortDirections.SortAscending ) dir = !dir; // flip it if ( !this.NumericCompare ) { if ( dir ) { return ( item1.SubItems[SortColumn].Text.CompareTo( item2.SubItems[SortColumn].Text ) < 0 ); } else { return ( item1.SubItems[SortColumn].Text.CompareTo( item2.SubItems[SortColumn].Text ) > 0 ); } } else { try { double n1 = Double.Parse( item1.SubItems[SortColumn].Text ); double n2 = Double.Parse( item2.SubItems[SortColumn].Text ); if ( dir ) { // compare the numeric values inside the columns return ( n1 < n2 ); } else { return ( n1 > n2 ); } } catch( Exception ex ) { // no numeric value (bad bad) Debug.WriteLine( ex.ToString() ); return false; } } }
public void RemoveItemToRender(GLItem item) { m_ItemsToRender.Remove (item); }
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; }