public void Execute(object parameter)
        {
            var w = parameter as Window;
            if (w == null) return;

            // remove quotes
            var fileLocation = _vm.FileLocation.Trim('"');

            var newLog = new LogInfo(fileLocation, _vm.Alias);
            LogSource.Instance.Logs.Groups
                .First(group => group.Id.Equals(_vm.SelectedGroup.Id))
                .AddLog(newLog);

            w.Hide();
            w.Close();
        }
示例#2
0
 private void OnLogRemoved(LogInfo log)
 {
     Debug.WriteLine("OnLogRemoved fired (LogSource)");
     LogRemoved?.Invoke(this, new LogEventArgs(log));
 }
示例#3
0
 private void OnLogAdded(LogInfo log, Guid logId)
 {
     Debug.WriteLine("OnLogAdded fired (LogSource)");
     LogAdded?.Invoke(this, new LogEventArgs(log, logId));
 }
示例#4
0
        public void RemoveLog(LogInfo log)
        {
            // brute force
            foreach (var group in Logs.Groups)
            {
                group.Logs.RemoveAll(l => l.Id.Equals(log.Id));
            }

            SaveState();
            OnLogRemoved(log);
        }
示例#5
0
        public void AddLog(Guid groupId, LogInfo log)
        {
            var addTo = Logs.Groups
                .First(group => group.Id.Equals(groupId));

            if (addTo.Logs.Any(l => l.Alias.Equals(log.Alias, StringComparison.OrdinalIgnoreCase)))
            {
                Trace.WriteLine($"A log with the alias {log.Alias} already exists in the group {addTo.Name}! Aborting");
                return;
            }

            if (addTo.Logs.Any())
            {
                var highestOrder = addTo.Logs.Max(l => l.Order);
                log.Order = highestOrder + 1;
            }

            addTo.Logs.Add(log);

            SaveState();
            OnLogAdded(log, groupId);
        }
 public void SetTail(string path)
 {
     var logInfo = new LogInfo(path);
     TailFile = new TailFile(logInfo);
 }
示例#7
0
 public LogEventArgs(LogInfo log)
 {
     Log = log;
 }
示例#8
0
 public LogEventArgs(LogInfo log, Guid groupId)
     : this(log)
 {
     GroupId = groupId;
 }
示例#9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TailFile" /> class.
 /// </summary>
 /// <param name="logInfo">The log information.</param>
 public TailFile(LogInfo logInfo)
 {
     LogInfo = logInfo;
     SearchOptions = new SearchOptions(this);
     _displayBuffer = Settings.SeekBuffer * 0x400;
     _cts = new CancellationTokenSource();
     
     OpenMenuItemInExplorerCommand = new OpenMenuItemInExplorerCommand();
     
     BindingOperations.EnableCollectionSynchronization(LogLines, _lockObject);
 }
示例#10
0
 /// <summary>
 /// Adds the log through the LogSource singleton.
 /// </summary>
 /// <param name="log">The log.</param>
 public void AddLog(LogInfo log)
 {
     LogSource.Instance.AddLog(Id, log);
 }