public void m_OnRemovedSharedFile(InterfaceFile file) { if (OnRemovedSharedFile != null) { OnRemovedSharedFile(file); } }
protected override void OnDrawItem(int item, int column, Graphics g, Rectangle rec) { try { /*InterfaceFile file = (InterfaceFile)(Items[item].Tag); * Bitmap bar=new Bitmap(rec.Width,rec.Height,g); * Graphics g2=Graphics.FromImage(bar); * eAntInspector.DrawBar(file, g2, new Rectangle(0,0,rec.Width,rec.Height), true, true); * g2.FillRectangle(new SolidBrush(this.BackColor),0,rec.Height-1,rec.Width,1); * g.DrawImageUnscaled(bar, rec.Left, rec.Top); * bar.Dispose();*/ InterfaceFile file = (InterfaceFile)(Items[item].Tag); eAntInspector.DrawBar(file, g, rec, true, true); g.FillRectangle(new SolidBrush(this.BackColor), rec.Left, rec.Height - 1, rec.Width, 1); //draw a backcolor margin //g.FillRectangle(new SolidBrush(this.BackColor),rec.X,rec.Bottom-1,rec.Width,1); } catch { Debug.WriteLine("GDI Error: drawing element bar"); } }
private void m_OnCancelFile() { if (SelectedItems.Count == 0) { return; } try { int SelectedItem = SelectedItems.Count; InterfaceFile[] Items = new InterfaceFile[SelectedItem]; for (int i = 0; i != SelectedItem; i++) { Items[i] = (InterfaceFile)SelectedItems[i].Tag; } for (int i = 0; i != SelectedItem; i++) { string message = String.Format(eAntForm.Globalization["MSG_DELETEFILE"], (Items[i].Name)); if (MessageBox.Show(message, "Ant", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes) { krnGateway.CancelFile(Items[i].strHash); } } } catch (Exception ex) { Debug.WriteLine(ex.ToString()); } }
public void m_OnNewFile(InterfaceFile file) { if (OnNewFile != null) { OnNewFile(file); } }
private void m_CheckPriority() { PriorityMenu.MenuItems[0].Checked = false; PriorityMenu.MenuItems[1].Checked = false; PriorityMenu.MenuItems[2].Checked = false; if (SelectedItems.Count == 0) { return; } if (SelectedItems.Count > 1) { return; } InterfaceFile file = (InterfaceFile)SelectedItems[0].Tag; byte index = 1; switch (file.DownloadPriority) { case Constants.Priority.High: index = 0; break; case Constants.Priority.Normal: index = 1; break; case Constants.Priority.Low: index = 2; break; default: index = 1; break; } PriorityMenu.MenuItems[index].Checked = true; }
private void m_OnNewShared(InterfaceFile shared) { ListViewItem ItemShared = new ListViewItem(new string[] { "", "", "", "" }); ItemShared.Tag = shared; SharedToItem(shared, ItemShared); Items.Add(ItemShared); }
private void OnCopyLinkHTML(object sender, System.EventArgs e) { if (SelectedItems.Count == 0) { return; } InterfaceFile file = (InterfaceFile)SelectedItems[0].Tag; Clipboard.SetDataObject("<a href=\"ed2k://|file|" + file.Name + "|" + file.Size.ToString() + "|" + file.strHash + "|/\">" + file.Name + "</a>"); }
private void m_InvokeOnRemovedSharedFile(InterfaceFile file) { if (this.InvokeRequired) { this.BeginInvoke(new FileEvent(m_OnRemovedSharedFile), new object[] { file }); } else { m_OnRemovedSharedFile(file); } }
private void sharedListView_SelectedIndexChanged(object sender, EventArgs e) { if (SelectedItems.Count > 0) { InterfaceFile file = (InterfaceFile)SelectedItems[0].Tag; MenuInfo.SearchString = SelectedItems[0].Text; MenuInfo.FileHash = file.strHash; MenuInfo.eD2kLink = "ed2k://|file|" + file.Name + "|" + file.Size.ToString() + "|" + file.strHash + "|/"; } }
internal static void RemovedSharedFile(CElement element) { InterfaceFile file = InterfaceGateway[0].FileToInterfaceFile(element); for (int i = 0; i <= InterfaceGateway.Length - 1; i++) { if (CKernel.InterfaceGateway[i] != null) { InterfaceGateway[i].RemovedSharedFile(file); } } }
/// <summary> /// Adds a <see cref="InterfaceFile" /> to be used to generate an interface (classes can be used here if you want to /// generate a typescript interface from a c# class) /// </summary> /// <param name="type"></param> /// <param name="forceInterfaceForProperties"></param> /// <returns>The created <see cref="InterfaceFile" /> so you can make changes like adjusting property names or values.</returns> public InterfaceFile Interface(Type type, bool forceInterfaceForProperties = false) { var t = type.UnderlyingType(); if (InterfaceFiles.ContainsKey(t)) { return(InterfaceFiles[t]); } InterfaceFiles[t] = new InterfaceFile(this, t, RootDir, forceInterfaceForProperties); return(InterfaceFiles[t]); }
private void OnCopyLinkSources(object sender, System.EventArgs e) { if (SelectedItems.Count == 0) { return; } InterfaceFile file = (InterfaceFile)SelectedItems[0].Tag; string IP = (new System.Net.IPAddress(m_config.UserID)).ToString(); Clipboard.SetDataObject("ed2k://|file|" + file.Name + "|" + file.Size.ToString() + "|" + file.strHash + "|/|sources," + IP + ":" + m_config.TCPPort + "|/"); }
private void m_RefreshStatistics(InterfaceFile file) { FileStatistics fstatistics = krnGateway.GetFileStatistics(file.strHash); labelSessionDownloadedRes.Text = eLePhantListView.SizeToString((uint)fstatistics.SessionDownload); labelSessionUploadedRes.Text = eLePhantListView.SizeToString((uint)fstatistics.SessionUpload); labelSessionRequestsRes.Text = fstatistics.SessionRequests.ToString(); byte rating = 0; string comment = ""; krnGateway.GetFileComment(file.strHash, ref comment, ref rating); this.textBoxComment.Text = comment; }
private void m_OnRemovedSharedFile(InterfaceFile shared) { try { for (int i = 0; i < this.Items.Count; i++) { if (shared.strHash == ((InterfaceFile)Items[i].Tag).strHash) { Items.RemoveAt(i); } } } catch {} }
private void OnOpenFile(object sender, System.EventArgs e) { if (SelectedItems.Count == 0) { return; } InterfaceFile file = (InterfaceFile)SelectedItems[0].Tag; try { System.Diagnostics.Process.Start(file.CompleteName); } catch {} }
private void m_OnNewFile(InterfaceFile file) { ListViewItem itemFile = new ListViewItem(new string[] { "", "", "", "", "", "", "", "", "", "", "", "", "" }); itemFile.Tag = file; FileToItem(file, itemFile); lock (this) { if ((!IsFiltered(file.Status)) && (!IsCategoryFiltered(file.CategoryID, file.Name))) { Items.Add(itemFile); } } }
private void m_RefreshList() { foreach (ListViewItem Item in Items) { InterfaceFile file = krnGateway.GetDownloadFile(((InterfaceFile)Item.Tag).strHash); if (file == null) { Items.Remove(Item); } else { SharedToItem(file, Item); } } }
/// <summary>Create and initialize the zoom bar control</summary> public eLePhantInspector() { // Prevent flicker with double buffering and all painting inside WM_PAINT SetStyle(ControlStyles.DoubleBuffer | ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint, true); // Set initial state _borderWidth = 5; _barHeight = 29; _barSpacing = 3; _file = null; // recalculate the bars Recalculate(); }
private void m_OnOpenFile() { if (SelectedItems.Count == 0) { return; } InterfaceFile file = (InterfaceFile)SelectedItems[0].Tag; if (file.Status == 9) { try { System.Diagnostics.Process.Start(file.CompleteName); } catch {} } }
private void showInfo(InterfaceFile file) { sFileDetails FileInfo = (sFileDetails)krnGateway.GetFileDetails(file.strHash); this.tx_fileName.Text = file.Name; this.tx_completeName.Text = file.CompleteName; switch ((byte)FileInfo.Type) { case ((byte)Constants.FileType.Avi): FAviDetails.ShowData((Hashtable)FileInfo.ListDetails); FAviDetails.Show(); break; default: FAviDetails.Hide(); break; } }
private bool m_IsCompleted() { if (SelectedItems.Count == 0) { return(false); } InterfaceFile file = (InterfaceFile)SelectedItems[0].Tag; //status = 9 -> completed if (file.Status == 9) { return(true); } else { return(false); } }
private void SharedToItem(InterfaceFile shared, ListViewItem ItemShared) { if (shared == null) { return; } if (ItemShared.SubItems[0].Text != shared.Name) { ItemShared.SubItems[0].Text = shared.Name; } if (ItemShared.SubItems[1].Text != SizeToString(shared.Size)) { ItemShared.SubItems[1].Text = SizeToString(shared.Size); } if (ItemShared.SubItems[2].Text != PriorityToString(shared.UploadPriority)) { ItemShared.SubItems[2].Text = PriorityToString(shared.UploadPriority); } ItemShared.Tag = shared; ItemShared.ImageIndex = eAntForm.SystemIconsList.GetIconIndexOf(shared.Name); }
private void m_RefreshList(CkernelGateway in_krnGateway) { foreach (ListViewItem Item in Items) { InterfaceFile file = in_krnGateway.GetDownloadFile(((InterfaceFile)Item.Tag).strHash); if ((file == null) || ((m_ClearingCompleted) && (((InterfaceFile)Item.Tag).Status == 9))) { Items.Remove(Item); } else { FileToItem(file, Item); } } //enable this to autosort the list if (eAntForm.preferences.GetBool("AutoSort")) { this.ListViewItemSorter = TheColumnSorter; this.Sort(); this.ListViewItemSorter = null; } }
private void m_CheckCategories() { ArrayList categories = krnGateway.GetCategories(); CategoryMenu.MenuItems.Clear(); MenuItem noneItem = CategoryMenu.MenuItems.Add(eAntForm.Globalization["LBL_NONE"], new EventHandler(OnSelectCategory)); CategoryMenu.MenuItems.Add("-"); MenuItem catItem; InterfaceFile file = null; if (SelectedItems.Count > 0) { file = (InterfaceFile)SelectedItems[0].Tag; } if ((file != null) && (file.CategoryID == 0)) { noneItem.Checked = true; } foreach (CCategory category in categories) { catItem = CategoryMenu.MenuItems.Add(category.Name, new EventHandler(OnSelectCategory)); if ((file != null) && (file.CategoryID == category.ID)) { catItem.Checked = true; } } if (categories.Count > 0) { CategoryMenu.MenuItems.Add("-"); } CategoryMenu.MenuItems.Add(eAntForm.Globalization["LBL_MANAGECATEGORIES"], new EventHandler(OnAddCategory)); }
private static void WriteDocument(InterfaceFile vint, Stream output) { var settings = new XmlWriterSettings(); settings.Indent = true; settings.IndentChars = "\t"; settings.OmitXmlDeclaration = true; settings.CheckCharacters = false; var writer = XmlWriter.Create(output, settings); writer.WriteStartDocument(); writer.WriteStartElement("root"); writer.WriteElementString("vint_doc_type", "vint_document"); writer.WriteElementString("name", Path.ChangeExtension(vint.Name, ".vint_xdoc")); writer.WriteElementString("vint_doc_version", "2"); writer.WriteElementString("anim_time", vint.AnimationTime.ToString()); writer.WriteStartElement("metadata"); foreach (var metadata in vint.Metadata) { writer.WriteStartElement("metadata_item"); writer.WriteElementString("name", metadata.Name); writer.WriteElementString("value", metadata.Value); writer.WriteEndElement(); } writer.WriteEndElement(); writer.WriteStartElement("critical_resources"); { writer.WriteStartElement("pegs"); { writer.WriteStartElement("autoload"); { foreach (var resource in vint.CriticalResources .Where(r => r.Type == Interface.CriticalResourceType.Peg && r.Autoload == true)) { writer.WriteElementString("filename", resource.Name); } } writer.WriteEndElement(); foreach (var resource in vint.CriticalResources .Where(r => r.Type == Interface.CriticalResourceType.Peg && r.Autoload == false)) { writer.WriteElementString("filename", resource.Name); } } writer.WriteEndElement(); writer.WriteStartElement("documents"); { foreach (var resource in vint.CriticalResources .Where(r => r.Type == Interface.CriticalResourceType.Document)) { writer.WriteElementString("filename", resource.Name); } } writer.WriteEndElement(); } writer.WriteEndElement(); writer.WriteStartElement("elements"); foreach (Interface.Object element in vint.Elements) { writer.WriteStartElement("object"); WriteObject(writer, element); writer.WriteEndElement(); } writer.WriteEndElement(); writer.WriteStartElement("animations"); foreach (Interface.Object animation in vint.Animations) { writer.WriteStartElement("object"); WriteObject(writer, animation); writer.WriteEndElement(); } writer.WriteEndElement(); writer.WriteEndElement(); writer.WriteEndDocument(); writer.Flush(); }
protected override void OnDrawItem(int item, int column, Graphics g, Rectangle rec) { InterfaceFile file = (InterfaceFile)(Items[item].Tag); LinearGradientBrush chunkBrush; int xpos = rec.Left; Color b = Color.Red; Color end; if (file.UploadChunksAvaibility == null) { try { // calculate the new end color based on start color end = ControlPaint.Dark(b, 0.3F); // generate the linear brush chunkBrush = new LinearGradientBrush(new Rectangle(xpos, rec.Top, rec.Right - xpos, rec.Height), b, end, 90); g.FillRectangle(chunkBrush, xpos, rec.Top, rec.Right - xpos, rec.Height); //draw a backcolor margin g.FillRectangle(new SolidBrush(this.BackColor), rec.X, rec.Bottom - 1, rec.Width, 1); } catch (Exception e) { Debug.WriteLine(e.ToString()); } return; } int ChunkLength; for (int i = 0; i < file.UploadChunksAvaibility.Length; i++) { ChunkLength = (int)Decimal.Round((decimal)(this.HeaderRight[column] - xpos) / (decimal)(file.UploadChunksAvaibility.Length - i), 0); b = Color.Red; if ((file.UploadChunksAvaibility != null) && (file.UploadChunksAvaibility[i] > 0)) { int col = file.UploadChunksAvaibility[i] * 4; if (col > 200) { col = 200; } col = Math.Abs(200 - col); b = Color.FromArgb(255, col, col, 255); } try { // calculate the new end color based on start color if (ChunkLength <= 0) { continue; } end = ControlPaint.Dark(b, 0.3F); // generate the linear brush chunkBrush = new LinearGradientBrush(new Rectangle(xpos, rec.Top, ChunkLength, rec.Height), b, end, 90); g.FillRectangle(chunkBrush, xpos, rec.Top, ChunkLength, rec.Height); //draw a backcolor margin, TODO it produces some flickering g.FillRectangle(new SolidBrush(this.BackColor), rec.X, rec.Bottom - 1, rec.Width, 1); } catch (Exception e) { Debug.WriteLine(e.ToString()); } xpos += ChunkLength; } }
public void prueba(InterfaceFile file) { Console.WriteLine ("prueba"); }
/// <summary> /// Paint a InterfaceFile chunk to any graphics /// </summary> /// <param name="file"></param> /// <param name="g"></param> /// <param name="rec"></param> /// <param name="PercentBar"></param> static public void DrawBar(InterfaceFile file, Graphics g, Rectangle rec, bool PercentBar, bool PercentNumber) { Rectangle barRect; Color end; LinearGradientBrush chunkBrush; // fill background with white //SolidBrush white = new SolidBrush(Color.White); //g.FillRectangle(white, rec); barRect = new Rectangle(rec.Left, rec.Top, rec.Width, rec.Height); //SolidBrush b = new SolidBrush(Color.Red); Color b = Color.Red; int xpos = barRect.Left; //this.HeaderLeft[column]; //if (xpos==0) xpos = barRect.Left; int ChunkLength; for (int i = 0; i < file.ChunksStatus.Length; i++) { //ChunkLength=(int)Decimal.Round((decimal)(this.HeaderRight[column]-xpos)/(decimal)(file.ChunksStatus.Length-i),0); ChunkLength = (int)Decimal.Round((decimal)(barRect.Right - xpos) / (decimal)(file.ChunksStatus.Length - i), 0); switch (file.ChunksStatus[i]) { case 3: //if completed : green else black if (file.Status == 9) { b = System.Drawing.Color.Green; //Color.FromArgb(82, 246, 91); } else { b = Color.Black; } break; case 0: b = Color.Red; break; case 1: b = Color.Gray; break; case 2: b = Color.LightGray; break; default: b = Color.Red; break; } if ((file.ChunksStatus[i] == 0) && (file.ChunksAvaibility != null) && (file.ChunksAvaibility[i] > 0)) { int col = file.ChunksAvaibility[i] * 4; if (col > 200) { col = 200; } col = Math.Abs(200 - col); b = Color.FromArgb(255, col, col, 255); } try { if (ChunkLength <= 0) { continue; } // calculate the new end color based on start color end = ControlPaint.Dark(b, 0.3F); // generate the linear brush chunkBrush = new LinearGradientBrush(new Rectangle(xpos, barRect.Top, ChunkLength, barRect.Height), b, end, 90); g.FillRectangle(chunkBrush, xpos, barRect.Top, ChunkLength, barRect.Height); } catch (Exception e) { Debug.WriteLine(e.ToString()); } xpos += ChunkLength; } decimal percent = file.PercentCompleted; if (PercentBar) { int CompleteChunkLength = (int)(percent * (rec.Right - rec.Left)); Pen myProgressBarPen = new Pen(Color.FromArgb(82, 246, 91), 2); g.DrawLine(myProgressBarPen, rec.Left, rec.Top + 1, rec.Left + CompleteChunkLength, rec.Top + 1); } if (PercentNumber) { g.DrawString(((byte)(percent * 100)).ToString() + " %", new System.Drawing.Font("Microsoft Sans Serif", 7.25F, GraphicsUnit.Point), new SolidBrush(Color.White), barRect); } }
public static void Main(string[] args) { bool showHelp = false; bool overwriteFiles = false; var options = new OptionSet() { { "o|overwrite", "overwrite files if they already exist", v => overwriteFiles = v != null }, { "h|help", "show this message and exit", v => showHelp = v != null }, }; List <string> extras; try { extras = options.Parse(args); } catch (OptionException e) { Console.Write("{0}: ", GetExecutableName()); Console.WriteLine(e.Message); Console.WriteLine("Try `{0} --help' for more information.", GetExecutableName()); return; } if (extras.Count == 0 || showHelp == true) { Console.WriteLine("Usage: {0} [OPTIONS]+ input_directory+", GetExecutableName()); Console.WriteLine("Convert .vint_doc files to .vint_xdoc."); Console.WriteLine(); Console.WriteLine("Options:"); options.WriteOptionDescriptions(Console.Out); return; } foreach (string directory in extras) { foreach (string inputPath in Directory.GetFiles(Path.GetFullPath(directory), "*.vint_doc")) { var outputPath = Path.ChangeExtension(inputPath, ".vint_xdoc"); if (overwriteFiles == false && File.Exists(outputPath) == true) { continue; } Console.WriteLine(Path.GetFullPath(inputPath)); using (var input = File.OpenRead(inputPath)) { if (input.ReadValueU32() != 0x3027) { input.Close(); continue; } input.Seek(-4, SeekOrigin.Current); var vint = new InterfaceFile(); vint.Deserialize(input); using (var output = File.Open(outputPath, FileMode.Create, FileAccess.Write, FileShare.ReadWrite)) { WriteDocument(vint, output); } } } } }
public void prueba(InterfaceFile file) { Console.WriteLine("prueba"); }
private void FileToItem(InterfaceFile file, ListViewItem itemFile) { if (file == null) { return; } if (itemFile.SubItems[0].Text != file.Name) { itemFile.SubItems[0].Text = file.Name; } //CNameCleaner.Clean(file.Name); if (itemFile.SubItems[1].Text != SizeToString(file.Size)) { itemFile.SubItems[1].Text = SizeToString(file.Size); } if (itemFile.SubItems[2].Text != SpeedToString(file.DownSpeed)) { itemFile.SubItems[2].Text = SpeedToString(file.DownSpeed); } if (itemFile.SubItems[3].Text != SizeToString(file.BytesDownloaded)) { itemFile.SubItems[3].Text = SizeToString(file.BytesDownloaded); } if (itemFile.SubItems[4].Text != SizeToString(file.RemainingBytes)) { itemFile.SubItems[4].Text = SizeToString(file.RemainingBytes); } if (itemFile.SubItems[5].Text != Convert.ToString(file.nSources)) { itemFile.SubItems[5].Text = Convert.ToString(file.nSources); } if (itemFile.SubItems[6].Text != Convert.ToString(file.nValidSources)) { itemFile.SubItems[6].Text = Convert.ToString(file.nValidSources); } if (itemFile.SubItems[7].Text != Convert.ToString(file.nTransferringSources)) { itemFile.SubItems[7].Text = Convert.ToString(file.nTransferringSources); } if (itemFile.SubItems[8].Text != StatusToString(file.Status)) { itemFile.SubItems[8].Text = StatusToString(file.Status); } if (itemFile.SubItems[9].Text != "") { itemFile.SubItems[9].Text = ""; } if (itemFile.SubItems[10].Text != PriorityToString(file.DownloadPriority)) { itemFile.SubItems[10].Text = PriorityToString(file.DownloadPriority); } string estimatedTime = "?"; if (file.DownSpeed > 0.3F) { TimeSpan ts = TimeSpan.FromSeconds(file.RemainingBytes / 1024 / file.DownSpeed); //new TimeSpan(0,0,file.RemainingBytes*1024/file.DownSpeed); if (ts.Days <= 99) { if (ts.Days > 0) { estimatedTime = ts.Days + "d "; } else { estimatedTime = ""; } estimatedTime += ts.Hours + "h " + ts.Minutes + "m"; } } if (itemFile.SubItems[11].Text != estimatedTime) { itemFile.SubItems[11].Text = estimatedTime; } if (itemFile.SubItems[12].Text != file.Category) { itemFile.SubItems[12].Text = file.Category; } itemFile.ImageIndex = eAntForm.SystemIconsList.GetIconIndexOf(file.Name); itemFile.Tag = file; }