Пример #1
0
 private void ImageStatusEventHandler(object sender, Accusoft.ImagXpressSdk.ImageStatusEventArgs e)
 {
     if (lstView.InvokeRequired)
     {
         object[]            theparams         = { e.Status.ToString() };
         controlTextModifier theListViewModder = new controlTextModifier(lstViewThreadSafeTextAdder);
         lstView.Invoke(theListViewModder, theparams);
     }
     else
     {
         lstView.Items.Add(e.Status.ToString());
     }
 }
Пример #2
0
 public static void LogParserMessage(string message)
 {
     if (lstMessages != null)
     {
         lstMessages.Invoke(new Action(() => lstMessages.Items.Add(message)));
     }
 }
Пример #3
0
        public static void AddItemToListBox(ListBox listBox, string text)
        {
            // Check if the listbox need to be invoked.
            if (listBox.InvokeRequired)
                // Invoke the listbox control with the appropiate delegate.
                listBox.Invoke(new Action<ListBox, string>(AddItemToListBox), listBox, text);
            else
            {
                // Declare and instantiate a list for the listboxes item in the form of strings.
                List<string> listListBox = new List<string>();

                // Add the newest string to the newly created list, so that this is on top.
                listListBox.Add(text);

                // Add all of the current items to the list.
                foreach (string item in listBox.Items)
                    listListBox.Add(item);

                // Clear the listbox of all of its items.
                listBox.Items.Clear();

                // Add the newly created list to the listbox.
                foreach (string item in listListBox)
                    listBox.Items.Add(item);
            }
        }
Пример #4
0
 public static void ClearItemFromListBox(ListBox listBox)
 {
     // Check if the listbox need to be invoked.
     if (listBox.InvokeRequired)
         // Invoke the listbox control with the appropiate delegate.
         listBox.Invoke(new Action<ListBox>(ClearItemFromListBox), listBox);
     else
         // Directly clear the listbox.
         listBox.Items.Clear();
 }
Пример #5
0
 public void debug_(ListBox listBoxToUpdate, object data)
 {
     if (listBoxToUpdate.InvokeRequired)
       {
     debugDelegate dd = new debugDelegate(debug_);
     listBoxToUpdate.Invoke(dd, new object[] { listBoxToUpdate, data });
       }
       else
       {
     int i = listBoxToUpdate.Items.Add(DateTime.Now.ToShortTimeString() + " : " + data);
     listBoxToUpdate.TopIndex = i;
       }
 }
Пример #6
0
            public static void RemoveItemAt(ListBox listbox, int index)
            {
                MethodInvoker miRemoveItem = delegate
                {
                    listbox.Items.RemoveAt(index);
                };

                if (listbox.InvokeRequired)
                {
                    listbox.Invoke(miRemoveItem);
                }
                else
                {
                    miRemoveItem();
                }
            }
Пример #7
0
            public static void InsertItem(ListBox listbox, int index, object item)
            {
                MethodInvoker miInsertItem = delegate
                {
                    listbox.Items.Insert(index, item);
                };

                if (listbox.InvokeRequired)
                {
                    listbox.Invoke(miInsertItem);
                }
                else
                {
                    miInsertItem();
                }
            }
Пример #8
0
 public static void AddItemThreadSafe(this System.Windows.Forms.ListBox lb, object item)
 {
     if (lb.InvokeRequired)
     {
         lb.Invoke(new MethodInvoker(delegate
         {
             lb.Items.Add(item);
             lb.SelectedIndex = lb.Items.Count - 1;
         }));
     }
     else
     {
         lb.Items.Add(item);
         lb.SelectedIndex = lb.Items.Count - 1;
     }
 }
Пример #9
0
        public static void AddItem(ListBox box, string item)
        {
            MethodInvoker miAddItem = delegate
            {
                box.Items.Add(item);
            };

            if (box.InvokeRequired)
            {
                box.Invoke(miAddItem);
            }
            else
            {
                miAddItem();
            }
        }
