Пример #1
0
		///<summary></summary>
		public static long Insert(SigButDef def) {
			if(RemotingClient.RemotingRole==RemotingRole.ClientWeb) {
				def.SigButDefNum=Meth.GetLong(MethodBase.GetCurrentMethod(),def);
				return def.SigButDefNum;
			}
			return Crud.SigButDefCrud.Insert(def);
		}
Пример #2
0
		///<summary></summary>
		public static void Update(SigButDef def) {
			if(RemotingClient.RemotingRole==RemotingRole.ClientWeb) {
				Meth.GetVoid(MethodBase.GetCurrentMethod(),def);
				return;
			}
			Crud.SigButDefCrud.Update(def);
		}
Пример #3
0
		///<summary>Used in the Button edit dialog.</summary>
		public static void DeleteElements(SigButDef def) {
			if(RemotingClient.RemotingRole==RemotingRole.ClientWeb) {
				Meth.GetVoid(MethodBase.GetCurrentMethod(),def);
				return;
			}
			string command="DELETE FROM sigbutdefelement WHERE SigButDefNum="+POut.Long(def.SigButDefNum);
			Db.NonQ(command);
		}
Пример #4
0
		///<summary></summary>
		public SigButDef Copy() {
			SigButDef s=new SigButDef();
			s.SigButDefNum=SigButDefNum;
			s.ButtonText=ButtonText;
			s.ButtonIndex=ButtonIndex;
			s.SynchIcon=SynchIcon;
			s.ComputerName=ComputerName;
			s.ElementList=new SigButDefElement[ElementList.Length];
			ElementList.CopyTo(s.ElementList,0);
			return s;
		}
Пример #5
0
 ///<summary>Used in Setup.  The returned list also includes defaults if not overridden by one with a computername.  The supplied computer name can be blank for the default setup.</summary>
 public static SigButDef[] GetByComputer(string computerName)
 {
     //No need to check RemotingRole; no call to db.
     //first, get a default list, because we will always need that
     ArrayList AL=new ArrayList();
     for(int i=0;i<Listt.Length;i++) {
         if(Listt[i].ComputerName=="") {
             AL.Add(Listt[i]);
         }
     }
     SigButDef[] defaultList=new SigButDef[AL.Count];
     AL.CopyTo(defaultList);
     if(computerName=="") {//if all we are interested in is the default list, then done.
         return defaultList;
     }
     //for any other computer:
     List<SigButDef> listSigButDefs=new List<SigButDef>();
     for(int i=0;i<Listt.Length;i++) {
         if(computerName==Listt[i].ComputerName) {
             listSigButDefs.Add(Listt[i]);
         }
     }
     //but we are still missing some defaults
     SigButDef matchingBut;
     for(int i=0;i<defaultList.Length;i++) {
         matchingBut=GetByIndex(defaultList[i].ButtonIndex,listSigButDefs);//retVal);
         if(matchingBut!=null) {//There is a button for this computer which overrides the default, so don't add the default.
             continue;
         }
         //AL.Add(defaultList[i]);
         listSigButDefs.Add(defaultList[i]);
     }
     listSigButDefs.Sort(CompareButtonsByIndex);
     SigButDef[] retVal=new SigButDef[listSigButDefs.Count];
     listSigButDefs.CopyTo(retVal);
     return retVal;
 }
Пример #6
0
		private void listButtons_DoubleClick(object sender,EventArgs e) {
			if(listButtons.SelectedIndex==-1){//should never happen
				return;
			}
			//Save any changes to the cache because the item order could have changed.
			if(SigButDefs.UpdateButtonIndexIfChanged(SubList)) {
				DataValid.SetInvalid(InvalidType.Signals);
			}
			int selected=listButtons.SelectedIndex;
			SigButDef button=SigButDefs.GetByIndex(selected,SubList);
			string computerName="";
			if(button==null){//Add
				FormSigButDefEdit FormS=new FormSigButDefEdit();
				FormS.IsNew=true;
				button=new SigButDef();
				button.ElementList=new SigButDefElement[0];
				button.ButtonIndex=selected;
				if(listComputers.SelectedIndex!=0) {
					computerName=Computers.List[listComputers.SelectedIndex-1].CompName;
				}
				button.ComputerName=computerName;
				FormS.ButtonCur=button.Copy();
				FormS.ShowDialog();
			}
			else if(button.ComputerName=="" && listComputers.SelectedIndex!=0){
				//create a copy of the default, and treat it as a new
				FormSigButDefEdit FormS=new FormSigButDefEdit();
				FormS.IsNew=true;
				button.ComputerName=Computers.List[listComputers.SelectedIndex-1].CompName;
				FormS.ButtonCur=button.Copy();
				FormS.ShowDialog();
			}
			else{//edit
				if(listComputers.SelectedIndex>0) {//If "All" is selected, the computerName will already be blank, so it only needs reset if it isn't "All".
					computerName=Computers.List[listComputers.SelectedIndex].CompName;
				}
				FormSigButDefEdit FormS=new FormSigButDefEdit();
				FormS.ButtonCur=button.Copy();
				FormS.ShowDialog();
			}
			SubList=SigButDefs.GetByComputer(computerName);//Refresh our local list to match the cache in case the user edited or added a new button item.
			FillList();
		}
Пример #7
0
		/// <summary></summary>
		/// <param name="myButton"></param>
		public ODLightSignalGridClickEventArgs(int myButton,SigButDef myDef,Signalod mySignal) {
			buttonIndex=myButton;
			buttonDef=myDef;
			activeSignal=mySignal;
		}
