using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Linq;
using MercatorApi;
using MercatorExtensions;
using MercatorUi;
using MercatorDatabase;
namespace HistCli
{
public class Customizer : MercatorUi.ICustomizers.IDialogLoadCustomizer, MercatorUi.ICustomizers.IStringUpdater
{
private MercatorUi._BaseClasses.ComboBoxExReadOnly comboBoxCentralisation;
public void DialogLoadCustomize(System.Windows.Forms.Form form)
{
// Deze lijst komt overeen met de elementen van het rolmenu dat zal worden toegevoegd in het dialoogvenster
List<MercatorUi._BaseClasses.MercatorComboItem> l = new List<MercatorUi._BaseClasses.MercatorComboItem>();
l.Add(new MercatorUi._BaseClasses.MercatorComboItem("Alle", (Int16)0));
l.Add(new MercatorUi._BaseClasses.MercatorComboItem("Niet-gecentraliseerd", (Int16)1));
l.Add(new MercatorUi._BaseClasses.MercatorComboItem("Foutief", (Int16)2));
l.Add(new MercatorUi._BaseClasses.MercatorComboItem("Vast", (Int16)3));
l.Add(new MercatorUi._BaseClasses.MercatorComboItem("Gecentraliseerd", (Int16)4));
// Men voegt het rolmenu toe in het dialoogvenster
comboBoxCentralisation = new MercatorUi._BaseClasses.ComboBoxExReadOnly();
comboBoxCentralisation.DisplayMember = "Text";
comboBoxCentralisation.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawFixed;
comboBoxCentralisation.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
comboBoxCentralisation.FormattingEnabled = true;
comboBoxCentralisation.ItemHeight = 14;
comboBoxCentralisation.Location = new System.Drawing.Point(355, 210);
comboBoxCentralisation.Name = "comboBoxDepot";
comboBoxCentralisation.Size = new System.Drawing.Size(122, 20);
comboBoxCentralisation.BringToFront();
comboBoxCentralisation.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled;
comboBoxCentralisation.DisplayMember = "Description";
comboBoxCentralisation.ValueMember = "N";
comboBoxCentralisation.DataSource = l;
comboBoxCentralisation.SelectedValue = (Int16)0;
form.Controls.Add(comboBoxCentralisation);
form.Disposed += form_disposed;
}
public string StringUpdate(string StringToModify)
{
if (comboBoxCentralisation == null)
return StringToModify; // Men heeft de historiek bereikt zonder gebruik van het dialoogvenster (bv. vanuit een automatische groepering)
string compl_where = null;
int selectedValueInCombo = System.Convert.ToInt32(comboBoxCentralisation.SelectedValue);
if (selectedValueInCombo == 1) // Niet-gecentraliseerd
compl_where = "(cubic=0)";
else if (selectedValueInCombo == 2) // Foutief
compl_where = "((cubic>0) and (cubic<8))";
else if (selectedValueInCombo == 3) // Vast
compl_where = "(cubic=8)";
else if (selectedValueInCombo == 4) // Gecentraliseerd
compl_where = "(cubic=9)";
if (compl_where == null)
return StringToModify;
else
return StringToModify.Replace(" order by ", " and " + compl_where + " order by "); // Men voegt de nieuwe voorwaarde toe net voor order by
}
private void form_disposed(object sender, EventArgs e)
{
System.Windows.Forms.Form form = (System.Windows.Forms.Form)sender;
form.Disposed -= form_disposed;
comboBoxCentralisation = null;
}
}
}