Ejemplo n.º 1
0
        public override void Write(string value)
        {
            VoidAction action = delegate
            {
                _listBox.Items.Insert(0, string.Format("[{0:HH:mm:ss}]{1}", DateTime.Now, value));
            };

            _listBox.BeginInvoke(action);
        }
Ejemplo n.º 2
0
 public void broadcastMessage(String title, String text)
 {
     messages.BeginInvoke(new MethodInvoker(delegate
     {
         int remainder;
         int lines = Math.DivRem(text.Length, 120, out remainder);
         messages.Items.Add(title + " :: " + text);
         messages.Refresh();
     }));
 }
Ejemplo n.º 3
0
        public override void Write(string value)
        {
            VoidAction action = delegate
            {
                //lstBox.Items.Insert(0, string.Format("[{0:HH:mm:ss}]{1}", DateTime.Now, value));
                lstBox.TopIndex = lstBox.Items.Count - 1;
                lstBox.Items.Add(value);
            };

            lstBox.BeginInvoke(action);
        }
 public void AddIP(Socket s)
 {
     if (s != null)
     {
         lbClients.BeginInvoke(
             new Action(
                 () =>
         {
             lbClients.Items.Add(s.RemoteEndPoint.ToString());
         }));
     }
 }
Ejemplo n.º 5
0
        public static void CarregarProcessos()
        {
            if (File.Exists("1542228_AED_TI_SO_dados.txt"))
            {
                string       linha;
                string[]     info;
                StreamReader entrada = new StreamReader("1542228_AED_TI_SO_dados.txt");
                while (!entrada.EndOfStream)
                {
                    linha = entrada.ReadLine();
                    info  = linha.Split(';');
                    novo  = new Processos(int.Parse(info[0]), info[1], int.Parse(info[2]), int.Parse(info[3]));
                    switch (int.Parse(info[2]))
                    {
                    case 1:
                    case 2:
                    case 3:
                    case 4:
                    case 5:
                    case 6:
                    case 7:
                    case 8:
                    case 9:
                    case 10: i.B[int.Parse(info[2]) - 1].inserir(novo); break;

                    default:
                        Console.WriteLine("ERRO AO LER O ARQUIVO");
                        break;
                    }
                    if (int.Parse(info[2]) == 1)
                    {
                        Processos Pro = (Processos)(novo);
                        if (list1.InvokeRequired)
                        {
                            list1.BeginInvoke((MethodInvoker) delegate {
                                list1.Items.Add(Pro.ToString());
                            });
                        }
                        Application.DoEvents();
                    }
                }
                entrada.Close();
                for (int o = 0; o < i.B.Length; o++)
                {
                    i.A1.inserir(i.B[o]);
                }
            }
        }
        public static void AppendTextToListBox(ListBox control, string msg)
        {
            if (control.InvokeRequired)
            {
                MethodInvoker delcall = () => { AppendTextToListBox(control, msg); };

                try
                { control.BeginInvoke(delcall); }

                catch (Exception ex)
                { ex.ToDummy(); }
            }

            else
            {
                foreach (string line in msg.Split(new char[] { '\n' }))
                {
                    control.Items.Add(line);

                    int itemsPerPage = (int)(control.Height / control.ItemHeight);

                    control.TopIndex = control.Items.Count - itemsPerPage;

                    control.Refresh();
                }
            }
        }
Ejemplo n.º 7
0
 public void WriteLine(String value)
 {
     if (listBox_Info.InvokeRequired)
     {
         listBox_Info.BeginInvoke(new dgWriteLine(WriteLine), new object[] { value });
     }
     else
     {
         listBox_Info.Items.Add(value);
         if (listBox_Info.Items.Count > 200)
         {
             listBox_Info.Items.RemoveAt(
                 listBox_Info.Items.Count - 1);
         }
     }
 }
