示例#1
0
 void CopyMarkedLinesToClipboard()
 {
     if (_guiStateArgs.CellSelectMode)
     {
         DataObject data = dataGridView.GetClipboardContent();
         Clipboard.SetDataObject(data);
     }
     else
     {
         List<int> lineNumList = new List<int>();
         foreach (DataGridViewRow row in dataGridView.SelectedRows)
         {
             if (row.Index != -1)
             {
                 lineNumList.Add(row.Index);
             }
         }
         lineNumList.Sort();
         StringBuilder clipText = new StringBuilder();
         LogExpertCallback callback = new LogExpertCallback(this);
         foreach (int lineNum in lineNumList)
         {
             string line = CurrentLogFileReader.GetLogLine(lineNum);
             if (CurrentColumnizer is ILogLineXmlColumnizer)
             {
                 callback.LineNum = lineNum;
                 line = (CurrentColumnizer as ILogLineXmlColumnizer).GetLineTextForClipboard(line, callback);
             }
             clipText.AppendLine(line);
         }
         Clipboard.SetText(clipText.ToString());
     }
 }
示例#2
0
 void LaunchHighlightPlugins(IList<HilightEntry> matchingList, int lineNum)
 {
     LogExpertCallback callback = new LogExpertCallback(this);
     callback.LineNum = lineNum;
     foreach (HilightEntry entry in matchingList)
     {
         if (entry.IsActionEntry && entry.ActionEntry.pluginName != null)
         {
             IKeywordAction plugin = PluginRegistry.GetInstance().FindKeywordActionPluginByName(entry.ActionEntry.pluginName);
             if (plugin != null)
             {
                 Action<string, string, ILogExpertCallback, ILogLineColumnizer> fx = new Action<string, string, ILogExpertCallback, ILogLineColumnizer>(plugin.Execute);
                 fx.BeginInvoke(entry.SearchText, entry.ActionEntry.actionParam, callback, CurrentColumnizer, null, null);
             }
         }
     }
 }
示例#3
0
        void WritePipeToTab(FilterPipe pipe, IList<int> lineNumberList, string name, PersistenceData persistenceData)
        {
            Logger.logInfo("WritePipeToTab(): " + lineNumberList.Count + " lines.");
            _guiStateArgs.MenuEnabled = false;
            SendGuiStateUpdate();

            StartProgressBar(lineNumberList.Count, "Writing to temp file... Press ESC to cancel.");

            _isSearching = true;
            _shouldCancel = false;

            lock (_filterPipeList)
            {
                _filterPipeList.Add(pipe);
            }
            pipe.Closed += new FilterPipe.ClosedEventHandler(Pipe_Disconnected);
            int count = 0;
            pipe.OpenFile();
            LogExpertCallback callback = new LogExpertCallback(this);
            foreach (int i in lineNumberList)
            {
                if (_shouldCancel)
                {
                    break;
                }
                string line = CurrentLogFileReader.GetLogLine(i);
                if (CurrentColumnizer is ILogLineXmlColumnizer)
                {
                    callback.LineNum = i;
                    line = (CurrentColumnizer as ILogLineXmlColumnizer).GetLineTextForClipboard(line, callback);
                }
                pipe.WriteToPipe(line, i);
                if (++count % PROGRESS_BAR_MODULO == 0)
                {
                    _progressEventArgs.Value = count;
                    Invoke(new MethodInvoker(SendProgressBarUpdate));
                }
            }
            pipe.CloseFile();
            Logger.logInfo("WritePipeToTab(): finished");
            Invoke(new Action<FilterPipe, string, PersistenceData>(WriteFilterToTabFinished), new object[] { pipe, name, persistenceData });
        }