Пример #10
0
            public static void AddItem(ListBox listbox, object item)
            {
                MethodInvoker miAddItem = delegate
                {
                    listbox.Items.Add(item);
                };

                if (listbox.InvokeRequired)
                {
                    listbox.Invoke(miAddItem);
                }
                else
                {
                    miAddItem();
                }
            }
Пример #11
0
            public static void ClearItems(ListBox listbox)
            {
                MethodInvoker miClearItems = delegate
                {
                    listbox.Items.Clear();
                };

                if (listbox.InvokeRequired)
                {
                    listbox.Invoke(miClearItems);
                }
                else
                {
                    miClearItems();
                }
            }
Пример #12
0
 public void LogMessagePrint(string msg)
 {
     if (log.InvokeRequired)
     {
         log.Invoke(new MethodInvoker(delegate()
         {
             LogMessagePrint(msg);
         }));
     }
     else
     {
         log.Items.Add("[" + LogGetTime() + "] : " + msg);
         log.Refresh();
         log.SelectedIndex = log.Items.Count - 1;
     }
 }
Пример #13
0
        internal static void FetchAttendees(User i_LoggedInUser, ListBox i_ListBoxFriendsWithRank)
        {
            List<UserRank<Event>> allUsersWithSharedEvents = CentralSingleton.Instance.AttendeesFromEventListAdapter.UserRankList;
            if (allUsersWithSharedEvents == null)
            {
                allUsersWithSharedEvents = FetchAttendeesFromEvents(i_LoggedInUser);
                CentralSingleton.Instance.AttendeesFromEventListAdapter.UserRankList = allUsersWithSharedEvents;
            }

            ArrayList userRankList = new ArrayList(allUsersWithSharedEvents);
            userRankList.Sort();
            userRankList.Reverse();
            foreach (UserRank<Event> userRank in userRankList)
            {
                i_ListBoxFriendsWithRank.Invoke(new Action(() => i_ListBoxFriendsWithRank.Items.Add(userRank)));
            }
        }
Пример #14
0
 public static void AddItemThreadSafe(this System.Windows.Forms.ListBox lb, object item)
 {
     if (lb.InvokeRequired)
     {
         lb.Invoke(new MethodInvoker(delegate
         {
             lb.Items.Add(item);
             lb.TopIndex = Math.Max(lb.Items.Count - lb.ClientSize.Height / lb.ItemHeight + 1, 0);
             lb.Refresh();
         }));
     }
     else
     {
         lb.Items.Add(item);
         lb.TopIndex = Math.Max(lb.Items.Count - lb.ClientSize.Height / lb.ItemHeight + 1, 0);
         lb.Refresh();
     }
 }
Пример #15
0
 public static void MesageRecievedFromServer(byte[] buffer)
 {
     if (listaMensagens.InvokeRequired)
     {
         DelegateFileFromServer del = new DelegateFileFromServer(MesageRecievedFromServer);
         listaMensagens.Invoke(del, buffer);
     }
     else
     {
         using (MemoryStream ms = new MemoryStream(buffer))
         {
             ProjetoChat.Mensagem msg = new ProjetoChat.Mensagem(null, null, null, DateTime.Now, null);
             try
             {
                 BinaryFormatter bf = new BinaryFormatter();
                 msg = (ProjetoChat.Mensagem)bf.Deserialize(ms);
                 mensagens.Add(msg);
                 if (msg.getImage() != null)
                 {
                     listaMensagens.Items.Add("(" + msg.getDataEnvio() + ") " + msg.getRemetente() + " enviou uma imagem (double click para visualizar)");
                 }
                 else
                 {
                     if (msg.getContent().Equals(string.Empty))
                     {
                         listaMensagens.Items.Add("(" + msg.getDataEnvio() + ") " + msg.getRemetente() + " enviou um arquivo texto (double click para visualizar)");
                     }
                     else
                     {
                         listaMensagens.Items.Add("(" + msg.getDataEnvio().ToString() + ") " + msg.getRemetente() + " says: " + msg.getContent());
                     }
                 }
             }
             catch (Exception)
             {
                 MessageBox.Show("Tivemos um erro ao receber a mensagem");
             }
             finally
             {
                 ms.Close();
             }
         }
     }
 }