Ejemplo n.º 8
0
        public void OnNext(IZeroconfHost value)
        {
            if (!String.IsNullOrEmpty(value.IPAddress))
            {
                foreach (var property in value.Services[HttpService].Properties)
                {
                    if (property.TryGetValue("product", out var product) && product.StartsWith("Duet"))
                    {
                        Task.Run(async() =>
                        {
#if !DEBUG
                            // Request oem.json from the Duet
                            OemInfo info = await OemInfo.Get(value.IPAddress);
                            if (info.Vendor == "diabase")
#endif
                            {
                                // This is a Diabase machine
                                ExtendedStatusResponse statusResponse = await ExtendedStatusResponse.Get(value.IPAddress);
                                MachineInfo boardInfo = new MachineInfo
                                {
                                    IPAddress = value.IPAddress,
                                    Name      = statusResponse.Name
                                };

                                list.BeginInvoke(new ItemAddDelegate(AddItem), boardInfo);
                            }
                        });
                    }
                }
            }
        }
Ejemplo n.º 9
0
        private async Task ContextChanged(IContext context)
        {
            if (!context.HasAny("Debug"))
            {
                return;
            }

            if (!_control.IsHandleCreated)
            {
                return;
            }

            _control.BeginInvoke((MethodInvoker) delegate
            {
                _control.BeginUpdate();
                _control.Items.Clear();

                foreach (var key in context.GetAll())
                {
                    object p;
                    if (!context.TryGet(key, out p))
                    {
                        p = null;
                    }
                    var str = key;
                    if (p != null)
                    {
                        str += ": " + GetDisplayName(p);
                    }
                    _control.Items.Add(str);
                }

                _control.EndUpdate();
            });
        }
Ejemplo n.º 10
0
 private void WriteEvent(LogEvent logEvent)
 {
     if ((logEvent != null) && (_canAdd))
     {
         _listBox.BeginInvoke(new AddALogEntryDelegate(AddALogEntry), logEvent);
     }
 }
Ejemplo n.º 11
0
        private void UpdateInfo(ListBox listbox, string message)
        {
            if (listbox.Items.Count > 1000)
            {
                listbox.Items.RemoveAt(0);
            }

            string item = string.Empty;

            //listbox.Items.Add("");
            item = DateTime.Now.ToString("HH:mm:ss") + " " + @message;
            if (listbox.InvokeRequired)
            {
                listbox.BeginInvoke(new Action <string>((msg) =>
                {
                    listbox.Items.Add(msg);
                }), item);
            }
            else
            {
                listbox.Items.Add(item);
            }
            if (listbox.Items.Count > 1)
            {
                listbox.TopIndex = listbox.Items.Count - 1;
                listbox.SetSelected(listbox.Items.Count - 1, true);
            }
        }
        void ILogHnd.OnLog(string userId, ILogInfo info)
        {
            try
            {
                // Threadsicherer Aufruf der Listbox Add Methode
                if (_lbx.InvokeRequired)
                {
                    ILogHnd logHnd = this;
                    DGHnd   dg     = new DGHnd(logHnd.OnLog);
                    _lbx.BeginInvoke(dg, new object[] { userId, info });
                }
                else
                {
                    switch (info.LogType)
                    {
                    case EnumLogType.Error:
                    {
                        string descr = string.Format("Err: user= {0:s}: {1} / {2}", info.LogDate, userId, info.Message);
                        Debug.Fail("WinFormListBoxLogHnd: " + descr);
                        _lbx.Items.Add(_counter.ToString() + '\t' + descr);
                        _counter++;
                    }
                    break;

                    case EnumLogType.Message:
                        if (ShowMessage)
                        {
                            string descr = string.Format("Msg: user= {0:s}: {1} / {2}", info.LogDate, userId, info.Message);
                            Debug.WriteLine("WinFormListBoxLogHnd: " + descr);
                            _lbx.Items.Add(_counter.ToString() + '\t' + descr);
                            _counter++;
                        }
                        break;

                    case EnumLogType.Status:
                        if (ShowStatus)
                        {
                            string descr = string.Format("Sta: user= {0}: {1} / {2}", info.LogDate, userId, info.Message);
                            Debug.WriteLine("WinFormListBoxLogHnd: " + descr);
                            _lbx.Items.Add(_counter.ToString() + '\t' + descr);
                            _counter++;
                        }
                        break;

                    default:
                    {
                        string descr = string.Format("Unbekannter Logtyp: user= {0:s}: {1} / {2}", info.LogDate, userId, info.Message);
                        _lbx.Items.Add(_counter.ToString() + '\t' + descr);
                        Debug.Fail("WinFormListBoxLogHnd: " + descr);
                    }
                    break;
                    }
                }
            }
            catch (Exception ex)
            {
                SelfDeregisterILogHnd();
            }
        }
