Пример #1
0
        public MainForm()
        {
            if (!string.IsNullOrEmpty(Settings.Default.Language))
            Thread.CurrentThread.CurrentUICulture = new CultureInfo(Settings.Default.Language);
              this.LookAndFeel.SetSkinStyle("Office 2010 Blue");
              InitializeComponent();

              if (!Settings.Default.WindowSize.IsEmpty)
            this.Size = Settings.Default.WindowSize;
              this.title = string.Format(base.Text, AppVersion);
              base.Text = title;
              this.plugins = this.LoadSerializerPlugins();
              this.FillMenuWithIsoEncodings();

              using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("ChanSort.Ui.app.ico"))
              {
            if (stream != null)
              this.Icon = new Icon(stream);
              }
              var bcLeft = new BindingContext();
              this.grpOutputList.BindingContext = bcLeft;
              this.lastFocusedGrid = this.gviewRight;
              if (this.curEditMode == EditMode.InsertAfter) this.rbInsertAfter.Checked = true;
              else if (this.curEditMode == EditMode.InsertBefore) this.rbInsertBefore.Checked = true;
              else this.rbInsertSwap.Checked = true;
              this.ActiveControl = this.gridRight;

            #if !ADD_CHANNELS_FROM_REF_LIST
              this.miAddFromRefList.Visibility = BarItemVisibility.Never;
              this.miAddFromRefList.Enabled = false;
            #endif
        }
Пример #2
0
        /// <summary>
        /// Fill list box with fileds of the current datasource.
        /// </summary>
        /// <param name="listBox">ListBox control to fill.</param>
        /// <param name="context">Type descriptor context.</param>
        /// <param name="value">Current value.</param>
        protected override void FillListBox(ListBox listBox, ITypeDescriptorContext context, object value)
        {
            var selectedField = (string) value;
            if (selectedField == null)
                selectedField = string.Empty;

            var dataSourceDescriptor = TypeDescriptor.GetProperties(context.Instance)["DataSource"];
            if (dataSourceDescriptor == null)
            {
                return;
            }
            var dataSource = dataSourceDescriptor.GetValue(context.Instance);
            if (dataSource != null)
            {
                var currencyManager = new BindingContext()[dataSource] as CurrencyManager;
                if (currencyManager != null)
                {
                    foreach (PropertyDescriptor descriptor in currencyManager.GetItemProperties())
                    {
                        int lastIndex = listBox.Items.Add(descriptor.Name);
                        if (string.Compare(descriptor.Name, selectedField) == 0)
                        {
                            listBox.SelectedIndex = lastIndex;
                        }
                    }
                }
            }
        }
 private static bool ValidDataMember(object dataSource, string dataMember)
 {
     if (!string.IsNullOrEmpty(dataMember))
     {
         BindingManagerBase base2;
         if (bc == null)
         {
             bc = new BindingContext();
         }
         BindingMemberInfo info = new BindingMemberInfo(dataMember);
         PropertyDescriptorCollection itemProperties = null;
         try
         {
             base2 = bc[dataSource, info.BindingPath];
         }
         catch (ArgumentException)
         {
             return false;
         }
         if (base2 == null)
         {
             return false;
         }
         itemProperties = base2.GetItemProperties();
         if (itemProperties == null)
         {
             return false;
         }
         if (itemProperties[info.BindingField] == null)
         {
             return false;
         }
     }
     return true;
 }
		public void CheckValidDataSource_emptyMappingName ()
		{
			StylePoker p = new StylePoker ();
			string[] arr = new string[] { "hi", "bye" };
			BindingContext bc = new BindingContext ();

			p.DoCheckValidDataSource ((CurrencyManager)bc[arr]);
		}
Пример #5
0
		public void BindingContextChangedTest ()
		{
			Control c = new Control ();
			// Test BindingContextChanged Event
			c.BindingContextChanged += new EventHandler (Event_Handler1);
			BindingContext bcG1 = new BindingContext ();
			eventhandled = false;
			c.BindingContext = bcG1;
			Assert.AreEqual (true, eventhandled, "#A3");

		}
Пример #6
0
		public void CtorTest ()
		{
			BindingContext bc = new BindingContext ();

			Assert.IsFalse (bc.IsReadOnly, "CT1");
			Assert.IsFalse (bc.Contains (this), "CT2");
			Assert.IsFalse (bc.Contains (this, String.Empty), "CT3");
			Assert.IsFalse (bc.Contains (this, "Me is String"), "CT4");

			// Test the ICollection interface
			ICollection ic = (ICollection) bc;
			Assert.AreEqual (ic.Count, 0, "CT5");
			Assert.IsFalse (ic.IsSynchronized, "CT6");
			Assert.IsNull (ic.SyncRoot, "CT7");
			object [] arr = new object [] { "A", "B", "C" };
			ic.CopyTo (arr, 0);
			Assert.AreEqual (0, ic.Count, "CT8");
			Assert.IsFalse (ic.GetEnumerator ().MoveNext (), "CT9");
		}