Пример #8
0
		///<summary></summary>
		protected void OnButtonClicked(int myButton,SigButDef myDef,Signalod mySignal) {
			ODLightSignalGridClickEventArgs bArgs=new ODLightSignalGridClickEventArgs(myButton,myDef,mySignal);
			if(ButtonClick!=null)
				ButtonClick(this,bArgs);
		}
Пример #9
0
		//private void DrawBackground(Graphics g){
			
		//	g.DrawRectangle()
		//}
		#endregion Painting

		///<summary>This will clear the buttons, reset buttons to the specified list, reset the buttonstates, layout the rows, and invalidate for repaint.</summary>
		public void SetButtons(SigButDef[] butDefs) {
			if(butDefs.Length==0){
				sigButStates=new SignalButtonState[0];
				LayoutButtons();
				Invalidate();
				return;
			}
			//since defs are ordered by buttonIndex, the last def will contain the max number of buttons
			sigButStates=new SignalButtonState[butDefs[butDefs.Length-1].ButtonIndex+1];
			for(int i=0;i<sigButStates.Length;i++){
				sigButStates[i]=new SignalButtonState();
				sigButStates[i].ButDef=SigButDefs.GetByIndex(i,butDefs);//might be null
				if(sigButStates[i].ButDef!=null){
					sigButStates[i].Text=sigButStates[i].ButDef.ButtonText;
				}
				sigButStates[i].CurrentColor=Color.White;
			}
			LayoutButtons();
			Invalidate();
		}
Пример #10
0
 private void listButtons_DoubleClick(object sender,EventArgs e)
 {
     if(listButtons.SelectedIndex==-1){//should never happen
         return;
     }
     int selected=listButtons.SelectedIndex;
     SigButDef button=SigButDefs.GetByIndex(selected,SubList);
     if(button==null){//Add
         FormSigButDefEdit FormS=new FormSigButDefEdit();
         FormS.IsNew=true;
         button=new SigButDef();
         button.ElementList=new SigButDefElement[0];
         button.ButtonIndex=selected;
         if(listComputers.SelectedIndex==0){
             button.ComputerName="";
         }
         else{
             button.ComputerName=Computers.List[listComputers.SelectedIndex-1].CompName;
         }
         FormS.ButtonCur=button.Copy();
         FormS.ShowDialog();
     }
     else if(button.ComputerName=="" && listComputers.SelectedIndex!=0){
         //create a copy of the default, and treat it as a new
         FormSigButDefEdit FormS=new FormSigButDefEdit();
         FormS.IsNew=true;
         button.ComputerName=Computers.List[listComputers.SelectedIndex-1].CompName;
         FormS.ButtonCur=button.Copy();
         FormS.ShowDialog();
     }
     else{//edit
         FormSigButDefEdit FormS=new FormSigButDefEdit();
         FormS.ButtonCur=button.Copy();
         FormS.ShowDialog();
     }
     FillList();
 }
Пример #11
0
 private static int CompareButtonsByIndex(SigButDef x,SigButDef y)
 {
     //No need to check RemotingRole; no call to db.
     return x.ButtonIndex.CompareTo(y.ButtonIndex);
 }
Пример #12
0
 ///<summary>Moves the selected item up in the supplied sub list.</summary>
 public static void MoveUp(SigButDef selected,SigButDef[] subList)
 {
     //No need to check RemotingRole; no call to db.
     if(selected.ButtonIndex==0) {//already at top
         return;
     }
     SigButDef occupied=null;
     for(int i=0;i<subList.Length;i++) {
         if(subList[i].SigButDefNum!=selected.SigButDefNum//if not the selected object
             && subList[i].ButtonIndex==selected.ButtonIndex-1)//and position occupied
         {
             occupied=subList[i].Copy();
         }
     }
     if(occupied!=null) {
         occupied.ButtonIndex++;
         Update(occupied);
     }
     selected.ButtonIndex--;
     Update(selected);
 }
Пример #13
0
 ///<summary></summary>
 public static void MoveDown(SigButDef selected,SigButDef[] subList)
 {
     //No need to check RemotingRole; no call to db.
     if(selected.ButtonIndex==20) {
         throw new ApplicationException(Lans.g("SigButDefs","Max 20 buttons."));
     }
     SigButDef occupied=null;
     for(int i=0;i<subList.Length;i++) {
         if(subList[i].SigButDefNum!=selected.SigButDefNum//if not the selected object
             && subList[i].ButtonIndex==selected.ButtonIndex+1)//and position occupied
         {
             occupied=subList[i].Copy();
         }
     }
     if(occupied!=null) {
         occupied.ButtonIndex--;
         Update(occupied);
     }
     selected.ButtonIndex++;
     Update(selected);
 }
Пример #14
0
 ///<summary>Loops through the element list and pulls out one element of a specific type. Used in the button edit window.</summary>
 public static SigButDefElement GetElement(SigButDef def,SignalElementType elementType)
 {
     //No need to check RemotingRole; no call to db.
     for(int i=0;i<def.ElementList.Length;i++) {
         if(SigElementDefs.GetElement(def.ElementList[i].SigElementDefNum).SigElementType==elementType) {
             return def.ElementList[i].Copy();
         }
     }
     return null;
 }
Пример #15
0
 ///<summary>Returns the SigButDef with the specified buttonIndex.  Used from the setup page.  The supplied list will already have been filtered by computername.  Supply buttonIndex in 0-based format.</summary>
 public static SigButDef GetByIndex(int buttonIndex,SigButDef[] subList)
 {
     //No need to check RemotingRole; no call to db.
     for(int i=0;i<subList.Length;i++) {
         if(subList[i].ButtonIndex==buttonIndex) {
             return subList[i].Copy();
         }
     }
     return null;
 }