Ejemplo n.º 13
0
        async Task <bool> LoadIndexFile(string indexFile, string baseFile)
        {
            Func <string, bool> log = AddLogRecord;

            _header = Helper.ReadFromBinaryFile <SelfOrganizeIndexHeader>(indexFile, 0);
            if (_header.version == 0)
            {
                logLstBox.BeginInvoke(log, new object[] { "Ошибка чтения заголовка" });
                return(false);
            }

            logLstBox.BeginInvoke(log, new object[] { "Заголовок успешно прочитан" });

            logLstBox.BeginInvoke(log, new object[] { "Загрузка index файла займёт некоторое время, пожалуйста, подождите" });

            _linkedList = Helper.ReadFromBinaryFileLinkedList <SelfOrganizeIndexNode>(indexFile, _header.nodesBeginOffset, 0, true);

            return(true);
        }
Ejemplo n.º 14
0
        internal static void DisplayTo(ListBox lb)
        {
            string path = RazorEnhanced.Settings.General.ReadString("CapPath");

            if (!Directory.Exists(path))
            {
                path = Assistant.Engine.RootPath;                 //Path.GetDirectoryName(Application.ExecutablePath);
                RazorEnhanced.Settings.General.WriteString("CapPath", path);
                Assistant.Engine.MainWindow.ScreenPath.Text = path;
            }

            // Credzba look here
            if (lb.InvokeRequired)
            {
                lb.BeginInvoke(new MethodInvoker(delegate
                {
                    lock (m_lock)
                    {
                        lb.BeginUpdate();
                        lb.Items.Clear();
                        AddFiles(lb, path, "jpeg");
                        AddFiles(lb, path, "jpg");
                        AddFiles(lb, path, "png");
                        AddFiles(lb, path, "bmp");
                        AddFiles(lb, path, "gif");
                        AddFiles(lb, path, "tiff");
                        AddFiles(lb, path, "tif");
                        AddFiles(lb, path, "wmf");
                        AddFiles(lb, path, "exif");
                        AddFiles(lb, path, "emf");
                        lb.EndUpdate();
                    }
                }));
            }
            else
            {
                lock (m_lock)
                {
                    lb.BeginUpdate();
                    lb.Items.Clear();
                    AddFiles(lb, path, "jpeg");
                    AddFiles(lb, path, "jpg");
                    AddFiles(lb, path, "png");
                    AddFiles(lb, path, "bmp");
                    AddFiles(lb, path, "gif");
                    AddFiles(lb, path, "tiff");
                    AddFiles(lb, path, "tif");
                    AddFiles(lb, path, "wmf");
                    AddFiles(lb, path, "exif");
                    AddFiles(lb, path, "emf");
                    lb.EndUpdate();
                }
            }
        }
Ejemplo n.º 15
0
        public void ShowListeners(ContextRouter router, ContextItem item,
                                  [Context(nameof(OtherContextRouter))]   ContextRouter otherRouter,
                                  [Context(nameof(ListenerListBox))]      ListBox listBox)
        {
            var listeners = otherRouter.GetAllListeners();

            listBox.BeginInvoke(() =>
            {
                listBox.Items.AddRange(listeners.Select(l => l.Name).OrderBy(n => n).ToArray());
            });
        }
Ejemplo n.º 16
0
 public static void SetListbox(ListBox listBox, string textValue)
 {
     if (listBox.InvokeRequired)
     {
         DSetListbox dSetListbox = SetListbox;
         listBox.BeginInvoke(dSetListbox, new object[] { listBox, textValue });
     }
     else
     {
         listBox.SelectedIndex = listBox.FindString(textValue);
     }
 }