Пример #7
0
        public static void PopulateComboBox(string storedProc, ComboBox cbo, string colName, string colValue, List<SqlParameter> lstParams, BindingContext bindingContext)
        {
            if (cbo != null)
            {
                DB db = new DB();
                if (lstParams != null)
                {
                    foreach (SqlParameter p in lstParams)
                    {
                        db.AddParam(p.ParameterName, p.Value);
                    }
                }

                DataTable dt = db.SQLResults(storedProc);
                cbo.DataSource = dt;
                cbo.DisplayMember = colName;
                cbo.ValueMember = colValue;
                cbo.BindingContext = bindingContext;
            }
        }
 private static void CheckPropertyBindingCycles(BindingContext newBindingContext, Binding propBinding)
 {
     if (((newBindingContext != null) && (propBinding != null)) && newBindingContext.Contains(propBinding.BindableComponent, ""))
     {
         BindingManagerBase base2 = newBindingContext.EnsureListManager(propBinding.BindableComponent, "");
         for (int i = 0; i < base2.Bindings.Count; i++)
         {
             Binding binding = base2.Bindings[i];
             if (binding.DataSource == propBinding.BindableComponent)
             {
                 if (propBinding.BindToObject.BindingMemberInfo.BindingMember.Equals(binding.PropertyName))
                 {
                     throw new ArgumentException(System.Windows.Forms.SR.GetString("DataBindingCycle", new object[] { binding.PropertyName }), "propBinding");
                 }
             }
             else if (propBinding.BindToObject.BindingManagerBase is PropertyManager)
             {
                 CheckPropertyBindingCycles(newBindingContext, binding);
             }
         }
     }
 }
Пример #9
0
        public ToolsPanel()
        {
            //graphcreator = g;
            routes = Status.Routes;
            points = Status.Points;

            InitializeComponent();

            routesListBox.DataSource = routes;
            //routesListBox.DataSource = Status.myRoutes.routes;
            //routesListBox.DisplayMember = "rs";
            BindingContext bc1 = new BindingContext();
            BindingContext bc2 = new BindingContext();

            srcPoint.BindingContext = bc1;
            srcPoint.DataSource = points;

            destPoint.BindingContext = bc2;
            destPoint.DataSource = points;

            srcPoint.DisplayMember = "N";
            destPoint.DisplayMember = "N";
        }
Пример #10
0
 CreateGridTables(DataGridTableStyle gridTable, object dataSource, string dataMember, BindingContext bindingManager)
 {
     return(new DataGridTableStyle[] { gridTable });
 }
Пример #11
0
 public static void UpdateBinding(BindingContext newBindingContext, Binding binding)
 {
 }
Пример #12
0
		public void Bug81022 ()
		{
			if (TestHelper.RunningOnUnix) {
				Assert.Ignore ("Fails at the moment");
			}

			BindingContext bc = new BindingContext ();
			CurrencyManager cm;

			DataView dv = new DataView();
			DataTable dt = new DataTable("Testdata");

			cm = (CurrencyManager)bc [dt];

			HookupCurrencyManager (cm);

			event_log = ""; event_num = 0;

			dv.Table = dt;

			Assert.AreEqual ("", event_log, "1");

			Console.WriteLine (">1");
			dt.Columns.Add("A");
			Console.WriteLine ("<1");

			Assert.AreEqual ("0: MetaDataChanged\n", event_log, "1");

			event_log = ""; event_num = 0;
			Console.WriteLine (">2");
			dt.Columns.Add("B");
			Console.WriteLine ("<2");

			Assert.AreEqual ("0: MetaDataChanged\n", event_log, "2");

			event_log = ""; event_num = 0;
			Console.WriteLine (">3");
			dt.Rows.Add(new object[]{"A1", "B1"});
			Console.WriteLine ("<3");

#if NET_2_0
			Assert.AreEqual ("0: PositionChanged (to 0)\n1: CurrentChanged\n2: CurrentItemChanged\n3: ItemChanged (index = -1)\n4: ItemChanged (index = -1)\n", event_log, "3");
#else
			Assert.AreEqual ("0: PositionChanged (to 0)\n1: CurrentChanged\n2: ItemChanged (index = -1)\n3: ItemChanged (index = -1)\n", event_log, "3");
#endif

			event_log = ""; event_num = 0;
			Console.WriteLine (">4");
			dt.Rows.Add(new object[]{"A2", "B2"});
			Console.WriteLine ("<4");

			Assert.AreEqual ("0: ItemChanged (index = -1)\n", event_log, "4");

			Assert.AreEqual (2, cm.Count, "5");
		}
     CreateGridTables(DataGridTableStyle gridTable, object dataSource, string dataMember, BindingContext bindingManager)
 {
     return new DataGridTableStyle[] {gridTable};
 }
