/// <summary> /// This procedure will remove the currently selected column, /// and after that no column is selected /// /// </summary> /// <returns>void</returns> protected bool RemoveColumn(System.Int32 ASelectedColumn, bool AAskBeforeRemove) { bool ReturnValue; System.Int32 NewMaxColumn; ReturnValue = false; if ((!AAskBeforeRemove) || (MessageBox.Show("Do you really want to delete this column?", "Really delete?", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)) { NewMaxColumn = TUC_ColumnHelper.RemoveColumn(ref FColumnParameters, ASelectedColumn); /* need to move the following columns to the left */ FPetraUtilsObject.FMaxDisplayColumns = NewMaxColumn; FillColumnGrid(); FSelectedColumn = -1; SelectColumn(-1); ReturnValue = true; } return(ReturnValue); }
/// <summary> /// This procedure will apply the current settings of the column, /// and then will unselect the column /// /// </summary> /// <returns>void</returns> protected bool ApplyColumn(System.Int32 ASelectedColumn, bool ACheckForDoubleEntries) { bool ReturnValue; ReturnValue = false; double ColumnWidth = 2.0; if (!ACheckForDoubleEntries || TUC_ColumnHelper.CheckAddDoubleEntry(ref FColumnParameters, this.cmbCalculation.GetSelectedString(0), ASelectedColumn)) { try { ColumnWidth = Convert.ToDouble(txtColumnWidth.Text); FColumnParameters.Add("param_calculation", new TVariant(cmbCalculation.GetSelectedString()), ASelectedColumn); FColumnParameters.Add("ColumnWidth", new TVariant(ColumnWidth), ASelectedColumn); ReturnValue = true; } catch (Exception e) { if (e.GetType().ToString() == "System.FormatException") { MessageBox.Show("Please insert a correct number value for the column width", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } ReturnValue = false; } } return(ReturnValue); }
/// <summary> /// Reads the selected values from the controls, /// and stores them into the parameter system of FCalculator /// /// </summary> /// <param name="ACalculator"></param> /// <param name="AReportAction"></param> /// <returns>void</returns> public void ReadControls(TRptCalculator ACalculator, TReportActionEnum AReportAction) { System.Int32 MaxDisplayColumns; MaxDisplayColumns = TUC_ColumnHelper.ReadControls(ref FColumnParameters, ref ACalculator); FPetraUtilsObject.FMaxDisplayColumns = MaxDisplayColumns; }
/// <summary> /// Sets the selected values in the controls, using the parameters loaded from a file /// /// </summary> /// <param name="AParameters"></param> /// <returns>void</returns> public void SetControls(TParameterList AParameters) { System.Int32 MaxDisplayColumns; MaxDisplayColumns = TUC_ColumnHelper.SetControls(ref FColumnParameters, ref AParameters); /* copy values for columns to the current set of parameters */ FPetraUtilsObject.FMaxDisplayColumns = MaxDisplayColumns; FillColumnGrid(); }
/// <summary> /// This procedure will switch the two columns /// and after that the column in the new position is selected /// /// </summary> /// <returns>void</returns> protected virtual void MoveColumn(System.Int32 ASelectedColumn, System.Int32 ANewColumnPosition) { if ((ANewColumnPosition > -1) && (ANewColumnPosition < FColumnParameters.Get("MaxDisplayColumns").ToInt())) { if (SelectColumn(-1)) { TUC_ColumnHelper.SwitchColumn(ref FColumnParameters, ASelectedColumn, ANewColumnPosition); FillColumnGrid(); SelectColumn(ANewColumnPosition); } } }
/// <summary> /// Fills the column choice datagrid with the current values, /// that are stored in the local column parameters /// /// </summary> /// <returns>void</returns> public void FillColumnGrid() { DataTable columnTab; DataRow rowContent; DataRow rowDisplayWidth; System.Int32 counter; String calculation; System.Int32 rowCounter; TPartnerColumnFunction Func; columnTab = new System.Data.DataTable(); /* create columns */ for (counter = 0; counter <= FColumnParameters.Get("MaxDisplayColumns").ToInt() - 1; counter += 1) { columnTab.Columns.Add("Column " + Convert.ToString(counter + 1)); } /* first row: name of calculation */ rowContent = columnTab.NewRow(); /* second row: display width of the column */ rowDisplayWidth = columnTab.NewRow(); for (counter = 0; counter <= FColumnParameters.Get("MaxDisplayColumns").ToInt() - 1; counter += 1) { calculation = FColumnParameters.GetOrDefault("param_calculation", counter, new TVariant(cmbCalculation.GetSelectedString())).ToString(); Func = (TPartnerColumnFunction)GetFunction(calculation, FColumnParameters, counter); if (Func != null) { rowContent[counter] = Func.GetDisplayValue(); rowDisplayWidth[counter] = FColumnParameters.GetOrDefault("ColumnWidth", counter, new TVariant(Func.FColumnWidth)).ToString() + " cm"; } } rowCounter = 0; columnTab.Rows.InsertAt(rowContent, rowCounter); rowCounter = rowCounter + 1; columnTab.Rows.InsertAt(rowDisplayWidth, rowCounter); TUC_ColumnHelper.LoadDataToGrid(ref grdColumns, ref columnTab); }
/// <summary> /// This procedure will add a new column; /// it will check if the currently selected column can be unselected; /// the new column is selected /// </summary> /// <param name="ASelectedColumn">the new column should be inserted after this column /// if it is -1, the column will be added at the right</param> /// <returns>true if a new column was added /// </returns> protected bool AddColumn(System.Int32 ASelectedColumn) { bool ReturnValue; System.Int32 NewColumn; ReturnValue = false; if (SelectColumn(-1)) { NewColumn = TUC_ColumnHelper.AddColumn(ref FColumnParameters, ASelectedColumn); FillColumnGrid(); SelectColumn(NewColumn); ApplyColumn(NewColumn, false); ReturnValue = true; } return(ReturnValue); }
/// <summary> /// get the function object of the given calculation string /// </summary> /// <returns>nil if the function cannot be found /// </returns> protected TColumnFunction GetFunction(String calculation, TParameterList AParameterList, int AColumnNumber) { return(TUC_ColumnHelper.GetFunction(ref FAvailableFunctions, calculation, AParameterList, AColumnNumber)); }
/// <summary> /// get the function object of the given calculation string /// </summary> /// <returns>nil if the function cannot be found /// </returns> protected TColumnFunction GetFunction(String calculation) { return(TUC_ColumnHelper.GetFunction(ref FAvailableFunctions, calculation)); }