public static bool Restore(tblAppNavigation tbl) { bool rVal = false; foreach (Form frm in frmNavigate.ActiveForm.MdiChildren) { try { clsForm f = (clsForm)frm; if (f.tblNav.NAVID == tbl.NAVID) { frm.BringToFront(); frm.Focus(); frm.WindowState = FormWindowState.Normal; rVal = true; } } catch (Exception ex) { if (frm.Name == tbl.NAV_Item) { frm.BringToFront(); frm.Focus(); frm.WindowState = FormWindowState.Normal; rVal = true; } } } return(rVal); }
private void frmNavigate_Shown(object sender, EventArgs e) { try { try { ListViewItem clickedItem = lstIcons.Items[0]; Int32 intNAVID = Convert.ToInt32(clickedItem.Name); tblAppNavigation tbl = (from ct in db.tblAppNavigation where ct.NAVID == intNAVID select ct).First <tblAppNavigation>(); OpenForm(tbl); } catch (Exception) { } //var lstOpen = new int[] { 5, 6, 7, 16}; //if (lstOpen.Contains(this.APPID)) //{ // Int32 intItem = Convert.ToInt32(lstIcons.Items[0].Name.ToString()); // tblAppNavigation tbl = (from ct in db.tblAppNavigation // where ct.NAVID == intItem // select ct).First<tblAppNavigation>(); // OpenForm(tbl); //} } catch (Exception ex) { } }
public static Color GetHeaderColor(tblAppNavigation tbl) { Color col = new Color(); try { string strColor = tbl.NAV_Color; col = System.Drawing.ColorTranslator.FromHtml(strColor); } catch (Exception ex) { col = Color.Ivory; } return(col); }
private void lstIcons_MouseUp(object sender, MouseEventArgs e) { this.Cursor = Cursors.Hand; ListViewItem clickedItem = lstIcons.GetItemAt(m_iMouseX, m_iMouseY); if (clickedItem != null) { clickedItem.Selected = true; clickedItem.Focused = true; Int32 intNAVID = Convert.ToInt32(clickedItem.Name); tblAppNavigation tbl = (from ct in db.tblAppNavigation where ct.NAVID == intNAVID select ct).First <tblAppNavigation>(); OpenForm(tbl); } }
public static bool IsOpen(tblAppNavigation tbl) { bool rVal = false; try { // loop though all forms in MDI container to determine if form designated by FormName is open foreach (Form frm in Application.OpenForms) { if (frm.Name.Equals(tbl.NAV_Item) && frm.Text.Equals(tbl.NAV_Desc)) { rVal = true; break; } } } catch (Exception ex) { return(false); } //Debug.WriteLine(rVal); return(rVal); }
private void OpenForm(tblAppNavigation tbl) { string appName = Application.ProductName; string mForm = tbl.NAV_Item; try { if (tbl.NAV_Option == 1) //open form { if (clsUtility.IsOpen(tbl) == false) { Type oFormType = Type.GetType(appName + "." + mForm); ConstructorInfo oConstructorInfo = oFormType.GetConstructor(System.Type.EmptyTypes); //clsForm frm = (clsForm)oConstructorInfo.Invoke(null); clsForm frm = (clsForm)Activator.CreateInstance(oFormType); frm.Icon = Icon.FromHandle(((Bitmap)lstImage.Images[tbl.NAV_Image]).GetHicon()); frm.tblNav = tbl; frm.Text = tbl.NAV_Desc; frm.Token = this.Token; frm.Associate = this.Associate; frm.AppName = this.AppName; frm.LNID = this.LNID; frm.TSID = this.TSID; frm.APPID = this.APPID; string strDev = clsUtility.ConfigVal("DEV"); var lstNav = new int[] { 51, 196, 198, 326, 374, 729 }; if (lstNav.Contains(tbl.NAVID)) { frm.WindowState = FormWindowState.Maximized; this.Cursor = Cursors.WaitCursor; frm.Show(); this.Cursor = Cursors.Default; } else if (tbl.NAVID == 311 && this.LNID == 1) { frm.WindowState = FormWindowState.Maximized; this.Cursor = Cursors.WaitCursor; frm.Show(); this.Cursor = Cursors.Default; } else { frm.MdiParent = this; this.Cursor = Cursors.WaitCursor; frm.Show(); this.Cursor = Cursors.Default; FillActiveChildFormToClient(); } //} } else { clsUtility.Restore(tbl); } } else if (tbl.NAV_Option == 7) //open help { var qry = (from ct in db.tblApp where ct.APPID == this.APPID select ct).First(); string strNav = tbl.NAV_Item + this.Associate.AS_User + "&ORGID=" + qry.APP_HelpdeskOrg.ToString(); Process training = new Process(); training.StartInfo.FileName = strNav; training.Start(); } } catch (System.NullReferenceException Err) { Debug.WriteLine(Err.Message.ToString()); } catch (Exception ErrorObject) { MessageBox.Show("Error opening form " + tbl.NAV_Item + " " + ErrorObject.Message, this.AppName); } finally { } }