Пример #14
0
 public static DataGridTableStyle[] CreateGridTables(DataGridTableStyle gridTable, object dataSource, string dataMember, BindingContext bindingManager)
 {
     throw new NotImplementedException();
 }
Пример #15
0
		public void NonStringConverterTest ()
		{
			CultureInfo originalCulture = CultureInfo.CurrentCulture;

			try {
				Thread.CurrentThread.CurrentCulture = new CultureInfo ("en-GB");

				table = new DataTable ();
				view = table.DefaultView;
				table.Columns.Add (new DataColumn ("Amount", typeof (MockNumericNonStringConvertable)));

				DataRow row = table.NewRow ();
				row ["Amount"] = new MockNumericNonStringConvertable (1);
				table.Rows.Add (row);

				row = table.NewRow ();
				row ["Amount"] = new MockNumericNonStringConvertable (2);
				table.Rows.Add (row);

				tableStyle = new DataGridTableStyle ();
				ColumnPoker amountColumnStyle = new ColumnPoker ();
				amountColumnStyle.MappingName = "Amount";
				tableStyle.GridColumnStyles.Add (amountColumnStyle);

				BindingContext bc = new BindingContext ();
				DataGrid dg = new DataGrid ();
				dg.BindingContext = bc;
				dg.TableStyles.Add (tableStyle);
				dg.DataSource = table;

				CurrencyManager cm = (CurrencyManager) bc [view];
				TextBox tb = amountColumnStyle.TextBox;

				Assert.IsNotNull (tb, "#A1");
				Assert.AreEqual (string.Empty, tb.Text, "#A2");

				amountColumnStyle.DoEdit (cm, 0, new Rectangle (new Point (0, 0), new Size (100, 100)), false, null, true);
				Assert.AreEqual ("uno", tb.Text, "#B1");
				Assert.AreEqual (new MockNumericStringConvertable (1), table.Rows [0] ["Amount"], "#B2");

				amountColumnStyle.DoEdit (cm, 1, new Rectangle (new Point (0, 0), new Size (100, 100)), false, null, true);
				Assert.AreEqual ("dos", tb.Text, "#C1");
				Assert.AreEqual (new MockNumericStringConvertable (2), table.Rows [1] ["Amount"], "#C2");

				amountColumnStyle.DoEdit (cm, 0, new Rectangle (new Point (0, 0), new Size (100, 100)), false, "£3.00", true);
				Assert.AreEqual ("£3.00", tb.Text, "#D1");
				Assert.AreEqual (new MockNumericStringConvertable (1), table.Rows [0] ["Amount"], "#D2");

				Assert.IsFalse (amountColumnStyle.DoCommit (cm, cm.Position), "#E1");
				Assert.AreEqual ("£3.00", tb.Text, "#E2");
				//Assert.AreEqual ("£3.00", table.Rows [0] ["Amount"], "#E3");
			} finally {
				Thread.CurrentThread.CurrentCulture = originalCulture;
			}
		}
