C2019-036 View Only mode work with Checked Out Procedures
This commit is contained in:
@@ -16,6 +16,8 @@ using DevComponents.DotNetBar;
|
||||
using Microsoft.Win32;
|
||||
using System.Diagnostics;
|
||||
using JR.Utils.GUI.Forms;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Volian.Controls.Library
|
||||
{
|
||||
@@ -906,6 +908,11 @@ namespace Volian.Controls.Library
|
||||
// //SetButtonAndMenuEnabling(false);
|
||||
//}
|
||||
private Bitmap createTextBitmap(char ch)
|
||||
{
|
||||
return createTextBitmap(ch, new Font("FreeMono", 18, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel));
|
||||
}
|
||||
|
||||
private Bitmap createTextBitmap(char ch, Font objFont)
|
||||
{
|
||||
string txt = string.Format("{0}", ch);
|
||||
Bitmap objBmpImage = new Bitmap(1, 1);
|
||||
@@ -916,8 +923,6 @@ namespace Volian.Controls.Library
|
||||
// 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);
|
||||
@@ -937,7 +942,6 @@ namespace Volian.Controls.Library
|
||||
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);
|
||||
@@ -2067,6 +2071,9 @@ namespace Volian.Controls.Library
|
||||
rtabHome.Select();
|
||||
rtabTableGridTools.Visible = false;
|
||||
SetButtonMenuEnabledDisabledOnStepType(false);
|
||||
//C2019-036 View Only mode work with Checked Out Procedures
|
||||
//Is in View Only Mode so show button as selected
|
||||
btnEditMode.Checked = btnCMEditMode1.Checked = true;
|
||||
this.Refresh();
|
||||
return;
|
||||
}
|
||||
@@ -3338,10 +3345,43 @@ namespace Volian.Controls.Library
|
||||
public void SetupAdminMode()
|
||||
{
|
||||
}
|
||||
|
||||
//C2019-036 View Only mode work with Checked Out Procedures
|
||||
public event StepTabRibbonEvent EnableDisableStepProperties;
|
||||
private void OnEnableDisableStepProperties(StepTabRibbonEventArgs args)
|
||||
{
|
||||
if (EnableDisableStepProperties != null)
|
||||
EnableDisableStepProperties(this, args);
|
||||
}
|
||||
private void btnToggleEditView_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (MyEditItem == null) return;
|
||||
|
||||
//C2019-036 View Only mode work with Checked Out Procedures
|
||||
string message = string.Empty;
|
||||
if (MyEditItem.MyStepPanel.VwMode == E_ViewMode.View && !MySessionInfo.CanCheckOutItem(MyEditItem.MyItemInfo.MyProcedure.ItemID, CheckOutType.Procedure, ref message))
|
||||
{
|
||||
//someone else has the procedure checked out so cannot swap out of view only mode
|
||||
message = message.Replace("\r\nWould You like to open the procedure in View Only Mode?", "\r\n\r\nYou will be unable to turn off View Only Mode for this procedure until it is checked in by the user specified above.");
|
||||
MessageBox.Show(this, message, "Procedure Already Checked Out", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||||
return;
|
||||
}
|
||||
else if (MyEditItem.MyStepPanel.VwMode == E_ViewMode.View)
|
||||
{
|
||||
//swapping into edit mode, so check out procedure and Setup Security
|
||||
(this.Parent as StepTabPanel).MyDisplayTabItem.OwnerID = MySessionInfo.CheckOutItem(MyEditItem.MyItemInfo.MyProcedure.ItemID, 0);
|
||||
(this.Parent as StepTabPanel).MyDisplayTabItem.SetupSecurity(MyItemInfo);
|
||||
}
|
||||
else
|
||||
{
|
||||
//swapping into View Only mode, so check in procedure
|
||||
OwnerInfo oi = OwnerInfo.GetByItemID(MyEditItem.MyItemInfo.MyProcedure.ItemID, CheckOutType.Procedure);
|
||||
MySessionInfo.CheckInItem(oi.OwnerID);
|
||||
}
|
||||
|
||||
MyEditItem.MyStepPanel.VwMode = MyEditItem.MyStepPanel.VwMode == E_ViewMode.Edit ? E_ViewMode.View : E_ViewMode.Edit;
|
||||
//enable / disable the Step Properties Panel based on the ViewMode
|
||||
OnEnableDisableStepProperties(new StepTabRibbonEventArgs(MyEditItem.MyItemInfo, 0, MyEditItem.MyStepPanel.VwMode));
|
||||
MyEditItem.ToggleEditView(MyEditItem.MyStepPanel.VwMode);
|
||||
SetButtonAndMenuEnabling(true);
|
||||
SetStepButtonAndMenuEnabling(true);
|
||||
@@ -3355,7 +3395,62 @@ namespace Volian.Controls.Library
|
||||
// btnEnhancedDocSync.Checked = !btnEnhancedDocSync.Checked;
|
||||
//}
|
||||
|
||||
//C2019-036 View Only mode work with Checked Out Procedures
|
||||
// using a blocking collection to make it thread safe in case someone
|
||||
// spams hitting the refresh button
|
||||
private BlockingCollection<bool> blockingRefreshProcedure = new BlockingCollection<bool>();
|
||||
|
||||
//C2019-036 View Only mode work with Checked Out Procedures
|
||||
private void btnRefreshProcedure_Click(object sender, EventArgs e)
|
||||
{
|
||||
//Consumer
|
||||
Task.Run(() =>
|
||||
{
|
||||
//Blocks until a newRefresh Procedure Run is available
|
||||
while (!blockingRefreshProcedure.IsCompleted)
|
||||
{
|
||||
_ = blockingRefreshProcedure.Take();
|
||||
RefreshProcedure();
|
||||
}
|
||||
});
|
||||
|
||||
//Producer
|
||||
Task.Run(() => { blockingRefreshProcedure.Add(true); });
|
||||
}
|
||||
|
||||
public void RefreshProcedure()
|
||||
{
|
||||
StepTabPanel stab_Panel = Parent as StepTabPanel;
|
||||
|
||||
if (MyEditItem != null)
|
||||
{
|
||||
if (!MyEditItem.MyStepPanel.ContainsFocus)
|
||||
this.Invoke((Action)(() => { MyEditItem.MyStepPanel.Focus(); }));
|
||||
|
||||
E_ViewMode mode = MyEditItem.MyStepPanel.VwMode;
|
||||
Application.DoEvents();
|
||||
this.Invoke((Action)(() => {MyEditItem.MyStepPanel.ResetAll();}));
|
||||
Application.DoEvents();
|
||||
this.Invoke((Action)(() => {MyEditItem.MyStepPanel.Refresh();}));
|
||||
Application.DoEvents();
|
||||
MyEditItem.MyStepPanel.VwMode = mode;
|
||||
Application.DoEvents();
|
||||
}
|
||||
else if (stab_Panel != null)
|
||||
{
|
||||
if (!stab_Panel.MyStepPanel.ContainsFocus)
|
||||
this.Invoke((Action)(() => {stab_Panel.MyStepPanel.Focus();}));
|
||||
|
||||
E_ViewMode mode = stab_Panel.MyStepPanel.VwMode;
|
||||
Application.DoEvents();
|
||||
this.Invoke((Action)(() => {stab_Panel.MyStepPanel.ResetAll();}));
|
||||
Application.DoEvents();
|
||||
this.Invoke((Action)(() => {stab_Panel.MyStepPanel.Refresh();}));
|
||||
Application.DoEvents();
|
||||
stab_Panel.MyStepPanel.VwMode = mode;
|
||||
Application.DoEvents();
|
||||
}
|
||||
}
|
||||
private void btnROEdit_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (VlnSettings.ReleaseMode.Equals("DEMO"))
|
||||
@@ -4865,10 +4960,11 @@ namespace Volian.Controls.Library
|
||||
public class StepTabRibbonEventArgs : EventArgs
|
||||
{
|
||||
public StepTabRibbonEventArgs() { ; }
|
||||
public StepTabRibbonEventArgs(ItemInfo proc, int oringFlg = 0)
|
||||
public StepTabRibbonEventArgs(ItemInfo proc, int oringFlg = 0, E_ViewMode viewMode = E_ViewMode.Edit)
|
||||
{
|
||||
_Proc = proc;
|
||||
OringFlg = oringFlg;
|
||||
ViewMode = viewMode;
|
||||
}
|
||||
private ItemInfo _Proc;
|
||||
|
||||
@@ -4884,6 +4980,9 @@ namespace Volian.Controls.Library
|
||||
get { return _OringFlg; }
|
||||
set { _OringFlg = value; }
|
||||
}
|
||||
|
||||
//C2019-036 View Only mode work with Checked Out Procedures
|
||||
public E_ViewMode ViewMode { get; set; }
|
||||
}
|
||||
public delegate void StepTabRibbonEvent(object sender, StepTabRibbonEventArgs args);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user