Пример #16
0
            public static object GetSelectedItem(ListBox listbox)
            {
                object selectedItem = null;

                MethodInvoker miClearItems = delegate
                {
                    selectedItem = listbox.SelectedItem;
                };

                if (listbox.InvokeRequired)
                {
                    listbox.Invoke(miClearItems);
                }
                else
                {
                    miClearItems();
                }

                return selectedItem;
            }
Пример #17
0
            public static object GetItem(ListBox listbox, int index)
            {
                object item = null;

                MethodInvoker miRemoveItem = delegate
                {
                    item = listbox.Items[index];
                };

                if (listbox.InvokeRequired)
                {
                    listbox.Invoke(miRemoveItem);
                }
                else
                {
                    miRemoveItem();
                }

                return item;
            }
Пример #18
0
        private void MessageHandler_Message(int nId, string sMessage)
        {
            if (m_isClosing)
            {
                return;
            }
            var writeMessageAction = new Action(
                () =>
            {
                m_listBoxMessages.BeginUpdate();

                int nItem = m_listBoxMessages.Items.Add(string.Format("({0}) <{1}> {2}", nId, System.DateTime.Now, sMessage));

                if (m_listBoxMessages.Items.Count > 5000)
                {
                    m_listBoxMessages.Items.RemoveAt(0);
                }

                if (m_listBoxMessages.SelectedIndex < 0)
                {
                    m_listBoxMessages.TopIndex = nItem;
                }
                else if (m_listBoxMessages.SelectedIndex == nItem - 1)
                {
                    m_listBoxMessages.SelectedIndex = nItem;
                }

                m_listBoxMessages.EndUpdate();
            });

            if (m_listBoxMessages.InvokeRequired)
            {
                m_listBoxMessages.Invoke(writeMessageAction);
            }
            else
            {
                writeMessageAction();
            }
        }
        private void ShowStat(ListBox lstBox, string str)
        {
            if (lstBox.InvokeRequired)
            {
                ShowStatCallBack ShowStatCallBack = ShowStat;
                lstBox.Invoke(ShowStatCallBack, new object[] { lstBox, str });
            }
            else
            {

                if (str.Equals("finish-all"))
                {
                    buttonSyncIni.Enabled = true;
                    int nIdex = lstBox.Items.Add(str);
                    bSyncing = false;
                }
                else if (str.Equals("finish-diff"))
                {
                    buttonSyncDiff.Enabled = true; int nIdex = lstBox.Items.Add(str);
                }
                else
                {
                    int nIdex = 0;
                    if (str.Length == 0)
                    {
                        nIdex = lstBox.Items.Add("");
                    }
                    else
                    {
                        string sLine = DateTime.Now.ToString("mm:ss") + " " + str;
                        nIdex = lstBox.Items.Add(sLine);
                        //�������ײ�
                        listBox1.SelectedIndex = nIdex; //  listBox1.SelectedIndex = -1;
                    }
                    if (nIdex > 1000)
                        listBox1.Items.Clear();
                }
            }
        }
Пример #20
0
 private void ListBoxFill(ListBox listbox, string[] entries)
 {
     if (listbox.InvokeRequired)
     {
         listbox.Invoke(new ListBoxModifyCall(ListBoxFill), new object[] { listbox, entries, });
     }
     else
     {
         listbox.Items.Clear();
         listbox.Items.AddRange(entries);
     }
 }
Пример #21
0
 public void addTextLine(ListBox Destination, String newLine)
 {
     if(Destination.InvokeRequired)
         Destination.Invoke(new del_addText(addTextLine), Destination, newLine);
     else
     {
         Destination.Items.Add(newLine);
         Destination.SelectedIndex = lbEddnImplausible.Items.Count-1;
         Destination.SelectedIndex = -1;
     }
 }