Пример #16
0
		public void IFormattable_DateTime ()
		{
			CultureInfo originalCulture = CultureInfo.CurrentCulture;

			try {
				Thread.CurrentThread.CurrentCulture = new CultureInfo ("nl-BE");
				DateTime today = DateTime.Today;
				DateTime now = DateTime.Now;

				table = new DataTable ();
				view = table.DefaultView;
				table.Columns.Add (new DataColumn ("Date", typeof (DateTime)));

				DataRow row = table.NewRow ();
				row ["Date"] = today;
				table.Rows.Add (row);

				row = table.NewRow ();
				row ["Date"] = now;
				table.Rows.Add (row);

				tableStyle = new DataGridTableStyle ();
				ColumnPoker dateColumnStyle = new ColumnPoker ();
				dateColumnStyle.MappingName = "Date";
				tableStyle.GridColumnStyles.Add (dateColumnStyle);

				BindingContext bc = new BindingContext ();
				DataGrid dg = new DataGrid ();
				dg.BindingContext = bc;
				dg.TableStyles.Add (tableStyle);
				dg.DataSource = table;

				CurrencyManager cm = (CurrencyManager) bc [view];
				TextBox tb = dateColumnStyle.TextBox;
				DateTimeConverter converter = new DateTimeConverter ();

				Assert.IsNotNull (tb, "#A1");
				Assert.AreEqual (string.Empty, tb.Text, "#A2");

				dateColumnStyle.DoEdit (cm, 0, new Rectangle (new Point (0,0), new Size (100, 100)), false, null, true);
				Assert.AreEqual (converter.ConvertTo (null, CultureInfo.CurrentCulture,
					today, typeof (string)), tb.Text, "#B1");
				Assert.AreEqual (today, table.Rows [0] ["Date"], "#B2");

				dateColumnStyle.DoEdit (cm, 1, new Rectangle (new Point (0,0), new Size (100, 100)), false, null, true);
				Assert.AreEqual (converter.ConvertTo (null, CultureInfo.CurrentCulture,
					now, typeof (string)), tb.Text, "#C1");
				Assert.AreEqual (now, table.Rows [1] ["Date"], "#C2");

				dateColumnStyle.Format = "MM";

				dateColumnStyle.DoEdit (cm, 0, new Rectangle (new Point (0,0), new Size (100, 100)), false, null, true);
				Assert.AreEqual (today.ToString ("MM", CultureInfo.CurrentCulture), tb.Text, "#D1");
				Assert.AreEqual (today, table.Rows [0] ["Date"], "#D2");

				dateColumnStyle.DoEdit (cm, 1, new Rectangle (new Point (0,0), new Size (100, 100)), false, null, true);
				Assert.AreEqual (now.ToString ("MM", CultureInfo.CurrentCulture), tb.Text, "#E1");
				Assert.AreEqual (now, table.Rows [1] ["Date"], "#E2");

				dateColumnStyle.DoEdit (cm, 0, new Rectangle (new Point (0,0), new Size (100, 100)), false, "INVALID", true);
				Assert.IsFalse (dateColumnStyle.DoCommit (cm, 0), "#F1");
				Assert.AreEqual ("INVALID", tb.Text, "#F2");
				Assert.AreEqual (today, table.Rows [0] ["Date"], "#F3");

				dateColumnStyle.DoEdit (cm, 0, new Rectangle (new Point (0,0), new Size (100, 100)), false, "12", true);
				Assert.IsFalse (dateColumnStyle.DoCommit (cm, 0), "#G1");
				Assert.AreEqual ("12", tb.Text, "#G2");
				Assert.AreEqual (today, table.Rows [0] ["Date"], "#G3");

				dateColumnStyle.DoEdit (cm, 0, new Rectangle (new Point (0,0), new Size (100, 100)), false, "07/09/2007", true);
				Assert.IsTrue (dateColumnStyle.DoCommit (cm, 0), "#H1");
				Assert.AreEqual (converter.ConvertTo (null, CultureInfo.CurrentCulture,
					new DateTime (2007, 9, 7), typeof (string)), tb.Text, "#H2");
				Assert.AreEqual (new DateTime (2007, 9, 7), table.Rows [0] ["Date"], "#H3");

				dateColumnStyle.FormatInfo = CultureInfo.CurrentCulture;

				dateColumnStyle.DoEdit (cm, 0, new Rectangle (new Point (0,0), new Size (100, 100)), false, "08/06/2005", true);
				Assert.IsTrue (dateColumnStyle.DoCommit (cm, 0), "#I1");
				Assert.AreEqual ("06", tb.Text, "#I2");
				Assert.AreEqual (new DateTime (2005, 6, 8), table.Rows [0] ["Date"], "#I3");
			} finally {
				Thread.CurrentThread.CurrentCulture = originalCulture;
			}
		}
Пример #17
0
		public void TestReadOnly_TableStyle ()
		{
			MakeTable (false);

			BindingContext bc = new BindingContext ();
			DataGrid dg = new DataGrid ();
			dg.BindingContext = bc;
			dg.TableStyles.Add (tableStyle);
			dg.DataSource = table;

			tableStyle.ReadOnly = true;

			CurrencyManager cm = (CurrencyManager)bc[view];
			ColumnPoker column = nameColumnStyle;
			TextBox tb = nameColumnStyle.TextBox;

			Assert.IsNotNull (tb, "1");
			Assert.AreEqual (typeof (DataGridTextBox), tb.GetType(), "2");
			Assert.IsTrue (tb.Enabled, "3");
			Assert.IsFalse (tb.Visible, "4");
			Assert.AreEqual ("", tb.Text, "5");
			Assert.IsFalse (tb.ReadOnly, "6");

			column.DoEdit (cm, 0, new Rectangle (new Point (0,0), new Size (100, 100)), false, "hi there", true);

			Assert.IsTrue (tb.ReadOnly, "7");

			Assert.AreEqual ("Miguel", tb.Text, "8");
		}
