public void m_OnNewUpload(InterfaceClient client) { if (OnNewUpload != null) { OnNewUpload(client); } }
public void m_OnNewSource(InterfaceClient client, string strFileHash) { if (OnNewSource != null) { OnNewSource(client, strFileHash); } }
private void m_RefreshList(CkernelGateway in_krnGateway) { int nItem = 0; itemsToRemove.Clear(); while (nItem < Items.Count) { ListViewItem Item = Items[nItem]; if (Item == null) { break; } InterfaceClient clientant = (InterfaceClient)Item.Tag; InterfaceClient client = in_krnGateway.GetUploadClient(clientant.ID, clientant.Port, clientant.ServerIP, clientant.UserHash); if (client == null) { itemsToRemove.Add(Item); //Items.RemoveAt(nItem); } else { ClientToItem(client, Item); } nItem++; } foreach (ListViewItem Item in itemsToRemove) { this.Items.Remove(Item); } }
public void StartChatSession(InterfaceClient source) { if (OnStartChatSession != null) { OnStartChatSession(source); } }
static void Main(string[] args) { InterfaceClient client = new InterfaceClient(); Console.WriteLine(client.ErrorDescription(client.AddLogin("Login8", "333"))); Console.ReadLine(); }
public void m_OnNewChatMessage(InterfaceClient source, string message) { if (OnNewChatMessage != null) { OnNewChatMessage(source, message); } }
protected override void OnDrawItem(int item, int column, Graphics g, Rectangle rec) { InterfaceClient source = (InterfaceClient)(Items[item].Tag); Color b = Color.Red; Color end; LinearGradientBrush chunkBrush; int xpos = rec.Left; int ChunkLength; if (source.UpFileChunks == null) { //draw empty rect g.FillRectangle(new SolidBrush(this.BackColor), rec); return; } for (int i = 0; i < source.UpFileChunks.Length; i++) { //ChunkLength=(int)Decimal.Round((decimal)(rec.Right-xpos)/(decimal)(source.PartesFicheroSubida.Length-i),0); ChunkLength = (int)Decimal.Round((decimal)(rec.Right - xpos) / (decimal)(source.UpFileChunks.Length - i), 0); switch (source.UpFileChunks[i]) { case 3: b = Color.Black; break; case 0: b = Color.Red; break; // case 1: b=Color.DarkBlue; // break; // case 2: b=Color.Green; // break; default: b = Color.Red; break; } 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, rec.Top, ChunkLength, rec.Height), b, end, 90); g.FillRectangle(chunkBrush, xpos, rec.Top, ChunkLength, 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()); } xpos += ChunkLength; } }
// méthode pour définir le clic du bouton envoi Fichier public void SetInputInterfaceClient(InterfaceClient client) { interfaceClient = client; client.BtnEnvoiFichier.Click += new RoutedEventHandler(delegate { OpenFile(); }); }
public FenEnregistrerUtilisateur() { tcp = new TcpChannel(); objetcompte = (InterfaceCompte)Activator.GetObject(typeof(InterfaceCompte), "tcp://localhost:6060/objetcompte"); objetClient = (InterfaceClient)Activator.GetObject(typeof(InterfaceClient), "tcp://localhost:6060/objetclient"); objetUtilisateur = (InterfaceUtilisateur)Activator.GetObject(typeof(InterfaceUtilisateur), "tcp://localhost:6060/objetutilisateur"); InitializeComponent(); }
private void m_OnStartChatSession(InterfaceClient client) { m_LastClient = client; m_LastMessage = ""; MethodInvoker mi = new MethodInvoker(this.m_ProcessMessage); this.BeginInvoke(mi); }
private void m_OnNewChatMessage(InterfaceClient client, string message) { m_LastClient = client; m_LastMessage = message; MethodInvoker mi = new MethodInvoker(this.m_ProcessMessage); this.BeginInvoke(mi); }
private void ClientToItem(InterfaceClient client, ListViewItem itemUpload) { if (client == null) { return; } if (itemUpload.SubItems[0].Text != client.Name) { itemUpload.SubItems[0].Text = client.Name; } if (itemUpload.SubItems[1].Text != client.UpFileName) { itemUpload.SubItems[1].Text = client.UpFileName; } if (itemUpload.SubItems[2].Text != SpeedToString(client.UploadSpeed)) { itemUpload.SubItems[2].Text = SpeedToString(client.UploadSpeed); } if (itemUpload.SubItems[3].Text != SizeToString(client.UploadedBytes)) { itemUpload.SubItems[3].Text = SizeToString(client.UploadedBytes); } if (itemUpload.SubItems[4].Text != SizeToString(client.DownloadedBytes)) { itemUpload.SubItems[4].Text = SizeToString(client.DownloadedBytes); } if (itemUpload.SubItems[5].Text != StatusToString(client.UploadState)) { itemUpload.SubItems[5].Text = StatusToString(client.UploadState); } if (itemUpload.SubItems[6].Text != "") { itemUpload.SubItems[6].Text = ""; //progress } if (itemUpload.SubItems[7].Text != client.Software) { itemUpload.SubItems[7].Text = client.Software; } // if (client.Software=="eMule") // { // if (itemUpload.SubItems[8].Text!=client.Version.ToString("X")) // itemUpload.SubItems[8].Text=client.Version.ToString("X"); // } // else // { float div = 100F; if (client.Software == "eDonkeyHybrid") { div = 1000F; } if (itemUpload.SubItems[8].Text != (client.Version / div).ToString("0.00")) { itemUpload.SubItems[8].Text = (client.Version / div).ToString("0.00"); } // } itemUpload.Tag = client; }
public void DeleteFriend(byte[] ClientHash, uint ID, ushort Port) { krnGateway.DeleteFriend(ClientHash, ID, Port); InterfaceClient source = new InterfaceClient(); source.ID = ID; source.UserHash = ClientHash; source.Port = Port; OnDeleteFriend(source); }
private void OnSendMessage(object sender, System.EventArgs e) { if (this.SelectedItems.Count <= 0) { return; } InterfaceClient source = (InterfaceClient)SelectedItems[0].Tag; krnGateway.StartChatSession(source); }
private void OnViewFiles(object sender, System.EventArgs e) { if (this.SelectedItems.Count <= 0) { return; } InterfaceClient source = (InterfaceClient)SelectedItems[0].Tag; krnGateway.RequestSharedList(source.ID, source.Port, source.ServerIP, source.UserHash); }
private void OnAddFriend(object sender, System.EventArgs e) { if (this.SelectedItems.Count <= 0) { return; } InterfaceClient source = (InterfaceClient)SelectedItems[0].Tag; krnGateway.AddFriend(source); }
public FenRemboursement() { tcp = new TcpChannel(); objetclient = (InterfaceClient)Activator.GetObject(typeof(InterfaceClient), "tcp://localhost:6060/objetclient"); objetcompte = (InterfaceCompte)Activator.GetObject(typeof(InterfaceCompte), "tcp://localhost:6060/objetcompte"); P = (InterfacePret)Activator.GetObject(typeof(InterfacePret), "tcp://localhost:6060/objetpret"); Pre = (InterfacePret)Activator.GetObject(typeof(InterfacePret), "tcp://localhost:6060/objetpret"); Par = (InterfacePret)Activator.GetObject(typeof(InterfacePret), "tcp://localhost:6060/objetpret"); InitializeComponent(); }
internal static void NewSource(CClient client, string strDownFileHash) { InterfaceClient interfaceClient = InterfaceGateway[0].ClientToInterfaceClient(client); for (int i = 0; i <= InterfaceGateway.Length - 1; i++) { if (CKernel.InterfaceGateway[i] != null) { InterfaceGateway[i].NewSource(interfaceClient, strDownFileHash); } } }
internal static void NewUpload(CClient client) { InterfaceClient interfaceClient = InterfaceGateway[0].ClientToInterfaceClient(client); for (int i = 0; i <= InterfaceGateway.Length - 1; i++) { if (CKernel.InterfaceGateway[i] != null) { InterfaceGateway[i].NewUpload(interfaceClient); } } }
private void m_RefreshList(CkernelGateway in_krnGateway) { //refresh 30 items each second itemsToRemove.Clear(); int nRefreshed = 0; int nItem = 0; bool refresh; ListViewItem Item; while (nItem < Items.Count) { Item = Items[nItem]; if (Item == null) { break; } InterfaceClient sourceant = (InterfaceClient)Item.Tag; refresh = false; if ((nItem >= m_LastItem) && (nItem <= m_LastItem + 30)) //only refresh not queued sources { refresh = true; } if ((sourceant.DownloadState != 2) && (sourceant.DownloadState != 6)) { refresh = true; } if (refresh) { nRefreshed++; InterfaceClient source = in_krnGateway.GetDownloadClient(sourceant.ID, sourceant.Port, sourceant.ServerIP, sourceant.UserHash, strFileHash); if (source == null) { itemsToRemove.Add(Item); } else { SourceToItem(source, Item); } } nItem++; } m_LastItem += 30; if (m_LastItem >= Items.Count) { m_LastItem = 0; } foreach (ListViewItem ItemRemove in itemsToRemove) { this.Items.Remove(ItemRemove); } //Debug.WriteLine("Refreshed: "+ nRefreshed.ToString() +" : "+m_LastItem.ToString()); }
private void m_OnNewSource(InterfaceClient source, string strHashFicheroDescarga) { if (strHashFicheroDescarga != strFileHash) { return; } ListViewItem itemSource = new ListViewItem(new string[] { "", "", "", "", "", "", "", "", "", "" }); itemSource.Tag = source; SourceToItem(source, itemSource); Items.Add(itemSource); }
private void OnAddFriend(object sender, System.EventArgs e) { if (tabMessages.TabPages.Count <= 0) { return; } if (tabMessages.SelectedTab == null) { return; } InterfaceClient source = (InterfaceClient)tabMessages.SelectedTab.Tag; krnGateway.AddFriend(source); }
public void AddFriend(SFriend friend) { krnGateway.AddFriend(friend.ID, friend.Port, friend.ServerIP, friend.UserHash, 0, friend.OurName, friend.Name, friend.Software, friend.Version, friend.FriendSlot); InterfaceClient source = new InterfaceClient(); source.Name = friend.OurName; source.ID = friend.ID; source.Port = friend.Port; if (friend.UserHash != null) { source.UserHash = friend.UserHash; } OnAddingFriend(source); }
private void buttonSend_Click(object sender, System.EventArgs e) { if ((tabMessages.SelectedIndex < 0) || (textBoxMessage.Text.Length <= 0)) { return; } Crownwood.Magic.Controls.TabPage messagePage = tabMessages.TabPages[tabMessages.SelectedIndex]; InterfaceClient client = (InterfaceClient)messagePage.Tag; RichTextBox textBox = (RichTextBox)messagePage.Control; textBox.Text += DateTime.Now.ToString() + "->" + textBoxMessage.Text + "\r\n"; Win32.SendMessage(textBox.Handle, Win32.WM_VSCROLL, (IntPtr)Win32.SB_BOTTOM, (IntPtr)0); krnGateway.SendChatMessage(client.ID, client.Port, client.ServerIP, client.UserHash, textBoxMessage.Text); textBoxMessage.Text = ""; }
private void m_OnNewUpload(InterfaceClient client) { //we fist check if the upload is in the list, possible when interface is sleeping and a deleted source //is added again (the deleted source was not really removed because interface was sleeping foreach (ListViewItem item in Items) { if ((((InterfaceClient)item.Tag).ID == client.ID) && (((InterfaceClient)item.Tag).Port == client.Port)) { return; } } ListViewItem itemUpload = new ListViewItem(new string[] { "", "", "", "", "", "", "", "", "" }); itemUpload.Tag = client; ClientToItem(client, itemUpload); Items.Add(itemUpload); }
private void OnViewFiles(object sender, System.EventArgs e) { if (listViewFriends.SelectedItems.Count <= 0) { return; } int index = listViewFriends.SelectedIndices[0]; InterfaceClient source = new InterfaceClient(); source.ID = m_Friends[index].ID; source.Name = m_Friends[index].Name; if (m_Friends[index].OurName != "") { source.Name = m_Friends[index].OurName; } source.Port = m_Friends[index].Port; source.ServerIP = m_Friends[index].ServerIP; source.Software = m_Friends[index].Software; source.Version = m_Friends[index].Version; source.UserHash = m_Friends[index].UserHash; krnGateway.RequestSharedList(source.ID, source.Port, source.ServerIP, source.UserHash); }
private void OnSendMessage(object sender, System.EventArgs e) { if (listViewFriends.SelectedItems.Count <= 0) { return; } int index = listViewFriends.SelectedIndices[0]; InterfaceClient source = new InterfaceClient(); source.ID = m_Friends[index].ID; source.Name = m_Friends[index].Name; if (m_Friends[index].OurName != "") { source.Name = m_Friends[index].OurName; } source.Port = m_Friends[index].Port; source.ServerIP = m_Friends[index].ServerIP; source.Software = m_Friends[index].Software; source.Version = m_Friends[index].Version; source.UserHash = m_Friends[index].UserHash; krnGateway.StartChatSession(source); }
private void ClientToItem(InterfaceClient client, ListViewItem itemUpload) { if (client == null) { return; } if (itemUpload.SubItems[0].Text != client.Name) { itemUpload.SubItems[0].Text = client.Name; } if (itemUpload.SubItems[1].Text != client.UpFileName) { itemUpload.SubItems[1].Text = client.UpFileName; } if (itemUpload.SubItems[2].Text != SizeToString(client.UploadedBytes)) { itemUpload.SubItems[2].Text = SizeToString(client.UploadedBytes); } if (itemUpload.SubItems[3].Text != SizeToString(client.DownloadedBytes)) { itemUpload.SubItems[3].Text = SizeToString(client.DownloadedBytes); } if (itemUpload.SubItems[4].Text != StatusToString(client.UploadState)) { itemUpload.SubItems[4].Text = StatusToString(client.UploadState); } if (itemUpload.SubItems[5].Text != "") { itemUpload.SubItems[5].Text = ""; //progress } if (itemUpload.SubItems[6].Text != client.Software) { itemUpload.SubItems[6].Text = client.Software; } if (itemUpload.SubItems[7].Text != client.Version.ToString()) { itemUpload.SubItems[7].Text = client.Version.ToString(); } }
protected override void OnDrawItem(int item, int column, Graphics g, Rectangle rec) { InterfaceClient source = (InterfaceClient)(Items[item].Tag); if (source.UpFileChunks == null) { return; } SolidBrush b = new SolidBrush(Color.Red); int xpos = rec.Left; int ChunkLength; for (int i = 0; i < source.UpFileChunks.Length; i++) { ChunkLength = (int)Decimal.Round((decimal)(rec.Right - xpos) / (decimal)(source.UpFileChunks.Length - i), 0); switch (source.UpFileChunks[i]) { case 3: b.Color = Color.Black; break; case 0: b.Color = Color.Red; break; case 1: b.Color = Color.DarkBlue; break; case 2: b.Color = Color.Green; break; default: b.Color = Color.Red; break; } g.FillRectangle(b, xpos, rec.Top, ChunkLength, rec.Height); xpos += ChunkLength; } }
private void m_ProcessMessage() { if ((m_LastClient.UserHash == null) && (m_LastClient.ID == 0 || m_LastClient.Port == 0)) { return; } Crownwood.Magic.Controls.TabPage messagePage = null; foreach (Crownwood.Magic.Controls.TabPage page in tabMessages.TabPages) { InterfaceClient clicomp = (InterfaceClient)page.Tag; if ((clicomp.UserHash != null) && (m_LastClient.UserHash != null)) { if (m_HashToString(m_LastClient.UserHash) == m_HashToString(clicomp.UserHash)) { messagePage = page; break; } } else { if ((m_LastClient.ID == clicomp.ID) && (m_LastClient.Port == clicomp.Port)) { messagePage = page; break; } } } if (messagePage == null) { RichTextBox textBoxMsg = new RichTextBox(); textBoxMsg.BackColor = Color.White; textBoxMsg.Multiline = true; textBoxMsg.ReadOnly = true; textBoxMsg.BorderStyle = BorderStyle.FixedSingle; textBoxMsg.ScrollBars = RichTextBoxScrollBars.Both; textBoxMsg.Dock = DockStyle.Fill; textBoxMsg.ForeColor = eLePhantForm.Skin.GetColor("TextBoxForeColor"); textBoxMsg.BackColor = eLePhantForm.Skin.GetColor("TextBoxBackColor"); textBoxMsg.DetectUrls = true; textBoxMsg.LinkClicked += new LinkClickedEventHandler(Link_Clicked); //textBoxMsg.ContextMenu.MenuItems.Add("-"); textBoxMsg.ContextMenu = new ContextMenu(); textBoxMsg.ContextMenu.MenuItems.Add("Add to friends", new EventHandler(OnAddFriend)); messagePage = new Crownwood.Magic.Controls.TabPage(m_LastClient.Name, textBoxMsg, null); messagePage.Tag = m_LastClient; tabMessages.TabPages.Add(messagePage); tabMessages.SelectedIndex = tabMessages.TabPages.Count - 1; if (m_LastMessage.Length > 0) { textBoxMsg.Text = DateTime.Now.ToString() + "<-" + m_LastMessage + "\r\n"; } textBoxMessage.Focus(); } else { RichTextBox textBox = (RichTextBox)messagePage.Control; tabMessages.SelectedIndex = tabMessages.TabPages.IndexOf(messagePage); if (m_LastMessage.Length > 0) { textBox.Text += DateTime.Now.ToString() + "<-" + m_LastMessage + "\r\n"; Win32.SendMessage(textBox.Handle, Win32.WM_VSCROLL, (IntPtr)Win32.SB_BOTTOM, (IntPtr)0); } } }