Ejemplo n.º 17
0
        public void DoAppend(log4net.Core.LoggingEvent loggingEvent)
        {
            try
            {
                if (_listBox == null)
                {
                    return;
                }

                // For my situation, this quick and dirt filter was all that was
                // needed. Depending on your situation, you may decide to delete
                // this logic, modify it slightly, or implement something a
                // little more sophisticated.
                if (loggingEvent.LoggerName.Contains("NHibernate"))
                {
                    return;
                }

                // Again, my requirements were simple; displaying the message was
                // all that was needed. Depending on your circumstances, you may
                // decide to add information to the displayed message
                // (e.g. log level) or implement something a little more
                // dynamic.
                var msg = string.Concat(loggingEvent.RenderedMessage, "\r\n");

                lock (_lockObj)
                {
                    // This check is required a second time because this class
                    // is executing on multiple threads.
                    if (_listBox == null)
                    {
                        return;
                    }

                    // Because the logging is running on a different thread than
                    // the GUI, the control's "BeginInvoke" method has to be
                    // leveraged in order to append the message. Otherwise, a
                    // threading exception will be thrown.
                    var del = new Action <string>(s =>
                    {
                        string strTime = DateTime.Now.ToString("HH:mm:ss.fff");
                        string strMsg  = String.Format("[{0}] {1}", strTime, s);
                        _listBox.Items.Add(strMsg);
                    });
                    _listBox.BeginInvoke(del, msg);
                }
            }
            catch
            {
                // There is not much that can be done here, and
                // swallowing the error is desired in my situation.
            }
        }
Ejemplo n.º 18
0
 public static void SetIndexList(ListBox c, int i)
 {
     if (c.InvokeRequired)
     {
         SetTopIndexListCallBack d = new SetTopIndexListCallBack(SetIndexList);
         c.BeginInvoke(d, c, i);
     }
     else
     {
         c.TopIndex = i;
     }
 }
Ejemplo n.º 19
0
 public static void ClearList(ListBox c)
 {
     if (c.InvokeRequired)
     {
         ClearListCallBack d = new ClearListCallBack(ClearList);
         c.BeginInvoke(d, c);
     }
     else
     {
         c.Items.Clear();
     }
 }
Ejemplo n.º 20
0
 public static void AddList(ListBox c, object str)
 {
     if (c.InvokeRequired)
     {
         AddItemListCallBack d = new AddItemListCallBack(AddList);
         c.BeginInvoke(d, c, str);
     }
     else
     {
         c.Items.Add(str);
     }
 }
Ejemplo n.º 21
0
 public void Set(string msg)
 {
     if (_listBox.InvokeRequired)  // 別スレッドから呼び出された場合
     {
         _listBox.BeginInvoke(new MethodInvoker(() => Set(msg)));
     }
     else
     {
         _listBox.Items.Add(msg);
         _listBox.TopIndex = _listBox.Items.Count - _listBox.Height / _listBox.ItemHeight;
     }
 }
Ejemplo n.º 22
0
        public void ShowActiveListeners(ContextRouter router, ContextItem item,
                                        [Context(nameof(OtherContextRouter))]         ContextRouter otherRouter,
                                        [Context(nameof(ActiveListenersListBox))]     ListBox listBox,
                                        [Context(nameof(SelectedContext))]            string contextName)
        {
            var listenerTypes = otherRouter.GetListeners(contextName);

            listBox.BeginInvoke(() =>
            {
                listBox.Items.Clear();
                listBox.Items.AddRange(listenerTypes.Select(lt => lt.Name).ToArray());
            });
        }