Пример #18
0
		public void IFormattable ()
		{
			CultureInfo originalCulture = CultureInfo.CurrentCulture;

			try {
				Thread.CurrentThread.CurrentCulture = new CultureInfo ("en-GB");

				table = new DataTable ();
				view = table.DefaultView;
				table.Columns.Add (new DataColumn ("Amount", typeof (MockNumeric)));

				DataRow row = table.NewRow ();
				row ["Amount"] = new MockNumericFormattable (1);
				table.Rows.Add (row);

				row = table.NewRow ();
				row ["Amount"] = new MockNumericFormattable (2);
				table.Rows.Add (row);

				row = table.NewRow ();
				row ["Amount"] = new MockNumeric (3);
				table.Rows.Add (row);

				tableStyle = new DataGridTableStyle ();
				ColumnPoker amountColumnStyle = new ColumnPoker ();
				amountColumnStyle.MappingName = "Amount";
				tableStyle.GridColumnStyles.Add (amountColumnStyle);

				BindingContext bc = new BindingContext ();
				DataGrid dg = new DataGrid ();
				dg.BindingContext = bc;
				dg.TableStyles.Add (tableStyle);
				dg.DataSource = table;

				CurrencyManager cm = (CurrencyManager) bc [view];
				TextBox tb = amountColumnStyle.TextBox;

				Assert.IsNotNull (tb, "#A1");
				Assert.AreEqual (string.Empty, tb.Text, "#A2");

				amountColumnStyle.DoEdit (cm, 0, new Rectangle (new Point (0,0), new Size (100, 100)), false, null, true);
				Assert.AreEqual ("uno", tb.Text, "#B1");
				Assert.AreEqual (new MockNumericFormattable (1), table.Rows [0] ["Amount"], "#B2");

				amountColumnStyle.DoEdit (cm, 1, new Rectangle (new Point (0,0), new Size (100, 100)), false, null, true);
				Assert.AreEqual ("dos", tb.Text, "#C1");
				Assert.AreEqual (new MockNumericFormattable (2), table.Rows [1] ["Amount"], "#C2");

				amountColumnStyle.DoEdit (cm, 2, new Rectangle (new Point (0,0), new Size (100, 100)), false, null, true);
				Assert.AreEqual ("tres", tb.Text, "#D1");
				Assert.AreEqual (new MockNumeric (3), table.Rows [2] ["Amount"], "#D2");

				amountColumnStyle.Format = string.Empty;

				amountColumnStyle.DoEdit (cm, 0, new Rectangle (new Point (0,0), new Size (100, 100)), false, null, true);
				Assert.AreEqual ("uno", tb.Text, "#E1");
				Assert.AreEqual (new MockNumericFormattable (1), table.Rows [0] ["Amount"], "#E2");

				amountColumnStyle.Format = "currency";

				amountColumnStyle.DoEdit (cm, 0, new Rectangle (new Point (0,0), new Size (100, 100)), false, null, true);
				Assert.AreEqual ("#£1.00", tb.Text, "#F1");
				Assert.AreEqual (new MockNumericFormattable (1), table.Rows [0] ["Amount"], "#F2");

				amountColumnStyle.DoEdit (cm, 2, new Rectangle (new Point (0,0), new Size (100, 100)), false, null, true);
				Assert.AreEqual ("tres", tb.Text, "#G1");
				Assert.AreEqual (new MockNumeric (3), table.Rows [2] ["Amount"], "#G2");

				amountColumnStyle.DoEdit (cm, 0, new Rectangle (new Point (0,0), new Size (100, 100)), false, "#£5.00", true);
				Assert.AreEqual ("#£5.00", tb.Text, "#H1");
				Assert.AreEqual (new MockNumericFormattable (1), table.Rows [0] ["Amount"], "#H2");

				amountColumnStyle.DoEdit (cm, 0, new Rectangle (new Point (0,0), new Size (100, 100)), false, "INVALID", true);
				Assert.IsFalse (amountColumnStyle.DoCommit (cm, 0), "#I1");
				Assert.AreEqual ("INVALID", tb.Text, "#I2");
				//Assert.AreEqual ("INVALID", table.Rows [0] ["Amount"], "#I3");

				amountColumnStyle.FormatInfo = new CultureInfo ("en-US");

				amountColumnStyle.DoEdit (cm, 1, new Rectangle (new Point (0,0), new Size (100, 100)), false, null, true);
				Assert.AreEqual ("#$2.00", tb.Text, "#J1");
				Assert.AreEqual (new MockNumericFormattable (2), table.Rows [1] ["Amount"], "#J2");
			} finally {
				Thread.CurrentThread.CurrentCulture = originalCulture;
			}
		}
        ///<summary>
        /// GridComboBoxExEditControl
        ///</summary>
        public GridComboBoxExEditControl()
        {
            DrawMode = DrawMode.OwnerDrawFixed;

            BindingContext = new BindingContext();
        }