Пример #22
0
        private void ShowStat(ListBox lstBox, string str)
        {
            if (lstBox.InvokeRequired)
            {
                ShowStatCallBack ShowStatCallBack = ShowStat;
                lstBox.Invoke(ShowStatCallBack, new object[] { lstBox, str });
            }
            else
            {

                if (str.Equals("finish-all"))
                {
                    buttonSyncIni.Enabled = true;
                    // int nIdex = lstBox.Items.Add(str);
                    bSyncing = false;
                    iniData();
                    if (bIsFirstIni)
                    {
                        MessageBox.Show("��ʼ����ɣ�", "��ʾ", MessageBoxButtons.OK, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1);
                        this.Close();
                    }
                }
                else if (str.Equals("finish-diff"))
                {
                    buttonSyncDiff.Enabled = true;
                    //  int nIdex = lstBox.Items.Add(str);
                    iniData();
                    this.Text = string.Format("Asset System(��ͬ����{0})", 0);
                }
                else
                {
                    int nIdex = 0;
                    if (str.Length == 0)
                    {
                        nIdex = lstBox.Items.Add("");
                    }
                    else
                    {
                        string sLine = DateTime.Now.ToString("mm:ss") + " " + str;
                        nIdex = lstBox.Items.Add(sLine);
                        //�������ײ�
                        listBox1.SelectedIndex = nIdex; //  listBox1.SelectedIndex = -1;
                    }
                    if (nIdex > 1000)
                        listBox1.Items.Clear();
                }
            }
        }
Пример #23
0
 public void UpdateUI()
 {
     profileListBox.Invoke(new UpdateDelegate(ReallyUpdateUI), null);
 }
Пример #24
0
 private void ShowMessage(ListBox listbox, string text)
 {
     if (listbox.InvokeRequired)
     {
         ShowMessageCallBack showmessageCallback = ShowMessage;
         listbox.Invoke(showmessageCallback, new object[] { listbox, text });
     }
     else
     {
         listbox.Items.Add(text);
         listbox.SelectedIndex = listbox.Items.Count - 1;
         listbox.ClearSelected();
     }
 }
Пример #25
0
 private bool ListAdd(ListBox Info, string domen)
 {
     if (Info.InvokeRequired)
     {
         ListDelegate DDD = new ListDelegate(ListAdd);
         return (bool)Info.Invoke(DDD, new object[] { Info, domen });
     }
     else
     {
         if (listBox1.FindString(domen) < 0)
             listBox1.Items.Add(domen);
         else return false;
         return true;
     }
 }
Пример #26
0
 public static void AddLog2List(ListBox lstAct, string content)
 {
     try
     {
         if (lstAct.InvokeRequired)
         {
             lstAct.Invoke(new AddLog(AddLog2List), new object[] { lstAct, content });
         }
         else
         {
             lstAct.BeginUpdate();
             lstAct.Items.Add(content);
             lstAct.EndUpdate();
         }
     }
     catch
     {
     }
 }
Пример #27
0
 public void GetUsers(ListBox piList)
 {
     var client = new RestClient(baseURL);
     var request = new RestRequest(subURL + "GetUsers");
     List<UserModel> userlist = new List<UserModel>();
     client.ExecuteAsync(request, response =>
     {
         var res = client.Execute(request);
         JArray users = JArray.Parse(res.Content);
         foreach (JObject content in users)
         {
             userlist.Add(new UserModel((string)content["username"], (string)content["ip"]));
         }
         if(userlist.Count > 0)
         {
             foreach(UserModel us in userlist)
             {
                 piList.Invoke(new Action(() => piList.Items.Add(us.Username)));
             }
         }
     });
 }
