This commit is contained in:
Jsj
2008-05-16 18:13:12 +00:00
parent 8ba64060e2
commit af04fa6ef6
16 changed files with 1240 additions and 595 deletions

View File

@@ -106,15 +106,13 @@ namespace VEPROMS
private void SetupAnnotations()
{
cbAnnoType.DataSource = AnnotationTypeInfoList.Get();
cbAnnoType.DisplayMember = "Name";
cbAnnoType.DataSource = AnnotationTypeInfoList.Get();
lbResults.MouseMove += new MouseEventHandler(lbResults_MouseMove);
//comboBox1.DataSource = AnnotationTypeInfo.AllList(); //AnnotationType.AllTypes();
////comboBox1.DataSource = AnnotationTypeInfoList.Get();
//comboBox1.DisplayMember = "_Name";
foreach (AnnotationTypeInfo item in cbAnnoType.Items)
cbGridAnnoType.Items.Add(item);
c1AnnotationGrid.Cols[0].Editor = cbGridAnnoType;
cbGridAnnoType.DisplayMember = "Name";
cbGridAnnoType.ValueMember = "TypeId";
cbGridAnnoType.DataSource = AnnotationTypeInfoList.Get().Clone();
}
#region MRU
@@ -221,7 +219,7 @@ namespace VEPROMS
tc.OpenItem((ItemInfo)_LastProcedureInfo);
// Display any annotations
itemAnnotationsBindingSource.DataSource = _LastProcedureInfo.ItemAnnotations;
//itemAnnotationsBindingSource.DataSource = _LastProcedureInfo.ItemAnnotations;
}
else if (node.VEObject.GetType() == typeof(SectionInfo))
{
@@ -229,7 +227,7 @@ namespace VEPROMS
_LastSection = _LastSectionInfo.Get();
tc.OpenItem((ItemInfo)_LastSectionInfo);
// Display any annotations
itemAnnotationsBindingSource.DataSource = _LastSectionInfo.ItemAnnotations;
//itemAnnotationsBindingSource.DataSource = _LastSectionInfo.ItemAnnotations;
}
else if (node.VEObject.GetType() == typeof(StepInfo))
{
@@ -237,7 +235,7 @@ namespace VEPROMS
_LastStep = _LastStepInfo.Get();
tc.OpenItem((ItemInfo)_LastStepInfo);
// Display any annotations
itemAnnotationsBindingSource.DataSource = _LastStepInfo.ItemAnnotations;
//itemAnnotationsBindingSource.DataSource = _LastStepInfo.ItemAnnotations;
#region Sample Display Table Code
// display an exiting table in that rtf grid thing
//if ((_LastStepInfo.MyContent.Type == 20007) || (_LastStepInfo.MyContent.Type == 20009))
@@ -813,8 +811,8 @@ namespace VEPROMS
private void RefreshBookMarkData()
{
lbxBookMarks.DataSource = null;
lbxBookMarks.DataSource = _MyBookMarks;
lbxBookMarks.DisplayMember = "MenuTitle";
lbxBookMarks.DataSource = _MyBookMarks;
btnClrBookMrks.Enabled = (lbxBookMarks.Items.Count > 0);
}
@@ -1153,81 +1151,182 @@ namespace VEPROMS
displayTransition.CurTrans = null;
}
#endregion
private void tc_ItemSelectedChanged(object sender, StepPanelEventArgs args)
private AnnotationInfoList _Annotations;
private ItemInfo _CurrentItem = null;
private void tc_ItemSelectedChanged(object sender,ItemSelectedChangedEventArgs args)
{
//CurrentAnnotation = null;
if (args == null)
itemAnnotationsBindingSource.DataSource = null;
{
_CurrentItem = null;
CurrentAnnotation = null;
_Annotations = null;
itemAnnotationsBindingSource.DataSource = _Annotations;
AnnotationPanelView();
return;
}
if (_CurrentItem != args.MyItemInfo)
_CurrentItem = args.MyItemInfo; //tc.SelectedDisplayTabItem.MyItemInfo;
vlnStackTrace.ShowStack("enter tc_ItemSelectedChanged {0}",_CurrentItem);
if (args.MyStepItem == null)
{
//itemAnnotationsBindingSource.DataSource = null;
//_Annotations = null;
//UpdateAnnotationGrid();
//_CurrentItem = args.MyItemInfo; //tc.SelectedDisplayTabItem.MyItemInfo;
//vlnStackTrace.ShowStack("enter tc_ItemSelectedChanged {0}", _CurrentItem);
}
else
{
itemAnnotationsBindingSource.DataSource = args.MyStepItem.MyItemInfo.ItemAnnotations;
StepTabPanel dtp = ((DisplayTabItem)tc.SelectedDisplayTabItem).MyStepTabPanel;
if (dtp == null) return;
displayTransition.MyRTB = dtp.MyStepPanel.SelectedStepRTB;
displayRO.MyRTB = dtp.MyStepPanel.SelectedStepItem.MyStepRTB;
//_CurrentItem = args.MyItemInfo;
//vlnStackTrace.ShowStack("enter tc_ItemSelectedChanged {0}", _CurrentItem);
//UpdateAnnotationGrid();
//StepTabPanel dtp = ((DisplayTabItem)tc.SelectedDisplayTabItem).MyStepTabPanel;
//if (dtp == null) return;
//displayTransition.MyRTB = dtp.MyStepPanel.SelectedStepRTB;
//displayRO.MyRTB = dtp.MyStepPanel.SelectedStepItem.MyStepRTB;
displayTransition.MyRTB = args.MyStepItem.MyStepRTB;
displayRO.MyRTB = args.MyStepItem.MyStepRTB;
}
UpdateAnnotationGrid();
}
private void itemAnnotationsBindingSource_DataSourceChanged(object sender, EventArgs e)
private void UpdateAnnotationGrid()
{
AnnotationInfoList myAnnotations = itemAnnotationsBindingSource.DataSource as AnnotationInfoList;
AnnotationPannelView(myAnnotations);
}
private void AnnotationPannelView(AnnotationInfoList ail)
{
int selectedAnnoID = -1;
int selectedAnno = 0;
if (ail != null && ail.Count != 0)
//ShowItemAnnotations("UpdateAnnotationGrid before RefreshItemAnnotations");
//_CurrentItem.RefreshItemAnnotations();
//ShowItemAnnotations("UpdateAnnotationGrid");
_LoadingGrid = true;
_Annotations = _CurrentItem.ItemAnnotations;
itemAnnotationsBindingSource.DataSource = _Annotations;
AnnotationPanelView();
if ((CurrentAnnotation == null || (_CurrentItem.ItemID != CurrentAnnotation.ItemID)))
{
if (!cbAnnotationDontPopup.Checked)
if (_Annotations != null && _Annotations.Count > 0)
CurrentAnnotation = _Annotations[0];
else
CurrentAnnotation = null;
//InitializeAnnotation();
}
FindCurrentAnnotation();
_LoadingGrid = false;
}
private void FindCurrentAnnotation()
{
int row = 0;
if (CurrentAnnotation != null)
{
if (_Annotations != null)
{
foreach (AnnotationInfo ai in _Annotations)
{
if (ai.AnnotationID == CurrentAnnotation.AnnotationID)
{
row = _Annotations.IndexOf(ai) + 1;
break;
}
}
}
}
Console.WriteLine("Row = {0}",row);
c1AnnotationGrid.Select(row, 0, true);
}
//private void ShowItemAnnotations(string title)
//{
// Console.WriteLine("{0} CurrentItem {1} {2} ItemAnnotationsCount {3}", title, _CurrentItem.ItemID, _CurrentItem.MyItemInfoUnique, _CurrentItem.ItemAnnotationCount);
//}
//private void itemAnnotationsBindingSource_DataSourceChanged(object sender, EventArgs e)
//{
//_LoadingGrid = true;
//Console.WriteLine("itemAnnotationsBindingSource_DataSourceChanged 1");
//AnnotationInfoList myAnnotations = itemAnnotationsBindingSource.DataSource as AnnotationInfoList;
//Console.WriteLine("itemAnnotationsBindingSource_DataSourceChanged 2");
//AnnotationPannelView(_Annotations);
//Console.WriteLine("itemAnnotationsBindingSource_DataSourceChanged 3");
//_LoadingGrid = false;
//}
private void AnnotationPanelView()
{
if (_Annotations != null && _Annotations.Count != 0)
{
if (Settings.Default.AutoPopUpAnnotations) //cbAnnotationPopup.Checked
epAnnotations.Expanded = true;
else
epAnnotations.TitleStyle.BackColor1.Color = Color.Yellow;
if (lbResults != null && lbResults.SelectedIndex > -1)
{
selectedAnnoID = ((AnnotationInfo)lbResults.SelectedItem).AnnotationID;
foreach (AnnotationInfo ai in ail)
{
if (ai.AnnotationID != selectedAnnoID)
selectedAnno++;
else
break;
}
if (selectedAnno >= ail.Count)
selectedAnno = 0;
}
//rtxbComment.Text = ail[0].SearchText;
rtxbComment.Text = ail[selectedAnno].SearchText;
if (epAnnotations.Expanded)
{
//epAnnotations.PerformClick();
//epAnnotations.SelectNextControl(rtxbComment, false, false, false, false);
//rtxbComment.Focus();
//c1AnnotationGrid.SelectionMode = C1.Win.C1FlexGrid.SelectionModeEnum.Cell;
c1AnnotationGrid.Focus();
//c1AnnotationGrid.Select();
//C1.Win.C1FlexGrid.CellRange cr = c1AnnotationGrid.GetCellRange(selectedAnno, 3);
//c1AnnotationGrid.Select(cr, true);
//c1AnnotationGrid.Controls[3].Select();
//c1AnnotationGrid.ShowCell(selectedAnno+1,3);
//SendKeys.Flush();
c1AnnotationGrid.Select(selectedAnno + 1, 3, true);
//c1AnnotationGrid.AccessibilityObject.Select(AccessibleSelection.TakeFocus);
//SendKeys.Send("{RIGHT}");
//SendKeys.Flush();
rtxbComment.Focus();
}
rtxbComment.SelectionStart = rtxbComment.TextLength;
}
else
{
if (!cbAnnotationDontPopup.Checked)
epAnnotations.Expanded = false;
epAnnotations.Expanded = false;
epAnnotations.TitleStyle.BackColor1.Color = _CommentTitleBckColor;
rtxbComment.Text = null;
}
}
private AnnotationInfo _CurrentAnnotation = null;
private AnnotationInfo CurrentAnnotation
{
get { return _CurrentAnnotation; }
set
{
if (_CurrentAnnotation == null && value == null) return; // No Change
if (_CurrentAnnotation != null && value != null)
if (_CurrentAnnotation.AnnotationID == value.AnnotationID) return; // No Change
vlnStackTrace.ShowStack("CurrentAnnotation = '{0}' Old = '{1}'", value, _CurrentAnnotation);
if (_CurrentAnnotation != null || _AddingAnnotation)
{
//if (_CurrentAnnotation.TypeID != (int)cbGridAnnoType.SelectedValue) SaveAnnotation();
//else if (_CurrentAnnotation.RtfText != string.Empty && _CurrentAnnotation.RtfText != rtxbComment.Rtf)
// SaveAnnotation();
//else if (_CurrentAnnotation.RtfText == string.Empty && _CurrentAnnotation.SearchText != rtxbComment.Text)
if (AnnotationDirty)
SaveAnnotation();
}
_CurrentAnnotation = value;
InitializeAnnotation();
}
}
private void SaveAnnotation()
{
if (cbGridAnnoType.SelectedIndex == -1) return;
if (rtxbComment.Text == string.Empty) return;
using (AnnotationType annotationType = AnnotationType.Get((int)cbGridAnnoType.SelectedValue))
{
if (_AddingAnnotation)
{
_AddingAnnotation = false;
using (Item myItem = _CurrentItem.Get())
{
using (Annotation annotation = Annotation.MakeAnnotation(myItem, annotationType, rtxbComment.Rtf, rtxbComment.Text, ""))
{
CurrentAnnotation = AnnotationInfo.Get(annotation.AnnotationID);
annotation.DTS = DateTime.Now;
annotation.Save();
}
}
}
else
{
using (Annotation annotation = CurrentAnnotation.Get())
{
annotation.RtfText = rtxbComment.Rtf;
annotation.SearchText = rtxbComment.Text;
annotation.MyAnnotationType = annotationType;
annotation.DTS = DateTime.Now;
//Console.WriteLine("Before Annotation Type = {0} ({1})", CurrentAnnotation.MyAnnotationType, CurrentAnnotation.MyAnnotationType.AnnotationTypeAnnotations.Count);
//Console.WriteLine("Before Annotation Type = {0}", CurrentAnnotation.MyAnnotationType);
annotation.Save();
//Console.WriteLine("After Annotation Type = {0} ({1})", CurrentAnnotation.MyAnnotationType, CurrentAnnotation.MyAnnotationType.AnnotationTypeAnnotations.Count);
}
}
}
AnnotationDirty = false;
UpdateAnnotationGrid();
//UpdateAnnotationSearchResults();
}
private void btnSave_Click(object sender, EventArgs e)
{
@@ -1282,11 +1381,16 @@ namespace VEPROMS
private bool _LoadingList = false;
private void cbAnnoType_SelectedValueChanged(object sender, EventArgs e)
{
UpdateAnnotationSearchResults();
}
private void UpdateAnnotationSearchResults()
{
AnnotationTypeInfo ati = cbAnnoType.SelectedValue as AnnotationTypeInfo;
_LoadingList = true;
lbResults.DataSource = ati.AnnotationTypeAnnotations;
lbResults.DisplayMember = "SearchText";
lbResults.DataSource = ati.AnnotationTypeAnnotations;
lbResults.SelectedIndex = -1;
LastResultsMouseOverIndex = -1;
_LoadingList = false;
@@ -1304,61 +1408,181 @@ namespace VEPROMS
LastResultsMouseOverIndex = ResultsMouseOverIndex;
}
}
private void lbResults_SelectedValueChanged(object sender, EventArgs e)
{
if (!_LoadingList)
{
AnnotationInfo ai = lbResults.SelectedValue as AnnotationInfo;
tc.OpenItem(ai.MyItem);
//AnnotationInfo ai = lbResults.SelectedValue as AnnotationInfo;
//if(ai != null)
// tc.OpenItem(ai.MyItem);
CurrentAnnotation = lbResults.SelectedValue as AnnotationInfo;
if (CurrentAnnotation != null)
{
tc.OpenItem(CurrentAnnotation.MyItem);
}
FindCurrentAnnotation();
}
}
private void lbxBookMarks_Click(object sender, EventArgs e)
{
MostRecentItem itm = lbxBookMarks.SelectedValue as MostRecentItem;
tc.OpenItem(itm.MyItemInfo);
}
private void cbGridAnnoType_Validating(object sender, CancelEventArgs e)
{
try
{
//bool test1 = c1AnnotationGrid.IsCellSelected(c1AnnotationGrid.RowSel, c1AnnotationGrid.ColSel);
//bool test2 = c1AnnotationGrid.IsCellValid(c1AnnotationGrid.RowSel, c1AnnotationGrid.ColSel);
//AnnotationTypeInfo celldat = (AnnotationTypeInfo)c1AnnotationGrid.GetData(c1AnnotationGrid.RowSel, c1AnnotationGrid.ColSel);
AnnotationTypeInfo newcelldat = (AnnotationTypeInfo)cbGridAnnoType.SelectedItem;
AnnotationInfo ani = ((AnnotationInfoList)itemAnnotationsBindingSource.DataSource)[c1AnnotationGrid.RowSel - 1] as AnnotationInfo;
Annotation ano = ani.Get();
if (ano.TypeID != newcelldat.TypeID)
{
ano.Update(newcelldat.TypeID);
btnSaveAnnoation.Enabled = true;
c1AnnotationGrid.Refresh();
}
}
catch (Exception ex)
{
log.ErrorFormat("Error saving Annotation Type Change: {0}", ex.Message);
}
//try
//{
// //bool test1 = c1AnnotationGrid.IsCellSelected(c1AnnotationGrid.RowSel, c1AnnotationGrid.ColSel);
// //bool test2 = c1AnnotationGrid.IsCellValid(c1AnnotationGrid.RowSel, c1AnnotationGrid.ColSel);
// //AnnotationTypeInfo celldat = (AnnotationTypeInfo)c1AnnotationGrid.GetData(c1AnnotationGrid.RowSel, c1AnnotationGrid.ColSel);
// AnnotationTypeInfo newcelldat = (AnnotationTypeInfo)cbGridAnnoType.SelectedItem;
// AnnotationInfo ani = ((AnnotationInfoList)itemAnnotationsBindingSource.DataSource)[c1AnnotationGrid.RowSel - 1] as AnnotationInfo;
// Annotation ano = ani.Get();
// if (ano.TypeID != newcelldat.TypeID)
// {
// ano.Update(newcelldat.TypeID);
// //btnCancelAnnoation.Enabled = true;
// c1AnnotationGrid.Refresh();
// }
//}
//catch (Exception ex)
//{
// log.ErrorFormat("Error saving Annotation Type Change: {0}", ex.Message);
//}
}
private void epAnnotations_Layout(object sender, LayoutEventArgs e)
{
cbGridAnnoType.Visible = false;
//cbGridAnnoType.Visible = false;
}
//private void btnSaveAnnoation_Click(object sender, EventArgs e)
//{
// AnnotationInfoList ail = (AnnotationInfoList)itemAnnotationsBindingSource.DataSource;
// foreach (AnnotationInfo ai in ail)
// {
// Annotation ano = ai.Get();
// ano.CommitChanges();
// }
// btnCancelAnnoation.Enabled = false;
//}
private bool _AddingAnnotation = false;
private void btnAddAnnotation_Click(object sender, EventArgs e)
{
c1AnnotationGrid.Row = -1;
CurrentAnnotation = null;
_AddingAnnotation = true;
//InitializeAnnotation();
}
private bool _LoadingAnnotation = false;
private bool _LoadingGrid = false;
private void c1AnnotationGrid_EnterCell(object sender, EventArgs e)
{
if (!_LoadingGrid) // Only set the Current Annotation when not loading the grid
{
if ((_Annotations != null) && (c1AnnotationGrid.Row > 0))
CurrentAnnotation = _Annotations[c1AnnotationGrid.Row - 1];
else
CurrentAnnotation = null;
}
//InitializeAnnotation();
}
private void InitializeAnnotation()
{
//vlnCSLAStackTrace.ShowStack("InitializeAnnotation - CurrentAnnotation = {0}", CurrentAnnotation);
_LoadingAnnotation = true;
if (CurrentAnnotation == null)
{
cbGridAnnoType.SelectedIndex = -1;
rtxbComment.Text = "";
}
else
{
cbGridAnnoType.SelectedValue = CurrentAnnotation.TypeID;
if (CurrentAnnotation.RtfText != "")
rtxbComment.Rtf = CurrentAnnotation.RtfText;
else
rtxbComment.Text = CurrentAnnotation.SearchText;
}
_LoadingAnnotation = false;
AnnotationDirty = false;
if (!_LoadingGrid)
{
rtxbComment.SelectionStart = rtxbComment.TextLength; // Position the cursor at the end of the current text
rtxbComment.Focus(); // Set the focus to the comment text
}
}
private bool _AnnotationDirty = false;
private bool AnnotationDirty
{
get { return _AnnotationDirty; }
set
{
btnRemoveAnnotation.Enabled = btnAddAnnotation.Enabled = !value;
btnSaveAnnotation.Enabled = btnCancelAnnoation.Enabled = value;
_AddingAnnotation = value && (CurrentAnnotation == null);
_AnnotationDirty = value;
}
}
private void buttonX1_Click(object sender, EventArgs e)
private void rtxbComment_TextChanged(object sender, EventArgs e)
{
AnnotationInfoList ail = (AnnotationInfoList)itemAnnotationsBindingSource.DataSource;
foreach (AnnotationInfo ai in ail)
if (!_LoadingAnnotation)
{
Annotation ano = ai.Get();
ano.CommitChanges();
AnnotationDirty = true;
}
}
private void btnCancelAnnoation_Click(object sender, EventArgs e)
{
InitializeAnnotation();
}
private void cbGridAnnoType_SelectedValueChanged(object sender, EventArgs e)
{
if (!_LoadingAnnotation)
{
AnnotationDirty = true;
}
}
private void btnSaveAnnotation_Click(object sender, EventArgs e)
{
if (cbGridAnnoType.SelectedIndex == -1)
{
MessageBox.Show("You Must Select an Annotation Type", "Annotation Type Not Selected", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
cbGridAnnoType.Focus();
return;
}
if (rtxbComment.Text == string.Empty)
{
MessageBox.Show("You Must Enter Annotation Text", "Annotation Text Is Blank", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
rtxbComment.Focus();
return;
}
SaveAnnotation();
}
private void btnRemoveAnnotation_Click(object sender, EventArgs e)
{
using (Annotation annotation = CurrentAnnotation.Get())
{
//ShowItemAnnotations("btnRemoveAnnotation_Click Start");
//annotation.DTS = DateTime.Now;
//annotation.Save();
//ShowItemAnnotations("btnRemoveAnnotation_Click After Change Save");
annotation.Delete();
_LoadingList = true;
annotation.Save();
_LoadingList = false;
CurrentAnnotation = null;
//ShowItemAnnotations("btnRemoveAnnotation_Click After Delete Save");
//c1AnnotationGrid.Row = -1;
//ShowItemAnnotations("btnRemoveAnnotation_Click Before Update Grid");
UpdateAnnotationGrid();
//ShowItemAnnotations("After UpdateAnnotationGrid After Update Grid");
UpdateAnnotationSearchResults();
}
btnSaveAnnoation.Enabled = false;
}