Exemplo n.º 1
0
		///<summary>Only for editing fields that already exist.</summary>
		private void LaunchEditWindow(SheetFieldDef field){
			bool refreshBuffer=false;
			//not every field will have been saved to the database, so we can't depend on SheetFieldDefNum.
			int idx=SheetDefCur.SheetFieldDefs.IndexOf(field);
			switch(field.FieldType){
				case SheetFieldType.InputField:
					FormSheetFieldInput FormS=new FormSheetFieldInput();
					FormS.SheetDefCur=SheetDefCur;
					FormS.SheetFieldDefCur=field;
					if(this.IsInternal){
						FormS.IsReadOnly=true;
					}
					FormS.ShowDialog();
					if(FormS.DialogResult!=DialogResult.OK){
						return;
					}
					if(FormS.SheetFieldDefCur==null){
						SheetDefCur.SheetFieldDefs.RemoveAt(idx);
					}
					break;
				case SheetFieldType.OutputText:
					FormSheetFieldOutput FormSO=new FormSheetFieldOutput();
					FormSO.SheetDefCur=SheetDefCur;
					FormSO.SheetFieldDefCur=field;
					if(this.IsInternal){
						FormSO.IsReadOnly=true;
					}
					FormSO.ShowDialog();
					if(FormSO.DialogResult!=DialogResult.OK){
						return;
					}
					if(FormSO.SheetFieldDefCur==null){
						SheetDefCur.SheetFieldDefs.RemoveAt(idx);
					}
					break;
				case SheetFieldType.StaticText:
					FormSheetFieldStatic FormSS=new FormSheetFieldStatic();
					FormSS.SheetDefCur=SheetDefCur;
					FormSS.SheetFieldDefCur=field;
					if(this.IsInternal){
						FormSS.IsReadOnly=true;
					}
					FormSS.ShowDialog();
					if(FormSS.DialogResult!=DialogResult.OK){
						return;
					}
					if(FormSS.SheetFieldDefCur==null){
						SheetDefCur.SheetFieldDefs.RemoveAt(idx);
					}
					break;
				case SheetFieldType.Image:
					FormSheetFieldImage FormSI=new FormSheetFieldImage();
					FormSI.SheetDefCur=SheetDefCur;
					FormSI.SheetFieldDefCur=field;
					if(this.IsInternal){
						FormSI.IsReadOnly=true;
					}
					FormSI.ShowDialog();
					if(FormSI.DialogResult!=DialogResult.OK){
						return;
					}
					if(FormSI.SheetFieldDefCur==null) {
						SheetDefCur.SheetFieldDefs.RemoveAt(idx);
					}
					refreshBuffer=true;
					break;
				case SheetFieldType.PatImage:
					FormSheetFieldPatImage FormSPI=new FormSheetFieldPatImage();
					FormSPI.SheetDefCur=SheetDefCur;
					FormSPI.SheetFieldDefCur=field;
					if(this.IsInternal) {
						FormSPI.IsReadOnly=true;
					}
					FormSPI.ShowDialog();
					if(FormSPI.DialogResult!=DialogResult.OK) {
						return;
					}
					if(FormSPI.SheetFieldDefCur==null) {
						SheetDefCur.SheetFieldDefs.RemoveAt(idx);
					}
					refreshBuffer=true;
					break;
				case SheetFieldType.Line:
					FormSheetFieldLine FormSL=new FormSheetFieldLine();
					FormSL.SheetDefCur=SheetDefCur;
					FormSL.SheetFieldDefCur=field;
					if(this.IsInternal){
						FormSL.IsReadOnly=true;
					}
					FormSL.ShowDialog();
					if(FormSL.DialogResult!=DialogResult.OK){
						return;
					}
					if(FormSL.SheetFieldDefCur==null){
						SheetDefCur.SheetFieldDefs.RemoveAt(idx);
					}
					break;
				case SheetFieldType.Rectangle:
					FormSheetFieldRect FormSR=new FormSheetFieldRect();
					FormSR.SheetDefCur=SheetDefCur;
					FormSR.SheetFieldDefCur=field;
					if(this.IsInternal){
						FormSR.IsReadOnly=true;
					}
					FormSR.ShowDialog();
					if(FormSR.DialogResult!=DialogResult.OK){
						return;
					}
					if(FormSR.SheetFieldDefCur==null){
						SheetDefCur.SheetFieldDefs.RemoveAt(idx);
					}
					break;
				case SheetFieldType.CheckBox:
					FormSheetFieldCheckBox FormSB=new FormSheetFieldCheckBox();
					FormSB.SheetDefCur=SheetDefCur;
					FormSB.SheetFieldDefCur=field;
					if(this.IsInternal){
						FormSB.IsReadOnly=true;
					}
					FormSB.ShowDialog();
					if(FormSB.DialogResult!=DialogResult.OK){
						return;
					}
					if(FormSB.SheetFieldDefCur==null){
						SheetDefCur.SheetFieldDefs.RemoveAt(idx);
					}
					break;
				case SheetFieldType.SigBox:
					FormSheetFieldSigBox FormSBx=new FormSheetFieldSigBox();
					FormSBx.SheetDefCur=SheetDefCur;
					FormSBx.SheetFieldDefCur=field;
					if(this.IsInternal){
						FormSBx.IsReadOnly=true;
					}
					FormSBx.ShowDialog();
					if(FormSBx.DialogResult!=DialogResult.OK){
						return;
					}
					if(FormSBx.SheetFieldDefCur==null){
						SheetDefCur.SheetFieldDefs.RemoveAt(idx);
					}
					break;
				case SheetFieldType.Special:
					FormSheetFieldSpecial FormSFS=new FormSheetFieldSpecial();
					FormSFS.SheetDefCur=SheetDefCur;
					FormSFS.SheetFieldDefCur=field;
					if(this.IsInternal) {
						FormSFS.IsReadOnly=true;
					}
					FormSFS.ShowDialog();
					if(FormSFS.DialogResult!=DialogResult.OK) {
						return;
					}
					if(FormSFS.SheetFieldDefCur==null) {
						SheetDefCur.SheetFieldDefs.RemoveAt(idx);
					}
					break;
				case SheetFieldType.Grid:
					FormSheetFieldGrid FormSFG=new FormSheetFieldGrid();
					FormSFG.SheetDefCur=SheetDefCur;
					FormSFG.SheetFieldDefCur=field;
					if(this.IsInternal) {
						FormSFG.IsReadOnly=true;
					}
					FormSFG.ShowDialog();
					if(FormSFG.DialogResult!=DialogResult.OK) {
						return;
					}
					if(FormSFG.SheetFieldDefCur==null) {
						SheetDefCur.SheetFieldDefs.RemoveAt(idx);
						return;
					}
					break;
			}
			if(IsTabMode) {
				if(ListSheetFieldDefsTabOrder.Contains(field)) {
					ListSheetFieldDefsTabOrder.RemoveAt(ListSheetFieldDefsTabOrder.IndexOf(field));
				}
				if(field.TabOrder>0 && field.TabOrder<=(ListSheetFieldDefsTabOrder.Count+1)) {
					ListSheetFieldDefsTabOrder.Insert(field.TabOrder-1,field);
				}
				RenumberTabOrderHelper();
				return;
			}
			//listFields.ClearSelected();
			FillFieldList();
			if(refreshBuffer) {//Only when image was edited.
				RefreshDoubleBuffer();
			}
			//for(int i=0;i<SheetDefCur.SheetFieldDefs.Count;i++) {
			//	if(SheetDefCur.SheetFieldDefs[i].FieldType==field.FieldType
			//		&& SheetDefCur.SheetFieldDefs[i].FieldType==field.FieldType
			//		&& SheetDefCur.SheetFieldDefs[i].FieldType==field.FieldType
			//}
			//idx=SheetDefCur.SheetFieldDefs.IndexOf(field);
			//if(idx>0) {//only true if field was not deleted.
			//	listFields.SetSelected(idx,true);
			//}
			if(listFields.Items.Count-1>=idx){
				listFields.SelectedIndex=idx;//reselect the item.
			}
			panelMain.Refresh();
		}
Exemplo n.º 2
0
		private void butAddStaticText_Click(object sender,EventArgs e) {
			Font font=new Font(SheetDefCur.FontName,SheetDefCur.FontSize);
			FormSheetFieldStatic FormS=new FormSheetFieldStatic();
			FormS.SheetDefCur=SheetDefCur;
			FormS.SheetFieldDefCur=SheetFieldDef.NewStaticText("",SheetDefCur.FontSize,SheetDefCur.FontName,false,0,0,100,font.Height);
			if(this.IsInternal){
				FormS.IsReadOnly=true;
			}
			FormS.ShowDialog();
			if(FormS.DialogResult!=DialogResult.OK){
				return;
			}
			SheetDefCur.SheetFieldDefs.Add(FormS.SheetFieldDefCur);
			FillFieldList();
			panelMain.Refresh();
		}