Sorry for the long delay everyone. I flew straight from insights out to the coast for a couple weeks and life has been hectic ever since. Here are the code snippets from my portion of the presentation with @josecgomez on UI interactions and Infragistics controls. If you have any questions, feel free to reach out to me.
- Clear controls (you want to flush a large number of filters in a dashboard for ex.)
using Infragistics.Win.UltraWinGrid;
using System.Collections.Generic;
public class Script
{
public void InitializeCustomCode()
{
this.btnClearFilters.Click += new System.EventHandler(this.btnClearFilters_Click);
}
public void DestroyCustomCode()
{
this.btnClearFilters.Click -= new System.EventHandler(this.btnClearFilters_Click);
}
private void btnClearFilters_Click(object sender, System.EventArgs args)
{
Ice.Lib.Framework.EpiBasePanel pnl = (Ice.Lib.Framework.EpiBasePanel)csm.GetNativeControlReference("9fc6a346-e062-4c54-a790-6e37882f4463");
foreach (Control c in pnl.Controls)
{
if (c.GetType() == typeof(EpiTextBox))
c.Text = string.Empty;
if (c.GetType() == typeof(EpiNumericEditor))
{
((EpiNumericEditor)c).Value = null;
}
if (c.GetType() == typeof(EpiCombo))
{
c.Text = string.Empty;
}
if (c.GetType() == typeof(EpiDateTimeEditor))
{
c.Text = string.Empty;
}
if (c.GetType() == typeof(EpiTimeEditor))
{
c.Text = string.Empty;
}
}
}
// You can also reference native Epicor objects in this manner when you are going to reference it throughout your customization
EpiBasePanel myPanel
{
get
{
return (EpiBasePanel)csm.GetNativeControlReference("9fc6a346-e062-4c54-a790-6e37882f4463");
}
}
}
- Filter a dashboard grid with a separate DateTimePicker and a TimerPicker. This uses a minutes past an epoch integer column for tracker query control
using Infragistics.Win.UltraWinGrid;
using System.Collections.Generic;
public class Script
{
EpiTextBox epiCalculated_numLastPacked;
public void InitializeCustomCode()
{
this.edeLastPackedDate.Validating += new System.ComponentModel.CancelEventHandler(this.edeLastPackedDate_Validating);
this.eteLastPackedTime.Validating += new System.ComponentModel.CancelEventHandler(this.eteLastPackedTime_Validating);
epiCalculated_numLastPacked = (EpiTextBox)csm.GetNativeControlReference("fd40bea2-2cda-4f4b-b86c-adf9bbee8af6");
}
public void DestroyCustomCode()
{
this.edeLastPackedDate.Validating -= new System.ComponentModel.CancelEventHandler(this.edeLastPackedDate_Validating);
this.eteLastPackedTime.Validating -= new System.ComponentModel.CancelEventHandler(this.eteLastPackedTime_Validating);
}
private void edeLastPackedDate_Validating(object sender, System.ComponentModel.CancelEventArgs args)
{
if(eteLastPackedTime.Value != null && edeLastPackedDate.Value != null)
{
Calc_numLastPacked();
}
}
private void eteLastPackedTime_Validating(object sender, System.ComponentModel.CancelEventArgs args)
{
if (edeLastPackedDate.Value != null && eteLastPackedTime.Value != null)
{
Calc_numLastPacked();
}
}
private void Calc_numLastPacked()
{
DateTime dt;
DateTime dt1;
if(DateTime.TryParse(edeLastPackedDate.Value.ToString(), out dt) && DateTime.TryParse(eteLastPackedTime.Value.ToString(), out dt1))
{
TimeSpan span = dt - Convert.ToDateTime("2000-01-01");
TimeSpan span1 = dt1 - Convert.ToDateTime(DateTime.Today);
epiCalculated_numLastPacked.Value = ((int)span.TotalMinutes + (int)span1.TotalMinutes).ToString();
}
}
- How we select and deselect, or update columns in rows in a grid through through highlighting, button clicks etc
using Infragistics.Win.UltraWinGrid;
using System.Collections.Generic;
public class Script
{
EpiUltraGrid myPackGrid;
EpiUltraGrid myDetailGrid;
List<UltraGridRow> gatherRows;
string user;
public void InitializeCustomCode()
{
myPackGrid = (EpiUltraGrid)csm.GetNativeControlReference("e9860346-a5da-4352-9e89-e1d3137599de");
myDetailGrid = (EpiUltraGrid)csm.GetNativeControlReference("eddfa7cc-e133-4f5d-95e0-bb7dda5268e9");
gatherRows = new List<UltraGridRow>();
var CCCData = oTrans.Factory("CallContextClientData");
user = CCCData.dataView[CCCData.Row]["CurrentUserId"].ToString();
}
private void btnSelectAllPacks_Click(object sender, System.EventArgs args)
{
// Get all the rows
GatherRows(myPackGrid.Rows, "Calculated_Release", false);
// Change a column value on those rows
ChangeField(myPackGrid, gatherRows, "Calculated_Release", true);
}
private void btnClearAllPacks_Click(object sender, System.EventArgs args)
{
GatherRows(myPackGrid.Rows, "Calculated_Release", true);
ChangeField(myPackGrid, gatherRows, "Calculated_Release", false);
}
private void btnSelectHighlightedPacks_Click(object sender, System.EventArgs args)
{
// Use linq to grab all rows the user highlighted with their mouse that aren't groupby rows
List<UltraGridRow> gridRows = (from UltraGridRow r in myPackGrid.Selected.Rows
where Convert.ToBoolean(r.Cells["Calculated_Release"].Value).Equals(false)
&& r.GetType() != typeof(UltraGridGroupByRow)
select r).ToList();
ChangeField(myPackGrid, gridRows, "Calculated_Release", true);
}
private void ChangeField(UltraGrid grid, List<UltraGridRow> gridRows, string field, bool val)
{
/* SuspendRowSynchronization and ResumeRowSynchronization methods can be used to temporarily
suspend UltraGrid from responding to data source change notifications. When row syncrhonization
is suspended, the UltraGrid will still mark the rows dirty so it will re-create the rows next time it gets painted. */
if (gridRows.Count > 0)
{
try
{
myPackGrid.BeginUpdate();
myPackGrid.SuspendRowSynchronization();
foreach (var row in gridRows)
{
//Check and uncheck the boxes we want
row.Cells[field].Value = val;
}
}
catch
{
//Do some error handling here
}
finally
{
// Clean up
myPackGrid.ResumeRowSynchronization();
myPackGrid.EndUpdate();
gatherRows.Clear();
}
}
}
private void GatherRows(RowsCollection row, string field, bool val)
{
List<UltraGridRow> gridRows = new List<UltraGridRow>();
foreach (UltraGridRow r in row)
{
if (r.GetType() == typeof(UltraGridGroupByRow))
{
// A recursive query that gets to the bottom of things
GatherRows(((UltraGridGroupByRow)r).Rows, field, val);
}
else
{
if(r.Cells[field].Value.Equals(val))
{
// Add this to our collection of stuff to do
gatherRows.Add(r);
}
}
}
}
}
- Invoke a tool click on tool bar items programatically
using Infragistics.Win.UltraWinGrid;
using System.Collections.Generic;
public class Script
{
public void InitializeCustomCode()
{
this.btnRefresh.Click += new System.EventHandler(this.btnRefresh_Click);
// End Wizard Added Custom Method Calls
}
public void DestroyCustomCode()
{
this.btnRefresh.Click -= new System.EventHandler(this.btnRefresh_Click);
}
private void btnRefresh_Click(object sender, System.EventArgs args)
{
ToolBarClick("RefreshTool");
}
private void ToolBarClick(string tool)
{
MainController.AppControlPanel.HandleToolClick(tool, new
Infragistics.Win.UltraWinToolbars.ToolClickEventArgs(MainController.MainToolManager.Tools[tool], null));
}
}
- Save a grid layout via a checkbox to a temp directory as an xml file and automatically restore the layout to what it was at the time of save by unchecking the box.
using Infragistics.Win.UltraWinGrid;
using System.Collections.Generic;
using System.IO;
using System.Drawing;
public class Script
{
public string tempFile = string.Empty;
public void InitializeCustomCode()
{
this.cbxPrintMode.CheckStateChanged += new System.EventHandler(this.cbxPrintMode_CheckStateChanged);
}
public void DestroyCustomCode()
{
this.cbxPrintMode.CheckStateChanged -= new System.EventHandler(this.cbxPrintMode_CheckStateChanged);
}
private void cbxPrintMode_CheckStateChanged(object sender, System.EventArgs args)
{
// ** Place Event Handling Code Here **
if (cbxPrintMode.CheckState.ToString() == "Checked")
{
MessageBox.Show("You will only be able to print jobs with material issued. Issue Material function will be disabled in Print Mode.");
tempFilePM = Path.GetTempFileName().Replace(".tmp", ".xml");
myGrid.DisplayLayout.SaveAsXml(tempFilePM);
btnIssue.Visible = false;
btnIssue.ReadOnly = true;
btnSS.Visible = true;
btnSS.ReadOnly = false;
btnPrintAll.Visible = true;
btnPrintAll.ReadOnly = false;
myGrid.DisplayLayout.Bands[0].SortedColumns.Clear();
myGrid.DisplayLayout.Bands[0].SortedColumns.Add("UD10_Lot_Num_c", true);
shpPrintMode.Visible = true;
shpPrintMode.Enabled = true;
shpPrintMode.Status = StatusTypes.Warning;
shpPrintMode.EnabledCaption = "**** PRINT MODE ****";
}
if (cbxPrintMode.CheckState.ToString() == "Unchecked")
{
myGrid.DisplayLayout.LoadFromXml(tempFilePM);
File.Delete(tempFilePM);
MainController.AppControlPanel.HandleToolClick("RefreshTool", new Infragistics.Win.UltraWinToolbars.ToolClickEventArgs(MainController.MainToolManager.Tools["RefreshTool"], null));
btnIssue.Visible = true;
btnIssue.ReadOnly = false;
btnSS.Visible = false;
btnSS.ReadOnly = true;
btnPrintAll.Visible = false;
btnPrintAll.ReadOnly = true;
shpPrintMode.Visible = false;
shpPrintMode.Enabled = false;
}
}
}
Was really great seeing everyone there this year. Looking forward to next!