Ejemplo n.º 1
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();
		}
Ejemplo n.º 2
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();
 }