示例#1
0
        private void watcher_Renamed(object sender, RenamedEventArgs e)
        {
            File         file = new File(e.Name, e.FullPath);
            ListViewItem lvi  = new ListViewItem(file.ToString());

            lvi.Tag = file;
            Lv.Items.Add(lvi);
            lvi.SubItems.AddRange(new string[] { e.ChangeType.ToString(), DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss") });
            del d = Open;

            Frm.Invoke(d, e.Name);
            ToPaly();
        }
示例#2
0
        private void watcher_Changed(object sender, FileSystemEventArgs e)
        {
            if (e.ChangeType == WatcherChangeTypes.Changed)
            {
                watcher.EnableRaisingEvents = false;
                watcher.EnableRaisingEvents = true;
            }
            File         file = new File(e.Name, e.FullPath);
            ListViewItem lvi  = new ListViewItem(file.ToString())
            {
                Tag = file
            };

            Lv.Items.Add(lvi);
            lvi.SubItems.AddRange(new string[] { e.ChangeType.ToString(), DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss") });
            del d = Open;

            Frm.Invoke(d, e.Name);
            ToPaly();
        }
示例#3
0
        public void WriteToLog(LogType LT, string LogMessage)
        {
            try
            {
                DateTime DT    = DateTime.Today;
                string   Datum = DT.ToString("dd.MM.yyyy");

                string CompMessage = "";
                Form   Frm;
                bool   loglevel = true;

                switch (LT)
                {
                case LogType.Error:
                    CompMessage = "FEHLER: " + LogMessage + "\r\n";
                    if (Mode != LogMode.Error && Mode != LogMode.All)
                    {
                        loglevel = false;
                    }
                    break;

                case LogType.Warning:
                    CompMessage = "WARNUNG: " + LogMessage + "\r\n";
                    if (Mode != LogMode.Warning && Mode != LogMode.All)
                    {
                        loglevel = false;
                    }
                    break;

                case LogType.Info:
                    CompMessage = "INFO: " + LogMessage + "\r\n";
                    if (Mode != LogMode.Info && Mode != LogMode.All)
                    {
                        loglevel = false;
                    }
                    break;
                }



                if (Datum != aktdate)
                {
                    OpenLogFile();
                }

                if (fs.CanWrite)
                {
                    if (WType != WindowType.None)
                    {
                        switch (WType)
                        {
                        case WindowType.RichTextBox:
                            RichTextBox RTB = (RichTextBox)Window;
                            //this.Invoke((MethodInvoker)(() => richTextBox1.Text = richTextBox1.Text + CompMessage));
                            Frm = RTB.FindForm();
                            Frm.Invoke((MethodInvoker)(() => RTB.Text = RTB.Text + CompMessage));
                            break;

                        case WindowType.TextBox:
                            TextBox TB = (TextBox)Window;
                            Frm = TB.FindForm();
                            Frm.Invoke((MethodInvoker)(() => TB.Text = TB.Text + CompMessage));
                            break;

                        case WindowType.ComboBox:
                            ComboBox CB = (ComboBox)Window;
                            Frm = CB.FindForm();
                            Frm.Invoke((MethodInvoker)(() => CB.Items.Add(CompMessage)));
                            break;

                        case WindowType.ListBox:
                            ListBox LB = (ListBox)Window;
                            Frm = LB.FindForm();
                            Frm.Invoke((MethodInvoker)(() => LB.Items.Add(CompMessage)));
                            break;

                        case WindowType.None:

                            break;
                        }
                    }

                    if (loglevel)
                    {
                        fs.WriteAsync(Encoding.ASCII.GetBytes(CompMessage), 0, CompMessage.Length);
                        fs.FlushAsync();
                    }
                }
            }
            catch (Exception ex)
            {
                if (fs.CanWrite)
                {
                    fs.WriteAsync(Encoding.ASCII.GetBytes(ex.Message.ToString()), 0, ex.Message.Length);
                    fs.FlushAsync();
                }
            }
        }