Пример #28
0
        public void SearchAllv5(string searchString, ListBox box, string searchType)
        {
            box.Invoke(new Action(() => box.ClearSelected()));
            string pattern = Regex.Escape(searchString).ToLower();

            if (searchString != string.Empty)
            {
                List<string> list = new List<string>();

                // KFreon: Hash search
                if (searchString.Length > 2 && searchString.Substring(0, 2) == "0x")
                {
                    for (int i = 0; i < texes.Count; i++)
                    {
                        TreeTexInfo tex = texes[i];
                        string thing = searchString.Substring(2).ToLowerInvariant();
                        string fromGame = KFreonLib.Textures.Methods.FormatTexmodHashAsString(tex.Hash).Substring(2).ToLowerInvariant();
                        if (fromGame.Contains(thing))
                            list.Add(tex.TexName + " (" + tex.ParentNode.Text.ToLower() + ")");
                    }
                }
                else if (searchString[0] == '@')   // KFreon: Export ID search
                {
                    int expID = 0;
                    if (!int.TryParse(searchString.Substring(1), out expID))
                        return;

                    for (int i = 0; i < texes.Count; i++)
                    {
                        TreeTexInfo tex = texes[i];
                        if (tex.ExpIDs.Contains(expID))
                            list.Add(tex.TexName + " (" + tex.ParentNode.Text.ToLower() + ")");
                    }
                }
                else if (searchString[0] == '\\')  // KFreon: Filename search
                {
                    int exppos = searchString.IndexOf('@');
                    int length = searchString.Length - (searchString.Length - exppos) - 2;
                    string name = (exppos == -1) ? searchString.Substring(1).ToLowerInvariant() : searchString.Substring(1, length).ToLowerInvariant();


                    if (exppos != -1)  // KFreon: Filename + ExpID search
                    {
                        int expID = 0;
                        if (!int.TryParse(searchString.Substring(exppos + 1), out expID))
                            return;

                        for (int i = 0; i < texes.Count; i++)
                        {
                            TreeTexInfo tex = texes[i];
                            for (int j = 0; j < tex.Files.Count; j++)
                                if (tex.Files[j].Split('\\').Last().ToLowerInvariant().Contains(name) && tex.ExpIDs[j] == expID)
                                    list.Add(tex.TexName + " (" + tex.ParentNode.Text.ToLower() + ")");
                        }
                    }
                    else  // KFreon: Normal filename search
                        for (int i = 0; i < texes.Count; i++)
                        {
                            TreeTexInfo tex = texes[i];
                            foreach (string filename in tex.Files)
                                if (filename.Split('\\').Last().ToLowerInvariant().Contains(name))
                                    list.Add(tex.TexName + " (" + tex.ParentNode.Text.ToLower() + ")");
                        }
                }
                else if (searchString[0] == '-')  // KFreon: Thumbnail search
                {
                    string searchstr = searchString.Substring(1).ToLowerInvariant();
                    foreach (TreeTexInfo tex in texes)
                    {
                        string name = Path.GetFileNameWithoutExtension(tex.ThumbnailPath).ToLowerInvariant();
                        if (name.Contains(searchstr))
                            list.Add(tex.TexName + " (" + tex.ParentNode.Text.ToLower() + ")");
                    }
                }
                else  // KFreon: Normal search
                {
                    for (int i = 0; i < texes.Count; i++)
                    {
                        TreeTexInfo tex = texes[i];
                        string name = tex.TexName + " (" + tex.ParentNode.Text.ToLower() + ")";
                        string s = name.ToLower();
                        Match match = Regex.Match(s, pattern, RegexOptions.IgnoreCase);
                        if (match.Success)
                            list.Add(s);
                    }
                }
                box.Invoke(new Action(() =>
                {
                    box.Items.Clear();
                    box.Items.AddRange(list.ToArray());
                }));
            }
        }
Пример #29
0
        internal static void FetchTags(User i_LoggedInUser, ListBox i_ListBoxFriendsWithRank)
        {
            List<UserRank<Photo>> allUsersWithTagsOnPhotos = CentralSingleton.Instance.SharedPhotosTagsListAdapter.UserRankList;
            if (allUsersWithTagsOnPhotos == null)
            {
                allUsersWithTagsOnPhotos = FetchTags(i_LoggedInUser);
                CentralSingleton.Instance.SharedPhotosTagsListAdapter.UserRankList = allUsersWithTagsOnPhotos;
            }

            ArrayList userRankList = new ArrayList(allUsersWithTagsOnPhotos);
            userRankList.Sort();
            userRankList.Reverse();
            foreach (UserRank<Photo> userRank in userRankList)
            {
                i_ListBoxFriendsWithRank.Invoke(new Action(() => i_ListBoxFriendsWithRank.Items.Add(userRank)));
            }
        }