Пример #20
0
		public void StringConverterTest ()
		{
			CultureInfo originalCulture = CultureInfo.CurrentCulture;

			try {
				Thread.CurrentThread.CurrentCulture = new CultureInfo ("en-GB");

				table = new DataTable ();
				view = table.DefaultView;
				table.Columns.Add (new DataColumn ("Amount", typeof (MockNumericStringConvertable)));

				DataRow row = table.NewRow ();
				row ["Amount"] = new MockNumericStringConvertable (1);
				table.Rows.Add (row);

				row = table.NewRow ();
				row ["Amount"] = new MockNumericStringConvertable (2);
				table.Rows.Add (row);

				tableStyle = new DataGridTableStyle ();
				ColumnPoker amountColumnStyle = new ColumnPoker ();
				amountColumnStyle.MappingName = "Amount";
				tableStyle.GridColumnStyles.Add (amountColumnStyle);

				BindingContext bc = new BindingContext ();
				DataGrid dg = new DataGrid ();
				dg.BindingContext = bc;
				dg.TableStyles.Add (tableStyle);
				dg.DataSource = table;

				CurrencyManager cm = (CurrencyManager) bc [view];
				DataGridTextBox tb = (DataGridTextBox) amountColumnStyle.TextBox;

				Assert.IsNotNull (tb, "#A1");
				Assert.AreEqual (string.Empty, tb.Text, "#A2");
				Assert.IsTrue (tb.IsInEditOrNavigateMode, "#A3");

				amountColumnStyle.DoEdit (cm, 0, new Rectangle (new Point (0,0), new Size (100, 100)), false, null, true);
				Assert.AreEqual ("£1.00", tb.Text, "#B1");
				Assert.AreEqual (new MockNumericStringConvertable (1), table.Rows [0] ["Amount"], "#B2");
				Assert.IsTrue (tb.IsInEditOrNavigateMode, "#B3");

				amountColumnStyle.DoEdit (cm, 1, new Rectangle (new Point (0,0), new Size (100, 100)), false, null, true);
				Assert.AreEqual ("£2.00", tb.Text, "#C1");
				Assert.AreEqual (new MockNumericStringConvertable (2), table.Rows [1] ["Amount"], "#C2");
				Assert.IsTrue (tb.IsInEditOrNavigateMode, "#C3");

				amountColumnStyle.DoEdit (cm, 0, new Rectangle (new Point (0,0), new Size (100, 100)), false, "£3.00", true);
				Assert.AreEqual ("£3.00", tb.Text, "#D1");
				Assert.AreEqual (new MockNumericStringConvertable (1), table.Rows [0] ["Amount"], "#D2");
				Assert.IsFalse (tb.IsInEditOrNavigateMode, "#D3");

				Assert.IsTrue (amountColumnStyle.DoCommit (cm, cm.Position), "#E1");
				Assert.AreEqual ("£3.00", tb.Text, "#E2");
				Assert.AreEqual (new MockNumericStringConvertable (3), table.Rows [0] ["Amount"], "#E3");
				Assert.IsTrue (tb.IsInEditOrNavigateMode, "#E4");

				amountColumnStyle.DoEdit (cm, 0, new Rectangle (new Point (0,0), new Size (100, 100)), false, "INVALID", true);
				Assert.IsFalse (amountColumnStyle.DoCommit (cm, cm.Position), "#F1");
				Assert.AreEqual ("INVALID", tb.Text, "#F2");
				Assert.AreEqual (new MockNumericStringConvertable (3), table.Rows [0] ["Amount"], "#F3");
				Assert.IsFalse (tb.IsInEditOrNavigateMode, "#F4");

				amountColumnStyle.Format = "whatever";
				amountColumnStyle.FormatInfo = new CultureInfo ("en-US");

				amountColumnStyle.DoEdit (cm, 0, new Rectangle (new Point (0,0), new Size (100, 100)), false, null, true);
				Assert.AreEqual ("£3.00", tb.Text, "#G1");
				Assert.AreEqual (new MockNumericStringConvertable (3), table.Rows [0] ["Amount"], "#G2");
				Assert.IsFalse (tb.IsInEditOrNavigateMode, "#G3");

				tb.Text = "5";
				Assert.IsTrue (amountColumnStyle.DoCommit (cm, cm.Position), "#H1");
				Assert.AreEqual ("£5.00", tb.Text, "#H2");
				Assert.AreEqual (new MockNumericStringConvertable (5), table.Rows [0] ["Amount"], "#H3");
			} finally {
				Thread.CurrentThread.CurrentCulture = originalCulture;
			}
		}
        ///<summary>
        /// GridComboTreeEditControl
        ///</summary>
        public GridComboTreeEditControl()
        {
            BindingContext = new BindingContext();

            ButtonDropDown.Visible = true;
        }
Пример #22
0
		protected virtual void OnParentBindingContextChanged(EventArgs e) {
			if (binding_context==null && Parent != null) {
				binding_context=Parent.binding_context;
				OnBindingContextChanged(e);
			}
		}
Пример #23
0
		/* create control and set binding context */
		public void BindingContextChangedTest ()
		{
			Control c = new Control ();
			// Test BindingContextChanged Event
			c.BindingContextChanged += new EventHandler (Event_Handler1);
			BindingContext bcG1 = new BindingContext ();
			eventcount = 0;
			c.BindingContext = bcG1;
			Assert.AreEqual (1, eventcount, "A1");
		}
		public static DataGridTableStyle[] CreateGridTables (DataGridTableStyle gridTable, object dataSource, string dataMember, BindingContext bindingManager)
		{
			throw new NotImplementedException ();
		}
