Beispiel #1
0
 public void m_OnNewUpload(InterfaceClient client)
 {
     if (OnNewUpload != null)
     {
         OnNewUpload(client);
     }
 }
Beispiel #2
0
 public void m_OnNewSource(InterfaceClient client, string strFileHash)
 {
     if (OnNewSource != null)
     {
         OnNewSource(client, strFileHash);
     }
 }
Beispiel #3
0
        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);
            }
        }
Beispiel #4
0
 public void StartChatSession(InterfaceClient source)
 {
     if (OnStartChatSession != null)
     {
         OnStartChatSession(source);
     }
 }
Beispiel #5
0
        static void Main(string[] args)
        {
            InterfaceClient client = new InterfaceClient();

            Console.WriteLine(client.ErrorDescription(client.AddLogin("Login8", "333")));
            Console.ReadLine();
        }
Beispiel #6
0
 public void m_OnNewChatMessage(InterfaceClient source, string message)
 {
     if (OnNewChatMessage != null)
     {
         OnNewChatMessage(source, message);
     }
 }
Beispiel #7
0
        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;
            }
        }
Beispiel #8
0
 // 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();
 }
Beispiel #10
0
        private void m_OnStartChatSession(InterfaceClient client)
        {
            m_LastClient  = client;
            m_LastMessage = "";
            MethodInvoker mi = new MethodInvoker(this.m_ProcessMessage);

            this.BeginInvoke(mi);
        }
Beispiel #11
0
        private void m_OnNewChatMessage(InterfaceClient client, string message)
        {
            m_LastClient  = client;
            m_LastMessage = message;
            MethodInvoker mi = new MethodInvoker(this.m_ProcessMessage);

            this.BeginInvoke(mi);
        }
Beispiel #12
0
        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;
        }
Beispiel #13
0
        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);
        }
Beispiel #14
0
        private void OnSendMessage(object sender, System.EventArgs e)
        {
            if (this.SelectedItems.Count <= 0)
            {
                return;
            }
            InterfaceClient source = (InterfaceClient)SelectedItems[0].Tag;

            krnGateway.StartChatSession(source);
        }
Beispiel #15
0
        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);
        }
Beispiel #16
0
        private void OnAddFriend(object sender, System.EventArgs e)
        {
            if (this.SelectedItems.Count <= 0)
            {
                return;
            }
            InterfaceClient source = (InterfaceClient)SelectedItems[0].Tag;

            krnGateway.AddFriend(source);
        }
Beispiel #17
0
        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();
        }
Beispiel #18
0
        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);
                }
            }
        }
Beispiel #19
0
        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);
                }
            }
        }
Beispiel #20
0
        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());
        }
Beispiel #21
0
        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);
        }
Beispiel #22
0
        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);
        }
Beispiel #23
0
        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);
        }
Beispiel #24
0
        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 = "";
        }
Beispiel #25
0
        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);
        }
Beispiel #26
0
        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);
        }
Beispiel #27
0
        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);
        }
Beispiel #28
0
 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();
     }
 }
Beispiel #29
0
        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;
            }
        }
Beispiel #30
0
        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);
                }
            }
        }