4842 lines
205 KiB
C#

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Text;
using System.Data;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Text.RegularExpressions;
using VEPROMS.CSLA.Library;
using Accentra.Controls;
using Volian.Base.Library;
using DevComponents.DotNetBar;
using Microsoft.Win32;
using System.Diagnostics;
using JR.Utils.GUI.Forms;
namespace Volian.Controls.Library
{
public delegate void CellRangeApplyStyle();
public partial class StepTabRibbon : UserControl
{
private static string _SpecifiedVisioPath = null;
public static string SpecifiedVisioPath
{
get { return StepTabRibbon._SpecifiedVisioPath; }
set { StepTabRibbon._SpecifiedVisioPath = value; }
}
private static bool _PastePlainTextSetting = false;
public static bool PastePlainTextSetting
{
get { return _PastePlainTextSetting; }
set { _PastePlainTextSetting = value; }
}
private static bool _PasteNoReturnsSetting = false;
public static bool PasteNoReturnsSetting
{
get { return _PasteNoReturnsSetting; }
set { _PasteNoReturnsSetting = value; }
}
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#region Properties
private bool EnableROEdit;
private VlnFlexGrid MyFlexGrid
{
get
{
if (MyEditItem is GridItem) return (MyEditItem as GridItem).MyFlexGrid;
return null;
}
}
private EditItem _MyEditItem;
public EditItem MyEditItem
{
get { return _MyEditItem; }
set
{
if (_MyEditItem == value) return; // Don't do this if the value is not different
_MyEditItem = value;
SetBtnInsSupInfoVisible();
ToggleTableFontSize(value is GridItem);
if (value != null)
{
(this.Parent as StepTabPanel).MyDisplayTabItem.SetupSecurity(MyItemInfo);
MyStepRTB = value.MyStepRTB;
if (btnInsSupInfo.Visible && btnInsSupInfo.Enabled) btnInsSupInfo.Tag = string.Format("{0} {1}", (int)E_FromTypes.SupInfos, 1040); // use 1040 to flag RNO (40) and special case handling (1000)
if (value is GridItem)
{
ToggleTableDesignButtons(true);
MyFlexGrid_SelChange(this, new EventArgs());
}
}
else
MyStepRTB = null;
//if (rtabChgId.Visible)
// txtBxChgId.Text = (this.Parent as StepTabPanel).MyDisplayTabControl.ChgId;
}
}
public void SetChangeId(string chgid, ItemInfo ii)
{
txtBxChgId.Text = chgid;
rtabChgId.Visible = (ii != null) ? ii.ActiveFormat.PlantFormat.FormatData.ProcData.ChangeBarData.ChangeIds : false;
}
// added jcb 20121221 to support set ro from word doc
private ROFSTLookup MyLookup;
private DocVersionInfo _Mydvi;
public DocVersionInfo Mydvi
{
get
{
if (_Mydvi != null) return _Mydvi;
if (_MyEditItem != null)
{
ItemInfo procInfo = _MyEditItem.MyItemInfo.MyProcedure as ItemInfo;
if (procInfo == null) return null;
_Mydvi = procInfo.ActiveParent as DocVersionInfo;
// added jcb 20121221 to support set ro from word doc
if (_Mydvi.DocVersionAssociations != null && _Mydvi.DocVersionAssociations.Count > 0)
MyLookup = _Mydvi.DocVersionAssociations[0].MyROFst.GetROFSTLookup(_Mydvi);
else
MyLookup = null;
return _Mydvi;
}
return null;
}
}
private ItemInfo MyItemInfo
{
get
{
if(_MyStepRTB != null && _MyStepRTB.MyItemInfo != null) return _MyStepRTB.MyItemInfo;
if(_MyEditItem != null && _MyEditItem.MyItemInfo != null) return _MyEditItem.MyItemInfo;
return null;
}
}
private static UserInfo _MyUserInfo = null;
public static UserInfo MyUserInfo
{
get { return _MyUserInfo; }
set { _MyUserInfo = value; }
}
private static SessionInfo _MySessionInfo;
public static SessionInfo MySessionInfo
{
get { return _MySessionInfo; }
set { _MySessionInfo = value; }
}
private DevComponents.DotNetBar.ButtonItem _DefaultContextMenu;
public void ClearContextMenu()
{
_ContextMenuBar.SetContextMenuEx(_MyStepRTB, null);
}
#region Save ROs from Word Document jcb 20121221
private string MyLookupData;
private Dictionary<string, string> MyAvailableROs;
public void SetContextMenu(object sender)
{
AddEnhancedDocumentMenu(btnCMRtfEdit, sender);
AddWROContext(btnCMRtfEdit);
_ContextMenuBar.SetContextMenuEx(_MyStepRTB, btnCMRtfEdit);
}
public void SetContextMenuImage(ImageItem imgItem)
{
btnCMCut.Enabled = false;
btnCMCopy.Enabled = false;
btnCMPaste.Enabled = false;
btnCMPasteText.Enabled = false;
btnCMRO.Enabled = false;
bool isInBuff = false;
try // image in clipboard - for 'paste'
{
System.Drawing.Image img = Clipboard.GetImage();
isInBuff = img != null;
}
catch (Exception ex)
{
isInBuff = false;
}
btnCMPasteImage.Enabled = isInBuff;
btnCMEditMode1.Enabled = false; //View mode (irrelevant for images)
btnCMGoTo.Enabled = MyItemInfo!=null && MyItemInfo.MyContent != null && MyItemInfo.MyContent.ContentRoUsageCount > 0;
// B2016-237 added context menu item to change image size
// B2017-124 - added a check for null references
btnCMImgSz.Enabled = MyEditItem != null && MyEditItem.MyItemInfo != null && MyEditItem.MyItemInfo.IsFigure && (MyEditItem.MyItemInfo.MyContent.MyImage != null || MyEditItem.MyItemInfo.MyContent.Text.ToUpper().Contains("#LINK"));
_ContextMenuBar.SetContextMenuEx(imgItem, btnCMRtfEdit);
}
private void AddEnhancedDocumentMenu(DevComponents.DotNetBar.ButtonItem myButtonItem, object sender)
{
DVEnhancedDocuments dveds = MyItemInfo.MyDocVersion.DocVersionConfig.MyEnhancedDocuments;
if (dveds == null || dveds.Count == 0) return; // No enhanced!
// for all enhanced documents, create the list of buttons as they should be for items in the docversion
// using the list of enhanced documents that are on the docversion. Note that later, some may be
// made invisible or menu text changed.
// first, get correct number of enhanced buttons. This is needed in case the selected item doesn't
// have links to enhanced, but should.
List<string> existingEnhancedButtons = new List<string>();
foreach (DevComponents.DotNetBar.ButtonItem bi in myButtonItem.SubItems)
if (bi.Name.StartsWith("btnEnhanced"))
existingEnhancedButtons.Add(bi.Name);
bool inSource = dveds[0].Type != 0;
int buttonsNeeded = inSource ? dveds.Count : (dveds.Count * 2); // enhanced items need unlink button also.
// if in view only mode, don't do unlink
if (!inSource && MyEditItem != null && MyEditItem.MyStepPanel.VwMode == E_ViewMode.View) buttonsNeeded--;
if (MyItemInfo.IsSection && !MyItemInfo.IsStepSection) buttonsNeeded = 0; // no buttons for word sections
if (buttonsNeeded > existingEnhancedButtons.Count) // add buttons
{
// may need to change the following to add more buttons if a new working draft level was made
foreach (DVEnhancedDocument dved in dveds)
{
string buttonName = string.Format("btnEnhancedTo{0}", dved.Type);
DevComponents.DotNetBar.ButtonItem biEnhanced = new DevComponents.DotNetBar.ButtonItem(buttonName, "Go To " + dved.Name + " Document");
biEnhanced.Click += btnEnhancedGoTo_Click;
myButtonItem.SubItems.Add(biEnhanced);
existingEnhancedButtons.Add(biEnhanced.Name);
// if in view only mode, don't do unlink
if (!inSource && MyEditItem != null && MyEditItem.MyStepPanel.VwMode != E_ViewMode.View)
{
// add unlink buttons:
buttonName = string.Format("btnEnhancedUnlink{0}", dved.Type);
biEnhanced = new DevComponents.DotNetBar.ButtonItem(buttonName, "Unlink " + dved.Name + " Document");
biEnhanced.Click += btnEnhancedGoTo_Click;
biEnhanced.BeginGroup = true; // C2019=003: add separator between go to & unlink
myButtonItem.SubItems.Add(biEnhanced);
existingEnhancedButtons.Add(biEnhanced.Name);
}
}
}
// Now handle specific cases for the Item that user is positioned on.
// If a link exists, the menu item should be 'go to' and 'Unlink' if on an enhanced item.
// If link doesn't exist
// if in source & on procedure, section, high, note or caution, the menu item should be 'create missing'
// else the menu item should be made invisible.
StepRTB myStepRTB = sender as StepRTB ?? _MyStepRTB;
EnhancedDocuments eds = myStepRTB.MyItemInfo.GetMyEnhancedDocuments();
foreach (string btnenh in existingEnhancedButtons)
{
DevComponents.DotNetBar.ButtonItem biEnhanced = myButtonItem.SubItems[btnenh] as DevComponents.DotNetBar.ButtonItem;
int edtypebtn = System.Convert.ToInt32(biEnhanced.Name.Substring(biEnhanced.Name.Length - 1));
bool itemHasLink = false;
if (myStepRTB.MyItemInfo.MyContent.Text == "") // empty text represents a newly inserted step - don't do any enhanced buttons until saved (moved off)
biEnhanced.Visible = false;
else
{
foreach (EnhancedDocument ed in eds)
{
if (edtypebtn == ed.Type) // this button is for this document:
{
if (biEnhanced.Name.StartsWith("btnEnhancedTo"))
{
biEnhanced.Visible = true;
biEnhanced.Text = "Go To " + dveds.GetByType(ed.Type).Name + " Document";
biEnhanced.Tag = ed.ItemID;
itemHasLink = true;
break;
}
else // this is for 'unlink'
{
biEnhanced.Visible = true;
biEnhanced.Tag = ed.ItemID;
itemHasLink = true;
break;
}
}
}
// if there is no link & item is in the 'source document', allow the user to create missing
// enhanced items
if (!itemHasLink && inSource)
{
// need to handle procedures, sections and steps differently:
if (MyItemInfo.IsProcedure)
{
biEnhanced.Visible = true;
biEnhanced.Text = string.Format("Create Missing Enhanced {0} Document Procedure", dveds.GetByType(edtypebtn).Name);
biEnhanced.Tag = MyItemInfo.ItemID;
}
else if (MyItemInfo.IsSection)
{
// verify that procedure has enhanced procedure for this type
EnhancedDocuments peds = MyItemInfo.MyProcedure.GetMyEnhancedDocuments();
bool didMenuItem = false;
foreach (EnhancedDocument ped in peds)
{
if (edtypebtn == ped.Type && MyItemInfo.IsStepSection) // this button is for this document:
{
biEnhanced.Visible = true;
biEnhanced.Text = string.Format("Create Missing Enhanced {0} Document Section", dveds.GetByType(edtypebtn).Name);
biEnhanced.Tag = MyItemInfo.ItemID;
didMenuItem = true;
break;
}
}
if (!didMenuItem) biEnhanced.Visible = false;
}
else if (MyItemInfo.IsHigh || MyItemInfo.IsCaution || MyItemInfo.IsNote)
{
// for HLS there could be multiple level of sections, so need to walk up tree until a procedure to see if one exists on section/subsections.
ItemInfo sect = MyItemInfo.ActiveSection;
bool didMenuItem = false;
while (!didMenuItem && sect.IsSection)
{
EnhancedDocuments seds = sect.GetMyEnhancedDocuments();
foreach (EnhancedDocument sed in seds)
{
if (sed.Type == edtypebtn)
{
// B2018-111: In the following line of code, added that if item is caution/note its parent must be a high level step.
if (MyItemInfo.IsHigh || ((MyItemInfo.IsCaution || MyItemInfo.IsNote) && MyItemInfo.MyParent.IsHigh && MyItemInfo.MyHLS.GetMyEnhancedDocuments().Count > 0))
{
biEnhanced.Visible = true;
biEnhanced.Text = string.Format("Create Missing Enhanced {0} Document Step", dveds.GetByType(edtypebtn).Name);
biEnhanced.Tag = MyItemInfo.ItemID;
didMenuItem = true;
break;
}
}
}
sect = sect.MyParent;
}
if (!didMenuItem) biEnhanced.Visible = false;
}
else
biEnhanced.Visible = false;
}
else if (!itemHasLink && !inSource)
biEnhanced.Visible = false;
}
}
#endregion
}
public ItemInfo enhUseExist = null;
public bool enhDoConv = false;
void btnEnhancedGoTo_Click(object sender, EventArgs e)
{
DevComponents.DotNetBar.BaseItem btn = sender as DevComponents.DotNetBar.BaseItem;
ItemInfo ii = ItemInfo.Get(int.Parse(btn.Tag.ToString()));
if (ii == null || ii.ItemID != MyItemInfo.ItemID) //B2018-116 null reference check - allow user to unlink a background step that has invalid ItemId
{
// if button name starts with btnEnhancedTo... open it, otherwise, unlink:
if (btn.Name.StartsWith("btnEnhancedTo"))
{
MyEditItem.SaveContents();
if(ii!=null) // B2018-142 to allow for the deletion of an un-linked background procedure
MyEditItem.MyStepPanel.MyStepTabPanel.MyDisplayTabControl.OpenItem(ii);
}
else if (btn.Name.Contains("Unlink"))
{
// C2019=003: add a confirmation dialog before unlinking a step:
// B2024 - 075: Change made to pass in an EditTem instead of a ItemInfo
//so can refresh the UI
if (FlexibleMessageBox.Show(this, "Do you want to unlink this step?", "Confirm Enhanced Step Unlink", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
MyEditItem.UnlinkEnhanced(MyEditItem);
}
}
else
{
// have to create it. This will bring up a dialog to either create a new step or
// link to an existing step:
enhUseExist = null;
int enhtype = System.Convert.ToInt32(btn.Name.Replace("btnEnhancedTo", ""));
dlgEnhMissingItem enhMissDlg = new dlgEnhMissingItem(this, ii, enhtype);
DialogResult dr = enhMissDlg.ShowDialog(this.Parent);
if (enhMissDlg.OKSelected || dr == DialogResult.OK)
{
if (enhUseExist == null)
{
ItemInfo newEnh = MyEditItem.AddMissingEnhancedStep(ii, enhtype);
if (ii.IsProcedure && newEnh != null) OnAddProcToDVInTree(new StepTabRibbonEventArgs(newEnh));
}
else if (!enhDoConv)
MyEditItem.CreateLinksEnhancedSingleItem(ii, enhUseExist, enhtype);
else
MyEditItem.CreateLinksEnhancedAllInProcedure(ii, enhUseExist, enhtype);
MyEditItem.SetFocus();
}
}
}
#region set up save ro menu jcb 20121221
private void AddWROContext(DevComponents.DotNetBar.ButtonItem myButtonItem)
{
MyAvailableROs = new Dictionary<string, string>();
DevComponents.DotNetBar.BaseItem btnSaveRO = null;
if (!myButtonItem.SubItems.Contains("btnSaveRO"))
{
btnSaveRO = new DevComponents.DotNetBar.ButtonItem("btnSaveRO", "Save RO");
btnSaveRO.Visible = false;
myButtonItem.SubItems.Add(btnSaveRO);
}
else
btnSaveRO = myButtonItem.SubItems["btnSaveRO"];
if (Clipboard.ContainsData(System.Windows.Forms.DataFormats.Text))
{
MyLookupData = Clipboard.GetData(System.Windows.Forms.DataFormats.Text).ToString();
if (MyLookupData.StartsWith("<STP") || MyLookupData.StartsWith("<MEL") || MyLookupData.StartsWith("<ARP"))
{
if (IsValidRO(MyLookupData))
{
btnSaveRO.SubItems.Clear();
btnSaveRO.Text = "Save RO";
foreach (string k in MyAvailableROs.Keys)
{
DevComponents.DotNetBar.BaseItem btn = new DevComponents.DotNetBar.ButtonItem(k, MyAvailableROs[k]);
btn.Tag = MyAvailableROs[k];
btn.Click += new EventHandler(SaveRO_Click);
btnSaveRO.SubItems.Add(btn);
if (MyStepRTB.SelectedText.Length > 0 && MyStepRTB.SelectedText.ToLower() != MyAvailableROs[k].ToLower())
{
btn = new DevComponents.DotNetBar.ButtonItem("_" + k, MyAvailableROs[k] + " with Annotation");
btn.Tag = MyAvailableROs[k];
btn.Click += new EventHandler(SaveROWithAnnotation_Click);
btnSaveRO.SubItems.Add(btn);
}
}
btnSaveRO.Visible = true;
}
else
{
btnSaveRO.SubItems.Clear();
btnSaveRO.Text = "No RO Found";
DevComponents.DotNetBar.BaseItem btn = new DevComponents.DotNetBar.ButtonItem("btnRONotFound", "Create Annotation");
btn.Tag = string.Format("Text '{0}' has no corresponding RO", MyStepRTB.SelectedText);
btn.Click += new EventHandler(NoROFound_Click);
btnSaveRO.SubItems.Add(btn);
btnSaveRO.Visible = true;
}
}
}
}
#endregion
private bool IsValidRO(string data)
{
bool rv = false;
MyAvailableROs = new Dictionary<string, string>();
if (Mydvi != null)
{
#region force arp without hi or lo jcb 20121221
//if (data == "<ARP CDS-LT002-1-MED-LO1 \\s\\l\\1>")
//{
// data = data.Replace("-LO1", "");
// Console.WriteLine("force null roc");
//}
#endregion
string accPageID = GetAccPageID(data);
ROFSTLookup.rochild? roc = MyLookup.GetROChildByAccPageID(accPageID, Mydvi.DocVersionConfig.RODefaults_setpointprefix, Mydvi.DocVersionConfig.RODefaults_graphicsprefix);
if (roc != null)
{
int index = GetROValueIndex(data);
if (index > -1)
{
MyAvailableROs.Add(((ROFSTLookup.rochild)roc).children[index].roid, ((ROFSTLookup.rochild)roc).children[index].value.Replace(@"\u160?", " "));
if (accPageID.StartsWith("MEL") && index == 0) // If equipment and 1st return value, then add option to add 4th Return Value
{
MyAvailableROs.Add(((ROFSTLookup.rochild)roc).children[3].roid, ((ROFSTLookup.rochild)roc).children[3].value.Replace(@"\u160?", " "));
MyAvailableROs.Add(((ROFSTLookup.rochild)roc).children[4].roid, ((ROFSTLookup.rochild)roc).children[4].value.Replace(@"\u160?", " "));
}
rv = true;
}
}
else
{
//see if arp then try HI 1,2,3 and LO 1,2,3
if (accPageID.StartsWith("ARP"))
{
string tmpAccPageID = string.Empty;
//try HI1,2,3
string suffix = "-HI";
for (int i = 1; i < 4; i++)
{
tmpAccPageID = accPageID + suffix + i.ToString();
roc = MyLookup.GetROChildByAccPageID(tmpAccPageID, Mydvi.DocVersionConfig.RODefaults_setpointprefix, Mydvi.DocVersionConfig.RODefaults_graphicsprefix);
if (roc != null)
{
int index = GetROValueIndex(data);
if (index > -1)
{
MyAvailableROs.Add(((ROFSTLookup.rochild)roc).children[index].roid, ((ROFSTLookup.rochild)roc).children[index].value.Replace(@"\u160?", " "));
rv = true;
}
}
}
//try LO1,2,3
suffix = "-LO";
for (int i = 1; i < 4; i++)
{
tmpAccPageID = accPageID + suffix + i.ToString();
roc = MyLookup.GetROChildByAccPageID(tmpAccPageID, Mydvi.DocVersionConfig.RODefaults_setpointprefix, Mydvi.DocVersionConfig.RODefaults_graphicsprefix);
if (roc != null)
{
int index = GetROValueIndex(data);
if (index > -1)
{
MyAvailableROs.Add(((ROFSTLookup.rochild)roc).children[index].roid, ((ROFSTLookup.rochild)roc).children[index].value.Replace(@"\u160?", " "));
rv = true;
}
}
}
}
}
}
return rv;
}
private string GetAccPageID(string txt)
{
//<MEL FWS-MP-02B \\n \\H>
//<STP L19 \\v \\E \\H \\P \\S >
//<ARP FWS-MP-02C-TMP1 \\s \\h \\1>
txt = txt.Replace("<MEL ", "MEL-");
txt = txt.Replace("<STP ", Mydvi.DocVersionConfig.RODefaults_setpointprefix + "-");
txt = txt.Replace("<ARP ", "ARP-");
int i = txt.IndexOf(" ");
txt = txt.Substring(0, i);
return txt;
}
private int GetROValueIndex(string data)
{
int rv = -1;
if (data.StartsWith("<ARP"))
{
// arp children = \n alarm, \s value, \t type, \d description
if (data.IndexOf(@"\n") > 0)
rv = 0;
else if (data.IndexOf(@"\s") > 0)
rv = 1;
else if (data.IndexOf(@"\t") > 0)
rv = 2;
else if (data.IndexOf(@"\d") > 0)
rv = 3;
else
rv = -1;
}
else if (data.StartsWith("<MEL"))
{
//mel children = \n name, \d description, \r room
if (data.IndexOf(@"\n") > 0)
rv = 0;
else if (data.IndexOf(@"\d") > 0)
rv = 1;
else if (data.IndexOf(@"\r") > 0)
rv = 2;
else
rv = -1;
}
else if (data.StartsWith("<STP"))
{
//stp children = \v value, \d description, \n id
if (data.IndexOf(@"\v") > 0)
rv = 0;
else if (data.IndexOf(@"\d") > 0)
rv = 1;
else if (data.IndexOf(@"\n") > 0)
rv = 2;
else
rv = -1;
}
return rv;
}
private void SaveRO_Click(object sender, EventArgs e)
{
DevComponents.DotNetBar.BaseItem btn = sender as DevComponents.DotNetBar.BaseItem;
string myroid = btn.Name;
string myvalue = btn.Tag.ToString();
// the roid may be 12 or 16 chars long, with the last 4 set if there is unit specific
// menuing. Pad to 12 to store in the rousage table.
string padroid = (myroid.Length <= 12) ? myroid + "0000" : myroid;
string linktxt = string.Format(@"#Link:ReferencedObject:<NewID> {0} {1}", padroid, MyLookup.MyDocVersionInfo.DocVersionAssociations[0].MyROFst.MyRODb.RODbID);
// Resolve symbols and scientific notation in the RO return value
string valtxt = MyLookup.GetTranslatedRoValue(padroid, MyStepRTB.MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.ConvertCaretToDelta, MyStepRTB.MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.UseTildaPoundCharsForSuperSubScriptInROValues,
false, MyStepRTB.MyItemInfo); //ConvertSymbolsAndStuff(selectedChld.value);
MyStepRTB.OnRoInsert(this, new StepRTBRoEventArgs(valtxt, myvalue, linktxt, padroid, MyLookup.MyDocVersionInfo.DocVersionAssociations[0].MyROFst.MyRODb.RODbID));
}
private void SaveROWithAnnotation_Click(object sender, EventArgs e)
{
DevComponents.DotNetBar.BaseItem btn = sender as DevComponents.DotNetBar.BaseItem;
string myroid = btn.Name.Replace("_", "");
string myvalue = btn.Tag.ToString();
using (Item itm = MyStepRTB.MyItemInfo.Get())
{
Annotation x = Annotation.MakeAnnotation(itm, AnnotationType.GetByName("RO Value Changed"), null, string.Format("RO Value '{0}' replaces text '{1}'", myvalue, MyStepRTB.SelectedText), null);
}
// the roid may be 12 or 16 chars long, with the last 4 set if there is unit specific
// menuing. Pad to 12 to store in the rousage table.
string padroid = (myroid.Length <= 12) ? myroid + "0000" : myroid;
string linktxt = string.Format(@"#Link:ReferencedObject:<NewID> {0} {1}", padroid, MyLookup.MyDocVersionInfo.DocVersionAssociations[0].MyROFst.MyRODb.RODbID);
// Resolve symbols and scientific notation in the RO return value
string valtxt = MyLookup.GetTranslatedRoValue(padroid, MyStepRTB.MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.ConvertCaretToDelta, MyStepRTB.MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.UseTildaPoundCharsForSuperSubScriptInROValues, false, MyStepRTB.MyItemInfo); //ConvertSymbolsAndStuff(selectedChld.value);
MyStepRTB.OnRoInsert(this, new StepRTBRoEventArgs(valtxt, myvalue, linktxt, padroid, MyLookup.MyDocVersionInfo.DocVersionAssociations[0].MyROFst.MyRODb.RODbID));
}
private void NoROFound_Click(object sender, EventArgs e)
{
DevComponents.DotNetBar.BaseItem btn = sender as DevComponents.DotNetBar.BaseItem;
string myvalue = btn.Tag.ToString();
using (Item itm = MyStepRTB.MyItemInfo.Get())
{
Annotation x = Annotation.MakeAnnotation(itm, AnnotationType.GetByName("RO Missing"), null, myvalue, null);
}
}
#endregion
public void SetGridCellContextMenu()
{
AddWROContext(btnCMRtfCellEdit);
_ContextMenuBar.SetContextMenuEx(_MyStepRTB, btnCMRtfCellEdit);
}
public void SetGridContextMenu()
{
if (rtabTableGridTools.Visible)
_ContextMenuBar.SetContextMenuEx(MyFlexGrid, btnCMGrid);
}
public void OpenContextMenu(Point loc, object sender)
{
if (rtabTableGridTools != null && !rtabTableGridTools.Visible)
{
AddEnhancedDocumentMenu(btnCMRtfEdit, sender);
btnCMRtfEdit.Popup(loc);
}
else // in a table cell, use the table cell's context menu:
btnCMRtfCellEdit.Popup(loc);
}
private int _MyLastFormatID = -1;
private StepRTB _MyStepRTB;
public StepRTB MyStepRTB
{
get { return _MyStepRTB; }
set
{
_MyStepRTB = value;
SetBtnInsSupInfoVisible();
if (fiwc != null) fiwc.MyStepRTB = value;
if (value != null)
{
//Console.WriteLine(string.Format("StepTabRibbon: In set of MyStepRTB, Selected Text = {0}", MyStepRTB.SelectedText));
switch (_MyStepRTB.FieldToEdit)
{
case E_FieldToEdit.PSI:
_ContextMenuBar.SetContextMenuEx(_MyStepRTB, btnCMPSI);
_DefaultContextMenu = btnCMPSI;
break;
case E_FieldToEdit.StepText:
if (MyFlexGrid != null)
{
// This happends when the FlexGrid (table) is selected (not when you edit a table cell)
_ContextMenuBar.SetContextMenuEx(_MyStepRTB, btnCMRtfCellEdit);
_DefaultContextMenu = btnCMRtfCellEdit;
}
else
{
_ContextMenuBar.SetContextMenuEx(_MyStepRTB, btnCMRtfEdit);
_DefaultContextMenu = btnCMRtfEdit;
}
break;
case E_FieldToEdit.Text:
case E_FieldToEdit.Number:
_ContextMenuBar.SetContextMenuEx(_MyStepRTB, btnCMRtfEdit3);
_DefaultContextMenu = btnCMRtfEdit3;
break;
default:
break;
}
// The following two lines were replaced by the third line so that the Ribbon KeyTips will work properly.
// ex. Positon on a substep, press <shift><F6> <N> <S> <S>, to list the substep types
//_MyStepRTB.MouseUp += new MouseEventHandler(_MyStepRTB_MouseUp); //+= new MouseEventHandler(MyStepRTB_SelectionChanged);
//_MyStepRTB.KeyUp += new KeyEventHandler(_MyStepRTB_KeyUp); //+= new KeyEventHandler(MyStepRTB_SelectionChanged);
_MyStepRTB.SelectionChanged += new EventHandler(_MyStepRTB_SelectionChanged);
//_MyStepRTB.ModeChange += new StepRTBModeChangeEvent(_MyStepRTB_ModeChange);
if (_MyEditItem != null) _MyEditItem.Leave += new EventHandler(_MyEditItem_Leave);
//_MyStepRTB.Leave += new EventHandler(_MyStepRTB_Leave);
_MyStepRTB.LinkChanged += new StepRTBLinkEvent(_MyStepRTB_LinkChanged);
_MyStepRTB.TextChanged += new EventHandler(_MyStepRTB_TextChanged);
if (MyFlexGrid != null)
{
MyFlexGrid.CopyOptionChanged += new VlnFlexGridEvent(MyFlexGrid_CopyOptionChanged);
MyFlexGrid.SelChange+=new EventHandler(MyFlexGrid_SelChange);
}
// C2021-043: have Proms specific context menu, i.e. with Hard space, styles and symbols rather than Windows clipboard
// The frmSI dialog uses a StepRTB that ends up in this code to work with the symbol list. This occurs when the
// MyItemInfo is null.
if (MyItemInfo == null)
{
// get base symbol list & add.
FormatInfo fmt = FormatInfo.Get(1);
SymbolList sl = fmt.PlantFormat.FormatData.SymbolList;
if (sl == null || sl.Count <= 0)
{
FlexibleMessageBox.Show("No symbols are available, check with administrator");
return;
}
BuildSymbolGallery(sl, galleryContainerSymbolsCM, galleryContainerSymbolsCM3, galleryContainerSymbolsGrid, galleryContainerSymbolsCM4);
return;
}
if (MyItemInfo.ActiveFormat.FormatID != _MyLastFormatID && _MyLastFormatID == -1)
{
// Add symbols to the tabribbon & also to the context menu getting info from the format file...
// Note that the ButtonItems must be used in order to place the buttons on a gallery (cannot
// use buttonx or dotnet/windows/button). However, you cannot change the font on ButtonItems so
// the ribbon MUST use the Arial Unicode MS Font for this to work!!!!
FormatInfo fmt = MyItemInfo.ActiveFormat;
SymbolList sl = fmt.PlantFormat.FormatData.SymbolList;
if (sl == null || sl.Count <= 0)
{
FlexibleMessageBox.Show("No symbols are available, check with administrator");
return;
}
BuildSymbolGallery(sl, galleryContainerSymbolsCM, galleryContainerSymbolsCM3, galleryContainerSymbolsGrid, galleryContainerSymbolsCM4);
//BuildSymbolGallery(sl, galleryContainerSymbolsCM);
//BuildSymbolGallery(sl, galleryContainerSymbolsCM3);
//BuildSymbolGallery(sl, galleryContainerSymbolsGrid);
}
SetButtonAndMenuEnabling(true);
SetStepButtonAndMenuEnabling(true);
SetMenuEnablingForObjectsWOText();
_MyLastFormatID = MyItemInfo.ActiveFormat.FormatID;
}
}
}
private void SetBtnInsSupInfoVisible()
{
if (MyItemInfo == null) return;
if (!MyItemInfo.SupplementalInformation)
{
btnInsSupInfo.Visible = false;
return;
}
btnInsSupInfo.Visible = true;
// Any step type can insert supplemental information, unless within supplemental information:
if (MyItemInfo.IsSection || MyItemInfo.IsProcedure || MyItemInfo.IsInSupInfo || (MyItemInfo.SupInfos != null && MyItemInfo.SupInfos.Count > 0)) // || ParentHasSupInfo(MyItemInfo))
btnInsSupInfo.Enabled = false;
else
btnInsSupInfo.Enabled = true;
}
void _MyStepRTB_TextChanged(object sender, EventArgs e)
{
if (_MyStepRTB == null) return;
// if we are in view mode or the edit window is empty, then don't allow inserting steps/substeps,
// page breaks, copy step, nor creating a pdf
// B2021-083: Create PDF button on ribbon was disabled for reviewer (removed code). Note that this allow
// is only used for the Create Pdf button now - code has changed for any other use.
bool allow = (_MyStepRTB.TextLength > 0);
//// turn ribbon items on/off base on whether there is text in the edit window
//rbnSiblings.Enabled = rbnParagraph.Enabled = rbnStepParts.Enabled = allow;
//// only turn on the Insert Before/After and the CopyStep buttons if on a step part
////btnInsAftH.Enabled = btnInsBefH.Enabled = btnInsAfter.Enabled = btnInsBefore.Enabled = btnCpyStp.Enabled =
//// allow && !(MyItemInfo.IsProcedure || MyItemInfo.IsSection || MyItemInfo.IsFigure || MyItemInfo.IsTable || MyItemInfo.IsRNOPart);
btnPdfCreate.Enabled = allow || (MyFlexGrid != null); // allways allow if on a table even if table cell is empty
//// toggle context menus used with the shortcut key
//btnCMInsHLS.Enabled = btnCMInsRNO.Enabled = btnCMInsSubStps.Enabled = btnCMInsCaution.Enabled =
// btnCMInsNote.Enabled = btnCMInsTable.Enabled = btnCMInsFigure.Enabled = allow;
// C2014-009 Commented out to allow for inserting Note/Caution
// if in Calvert Alarms Condition/Response, disable insert of Cautions and Notes
//if (MyItemInfo.ActiveFormat.PlantFormat.FormatData.PrintData.SpecialCaseCalvertAlarm)
//btnInsCaut.Enabled = btnInsNote.Enabled = btnCMInsCaution.Enabled = btnCMInsNote.Enabled = allow && !MyItemInfo.IsInCalvertConditionResponse;
// C2021 - 027: Procedure level PC/PC - if text changed, i.e. applicability may have changed, redo the print menus
if (MyItemInfo != null && MyItemInfo.MyDocVersion.MultiUnitCount > 1)
SetParentChildCreatePDFButton(MyItemInfo.MyDocVersion.UnitNames, MyItemInfo);
}
void MyFlexGrid_SelChange(object sender, EventArgs e)
{
if (MyFlexGrid == null)
return;
//B2017-156 Don't allow alignment or borders if the selection is not valid
// Alternatively allow alignment or borders if the selection is valid
rbTblBorder.Enabled = btnTblDgnAlignText.Enabled = MyFlexGrid.Selection.IsValid;
if (MyFlexGrid.Selection.c1 < 0 || MyFlexGrid.Selection.r1 < 0)
return;
if (MyFlexGrid.Selection.c1 >= MyFlexGrid.Cols.Count || MyFlexGrid.Selection.r1 >= MyFlexGrid.Rows.Count)
return;
if ((MyEditItem as GridItem).Initializing) return;
//C1.Win.C1FlexGrid.CellRange cr = MyFlexGrid.GetEvenSelection();
//rbnBorderSelectionPanel.InitializeBorder(MyFlexGrid.MyBorders, cr.r1, cr.c1, cr.r2, cr.c2);
rbnBorderSelectionPanel.InitializeBorder(MyFlexGrid, MyFlexGrid.Selection);
}
void _MyEditItem_Leave(object sender, EventArgs e)
{
// The following two lines were replaced by the third line so that the Ribbon KeyTips will work properly.
// ex. Positon on a substep, press <shift><F6> <N> <S> <S>, to list the substep types
//_MyStepRTB.KeyUp -=new KeyEventHandler(_MyStepRTB_KeyUp);
//_MyStepRTB.MouseUp -= new MouseEventHandler(_MyStepRTB_MouseUp);
if (_MyEditItem != null)
{
_MyEditItem.Leave -= new EventHandler(_MyEditItem_Leave);
_MyEditItem.Enter += new EventHandler(_MyEditItem_Enter);
}
//_MyStepRTB.Leave -= new EventHandler(_MyStepRTB_Leave);
if (_MyStepRTB != null)
{
_MyStepRTB.SelectionChanged -= new EventHandler(_MyStepRTB_SelectionChanged);
_MyStepRTB.LinkChanged -= new StepRTBLinkEvent(_MyStepRTB_LinkChanged);
}
if (MyFlexGrid != null)
{
MyFlexGrid.CopyOptionChanged -= new VlnFlexGridEvent(MyFlexGrid_CopyOptionChanged);
MyFlexGrid.SelChange -= new EventHandler(MyFlexGrid_SelChange);
}
}
public bool SiblingsButtonsEnabled
{
set
{
// turn ribbon items on/off base on whether there is text in the edit window
rbnSiblings.Enabled = rbnParagraph.Enabled = rbnStepParts.Enabled =value;
}
}
public bool InsertButtonsEnabled
{
set
{
// only turn on the Insert Before/After and the CopyStep buttons if on a step part
btnInsAftH.Enabled = btnInsBefH.Enabled = btnInsAfter.Enabled = btnInsBefore.Enabled = btnCpyStp.Enabled = value;
}
}
public void SetCopyStepButton(bool val)
{
btnCpyStp.Enabled = val;
}
void _MyEditItem_Enter(object sender, EventArgs e)
{
// The following two lines were replaced by the third line so that the Ribbon KeyTips will work properly.
// ex. Positon on a substep, press <shift><F6> <N> <S> <S>, to list the substep types
//_MyStepRTB.KeyUp -=new KeyEventHandler(_MyStepRTB_KeyUp);
//_MyStepRTB.MouseUp -= new MouseEventHandler(_MyStepRTB_MouseUp);
if (_MyEditItem != null)
{
_MyEditItem.Leave += new EventHandler(_MyEditItem_Leave);
_MyEditItem.Enter -= new EventHandler(_MyEditItem_Enter);
}
//_MyStepRTB.Leave -= new EventHandler(_MyStepRTB_Leave);
if (_MyStepRTB != null)
{
_MyStepRTB.LinkChanged += new StepRTBLinkEvent(_MyStepRTB_LinkChanged);
_MyStepRTB.SelectionChanged += new EventHandler(_MyStepRTB_SelectionChanged);
}
if (MyFlexGrid != null)
{
MyFlexGrid.CopyOptionChanged += new VlnFlexGridEvent(MyFlexGrid_CopyOptionChanged);
MyFlexGrid.SelChange += new EventHandler(MyFlexGrid_SelChange);
//Console.WriteLine("Turn on SelChange");
}
}
void MyFlexGrid_CopyOptionChanged(object sender, EventArgs args)
{
btnTblDgnPaste.Enabled = true;
btnCmGridPaste.Enabled = true;
switch (VlnFlexGrid.MyCopyInfo.MyCopyOption)
{
case GridCopyOption.Row:
btnTblDgnPasteRow.Visible = true;
btnCmGridPasteRow.Visible = true;
btnTblDgnPasteColumn.Visible = false;
btnCmGridPasteCol.Visible = false;
break;
case GridCopyOption.Column:
btnTblDgnPasteRow.Visible = false;
btnCmGridPasteRow.Visible = false;
btnTblDgnPasteColumn.Visible = true;
btnCmGridPasteCol.Visible = true;
break;
case GridCopyOption.Selection:
btnTblDgnPasteRow.Visible = false;
btnCmGridPasteRow.Visible = false;
btnTblDgnPasteColumn.Visible = false;
btnCmGridPasteCol.Visible = false;
break;
default:
break;
}
}
private ItemInfo lastItem = null;
private int lastStart = -1;
private int lastLength = -1;
private string lastText = null;
// B2019-161 When tracking timing time this action
private static VolianTimer _TimeActivity = new VolianTimer("StepTabRibbon.cs _MyStepRTB_SelectionChanged",837);
void _MyStepRTB_SelectionChanged(object sender, EventArgs e)
{
if (_MyStepRTB == null) return;
_TimeActivity.Open();
//B2019-154 This will prevent duplicate processing of the ribbon menu and refresh of step items, speeding up the editing experience
if (_MyStepRTB != null && _MyStepRTB.MyItemInfo == lastItem && _MyStepRTB.SelectionStart == lastStart && _MyStepRTB.SelectionLength == lastLength && _MyStepRTB.SelectedText == lastText)
return;
lastItem = _MyStepRTB.MyItemInfo;
lastStart = _MyStepRTB.SelectionStart;
lastLength = _MyStepRTB.SelectionLength;
lastText = _MyStepRTB.SelectedText;
SetButtonAndMenuEnabling(false);
_TimeActivity.Close();
}
//void _MyStepRTB_MouseUp(object sender, MouseEventArgs e)
//{
// //SetButtonAndMenuEnabling(false);
//}
//void _MyStepRTB_KeyUp(object sender, KeyEventArgs e)
//{
// //SetButtonAndMenuEnabling(false);
//}
private Bitmap createTextBitmap(char ch)
{
string txt = string.Format("{0}", ch);
Bitmap objBmpImage = new Bitmap(1, 1);
int intWidth = 0;
int intHeight = 0;
// Create the Font object for the image text drawing.
// later on, we could add logic to use either FreeMono or Arial Unicode MS based on the format being used
// but for now, we are going to use FreeMono to create the symbol list
Font objFont = new Font("FreeMono", 18, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel);
//Font objFont = new Font("Arial Unicode MS", 18, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel);
// Create a graphics object to measure the text's width and height.
Graphics objGraphics = Graphics.FromImage(objBmpImage);
// This is where the bitmap size is determined.
intWidth = (int)objGraphics.MeasureString(txt, objFont).Width;
intHeight = (int)objGraphics.MeasureString(txt, objFont).Height;
// Create the bmpImage again with the correct size for the text and font.
objBmpImage = new Bitmap(objBmpImage, new Size(intWidth, intHeight));
// Add the colors to the new bitmap.
objGraphics = Graphics.FromImage(objBmpImage);
// Set Background color
objGraphics.Clear(Color.Transparent); //.White);
objGraphics.SmoothingMode = SmoothingMode.AntiAlias;
objGraphics.TextContrast = 0;
objGraphics.TextRenderingHint = TextRenderingHint.AntiAlias;
//objGraphics.DrawString(txt, objFont, new SolidBrush(Color.FromArgb(102, 102, 102)), 0, 0);
objGraphics.DrawString(txt, objFont, new SolidBrush(Color.Black),0,0);
objGraphics.Flush();
return (objBmpImage);
}
private void BuildSymbolGallery(SymbolList sl, DevComponents.DotNetBar.GalleryContainer gc1, DevComponents.DotNetBar.GalleryContainer gc2, DevComponents.DotNetBar.GalleryContainer gc3, DevComponents.DotNetBar.GalleryContainer gc4)
{
foreach (Symbol sym in sl)
{
// get an image of the symbol character
// found the we cannot change the font being used for the button text
Bitmap symCharBtmp = createTextBitmap((char)sym.Unicode);
DevComponents.DotNetBar.ButtonItem btn = new DevComponents.DotNetBar.ButtonItem();
btn.Image = symCharBtmp;
//btn.Text = string.Format("{0}", (char)sym.Unicode);
// to name button use unicode rather than desc, desc may have spaces or odd chars
btn.Name = "btn" + sym.Unicode.ToString();
btn.Tooltip = sym.Desc;
btn.Tag = string.Format(@"{0}", sym.Unicode);
//btn.FontBold = true;
btn.Click += new System.EventHandler(btnSym_Click);
galleryContainerSymbols.SubItems.Add(btn);
DevComponents.DotNetBar.ButtonItem btnCM1 = GetCMButton(sym);
btnCM1.Image = symCharBtmp;
btnCM1.Click += new System.EventHandler(btnSym_Click);
gc1.SubItems.Add(btnCM1);
DevComponents.DotNetBar.ButtonItem btnCM2 = GetCMButton(sym);
btnCM2.Image = symCharBtmp;
btnCM2.Click += new System.EventHandler(btnSym_Click);
gc2.SubItems.Add(btnCM2);
DevComponents.DotNetBar.ButtonItem btnCM3 = GetCMButton(sym);
btnCM3.Image = symCharBtmp;
btnCM3.Click += new System.EventHandler(btnSym_Click);
gc3.SubItems.Add(btnCM3);
DevComponents.DotNetBar.ButtonItem btnCM4 = GetCMButton(sym);
btnCM4.Image = symCharBtmp;
btnCM4.Click += new System.EventHandler(btnSym_Click);
gc4.SubItems.Add(btnCM4);
}
}
private static DevComponents.DotNetBar.ButtonItem GetCMButton(Symbol sym)
{
DevComponents.DotNetBar.ButtonItem btnCM3 = new DevComponents.DotNetBar.ButtonItem();
//btnCM3.Text = string.Format("{0}", (char)sym.Unicode);
// to name button use unicode rather than desc, desc may have spaces or odd chars
btnCM3.Name = "btnCM" + sym.Unicode.ToString();
btnCM3.Tooltip = sym.Desc;
btnCM3.Tag = string.Format(@"{0}", sym.Unicode);
//btnCM3.FontBold = true;
return btnCM3;
}
//void _MyStepRTB_ModeChange(object sender, StepRTBModeChangeEventArgs args)
//{
// SetButtonAndMenuEnabling(true);
//}
#region Constructor
public StepTabRibbon()
{
InitializeComponent();
this.btnInsSupInfo.Tag = string.Format("{0} {1}", (int)E_FromTypes.SupInfos, 1040); // Make type of rno (40) & special case 1000
SetChangeIdRibbon();
EnableROEdit = true;
_RibbonControl.AutoSize = true;
_RibbonControl.SizeChanged += new EventHandler(_RibbonControl_SizeChanged);
// When AutoExpand is set to true, [CTRL][F1] and double click will hide/expand the ribbon bar
// causing its state to be out of sync with that of the QAT menu option to
// expand/hide the ribbon.
// We now set AutoExpand to false and issue an event to expand/collapse the ribbon
// in a generic event method (ribbonTab_DoubleClick)
// and assigned it to the DoubleClick event of each tab in the ribbon.
// (see ribbonTab_DoubleClick() for more information) -jsj 07-APR-2011
// Note: the QAT menu is to the right of the V start button in the upper left
_RibbonControl.AutoExpand = false;
_RibbonControl.Items[0].RaiseClick(); // initially default to HOME tab
rbnBorderlistBox.Resize += new EventHandler(rbnBorderlistBox_Resize);
rbnBorderlistBox.SetupFontAndSize(6); // 6 Point Font
// added per Harry to hide refresh buttons
btnRefObjRefresh.Visible = btnTranRefresh.Visible = false;
// hide the import from Word file if not running in Debug mode
if (!VlnSettings.DebugMode)
rbnImpWrd.Visible = false;
}
void _RibbonControl_SizeChanged(object sender, EventArgs e)
{
this.Size = _RibbonControl.Size;
}
public bool Expanded
{
get { return _RibbonControl.Expanded; }
set { _RibbonControl.Expanded = value; }
}
#endregion
#region Events
//public event StepTabRibbonEvent OpenEnhancedDocument;
//private void OnOpenEnhancedDocument(StepTabRibbonEventArgs args)
//{
// if (OpenEnhancedDocument != null)
// OpenEnhancedDocument(this, args);
//}
public event StepTabRibbonEvent PrintRequest;
public event StepTabRibbonEvent QPrintRequest;
private void OnPrintRequest(StepTabRibbonEventArgs args, int prttyp = 0)
{
if (PrintRequest != null) {
if (prttyp == 0)
{
PrintRequest(this, args);
}
}
if (QPrintRequest != null)
{
if (prttyp == 1)
{
QPrintRequest(this, args);
}
}
}
public event StepTabRibbonEvent ContActionSummaryRequest;
private void OnContActionSummaryRequest(StepTabRibbonEventArgs args)
{
if (ContActionSummaryRequest != null)
ContActionSummaryRequest(this, args);
}
// F2022-024 Time Critical Action Summary
public event StepTabRibbonEvent TimeCriticalActionSummaryRequest;
private void OnTimeCriticalActionSummaryRequest(StepTabRibbonEventArgs args)
{
if (TimeCriticalActionSummaryRequest != null)
TimeCriticalActionSummaryRequest(this, args);
}
public event StepTabRibbonEvent AddProcToDVInTree;
private void OnAddProcToDVInTree(StepTabRibbonEventArgs args)
{
if (AddProcToDVInTree != null)
AddProcToDVInTree(this, args);
}
void _MyStepRTB_LinkChanged(object sender, StepPanelLinkEventArgs args)
{
// do all Transition and ReferencedObject menu items/buttons based on whether a 'link is selected' and the link type.
SetupGoToButton();
if (btnCMGoTo.Enabled == true && _MyStepRTB.MyLinkText != null) // must have some link test, use it to set edit of transition or ro...
{
btnCMEditTran.Enabled = _MyStepRTB.MyLinkText.IndexOf("Transition") > -1; // selected link must be a transition
btnCMEditRO.Enabled = _MyStepRTB.MyLinkText.IndexOf("ReferencedObject") > -1; // selected link must be ro
}
else
{
btnCMEditTran.Enabled = false;
btnCMEditRO.Enabled = false;
}
}
private void SetupGoToButton()
{
if (MyEditItem is GridItem && (MyEditItem as GridItem).MyFlexGrid.IsRoTable)
// B2016-127 - disable if is an RO table type but no RO was selected.
btnCMGoTo.Enabled = btnGoTo.Enabled = UserInfo.CanEditROs(MyUserInfo, Mydvi) && (MyEditItem as GridItem).MyFlexGrid.ROID != null;//Don't allow Writers and Reviews run the RO Editor
else
{
if (_MyStepRTB == null) return;
if (_MyStepRTB.IsSelectionLinked(_MyStepRTB.SelectionStart, _MyStepRTB.SelectionLength))
{
// if selected text = ?, i.e. a missing/undefined destination, don't allow go to
// if the selected link is an RO then check to see if the user is allowed to run the RO Editor (writers and reviewers cannot run the RO Editor)
btnCMGoTo.Enabled = btnGoTo.Enabled = !_MyStepRTB.SelectedText.StartsWith("?") && (_MyStepRTB.SelectedText.Contains("Transition") || (_MyStepRTB.SelectedText.Contains("ReferencedObject") && UserInfo.CanEditROs(MyUserInfo, Mydvi)));
}
else
btnCMGoTo.Enabled = btnGoTo.Enabled = false;
}
}
void _MyStepRTB_Leave(object sender, EventArgs e)
{
// The following two lines were replaced by the third line so that the Ribbon KeyTips will work properly.
// ex. Positon on a substep, press <shift><F6> <N> <S> <S>, to list the substep types
//_MyStepRTB.KeyUp -=new KeyEventHandler(_MyStepRTB_KeyUp);
//_MyStepRTB.MouseUp -= new MouseEventHandler(_MyStepRTB_MouseUp);
_MyStepRTB.SelectionChanged -= new EventHandler(_MyStepRTB_SelectionChanged);
_MyStepRTB.Leave -= new EventHandler(_MyStepRTB_Leave);
_MyStepRTB.LinkChanged -= new StepRTBLinkEvent(_MyStepRTB_LinkChanged);
}
void btnInsStep_Click(object sender, EventArgs e)
{
// Fix B2016-238 Fix B2017-139 account for image sub-steps
// C2017-028 don't display message if on a table (allow sup info off of a table)
if (_MyEditItem.MyStepRTB.Text == "" && !(_MyEditItem is ImageItem) && !(_MyEditItem is GridItem))
{
FlexibleMessageBox.Show(this, "Cannot insert step from empty step.", "Insert step", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
return;
}
string cautNoteOrder = _MyEditItem.MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.StepSectionLayoutData.CautionNoteOrder;
DevComponents.DotNetBar.ButtonItem b = (DevComponents.DotNetBar.ButtonItem)sender;
if (b.Tag == null) return;
char[] sep = { ' ' };
string[] insdata = b.Tag.ToString().Split(sep);
if (insdata.Length < 2) return;
int fromtype = Convert.ToInt32(insdata[0]);
int contenttype = Convert.ToInt32(insdata[1]) + 20000;
string tabOrFigType = (insdata.Length == 3) ? insdata[2] : null;
// if CautionNoteOrder format variable is set then use it to determine the placement of the
// Caution, Note, Warning, or Message (calvert format)
if (cautNoteOrder != null && ("," + cautNoteOrder + ",").Contains("," + (contenttype % 10000).ToString() + ",") && (_MyEditItem.MyItemInfo.Cautions != null || _MyEditItem.MyItemInfo.Notes != null))
{
EditItem stepBefore = FindStepBefore(cautNoteOrder, contenttype);
if (stepBefore != null)
stepBefore.AddSiblingAfter((int?)contenttype, true);
else
{
EditItem stepAfter = FindStepAfter(cautNoteOrder, contenttype);
if (stepAfter != null)
stepAfter.AddSiblingBefore((int?)contenttype, true);
}
}
// if from type == 0, we've inserted a hls.
// if inserting from section, insert first child
// else do a after from current HLS - if not at HLS, go up parents until find it.
else if (fromtype == 0 && !_MyEditItem.MyItemInfo.IsStepSection)
{
SaveTableChanges(); // B2018-055 Save Current Changes to the table
EditItem hlsEditItem = _MyEditItem;
while (!hlsEditItem.MyItemInfo.IsHigh)
hlsEditItem = hlsEditItem.ActiveParent;
hlsEditItem.AddSiblingAfter((int?)contenttype, true);
}
else if (contenttype == 21040)
{
SaveTableChanges(); // B2018-055 Save Current Changes to the table
_MyEditItem.AddChild((E_FromType)fromtype, 20040);
}
else if (InsertingTable(contenttype))
{
if (tabOrFigType.Contains("RO"))
{
VlnFlexGrid grd = new VlnFlexGrid();
grd.Rows.Count = 1;
grd.Cols.Count = 1;
grd.IsRoTable = true;
_MyEditItem.AddChild((E_FromType)fromtype, contenttype, grd);
StepTabPanel tmp = Parent as StepTabPanel;
tmp.MyDisplayTabControl.OnLinkModifyRO(this, new StepPanelLinkEventArgs(null));
}
else
{
VlnFlexGrid grd = CreateNewTable();
if (grd != null) _MyEditItem.AddChild((E_FromType)fromtype, contenttype, grd);
}
}
else if (InsertingFigure(contenttype))
{
if (tabOrFigType.Contains("RO"))
{
_MyEditItem.AddChild((E_FromType)fromtype, contenttype, ImageItem.E_ImageSource.RoFigure);
StepTabPanel tmp = Parent as StepTabPanel;
tmp.MyDisplayTabControl.OnLinkModifyRO(this, new StepPanelLinkEventArgs(null));
}
else
{
System.Drawing.Image img = Clipboard.GetImage();
if (img == null && tabOrFigType.Contains("CL"))
{
FlexibleMessageBox.Show("Clipboard does not contain image data. Cannot create figure.", "Clipboard Error");
return;
}
_MyEditItem.AddChild((E_FromType)fromtype, contenttype, tabOrFigType.Contains("CL") ? ImageItem.E_ImageSource.Clipboard : ImageItem.E_ImageSource.File);
}
if (_MyEditItem.MyItemInfo.IsFigure && tabOrFigType.Contains("RO"))
btnInsRO_Click(sender, e);
}
else if (InsertingEquation(contenttype))
{
// launch Ole Object Editor - added support for Visio
switch (OleObjectEditors)
{
case 0: // None
FlexibleMessageBox.Show("The Equation Editor needs to be started.", "Reminder", MessageBoxButtons.OK);
break;
case 1: // Equation Editor
Process.Start(EqnEdtPath);
break;
case 2: // Visio
Process.Start(VisioPath);
break;
case 3: // Both
string editor = (sender as ButtonItem).Tag.ToString();
if (editor.EndsWith("Visio"))
Process.Start(VisioPath);
else
Process.Start(EqnEdtPath);
break;
}
_MyEditItem.AddChild((E_FromType)fromtype, contenttype);
}
else
{
_MyEditItem.AddChild((E_FromType)fromtype, contenttype);
}
}
// the following launches the equation editor based on registry setting:
private static string GetEqnEdt()
{
string retval = null;
try
{
RegistryKey key = Registry.ClassesRoot;
string rootName = key.Name;
string curVer = GetDefaultKeyValue(key.Name + "\\Equation\\CurVer");
string clsid = GetDefaultKeyValue(key.Name + "\\" + curVer + "\\CLSID");
retval = GetDefaultKeyValue(key.Name + "\\CLSID\\" + clsid + "\\LocalServer32");
}
catch (Exception ex)
{
_MyLog.WarnFormat("Equation Editor is not correctly configured in the registry.");
string folderPath = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles);
folderPath += @"\Common Files\Microsoft Shared\EQUATION\EQNEDT32.EXE";
System.IO.FileInfo fi = new System.IO.FileInfo(folderPath);
if (fi.Exists) return fi.FullName;
folderPath = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles).Replace(" (x86)", "");
folderPath += @"\Common Files\Microsoft Shared\EQUATION\EQNEDT32.EXE";
fi = new System.IO.FileInfo(folderPath);
if (fi.Exists) return fi.FullName;
folderPath = @"C:\Program Files\Common Files\Microsoft Shared\EQUATION\EQNEDT32.EXE";
fi = new System.IO.FileInfo(folderPath);
if (fi.Exists) return fi.FullName;
return null;
}
if (retval == null)
_MyLog.WarnFormat("Equation Editor executable could not be found.");
return retval;
}
// B2018-038 MathType Replacement for EQNEDT32.EXE
private static string GetMathType()
{
string retval = null;
try
{
RegistryKey key = Registry.ClassesRoot;
string rootName = key.Name;
string clsid = GetDefaultKeyValue(key.Name + "\\DSEquations\\CLSID");
retval = GetDefaultKeyValue(key.Name + "\\CLSID\\" + clsid + "\\LocalServer32");
}
catch (Exception ex)
{
_MyLog.WarnFormat("MathType Equation Editor is not correctly configured in the registry.");
string folderPath = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles);
folderPath += @"\MathType\MathType.EXE";
System.IO.FileInfo fi = new System.IO.FileInfo(folderPath);
if (fi.Exists) return fi.FullName;
folderPath = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles).Replace(" (x86)", "");
folderPath += @"\MathType\MathType.EXE";
fi = new System.IO.FileInfo(folderPath);
if (fi.Exists) return fi.FullName;
folderPath = @"C:\Program Files\\MathType\MathType.EXE";
fi = new System.IO.FileInfo(folderPath);
if (fi.Exists) return fi.FullName;
return null;
}
if (retval == null)
_MyLog.WarnFormat("Equation Editor executable could not be found.");
return retval;
}
private static string GetVisio() // Added support for Visio
{
string retval = _SpecifiedVisioPath; // use the Visio path specified by the user
if (!string.IsNullOrEmpty(retval))
{
if (!retval.ToUpper().EndsWith(".EXE"))
retval += (retval.EndsWith("\\")) ? "visio.exe" : "\\visio.exe";
if (!File.Exists(retval)) // visio path was invalid, so try the registry next
{
_MyLog.WarnFormat("Specified Visio Path is Invalid: {0}",retval);
retval = null; // look in the registry
}
}
if (!string.IsNullOrEmpty(retval))
{
try
{
RegistryKey regVersionString = Registry.ClassesRoot.OpenSubKey("Visio.Drawing\\CurVer");
RegistryKey regClassId = Registry.ClassesRoot.OpenSubKey(regVersionString.GetValue("") + "\\CLSID");
RegistryKey regInstallPath = Registry.ClassesRoot.OpenSubKey("CLSID\\" + regClassId.GetValue("") + "\\LocalServer32");
retval = Path.GetFullPath(regInstallPath.GetValue("").ToString()); // this will convert a short file/folder names to long file/folder names
}
catch
{
_MyLog.WarnFormat("Visio was not found in the registry.");
}
}
return retval;
}
private static string _EqnEdtPath = null;
public static string EqnEdtPath
{
get { return StepTabRibbon._EqnEdtPath; }
}
private static string _VisioPath = null;
public static string VisioPath
{
get { return StepTabRibbon._VisioPath; }
}
private int _OleObjectEditors = -1;
public int OleObjectEditors
{
get
{
if (_OleObjectEditors == -1)
{
_OleObjectEditors = 0;// no OLE Object Editors
_EqnEdtPath = GetEqnEdt();
if (_EqnEdtPath == null) _EqnEdtPath = GetMathType();// B2018-038 MathType Replacement for EQNEDT32.EXE
// B2017-067 check for empty string as well as a null for paths to the Equation Editor and Visio
if (_EqnEdtPath != null && _EqnEdtPath != "") _OleObjectEditors += 1;
_VisioPath = GetVisio();
if (_VisioPath != null && _VisioPath != "") _OleObjectEditors += 2;
}
return _OleObjectEditors;
}
}
private static string FindFile(DirectoryInfo di, string fileName)
{
try
{
foreach (FileInfo fi in di.GetFiles(fileName))
return fi.FullName;
foreach (DirectoryInfo sub in di.GetDirectories())
{
string path = FindFile(sub, fileName);
if (path != null)
return path;
}
}
catch (Exception)
{
;
}
return null;
}
public static String GetDefaultKeyValue(String key)
{
object xxx = null;
// fixed null reference error - appeared only while debugged - for user was handled via Try/Catch and ignored
object gtval = Registry.GetValue(key, "", xxx);
return (string)((gtval != null) ? gtval.ToString() : gtval);
}
private EditItem FindStepAfter(string types, int contenttype)
{
string[] order = types.Split(",".ToCharArray()); //"29,7,6,22"
bool found = false;
List<int> lOrder = new List<int>();
foreach (string type in order)
{
if (found)
lOrder.Add(int.Parse(type));
if (int.Parse(type) == contenttype % 10000) found = true;
}
//_MyEditItem.MyItemInfo.RefreshItemParts();
_MyEditItem.MyItemInfo.ResetParts();
if (_MyEditItem.MyItemInfo.Cautions != null)
foreach (ItemInfo ii in _MyEditItem.MyItemInfo.Cautions)
{
if (lOrder.Contains((int)ii.MyContent.Type % 10000))
return _MyEditItem.MyStepPanel.FindItem(ii);
}
if (_MyEditItem.MyItemInfo.Notes != null)
foreach (ItemInfo ii in _MyEditItem.MyItemInfo.Notes)
{
if (lOrder.Contains((int)ii.MyContent.Type % 10000))
return _MyEditItem.MyStepPanel.FindItem(ii);
}
return null;
}
private EditItem FindStepBefore(string types, int contenttype)
{
string[] order = types.Split(",".ToCharArray()); //"29,7,6,22"
List<int> lOrder = new List<int>();
foreach (string type in order)
{
lOrder.Add(int.Parse(type));
if (lOrder.Contains(contenttype % 10000))
break;
}
ItemInfo itemBefore = null;
//_MyEditItem.MyItemInfo.RefreshItemParts();
_MyEditItem.MyItemInfo.ResetParts();
if (_MyEditItem.MyItemInfo.Cautions != null)
foreach (ItemInfo ii in _MyEditItem.MyItemInfo.Cautions)
{
if (lOrder.Contains((int)ii.MyContent.Type % 10000))
itemBefore = ii;
}
if (_MyEditItem.MyItemInfo.Notes != null)
foreach (ItemInfo ii in _MyEditItem.MyItemInfo.Notes)
{
if (lOrder.Contains((int)ii.MyContent.Type % 10000))
itemBefore = ii;
}
if (itemBefore != null)
{
//Console.WriteLine("findStepBefore {0}", itemBefore.DisplayText);
return _MyEditItem.MyStepPanel.FindItem(itemBefore);
}
return null;
}
// Table Grid
private bool InsertingTable(int contenttype)
{
bool rtnval = false;
switch (contenttype)
{
case 20008: // Centered table
case 20010: // AER table
case 20033: // AER table without boarder
case 20034: // Centered table without boarder
rtnval = true;
break;
}
return rtnval;
}
// Figure (embedded images)
private bool InsertingFigure(int contenttype)
{
bool rtnval = false;
switch (contenttype)
{
case 20036: // Centered
case 20037: // AER (left)
case 20038: // AER (left) without boarder
case 20039: // Centered without boarder
rtnval = true;
break;
}
return rtnval;
}
// Equation
private bool InsertingEquation(int contenttype)
{
bool rtnval = false;
switch (contenttype)
{
case 21000:
case 21001:
case 21002:
case 21003:
rtnval = true;
break;
}
return rtnval;
}
private void btnInsBefore_Click(object sender, EventArgs e)
{
SaveTableChanges(); // B2018-055 Save Current Changes to the table
_MyEditItem.AddSiblingBefore();
}
private void btnInsAfter_Click(object sender, EventArgs e)
{
SaveTableChanges(); // B2018-055 Save Current Changes to the table
_MyEditItem.AddSiblingAfter();
}
private void SaveTableChanges()
{
if (_MyEditItem.MyItemInfo.IsTable) // B2018-005 Save Current Changes to the table
if (_MyEditItem.MyParentEditItem != null)// B2018-055 Move to Parent if it exists
_MyEditItem.MyParentEditItem.Select(); // Next
else if (_MyEditItem.MyPreviousEditItem != null)// B2018-055 Move to Previous if it exists
_MyEditItem.MyPreviousEditItem.Select();
}
/// <summary>
/// Using style for step type, enable/disable formatting buttons
/// </summary>
private void SetButtonForStyle()
{
btnBold.Enabled = btnCMBold.Enabled = (!((_MyStepRTB.MyStyleFont.Style & E_Style.Bold) == E_Style.Bold || (_MyStepRTB.MyStyleFont.Style & E_Style.MmBold) == E_Style.MmBold));
btnUnderline.Enabled = btnCMUnderline.Enabled = (!((_MyStepRTB.MyStyleFont.Style & E_Style.Underline) == E_Style.Underline));
btnItalics.Enabled = btnCMItalics.Enabled = (!((_MyStepRTB.MyStyleFont.Style & E_Style.Italics) == E_Style.Italics));
}
public void SetTableButtonsForMergeRangeSelection()
{
if (MyFlexGrid != null )
{
// B2017-128 added check for only one cell selected (should not be alowed to merge just a single cell)
btnTblDgnMergeCells.Enabled = btnCmGridMergeCells.Enabled = !MyFlexGrid.IsRoTable && !MyFlexGrid.IsInMergeRange() && !MyFlexGrid.Selection.IsSingleCell;
}
}
private void SetButtonMenuEnabledDisabledOnSelection(bool setting)
{
btnCMBold.Enabled = btnBold.Enabled = setting;
btnCMItalics.Enabled = btnItalics.Enabled = setting;
btnCMUnderline.Enabled = btnUnderline.Enabled = setting;
btnCMSubscript.Enabled = btnSubscript.Enabled = setting;
btnCMSuperscript.Enabled = btnSuperscript.Enabled = setting;
btnCMCut.Enabled = btnCut.Enabled = setting;
btnCMUndo.Enabled = btnUndo.Enabled = setting;
btnCMRedo.Enabled = btnRedo.Enabled = setting;
//btnEdit3CMPaste.Enabled = btnPasteText.Enabled = btnCMPasteText.Enabled = btnCMPaste.Enabled = btnPaste.Enabled = setting;
btnCMPaste.Enabled = btnCMPasteText.Enabled = btnPasteText.Enabled = btnPasteStepText.Enabled = btnPaste.Enabled = setting;
btnCMCopy.Enabled = btnCopy.Enabled = setting;
btnPasteAfter.Enabled = btnPasteBefore.Enabled = btnStepPaste.Enabled = btnPasteReplace.Enabled = setting;
btnCMGrid.Enabled = setting;
btnCMPasteImage.Enabled = setting;
}
private void SetButtonMenuEnabledDisabledOnStepType(bool setting)
{
btnPageBreak.Enabled = btnInsPgBrk.Enabled = setting;
btnCMChgStep.Enabled = btnChgTyp.Enabled = setting;
btnInsHLS.Enabled = btnInsCaut.Enabled = btnInsNote.Enabled = btnInsRNO.Enabled = btnInsFig.Enabled =
btnInsTable.Enabled = btnInsSubstep.Enabled = btnInsBefore.Enabled = btnInsAfter.Enabled = setting;
btnInsTrans.Enabled = btnCMTransition.Enabled = setting;
btnInsRO.Enabled = btnCMRO.Enabled = setting && Mydvi.DocVersionAssociationCount > 0; // 2016-128 don't enable if RO Path was not selected at the Working Draft node
btnInsAftH.Enabled = btnInsBefH.Enabled = setting;
btnCMChgCase.Enabled = btnChgCase.Enabled = setting;
btnCMHardSpace.Enabled = btnInsHrdSpc.Enabled = setting;
btnCMSymbol.Enabled = btnSymbols.Enabled = setting;
btnIndent.Enabled = setting;
btnDelelete.Enabled = btnDelStep.Enabled = setting;
btnSpell.Enabled = setting;
rtabTableGridTools.Visible = setting;
btnCMGrid.Enabled = setting;
if (MyItemInfo.IsSection && MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.StepSectionLayoutData.AllowNoteCautionAdd)
{
btnInsNote.Enabled = true;
btnInsCaut.Enabled = true;
}
// C2014-009 Commented out to allow for inserting Note/Caution
// if in Calvert Alarms Condition/Response, disable insert of Cautions and Notes
//if (MyItemInfo.ActiveFormat.PlantFormat.FormatData.PrintData.SpecialCaseCalvertAlarm)
//btnInsCaut.Enabled = btnInsNote.Enabled = btnCMInsCaution.Enabled = btnCMInsNote.Enabled = setting && !MyItemInfo.IsInCalvertConditionResponse;
// B2016-237 added context menu item to change image size
btnCMImgSz.Enabled = MyEditItem.MyItemInfo.IsFigure && (MyEditItem.MyItemInfo.MyContent.MyImage != null || MyEditItem.MyItemInfo.MyContent.Text.ToUpper().Contains("#LINK"));
if (MyItemInfo.IsSupInfoPart) btnInsAfter.Enabled = btnInsAftH.Enabled = btnInsBefore.Enabled = btnInsBefH.Enabled = false;
// C2018-005: disable the change step type button when on procedure or section:
if (MyItemInfo.IsProcedure || MyItemInfo.IsSection) btnCMChgStep.Enabled = btnChgTyp.Enabled = false;
}
public void SetButtonAndMenuEnabling(bool docontextmenus)
{
if (_MyStepRTB == null) return;
// B2020-052: context menu items for setting text styles, fix for properties:
if ((_MyStepRTB.FieldToEdit != E_FieldToEdit.Number && _MyStepRTB.FieldToEdit != E_FieldToEdit.Text && _MyStepRTB.FieldToEdit != E_FieldToEdit.PSI) && _MyStepRTB.FieldToEdit != E_FieldToEdit.StepText && !MyItemInfo.IsFigure && !MyItemInfo.IsRtfRaw) // want menu enabling for figures & aations
return; // No need to change menu that does not get used
DocVersionInfo dvi = MyEditItem != null ? MyEditItem.MyItemInfo.MyProcedure.ActiveParent as DocVersionInfo : MyItemInfo.MyProcedure.ActiveParent as DocVersionInfo;
if (dvi == null) return;
// enable the following in case they were disabled for enhanced steps - only do for formats that have enhanced:
if (!MyItemInfo.IsEnhancedStep && !MyItemInfo.IsEnhancedSection &&
(((MyItemInfo.ActiveFormat.PlantFormat.FormatData.PurchaseOptions.Value & E_PurchaseOptions.EnhancedBackgrounds) == E_PurchaseOptions.EnhancedBackgrounds) ||
((MyItemInfo.ActiveFormat.PlantFormat.FormatData.PurchaseOptions.Value & E_PurchaseOptions.EnhancedDeviations) == E_PurchaseOptions.EnhancedDeviations)))
SetButtonEnablingForEnhanced(MyUserInfo.IsAllowedToEdit(dvi)); // B2018-112 - set context menu and ribbon buttons based on user's PROMS Security setting
if (dvi.VersionType > 127 || (MyEditItem != null && MyEditItem.MyStepPanel.VwMode == E_ViewMode.View))
{
SetButtonMenuEnabledDisabledOnSelection(false);
}
else if (MyItemInfo != null && MyItemInfo.IsEnhancedStep || MyItemInfo.IsEnhancedSection)
{
SetButtonEnablingForEnhanced(false);
}
else
{
SetButtonMenuEnabledDisabledOnSelection(true);
if (_MyStepRTB.SelectionFont != null)
{
// B2017-208 added (MyFlexGrid == null || MyFlexGrid.TableCellEditor.EditMode)
// toggle on/off attributes button checks when you edit table cells, going from one cell to another
// Also don't keep the attributes buttons checked after setting a group of table cells all at one time
btnCMBold.Checked = btnBold.Checked = RTBAPI.IsBold(_MyStepRTB) && (MyFlexGrid == null || MyFlexGrid.TableCellEditor.EditMode);
btnCMItalics.Checked = btnItalics.Checked = RTBAPI.IsItalic(_MyStepRTB) && (MyFlexGrid == null || MyFlexGrid.TableCellEditor.EditMode);
btnCMUnderline.Checked = btnUnderline.Checked = RTBAPI.IsUnderline(_MyStepRTB) && (MyFlexGrid == null || MyFlexGrid.TableCellEditor.EditMode);
btnCMSubscript.Checked = btnSubscript.Checked = RTBAPI.IsSubScript(_MyStepRTB) && (MyFlexGrid == null || MyFlexGrid.TableCellEditor.EditMode);
btnCMSuperscript.Checked = btnSuperscript.Checked = RTBAPI.IsSuperScript(_MyStepRTB) && (MyFlexGrid == null || MyFlexGrid.TableCellEditor.EditMode);
}
SetButtonForStyle();
btnCMCut.Enabled = btnCut.Enabled = _MyStepRTB.SelectionLength > 0;
btnCMUndo.Enabled = btnUndo.Enabled = _MyStepRTB.CanUndo;
btnCMRedo.Enabled = btnRedo.Enabled = _MyStepRTB.CanRedo;
// for paste, see if there is clipboard data, & if so, of a type we can use.
btnCMPasteImage.Enabled = false;
try // RHM20150506 Multiline ItemID TextBox
{
IDataObject iData = Clipboard.GetDataObject();
// B2019-154 clean up the Windows Clipboard - Word on Windows 10 computers seems to have placed extra information (not needed by PROMS) on the clipboard
if (iData.GetFormats().Length > 1)
{
DataObject myDO = new DataObject();
foreach (string objname in iData.GetFormats())
{
switch (objname)
{
//case "Object Descriptor":
//case "HTML Format":
case "EnhancedMetafile":
//case "MetaFilePict":
//case "Embed Source":
//case "Link Source":
//case "Link Source Descriptor":
//case "ObjectLink":
//case "HyperlinkWordBkmk":
//case "Hyperlink":
break;
default:
//case "Text":
//case "Rich Text Format":
myDO.SetData(objname, iData.GetData(objname));
break;
}
}
Clipboard.Clear();
Clipboard.SetDataObject(myDO); // this saves the cleaned up information to the Windows clipboard
}
iData = Clipboard.GetDataObject();
bool noEquationData = true;
// part of bug B2017-117 we were running out of window handles when printing, found this similar use of
// creating a new richtextbox just for some processing. Put a Using around this to ensure the window handle
// is free'd
using (System.Windows.Forms.RichTextBox richTextBox1 = new System.Windows.Forms.RichTextBox())
{
DataFormats.Format frm = DataFormats.GetFormat("Embed Source");
//System.Windows.Forms.RichTextBox richTextBox1;
//richTextBox1 = new System.Windows.Forms.RichTextBox();
richTextBox1.Location = new System.Drawing.Point(35, 32);
richTextBox1.Name = "richTextBox1";
richTextBox1.Size = new System.Drawing.Size(67, 58);
richTextBox1.TabIndex = 0;
richTextBox1.Text = "";
richTextBox1.ScrollBars = System.Windows.Forms.RichTextBoxScrollBars.None;
//bool noEquationData = true;
try
{
richTextBox1.Paste(frm);
if (richTextBox1.Rtf.ToUpper().Contains("OBJCLASS EQU")) noEquationData = false;
if (richTextBox1.Rtf.ToUpper().Contains("OBJCLASS VIS")) noEquationData = false;
}
catch (Exception ex)
{
noEquationData = false;
}
} // end using
//btnEdit3CMPaste.Enabled = btnPasteText.Enabled = btnCMPasteText.Enabled = btnCMPaste.Enabled = btnPaste.Enabled = (iData.GetDataPresent(DataFormats.Text) || iData.GetDataPresent(DataFormats.Rtf));
//btnPasteText.Enabled = btnPasteStepText.Enabled = btnPaste.Enabled = (iData.GetDataPresent(DataFormats.Text) || iData.GetDataPresent(DataFormats.Rtf));
btnPaste.Enabled = noEquationData && (iData.GetDataPresent(DataFormats.Text) || iData.GetDataPresent(DataFormats.Rtf));
btnCMPasteText.Enabled = btnPasteText.Enabled = noEquationData && iData.GetDataPresent(DataFormats.Text);
btnCMPaste.Enabled = btnPasteStepText.Enabled = noEquationData && iData.GetDataPresent(DataFormats.Rtf);
}
catch (Exception) // Error while trying to access the clipboard
{ // This happens when the ItemID Text Box at the bottom of the screen is used to paste
// a list of IDs using the context menu (Right-Click, Paste)
btnPaste.Enabled = false;
btnCMPasteText.Enabled = btnPasteText.Enabled = false;
btnCMPaste.Enabled = btnPasteStepText.Enabled = false;
}
}
// all selected copy while in either Edit or View mode
btnCMCopy.Enabled = btnCopy.Enabled = _MyStepRTB.SelectionLength > 0 && !MyItemInfo.IsRtfRaw;
// paste step only available if a step was copied. Also, check for valid types:
SetPasteButtonEnabled();
// do all Transition and ReferencedObject menu items/buttons based on whether a 'link is selected' and the link type.
//btnCMGoTo.Enabled = btnGoTo.Enabled = _MyStepRTB.IsSelectionLinked(_MyStepRTB.SelectionStart, _MyStepRTB.SelectionLength); //(_MyStepRTB.MyLinkText != null);
SetupGoToButton();
if (btnCMGoTo.Enabled == true && _MyStepRTB.MyLinkText != null) // must have some link test, use it to set edit of transition or ro...
{
btnCMEditTran.Enabled = _MyStepRTB.MyLinkText.IndexOf("Transition") > -1; // selected link must be a transition
btnCMEditRO.Enabled = _MyStepRTB.MyLinkText.IndexOf("ReferencedObject") > -1; // selected link must be ro
}
else
{
btnCMEditTran.Enabled = false;
btnCMEditRO.Enabled = false;
}
// OLD: SetStepButtonAndMenuEnabling(docontextmenus);
SetMenuEnablingForObjectsWOText();
}
private void SetMenuEnablingForObjectsWOText()
{
if (MyItemInfo.IsFigure || MyItemInfo.IsRtfRaw)
{
btnInsTrans.Enabled = btnCMTransition.Enabled = false;
btnInsRO.Enabled = btnCMRO.Enabled = false;
btnCMSymbol.Enabled = btnSymbols.Enabled = false;
btnCMHardSpace.Enabled = btnInsHrdSpc.Enabled = false;
btnIndent.Enabled = false;
btnCMBold.Enabled = btnBold.Enabled = false;
btnCMItalics.Enabled = btnItalics.Enabled = false;
btnCMUnderline.Enabled = btnUnderline.Enabled = false;
btnCMSubscript.Enabled = btnSubscript.Enabled = false;
btnCMSuperscript.Enabled = btnSuperscript.Enabled = false;
btnCMCut.Enabled = btnCut.Enabled = false;
btnCMUndo.Enabled = btnUndo.Enabled = false;
btnCMRedo.Enabled = btnRedo.Enabled = false;
btnChgCase.Enabled = false;
btnPaste.Enabled = false;
btnCMPaste.Enabled = false;
btnCMPasteText.Enabled = false;
if (MyItemInfo.IsRtfRaw)
{
btnCopy.Enabled = false;
btnCMCopy.Enabled = false;
}
}
}
private void SetButtonEnablingForEnhanced(bool setting)
{
btnPaste.Enabled = btnCut.Enabled = setting;
btnUndo.Enabled = btnRedo.Enabled = setting;
rbFont.Enabled = rbStepType.Enabled = setting;
// if disabling the step buttons, first check if the step has 'linked' config data. If it does not,
// it can be deleted:
bool allowDel = false;
EnhancedDocuments eds = MyItemInfo.GetMyEnhancedDocuments();
// note in follow if statements, 'setting' == false when in enhanced document:
if (setting && MyItemInfo.IsStep && (eds == null || eds.Count == 0)) // this step is in enhanced, but not linked // B2018-112 and is allowed to edit
allowDel = true; // allow delete if not linked
btnCpyStp.Enabled = MyUserInfo.IsAllowedToEdit(Mydvi); // C2017-031: Support for paste/replace an enhanced step
//B20170-158 Allow a Unlinked Step to be pasted before or after a linked step.
StepTabPanel tmp = Parent as StepTabPanel;
//B2020-058: crash on null reference
if (tmp != null && tmp.MyDisplayTabControl != null && tmp.MyDisplayTabControl.MyCopyStep != null)
{
//B2017-180: The fix for B2017-158 also needed the 'HasEnhancedLinkedStep' to check if the copied step is a source step
if (!tmp.MyDisplayTabControl.MyCopyStep.IsEnhancedStep && !tmp.MyDisplayTabControl.MyCopyStep.HasEnhancedLinkedStep)
{
if (MyItemInfo.IsEnhancedStep) btnPasteReplace.Enabled = btnCMPasteReplace.Enabled = false;
}
}
else
btnStepPaste.Enabled = setting;
rbnCharacters.Enabled = rbnParagraph.Enabled = rbnLinks.Enabled = setting;
btnCMEdit.Enabled = setting;
btnDelStep.Enabled = setting; // context menu item
btnDelelete.Enabled = setting;
if (allowDel)
{
btnDelStep.Enabled = true;
btnDelelete.Enabled = true;
}
btnPageBreak.Enabled = setting; // context menu item
btnCMHardSpace.Enabled = btnCMTransition.Enabled = btnCMRO.Enabled = btnCMSymbol.Enabled = setting;
btnFindRplDlg.Enabled = setting; // no find replace button is available when in an enhanced document
btnEditMode.Enabled = btnCMEditMode1.Enabled = setting;
if (((MyItemInfo.ActiveFormat.PlantFormat.FormatData.PurchaseOptions.Value & E_PurchaseOptions.EnhancedBackgrounds) == E_PurchaseOptions.EnhancedBackgrounds) ||
((MyItemInfo.ActiveFormat.PlantFormat.FormatData.PurchaseOptions.Value & E_PurchaseOptions.EnhancedDeviations) == E_PurchaseOptions.EnhancedDeviations))
{
btnCASCreate.Enabled = false;
btnTCASCreate.Enabled = false; // F2022-024 Time Critical Action Summary button
}
else
{
btnCASCreate.Enabled = (MyEditItem != null) ? (MyEditItem.MyStepPanel.ApplDisplayMode > 0) : false;
btnTCASCreate.Enabled = btnCASCreate.Enabled; // F2022-024 Time Critical Action Summary button
}
// B2016-237 added context menu item to change image size
// B2020-058 added check for null MyEditItem
btnCMImgSz.Enabled = MyEditItem!=null && MyEditItem.MyItemInfo.IsFigure && (MyEditItem.MyItemInfo.MyContent.MyImage != null || MyEditItem.MyItemInfo.MyContent.Text.ToUpper().Contains("#LINK"));
}
// Made a public method so that it can be called when a step is deleted from the tree view.
// part of bug fix for B2016-005 - jsj 4-19-2016
public void SetPasteButtons(bool enable)
{
btnPasteBefore.Enabled = btnCMPasteBefore.Enabled = enable;
btnPasteAfter.Enabled = btnCMPasteAfter.Enabled = enable;
//B20170-158 Don't allow a step to replace a linked step
//B2017-180: The fix for B2017-158 also needed the 'HasEnhancedLinkedStep' to check if the copied step is a source step
// C2017-031: Support for paste/replace an enhanced step, enable button
btnPasteReplace.Enabled = btnCMPasteReplace.Enabled = enable && ((!MyItemInfo.IsEnhancedStep && !MyItemInfo.HasEnhancedLinkedStep) || (MyItemInfo.IsEnhancedStep));
}
private void SetPasteButtonEnabled()
{
#region new code
StepTabPanel tmp = Parent as StepTabPanel;
if (tmp == null) return;
//turn all on
SetPasteButtons(true);
//copy item is null, turn all off and return
if (tmp.MyDisplayTabControl.MyCopyStep == null)
{
SetPasteButtons(false);
return;
}
//if copy item is equation, can only paste if from an equation
if ((tmp.MyDisplayTabControl.MyCopyStep.IsRtfRaw && !MyItemInfo.IsRtfRaw) || (!tmp.MyDisplayTabControl.MyCopyStep.IsRtfRaw && MyItemInfo.IsRtfRaw))
{
SetPasteButtons(false);
return;
}
//copy item is procedure, turn all off and return must be done from tree
if(tmp.MyDisplayTabControl.MyCopyStep.IsProcedure)
{
SetPasteButtons(false);
return;
}
//copy item is section
if (tmp.MyDisplayTabControl.MyCopyStep.IsSection && !MyItemInfo.IsSection)
{
SetPasteButtons(false);
return;
}
if (tmp.MyDisplayTabControl.MyCopyStep.IsSection && MyItemInfo.IsSection && tmp.MyDisplayTabControl.MyCopyStep.ItemID == MyItemInfo.ItemID)
{
btnPasteReplace.Enabled = btnCMPasteReplace.Enabled = false; // don't replace itself
return;
}
// B2019-010 also don't allow paste step before/after if on an RNO step type (20040)
if (MyItemInfo.IsSupInfoPart || ((int)MyItemInfo.MyContent.Type) == 20040) // before and after are always false:
{
btnPasteAfter.Enabled = btnCMPasteAfter.Enabled = false;
btnPasteBefore.Enabled = btnCMPasteBefore.Enabled = false;
}
// for now (Jan 2016 - initial implementation of enhanced document support) do NOT paste any step (MyCopyStep) that has enhanced data associated
// with it unless pasting within a enhanced source document. The reason is that code would need to handle clearing the pasted enhanced config
// data if it is pasted into a non-enhanced location.
StepConfig stepToCfg = null;
bool fromSourceHasEnhancedLinks = false;
bool toSourceHasEnhancedLinks = false;
if (tmp.MyDisplayTabControl.MyCopyStep.IsHigh)
{
stepToCfg = tmp.MyDisplayTabControl.MyCopyStep.MyConfig as StepConfig;
if (stepToCfg.MyEnhancedDocuments != null && stepToCfg.MyEnhancedDocuments.Count > 0 && stepToCfg.MyEnhancedDocuments[0].Type != 0) fromSourceHasEnhancedLinks = true;
if (MyItemInfo.IsHigh)
{
stepToCfg = MyItemInfo.MyConfig as StepConfig;
if (stepToCfg.MyEnhancedDocuments != null && stepToCfg.MyEnhancedDocuments.Count > 0 && stepToCfg.MyEnhancedDocuments[0].Type != 0) toSourceHasEnhancedLinks = true;
}
}
// enhanced: if 'from' step is not enhanced, only allow paste before/after
if (MyItemInfo.IsHigh && !MyItemInfo.IsEnhancedStep)
{
stepToCfg = MyItemInfo.MyConfig as StepConfig;
if (stepToCfg.MyEnhancedDocuments != null && stepToCfg.MyEnhancedDocuments.Count > 0 && stepToCfg.MyEnhancedDocuments[0].Type != 0)
{
// Current selected step is source (i.e. has enhanced links to enhanced steps)
// check if 'from' step is non. If so, allow paste before/after but not replace
if (tmp.MyDisplayTabControl.MyCopyStep.IsHigh)
{
StepConfig fromCfg = tmp.MyDisplayTabControl.MyCopyStep.MyConfig as StepConfig;
if (fromCfg != null && (fromCfg.MyEnhancedDocuments==null || fromCfg.MyEnhancedDocuments.Count==0))
{
btnPasteReplace.Enabled = btnCMPasteReplace.Enabled = false;
return;
}
}
}
}
//copy item is high level step
// Allow a High Level step to be pasted to a sub-step, but not to a table, figure, section or procedure type
if (tmp.MyDisplayTabControl.MyCopyStep.IsHigh && (MyItemInfo.IsTable || MyItemInfo.IsFigure || MyItemInfo.IsSection || MyItemInfo.IsProcedure))
{
// commenting these lines out allows us to use Copy Step to copy a High Level Step
// to a sub-step level. - 05/18/2015 jsj
// changed above if so the the high level step cannot be paste to a Table, Figure, Section (on the editor panel), Procedure (on the editor panel) - jsj 09/17/2015
SetPasteButtons(false);
return;
}
// don't allow a paste of a substep into a table, figure, sectino,or procedure type
// this also allows a substep (text) to be copyed to a high level step type C2015-011
if (tmp.MyDisplayTabControl.MyCopyStep.IsSubStep && (MyItemInfo.IsTable || MyItemInfo.IsFigure || MyItemInfo.IsSection || MyItemInfo.IsProcedure))
{
SetPasteButtons(false);
return;
}
// copy item is a table of figure - don't allow pasting at High Level Step, Caution or Note level, as well as not at a section or procedure level)
// Bug fix B2015-152
if (tmp.MyDisplayTabControl.MyCopyStep.IsTable && !MyItemInfo.IsTable || tmp.MyDisplayTabControl.MyCopyStep.IsFigure && !MyItemInfo.IsFigure)
{
SetPasteButtons(false);
return;
}
//otherwise everything is ok except for same item prevent replace
if (tmp.MyDisplayTabControl.MyCopyStep.ItemID == MyItemInfo.ItemID)
{
btnPasteReplace.Enabled = btnCMPasteReplace.Enabled = false; // don't replace itself
return;
}
#endregion
#region original code
//// if there is no 'copied' step, or if a procedure is copied, just turn all buttons off, this can only
//// be done from the tree.
//StepTabPanel tmp = Parent as StepTabPanel;
//if (tmp.MyDisplayTabControl.MyCopyStep == null || tmp.MyDisplayTabControl.MyCopyStep.IsProcedurePart)
//{
// btnPasteReplace.Enabled = btnPasteBefore.Enabled = btnPasteAfter.Enabled = btnStepPaste.Enabled = false;
// return;
//}
//// If a section is copied, it can be pasted as a section (before/after/replace). If can also
//// be pasted as a subsection if the format allows it.
//if (tmp.MyDisplayTabControl.MyCopyStep.IsSectionPart)
//{
// btnPasteBefore.Enabled = btnPasteAfter.Enabled = btnPasteReplace.Enabled = MyItemInfo.IsSectionPart;
// // when doing 'substep' part of paste, need to check if format allows subsection.
//}
//else if (tmp.MyDisplayTabControl.MyCopyStep.IsCautionPart || tmp.MyDisplayTabControl.MyCopyStep.IsNotePart)
// // Part type of copied step must be same as Part type of destination, with exceptions of caution/note and step/rno
// // can be pasted into each other.
// // Part types are procedure - 1, section = 2, step = 6, caution = 3, note = 4, RNO (IsRNO), = 5 table/figure = 7.
// btnPasteBefore.Enabled = btnPasteAfter.Enabled = btnPasteReplace.Enabled = (MyItemInfo.IsCautionPart || MyItemInfo.IsNotePart);
//else if (tmp.MyDisplayTabControl.MyCopyStep.IsRNOPart || tmp.MyDisplayTabControl.MyCopyStep.IsStepPart)
// btnPasteBefore.Enabled = btnPasteAfter.Enabled = btnPasteReplace.Enabled = (MyItemInfo.IsRNOPart || MyItemInfo.IsStepPart);
//else if (tmp.MyDisplayTabControl.MyCopyStep.IsTable && MyItemInfo.IsTable)
//{
// btnPasteBefore.Enabled = btnPasteAfter.Enabled = btnCMPasteBefore.Enabled = btnCMPasteAfter.Enabled = false;
// btnPasteReplace.Enabled = btnCMPasteReplace.Enabled = true;
//}
//else if (tmp.MyDisplayTabControl.MyCopyStep.IsTable && !MyItemInfo.IsTable)
//{
// btnPasteBefore.Enabled = btnPasteAfter.Enabled = btnCMPasteBefore.Enabled = btnCMPasteAfter.Enabled = false;
// btnPasteReplace.Enabled = btnCMPasteReplace.Enabled = false;
//}
//// Can't replace step with same step
//if (tmp.MyDisplayTabControl.MyCopyStep.ItemID == MyItemInfo.ItemID) btnPasteReplace.Enabled = false;
#endregion
}
private void SetChangeIdRibbon()
{
if (MyItemInfo == null)
{
FolderInfo fi = FolderInfo.Get(1);
FormatInfo frmI = FormatInfo.Get(fi.FormatID ?? 1);
rtabChgId.Visible = frmI.PlantFormat.FormatData.ProcData.ChangeBarData.ChangeIds;
}
else
rtabChgId.Visible = MyItemInfo.ActiveFormat.PlantFormat.FormatData.ProcData.ChangeBarData.ChangeIds;
}
#region submenu for printing child procedures
// C2020-013 add unit (child) submenu to create PDF and create CAS buttons
private void miMultiUnit_Click(object sender, EventArgs e)
{
if (MyItemInfo == null) return; // if creating a pdf before rtb exists, return;
DevComponents.DotNetBar.ButtonItem mi = sender as DevComponents.DotNetBar.ButtonItem;
DevComponents.DotNetBar.ButtonItem mip = mi.Parent as DevComponents.DotNetBar.ButtonItem;
int selectedChild = (int)mi.Tag;
if (selectedChild == 0) return; // unit (child) not selected
MyItemInfo.MyProcedure.ProcedureConfig.SelectedSlave = (int) mi.Tag;
switch (mip.Text)
{
case "Create":
btnPdfCreate_Click(sender, e);
break;
case "Quick\r\nPrint":
btnPdfQuickCreate_Click(sender, e);
break;
case "Cont. Act\r\nSummary":
btnCASCreate_Click(sender, e);
break;
case "Time Crit\r\nSummary":
btnTCASCreate_Click(sender, e);
break;
}
MyItemInfo.MyProcedure.ProcedureConfig.SelectedSlave = 0; // unselect the unit (child)
}
public void SetParentChildCreatePDFButton(string[] unitNames, ItemInfo ii)
{
btnPdfCreate.SubItems.Clear();
btnPdfCreate.Tag = null;
btnPdfCreate.Click -= new System.EventHandler(btnPdfCreate_Click);
btnPdfQuickCreate.SubItems.Clear();
btnPdfQuickCreate.Tag = null;
btnPdfQuickCreate.Click -= new System.EventHandler(btnPdfQuickCreate_Click);
btnCASCreate.SubItems.Clear();
btnCASCreate.Tag = null;
btnCASCreate.Click -= new System.EventHandler(btnCASCreate_Click);
btnTCASCreate.SubItems.Clear();
btnTCASCreate.Tag = null;
btnTCASCreate.Click -= new System.EventHandler(btnTCASCreate_Click);
btnReviewCreatePDF.SubItems.Clear();
btnReviewCreatePDF.Tag = null;
btnReviewCreatePDF.Click -= new System.EventHandler(btnPdfCreate_Click);
btnReviewPdfQuickCreate.SubItems.Clear();
btnReviewPdfQuickCreate.Tag = null;
btnReviewPdfQuickCreate.Click -= new System.EventHandler(btnPdfQuickCreate_Click);
int k = 0;
foreach (string s in unitNames)
{
// C2021-027: Procedure level PC/PC - see if menu items for unit should be enabled
bool procAppl = ii.MyProcedure.ApplIncludeFromStr(s);
k++;
ButtonItem btn = MakeSubMenuButton(s, k, miMultiUnit_Click);
btn.Enabled = procAppl;
btnPdfCreate.SubItems.Add(btn);
btn = MakeSubMenuButton(s, k, miMultiUnit_Click);
btn.Enabled = procAppl;
btnPdfQuickCreate.SubItems.Add(btn);
btn = MakeSubMenuButton(s, k, miMultiUnit_Click);
btn.Enabled = procAppl;
btnReviewCreatePDF.SubItems.Add(btn);
btn = MakeSubMenuButton(s, k, miMultiUnit_Click);
btn.Enabled = procAppl;
btnCASCreate.SubItems.Add(btn);
btn = MakeSubMenuButton(s, k, miMultiUnit_Click);
btn.Enabled = procAppl;
btnTCASCreate.SubItems.Add(btn);
btn = MakeSubMenuButton(s, k, miMultiUnit_Click);
btn.Enabled = procAppl;
btnReviewPdfQuickCreate.SubItems.Add(btn);
}
btnPdfCreate.AutoExpandOnClick = true;
btnPdfQuickCreate.AutoExpandOnClick = true;
btnReviewCreatePDF.AutoExpandOnClick = true;
btnReviewPdfQuickCreate.AutoExpandOnClick = true;
btnCASCreate.AutoExpandOnClick = true;
btnTCASCreate.AutoExpandOnClick = true;
}
private DevComponents.DotNetBar.ButtonItem MakeSubMenuButton(string s, object tag, EventHandler ehandler)
{
DevComponents.DotNetBar.ButtonItem bi = new DevComponents.DotNetBar.ButtonItem();
bi.Text = s;
bi.Tag = tag;
bi.Click += new System.EventHandler(ehandler);
return bi;
}
#endregion // add submenu items to print child procedure
private void SetStepButtonAndMenuEnabling(bool docontextmenus)
{
if (MyEditItem == null) return;
DocVersionInfo dvi = MyEditItem.MyItemInfo.MyProcedure.ActiveParent as DocVersionInfo;
if (dvi == null) return;
if (dvi.VersionType > 127)
btnCMEditMode1.Enabled = btnEditMode.Enabled = false; // in approved
if (dvi.VersionType > 127 || MyEditItem.MyStepPanel.VwMode == E_ViewMode.View)
{
if (rtabTableGridTools.Checked)
rtabHome.Select();
rtabTableGridTools.Visible = false;
SetButtonMenuEnabledDisabledOnStepType(false);
this.Refresh();
return;
}
else
SetButtonMenuEnabledDisabledOnStepType(true);
btnInsPgBrk.Checked = false;
// see if manual page break - only available on HLS
if (MyItemInfo.IsHigh)
{
StepConfig cfg = MyItemInfo.MyConfig as StepConfig;
btnInsPgBrk.Checked = cfg == null ? false : cfg.Step_NewManualPagebreak;
}
btnInsPgBrk.Enabled = MyItemInfo.IsHigh;
btnPageBreak.Enabled = MyItemInfo.IsHigh; // edit context menu
btnIndent.Checked = (_MyStepRTB.EditMode && _MyStepRTB.SelectionHangingIndent != 0);
btnEditMode.Checked = btnCMEditMode1.Checked = MyEditItem.MyStepPanel.VwMode == E_ViewMode.View;
// if on procedure, 'Delete' buttons should be disabled.
btnDelelete.Enabled = btnDelStep.Enabled = !MyItemInfo.IsProcedure;
// Only display the table edit tools if in a grid (table) and that grid (table) is not an RO Table.
GridItem tmpGridItm = MyEditItem as GridItem;
if (btnTblDgnAdjustSize.Checked)
{
btnTblDgnAdjustSize.Checked = false;
ToggleTableDesignButtons(true);
}
rtabTableGridTools.Visible = tmpGridItm != null;
// If no longer on a table (grid) or the newly selectd table is an RO table
// then select the Home tab (since the Table tab is not visable)
if ((!(MyEditItem is GridItem) && rtabTableGridTools.Checked)) // || ((MyEditItem is GridItem) && !rtabTableGridTools.Visible))
{
rtabHome.Select();
}
// if on procedure or section, 'change type' & 'insert' buttons should be disabled.
if (MyItemInfo.IsProcedure || MyItemInfo.IsSection)
{
btnInsCaut.Enabled = btnInsNote.Enabled = btnInsRNO.Enabled = btnInsFig.Enabled =
btnInsTable.Enabled = btnInsSubstep.Enabled = btnInsBefore.Enabled = btnInsAfter.Enabled = btnInsEquation.Enabled = false;
// if on a section, allow note/caution. May want to add condition that this is a subsection?
if (MyItemInfo.IsSection && MyItemInfo.IsStepSection && MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.StepSectionLayoutData.AllowNoteCautionAdd)
{
btnInsNote.Enabled = true;
btnInsCaut.Enabled = true;
btnInsCaut.SubItems.Clear();
btnInsNote.SubItems.Clear();
if (docontextmenus)
{
btnCMInsCaution.SubItems.Clear();
btnCMInsNote.SubItems.Clear();
}
GalleryForSubTypes(MyItemInfo.ActiveFormat.PlantFormat.FormatData.StepDataList.Caution, MyItemInfo.FormatStepData, btnInsCaut, (int)E_FromType.Caution, btnCMInsCaution, docontextmenus);
GalleryForSubTypes(MyItemInfo.ActiveFormat.PlantFormat.FormatData.StepDataList.Note, MyItemInfo.FormatStepData, btnInsNote, (int)E_FromType.Note, btnCMInsNote, docontextmenus);
}
// if on a procedure or section title, don't allow for insert of ROs or Transitions:
// disable buttons. Info panels for ROs and Transitions are made invisible in frmVEPROMS.cs
btnInsTrans.Enabled = btnCMTransition.Enabled = btnInsRO.Enabled = btnCMRO.Enabled = false;
btnInsAftH.Enabled = btnInsBefH.Enabled = false;
//btnInsHLS.Enabled = (!MyItemInfo.IsStepSection || (MyItemInfo.IsStepSection && MyItemInfo.IsEnhancedSection)) ? false : true; // allow hls from step section
btnInsHLS.Enabled = !MyItemInfo.IsStepSection ? false : true; // allow hls from step section
// if active item is a section and format has metasections, check that a hls can be added.
if (MyItemInfo.IsStepSection)
{
if (MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.UseMetaSections)
// The 'editable' data config must be set to allow new steps to be created.
{
SectionConfig sc = MyItemInfo.MyConfig as SectionConfig;
if (sc != null && MyItemInfo.Sections != null && MyItemInfo.Sections.Count > 0 && sc.SubSection_Edit != "Y")
btnInsHLS.Enabled = false;
}
}
if (btnInsHLS.Enabled)
{
btnInsHLS.SubItems.Clear();
GalleryForSubTypes(MyItemInfo.ActiveFormat.PlantFormat.FormatData.StepDataList.HLS, MyItemInfo.ActiveFormat.PlantFormat.FormatData.StepDataList.HLS, btnInsHLS, (int)E_FromType.Step, btnCMInsHLS, docontextmenus);
}
// B2016-237 added context menu item to change image size
btnCMImgSz.Enabled = MyEditItem.MyItemInfo.IsFigure && (MyEditItem.MyItemInfo.MyContent.MyImage != null || MyEditItem.MyItemInfo.MyContent.Text.ToUpper().Contains("#LINK"));
if (MyItemInfo.IsSupInfoPart) btnInsAfter.Enabled = btnInsAftH.Enabled = btnInsBefore.Enabled = btnInsBefH.Enabled = false;
this.Refresh();
return;
}
btnChgTyp.Enabled = true;
// set up insert buttons based on format
E_AccStep? actable = 0;
StepData sd = MyItemInfo.FormatStepData;
actable = sd.StepEditData.AcTable;
if (actable == null) actable = 0;
btnInsHLS.Enabled = MyItemInfo.MyHLS != null;
btnInsCaut.Enabled = ((actable & E_AccStep.AddingCaution) > 0) && !MyItemInfo.IsEnhancedStep;
btnInsNote.Enabled = ((actable & E_AccStep.AddingNote) > 0) && !MyItemInfo.IsEnhancedStep;
btnInsRNO.Enabled = (actable & E_AccStep.AddingRNO) > 0;
btnInsFig.Enabled = (actable & E_AccStep.AddingTable) > 0;
btnInsTable.Enabled = (actable & E_AccStep.AddingTable) > 0;
btnInsSubstep.Enabled = (actable & E_AccStep.AddingSub) > 0;
btnInsBefore.Enabled = btnInsBefH.Enabled = !MyItemInfo.IsRNOPart && !MyItemInfo.IsSupInfoPart && (actable & E_AccStep.AddingPrev) > 0;
btnInsAfter.Enabled = btnInsAftH.Enabled = !MyItemInfo.IsRNOPart && !MyItemInfo.IsSupInfoPart && (actable & E_AccStep.AddingNext) > 0;
btnInsEquation.Enabled = (actable & E_AccStep.AddingTable) > 0;
// if this step has a table, figure or equation, disable both of those buttons.
if (MyItemInfo.Tables != null && MyItemInfo.Tables.Count > 0)
btnInsTable.Enabled = btnInsFig.Enabled = btnInsEquation.Enabled = btnCMInsFigure.Enabled = btnCMInsTable.Enabled = btnCMInsEquation.Enabled = false;
btnInsHLS.SubItems.Clear();
btnInsCaut.SubItems.Clear();
btnInsNote.SubItems.Clear();
btnInsRNO.SubItems.Clear();
btnInsFig.SubItems.Clear();
btnInsEquation.SubItems.Clear();
btnInsTable.SubItems.Clear();
btnInsSubstep.SubItems.Clear();
if (docontextmenus)
{
btnCMInsHLS.SubItems.Clear();
btnCMInsCaution.SubItems.Clear();
btnCMInsNote.SubItems.Clear();
btnCMInsFigure.SubItems.Clear();
btnCMInsEquation.SubItems.Clear();
btnCMInsTable.SubItems.Clear();
btnCMInsSubStps.SubItems.Clear();
btnCMInsRNO.SubItems.Clear();
btnCMInsEquation.Enabled = btnInsEquation.Enabled;
btnCMInsFigure.Enabled = btnInsFig.Enabled;
}
btnInsRNO.Enabled = btnCMInsRNO.Enabled = btnInsRNO.Enabled && (MyItemInfo.RNOs == null || MyItemInfo.RNOs.Count == 0); // don't insert an RNO if has an RNO
// if (rno is enabled, set the tag:
if (btnInsRNO.Enabled)
btnInsRNO.Tag = string.Format("{0} {1}", (int)E_FromTypes.RNOs, MyEditItem.MyItemInfo.ActiveFormat.PlantFormat.FormatData.GetIndexFromType("RNOType"));
// Proms Express/Message when substep level > 4 may have reset tooltip, so reset:
if (btnInsSubstep.Enabled) this.superTooltipRibbon.SetSuperTooltip(this.btnInsSubstep, new DevComponents.DotNetBar.SuperTooltipInfo("Insert Substep [Ctrl] [Shift] [S]", "", "", null, null, DevComponents.DotNetBar.eTooltipColor.Gray));
// add subitems depending on whether parent type is enabled:
if (btnInsHLS.Enabled) GalleryForSubTypes(MyItemInfo.ActiveFormat.PlantFormat.FormatData.StepDataList.HLS, sd, btnInsHLS, 0, btnCMInsHLS, docontextmenus);
if (btnInsCaut.Enabled) GalleryForSubTypes(MyItemInfo.ActiveFormat.PlantFormat.FormatData.StepDataList.Caution, sd, btnInsCaut, (int)E_FromType.Caution, btnCMInsCaution, docontextmenus);
if (btnInsNote.Enabled) GalleryForSubTypes(MyItemInfo.ActiveFormat.PlantFormat.FormatData.StepDataList.Note, sd, btnInsNote, (int)E_FromType.Note, btnCMInsNote, docontextmenus);
if (btnInsFig.Enabled) GalleryForSubTypes(MyItemInfo.ActiveFormat.PlantFormat.FormatData.StepDataList.Fig, sd, btnInsFig, (int)E_FromType.Table, btnCMInsFigure, docontextmenus);
if (btnInsTable.Enabled) GalleryForSubTypes(MyItemInfo.ActiveFormat.PlantFormat.FormatData.StepDataList.Table, sd, btnInsTable, (int)E_FromType.Table, btnCMInsTable, docontextmenus);
if (btnInsSubstep.Enabled) GalleryForSubTypes(MyItemInfo.ActiveFormat.PlantFormat.FormatData.StepDataList.Substep, sd, btnInsSubstep, (int)E_FromType.Step, btnCMInsSubStps, docontextmenus);
if (btnInsRNO.Enabled) GalleryForSubTypes(MyItemInfo.ActiveFormat.PlantFormat.FormatData.StepDataList.RNO, sd, btnInsRNO, 0, btnCMInsRNO, docontextmenus);
if (btnInsEquation.Enabled) GalleryForSubTypes(MyItemInfo.ActiveFormat.PlantFormat.FormatData.StepDataList.Equation, sd, btnInsEquation, (int)E_FromType.Table, btnCMInsEquation, docontextmenus);
btnInsTrans.Enabled = btnCMTransition.Enabled = !MyItemInfo.IsFigure && !MyItemInfo.IsRtfRaw;
btnInsRO.Enabled = btnCMRO.Enabled = Mydvi.DocVersionAssociationCount > 0; // 2016-128 don't enable if RO Path was not selected at the Working Draft node
// C2014-009 Commented out to allow for inserting Note/Caution
//if in Calvert Alarms Condition/Response, disable insert of Cautions and Notes
//if (MyItemInfo.ActiveFormat.PlantFormat.FormatData.PrintData.SpecialCaseCalvertAlarm)
//btnInsCaut.Enabled = btnInsNote.Enabled = btnCMInsCaution.Enabled = btnCMInsNote.Enabled = !MyItemInfo.IsInCalvertConditionResponse;
_RibbonControl.Refresh(); // jsj- added this because Table Design ribbon tab grouping was not going away when not on a table step type
}
/// <summary>
/// set up a gallery of step types whose parent are defined by input StepData. Can be below
/// more than one level, for example. Substep, EquipmentList, EquipmentWBlank - both equipment
/// lists would be put in gallery
/// </summary>
/// <param name="sdc">StepData: find subtypes related to this</param>
/// <param name="selType">StepData: this should be selected button</param>
/// <param name="btn">DevComponents.DotNetBar.ButtonItem: if items in the gallery, add gallery to this button</param>
/// <param name="cmbtn">DevComponents.DotNetBar.ButtonItem: if items in the gallery, add btns to context menu</param>
private void GalleryForSubTypes(StepData sdc, StepData selType, DevComponents.DotNetBar.ButtonItem btn, int fromtype, DevComponents.DotNetBar.ButtonItem cmbtn, bool docontextmenus)
{
int cursel = -1;
// The first argument (boolean) in StepGetLevelTypes provides the option to get a complete list of step types
// regardless of whether in the AER or RNO column (set to true). For all types, get both except for figures
// and tables.
bool getall = !(btn.Name == "btnInsFig" || btn.Name == "btnInsTable" || btn.Name == "btnInsEquation");
List<StepDataRetval> sdl = MyItemInfo.ActiveFormat.PlantFormat.FormatData.StepGetLevelTypes(getall, sdc, ref cursel, selType==null?"Section":selType.Type, MyItemInfo);
if (sdl != null && sdl.Count > 0)
{
Char kt = 'A'; // start with letter A for KeyTips
// if doing the insert substep button, check for substeps already there and if so must match type.
if (btn.Name == "btnInsSubstep")
{
if (MyItemInfo.Steps != null && MyItemInfo.Steps.Count > 0)
{
ItemInfo ichld = MyItemInfo.Steps[0];
btn.Click -= new System.EventHandler(btnInsStep_Click);
btn.Click += new System.EventHandler(btnInsStep_Click);
btn.Tag = string.Format("{0} {1}", fromtype, ichld.MyContent.Type - 20000);
// B2013-175: add the single substep type to the context menu too
int cmtype = (int)ichld.MyContent.Type - 20000; // content type is the index into the stepdatalist
StepData sdcm = MyItemInfo.ActiveFormat.PlantFormat.FormatData.StepDataList[cmtype];
DevComponents.DotNetBar.ButtonItem cmbix = new DevComponents.DotNetBar.ButtonItem("cmbtn" + sdcm.Type, sdcm.Type);
cmbix.ButtonStyle = DevComponents.DotNetBar.eButtonStyle.TextOnlyAlways;
cmbix.Text = sdcm.StepEditData.TypeMenu.MenuItem;
cmbix.Tag = string.Format("{0} {1}", fromtype, sdcm.Index); // index of type to insert it when button is clicked
cmbix.Click += new System.EventHandler(btnInsStep_Click);
cmbtn.SubItems.Add(cmbix);
return;
}
else
{
btn.Tag = null;
btn.Click -= new System.EventHandler(btnInsStep_Click);
}
}
foreach (StepDataRetval sdr in sdl)
{
bool addit = true;
StepData sd = MyItemInfo.ActiveFormat.PlantFormat.FormatData.StepDataList[sdr.Index];
int hlsSubType = -1; // if on hls, use this to set default on substep menu to first child
if (MyItemInfo.IsHigh && MyItemInfo.Steps != null && MyItemInfo.Steps.Count > 0)
{
hlsSubType = (int)MyItemInfo.Steps[0].MyContent.Type - 20000;
}
// unfortunately, there are some special cases to be handled.
// if high level step, don't put the rno button on
// if caution don't add note button (the StepGetLevelTypes method returns cautions/notes together
if (btn.Name == "btnInsHLS" && sd.Type == "RNOType") addit = false;
if (btn.Name == "btnInsCaut" && sd.Type.Length >= 4 && sd.Type.Substring(0, 4) == "Note") addit = false;
if (btn.Name == "btnInsNote" && sd.Type.Length >= 7 && sd.Type.Substring(0, 7) == "Caution") addit = false;
if (btn.Name == "btnInsSubstep" && MyItemInfo.Steps != null && MyItemInfo.Steps.Count > 0) addit = false;
if (addit)
{
DevComponents.DotNetBar.ButtonItem bi = new DevComponents.DotNetBar.ButtonItem("btn" + sd.Type, sd.Type);
bi.ButtonStyle = DevComponents.DotNetBar.eButtonStyle.TextOnlyAlways;
bi.Text = sdr.Name;
bi.Tag = string.Format("{0} {1}", fromtype, sdr.Index); // index of type to insert it when button is clicked
bi.Checked = (selType == null || (sd.Type == selType.Type));
if (docontextmenus)
{
DevComponents.DotNetBar.ButtonItem cmbi = new DevComponents.DotNetBar.ButtonItem("cmbtn" + sd.Type, sd.Type);
cmbi.ButtonStyle = DevComponents.DotNetBar.eButtonStyle.TextOnlyAlways;
cmbi.Text = sdr.Name;
cmbi.Tag = string.Format("{0} {1}", fromtype, sdr.Index); // index of type to insert it when button is clicked
cmbi.Checked = (selType == null || (sd.Type == selType.Type));
if(!AddVisioOrEqnEdt(cmbi)) // Added support for Visio
cmbi.Click += new System.EventHandler(btnInsStep_Click);
cmbtn.SubItems.Add(cmbi);
}
if (MyItemInfo.IsHigh && hlsSubType != -1 && sdr.Index == hlsSubType) bi.Checked = true;
if(!AddVisioOrEqnEdt(bi)) // Added support for Visio
bi.Click += new System.EventHandler(btnInsStep_Click);
// Assign only A-Z to the KeyTips in the list (i.e. assign only the first 24 in the list)
// Note that KeyTips logic support only single characters at this level (can't have 'AA' for example)
if (kt != '0')
{
bi.KeyTips = kt.ToString();
if (kt == 'Z')
kt = '0';
else
kt++;
}
btn.SubItems.Add(bi);
}
}
//handle various cases for figures:
if (btn.Name == "btnInsFig" && docontextmenus) DoFigureMenuing(btn, cmbtn, sdl);
// if this is a table, then need to add RO/Text table options
if (btn.Name == "btnInsTable" && docontextmenus)
{
// If there is only one 'table' type from format under the ribbon's table item,
// eliminate that button and move up the RO & Text Table buttons.
// This is done for single column mode, or if in the calvertconditionresponse table (dual column) and in the rno column. Note
// the '&&' in if check because when in the calvertconditionresponse table, the section is in 'single column' mode even though
// the condition response table is dual column. This fixes B2014-105.
SectionConfig sc = (SectionConfig)MyItemInfo.ActiveSection.MyConfig;
// One Column Mode or Two Column Mode in the RNO Column or Caution or Note
if ((sc.Section_ColumnMode == SectionConfig.SectionColumnMode.One && (!MyItemInfo.IsInCalvertConditionResponse || MyItemInfo.IsInRNO))
|| (sc.Section_ColumnMode == SectionConfig.SectionColumnMode.Two && MyItemInfo.IsInRNO)
|| ( MyItemInfo.IsCautionOrNotePart)) // single column step editor
{
// setup the sub menus for the insert table ribbon button
btn.Tag = btn.SubItems[0].Tag;
btn.SubItems.Clear();
DoTableSubMenu(btn);
// setup the sub menus for the context menu used with the keyborad shortcut <shift><ctrl><T>
cmbtn.Tag = cmbtn.SubItems[0].Tag;
cmbtn.SubItems.Clear();
DoTableSubMenu(cmbtn);
}
else
{
// setup the sub menus for the insert table ribbon button
foreach (DevComponents.DotNetBar.ButtonItem tabbtn in btn.SubItems)
DoTableSubMenu(tabbtn);
// setup the sub menus for the context menu used with the keyborad shortcut <shift><ctrl><T>
foreach (DevComponents.DotNetBar.ButtonItem cmtabbtn in cmbtn.SubItems)
DoTableSubMenu(cmtabbtn);
}
}
// if only 1, be sure event exists on button to insert item & if more than 1 remove event because
// we want the drop down to appear.
if (btn.Name != "btnInsRNO")
btn.Click -= new System.EventHandler(btnInsStep_Click);
if (docontextmenus)
cmbtn.Click -= new System.EventHandler(btnInsStep_Click);
if (btn.SubItems.Count == 1)
{
btn.SubItems.Clear();
if (btn.Name != "btnInsRNO")
{
btn.Tag = string.Format("{0} {1}", fromtype, sdc.Index);
btn.Click += new System.EventHandler(btnInsStep_Click);
}
if (docontextmenus)
{
cmbtn.SubItems.Clear();
DevComponents.DotNetBar.ButtonItem cmbi = new DevComponents.DotNetBar.ButtonItem("cmbtn" + sdc.Type, sdc.Type);
cmbi.ButtonStyle = DevComponents.DotNetBar.eButtonStyle.TextOnlyAlways;
cmbi.Text = btn.Text;
if (btn.Name == "btnInsRNO")
cmbi.Tag = btn.Tag;
else
cmbi.Tag = string.Format("{0} {1}", fromtype, sdc.Index); // index of type to insert it when button is clicked
cmbi.Click += new System.EventHandler(btnInsStep_Click);
cmbtn.SubItems.Add(cmbi);
}
}
}
// F2021-009 If in Proms Express, let user know if they are going to create a new substep deeper than the defined number of sub-step.
// This uses the tool tip to display the message.
if (MyItemInfo.ActiveFormat.PlantFormat.FormatData.Express && btn.Name == "btnInsSubstep" && (MyItemInfo.Steps == null || MyItemInfo.Steps.Count == 0))
{
if (MyItemInfo.GetStepLevel() >= MyItemInfo.GetDefinedSubStepCount())
{
string tpMsg = "Steps with excessive sub-step levels can be difficult to follow." +
"\nConsider rewriting the step using less sub-steps levels.";
this.superTooltipRibbon.SetSuperTooltip(this.btnInsSubstep, new DevComponents.DotNetBar.SuperTooltipInfo(tpMsg, "", "", null, null, DevComponents.DotNetBar.eTooltipColor.Red));
}
}
rbnStepParts.Refresh();
}
// Added Support for Visio
private bool AddVisioOrEqnEdt(DevComponents.DotNetBar.ButtonItem cmbi)
{
if (cmbi.Text.Contains("Equation") && OleObjectEditors == 3)
{
DevComponents.DotNetBar.ButtonItem btn1 = new DevComponents.DotNetBar.ButtonItem("btnEquation", "Equation Editor");
btn1.Click += new System.EventHandler(btnInsStep_Click);
btn1.Tag = cmbi.Tag + " EqnEdt";
btn1.ButtonStyle = DevComponents.DotNetBar.eButtonStyle.TextOnlyAlways;
//btn1.Tag = string.Format("Equation"); // index of type to insert it when button is clicked
cmbi.SubItems.Add(btn1);
DevComponents.DotNetBar.ButtonItem btn2 = new DevComponents.DotNetBar.ButtonItem("btnVisio", "Visio");
btn2.Click += new System.EventHandler(btnInsStep_Click);
btn2.Tag = cmbi.Tag + " Visio";
btn2.ButtonStyle = DevComponents.DotNetBar.eButtonStyle.TextOnlyAlways;
cmbi.SubItems.Add(btn2);
return true;
}
return false;
}
// From Figure menuing, need to map those strings to the index in the StepdataList for setting item's content type:
//<Step Index="36" Type="Figure" ParentType="Base" />
//<Step Index="37" Type="AERFigure" ParentType="Figure" />
//<Step Index="38" Type="BorderlessFigure" ParentType="Figure" />
//<Step Index="39" Type="BorderlessAERFigure" ParentType="AERFigure" />
private int Centered = 36; // will always be top level.
private void DoFigureMenuing(ButtonItem btn, ButtonItem cmbtn, List<StepDataRetval> sdl)
{
// Figure menuing:
// Figure (from ribbon)
// If in AER Column:
// Centered
// Left
// From both Centered & Left:
// With Border
// Without Border
// From both w/wo Border:
// RO Figure
// Figure from Clipboard
// Figure From File
// If in RNO column or single column mode (see comment below for this menu):
// With Border
// Without Border
// From both w/wo Border:
// RO Figure
// Figure from Clipboard
// Figure From File
// This is done for single column mode, or if in the calvertconditionresponse table (dual column) and in the rno column. Note
// the '&&' in if check because when in the calvertconditionresponse table, the section is in 'single column' mode even though
// the condition response table is dual column.
SectionConfig sc = (SectionConfig)MyItemInfo.ActiveSection.MyConfig;
// One Column Mode or Two Column Mode in the RNO Column or Caution or Note
if ((sc.Section_ColumnMode == SectionConfig.SectionColumnMode.One && (!MyItemInfo.IsInCalvertConditionResponse || MyItemInfo.IsInRNO))
|| (sc.Section_ColumnMode == SectionConfig.SectionColumnMode.Two && MyItemInfo.IsInRNO)
|| (MyItemInfo.IsCautionOrNotePart)) // single column step editor
{
// setup the sub menus for the insert table ribbon button
btn.Tag = btn.SubItems[0].Tag;
btn.SubItems.Clear();
DoFigureW_WOborderSubMenu(btn);
// setup the sub menus for the context menu used with the keyborad shortcut <shift><ctrl><T>
cmbtn.Tag = cmbtn.SubItems[0].Tag;
cmbtn.SubItems.Clear();
DoFigureW_WOborderSubMenu(cmbtn);
}
else
{
// this is AER column in dual column-need to add 'Centered' & 'Left'
char[] sp = { ' ' };
btn.Tag = btn.SubItems[0].Tag;
btn.SubItems.Clear();
string[] insdata = btn.Tag.ToString().Split(sp);
int ftype = Convert.ToInt32(insdata[0]);
int sdtype = Convert.ToInt32(insdata[1]);
DevComponents.DotNetBar.ButtonItem cmbt = new DevComponents.DotNetBar.ButtonItem("cmbtnt" + sdtype + "CENT", "Centered");
cmbt.ButtonStyle = DevComponents.DotNetBar.eButtonStyle.TextOnlyAlways;
cmbt.Text = "Centered";
cmbt.Tag = string.Format("{0} {1} {2}", ftype, 36, "CENT");
cmbt.Click += new System.EventHandler(btnInsStep_Click);
btn.SubItems.Add(cmbt);
cmbt = new DevComponents.DotNetBar.ButtonItem("cmbtnt" + sdtype + "LT", "Left");
cmbt.ButtonStyle = DevComponents.DotNetBar.eButtonStyle.TextOnlyAlways;
cmbt.Text = "Left";
cmbt.Tag = string.Format("{0} {1} {2}", ftype, 37, "LT"); // Text table
cmbt.Click += new System.EventHandler(btnInsStep_Click);
btn.SubItems.Add(cmbt);
btn.Tag = null;
btn.Click -= new System.EventHandler(btnInsStep_Click);
// setup the sub menus for the insert figure ribbon button
foreach (DevComponents.DotNetBar.ButtonItem tabbtn in btn.SubItems)
DoFigureW_WOborderSubMenu(tabbtn);
// setup the sub menus for the context menu used with the keyborad shortcut <shift><ctrl><T>
foreach (DevComponents.DotNetBar.ButtonItem cmtabbtn in cmbtn.SubItems)
DoFigureW_WOborderSubMenu(cmtabbtn);
}
}
private void DoFigureW_WOborderSubMenu(DevComponents.DotNetBar.ButtonItem tabbtn)
{
char[] sp = { ' ' };
string[] insdata = tabbtn.Tag.ToString().Split(sp);
int ftype = Convert.ToInt32(insdata[0]);
int sdtype = Convert.ToInt32(insdata[1]);
int with = sdtype == Centered ? 36 : 37;
DevComponents.DotNetBar.ButtonItem cmbt = new DevComponents.DotNetBar.ButtonItem("cmbtnt" + sdtype + "BD", "With Border");
cmbt.ButtonStyle = DevComponents.DotNetBar.eButtonStyle.TextOnlyAlways;
cmbt.Text = "With Border";
cmbt.Tag = string.Format("{0} {1} {2}", ftype, sdtype, "BD");
cmbt.Click += new System.EventHandler(btnInsStep_Click);
tabbtn.SubItems.Add(cmbt);
DoFigureFromSubMenu(cmbt);
int wo = sdtype == Centered ? 38 : 39;
cmbt = new DevComponents.DotNetBar.ButtonItem("cmbtnt" + wo + "NB", "Without Border");
cmbt.ButtonStyle = DevComponents.DotNetBar.eButtonStyle.TextOnlyAlways;
cmbt.Text = "Without Border";
cmbt.Tag = string.Format("{0} {1} {2}", ftype, wo, "NB");
cmbt.Click += new System.EventHandler(btnInsStep_Click);
tabbtn.SubItems.Add(cmbt);
DoFigureFromSubMenu(cmbt);
tabbtn.Tag = null;
tabbtn.Click -= new System.EventHandler(btnInsStep_Click);
}
private void DoFigureFromSubMenu(DevComponents.DotNetBar.ButtonItem tabbtn)
{
char[] sp = { ' ' };
string[] insdata = tabbtn.Tag.ToString().Split(sp);
int ftype = Convert.ToInt32(insdata[0]);
int sdtype = Convert.ToInt32(insdata[1]);
DevComponents.DotNetBar.ButtonItem cmbt = new DevComponents.DotNetBar.ButtonItem("cmbtnt" + sdtype + "RO", "RO Figure");
cmbt.ButtonStyle = DevComponents.DotNetBar.eButtonStyle.TextOnlyAlways;
cmbt.Text = "RO Figure";
cmbt.Tag = string.Format("{0} {1} {2}", ftype, sdtype, "RO");
cmbt.Click += new System.EventHandler(btnInsStep_Click);
tabbtn.SubItems.Add(cmbt);
cmbt = new DevComponents.DotNetBar.ButtonItem("cmbtnt" + sdtype + "CL", "From Clipboard");
cmbt.ButtonStyle = DevComponents.DotNetBar.eButtonStyle.TextOnlyAlways;
cmbt.Text = "From Clipboard";
cmbt.Tag = string.Format("{0} {1} {2}", ftype, sdtype, "CL");
cmbt.Click += new System.EventHandler(btnInsStep_Click);
tabbtn.SubItems.Add(cmbt);
cmbt = new DevComponents.DotNetBar.ButtonItem("cmbtnt" + sdtype + "FL", "From File");
cmbt.ButtonStyle = DevComponents.DotNetBar.eButtonStyle.TextOnlyAlways;
cmbt.Text = "From File";
cmbt.Tag = string.Format("{0} {1} {2}", ftype, sdtype, "FL"); // Text table
cmbt.Click += new System.EventHandler(btnInsStep_Click);
tabbtn.SubItems.Add(cmbt);
tabbtn.Tag = null;
tabbtn.Click -= new System.EventHandler(btnInsStep_Click);
}
private void DoTableSubMenu(DevComponents.DotNetBar.ButtonItem tabbtn)
{
char[] sp = { ' ' };
string[] insdata = tabbtn.Tag.ToString().Split(sp);
int ftype = Convert.ToInt32(insdata[0]);
int sdtype = Convert.ToInt32(insdata[1]);
DevComponents.DotNetBar.ButtonItem cmbt = new DevComponents.DotNetBar.ButtonItem("cmbtnt" + sdtype + "RO", "RO Table");
cmbt.ButtonStyle = DevComponents.DotNetBar.eButtonStyle.TextOnlyAlways;
cmbt.Text = "RO Table";
cmbt.Tag = string.Format("{0} {1} {2}", ftype, sdtype, "RO");
//cmbt.Checked = (sd.Type == selType.Type);
cmbt.Click += new System.EventHandler(btnInsStep_Click);
tabbtn.SubItems.Add(cmbt);
cmbt = new DevComponents.DotNetBar.ButtonItem("cmbtnt" + sdtype + "TX", "Text Table");
cmbt.ButtonStyle = DevComponents.DotNetBar.eButtonStyle.TextOnlyAlways;
cmbt.Text = "Text Table";
cmbt.Tag = string.Format("{0} {1} {2}", ftype, sdtype, "TX"); // Text table
//cmbt.Checked = (sd.Type == selType.Type);
cmbt.Click += new System.EventHandler(btnInsStep_Click);
tabbtn.SubItems.Add(cmbt);
tabbtn.Tag = null;
tabbtn.Click -= new System.EventHandler(btnInsStep_Click);
}
#endregion
#region Insert Tab
private void btnSym_Click(object sender, EventArgs e)
{
DevComponents.DotNetBar.ButtonItem b = (DevComponents.DotNetBar.ButtonItem)sender;
StartGridEditing(SelectionOption.Start); // If in a FlexGrid, start the editor for a cell
_MyStepRTB.InsertSymbol(Convert.ToInt32(b.Tag));
}
private enum SelectionOption
{
Start,
All,
End
}
/// <summary>
/// If in a FlexGrid, start the editor for a cell
/// </summary>
/// <param name="selectAll">If false cursor will be placed at the begining</param>
private void StartGridEditing(SelectionOption selOpt)
{
// Bug fix: B2012-203, B2012-204
// Need to check if the selected table cell is in edit mode already.
// if already in edit mode, we don't want to do the StartEditing code below, because it
// will override the current cursor positioning and selection range.
Control ctrl = FindActiveControl();
if (ctrl == null) return; // B2018-008 If a null is returned, don't do anything
if (ctrl is VlnFlexGrid)
{
// Selected table cell is not in edit mode. Go into edit mode and position acording
// to the pass in selOpt.
if (MyFlexGrid != null && MyFlexGrid.Editor == null)
{
MyFlexGrid.StartEditing();
switch (selOpt)
{
case SelectionOption.Start:
MyStepRTB.Select(0, 0);
break;
case SelectionOption.All:
MyStepRTB.SelectAll();
break;
case SelectionOption.End:
MyStepRTB.Select(MyStepRTB.TextLength, 0);
break;
default:
MyStepRTB.Select(0, 0);
break;
}
}
}
}
// C2016-029 apply a style (bold,italics,underline,text case) to the selected grid cells
// This method will apply the past in style to either the selected grid cells or to the currently selected step type
private void ApplyStyleToCurrentStepOrGridSelection(SelectionOption selOpt, CellRangeApplyStyle applyStyle)
{
// Need to check if the selected table cell is in edit mode already.
// if already in edit mode, we don't want to do the StartEditing code below, because it
// will override the current cursor positioning and selection range.
Control ctrl = FindActiveControl();
if (ctrl == null) return; // B2018-008 if a null is returned don't do anything
if (ctrl is VlnFlexGrid)
{
// Selected table cell is not in edit mode. Go into edit mode and position according
// to the pass in selOpt.
if (MyFlexGrid != null && MyFlexGrid.Editor == null)
{
C1.Win.C1FlexGrid.CellRange cr = MyFlexGrid.Selection; // get the selected grid cell range
for (int r = cr.r1; r <= cr.r2; r++)
for (int c = cr.c1; c <= cr.c2; c++)
{
MyFlexGrid.Select(r, c);
MyFlexGrid.StartEditing();
switch (selOpt)
{
case SelectionOption.Start:
MyStepRTB.Select(0, 0);
break;
case SelectionOption.All:
MyStepRTB.SelectAll();
break;
case SelectionOption.End:
MyStepRTB.Select(MyStepRTB.TextLength, 0);
break;
default:
MyStepRTB.Select(0, 0);
break;
}
applyStyle();
}
MyFlexGrid.Select(cr);
}
}
else
applyStyle(); // not in a grid, apply style to current step type
}
//C2021-005 the font size for the selected table cell(s)
private float GetTableCellFontSize(SelectionOption selOpt)
{
// return 0 if there are multiple font sizes or just an invalid selection
float rtnFontSize = -1;
// Need to check if the selected table cell is already in edit mode.
// if already in edit mode, we don't want to do the StartEditing code below, because it
// will override the current cursor positioning and selection range.
Control ctrl = FindActiveControl();
if (ctrl == null) return rtnFontSize; // B2018-008 if a null is returned don't do anything
if (ctrl is VlnFlexGrid)
{
// Selected table cell is not in edit mode. Go into edit mode and position according
// to the pass in selOpt.
// B2021-090 don't try to get the font size on an RO table
// B2022-137 Table performance improvements
if (MyFlexGrid != null && MyFlexGrid.Editor == null && !MyFlexGrid.IsRoTable)
{
rtnFontSize = StepRTB.GetRTFFontSize(MyFlexGrid.Selection.Clip);
}
else
rtnFontSize = MyStepRTB.GetRTFFontSize(); // returns 0 when there are mulitiple font sizes
}
return rtnFontSize;
}
// C2021-005 change the font size of the selected table cell(s) or cell text
private void ChangeFontSize(SelectionOption selOpt, float newSize)
{
// ChangeFontSize: similar to code that sets styles (above) except do the font size instead.
// Need to check if the selected table cell is already in edit mode.
// if already in edit mode, we don't want to do the StartEditing code below, because it
// will override the current cursor positioning and selection range.
Control ctrl = FindActiveControl();
if (ctrl == null) return; // B2018-008 if a null is returned don't do anything
if (ctrl is VlnFlexGrid)
{
// Selected table cell is not in edit mode. Go into edit mode and position according
// to the pass in selOpt.
if (MyFlexGrid != null && MyFlexGrid.Editor == null)
{
C1.Win.C1FlexGrid.CellRange cr = MyFlexGrid.Selection; // get the selected grid cell range
for (int r = cr.r1; r <= cr.r2; r++)
for (int c = cr.c1; c <= cr.c2; c++)
{
MyFlexGrid.Select(r, c);
MyFlexGrid.StartEditing();
switch (selOpt)
{
case SelectionOption.Start:
MyStepRTB.Select(0, 0);
break;
case SelectionOption.All:
MyStepRTB.SelectAll();
break;
case SelectionOption.End:
MyStepRTB.Select(MyStepRTB.TextLength, 0);
break;
default:
MyStepRTB.Select(0, 0);
break;
}
ChangeTableTextFontSize(newSize); // Apply font size to selected cells
}
MyFlexGrid.Select(cr);
}
else
{
int ss = MyStepRTB.SelectionStart;
int sl = MyStepRTB.SelectionLength;
MyStepRTB.OnReturnToEditor(this, new EventArgs());
MyStepRTB.Select(ss, sl);
ChangeTableTextFontSize(newSize);
}
}
else
{
if (MyStepRTB != null)
{
// the table cell editor lost focus when the font size dropdown is active
// Save the text selection information because when we re-activate it the selection
// will be lost.
// the logic below was copied from the Save Transition button function
int ss = MyStepRTB.SelectionStart;
int sl = MyStepRTB.SelectionLength;
MyStepRTB.OnReturnToEditor(this, new EventArgs());
MyStepRTB.Select(ss, sl);
ChangeTableTextFontSize(newSize);
}
}
}
// B2021-052 table cell text that ends with a link (RO or Transition) was not accepting a change in font size
private void ChangeTableTextFontSize(float newSize)
{
int ss = MyStepRTB.SelectionStart;
int sl = MyStepRTB.SelectionLength;
bool addedSpace = false;
// B2021-052 if the table cell text end with a link, then append a space to the end and reselect the text
if ((sl == MyStepRTB.TextLength || MyStepRTB.SelectedText.EndsWith("[END>")) && MyStepRTB.Text.EndsWith("[END>"))
{
addedSpace = true;
MyStepRTB.OnReturnToEditor(this, new EventArgs()); //reset and refocus to the table cell rtf edtior
MyStepRTB.AppendText(" ");
MyStepRTB.Select(ss, sl);
}
MyStepRTB.SetFontSize(newSize); // change the font size of the selection
// B2021-052 if a space as added, remove the space
if (addedSpace)
{
MyStepRTB.OnReturnToEditor(this, new EventArgs());
MyStepRTB.Select(MyStepRTB.TextLength - 1, 1); // select the space at the end of the text
MyStepRTB.SelectedText = ""; // remove the space
MyStepRTB.Select(ss, sl);
}
}
private void ToggleBold()
{
RTBAPI.ToggleBold(!RTBAPI.IsBold(_MyStepRTB), _MyStepRTB, _MyStepRTB.SelectionLength == 0 ? RTBAPI.RTBSelection.SCF_DEFAULT : RTBAPI.RTBSelection.SCF_SELECTION);
}
public void btnInsPgBrk_Click(object sender, EventArgs e)
{
//rtabInsert.Select(); // insert page break is no longer visible on the ribbon
if (MyItemInfo.IsProcedure || MyItemInfo.IsSection || !MyItemInfo.IsHigh) return;
MyEditItem.SaveContents();
// toggle manual page break
StepConfig cfg = MyItemInfo.MyConfig as StepConfig;
cfg.Step_NewManualPagebreak = !cfg.Step_NewManualPagebreak;
btnPageBreak.Checked = btnInsPgBrk.Checked = cfg.Step_NewManualPagebreak;
}
private void btnIndent_Click(object sender, EventArgs e)
{
if (MyItemInfo.IsProcedure || MyItemInfo.IsSection) return;
// Use the button as a toggle, i.e. if indent is on - turn it off. If indent is off, use the current cursor
// location to turn it on.
// The print tool (iTextSharp) only supports 1 indent per paragraph, i.e. steprtb (that is also a table cell)
// so the user interface only allows for 1 indent. Note that soft returns maintain the hanging indent & hard
// returns do not maintain it for the FIRST line after the hard return, but any wrapping lines will indent to
// the hanging indent location.
// The following code sets the hanging indent for the entire rtb by selecting all. Without
// this multiple hanging indents could be done - but it didn't appear that way in the user
// interface since the button just toggled on/off.
int savIndent = _MyStepRTB.GetPositionFromCharIndex(_MyStepRTB.SelectionStart).X;
int selStart = _MyStepRTB.SelectionStart;
int selLength = _MyStepRTB.SelectionLength;
_MyStepRTB.SelectAll();
if (_MyStepRTB.SelectionHangingIndent != 0) // this is what does the 'toggle' indent off
_MyStepRTB.SelectionHangingIndent = 0;
else
_MyStepRTB.SelectionHangingIndent = savIndent;
btnIndent.Checked = _MyStepRTB.SelectionHangingIndent != 0;
_MyStepRTB.SelectionStart = selStart;
_MyStepRTB.SelectionLength = selLength;
}
private void btnCMIndent_Click(object sender, EventArgs e)
{
if (_MyStepRTB.SelectionHangingIndent != 0)
_MyStepRTB.SelectionHangingIndent = 0;
else
_MyStepRTB.SelectionHangingIndent = _MyStepRTB.GetPositionFromCharIndex(_MyStepRTB.SelectionStart).X;
btnIndent.Checked = _MyStepRTB.SelectionHangingIndent != 0;
}
#endregion
#region Home Tab
private bool _PastePlainTextOvrRide = false;
private bool _PasteStepTextOvrRide = false;
private void btnPaste_Click(object sender, EventArgs e)
{
StartGridEditing(SelectionOption.End);
IDataObject myDO = Clipboard.GetDataObject();
RichTextBox myRtb = _MyStepRTB;
Control ctrl = FindActiveControl(); // null if on property page for procedure & section number/title
if (ctrl != null && !_MyStepRTB.Focused)
{
if (ctrl is RichTextBox)
{
myRtb = ctrl as RichTextBox;
}
else if (ctrl is ComboBox)
{
ComboBox cmb = ctrl as ComboBox;
if (myDO.GetDataPresent(DataFormats.UnicodeText))
cmb.SelectedText = myDO.GetData(DataFormats.UnicodeText).ToString();
else if (myDO.GetDataPresent(DataFormats.Text))
cmb.SelectedText = myDO.GetData(DataFormats.Text).ToString();
_PastePlainTextOvrRide = false;
_PasteStepTextOvrRide = false;
return;
}
else
{
SaveErrorInLogProblemWithType(ctrl);
_PastePlainTextOvrRide = false;
_PasteStepTextOvrRide = false;
return;
}
}
// check if rtf is coming from Word, i.e. if it has 'SCHEMAS.MICROSOFT.COM/OFFICE/WORD'.
// If it is coming from Word, it will be pasted as text so as not to get any rtf commands
// that PROMS does not support such as odd Fonts, other symbols, etc. This isn't a complete
// solution, clipboard data may come from other 3rd-party tools and unsupported Rtf may get
// pasted in. But the hope is that this will happen less often than getting it from MS Word.
if (myDO.GetDataPresent(DataFormats.Rtf) && (_PasteStepTextOvrRide || (!_PastePlainTextOvrRide && !PastePlainTextSetting)))
{
string tmpForLink = myDO.GetData(DataFormats.Rtf).ToString().Replace("\r\n", "");
if (tmpForLink.ToUpper().Contains(@"SCHEMAS.MICROSOFT.COM/OFFICE/WORD"))
myRtb.SelectedText = _MyStepRTB.GetPasteText(PasteNoReturnsSetting, myDO);
else
{
tmpForLink = ItemInfo.ReplaceLinkWithNewID(tmpForLink);
myRtb.SelectedRtf = tmpForLink;
// Fix for B2014-071: if link, save after paste so that goto's don't crash (grid & step run through this code)
if (tmpForLink.Contains("<NewID>")) _MyStepRTB.OnDoSaveContents(this, new EventArgs());
}
}
else if (myDO.GetDataPresent(DataFormats.Text))
myRtb.SelectedText = _MyStepRTB.GetPasteText(PasteNoReturnsSetting, myDO);
if (myRtb.SelectionLength == 0 && myRtb is StepRTB) myRtb.SelectionFont = (myRtb as StepRTB).MyStyleFont.WindowsFont;
_PastePlainTextOvrRide = false;
_PasteStepTextOvrRide = false;
}
private void SaveErrorInLogProblemWithType(Control ctrl)
{
StringBuilder errormsg = new StringBuilder(string.Format("Failed clipboard action with control {0} a {1} ", ctrl.Name, ctrl.GetType().Name));
Type typ = ctrl.GetType();
while (typ.Name != "Control")
{
errormsg.Append(string.Format(", dervied from {0}", typ.BaseType.Name));
typ = typ.BaseType;
}
_MyLog.Error(errormsg);
}
private Control FindActiveControl()
{
// added the flag below because a table (grid) could have a cell selected (a control)
// but it might not have focus (in edit mode)
bool beenThereDoneThat = false; // flag to prevent infinate loop
Control tmp = this;
while (!(tmp.Parent is Form))
{
tmp = tmp.Parent;
// if coming from property page (properties of procedure & section number/title),
// B2018-008 tmp becomes _MyStepRTB rather than from flexgrid or steptext.
if (tmp == null) return _MyStepRTB;
}
Form frm = tmp.Parent as Form;
tmp = frm.ActiveControl;
while (!beenThereDoneThat && tmp.Controls.Count > 0)
{
beenThereDoneThat = true;
foreach (Control ctrl in tmp.Controls)
if (ctrl.ContainsFocus)
{
tmp = ctrl;
beenThereDoneThat = false;
break;
}
}
return tmp;
}
private void btnCut_Click(object sender, EventArgs e)
{
StartGridEditing(SelectionOption.All);
MoveSelectedToClipboard(true);
}
private void MoveSelectedToClipboard(bool isCut)
{
Control ctrl = FindActiveControl();
if (ctrl == null) return; // B2018-008 If a null is returned, don't do anything
Clipboard.Clear();
//if (_MyStepRTB == null) return;
if (_MyStepRTB.SelectedText == null || _MyStepRTB.SelectedText == "")
return; // nothing to copy onto clipboard, just return
DataObject myDO = new DataObject(); ;
if (ctrl is RichTextBox)
{
//myDO = new DataObject("Rich Text Format", (ctrl as RichTextBox).SelectedRtf);
string tmp2 = _MyStepRTB.SelectedText;
string tmp = _MyStepRTB.GetSelectionForClipBoard();
tmp2 = Regex.Replace(tmp2, @"#Link:ReferencedObject:[0-9]+ +[0-9a-zA-Z]+ [0-9]+", @"");
tmp2 = Regex.Replace(tmp2, @"#Link:Transition:([0-9]+) [0-9]+ [1-9]+", @"");
tmp2 = Regex.Replace(tmp2, @"#Link:TransitionRange:([0-9]+) [0-9]+ [0-9]+ [0-9]+", "");
tmp2 = tmp2.Replace("<START]", "");
tmp2 = tmp2.Replace("[END>", "");
myDO.SetText(tmp2, TextDataFormat.Text);
//myDO.SetText(_MyStepRTB.SelectedRtf, TextDataFormat.Rtf);
myDO.SetText(tmp, TextDataFormat.Rtf);
if (isCut) (ctrl as RichTextBox).SelectedText = "";
}
else if (ctrl is ComboBox)
{
//myDO = new DataObject("Text Format", (ctrl as ComboBox).SelectedText);
myDO.SetText((ctrl as ComboBox).SelectedText, TextDataFormat.Text);
if (isCut) (ctrl as ComboBox).SelectedText = "";
}
else if (ctrl is TextBox)
{
//myDO = new DataObject("Text Format", (ctrl as TextBox).SelectedText);
myDO.SetText((ctrl as TextBox).SelectedText, TextDataFormat.Text);
if (isCut) (ctrl as TextBox).SelectedText = "";
}
else
{
SaveErrorInLogProblemWithType(ctrl);
return;
}
//DataObject myDO;
//if (ctrl is RichTextBox)
//{
// myDO = new DataObject("Rich Text Format", (ctrl as RichTextBox).SelectedRtf);
// myDO.SetText(_MyStepRTB.SelectedText);
// if(isCut) (ctrl as RichTextBox).SelectedText = "";
//}
//else if (ctrl is ComboBox)
//{
// myDO = new DataObject("Text Format", (ctrl as ComboBox).SelectedText);
// if (isCut) (ctrl as ComboBox).SelectedText = "";
//}
//else if (ctrl is TextBox)
//{
// myDO = new DataObject("Text Format", (ctrl as TextBox).SelectedText);
// if (isCut) (ctrl as TextBox).SelectedText = "";
//}
//else
//{
// SaveErrorInLogProblemWithType(ctrl);
// return;
//}
Clipboard.SetDataObject(myDO);
}
private void btnCopy_Click(object sender, EventArgs e)
{
StartGridEditing(SelectionOption.All);
MoveSelectedToClipboard(false);
}
private void btnBold_Click(object sender, EventArgs e)
{
ApplyStyleToCurrentStepOrGridSelection(SelectionOption.All,ToggleBold);
// B2017-208 toggle on/off attributes button checks when you edit table cells, going from one cell to another
// Also don't keep the attributes buttons checked after setting a group of table cells all at one time
btnCMBold.Checked = btnBold.Checked = RTBAPI.IsBold(_MyStepRTB) && (MyFlexGrid == null || MyFlexGrid.TableCellEditor.EditMode);
}
private void btnItalics_Click(object sender, EventArgs e)
{
ApplyStyleToCurrentStepOrGridSelection(SelectionOption.All,ToggleItalic);
// B2017-208 toggle on/off attributes button checks when you edit table cells, going from one cell to another
// Also don't keep the attributes buttons checked after setting a group of table cells all at one time
btnCMItalics.Checked = btnItalics.Checked = RTBAPI.IsItalic(_MyStepRTB) && (MyFlexGrid == null || MyFlexGrid.TableCellEditor.EditMode);
}
private void ToggleItalic()
{
RTBAPI.ToggleItalic(!RTBAPI.IsItalic(_MyStepRTB), _MyStepRTB, _MyStepRTB.SelectionLength == 0 ? RTBAPI.RTBSelection.SCF_DEFAULT : RTBAPI.RTBSelection.SCF_SELECTION);
}
private void btnUnderline_Click(object sender, EventArgs e)
{
ApplyStyleToCurrentStepOrGridSelection(SelectionOption.All, ToggleUnderline);
// B2017-208 toggle on/off attributes button checks when you edit table cells, going from one cell to another
// Also don't keep the attributes buttons checked after setting a group of table cells all at one time
btnCMUnderline.Checked = btnUnderline.Checked = RTBAPI.IsUnderline(_MyStepRTB) && (MyFlexGrid == null || MyFlexGrid.TableCellEditor.EditMode);
}
private void ToggleUnderline()
{
RTBAPI.ToggleUnderline(!RTBAPI.IsUnderline(_MyStepRTB), _MyStepRTB, _MyStepRTB.SelectionLength == 0 ? RTBAPI.RTBSelection.SCF_DEFAULT : RTBAPI.RTBSelection.SCF_SELECTION);
}
public void btnSuperscript_Click(object sender, EventArgs e)
{
StartGridEditing(SelectionOption.All);
RTBAPI.ToggleSuperscript(!RTBAPI.IsSuperScript(_MyStepRTB), _MyStepRTB, _MyStepRTB.SelectionLength == 0 ? RTBAPI.RTBSelection.SCF_DEFAULT : RTBAPI.RTBSelection.SCF_SELECTION);
btnCMSuperscript.Checked = btnSuperscript.Checked = RTBAPI.IsSuperScript(_MyStepRTB);
}
public void btnSubscript_Click(object sender, EventArgs e)
{
StartGridEditing(SelectionOption.All);
RTBAPI.ToggleSubscript(!RTBAPI.IsSubScript(_MyStepRTB), _MyStepRTB, _MyStepRTB.SelectionLength == 0 ? RTBAPI.RTBSelection.SCF_DEFAULT : RTBAPI.RTBSelection.SCF_SELECTION);
btnCMSubscript.Checked = btnSubscript.Checked = RTBAPI.IsSubScript(_MyStepRTB);
}
private void btnUppercase_Click(object sender, EventArgs e)
{
ApplyStyleToCurrentStepOrGridSelection(SelectionOption.All, SetUpperCase);
}
private void SetUpperCase()
{
_MyStepRTB.SetSelectedCase('U');
}
private void btnLowercase_Click(object sender, EventArgs e)
{
ApplyStyleToCurrentStepOrGridSelection(SelectionOption.All, SetLowerCase);
}
private void SetLowerCase()
{
_MyStepRTB.SetSelectedCase('l');
}
private void btnTitleCase_Click(object sender, EventArgs e)
{
ApplyStyleToCurrentStepOrGridSelection(SelectionOption.All, SetTitleCase);
}
private void SetTitleCase()
{
_MyStepRTB.SetSelectedCase('T');
}
private void btnInsTrans_Click(object sender, EventArgs e)
{
StartGridEditing(SelectionOption.Start);
// see if user is positioned 'on' a transition within the rtb, if so do a modify, otherwise,
// insert transition.
StepTabPanel tmp = Parent as StepTabPanel;
tmp.MyDisplayTabControl.OnLinkModifyTran(this, new StepPanelLinkEventArgs(MyStepRTB.MyLinkText));
}
private void btnInsHrdSpc_Click(object sender, EventArgs e)
{
StartGridEditing(SelectionOption.Start);
_MyStepRTB.InsertSymbol(@"\u160?");
}
private void btnInsRO_Click(object sender, EventArgs e)
{
StartGridEditing(SelectionOption.Start);
// see if user is positioned 'on' an ReferencedObject within the rtb, if so do a modify, otherwise,
// insert referenced object.
StepTabPanel tmp = Parent as StepTabPanel;
tmp.MyDisplayTabControl.OnLinkModifyRO(this, new StepPanelLinkEventArgs(MyStepRTB.MyLinkText));
}
private void btnRedo_Click(object sender, EventArgs e)
{
_MyStepRTB.Redo();
btnCMUndo.Enabled = btnUndo.Enabled = _MyStepRTB.CanUndo;
btnCMRedo.Enabled = btnRedo.Enabled = _MyStepRTB.CanRedo;
}
private void btnUndo_Click(object sender, EventArgs e)
{
_MyStepRTB.Undo();
if (_MyStepRTB.WasXDelete && _MyStepRTB.SelectionStart > 0 && _MyStepRTB.TextLength > 0 && (_MyStepRTB.Text[_MyStepRTB.SelectionStart - 1] == 'X'))
{
_MyStepRTB.Undo();
_MyStepRTB.WasXDelete = false;
// only allow one of these - not best case, but at least can get
// one undo
_MyStepRTB.ClearUndo();
}
btnCMRedo.Enabled = btnRedo.Enabled = _MyStepRTB.CanRedo;
btnCMUndo.Enabled = btnUndo.Enabled = _MyStepRTB.CanUndo;
}
private void btnGoTo_Click(object sender, EventArgs e)
{
// if on a transition, go to the selected transition 'to'. If on
// a referenced object, bring up ReferencedObject Editor (for now, just put up a message box.
if (_MyStepRTB.MyLinkText != null && _MyStepRTB.MyLinkText.IndexOf("Transition") > -1)
{
// B2021-094 fix for <Shift><Ctrl><G> key stroke for GoTo Transition or RO link
// Needed to clear the selection of the link or it will be used the next time
// <Shift><Ctrl><G> is used
string lnkText = _MyStepRTB.MyLinkText; // save the transition link information
_MyStepRTB.SetSelection(0, 0); // Clear the selection of the transition link
// note _MyStepRTB.DeselectAll() did not work all the time
_MyEditItem.MyStepPanel.OnLinkClicked(sender, new StepPanelLinkEventArgs(lnkText));
}
else
{
if (VlnSettings.ReleaseMode.Equals("DEMO"))
{
FlexibleMessageBox.Show("Referenced Object Editor not available in the Demo version.", "PROMS Demo Version");
return;
}
string myROID;
RODbInfo myRODB;
if (MyFlexGrid != null && MyFlexGrid.IsRoTable)
{
myROID = MyFlexGrid.ROID.ToLower();
myRODB = RODbInfo.Get(MyFlexGrid.RODbId);
}
else if (MyItemInfo.IsFigure && MyItemInfo.MyContent.ContentRoUsages != null && MyItemInfo.MyContent.ContentRoUsages.Count > 0)
{
myROID = MyItemInfo.MyContent.ContentRoUsages[0].ROID;
myRODB = MyItemInfo.MyContent.ContentRoUsages[0].MyRODb;
}
else
{
LinkText lt = new LinkText(_MyStepRTB.MyLinkText); // save the RO link information
// B2021-094 fix for <Shift><Ctrl><G> key stroke for GoTo Transition or RO link
// Needed to clear the selection of the link or it will be used the next time
// <Shift><Ctrl><G> is used
_MyStepRTB.SetSelection(0, 0); // clear the selection of the RO link
// note _MyStepRTB.DeselectAll() did not work all the time
//B2023-104 If we could not get the MyRoUsageInfo then we have a bad RO Link. Tell user to re-link the RO
if (lt.MyRoUsageInfo != null)
{
myROID = lt.MyRoUsageInfo.ROID.ToLower();
myRODB = lt.MyRoUsageInfo.MyRODb;
}
else
{
FlexibleMessageBox.Show("Invalid RO link information.\n\n Please re-link this RO value.", "Invalid RO Reference", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
}
if (myROID == null) return;
if (myROID.StartsWith("ffff"))
{
FlexibleMessageBox.Show("Unit Information RO's cannot be edited", "Unit Information RO", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
//string roapp = Environment.GetEnvironmentVariable("roapp");
string roapp = Volian.Base.Library.ExeInfo.GetROEditorPath(); // get the path to the RO Editor Executable
string args = "\"" + myRODB.FolderPath + "\" " + myROID;
if (!Directory.Exists(myRODB.FolderPath))
{
FlexibleMessageBox.Show(string.Format("RO Database directory does not exist: {0}", myRODB.FolderPath));
return;
}
// C2017-003: ro data in sql server, check for sql connection string
if (myRODB.DBConnectionString != "cstring") args = args + " \"" + myRODB.DBConnectionString + "\"";
// C2021-026 pass in Parent/Child information (list of the children)
// B2022-019 look at all DocVersions to find ParentChild information
// to ensure we pass in Parent/Child even when not coming from a Parent/Child procedure set
// B2022-073 Break out of the foreach when we find a set with parent/child information
DocVersionInfoList dvil = DocVersionInfoList.Get();
foreach (DocVersionInfo dvi in dvil)
{
DocVersionConfig dvc = dvi.DocVersionConfig as DocVersionConfig;
if (dvc != null && dvc.Unit_Name != "" && dvc.Unit_Count > 1) // B2021-089 only pass in applicability info if defined for more than one unit
{
args += " \"PC=" + dvc.Unit_Name + "\"";
break;
}
}
System.Diagnostics.Process.Start(roapp, args);
}
}
private void btnChgTyp_Click(object sender, EventArgs e)
{
StepPanelTabDisplayEventArgs args = new StepPanelTabDisplayEventArgs("Change Step Type");
MyEditItem.MyStepPanel.OnTabDisplay(sender, args);
}
#endregion
#region RHM debug
//#if DEBUG
// // The following code generates an XML output for the selected item for print testing.
// private void btnPageBreak_Click(object sender, EventArgs e)
// {
// // This is here temporarily to get a node and all of it's children for print testing.
// OutputAllChildren(MyRTBItem);
// }
// private void OutputAllChildren(RTBItem myRTBItem)
// {
// OutputAllChildren(myRTBItem.MyBeforeRTBItems);
// OutputStepInfo(myRTBItem);
// OutputAllChildren(myRTBItem.MyAfterRTBItems);
// OutputAllChildren(myRTBItem.MyRNORTBItems);
// }
// private void OutputStepInfo(RTBItem myRTBItem)
// {
// Label lbl = myRTBItem.MyLabel;
// if (lbl.Text.Trim() != "")
// Console.WriteLine("<text x='{0}In' y='{1}In' font-family='{2}' font-size='{3}Pt'>{4}</text>",
// ToInches(myRTBItem.Left + lbl.Left), ToInches(myRTBItem.Top + lbl.Top),
// lbl.Font.FontFamily.Name,lbl.Font.SizeInPoints,lbl.Text);
// StepRTB rtb = myRTBItem.MyStepRTB;
// Console.WriteLine("<foreignObject x='{0}In' y='{1}In' width='{2}In' " +
// "requiredExtensions='http://Volian.Com/EmbeddedRTF'>{3}</foreignObject>",
// ToInches(myRTBItem.Left + rtb.Left), ToInches(myRTBItem.Top + rtb.Top), ToInches(rtb.Width), myRTBItem.MyItemInfo.MyContent.Text);
//// ToInches(myRTBItem.Left + rtb.Left), ToInches(myRTBItem.Top + rtb.Top), ToInches(rtb.Width), rtb.Rtf);
// }
// private float ToInches(int val)
// {
// return Convert.ToSingle(val)/96F;
// }
// private void OutputAllChildren(List<RTBItem> list)
// {
// if(list != null)
// foreach (RTBItem itm in list)
// OutputAllChildren(itm);
// }
//#endif
#endregion
// C2021-021 change the tool tip for the Find and Find/Replace button based on the user's accessibility to the procedure.
// also change the text on the buttons to read either Find or Find/Replace
public void ToggleFindReplaceToolTip(bool isReviewer)
{
string tipMsg = string.Format("Find {0} [Ctrl] [F]", isReviewer ? "" : "/ Replace");
superTooltipRibbon.SetSuperTooltip(btnReviewFind, new DevComponents.DotNetBar.SuperTooltipInfo(tipMsg, "", "", null, null, DevComponents.DotNetBar.eTooltipColor.Gray));
superTooltipRibbon.SetSuperTooltip(btnFindRplDlg, new DevComponents.DotNetBar.SuperTooltipInfo(tipMsg, "", "", null, null, DevComponents.DotNetBar.eTooltipColor.Gray));
btnFindRplDlg.Text = btnReviewFind.Text = (isReviewer)?"Find": "Find /\r\nReplace";
}
public void SetupReviewerMode()
{
if (MyEditItem != null && MyEditItem.MyStepPanel.VwMode == E_ViewMode.Edit)
{
btnToggleEditView_Click(null, new EventArgs());
rtabView.Visible = false;
rtabHome.Visible = false;
rtabInsert.Visible = false;
rtabAdmin.Visible = false;
rtabReview.Select();
btnCMEditMode1.Enabled = btnEditMode.Enabled = false; // don't allow reviewer toggle out of view mode
}
}
public void SetupROEditorMode()
{
if (MyEditItem != null && MyEditItem.MyStepPanel.VwMode == E_ViewMode.Edit)
{
// bug fix B2015-188
// user with ROEditor only security also has Review privledges
btnToggleEditView_Click(null, new EventArgs());
rtabView.Visible = false;
rtabHome.Visible = false;
rtabInsert.Visible = false;
rtabAdmin.Select();
btnCMEditMode1.Enabled = btnEditMode.Enabled = false;
}
}
public void SetupWriterMode()
{
EnableROEdit = false;
rtabAdmin.Visible = false;
}
public void SetupSetAdminMode()
{
}
public void SetupAdminMode()
{
}
private void btnToggleEditView_Click(object sender, EventArgs e)
{
if (MyEditItem == null) return;
MyEditItem.MyStepPanel.VwMode = MyEditItem.MyStepPanel.VwMode == E_ViewMode.Edit ? E_ViewMode.View : E_ViewMode.Edit;
MyEditItem.ToggleEditView(MyEditItem.MyStepPanel.VwMode);
SetButtonAndMenuEnabling(true);
SetStepButtonAndMenuEnabling(true);
SetMenuEnablingForObjectsWOText();
MyEditItem.MyStepPanel.MyStepTabPanel.MyDisplayTabControl.OnModeChange(this, new StepRTBModeChangeEventArgs(MyEditItem.MyStepPanel.VwMode));
btnEditMode.Checked = btnCMEditMode1.Checked = MyEditItem.MyStepPanel.VwMode == E_ViewMode.View;
MyEditItem.MyStepRTB.SpellCheckContextMenuOn(MyEditItem.MyStepPanel.VwMode != E_ViewMode.View);
}
//private void btnEnhancedDocSync_Click(object sender, System.EventArgs e)
//{
// btnEnhancedDocSync.Checked = !btnEnhancedDocSync.Checked;
//}
private void btnROEdit_Click(object sender, EventArgs e)
{
if (VlnSettings.ReleaseMode.Equals("DEMO"))
{
FlexibleMessageBox.Show("Referenced Object Editor not available in the Demo version.", "PROMS Demo Version");
return;
}
//string roapp = Environment.GetEnvironmentVariable("roapp");
string roapp = Volian.Base.Library.ExeInfo.GetROEditorPath(); // get the path to the RO Editor Executable
if (roapp == null || roapp == string.Empty)
{
FlexibleMessageBox.Show("The 'roapp' environment variable needs to be set to the path of the RO Editor\n\n Ex: C:\\VE-PROMS.NET\\Bin\\roeditor.exe", "Environment Variable Error");
return;
}
if (!File.Exists(roapp))
{
string errtxt = string.Format("Could not find path to Referenced Objects Editor:\n\n roapp = {0}\n\n Verify the path assigned to the 'roapp' environment variable", roapp);
FlexibleMessageBox.Show(errtxt, "Environment Variable Error");
//MessageBox.Show("Could not find path to Ro Editor, check 'roapp' environment variable","Environment Variable Error");
return;
}
//if (roapp == null)
//{
// MessageBox.Show("Could not find path to Ro Editor, check 'roapp' environment variable");
// return;
//}
if (Mydvi == null || Mydvi.DocVersionAssociationCount < 1)
{
FlexibleMessageBox.Show("Could not find associated path for ro data.", "No RO Data", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
string roloc = "\"" + Mydvi.DocVersionAssociations[0].MyROFst.MyRODb.FolderPath + "\"";
if (!Directory.Exists(Mydvi.DocVersionAssociations[0].MyROFst.MyRODb.FolderPath))
{
FlexibleMessageBox.Show(string.Format("RO Database directory does not exist: {0}", Mydvi.DocVersionAssociations[0].MyROFst.MyRODb.FolderPath));
return;
}
// C2017-003: ro data in sql server, check for sql connection string
if (Mydvi.DocVersionAssociations[0].MyROFst.MyRODb.DBConnectionString != "cstring") roloc = roloc + " \"" + Mydvi.DocVersionAssociations[0].MyROFst.MyRODb.DBConnectionString + "\"";
// C2021-026 pass in Parent/Child information (list of the children)
// B2022-019 look at all DocVersions to find ParentChild information
// to ensure we pass in Parent/Child even when not coming from a Parent/Child procedure set
// B2022-073 Break out of the foreach when we find a set with parent/child information
DocVersionInfoList dvil = DocVersionInfoList.Get();
foreach (DocVersionInfo dvi in dvil)
{
DocVersionConfig dvc = dvi.DocVersionConfig as DocVersionConfig;
if (dvc != null && dvc.Unit_Name != "" && dvc.Unit_Count > 1) // B2021-089 only pass in applicability info if defined for more than one unit
{
roloc += " \"PC=" + dvc.Unit_Name + "\"";
break;
}
}
System.Diagnostics.Process.Start(roapp, roloc);
}
private void btnUpdROVal_Click(object sender, EventArgs e)
{
InitialProgressBarMessage = "Updating ROs";
// use rodb directory path of the first rofst for the this document version. Later, will need
// to modify code to get which one (when there is more than one)
if (Mydvi.DocVersionAssociations.Count < 1)
{
FinalProgressBarMessage = "No ROs associated";
FlexibleMessageBox.Show("Error Updating ro.fst", "No associated ro.fst"); //B2017-125 added title to messagebox
return;
}
ROFstInfo roFstInfo = Mydvi.DocVersionAssociations[0].MyROFst;
string rofstPath = roFstInfo.MyRODb.FolderPath + @"\ro.fst";
if (!File.Exists(rofstPath))
{
FinalProgressBarMessage = "No existing RO.FST";
FlexibleMessageBox.Show("No existing ro.fst in path " + roFstInfo.MyRODb.FolderPath + ". Check for invalid path", "No existing RO.FST"); //B2017-125 added title to messagebox
return;
}
// B2017-130 code no longer needed. Was checking the DTS but always was different by miliseconds
//FileInfo fiRofst = new FileInfo(rofstPath);
//if (roFstInfo.DTS == fiRofst.LastWriteTimeUtc)
//{
// FinalProgressBarMessage = "RO.FST up to date";
// MessageBox.Show("ro.fst files are same for path " + roFstInfo.MyRODb.FolderPath + ", import of that ro.fst will not be done", "RO.FST up to date"); //B2017-125 added title to messagebox
// return;
//}
//if (roFstInfo.DTS > fiRofst.LastWriteTimeUtc)
//{
// FinalProgressBarMessage = "RO.FST is older";
// MessageBox.Show("Cannot copy older ro.fst from " + roFstInfo.MyRODb.FolderPath + ", import of that ro.fst will not be done", "RO.FST is older"); //B2017-125 added title to messagebox
// return;
//}
Cursor = Cursors.WaitCursor;
// C2023-001: Check whether docversion can be checked out before continuing with update of ro.fst
string message = string.Empty;
if (!MySessionInfo.CanCheckOutItem(Mydvi.VersionID, CheckOutType.DocVersion, ref message))
{
FlexibleMessageBox.Show(this, message, "Working Draft Has Items Already Checked Out", MessageBoxButtons.OK, MessageBoxIcon.Warning);
FinalProgressBarMessage = "Cannot check-out Working Draft";
Cursor = Cursors.Default;
return;
}
// B2024-002: Save any changes to the database so that updating of ROs has current data:
MyEditItem.SaveContents();
using (DocVersion dv = DocVersion.Get(Mydvi.VersionID))
{
swROUpdate = new System.IO.StreamWriter(ROFstInfo.ROUpdateResultsPath(Mydvi));
// B2022-026 RO Memory Reduction code - first load the new ro.fst so that we can assign the ROTableUpdate event to the correct roFstInfo
if (dv.ROfstLoadingFigures || dv.NewerRoFst) // B2017-125 see if loading figures was completed
{
// only load the RO.fst
ROFstInfo.UpdateRoFst(roFstInfo.MyRODb, dv, roFstInfo, DoProgressBarRefresh);
roFstInfo = Mydvi.DocVersionAssociations[0].MyROFst;
}
roFstInfo.ROTableUpdate += new ROFstInfoROTableUpdateEvent(roFstInfo_ROTableUpdate);
ContentInfo.StaticContentInfoChange += ContentInfo_StaticContentInfoChange; // write changes to a text file
ROFst newrofst = ROFstInfo.RefreshROFst(dv, roFstInfo, DoProgressBarRefresh, null);
swROUpdate.Close();
ContentInfo.StaticContentInfoChange -= ContentInfo_StaticContentInfoChange;
roFstInfo.ROTableUpdate -= new ROFstInfoROTableUpdateEvent(roFstInfo_ROTableUpdate);
StepPanelTabDisplayEventArgs args = new StepPanelTabDisplayEventArgs("DisplayROUpdateROFST");
MyEditItem.MyStepPanel.OnTabDisplay(sender, args);
}
Cursor = Cursors.Default;
FinalProgressBarMessage = "ROs values updated";
}
private System.IO.StreamWriter swROUpdate;
// write the RO reference changes to a text file, include the old/new text, location, and the itemid of the step element
void ContentInfo_StaticContentInfoChange(object sender, StaticContentInfoEventArgs args)
{
if (args.Type == "RO")
swROUpdate.Write(string.Format("Fixed Referenced Object for {1}({4}){0}Old Text: {2}{0}New Text: {3}{0}{0}", Environment.NewLine, (sender as ItemInfo).ShortPath, args.OldValue, args.NewValue, (sender as ItemInfo).ItemID));
}
private ProgressBarItem _ProgressBar = null;
public ProgressBarItem ProgressBar
{
get { return _ProgressBar; }
set { _ProgressBar = value; }
}
private void DoProgressBarRefresh(int value, int max, string text)
{
if (ProgressBar == null) return;
ProgressBar.Maximum = max;
ProgressBar.Value = value;
ProgressBar.Text = text;
ProgressBar.TextVisible = true; //B2017-125 text was not always visible
Application.DoEvents();
}
private string InitialProgressBarMessage
{
set
{
if (ProgressBar == null) return;
ProgressBar.Value = 0;
ProgressBar.Maximum = 100;
ProgressBar.Text = value;
Application.DoEvents();
}
}
private string FinalProgressBarMessage
{
set
{
if (ProgressBar == null) return;
ProgressBar.Value = 100;
ProgressBar.Maximum = 100;
ProgressBar.Text = value;
Application.DoEvents();
}
}
public List<string> roFstInfo_ROTableUpdate(object sender, ROFstInfoROTableUpdateEventArgs args)
{
return VlnFlexGrid.ROTableUpdate(sender, args);
//string xml = null;
//string srchtxt = null;
//Content content = (Content)sender;
//using (VlnFlexGrid myGrid = new VlnFlexGrid(content.ContentItems[0]))
//{
// using (StringReader sr = new StringReader(args.OldGridXml))
// {
// myGrid.ReadXml(sr);
// sr.Close();
// }
// string roid = content.ContentRoUsages[0].ROID; //myGrid.ROID;
// int rodbid = content.ContentRoUsages[0].RODbID; //myGrid.RODbId;
// ////Font GridFont = myGrid.Font;
// //myGrid.MergedRanges.Clear();
// //myGrid.Clear();
// //myGrid.ParseTableFromText(args.ROText);
// //myGrid.AutoSizeCols();
// //myGrid.AutoSizeRows();
// //myGrid.MakeRTFcells();
// //myGrid.RODbId = rodbid;
// //myGrid.ROID = roid;
// //myGrid.IsRoTable = true;
// myGrid.Visible = false;
// myGrid.ConvertTableROToGrid(args.ROText, rodbid, roid);
// myGrid.FixTableCellsHeightWidth();
// myGrid.AdjustGridControlSize();
// myGrid.Visible = true;
// using (StringWriter sw = new StringWriter())
// {
// myGrid.WriteXml(sw);
// xml = sw.GetStringBuilder().ToString();
// sw.Close();
// }
// srchtxt = myGrid.GetSearchableText();
//}
//List<string> retlist = new List<string>();
//retlist.Add(srchtxt);
//retlist.Add(xml);
//return retlist;
}
private void rtabAdmin_Click(object sender, EventArgs e)
{
ribbonTab_SingleClick(sender, e);
btnUpdROVal.Enabled = false;
if (Mydvi.DocVersionAssociations == null || Mydvi.DocVersionAssociations.Count < 1)
{
btnROEdit.Enabled = false;
return;
}
btnROEdit.Enabled = EnableROEdit;
if (!NewerRoFst()) return;
btnUpdROVal.Enabled = true;
}
public bool NewerRoFst()
{
if (_Mydvi == null)return false;
// only allow update if association, and the RO update was not done and/or not completed
return !_Mydvi.ROfstLastCompleted || _Mydvi.NewerRoFst;
}
public void SetUpdRoValBtn(bool en)
{
btnUpdROVal.Enabled = en;
}
private void btnBookmarks_Click(object sender, EventArgs e)
{
StepPanelTabDisplayEventArgs args = new StepPanelTabDisplayEventArgs("Bookmarks");
MyEditItem.MyStepPanel.OnTabDisplay(sender, args);
}
private void btnSearch_Click(object sender, EventArgs e)
{
StepPanelTabDisplayEventArgs args = new StepPanelTabDisplayEventArgs("Global Search");
MyEditItem.MyStepPanel.OnTabDisplay(sender, args);
}
private void btnLibDocs_Click(object sender, EventArgs e)
{
StepPanelTabDisplayEventArgs args = new StepPanelTabDisplayEventArgs("LibDocs");
MyEditItem.MyStepPanel.OnTabDisplay(sender, args);
}
// C2020-033: Support the Review/Incoming Transition button to bring up Search/Incoming Transitions panel
private void btnSearchIncTrans_Click(object sender, EventArgs e)
{
MyEditItem.MyStepPanel.MyStepTabPanel.MyDisplayTabControl.OnSearchIncTrans(this, new vlnTreeItemInfoEventArgs(MyStepRTB.MyItemInfo));
}
public void btnAnnots_Click(object sender, EventArgs e)
{
StepPanelTabDisplayEventArgs args = new StepPanelTabDisplayEventArgs("Annots");
MyEditItem.MyStepPanel.OnTabDisplay(sender, args);
}
public void btnDelStep_Click(object sender, EventArgs e)
{
bool clearCopyStep = false;
StepTabPanel tmp = Parent as StepTabPanel;
if (tmp.MyDisplayTabControl.MyCopyStep != null &&
tmp.MyDisplayTabControl.MyCopyStep.ItemID == MyEditItem.MyItemInfo.ItemID)
{
if (FlexibleMessageBox.Show("Are you sure?\n\nIf you delete this step you will not able to paste it.\nYou should paste it before you delete it.", "Attempting to delete copied step.", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) return;
clearCopyStep = true;
}
bool surpressMessageBox = (e == null);
SectionInfo si = MyEditItem.MyItemInfo as SectionInfo;
if (si != null)
{
//C2020-026 specific description of what user is trying to delete
string msg = "Are you sure you want to delete this Section" + (si.HasChildren ? " and its steps?" : "?");
DialogResult result = FlexibleMessageBox.Show(msg, "Verify Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (result == DialogResult.Yes)
{
if (!si.IsStepSection)
{
WordSectionEventArgs args = new WordSectionEventArgs(si);
MyEditItem.MyStepPanel.OnWordSectionClose(sender, args);
}
MyEditItem.RemoveItem();
}
return;
}
StepInfo stpi = MyEditItem.MyItemInfo as StepInfo;
if (stpi == null) // not sure that it will every get here!
{
FlexibleMessageBox.Show("Unknown type {0}, cannot delete!", MyEditItem.MyItemInfo.GetType().Name);
return;
}
if (!surpressMessageBox)
{
string typeDescription = MyEditItem.MyStepData.StepEditData.TypeMenu.MenuItem;
string msgs = "";
if (MyFlexGrid != null) MyEditItem.IdentifyMe(true);
MyEditItem.IdentifyChildren(true);
//C2020-026 specific description of what user is trying to delete
if (stpi.HasChildren)
msgs = string.Format("Are you sure you want to delete this \"{0}\" and its substeps?", typeDescription);
else
msgs = string.Format("Are you sure you want to delete this \"{0}\"?", typeDescription);
if (stpi.HasEnhancedLinkedStep)
msgs = msgs + "\n\n The linked Enhanced step will also be deleted!";
DialogResult results = FlexibleMessageBox.Show(msgs, "Verify Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (MyFlexGrid != null)
{
MyFlexGrid.Styles.Fixed.BackColor = MyFlexGrid.DefaultFixedBackgroundColor;
MyFlexGrid.StyleBackColor = MyFlexGrid.DefaultCellBackgroundcolor;
}
MyEditItem.IdentifyChildren(false);
if (results == DialogResult.Yes)
{
MyEditItem.RemoveItem();
if (clearCopyStep)
{
tmp.MyDisplayTabControl.MyCopyStep = null;
tmp.MyDisplayTabControl.OnCopyStepSelected(null); // C2015-022 event to save copystep info in all of the separate windows
SetPasteButtonEnabled();
}
}
}
else
{
MyEditItem.RemoveItem();
if (clearCopyStep)
{
tmp.MyDisplayTabControl.MyCopyStep = null;
tmp.MyDisplayTabControl.OnCopyStepSelected(null); // C2015-022 event to save copystep info in all of the separate windows
SetPasteButtonEnabled();
}
}
}
private void btnCMIns_PopupClose(object sender, EventArgs e)
{
_ContextMenuBar.SetContextMenuEx(_MyStepRTB, _DefaultContextMenu);
}
public void SetShortCutContextMenu(string menuName)
{
bool displayMenu = false;
int moveDown = 0;
int cnt = 0;
E_AccStep? actable = 0;
if (menuName.Contains("PSI")) Console.WriteLine("menu = {0}", menuName);
StepData sd = MyItemInfo==null?null:MyItemInfo.FormatStepData;
if (sd != null) // will be null if section
{
actable = sd.StepEditData.AcTable;
if (actable == null) actable = 0;
}
//btnInsCaut.Enabled = (actable & E_AccStep.AddingCaution) > 0;
switch (menuName)
{
case "OpenRtfRawContextMenu":
ClearContextMenu();
FlexibleMessageBox.Show("No context menu for equations.");
break;
case "PSI":
displayMenu = true;
_ContextMenuBar.SetContextMenuEx(_MyStepRTB, btnCMPSI);
break;
case "InsHLS":
displayMenu = btnCMInsHLS.Enabled;
Cursor.Position = new Point(0, 0); // Enter Key hit, move mouse pointer out of way of context menu
_ContextMenuBar.SetContextMenuEx(_MyStepRTB, btnCMInsHLS);
string lookfor = "XXX";
if(_MyStepRTB.MyItemInfo.MyHLS != null)
lookfor = " " + (_MyStepRTB.MyItemInfo.MyHLS.MyContent.Type - 20000).ToString();
foreach (DevComponents.DotNetBar.ButtonItem bi in btnCMInsHLS.SubItems)
{
if (bi.Checked)
moveDown = cnt;
if(((string) bi.Tag).EndsWith(lookfor))
moveDown = cnt;
cnt++;
}
break;
case "InsRNO":
displayMenu = ((actable & E_AccStep.AddingRNO) > 0) && btnCMInsRNO.Enabled;
LetUserKnowIfTheyCannotAdd(actable, E_AccStep.AddingRNO,"RNO"); // B2018-014 Inform user that they cannot add the specified step type
_ContextMenuBar.SetContextMenuEx(_MyStepRTB, btnCMInsRNO);
break;
case "InsSubStps":
displayMenu = ((actable & E_AccStep.AddingSub) > 0) && btnCMInsSubStps.Enabled;
LetUserKnowIfTheyCannotAdd(actable, E_AccStep.AddingSub,"Sub-step"); // B2018-014 Inform user that they cannot add the specified step type
_ContextMenuBar.SetContextMenuEx(_MyStepRTB, btnCMInsSubStps);
if (displayMenu) Cursor.Position = new Point(0, 0); // Enter Key hit, move mouse pointer out of way of context menu
foreach (DevComponents.DotNetBar.ButtonItem bi in btnCMInsSubStps.SubItems)
{
if (bi.Checked)
moveDown = cnt;
cnt++;
}
// F2021-009 If in Proms Express, let user know if they are going to create a new substep deeper than the defined sub-step levels
if (MyItemInfo.ActiveFormat.PlantFormat.FormatData.Express && MyItemInfo.GetStepLevel() >= MyItemInfo.GetDefinedSubStepCount())
{
string msg = "Professional procedure writing standards (PPA) discourages\n" +
"excessive sub-step levels. With each sub-step level, there\n" +
"is less room for text, which could lead to steps that are\n" +
"difficult to follow.";
FlexibleMessageBox.Show(msg, "PPA Writing Standards", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
break;
case "InsCaution":
displayMenu = ((actable & E_AccStep.AddingCaution) > 0) && btnCMInsCaution.Enabled;
LetUserKnowIfTheyCannotAdd(actable, E_AccStep.AddingCaution,"Caution"); // B2018-014 Inform user that they cannot add the specified step type
_ContextMenuBar.SetContextMenuEx(_MyStepRTB, btnCMInsCaution);
break;
case "InsNote":
displayMenu = ((actable & E_AccStep.AddingNote) > 0) && btnCMInsNote.Enabled;
LetUserKnowIfTheyCannotAdd(actable, E_AccStep.AddingNote,"Note"); // B2018-014 Inform user that they cannot add the specified step type
_ContextMenuBar.SetContextMenuEx(_MyStepRTB, btnCMInsNote);
break;
case "InsTable":
displayMenu = ((actable & E_AccStep.AddingTable) > 0) && btnCMInsTable.Enabled;
LetUserKnowIfTheyCannotAdd(actable, E_AccStep.AddingTable,"Table"); // B2018-014 Inform user that they cannot add the specified step type
_ContextMenuBar.SetContextMenuEx(_MyStepRTB, btnCMInsTable);
break;
case "InsFigure":
displayMenu = ((actable & E_AccStep.AddingTable) > 0) && btnCMInsFigure.Enabled;
LetUserKnowIfTheyCannotAdd(actable, E_AccStep.AddingTable,"Figure"); // B2018-014 Inform user that they cannot add the specified step type
_ContextMenuBar.SetContextMenuEx(_MyStepRTB, btnCMInsFigure);
break;
case "InsEquation":
displayMenu = ((actable & E_AccStep.AddingTable) > 0) && btnCMInsEquation.Enabled;
LetUserKnowIfTheyCannotAdd(actable, E_AccStep.AddingTable,"Equation"); // B2018-014 Inform user that they cannot add the specified step type
_ContextMenuBar.SetContextMenuEx(_MyStepRTB, btnCMInsEquation);
break;
case "StepPaste":
displayMenu = true;
if (MyFlexGrid != null)
_ContextMenuBar.SetContextMenuEx(MyFlexGrid, btnCMStepPaste);
else
_ContextMenuBar.SetContextMenuEx(_MyStepRTB, btnCMStepPaste);
break;
}
if (displayMenu && UserInfo.CanEdit(MyUserInfo, Mydvi))
{
SendKeys.Send("+{F10}{DOWN}"); // Display Context menu
while (moveDown > 0) // position to current type
{
SendKeys.Send("{DOWN}");
moveDown--;
}
}
}
private void LetUserKnowIfTheyCannotAdd(E_AccStep? actable, E_AccStep e_AccStep, string stepType) // B2018-014 Inform user that they cannot add the specified step type
{
if ((actable & e_AccStep) > 0) return;
string msg = string.Format("Cannot add a {0} to this step type. If this is desired please contact Volian to change your format", stepType);
string cpt = string.Format("Cannot add {0}", stepType);
FlexibleMessageBox.Show(msg, cpt, MessageBoxButtons.OK, MessageBoxIcon.Information);
}
private void btnSpell_Click(object sender, EventArgs e)
{
//MessageBox.Show("Functionality not available.", "Spell Check");
MyEditItem.SaveContents();
StepPanelTabDisplayEventArgs args = new StepPanelTabDisplayEventArgs("SpellChecker");
MyEditItem.MyStepPanel.OnTabDisplay(sender, args);
}
private void btnTranRefresh_Click(object sender, System.EventArgs e)
{
// This code is disabled - Button is not visible
this.Cursor = Cursors.WaitCursor;
ProcedureInfo.RefreshTransitions(MyItemInfo.MyProcedure as ProcedureInfo);
this.Cursor = Cursors.Default;
// B2018-002 - Invalid Transitions - Display Transition Refresh Statistics
FlexibleMessageBox.Show(this, string.Format("Checked {0} transitions, modified {1} transitions, converted to text {2} transitions, {3} transitions unable to be fixed (Annotation: Bad Transition Link)", ProcedureInfo.TranCheckCount, ProcedureInfo.TranFixCount, ProcedureInfo.TranConvertCount, ProcedureInfo.TranCantFixCount), "Results of Refresh Transitions", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
private void btnRefObjRefresh_Click(object sender, System.EventArgs e)
{
//// This code is disabled - Button is not visible
//this.Cursor = Cursors.WaitCursor;
// ProcedureInfo.ResetROCounters();
// ProcedureInfo.RefreshReferenceObjects(MyItemInfo.MyProcedure as ProcedureInfo);
// this.Cursor = Cursors.Default;
//FlexibleMessageBox.Show(this, string.Format("Checked {0} referenced objects, fixed {1} referenced objects", ProcedureInfo.ROCheckCount, ProcedureInfo.ROFixCount), "Results of Refresh Referenced Objects", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
//private FindReplace dlgFindReplace = null;
private void btnFindRplDlg_Click(object sender, EventArgs e)
{
if (MyEditItem == null || MyEditItem.MyStepPanel == null) return;
StepPanelTabDisplayEventArgs args = new StepPanelTabDisplayEventArgs("FndRpl");
MyEditItem.MyStepPanel.OnTabDisplay(sender, args);
}
private void InsertSiblingBeforeOrAfter(string b4aftr)
{
E_AccStep? actable = 0;
StepData sd = MyItemInfo.FormatStepData;
actable = sd.StepEditData.AcTable;
if (actable == null) actable = 0;
switch (b4aftr)
{
case "after":
if ((actable & E_AccStep.AddingNext) > 0)
MyEditItem.AddSiblingAfter();
break;
case "before":
if ((actable & E_AccStep.AddingPrev) > 0)
MyEditItem.AddSiblingBefore();
break;
}
}
public void ProcessEnterKey()
{
bool deletedEmpty = false;
bool deletedHLS = false;
bool deletedSubStep = false;
bool deletedRNO = false;
bool deletedNote = false;
bool deletedCaution = false;
ItemInfo parentOfDeleted = null;
if (!MyItemInfo.IsTable && MyStepRTB.Text.Length < 1) //empty step text
{
deletedEmpty = true;
deletedHLS = MyItemInfo.IsHigh;
deletedSubStep = MyItemInfo.IsStepPart;
deletedRNO = MyItemInfo.IsRNOPart;
deletedNote = MyItemInfo.IsNote;
deletedCaution = MyItemInfo.IsCaution;
parentOfDeleted = MyItemInfo.MyParent; // B2020-015 save the parent of the empty step part that was deleted
btnDelStep_Click(MyStepRTB, null); // delete the empty step piece
}
if (MyItemInfo.IsHigh)
{
bool processed = true;
if (!deletedHLS)
{
if (deletedSubStep)
{
// B2019-136 if only one high level step type, don't display a pop up menu of high level step types
if (btnCMInsHLS.SubItems.Count > 1)
SetShortCutContextMenu("InsHLS");
else
InsertSiblingBeforeOrAfter("after");
}
else if (MyEditItem.MyRNOEditItems != null && MyEditItem.MyRNOEditItems.Count > 0)
MyStepRTB.StepRTB_ArrowPressed(E_ArrowKeys.CtrlRight); // jump to RNO
else if (deletedRNO)
{
processed = AddSubStep(); // B2020-015 see comment below
}
else if (!deletedHLS)
{
if (MyItemInfo.ColumnMode > 0)
CreateNewRNO();
else
processed = AddSubStep(); // B2020-015 see comment below
}
}
if (processed) return;
}
// B2020-015 Replaced the "else if" with just an "if". The code above processes pressing the Enter Key when starting on a high level step.
// We needed to have a special case when, during the processing of the enter key, we ended up on a table or figure. In those cases
// it was inserting a new table or figure before the existing one. Instead, we want it to process it as if we starting pressing
// the enter key while on the table or figure. By returning a "false" from AddSubStep(), we can let it fall through so that
// it is processed properly.
if (MyItemInfo.IsRNOPart)
{
// B2013-154: if in single column mode, enter key from an RNO part should insert an RNO part:
if (MyItemInfo.ColumnMode == 0)
{
CreateNewRNO();
return;
}
// B2020-015 We are on an RNO step type. Spin up the first non-RNO parent then decide what step part to add.
// Prior to this fix, an un-typed step part was created when you pressed Enter from a second RNO
ItemInfo ii = MyItemInfo;
while (ii.IsRNOPart) ii = ii.MyParent;
MyEditItem.MyStepPanel.MyStepTabPanel.MyDisplayTabControl.OpenItem(ii);
if (MyItemInfo.IsHigh)
{
if (MyEditItem != null && MyEditItem.NextDownEditItem != null &&
!MyEditItem.NextDownEditItem.MyItemInfo.IsTable && !MyEditItem.NextDownEditItem.MyItemInfo.IsFigure &&
MyEditItem.NextDownEditItem.MyItemInfo.MyParent.ItemID == MyEditItem.MyItemInfo.ItemID)
{
MyStepRTB.StepRTB_ArrowPressed(E_ArrowKeys.CtrlDown);
InsertSiblingBeforeOrAfter("before");
}
else
SetShortCutContextMenu("InsSubStps");
}
else
InsertSiblingBeforeOrAfter("after");
}
else if (MyItemInfo.IsInRNO && MyItemInfo.IsStepPart)
{
if (deletedEmpty)
{
MyEditItem.MyStepPanel.MyStepTabPanel.MyDisplayTabControl.OpenItem(parentOfDeleted);
if (parentOfDeleted.IsHigh)
{
if (!AddSubStep())
SetShortCutContextMenu("InsSubStps");
}
else if (!MyItemInfo.IsRNOPart)
InsertSiblingBeforeOrAfter("after");
}
else
InsertSiblingBeforeOrAfter("after");
}
else if (MyItemInfo.IsInRNO &&( MyItemInfo.IsTable || MyItemInfo.IsFigure))
{
if (deletedEmpty)
{
while (parentOfDeleted.IsRNOPart)
parentOfDeleted = parentOfDeleted.MyParent;
MyEditItem.MyStepPanel.MyStepTabPanel.MyDisplayTabControl.OpenItem(parentOfDeleted);
if (parentOfDeleted.IsHigh)
{
if (!AddSubStep())
SetShortCutContextMenu("InsSubStps");
}
else
InsertSiblingBeforeOrAfter("after");
}
else
{
ItemInfo tItemInfo = MyItemInfo.MyParent;
while (tItemInfo.IsRNOPart) tItemInfo = tItemInfo.MyParent;
MyEditItem.MyStepPanel.MyStepTabPanel.MyDisplayTabControl.OpenItem(tItemInfo);
if (MyItemInfo.IsHigh)
{
if (!AddSubStep())
SetShortCutContextMenu("InsSubStps");
}
else
InsertSiblingBeforeOrAfter("after");
}
}
else if (MyItemInfo.IsStepPart)
{
if (deletedSubStep)
{
// B2020-015 jump to the parent of the empty step part that was deleted
MyEditItem.MyStepPanel.MyStepTabPanel.MyDisplayTabControl.OpenItem(parentOfDeleted);
if (MyItemInfo.IsHigh)
SetShortCutContextMenu("InsHLS"); // prompt for new HLS
else
InsertSiblingBeforeOrAfter("after");
}
else if (!MyItemInfo.IsSequential) // only add a sibling if substep type does not have sequential tabs
InsertSiblingBeforeOrAfter("after");
else if (deletedRNO)
{
InsertSiblingBeforeOrAfter("after");
}
else if (MyEditItem.MyRNOEditItems != null && MyEditItem.MyRNOEditItems.Count > 0)
MyStepRTB.StepRTB_ArrowPressed(E_ArrowKeys.CtrlRight); // jump to RNO
else
if (MyItemInfo.ColumnMode > 0)
CreateNewRNO();
else
InsertSiblingBeforeOrAfter("after");
}
else if (MyItemInfo.IsCaution)
{
if (deletedEmpty)
{
MyStepRTB.StepRTB_ArrowPressed(E_ArrowKeys.CtrlDown);
if (deletedCaution)
CreateNewNote();
}
else
InsertSiblingBeforeOrAfter("after");
}
else if (MyItemInfo.IsNote)
{
if (!deletedEmpty)
InsertSiblingBeforeOrAfter("after");
else if (!deletedCaution)
MyStepRTB.StepRTB_ArrowPressed(E_ArrowKeys.CtrlDown);
}
else if (MyItemInfo.IsTable || MyItemInfo.IsFigure || MyItemInfo.IsRtfRaw) //is Table, Figure, or Equation
{
ItemInfo next = (deletedEmpty && !deletedHLS)? parentOfDeleted : MyItemInfo.MyParent;
while (next.IsTable || next.IsFigure || next.IsRtfRaw) next = next.MyParent;
MyEditItem.MyStepPanel.MyStepTabPanel.MyDisplayTabControl.OpenItem(next);
if (MyItemInfo.IsHigh)
{
if (!deletedHLS)
{
if (deletedSubStep)
SetShortCutContextMenu("InsHLS");
else if (!deletedNote && !deletedCaution)
SetShortCutContextMenu("InsSubStps");
}
}
else if (!deletedNote && !deletedCaution)
InsertSiblingBeforeOrAfter("after");
}
}
private bool AddSubStep()
{
EditItem nextDownEditItem = MyEditItem.NextDownEditItem;
if (nextDownEditItem != null && nextDownEditItem.MyItemInfo.MyParent.ItemID == MyEditItem.MyID)
{
MyStepRTB.StepRTB_ArrowPressed(E_ArrowKeys.CtrlDown);
// B2020-015 when nextDownEditItem is a table or figure, we want to treat it as if we started pressing the Enter Key while on that table or figure.
// Return "false' in this case so it can be processed properly
if (nextDownEditItem.MyItemInfo.IsTable || nextDownEditItem.MyItemInfo.IsFigure)
return false;
InsertSiblingBeforeOrAfter("before");
}
else
SetShortCutContextMenu("InsSubStps");
return true;
}
private void CreateNewRNO()
{
if (btnInsRNO.SubItems.Count > 1)
SetShortCutContextMenu("InsRNO");
else
btnInsRNO.RaiseClick();
}
private void CreateNewNote()
{
if (btnInsNote.SubItems.Count > 1)
SetShortCutContextMenu("InsNote");
else
btnInsNote.RaiseClick();
}
private void btnPasteAfter_Click(object sender, EventArgs e)
{
StepTabPanel tmp = Parent as StepTabPanel;
if (tmp.MyDisplayTabControl.MyCopyStep == null) return;
// B2016-009 check source and desintation types and display message box if needed
// C2022-017 check for user canceling the paste step
if (!ItemInfo.CheckSourceDestinationType(tmp.MyDisplayTabControl.MyCopyStep.ItemID, MyItemInfo)) return;
SaveTableChanges(); // B2018-055 Save Current Changes to the table
// F2021-009 display a message if pasting step will results in more sub-step levels than are defined in the format
ItemInfo.PasteStepIsWithinDefinedSubStepLevels(tmp.MyDisplayTabControl.MyCopyStep.ItemID, MyItemInfo, false);
MyEditItem.PasteSiblingAfter(tmp.MyDisplayTabControl.MyCopyStep.ItemID);
}
private void btnPasteBefore_Click(object sender, EventArgs e)
{
StepTabPanel tmp = Parent as StepTabPanel;
if (tmp.MyDisplayTabControl.MyCopyStep == null) return;
// B2016-009 check source and desintation types and display message box if needed
// C2022-017 check for user canceling the paste step
if (!ItemInfo.CheckSourceDestinationType(tmp.MyDisplayTabControl.MyCopyStep.ItemID, MyItemInfo)) return;
SaveTableChanges(); // B2018-055 Save Current Changes to the table
// F2021-009 display a message if pasting step will results in more sub-step levels than are defined in the format
ItemInfo.PasteStepIsWithinDefinedSubStepLevels(tmp.MyDisplayTabControl.MyCopyStep.ItemID, MyItemInfo, false);
MyEditItem.PasteSiblingBefore(tmp.MyDisplayTabControl.MyCopyStep.ItemID);
}
private void btnStepPaste_Click(object sender, EventArgs e)
{
// just return
}
private void btnCpyStp_Click(object sender, EventArgs e)
{
DoCopyStep();
}
public void DoCopyStep()
{
// highlight selected step(s) and prompt to see if selection is what user wants:
if (MyFlexGrid != null) MyEditItem.IdentifyMe(true);
MyEditItem.IdentifyChildren(true);
DialogResult dr = FlexibleMessageBox.Show("Step as Marked?", "Identify Step To Be Copied", MessageBoxButtons.YesNo);
if (dr == DialogResult.Yes)
{
StepTabPanel tmp = Parent as StepTabPanel;
tmp.MyDisplayTabControl.MyCopyStep = MyItemInfo;
tmp.MyDisplayTabControl.OnCopyStepSelected(null); // C2015-022 event to save copystep info in all of the separate windows
btnStepPaste.Enabled = true;
SetPasteButtonEnabled();
}
if (MyFlexGrid != null)
{
MyFlexGrid.Styles.Fixed.BackColor = MyFlexGrid.DefaultFixedBackgroundColor;
MyFlexGrid.StyleBackColor = MyFlexGrid.DefaultCellBackgroundcolor;
}
MyEditItem.IdentifyChildren(false);
}
private void btnPasteReplace_Click(object sender, EventArgs e)
{
StepTabPanel tmp = Parent as StepTabPanel;
if (tmp.MyDisplayTabControl.MyCopyStep == null) return;
// B2016-009 check source and desintation types and display message box if needed
// C2022-017 check for user canceling the paste step
if (!ItemInfo.CheckSourceDestinationType(tmp.MyDisplayTabControl.MyCopyStep.ItemID, MyItemInfo)) return;
// F2021-009 display a message if pasting step will results in more sub-step levels than are defined in the format
ItemInfo.PasteStepIsWithinDefinedSubStepLevels(tmp.MyDisplayTabControl.MyCopyStep.ItemID, MyItemInfo, true);
EditItem oldEditItem = MyEditItem;
// C2017-031: Support for paste/replace an enhanced step, if pasting an enhanced, remove its EditItem from the 'cache'. A new EditItem gets created during paste.
if (MyEditItem != null && MyEditItem.MyItemInfo.IsEnhancedStep) MyEditItem.MyStepPanel._LookupEditItems.Remove(MyEditItem.MyItemInfo.ItemID);
MyEditItem = MyEditItem.PasteReplace(tmp.MyDisplayTabControl.MyCopyStep.ItemID);
if (MyEditItem == null) oldEditItem.IdentifyMe(false); // B2017-179 if null then we didn't do the replace but did position to the first transition that needs resolved
// C2017-031: Support for paste/replace an enhanced step, add Dispose of old EditItem if enhanced
if (MyEditItem != null && ((MyEditItem.MyItemInfo.ItemID != oldEditItem.MyItemInfo.ItemID) || MyEditItem.MyItemInfo.IsEnhancedStep))
oldEditItem.Dispose();
// C2017-031: Support for paste/replace an enhanced step, refresh ItemInfo's in user interface caches.
if (MyEditItem.MyItemInfo.IsEnhancedStep)
{
MyEditItem.MyItemInfo = ItemInfo.Get(MyEditItem.MyItemInfo.ItemID);
tmp.MyStepPanel.SelectedItemInfo = ItemInfo.Get(MyEditItem.MyItemInfo.ItemID);
}
}
private void btnPdfCreate_Click(object sender, EventArgs e)
{
if (MyItemInfo == null) return; // if creating a pdf before rtb exists, return;
if (MyEditItem != null) MyEditItem.SaveCurrentAndContents();
OnPrintRequest(new StepTabRibbonEventArgs(MyItemInfo.MyProcedure), 0);
}
private void btnPdfQuickCreate_Click(object sender, EventArgs e)
{
if (MyItemInfo == null) return; // if creating a pdf before rtb exists, return;
if (MyEditItem != null) MyEditItem.SaveCurrentAndContents();
OnPrintRequest(new StepTabRibbonEventArgs(MyItemInfo.MyProcedure), 1);
}
private void btnCASCreate_Click(object sender, EventArgs e)
{
if (MyItemInfo == null) return; // if creating a Continuous Action Summary before rtb exists, return;
if (MyEditItem != null) MyEditItem.SaveCurrentAndContents();
OnContActionSummaryRequest(new StepTabRibbonEventArgs(MyItemInfo.MyProcedure));
}
#region Table Grid
#region TablePicker code
// TODO: for tables
//private void btnInsTable_Click(object sender, EventArgs e)
//{
// Point loc = btnInsTable.DisplayRectangle.Location;
// loc.X += 300;
// int top = this.Top + (btnInsTable.Size.Height * 2);
// TablePickerDlg(sender, e, loc, top);
//}
private VlnFlexGrid CreateNewTable()
{
Point pt = Cursor.Position;
int left = pt.X;
VlnFlexGrid grd = null;
TablePicker tpdlg = new TablePicker();
tpdlg.Location = pt;
tpdlg.Left = left;
tpdlg.MaxCols = 20;
tpdlg.MaxRows = 30;
DialogResult dr = tpdlg.ShowDialog();
while (tpdlg.Visible)
{
Application.DoEvents();
}
if (dr != DialogResult.Cancel) //!tpdlg.Cancel)
{
// Create a new grid to store the selected size
grd = new VlnFlexGrid();
grd.Rows.Count = tpdlg.SelectedRows;
grd.Cols.Count = tpdlg.SelectedColumns;
VE_Font vefont = MyItemInfo.ActiveFormat.PlantFormat.FormatData.StepDataList.Table.Font;
Font GridFont = new Font(vefont.Family, (float)vefont.Size);
grd.Font = GridFont;
grd.FitTableToPageWidth((int)(MyItemInfo.MyDocStyle.Layout.PageWidth - MyItemInfo.MyDocStyle.Layout.LeftMargin));
}
return grd;
}
//private void InitializeNewGrid(C1FlexGrid grd)
//{
// int numCols = grd.Cols.Count - 1;
// int numRows = grd.Rows.Count - 1;
// string defText = "";
// if (textBoxX1.Text.Length > 0)
// defText = textBoxX1.Text;
// else
// defText = textBoxX1.WatermarkText;
// grd.SetData(grd.GetCellRange(0, 0, numRows, numCols), defText);
//}
#endregion
#region Table Grid Copy/Paste
private void btnTblDgnCopyRow_Click(object sender, EventArgs e)
{
MyFlexGrid.CopyRow();
}
private void btnTblDgnCopyColumn_Click(object sender, EventArgs e)
{
MyFlexGrid.CopyColumn();
}
private void btnTblDgnCopySelection_Click(object sender, EventArgs e)
{
MyFlexGrid.CopyCellSelection();
}
private void btnTblDgnPasteRowAbove_Click(object sender, EventArgs e)
{
// create new rows before current position and copy clipboard data
MyFlexGrid.PasteRows(VlnFlexGrid.enmPastePos.Before);
GridItem tmp = MyEditItem as GridItem;
if (tmp!=null) tmp.SavePastedCellRoTran();
}
private void btnTblDgnPasteRowBelow_Click(object sender, EventArgs e)
{
// create new rows after current position and copy clipboard data
MyFlexGrid.PasteRows(VlnFlexGrid.enmPastePos.After);
GridItem tmp = MyEditItem as GridItem;
if (tmp != null) tmp.SavePastedCellRoTran();
}
private void btnTblDgnPasteReplaceRow_Click(object sender, EventArgs e)
{
// replace rows with current clipboard data starting as current row
MyFlexGrid.PasteRows(VlnFlexGrid.enmPastePos.Replace);
GridItem tmp = MyEditItem as GridItem;
if (tmp != null) tmp.SavePastedCellRoTran();
}
private void btnTblDgnPasteColumnLeft_Click(object sender, EventArgs e)
{
MyFlexGrid.PasteColumns(VlnFlexGrid.enmPastePos.Before);
GridItem tmp = MyEditItem as GridItem;
if (tmp != null) tmp.SavePastedCellRoTran();
}
private void btnTblDgnPasteColumnRight_Click(object sender, EventArgs e)
{
MyFlexGrid.PasteColumns(VlnFlexGrid.enmPastePos.After);
GridItem tmp = MyEditItem as GridItem;
if (tmp != null) tmp.SavePastedCellRoTran();
}
private void btnTblDgnPasteColumnReplace_Click(object sender, EventArgs e)
{
MyFlexGrid.PasteColumns(VlnFlexGrid.enmPastePos.Replace);
GridItem tmp = MyEditItem as GridItem;
if (tmp != null) tmp.SavePastedCellRoTran();
}
private void btnTblDgnPasteIntoSelection_Click(object sender, EventArgs e)
{
MyFlexGrid.PasteCopiedCells();
GridItem tmp = MyEditItem as GridItem;
if (tmp != null) tmp.SavePastedCellRoTran();
}
#endregion
#region Table Grid Delete
private void btnTblDgnRemoveRow_Click(object sender, EventArgs e)
{
if (MyFlexGrid.AllRowsSelected())
btnDelStep_Click(sender, e);
else
MyFlexGrid.RemoveSelectedRow();
}
private void btnTblDgnRemoveColumn_Click(object sender, EventArgs e)
{
if (MyFlexGrid.AllColumnsSelected())
btnDelStep_Click(sender, e);
else
MyFlexGrid.RemoveSelectedColumn();
}
#endregion
#region Table Grid Cell Style
//private void cpHighlight_SelectedColorChanged(object sender, EventArgs e)
//{
// string strColor = string.Format("{0}, {1}, {2};", cpTblDgnHighlight.SelectedColor.R, cpTblDgnHighlight.SelectedColor.G, cpTblDgnHighlight.SelectedColor.B);
// MyFlexGrid.ChangeBackgroundColor(strColor);
//}
private void btnTblDgnAlgnTxTopLeft_Click(object sender, EventArgs e)
{
MyFlexGrid.ChangeCellAlign(MyFlexGrid.Selection, C1.Win.C1FlexGrid.TextAlignEnum.LeftTop);
MyFlexGrid.RTFTextAlignment(MyFlexGrid.Selection, HorizontalAlignment.Left);
}
private void btnTblDgnAlgnTxTopCenter_Click(object sender, EventArgs e)
{
MyFlexGrid.ChangeCellAlign(MyFlexGrid.Selection, C1.Win.C1FlexGrid.TextAlignEnum.CenterTop);
MyFlexGrid.RTFTextAlignment(MyFlexGrid.Selection, HorizontalAlignment.Center);
}
private void btnTblDgnAlgnTxTopRight_Click(object sender, EventArgs e)
{
MyFlexGrid.ChangeCellAlign(MyFlexGrid.Selection, C1.Win.C1FlexGrid.TextAlignEnum.RightTop);
MyFlexGrid.RTFTextAlignment(MyFlexGrid.Selection, HorizontalAlignment.Right);
}
private void btnTblDgnAlgnTxCenterLeft_Click(object sender, EventArgs e)
{
MyFlexGrid.ChangeCellAlign(MyFlexGrid.Selection, C1.Win.C1FlexGrid.TextAlignEnum.LeftCenter);
MyFlexGrid.RTFTextAlignment(MyFlexGrid.Selection, HorizontalAlignment.Left);
}
private void btnTblDgnAlgnTxCenterCenter_Click(object sender, EventArgs e)
{
MyFlexGrid.ChangeCellAlign(MyFlexGrid.Selection, C1.Win.C1FlexGrid.TextAlignEnum.CenterCenter);
MyFlexGrid.RTFTextAlignment(MyFlexGrid.Selection, HorizontalAlignment.Center);
}
private void btnTblDgnAlgnTxCenterRight_Click(object sender, EventArgs e)
{
MyFlexGrid.ChangeCellAlign(MyFlexGrid.Selection, C1.Win.C1FlexGrid.TextAlignEnum.RightCenter);
MyFlexGrid.RTFTextAlignment(MyFlexGrid.Selection, HorizontalAlignment.Right);
}
private void btnTblDgnAlgnTxBottomLeft_Click(object sender, EventArgs e)
{
MyFlexGrid.ChangeCellAlign(MyFlexGrid.Selection, C1.Win.C1FlexGrid.TextAlignEnum.LeftBottom);
MyFlexGrid.RTFTextAlignment(MyFlexGrid.Selection, HorizontalAlignment.Left);
}
private void btnTblDgnAlgnTxBottomCenter_Click(object sender, EventArgs e)
{
MyFlexGrid.ChangeCellAlign(MyFlexGrid.Selection, C1.Win.C1FlexGrid.TextAlignEnum.CenterBottom);
MyFlexGrid.RTFTextAlignment(MyFlexGrid.Selection, HorizontalAlignment.Center);
}
private void btnTblDgnAlgnTxBottomRight_Click(object sender, EventArgs e)
{
MyFlexGrid.ChangeCellAlign(MyFlexGrid.Selection, C1.Win.C1FlexGrid.TextAlignEnum.RightBottom);
MyFlexGrid.RTFTextAlignment(MyFlexGrid.Selection, HorizontalAlignment.Right);
}
#endregion
#region Table Grid Merge/Split
private void btnTblDgnSplitCells_ToRows_Click(object sender, EventArgs e)
{
// without the BeginUpdate/EndUpdate, you will see the table jump around while
// it is being adjusted
MyFlexGrid.BeginUpdate();
MyFlexGrid.SplitSelection(false);
MyFlexGrid.EndUpdate();
}
#endregion
private void btnTblDgnSplitCellsToCols_Click(object sender, EventArgs e)
{
// without the BeginUpdate/EndUpdate, you will see the table jump around while
// it is being adjusted
MyFlexGrid.BeginUpdate();
MyFlexGrid.SplitSelection(true);
MyFlexGrid.EndUpdate();
}
private void btnTblDgnMergeCells_Click(object sender, EventArgs e)
{
MyFlexGrid.MergeSelection();
}
#endregion
#region Table Grid Design
private void btnTblDgnInsertRowAbove_Click(object sender, EventArgs e)
{
MyFlexGrid.InsertRowBefore();
}
private void btnTblDgnInsertRowBelow_Click(object sender, EventArgs e)
{
MyFlexGrid.InsertRowAfter();
}
private void btnTblDgnInsertColumnBefore_Click(object sender, EventArgs e)
{
MyFlexGrid.InsertColumnBefore();
}
private void btnTblDgnInsertColumnAfter_Click(object sender, EventArgs e)
{
MyFlexGrid.InsertColumnAfter();
}
public void ToggleTableFontSize(bool visible)
{
bool visl = visible;
if (MyFlexGrid != null)
{
if (MyFlexGrid.IsRoTable) visl = false;
}
btnCMChgFontSize.Visible = visl;
// C2021-005 - setup the font size dropdowns for the table ribbon and context menu
// A list of font sizes is set in the base format file and can be overidden in a plant's format file
string tfntszs = MyItemInfo.ActiveFormat.PlantFormat.FormatData.FontSizes.TableFontSizes;
// B2021-090 If the current formats were not updated then there will be no list of table font sizes
// so in this case we want to disable the font size dropdown list in the table ribbon and in the context menu
if (tfntszs == null)
{
btnCMChgFontSize.Enabled = false;
rbTblFont.Enabled = false;
rbTblFntSz.Enabled = false;
cmFontSizeList.Enabled = false;
return;
}
rbTblFntSz.Items.Clear();
cmFontSizeList.Items.Clear();
rbTblFntSz.Items.AddRange(tfntszs.Replace(" ", "").Split(",".ToCharArray())); // dropdown on table ribbon
cmFontSizeList.Items.AddRange(tfntszs.Replace(" ", "").Split(",".ToCharArray())); // dropdown on context menu
}
public void ToggleTableDesignButtons(bool enable)
{
bool enableContent = enable;
if (MyFlexGrid != null)
{
if (MyFlexGrid.IsRoTable) enableContent = false;
//B2017-156 Don't allow alignment or borders if the selection is not valid
rbTblBorder.Enabled = btnTblDgnAlignText.Enabled = MyFlexGrid.Selection.IsValid && enable; // B2017-194 moved to inside the test for a null MyFlexGrid
}
btnTblDgnCopy.Enabled = enableContent;
btnTblDgnRemove.Enabled = enableContent;
btnCmGridInsert.Enabled = enableContent;
btnCmGridCopy.Enabled = enableContent;
btnCmGridRemove.Enabled = enableContent;
//btnTblDgnGridStyle.Enabled = enable;
//rbTblBorder.Enabled = enable;
rbnBorderlistBox.Enabled = enable;
rbnBorderSelectionPanel.Enabled = enable;
btnTblNoBorder.Enabled = enable;
btnTblOutline.Enabled = enable;
btnTblInside.Enabled = enable;
btnTblDgnInsertColumn.Enabled = enableContent;
btnTblDgnInsertRow.Enabled = enableContent;
btnTblDgnMergeCells.Enabled = enableContent;
btnCmGridMergeCells.Enabled = enableContent;
btnCmGridPaste.Enabled =
btnTblDgnPaste.Enabled = ((VlnFlexGrid.MyCopyInfo.MyCopiedFlexGrid != null) && enableContent);
btnTblDgnSplitCells.Enabled = enableContent;
btnCmGridSplitCell.Enabled = enableContent;
//B2021-090 don't enable the font size selection on RO tables - was crashing trying to read font sizes on an RO table
// enableContent is set to false (above) when on an RO table
rbTblFont.Enabled = enableContent;
}
public void SetRibbonForGridCellIndent()
{
if (_MyStepRTB != null)
btnIndent.Checked = _MyStepRTB.SelectionHangingIndent != 0;
}
public void SetRibbonForGridCellIndentClear()
{
btnIndent.Checked = false;
}
public void SetRibbonForGrid()
{
// for paste, see if there is clipboard data, & if so, of a type we can use.
IDataObject iData = Clipboard.GetDataObject();
// set to true if editing cell, otherwise false for grids
//bool enable = (MyFlexGrid != null && MyFlexGrid.Editor != null);
// B2017-208 toggle on/off attributes button checks when you edit table cells, going from one cell to another
// Also don't keep the attributes buttons checked after setting a group of table cells all at one time
btnCMBold.Checked = btnBold.Checked = RTBAPI.IsBold(_MyStepRTB) && (MyFlexGrid == null || MyFlexGrid.TableCellEditor.EditMode);
btnCMItalics.Checked = btnItalics.Checked = RTBAPI.IsItalic(_MyStepRTB) && (MyFlexGrid == null || MyFlexGrid.TableCellEditor.EditMode);
btnCMUnderline.Checked = btnUnderline.Checked = RTBAPI.IsUnderline(_MyStepRTB) && (MyFlexGrid == null || MyFlexGrid.TableCellEditor.EditMode);
btnCMSubscript.Checked = btnSubscript.Checked = RTBAPI.IsSubScript(_MyStepRTB) && (MyFlexGrid == null || MyFlexGrid.TableCellEditor.EditMode);
btnCMSuperscript.Checked = btnSuperscript.Checked = RTBAPI.IsSuperScript(_MyStepRTB) && (MyFlexGrid == null || MyFlexGrid.TableCellEditor.EditMode);
bool enable = (MyFlexGrid != null && MyEditItem.MyStepPanel.VwMode == E_ViewMode.Edit);
//btnPasteText.Enabled = btnPasteStepText.Enabled = btnPaste.Enabled = enable;
btnPaste.Enabled = (iData.GetDataPresent(DataFormats.Text) || iData.GetDataPresent(DataFormats.Rtf)) && enable;
btnCMPasteText.Enabled = btnPasteText.Enabled = iData.GetDataPresent(DataFormats.Text) && enable;
btnCMPaste.Enabled = btnPasteStepText.Enabled = iData.GetDataPresent(DataFormats.Rtf ) && enable;
btnCopy.Enabled = enable;
btnCut.Enabled = enable;
btnBold.Enabled = enable && !MyFlexGrid.IsRoTable;// ;
btnItalics.Enabled = enable && !MyFlexGrid.IsRoTable;// ;
btnUnderline.Enabled = enable && !MyFlexGrid.IsRoTable;// ;
btnSubscript.Enabled = enable && !MyFlexGrid.IsRoTable;// ;
btnSuperscript.Enabled = enable && !MyFlexGrid.IsRoTable;// ;
btnChgCase.Enabled = enable && !MyFlexGrid.IsRoTable;// ;
btnInsHrdSpc.Enabled = enable && !MyFlexGrid.IsRoTable;// enable;
btnSymbols.Enabled = enable && !MyFlexGrid.IsRoTable;// enable;
btnIndent.Enabled = enable && !MyFlexGrid.IsRoTable;// ;enable;
btnInsTrans.Enabled = enable && !MyFlexGrid.IsRoTable;// ;
btnInsRO.Enabled = enable && Mydvi.DocVersionAssociationCount > 0; // 2016-128 don't enable if RO Path was not selected at the Working Draft node
btnCMRtfCellEdit.Enabled = enable && !MyFlexGrid.IsRoTable;
}
private bool _initTblFontSizeDropdown = true; // C2021-005 flag to allow setting font size in dropdown without triggering the dropdown item select
// C2021-005 get the font size being used in the selected table cell(s) then ititialize the font dropdown
public void SetFontSizeDropDown()
{
float sz = GetTableCellFontSize(SelectionOption.All);
SetFontSizeDropDownText(sz);
}
// C2021-005 Initialize the font size dropdown
public void SetFontSizeDropDownText(float fsz)
{
_initTblFontSizeDropdown = true;
rbTblFntSz.SelectedIndex = -1;
rbTblFntSz.Text = fsz.ToString();
cmFontSizeList.SelectedIndex = -1;
cmFontSizeList.Text = fsz.ToString();
_initTblFontSizeDropdown = false;
}
private void btnTblDgnAdjustSize_Click(object sender, EventArgs e)
{
if (MyFlexGrid.Cols.Fixed == 0) // allow change of size.
{
// set all the rows and columns to Fixed so that user can adjust the row/column size
if (MyFlexGrid.Cols[0].Width == -1) MyFlexGrid.Cols[0].Width = MyFlexGrid.Cols.DefaultSize;
MyFlexGrid.Cols.Fixed = MyFlexGrid.Cols.Count;
MyFlexGrid.Rows.Fixed = MyFlexGrid.Rows.Count;
MyFlexGrid.StyleBackColor = MyFlexGrid.DefaultFixedBackgroundColor; // C2021-004 force the fixed background color
ToggleTableDesignButtons(false);
//MyFlexGrid.ListStyles();
}
else
{
// set grid back to "normal" mode
MyFlexGrid.Cols.Fixed = 0;
MyFlexGrid.Rows.Fixed = 0;
MyFlexGrid.ShowTableCellShading(); // C2021-004 show the table cell colors
ToggleTableDesignButtons(true);
//MyFlexGrid.ListStyles();
}
}
#endregion
#region Table Grid Border
private void btnTblDgnTableBorderNone_Click(object sender, EventArgs e)
{
MyFlexGrid.SetTableBorder(C1.Win.C1FlexGrid.Util.BaseControls.BorderStyleEnum.None);
}
private void btnTblDgnTableBorderFixedSingle_Click(object sender, EventArgs e)
{
MyFlexGrid.SetTableBorder(C1.Win.C1FlexGrid.Util.BaseControls.BorderStyleEnum.FixedSingle);
}
private void btnTblDgnTableBorderFixed3D_Click(object sender, EventArgs e)
{
MyFlexGrid.SetTableBorder(C1.Win.C1FlexGrid.Util.BaseControls.BorderStyleEnum.Fixed3D);
}
private void btnTblDgnTableBorderLight3D_Click(object sender, EventArgs e)
{
MyFlexGrid.SetTableBorder(C1.Win.C1FlexGrid.Util.BaseControls.BorderStyleEnum.Light3D);
}
private void btnTblDgnTableBorderXPThemes_Click(object sender, EventArgs e)
{
MyFlexGrid.SetTableBorder(C1.Win.C1FlexGrid.Util.BaseControls.BorderStyleEnum.XpThemes);
}
#endregion
#region Table Grid Grid Style
private void btnTblDgnGridStyleNone_Click(object sender, EventArgs e)
{
MyFlexGrid.ChangeCellBorder(MyFlexGrid.Selection, C1.Win.C1FlexGrid.BorderStyleEnum.None);
}
private void btnTblDgnGridStyleFlat_Click(object sender, EventArgs e)
{
MyFlexGrid.ChangeCellBorder(MyFlexGrid.Selection, C1.Win.C1FlexGrid.BorderStyleEnum.Flat);
}
private void btnTblDgnGridStyleDouble_Click(object sender, EventArgs e)
{
MyFlexGrid.ChangeCellBorder(MyFlexGrid.Selection, C1.Win.C1FlexGrid.BorderStyleEnum.Double);
}
private void btnTblDgnGridStyleRaised_Click(object sender, EventArgs e)
{
MyFlexGrid.ChangeCellBorder(MyFlexGrid.Selection, C1.Win.C1FlexGrid.BorderStyleEnum.Raised);
}
private void btnTblDgnGridStyleInset_Click(object sender, EventArgs e)
{
MyFlexGrid.ChangeCellBorder(MyFlexGrid.Selection, C1.Win.C1FlexGrid.BorderStyleEnum.Inset);
}
private void btnTblDgnGridStyleGroove_Click(object sender, EventArgs e)
{
MyFlexGrid.ChangeCellBorder(MyFlexGrid.Selection, C1.Win.C1FlexGrid.BorderStyleEnum.Groove);
}
private void btnTblDgnGridStyleFillet_Click(object sender, EventArgs e)
{
MyFlexGrid.ChangeCellBorder(MyFlexGrid.Selection, C1.Win.C1FlexGrid.BorderStyleEnum.Fillet);
}
private void btnTblDgnGridStyleDotted_Click(object sender, EventArgs e)
{
MyFlexGrid.ChangeCellBorder(MyFlexGrid.Selection, C1.Win.C1FlexGrid.BorderStyleEnum.Dotted);
}
#endregion
private void rbnBorderlistBox_SelectedIndexChanged(object sender, EventArgs e)
{
rbnBorderSelectionPanel.SelectedBorder = rbnBorderlistBox.SelectedLinePattern;
}
private void rbnBorderSelectionPanel_BordersChanged(object sender, EventArgs args)
{
//C1.Win.C1FlexGrid.CellRange cr = MyFlexGrid.GetEvenSelection();
MyFlexGrid.SetBorders(MyFlexGrid.Selection, rbnBorderSelectionPanel.TopBorder, rbnBorderSelectionPanel.InsideHorizontalBorder,
rbnBorderSelectionPanel.BottomBorder, rbnBorderSelectionPanel.LeftBorder, rbnBorderSelectionPanel.InsideVerticalBorder, rbnBorderSelectionPanel.RightBorder);
MyEditItem.Invalidate();
MyFlexGrid.Invalidate();
}
private void btnTblNoBorder_Click(object sender, EventArgs e)
{
rbnBorderSelectionPanel.AllBorders = GridLinePattern.None;
}
private void btnTblOutline_Click(object sender, EventArgs e)
{
rbnBorderSelectionPanel.OutlineBorder = rbnBorderlistBox.SelectedLinePattern;
}
private void btnTblInside_Click(object sender, EventArgs e)
{
rbnBorderSelectionPanel.InsideBorders = rbnBorderlistBox.SelectedLinePattern;
}
private void rbnBorderlistBox_Resize(object sender, EventArgs e)
{
rbnBorderSelectionPanel.Size = rbnBorderlistBox.Size;
_RibbonControl.Height = rbnBorderlistBox.Height + _RibbonControl.Height - _RibbonControl.ClientSize.Height;
//_RibbonControl.Height = rbnBorderlistBox.Height + _RibbonControl.Height - _RibbonControl.ClientSize.Height;
}
#region Expand/Collaspe Ribbon
// In MS Word, a Double Click of a ribbon tab will toggle (Expand/Collapse) the ribbon.
// Once collapsed, a Single Click of a ribbon tab will temporarily expand the ribbon but does not push the text window
// down to make room. Thus your edit cursor could end up behind the ribbon.
// In our implementation of the ribbon interface, when we double click to collapse/expand the
// ribbon, the QAT menu on the main form gets out of sync, so we need to handle this manually, turning off AutoExpand
// on the ribbon control. (see StepTabRibbon() constructor) and issue an event to expand/collapse the ribbon.
// As a result of turning off the AutoExpand, a single click is not recongized internally.
// To get around this, we handle the single click event.
// Our single click event will expand the ribbon tabs if needed but not temporarily.
// Instead, it acts like a double click which is not the same a MS Word, but on the plus side,
// it elimates the risk of the ribbon expanding on top of the current edit window.
//-----------------------------
// This is assigned the DoubleClick event on all of the ribbon tabs
// Note that a single mouse click will expand the tabs if collapsed
// Note too that a double click also fires the single click event
// the "didSingleClick" variable handle this case
private void ribbonTab_DoubleClick(object sender, EventArgs e)
{
if (TimeSpan.FromTicks(DateTime.Now.Ticks - _LastClick.Ticks).TotalMilliseconds > 500)
{
//SendKeys.Send("^{F1}"); // toggle expand/collapse ribbon tabs <CTRL><F1>
MyEditItem.MyStepPanel.MyStepTabPanel.MyDisplayTabControl.OnToggleRibbonExpanded(this, new EventArgs());
_LastDoubleClick = DateTime.Now;
}
}
private DateTime _LastClick = DateTime.Now;
private DateTime _LastDoubleClick = DateTime.Now;
// This is assigned the Click event on all of the ribbon tabs
// If the tabs are collapsed, then expand them on a single click of the tab
private void ribbonTab_SingleClick(object sender, EventArgs e)
{
if ((!_RibbonControl.Expanded) && TimeSpan.FromTicks(DateTime.Now.Ticks - _LastDoubleClick.Ticks).TotalMilliseconds > 500)
{
//SendKeys.Send("^{F1}"); // Expand the ribbon tabs <CTRL><F1>
MyEditItem.MyStepPanel.MyStepTabPanel.MyDisplayTabControl.OnToggleRibbonExpanded(this, new EventArgs());
_LastClick = DateTime.Now;
}
}
#endregion // Expand/Collapse Ribbon
private void btnPasteText_Click(object sender, EventArgs e)
{
StartGridEditing(SelectionOption.End);
_PastePlainTextOvrRide = true;
btnPaste_Click(sender, e);
}
private void btnPasteImage_Click(object sender, EventArgs e)
{
if (MyEditItem is ImageItem) (MyEditItem as ImageItem).PasteImage();
}
private void btnPasteStepText_Click(object sender, EventArgs e)
{
StartGridEditing(SelectionOption.End);
_PasteStepTextOvrRide = true;
btnPaste_Click(sender, e);
}
private void btnSaveChgId_Click(object sender, EventArgs e)
{
(this.Parent as StepTabPanel).MyDisplayTabControl.ChgId = txtBxChgId.Text;
(this.Parent as StepTabPanel).MyDisplayTabControl.ItemsChangeIds.Remove(_MyEditItem.MyStepRTB.MyItemInfo.MyProcedure.ItemID);
(this.Parent as StepTabPanel).MyDisplayTabControl.ItemsChangeIds.Add(_MyEditItem.MyStepRTB.MyItemInfo.MyProcedure.ItemID, txtBxChgId.Text);
}
private frmImportWordContents fiwc = null;
// open the Import Word Text dialog
private void rbnImpWrd_ItemClick(object sender, EventArgs e)
{
if (fiwc == null) fiwc = new frmImportWordContents();
fiwc.MyStepRTB = this.MyStepRTB;
// B2019-108 When closed set value to null
fiwc.FormClosed += fiwc_FormClosed;
fiwc.Show();
}
void fiwc_FormClosed(object sender, FormClosedEventArgs e)
{
fiwc = null;
}
private void btnCMImgSz_Click(object sender, EventArgs e)
{
StepPanelTabDisplayEventArgs args = new StepPanelTabDisplayEventArgs("Change Image Size");
MyEditItem.MyStepPanel.OnTabDisplay(sender, args);
}
// C2021-005 user selected a font size from the dropdown (table ribbon)
private void rbTblFntSz_SelectedIndexChanged(object sender, EventArgs e)
{
if (!_initTblFontSizeDropdown)
{
float newSize = Convert.ToSingle(rbTblFntSz.SelectedItem); // font size selction from dropdown
ChangeFontSize(SelectionOption.All, newSize); // newSize is the font pt size not the RFT font size (which is twice the pt size)
}
}
// C2021-005 user selected a font size from the dropdown (context menu)
private void cmFontSizeList_SelectedIndexChanged(object sender, EventArgs e)
{
if (!_initTblFontSizeDropdown)
{
float newSize = Convert.ToSingle(cmFontSizeList.SelectedItem);
ChangeFontSize(SelectionOption.All, newSize);
}
}
#region Table Cell Shading
// C2021-004 Table Cell Shading
private void btnTblDgnCellShading_SelectedColorChanged(object sender, EventArgs e)
{
Color newshading = btnCellShading.SelectedColor;
MyFlexGrid.SetShading(MyFlexGrid.Selection, newshading); // assign the selected color the selected cell(s)
MyEditItem.Invalidate();
MyFlexGrid.Invalidate();
}
// This adds a button named "More Shading Options..." to the DotNetBar defined Color Selector button
private bool _CustomButtonAdded = false;
private void btnCellShading_PopupShowing(object sender, EventArgs e)
{
if (MyItemInfo == null || MyItemInfo.ActiveFormat.PlantFormat.FormatData.ShadingOptionList == null) return; //not shading options defined in format
if (!_CustomButtonAdded)
{
ButtonItem button = new ButtonItem();
button.Text = "More Shading Options...";
button.BeginGroup = true;
foreach (ShadingOption ShadeOpt in MyItemInfo.ActiveFormat.PlantFormat.FormatData.ShadingOptionList)
{
ButtonItem btn = new ButtonItem();
btn.Tag = ShadeOpt;
btn.Text = ShadeOpt.ToString();
btn.Click += new EventHandler(MoreShadingOptionsClick);
button.SubItems.Add(btn);
}
btnCellShading.SubItems.Add(button);
((MenuPanel)((PopupItem)button.Parent).PopupControl).RecalcLayout();
_CustomButtonAdded = true;
}
}
private void MoreShadingOptionsClick(object sender, EventArgs e)
{
ShadingOption sopt = (ShadingOption)((BaseItem)sender).Tag;
/* debug information
//string str = string.Format("Alpha {0}\n Red {1}\nBlue {2}\nGreen{3}", sopt.Alpha, sopt.Red, sopt.Blue, sopt.Green);
//MessageBox.Show(str,"more shading click");
*/
MyFlexGrid.SetShading(MyFlexGrid.Selection, sopt);
MyEditItem.Invalidate();
MyFlexGrid.Invalidate();
}
#endregion
// F2022-024 Time Critical Action Summary
private void btnTCASCreate_Click(object sender, EventArgs e)
{
if (MyItemInfo == null) return; // if creating a Time Critical Action Summary before rtb exists, return;
if (MyEditItem != null) MyEditItem.SaveCurrentAndContents();
OnTimeCriticalActionSummaryRequest(new StepTabRibbonEventArgs(MyItemInfo.MyProcedure));
}
}
public class StepTabRibbonEventArgs : EventArgs
{
public StepTabRibbonEventArgs() { ; }
public StepTabRibbonEventArgs(ItemInfo proc)
{
_Proc = proc;
}
private ItemInfo _Proc;
public ItemInfo Proc
{
get { return _Proc; }
set { _Proc = value; }
}
}
public delegate void StepTabRibbonEvent(object sender, StepTabRibbonEventArgs args);
}