Пример #25
0
		public void TestEndEdit ()
		{
			MakeTable (false);

			BindingContext bc = new BindingContext ();
			DataGrid dg = new DataGrid ();
			dg.BindingContext = bc;
			dg.TableStyles.Add (tableStyle);
			dg.DataSource = table;

			CurrencyManager cm = (CurrencyManager)bc[view];
			ColumnPoker column = nameColumnStyle;
			TextBox tb = column.TextBox;

			Assert.AreEqual ("", tb.Text, "1");
			column.DoEdit (cm, 0, new Rectangle (new Point (0,0), new Size (100, 100)), false, "hi there", true);
			Assert.AreEqual ("hi there", tb.Text, "2");

			tb.Text = "yo";

			column.DoEndEdit ();

			DataRowView v = (DataRowView)cm.Current;

			Assert.AreEqual ("Miguel", v[0], "3");
		}
Пример #26
0
		public void PropertyBindingContext ()
		{
			ToolStrip ts = new ToolStrip ();
			EventWatcher ew = new EventWatcher (ts);

			BindingContext b = new BindingContext ();
			ts.BindingContext = b;
			Assert.AreSame (b, ts.BindingContext, "B1");
			Assert.AreEqual (string.Empty, ew.ToString (), "B2");
		}
Пример #27
0
		public void TestCommit2 ()
		{
			MakeTable (false);

			BindingContext bc = new BindingContext ();
			DataGrid dg = new DataGrid ();
			dg.BindingContext = bc;
			dg.TableStyles.Add (tableStyle);
			dg.DataSource = table;

			CurrencyManager cm = (CurrencyManager)bc[view];
			ColumnPoker column = nameColumnStyle;
			DataGridTextBox tb = (DataGridTextBox)column.TextBox;

			Assert.AreEqual ("", tb.Text, "1");
			Assert.IsTrue (tb.IsInEditOrNavigateMode, "1.5");
			column.DoEdit (cm, 0, new Rectangle (new Point (0,0), new Size (100, 100)), false, "hi there", true);
			Assert.AreEqual ("hi there", tb.Text, "2");
			Assert.AreEqual (new Rectangle (new Point (2,2), new Size (97,97)), tb.Bounds, "3");
			Assert.IsFalse (tb.ReadOnly, "4");
			Assert.IsFalse (tb.IsInEditOrNavigateMode, "5");

			tb.Text = "yo";

			column.DoEndEdit ();

			Assert.IsTrue (tb.IsInEditOrNavigateMode, "5.5");

			bool rv = column.DoCommit (cm, cm.Position);
			Assert.IsTrue (rv, "6");
			DataRowView v = (DataRowView)cm.Current;
			Assert.AreEqual ("Miguel", v[0], "7");

			/* try it again with the DoCommit before the DoEndEdit */
			cm.Position = 0;
			column.DoEdit (cm, 0, new Rectangle (new Point (0,0), new Size (100,100)), false, "hi there", true);
			Assert.AreEqual ("hi there", tb.Text, "8");
			Assert.AreEqual (new Rectangle (new Point (2,2), new Size (97,97)), tb.Bounds, "9");
			Assert.IsFalse (tb.ReadOnly, "10");
			Assert.IsFalse (tb.IsInEditOrNavigateMode, "11");
			tb.Text = "yo";

			rv = column.DoCommit (cm, cm.Position);
			column.DoEndEdit ();
			Assert.IsTrue (rv, "12");
			v = (DataRowView)cm.Current;
			Assert.AreEqual ("yo", v[0], "13");
		}
Пример #28
0
		public void TestDeleteInEdit ()
		{
			Control c = new Control ();
			c.CreateControl ();
			Binding binding;
			BindingContext bc = new BindingContext ();
			CurrencyManager cm;

			DataSet dataSet1 = new DataSet();
			dataSet1.Tables.Add();
			dataSet1.Tables[0].Columns.Add();

			DataRow newrow = dataSet1.Tables[0].NewRow ();
			dataSet1.Tables[0].Rows.Add(newrow);

			cm = (CurrencyManager) bc[dataSet1, dataSet1.Tables[0].TableName];
			binding = c.DataBindings.Add ("Text", dataSet1.Tables[0], dataSet1.Tables[0].Columns[0].ColumnName);

			Assert.AreEqual (1, cm.Count, "1");

			HookupCurrencyManager (cm);
#if WITH_BINDINGS
			HookupBinding (binding);
#endif

			cm.Position = 0;

			event_log = "";
			event_num = 0;

			DataRowView row = (DataRowView)cm.Current;
			row.Delete ();

			Console.WriteLine (event_log);

			Assert.AreEqual (
#if NET_2_0
				 "0: PositionChanged (to -1)\n1: ItemChanged (index = -1)\n2: PositionChanged (to -1)\n3: CurrentChanged\n4: CurrentItemChanged\n5: ItemChanged (index = -1)\n"
#else
				 "0: PositionChanged (to -1)\n1: ItemChanged (index = -1)\n2: ItemChanged (index = -1)\n"
#endif
				 , event_log, "1");

			Assert.AreEqual (0, cm.Count, "2");
		}