Пример #30
0
 /// <summary>
 /// Adds a string to a listbox
 /// </summary>
 /// <param name="c">String to add to listbox</param>
 /// <param name="listbox">Listbox to add string to</param>
 private void DisplayString(string s, ListBox listbox)
 {
     if (listbox.InvokeRequired)
         listbox.Invoke(new DisplayDelegate(DisplayString), new object[] { s, listbox });
     else
         listbox.Items.Add(s);
 }
Пример #31
0
        public void AddItemsThreadSafe(ListBox l, String s)
        {
            if (l.InvokeRequired)
            {
            AddItemsDelegate mydelegate = new AddItemsDelegate(AddItemsThreadSafe);
            l.Invoke(mydelegate, new object[] { l, s });

            }
            else {
            l.Items.Add(s);
            }
        }
Пример #32
0
        public void FetchCollectionAsync(ListBox i_Listbox, IEnumerable<object> i_Collection, string i_MemberToDisplay)
        {
            i_Listbox.Invoke(new Action(() => i_Listbox.Items.Clear()));
            i_Listbox.Invoke(new Action(() => i_Listbox.DisplayMember = i_MemberToDisplay));
            foreach (object obj in i_Collection)
            {
                i_Listbox.Invoke(new Action(() => i_Listbox.Items.Add(obj)));
            }

            if (i_Listbox.Items.Count == 0)
            {
                MessageBox.Show("No items to display :(");
            }
        }
Пример #33
0
        private void updateUsersInLobbyListBox(ListBox usersInLobbyListBox)
        {
            if (usersInLobbyListBox.InvokeRequired)
            {
                usersInLobbyListBox.Invoke(new MethodInvoker(() => updateUsersInLobbyListBox(usersInLobbyListBox)));
                return;
            }

            usersInLobbyListBox.Items.Clear();
            foreach (var userID in Main.ludo.Rooms[ClientBase.roomListSelectionID].UserInRoomIDs)
            {
                if (Main.ludo.Rooms[ClientBase.roomListSelectionID].RoomModeratorUserID == userID)
                {
                    usersInLobbyListBox.Items.Add(Main.ludo.Users[userID].UserName + " [Moderator]");
                }
                else
                {
                    if (Main.ludo.Rooms[ClientBase.roomListSelectionID].ReadyUsersInRoomIDs.Contains(userID))
                    {
                        // When he is ready add ready string
                        if (Main.ludo.Rooms[ClientBase.roomListSelectionID].RoomStatus == "Starting")
                        {
                            usersInLobbyListBox.Items.Add(Main.ludo.Users[userID].UserName + " [Starting]");
                        }
                        else
                        {
                            usersInLobbyListBox.Items.Add(Main.ludo.Users[userID].UserName + " [Ready]");
                        }
                    }
                    else
                    {
                        usersInLobbyListBox.Items.Add(Main.ludo.Users[userID].UserName);
                    }
                }
            }
        }
Пример #34
0
            public static string GetText(ListBox listbox)
            {
                string text = string.Empty;

                MethodInvoker miGetText = delegate
                {
                    text = listbox.Text;
                };

                if (listbox.InvokeRequired)
                {
                    listbox.Invoke(miGetText);
                }
                else
                {
                    miGetText();
                }

                return text;
            }
Пример #35
0
 private void SetListBoxSelectedItem(ListBox listBox, string selectedItem)
 {
     if(listBox.InvokeRequired)
     {
         listBox.Invoke(new Action<ListBox, string>(SetListBoxSelectedItem), new object[] { listBox, selectedItem });
     }
     else
     {
         listBox.SelectedItem = selectedItem;
     }
 }