private void ribbonStyleButton1_Click(object sender, EventArgs e) { int lastIndex = 0; for (int i = 0; i < gridColumns.Rows.Count; i++) { var row = gridColumns.Rows[i]; var colName = (string)row.Cells[1].Value; if (colName.StartsWith("NOTE_TEXT")) { colName = colName.Replace("NOTE_TEXT", "0"); if (lastIndex < Int32.Parse(colName)) { lastIndex = Int32.Parse(colName); } } } lastIndex++; TabSetting newRow = new TabSetting(); newRow.Index = lastIndex; newRow.Order = gridColumns.Rows.Count + 1; newRow.ColumnName = "NOTE_TEXT" + lastIndex; newRow.DisplayName = "Document " + (lastIndex + 1); newRow.Visible = true; newRow.Dynamic = true; newRow.Score = true; var index = gridColumns.Rows.Add(newRow.Visible, newRow.ColumnName, newRow.DisplayName, newRow.Score); gridColumns.Rows[index].Tag = newRow; }
protected void AddViewTab(string tabName, DocumentViewType viewType) { int lastIndex = 0; foreach (var setting in _views.TabSettings) { if (lastIndex < setting.Index) { lastIndex = setting.Index; } } lastIndex++; TabSetting tabSetting = new TabSetting(); tabSetting.DisplayName = tabName; tabSetting.ColumnName = "NOTE_TEXT" + lastIndex.ToString(); tabSetting.Dynamic = true; tabSetting.Order = _views.TabSettings.Count + 1; tabSetting.Index = lastIndex; tabSetting.Visible = true; tabSetting.TabType = viewType; _views.TabSettings.Add(tabSetting); AddNewColumn(tabSetting); _views.DocumentsService.SetDocumentColumnSettings(_views.TabSettings); _tabPages.Add(AddNewTab(tabSetting)); RefreshTabs(); }
protected void AddNewColumn(TabSetting setting) { var newColumn = _views.MainForm.adapterDocuments.AddDynamicColumn(setting.ColumnName, DynamicColumnType.FreeText, true); var newColumnReviewML = _views.MainForm.adapterReviewMLDocumentsNew.AddDynamicColumn(setting.ColumnName, DynamicColumnType.FreeText, false); var order = _views.MainForm.datasetMain.DynamicColumns.Count(x => x.RowState != DataRowState.Deleted) + 1; _views.MainForm.adapterDynamicColumns.Insert(setting.ColumnName, (int)DynamicColumnType.FreeText, order, String.Empty); _views.MainForm.adapterDynamicColumns.Fill(_views.MainForm.datasetMain.DynamicColumns); }
protected void AddBrowserTab(string tabName, string columnName) { TabSetting tabSetting = new TabSetting(); tabSetting.DisplayName = tabName; tabSetting.ColumnName = columnName; tabSetting.Dynamic = false; tabSetting.Order = _views.TabSettings.Count + 1; tabSetting.Index = -1; tabSetting.Visible = true; tabSetting.TabType = DocumentViewType.Browser; _views.TabSettings.Add(tabSetting); _views.DocumentsService.SetDocumentColumnSettings(_views.TabSettings); _tabPages.Add(AddNewTab(tabSetting)); RefreshTabs(); }
public TabPage AddNewTab(TabSetting tabSetting) { TabPage tabPage = new TabPage(); tabPage.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(191)))), ((int)(((byte)(219)))), ((int)(((byte)(255))))); tabPage.Location = new System.Drawing.Point(4, 25); tabPage.Margin = new System.Windows.Forms.Padding(0); tabPage.Name = tabSetting.ColumnName; tabPage.Size = new System.Drawing.Size(940, 820); //tabPage.TabIndex = tabSetting.Index; tabPage.Text = tabSetting.DisplayName; tabPage.Tag = tabSetting; if (tabSetting.TabType == DocumentViewType.Normal) { PaneColumnNotes paneNotes = new PaneColumnNotes(tabSetting.ColumnName); paneNotes.InitPane(_views, _ownerView, _panel, _tab); paneNotes._eventDataModified += new EventHandler(OnDataModified); paneNotes.CalcScores += new EventHandler(paneTabs_CalcScores); paneNotes.RefreshHighlights += new EventHandler(paneTabs_RefreshHighlights); paneNotes.SortTabs += new EventHandler(onTabs_Clicked); paneNotes.AddBrowserTab += new EventHandler(onAddBrowserTab_Clicked); paneNotes.AddViewTab += new EventHandler(onAddViewTab_Clicked); //_splitter.Panel2.Controls.Add(_paneNotes); paneNotes.ShowPane(); //_paneNotesList.Add(paneNotes); tabPage.Controls.Add(paneNotes); } else if (tabSetting.TabType == DocumentViewType.Browser) { PaneBrowser paneBrowser = new PaneBrowser(tabSetting.ColumnName); paneBrowser.InitPane(_views, _ownerView, _panel, _tab); paneBrowser.SortTabs += new EventHandler(this.onTabs_Clicked); paneBrowser.AddBrowserTab += new EventHandler(this.onAddBrowserTab_Clicked); paneBrowser.AddViewTab += new EventHandler(this.onAddViewTab_Clicked); paneBrowser.ShowPane(); tabPage.Controls.Add(paneBrowser); } else { PaneNoteHtmlView paneHtmlView = new PaneNoteHtmlView(tabSetting.ColumnName, tabSetting.TabType); paneHtmlView.InitPane(_views, _ownerView, _panel, _tab); paneHtmlView._eventDataModified += new EventHandler(OnDataModified); paneHtmlView.SortTabs += new EventHandler(onTabs_Clicked); paneHtmlView.AddBrowserTab += new EventHandler(onAddBrowserTab_Clicked); paneHtmlView.AddViewTab += new EventHandler(onAddViewTab_Clicked); //_splitter.Panel2.Controls.Add(_paneNotes); paneHtmlView.ShowPane(); //_extraPaneNotesList.Add(paneHtmlView.GetDebugPaneColumnNotes()); tabPage.Controls.Add(paneHtmlView); } return(tabPage); }
protected void GetDocumentColumnSettings() { List <TabSetting> columnSettings = new List <TabSetting>(); _noteColumnCount = 0; var cmd = _connection.CreateCommand(); cmd.CommandText = "SELECT * FROM Documents"; var reader = cmd.ExecuteReader(CommandBehavior.SchemaOnly); DataTable table = reader.GetSchemaTable(); var nameCol = table.Columns["ColumnName"]; foreach (DataRow row in table.Rows) { if (row[nameCol].ToString().StartsWith("NOTE_TEXT")) { var noteIndex = Int32.Parse(row[nameCol].ToString().Replace("NOTE_TEXT", "0")); TabSetting setting = new TabSetting(); setting.ColumnName = row[nameCol].ToString(); setting.DisplayName = "Document " + (noteIndex + 1).ToString(); setting.Visible = true; setting.Index = noteIndex; setting.Order = -1; setting.Dynamic = IsColumnDynamic(setting.ColumnName); setting.TabType = DocumentViewType.Normal; setting.Score = false; columnSettings.Add(setting); _noteColumnCount++; } if (row[nameCol].ToString().StartsWith("NOTE_ENTITIES")) { TabSetting setting = new TabSetting(); setting.ColumnName = row[nameCol].ToString(); setting.DisplayName = "Document Entities"; setting.Visible = false; setting.Index = -1; setting.Order = -1; setting.Dynamic = false; setting.TabType = DocumentViewType.Html_SpaCyEntityView; setting.Score = false; columnSettings.Add(setting); } Console.WriteLine(row[nameCol]); } foreach (DataRow row1 in table.Rows) { if (row1[nameCol].ToString().StartsWith("Score")) { var index = Int32.Parse(row1[nameCol].ToString().Replace("Score", "0")); var srchResult = columnSettings.Find(x => x.Index == index); srchResult.Score = true; } } if (_noteColumnCount == 1) { columnSettings[0].DisplayName = "Document"; } int namedColumnCount = 0; try { var cmdNameRead = _connection.CreateCommand(); cmdNameRead.CommandText = "SELECT DocumentColumn, Name, Order, TabType FROM DocumentColumnNames"; using (reader = cmdNameRead.ExecuteReader()) { while (reader.Read()) { string documentColumn = reader.GetString(0); string Name = reader.GetString(1); int order = reader.GetInt32(2); DocumentViewType type = (DocumentViewType)reader.GetInt32(3); if (documentColumn.StartsWith("NOTE_TEXT") || documentColumn.StartsWith("NOTE_ENTITIES")) { var itemResult = columnSettings.Find(x => x.ColumnName == documentColumn); if (itemResult != null) { itemResult.DisplayName = Name; itemResult.Order = order; if (order == 0) { itemResult.Visible = false; } else { itemResult.Visible = true; } itemResult.TabType = type; namedColumnCount++; } } else { TabSetting setting = new TabSetting(); setting.ColumnName = documentColumn; setting.DisplayName = Name; setting.Visible = true; setting.Index = -1; setting.Order = order; setting.Dynamic = false; setting.TabType = DocumentViewType.Browser; setting.Score = false; columnSettings.Add(setting); } } } } catch (Exception e) { Console.WriteLine("GetDocumentColumnNames: " + e.Message); } finally { int max_ordernum = 1; for (int i = 0; i < _noteColumnCount; i++) { if (max_ordernum < columnSettings[i].Order) { max_ordernum = columnSettings[i].Order; } } for (int i = 0; i < _noteColumnCount; i++) { if (columnSettings[i].Order == -1) { columnSettings[i].Order = ++max_ordernum; } } TabSettingCompare gg = new TabSettingCompare(); columnSettings.Sort(gg); if (namedColumnCount < _noteColumnCount) { SetDocumentColumnSettings(columnSettings, true); } SendResponse(new IpcResponse { ResponseType = IpcResponseType.Success, DocumentColumnSettings = columnSettings, }); } }