Пример #29
0
		public void TestAbort_DifferentRow ()
		{
			MakeTable (false);

			BindingContext bc = new BindingContext ();
			DataGrid dg = new DataGrid ();
			dg.BindingContext = bc;
			dg.TableStyles.Add (tableStyle);
			dg.DataSource = table;

			CurrencyManager cm = (CurrencyManager)bc[view];
			ColumnPoker column = nameColumnStyle;
			DataGridTextBox tb = (DataGridTextBox)column.TextBox;

			Assert.AreEqual ("", tb.Text, "1");
			Assert.IsTrue (tb.IsInEditOrNavigateMode, "1.5");
			column.DoEdit (cm, 0, new Rectangle (new Point (0,0), new Size (100, 100)), false, "hi there", true);
			Assert.AreEqual ("hi there", tb.Text, "2");
			Assert.AreEqual (new Rectangle (new Point (2,2), new Size (97,97)), tb.Bounds, "3");
			Assert.IsFalse (tb.ReadOnly, "4");
			Assert.IsFalse (tb.IsInEditOrNavigateMode, "5");

			tb.Text = "yo";

			column.DoAbort (1);

			Assert.IsTrue (tb.IsInEditOrNavigateMode, "6");
			DataRowView v = (DataRowView)cm.Current;
			Assert.AreEqual ("Miguel", v[0], "7");
		}
Пример #30
0
		// Since this event is fired twice for the same binding context instance
		// (when the control is added to the form and when the form is shown), 
		// we only take into account the first time it happens
		protected override void OnBindingContextChanged (EventArgs e)
		{
			base.OnBindingContextChanged (e);
			if (last_binding_context == BindingContext)
				return;

			last_binding_context = BindingContext;
			ConnectToDataSource ();

			if (DataManager != null) {
				SetItemsCore (DataManager.List);
				if (AllowSelection)
					SelectedIndex = DataManager.Position;
			}
		}
Пример #31
0
		public void TestUpdateUI ()
		{
			MakeTable (false);

			BindingContext bc = new BindingContext ();
			DataGrid dg = new DataGrid ();
			dg.BindingContext = bc;
			dg.TableStyles.Add (tableStyle);
			dg.DataSource = table;

			CurrencyManager cm = (CurrencyManager)bc[view];
			ColumnPoker column = nameColumnStyle;
			DataGridTextBox tb = (DataGridTextBox)column.TextBox;

			Assert.AreEqual ("", tb.Text, "1");
			Assert.IsTrue (tb.IsInEditOrNavigateMode, "2");

			Assert.AreEqual (Point.Empty, tb.Location, "3");

			column.DoUpdateUI (cm, 0, "hi there");

			Assert.AreEqual (Point.Empty, tb.Location, "4");

			Assert.AreEqual ("hi there", tb.Text, "5");
			Assert.IsFalse (tb.ReadOnly, "6");
			Assert.IsTrue (tb.IsInEditOrNavigateMode, "7");

			DataRowView v = (DataRowView)cm.Current;
			Assert.AreEqual ("Miguel", v[0], "8");
		}
        /// <summary>
        /// Releases the unmanaged resources used by the 
        /// <see cref="T:System.Windows.Forms.ToolStripControlHost"/> and 
        /// optionally releases the managed resources.
        /// </summary>
        /// <param name="disposing">
        /// true to release both managed and unmanaged 
        /// resources; false to release only unmanaged resources.
        /// </param>
        protected override void Dispose(bool disposing)
        {
            base.Dispose(disposing);

            if (disposing)
            {
                this.Events.Dispose();

                if (this.dataBindings != null)
                {
                    this.dataBindings.Clear();
                    this.dataBindings = null;
                }

                this.bindingContext = null;
            }
        }
Пример #33
0
		public void TestReadOnly_AfterEditCall ()
		{
			MakeTable (false);

			BindingContext bc = new BindingContext ();
			DataGrid dg = new DataGrid ();
			dg.BindingContext = bc;
			dg.TableStyles.Add (tableStyle);
			dg.DataSource = table;

			CurrencyManager cm = (CurrencyManager)bc[view];
			ColumnPoker column = nameColumnStyle;
			TextBox tb = nameColumnStyle.TextBox;

			Assert.IsNotNull (tb, "1");
			Assert.AreEqual (typeof (DataGridTextBox), tb.GetType(), "2");
			Assert.IsTrue (tb.Enabled, "3");
			Assert.IsFalse (tb.Visible, "4");
			Assert.AreEqual ("", tb.Text, "5");
			Assert.IsFalse (tb.ReadOnly, "6");

			column.DoEdit (cm, 0, new Rectangle (new Point (0,0), new Size (100, 100)), false, "hi there", true);
			column.ReadOnly = true;

			Assert.IsFalse (tb.ReadOnly, "7");

			Assert.AreEqual ("hi there", tb.Text, "8");

			bool rv;

			rv = column.DoCommit (cm, cm.Position);
			column.DoEndEdit ();
			Assert.IsTrue (rv, "9");
			DataRowView v = (DataRowView)cm.Current;
			Assert.AreEqual ("hi there", v[0], "10");
		}