示例#4
0
        void DataGridContextMenuStrip_Opening(object sender, CancelEventArgs e)
        {
            int lineNum = -1;
            if (dataGridView.CurrentRow != null)
            {
                lineNum = dataGridView.CurrentRow.Index;
            }
            if (lineNum == -1)
            {
                return;
            }
            int refLineNum = lineNum;

            copyToTabToolStripMenuItem.Enabled = dataGridView.SelectedCells.Count > 0;
            scrollAllTabsToTimestampToolStripMenuItem.Enabled = CurrentColumnizer.IsTimeshiftImplemented() &&
            GetTimestampForLine(ref refLineNum, false) != DateTime.MinValue;
            locateLineInOriginalFileToolStripMenuItem.Enabled = IsTempFile &&
            FilterPipe != null &&
            FilterPipe.GetOriginalLineNum(lineNum) != -1;
            markEditModeToolStripMenuItem.Enabled = !dataGridView.CurrentCell.ReadOnly;

            // Remove all "old" plugin entries
            int index = dataGridContextMenuStrip.Items.IndexOf(pluginSeparator);
            if (index > 0)
            {
                for (int i = index + 1; i < dataGridContextMenuStrip.Items.Count;)
                {
                    dataGridContextMenuStrip.Items.RemoveAt(i);
                }
            }

            // Add plugin entries
            bool isAdded = false;
            if (PluginRegistry.GetInstance().RegisteredContextMenuPlugins.Count > 0)
            {
                IList<int> lines = GetSelectedContent();
                foreach (IContextMenuEntry entry in PluginRegistry.GetInstance().RegisteredContextMenuPlugins)
                {
                    LogExpertCallback callback = new LogExpertCallback(this);
                    ContextMenuPluginEventArgs evArgs = new ContextMenuPluginEventArgs(entry, lines, CurrentColumnizer, callback);
                    EventHandler ev = new EventHandler(HandlePluginContextMenu);
                    string menuText = entry.GetMenuText(lines, CurrentColumnizer, callback);
                    if (menuText != null)
                    {
                        bool disabled = menuText.StartsWith("_");
                        if (disabled)
                        {
                            menuText = menuText.Substring(1);
                        }
                        ToolStripItem item = dataGridContextMenuStrip.Items.Add(menuText, null, ev);
                        item.Tag = evArgs;
                        item.Enabled = !disabled;
                        isAdded = true;
                    }
                }
            }
            pluginSeparator.Visible = isAdded;

            // enable/disable Temp Highlight item
            tempHighlightsToolStripMenuItem.Enabled = _tempHilightEntryList.Count > 0;

            markCurrentFilterRangeToolStripMenuItem.Enabled = filterRangeComboBox.Text != null && filterRangeComboBox.Text.Length > 0;

            if (CurrentColumnizer.IsTimeshiftImplemented())
            {
                IList<WindowFileEntry> list = _parentLogTabWin.GetListOfOpenFiles();
                syncTimestampsToToolStripMenuItem.Enabled = true;
                syncTimestampsToToolStripMenuItem.DropDownItems.Clear();
                EventHandler ev = new EventHandler(HandleSyncContextMenu);
                Font italicFont = new Font(syncTimestampsToToolStripMenuItem.Font.FontFamily, syncTimestampsToToolStripMenuItem.Font.Size, FontStyle.Italic);
                foreach (WindowFileEntry fileEntry in list)
                {
                    if (fileEntry.LogWindow != this)
                    {
                        ToolStripMenuItem item = syncTimestampsToToolStripMenuItem.DropDownItems.Add(fileEntry.Title, null, ev) as ToolStripMenuItem;
                        item.Tag = fileEntry;
                        item.Checked = TimeSyncList != null && TimeSyncList.Contains(fileEntry.LogWindow);
                        if (fileEntry.LogWindow.TimeSyncList != null && !fileEntry.LogWindow.TimeSyncList.Contains(this))
                        {
                            item.Font = italicFont;
                            item.ForeColor = Color.Blue;
                        }
                        item.Enabled = fileEntry.LogWindow.CurrentColumnizer.IsTimeshiftImplemented();
                    }
                }
            }
            else
            {
                syncTimestampsToToolStripMenuItem.Enabled = false;
            }
            freeThisWindowFromTimeSyncToolStripMenuItem.Enabled = TimeSyncList != null && TimeSyncList.Count > 1;
        }