public static void LoadToolbar(ODToolBar ToolBarMain,ToolBarsAvail toolBarsAvail) { List<ToolButItem> toolButItems=ToolButItems.GetForToolBar(toolBarsAvail); for(int i=0;i<toolButItems.Count;i++) { ToolButItem toolButItemCur=((ToolButItem)toolButItems[i]); Program programCur=Programs.GetProgram(toolButItemCur.ProgramNum); string key=programCur.ProgramNum.ToString()+programCur.ProgName.ToString(); if(ToolBarMain.ImageList.Images.ContainsKey(key)) { //Dispose the existing image only if it already exists, because the image might have changed. ToolBarMain.ImageList.Images[ToolBarMain.ImageList.Images.IndexOfKey(key)].Dispose(); ToolBarMain.ImageList.Images.RemoveByKey(key); } if(programCur.ButtonImage!="") { Image image=PIn.Bitmap(programCur.ButtonImage); ToolBarMain.ImageList.Images.Add(key,image); } if(toolBarsAvail!=ToolBarsAvail.MainToolbar) { ToolBarMain.Buttons.Add(new ODToolBarButton(ODToolBarButtonStyle.Separator)); } ToolBarMain.Buttons.Add(new ODToolBarButton(toolButItemCur.ButtonText,-1,"",programCur)); } for(int i=0;i<ToolBarMain.Buttons.Count;i++) {//Reset the new index, because it might have changed due to removing/adding to the Images list. if(ToolBarMain.Buttons[i].Tag.GetType()!=typeof(Program)) { continue; } Program programCur=(Program)ToolBarMain.Buttons[i].Tag; string key=programCur.ProgramNum.ToString()+programCur.ProgName.ToString(); if(ToolBarMain.ImageList.Images.ContainsKey(key)) { ToolBarMain.Buttons[i].ImageIndex=ToolBarMain.ImageList.Images.IndexOfKey(key); } } }
///<summary>Returns a list of toolbutitems for the specified toolbar. Used when laying out toolbars.</summary> public static ArrayList GetForToolBar(ToolBarsAvail toolbar) { ArrayList retVal = new ArrayList(); for (int i = 0; i < List.Length; i++) { if (List[i].ToolBar == toolbar && Programs.IsEnabled(List[i].ProgramNum)) { retVal.Add(List[i]); } } return(retVal); }
///<summary>Returns a list of toolbutitems for the specified toolbar. Used when laying out toolbars.</summary> public static ArrayList GetForToolBar(ToolBarsAvail toolbar) { //No need to check RemotingRole; no call to db. if (List == null) { RefreshCache(); } ArrayList retVal = new ArrayList(); for (int i = 0; i < List.Length; i++) { if (List[i].ToolBar == toolbar && Programs.IsEnabled(List[i].ProgramNum)) { retVal.Add(List[i]); } } return(retVal); }
///<summary>Returns a list of toolbutitems for the specified toolbar. Used when laying out toolbars.</summary> public static ArrayList GetForToolBar(ToolBarsAvail toolbar){ ArrayList retVal=new ArrayList(); for(int i=0;i<List.Length;i++){ if(List[i].ToolBar==toolbar && Programs.IsEnabled(List[i].ProgramNum)){ retVal.Add(List[i]); } } return retVal; }
///<summary>Returns a list of toolbutitems for the specified toolbar. Used when laying out toolbars.</summary> public static List <ToolButItem> GetForToolBar(ToolBarsAvail toolbar) { //No need to check RemotingRole; no call to db. return(GetWhere(x => x.ToolBar == toolbar && Programs.IsEnabled(x.ProgramNum))); }
public static void LoadToolbar(ODToolBar ToolBarMain, ToolBarsAvail toolBarsAvail) { List <ToolButItem> toolButItems = ToolButItems.GetForToolBar(toolBarsAvail); foreach (ToolButItem toolButItemCur in toolButItems) { Program programCur = Programs.GetProgram(toolButItemCur.ProgramNum); if (PrefC.HasClinicsEnabled) { //User should not have PL hidden if Clinics are not Enabled, otherwise this could create a situation where users may turn clinics off but //have hidden the PL button for HQ and then be unable to turn the button back on without re-enabling Clinics. ProgramProperty programProp = ProgramProperties.GetPropForProgByDesc(programCur.ProgramNum , ProgramProperties.PropertyDescs.ClinicHideButton, Clinics.ClinicNum); if (programProp != null) { continue; //If there exists a programProp for a clinic which should have its buttons hidden, carry on and do not display the button. } } if (ProgramProperties.IsAdvertisingDisabled(programCur)) { continue; } string key = programCur.ProgramNum.ToString() + programCur.ProgName.ToString(); if (ToolBarMain.ImageList.Images.ContainsKey(key)) { //Dispose the existing image only if it already exists, because the image might have changed. ToolBarMain.ImageList.Images[ToolBarMain.ImageList.Images.IndexOfKey(key)].Dispose(); ToolBarMain.ImageList.Images.RemoveByKey(key); } if (programCur.ButtonImage != "") { Image image = PIn.Bitmap(programCur.ButtonImage); ToolBarMain.ImageList.Images.Add(key, image); } else if (programCur.ProgName == ProgramName.Midway.ToString()) { Image image = global::OpenDental.Properties.Resources.Midway_Icon_22x22; ToolBarMain.ImageList.Images.Add(key, image); } if (toolBarsAvail != ToolBarsAvail.MainToolbar) { ToolBarMain.Buttons.Add(new ODToolBarButton(ODToolBarButtonStyle.Separator)); } ODToolBarButton button = new ODToolBarButton(toolButItemCur.ButtonText, -1, "", programCur); AddDropDown(button, programCur); ToolBarMain.Buttons.Add(button); } for (int i = 0; i < ToolBarMain.Buttons.Count; i++) //Reset the new index, because it might have changed due to removing/adding to the Images list. { if (ToolBarMain.Buttons[i].Tag.GetType() != typeof(Program)) { continue; } Program programCur = (Program)ToolBarMain.Buttons[i].Tag; string key = programCur.ProgramNum.ToString() + programCur.ProgName.ToString(); if (ToolBarMain.ImageList.Images.ContainsKey(key)) { ToolBarMain.Buttons[i].ImageIndex = ToolBarMain.ImageList.Images.IndexOfKey(key); } } }
///<summary>Returns a list of toolbutitems for the specified toolbar. Used when laying out toolbars.</summary> public static ArrayList GetForToolBar(ToolBarsAvail toolbar) { //No need to check RemotingRole; no call to db. if(List==null) { RefreshCache(); } ArrayList retVal=new ArrayList(); for(int i=0;i<List.Length;i++){ if(List[i].ToolBar==toolbar && Programs.IsEnabled(List[i].ProgramNum)){ retVal.Add(List[i]); } } return retVal; }