Ejemplo n.º 23
0
        public void ShowListenerParameters(ContextRouter router, ContextItem item,
                                           [Context(nameof(OtherContextRouter))]   ContextRouter otherRouter,
                                           [Context(nameof(ParametersListBox))]    ListBox listBox,
                                           [Context(nameof(SelectedListener))]     string name)
        {
            var listener = otherRouter.GetAllListeners().Single(l => l.Name == name);

            listBox.BeginInvoke(() =>
            {
                listBox.Items.Clear();
                listBox.Items.AddRange(listener.GetParameters().ToArray());
            });
        }
Ejemplo n.º 24
0
 public void SetSelectedListBoxIdx(ListBox anything, int idx, bool state)
 {
     anything.BeginInvoke((MethodInvoker) delegate
     {
         try
         {
             anything.SetSelected(idx, state);
         }
         catch
         {
         }
     });
 }
Ejemplo n.º 25
0
 public void OnNext(IZeroconfHost value)
 {
     if (!String.IsNullOrEmpty(value.IPAddress))
     {
         foreach (var property in value.Services[HttpService].Properties)
         {
             if (property.TryGetValue("product", out var product) && product.StartsWith("Duet"))
             {
                 _ = CheckMachine(value.IPAddress, (boardInfo) => list.BeginInvoke(new ItemAddDelegate(AddItem), boardInfo));
             }
         }
     }
 }
Ejemplo n.º 26
0
 public static void AddListBoxItem(ListBox control, string item)
 {
     if (control.InvokeRequired)
     {
         SetAddItemCallback callback = new SetAddItemCallback(AddListBoxItem);
         control.BeginInvoke(callback, new object[] { control, item });
     }
     else
     {
         control.Items.Add(item);
         control.SelectedIndex = control.Items.Count - 1;
     }
 }
        //Separate thread
        private void Assets_OnImageReceived(AssetTexture texture)
        {
            if (texture.AssetID != region.MapImageID)
            {
                return;
            }
            if (texture.AssetData == null)
            {
                return;
            }

            OpenMetaverse.Imaging.ManagedImage tmp;

            if (!OpenMetaverse.Imaging.OpenJPEG.DecodeToImage(texture.AssetData, out tmp, out mapImage))
            {
                return;
            }

            imageDownloading = false;
            imageDownloaded  = true;
            listBox.BeginInvoke(new MethodInvoker(RefreshListBox));
            listBox.BeginInvoke(new OnMapImageRaise(OnMapImageDownloaded), new object[] { EventArgs.Empty });
        }
        public override void OnResult(string input, List <ApplicationAPI.SWayPoint> results, int resultCode)
        {
            if (resultList != null)
            {
                resultList.BeginInvoke(new Action(() =>
                {
                    resultList.Items.Clear();
                }));

                lock (resultList)
                {
                    foreach (var pt in results)
                    {
                        string res = pt.Location.lX + ", " + pt.Location.lY + ", " + pt.GetAddress();

                        resultList.BeginInvoke(new Action(() =>
                        {
                            resultList.Items.Add(res);
                        }));
                    }
                }
            }
        }
Ejemplo n.º 29
0
        /// <summary>
        /// 選択変更時にメッセージボックスを表示する
        /// </summary>
        /// <param name="listbox">リストボックス</param>
        static void ChangeSelectedIndexEvent(ListBox listbox)
        {
            EventHandler handler = null;

            handler = delegate
            {
                MessageBox.Show("");
                listbox.BeginInvoke((MethodInvoker) delegate
                {
                    listbox.SelectedIndexChanged -= handler;
                });
            };
            listbox.SelectedIndexChanged += handler;
        }
Ejemplo n.º 30
0
        private void Objects_ObjectProperties(object sender, ObjectPropertiesEventArgs e)
        {
            if (e.Properties.ObjectID != prim.ID)
            {
                return;
            }

            try
            {
                gettingProperties = false;
                gotProperties     = true;
                prim.Properties   = e.Properties;

                listBox.BeginInvoke(
                    new OnPropReceivedRaise(OnPropertiesReceived),
                    new object[] { EventArgs.Empty });
            }
            catch
            {
                ;
            }

            //client.Objects.ObjectProperties -= new EventHandler<ObjectPropertiesEventArgs>(Objects_ObjectProperties);
        }