CreateControl() public method

public CreateControl ( ) : void
return void
		static WindowsFormsSynchronizationContext ()
		{
			invoke_control = new Control ();
			invoke_control.CreateControl ();
			auto_installed = true;
			previous_context = SynchronizationContext.Current;
		}
Exemplo n.º 2
0
        public Session(Alphora.Dataphor.DAE.Client.DataSession dataSession, bool ownsDataSession) : base(dataSession, ownsDataSession)
        {
            _toolTip = new WinForms.ToolTip();
            try
            {
                _toolTip.Active = true;
            }
            catch
            {
                _toolTip.Dispose();
                _toolTip = null;
                throw;
            }

            // Ensure we are setup for SafelyInvoke.  This must happen on the main windows thread and thus is not in a static constructor.
            lock (_invokeControlLock)
            {
                if (_invokeControl == null)
                {
                    _invokeControl = new WinForms.Control();
                    _invokeControl.CreateControl();
                }
            }

            // Ensure the assembly resolver is loaded
            Alphora.Dataphor.Windows.AssemblyUtility.Initialize();
        }
Exemplo n.º 3
0
		public void BindingsTest ()
		{
			Control c1 = new Control ();
			Control c2 = new Control ();

			c1.CreateControl ();
			c2.CreateControl ();

			Binding binding;
			BindingManagerBase bm, bm2;

			c1.BindingContext = new BindingContext ();
			c2.BindingContext = c1.BindingContext;

			bm = c2.BindingContext[c1, "Text"];
			bm2 = c2.BindingContext[c1];

#if NET_2_0
			bm.BindingComplete += delegate (object sender, BindingCompleteEventArgs e) { Console.WriteLine (Environment.StackTrace); };
			bm2.BindingComplete += delegate (object sender, BindingCompleteEventArgs e) { Console.WriteLine (Environment.StackTrace); };
#endif

			binding = c2.DataBindings.Add ("Text", c1, "Text");

			Assert.AreEqual (0, bm.Bindings.Count, "1");
			Assert.AreEqual (1, bm2.Bindings.Count, "2");

			Assert.AreEqual (bm2.Bindings[0], binding, "3");
		}
Exemplo n.º 4
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Initializes a new instance of the <see cref="T:TeImportUi"/> class.
		/// </summary>
		/// <param name="progressDialog">The progress dialog.</param>
		/// ------------------------------------------------------------------------------------
		public TeImportUi(ProgressDialogWithTask progressDialog)
		{
			m_progressDialog = progressDialog;
			if (m_progressDialog != null)	// might be null for tests
				m_progressDialog.Cancel += new CancelHandler(OnCancelPressed);
			m_ctrl = new Control();
			m_ctrl.CreateControl();
		}
        public AdnFileDownloader(Uri url, string location)
        {
            _sw = new Stopwatch();
            _url = url;
            _location = location;

            _syncCtrl = new Control();
            _syncCtrl.CreateControl();
        }
Exemplo n.º 6
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Initializes a new instance of the <see cref="TeImportUi"/> class.
		/// </summary>
		/// <param name="progressDialog">The progress dialog.</param>
		/// <param name="helpTopicProvider">The help topic provider.</param>
		/// ------------------------------------------------------------------------------------
		public TeImportUi(ProgressDialogWithTask progressDialog, IHelpTopicProvider helpTopicProvider)
		{
			m_progressDialog = progressDialog;
			if (m_progressDialog != null)
				m_progressDialog.Canceling += OnCancelPressed;
			m_helpTopicProvider = helpTopicProvider;
			m_ctrl = new Control();
			m_ctrl.CreateControl();
		}
Exemplo n.º 7
0
 public static void SpawnUIUpdateThread()
 {
     mainThread = Thread.CurrentThread;
     mainThreadCtrl = new Panel();
     mainThreadCtrl.CreateControl();
     uiUpdateThread = new Thread(UIUpdateThread);
     uiUpdateThread.IsBackground = true;
     uiUpdateThread.Start();
 }
Exemplo n.º 8
0
		public void CtorEmptyProperty ()
		{
			Binding b = new Binding ("Text", 6, String.Empty);
			Control c = new Control ();
			c.BindingContext = new BindingContext ();
			c.CreateControl ();

			c.DataBindings.Add (b);
			Assert.AreEqual ("6", c.Text, "A1");
		}
Exemplo n.º 9
0
        /// <summary>
        /// WPFを使うための初期化処理を行います。
        /// </summary>
        public static void Initialize()
        {
            Initializer.Initialize();

            Synchronizer = new Control();
            Synchronizer.CreateControl();

            Util.SetPropertyChangedCaller(CallPropertyChanged);
            Util.SetColletionChangedCaller(CallCollectionChanged);
            Util.SetEventCaller(UIProcess);
        }
 public TreeListViewItemEditControlHandle(TreeListView treelistview, Control control, CustomEdit customedit)
 {
     _control      = control;
     _treelistview = treelistview;
     _customedit   = customedit;
     if (!control.Created)
     {
         control.CreateControl();
     }
     AssignHandle(control.Handle);
 }
        // This method handles the "Launch Color Builder UI" menu command.
        // Invokes the BuildColor method of the System.Web.UI.Design.ColorBuilder.
        private void launchColorBuilder(object sender, EventArgs e)
        {
            //<Snippet1>
            // Create a parent control.
            System.Windows.Forms.Control c = new System.Windows.Forms.Control();
            c.CreateControl();

            // Launch the Color Builder using the specified control
            // parent and an initial HTML format ("RRGGBB") color string.
            System.Web.UI.Design.ColorBuilder.BuildColor(this.Component, c, "405599");
            //</Snippet1>
        }
Exemplo n.º 12
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Initializes a new instance of the <see cref="T:StatusBarProgressHandler"/> class.
		/// </summary>
		/// <param name="label">The label that will display the message.</param>
		/// <param name="progressBar">The progress bar.</param>
		/// ------------------------------------------------------------------------------------
		public StatusBarProgressHandler(ToolStripStatusLabel label,
			ToolStripProgressBar progressBar)
		{
			m_label = label;
			m_progressBar = progressBar;

			// Create a (invisible) control for multithreading purposes. We have to do this
			// because ToolStripStatusLabel and ToolStripProgressBar don't derive from Control
			// and so don't provide an implementation of Invoke.
			m_control = new Control();
			m_control.CreateControl();
		}
        public TranslationNotifier(
            AdnViewDataClient client,
            string fileId,
            int pollingPeriod = 1000)
        {
            _worker = null;
            _client = client;
            _fileId = fileId;
            _pollingPeriod = pollingPeriod;

            _syncCtrl = new Control();
            _syncCtrl.CreateControl();
        }
        /// <summary>
        /// 将控件尺寸设置为期望的尺寸
        /// </summary>
        /// <param name="control"></param>
        /// <returns></returns>
        public static Size SetToPreferredSize(this Control control)
        {
            var size = control.PreferredSize;

            if (size.IsEmpty)
            {
                control.CreateControl();
                size = control.PreferredSize;
            }

            control.Size = size;

            return(size);
        }
Exemplo n.º 15
0
        public ConfigurationForm()
        {
            m_localControlForInvoke = new Control();
            m_localControlForInvoke.CreateControl();
#if DEBUG
            //    Debugger.Launch();
#endif
            InitializeComponent();
            MPTVSeriesLog.AddNotifier(ref listBox_Log);

            MPTVSeriesLog.Write("**** Plugin started in configuration mode ***");

            Translation.Init();

            // set height/width
            int height = DBOption.GetOptions(DBOption.cConfigSizeHeight);
            int width = DBOption.GetOptions(DBOption.cConfigSizeWidth);
            if (height > this.MinimumSize.Height && width > this.MinimumSize.Width)
            {
                System.Drawing.Size s = new Size(width, height);
                this.Size = s;
            }
            this.Resize += new EventHandler(ConfigurationForm_Resize);            

            load = new loadingDisplay();

            OnlineParsing.OnlineParsingCompleted += new OnlineParsing.OnlineParsingCompletedHandler(OnlineParsing_OnCompleted);
            
            InitSettingsTreeAndPanes();
            InitExtraTreeAndPanes();
            
            LoadImportPathes();
            LoadExpressions();
            LoadReplacements();
            
            initLoading = false;
            LoadTree();

            // Only Advanced Users / Skin Designers need to see these.
            // Tabs are visible if import="false" TVSeries.SkinSettings.xml
            if (SkinSettings.ImportFormatting) tabControl_Details.TabPages.Remove(tabFormattingRules);
            if (SkinSettings.ImportLogos) tabControl_Details.TabPages.Remove(tabLogoRules);
            
            if (load != null) load.Close();
            instance = this;

            this.aboutScreen.setUpMPInfo(Settings.Version.ToString(), Settings.BuildDate);
            this.aboutScreen.setUpPaths();
        }
Exemplo n.º 16
0
        public HtmlThumbNailer(NavigationIsolator isolator)
        {
            if (_theOnlyOneAllowed != null)
            {
                Debug.Fail("Something tried to make a second HtmlThumbnailer; there should only be one.");
                throw new ApplicationException("Something tried to make a second HtmlThumbnailer; there should only be one.");
            }

            _theOnlyOneAllowed = this;

            _isolator = isolator;

            _syncControl = new Control();
            _syncControl.CreateControl();
        }
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Set exception handler. Needs to be done before we create splash screen (don't
		/// understand why, but otherwise some exceptions don't get caught).
		/// </summary>
		/// ------------------------------------------------------------------------------------
		public WinFormsExceptionHandler()
		{
			// We need to create a control on the UI thread so that we have a control that we
			// can use to invoke the error reporting dialog on the correct thread.
			ControlOnUIThread = new Control();
			ControlOnUIThread.CreateControl();

			// Using Application.ThreadException rather than
			// AppDomain.CurrentDomain.UnhandledException has the advantage that the
			// program doesn't necessarily ends - we can ignore the exception and continue.
			Application.ThreadException += HandleTopLevelError;

			// We also want to catch the UnhandledExceptions for all the cases that
			// ThreadException don't catch, e.g. in the startup.
			AppDomain.CurrentDomain.UnhandledException += HandleUnhandledException;
		}
Exemplo n.º 18
0
		public TreeViewX(IApp app) {
			App = app;

			HotTracking = true;
			HideSelection = false;
			ShowLines = false;
			BorderStyle = BorderStyle.FixedSingle;
			DrawMode = TreeViewDrawMode.OwnerDrawAll;
			ImageList = new ImageList();
			ImageList.Images.Add(new Bitmap(16, 16));

			scratch = new Control();
			scratch.CreateControl();

			Font = new Font("Segoe UI", 9);
			SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint, true);
		}
Exemplo n.º 19
0
        //<Snippet1>
        // This method handles the "Launch Url Builder UI" menu command.
        // Invokes the BuildUrl method of the System.Web.UI.Design.UrlBuilder.
        private void launchUrlBuilder(object sender, EventArgs e)
        {
            // Create a parent control.
            System.Windows.Forms.Control c = new System.Windows.Forms.Control();
            c.CreateControl();

            // Launch the Url Builder using the specified control
            // parent, initial URL, empty relative base URL path,
            // window caption, filter string and URLBuilderOptions value.
            UrlBuilder.BuildUrl(
                this.Component,
                c,
                "http://www.example.com",
                "Select a URL",
                "",
                UrlBuilderOptions.None);
        }
Exemplo n.º 20
0
        public static bool Create(Form mainApplicationForm)
        {
            if (windowHandleControl != null)
                Log.Fatal("WinFormsAppWorld: Create: WinformsAppWorld is already created.");
            if (!mainApplicationForm.IsHandleCreated)
                Log.Fatal("WinFormsAppWorld: Create: mainApplicationForm: Handle is not created.");

            windowHandleControl = new Control();
            windowHandleControl.Parent = mainApplicationForm;
            windowHandleControl.Location = new System.Drawing.Point(0, 0);
            windowHandleControl.Size = new System.Drawing.Size(10, 10);
            windowHandleControl.Visible = false;
            windowHandleControl.CreateControl();

            EngineApp.Instance.WindowHandle = mainApplicationForm.Handle;
            if (!EngineApp.Instance.Create())
                return false;

            return true;
        }
Exemplo n.º 21
0
        //
        public static bool Init( Form mainApplicationForm, string logFileName )
        {
            if( !mainApplicationForm.IsHandleCreated )
                Log.Fatal( "WindowsAppWorld: Init: mainApplicationForm: Handle is not created." );

            if( !VirtualFileSystem.Init( logFileName, true, null, null, null ) )
                return false;
            Log.DumpToFile( string.Format( "Windows Application (NeoAxis Engine {0})\r\n",
                EngineVersionInformation.Version ) );

            Log.Handlers.WarningHandler += delegate( string text, ref bool handled )
            {
                handled = true;
                duringWarningOrErrorMessageBox = true;
                MessageBox.Show( text, "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning );
                duringWarningOrErrorMessageBox = false;
            };

            Log.Handlers.ErrorHandler += delegate( string text, ref bool handled )
            {
                handled = true;
                duringWarningOrErrorMessageBox = true;
                MessageBox.Show( text, "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning );
                duringWarningOrErrorMessageBox = false;
            };

            EngineApp.Init( new WindowsAppEngineApp() );

            windowHandleControl = new Control();
            windowHandleControl.Parent = mainApplicationForm;
            windowHandleControl.Location = new System.Drawing.Point( 0, 0 );
            windowHandleControl.Size = new System.Drawing.Size( 10, 10 );
            windowHandleControl.Visible = false;
            windowHandleControl.CreateControl();

            EngineApp.Instance.WindowHandle = windowHandleControl.Handle;
            if( !EngineApp.Instance.Create() )
                return false;

            return true;
        }
Exemplo n.º 22
0
		public void CollectionChangingTest ()
		{
			Control c = new Control ();
			c.BindingContext = new BindingContext ();
			c.CreateControl ();

			ControlBindingsCollection binding_coll = c.DataBindings;

			Binding binding = new Binding ("Text", new MockItem ("A", 0), "Text");
			Binding binding2 = new Binding ("Name", new MockItem ("B", 0), "Text");
			binding_coll.Add (binding);

			binding_coll.CollectionChanging += CollectionChangingHandler;

			collection_expected_count = 1;
			collection_action_expected = CollectionChangeAction.Add;
			collection_element_expected = binding2;
			collection_expected_assert = "#A0";
			binding_coll.Add (binding2);
			Assert.IsTrue (collection_changing_called, "#A1");

			collection_changing_called = false;
			collection_expected_count = 2;
			collection_action_expected = CollectionChangeAction.Remove;
			collection_element_expected = binding;
			collection_expected_assert = "#B0";
			binding_coll.Remove (binding);
			Assert.IsTrue (collection_changing_called, "#B1");

			collection_changing_called = false;
			collection_expected_count = 1;
			collection_element_expected = null;
			collection_action_expected = CollectionChangeAction.Refresh;
			collection_expected_assert = "#C0";
			binding_coll.Clear ();
			Assert.IsTrue (collection_changing_called, "#C1");
		}
Exemplo n.º 23
0
            /// <summary>
            ///  Adds a child control to this control. The control becomes the last control in
            ///  the child control list. If the control is already a child of another control it
            ///  is first removed from that control.
            /// </summary>
            public virtual void Add(Control value)
            {
                if (value == null)
                {
                    return;
                }

                if (value.GetTopLevel())
                {
                    throw new ArgumentException(SR.TopLevelControlAdd);
                }

                // Verify that the control being added is on the same thread as
                // us...or our parent chain.
                if (Owner.CreateThreadId != value.CreateThreadId)
                {
                    throw new ArgumentException(SR.AddDifferentThreads);
                }

                CheckParentingCycle(Owner, value);

                if (value._parent == Owner)
                {
                    value.SendToBack();
                    return;
                }

                // Remove the new control from its old parent (if any)
                if (value._parent != null)
                {
                    value._parent.Controls.Remove(value);
                }

                // Add the control
                InnerList.Add(value);

                if (value._tabIndex == -1)
                {
                    // Find the next highest tab index
                    int nextTabIndex = 0;
                    for (int c = 0; c < (Count - 1); c++)
                    {
                        int t = this[c].TabIndex;
                        if (nextTabIndex <= t)
                        {
                            nextTabIndex = t + 1;
                        }
                    }
                    value._tabIndex = nextTabIndex;
                }

                // if we don't suspend layout, AssignParent will indirectly trigger a layout event
                // before we're ready (AssignParent will fire a PropertyChangedEvent("Visible"), which calls PerformLayout)
#if DEBUG
                int dbgLayoutCheck = Owner.LayoutSuspendCount;
#endif
                Owner.SuspendLayout();

                try
                {
                    Control oldParent = value._parent;
                    try
                    {
                        // AssignParent calls into user code - this could throw, which
                        // would make us short-circuit the rest of the reparenting logic.
                        // you could end up with a control half reparented.
                        value.AssignParent(Owner);
                    }
                    finally
                    {
                        if (oldParent != value._parent && (Owner._state & STATE_CREATED) != 0)
                        {
                            value.SetParentHandle(Owner.InternalHandle);
                            if (value.Visible)
                            {
                                value.CreateControl();
                            }
                        }
                    }

                    value.InitLayout();
                }
                finally
                {
                    Owner.ResumeLayout(false);
#if DEBUG
                    Owner.AssertLayoutSuspendCount(dbgLayoutCheck);
#endif
                }

                // Not putting in the finally block, as it would eat the original
                // exception thrown from AssignParent if the following throws an exception.
                LayoutTransaction.DoLayout(Owner, value, PropertyNames.Parent);
                Owner.OnControlAdded(new ControlEventArgs(value));
            }
Exemplo n.º 24
0
            private static void UIThread()
            {
                s_ui = new Control();
                s_ui.CreateControl();

                s_uiReady.Set();
                Application.Run();
            }
Exemplo n.º 25
0
        public KeyboardInput()
        {
            keyBoardDelegate = KeyboardHookDelegate;

            var semaphore = new Semaphore(0, 1);

            new Thread(() =>
            {
                messageLoopControl = new Control();
                messageLoopControl.CreateControl();

                Thread.CurrentThread.IsBackground = true;

                semaphore.Release();

                Application.Run();
            }) { Name = "Hotkey Message Loop" }.Start();

            semaphore.WaitOne();

            RegisterHook();
        }
Exemplo n.º 26
0
 public TreeListViewItemEditControlHandle(TreeListView treelistview, Control control, CustomEdit customedit)
 {
     _control = control;
     _treelistview = treelistview;
     _customedit = customedit;
     if(!control.Created) control.CreateControl();
     AssignHandle(control.Handle);
 }
Exemplo n.º 27
0
        void SessionThreadStart()
        {
            Monitor.Enter(sessionThread);
            {
                try
                {
                    sessionThreadControl = new Control();
                    sessionThreadControl.CreateControl();

                    session = TtlLiveSingleton.Get();

                    dataTimer = new Timer();
                    dataTimer.Interval = 100;
                    dataTimer.Tick += new EventHandler(dataTimer_Tick);

                    notificationTimer = new Timer();
                    notificationTimer.Interval = 100;
                    notificationTimer.Tick += new EventHandler(notificationTimer_Tick);
                    notificationTimer.Start();
                }
                catch (Exception ex)
                {
                    sessionThreadInitException = ex;
                    TtlLiveSingleton.Dispose();
                }
                Monitor.Pulse(sessionThread);
            }
            Monitor.Exit(sessionThread);

            //Create a message pump for this thread
            Application.Run(applicationContext);

            //Dispose of all stuff on this thread
            dataTimer.Stop();
            dataTimer.Dispose();

            notificationTimer.Stop();
            notificationTimer.Dispose();

            TtlLiveSingleton.Dispose();
            sessionThreadControl.Dispose();

            return;
        }
Exemplo n.º 28
0
		public void TestColumnRemoveBound ()
		{
			Control c = new Control ();
			c.CreateControl ();
			Binding binding;
			CurrencyManager cm;

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

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

			HookupCurrencyManager (cm);
			HookupBinding (binding);

			cm.Position = 0;

			Assert.IsFalse (binding.IsBinding, "1");
			Assert.AreEqual (0, cm.Count, "2");

			event_log = "";
			event_num = 0;

			dataSet1.Tables[0].Columns.Remove(dataSet1.Tables[0].Columns[0]);

			Console.WriteLine (event_log);
			
			Assert.AreEqual ("0: MetaDataChanged\n", event_log, "3");

			Assert.AreEqual (0, cm.Count, "4");

			Assert.IsFalse (binding.IsBinding, "5");
		}
Exemplo n.º 29
0
 private static void HookInkImpl(IInkHooks subject, Control control)
 {
     HookAdapter adapter = new HookAdapter(subject);
     control.CreateControl();
     StylusReader.HookStylus(adapter, control);
 }
Exemplo n.º 30
0
		public void TestPropertyChange ()
		{
			if (TestHelper.RunningOnUnix) {
				Assert.Ignore ("Fails at the moment");
			}

			Control c1 = new Control ();
			Control c2 = new Control ();

			c1.CreateControl ();
			c2.CreateControl ();

			Binding binding;
			PropertyManager pm;

			c1.BindingContext = new BindingContext ();
			c2.BindingContext = c1.BindingContext;

			pm = (PropertyManager) c2.BindingContext[c1, "Text"];

			binding = c2.DataBindings.Add ("Text", c1, "Text");

			Console.WriteLine (pm.GetType());
			Console.WriteLine (binding.BindingManagerBase.GetType());
			Assert.IsFalse (pm == binding.BindingManagerBase, "0");

			HookupPropertyManager (pm);
			HookupBinding (binding);

			event_log = "";
			event_num = 0;

			c1.Text = "hi";

			Console.WriteLine (event_log);

#if NET_2_0
			Assert.AreEqual ("0: CurrentChanged\n1: CurrentItemChanged\n2: Binding.Format\n3: CurrentChanged\n4: CurrentItemChanged\n", event_log, "1");
#else
			Assert.AreEqual ("0: CurrentChanged\n1: Binding.Format\n2: CurrentChanged\n", event_log, "1");
#endif
		}
Exemplo n.º 31
0
		public void CancelAddNew ()
		{
			if (TestHelper.RunningOnUnix) {
				Assert.Ignore ("Fails at the moment");
			}

			Control c = new Control ();
			c.CreateControl ();
			Binding binding;
			CurrencyManager cm;

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

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

			HookupCurrencyManager (cm);
#if WITH_BINDINGS
			HookupBinding (binding);
#endif
			event_log = "";
			event_num = 0;

			Console.WriteLine (">>>");
			cm.AddNew ();

			cm.CancelCurrentEdit ();
			Console.WriteLine ("<<<");

			Console.WriteLine (event_log);

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

		}
Exemplo n.º 32
0
		public void TestRowCancelModify ()
		{
			Control c = new Control ();
			c.CreateControl ();
			Binding binding;
			CurrencyManager cm;
			string column_name;

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

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

			column_name = dataSet1.Tables[0].Columns[0].ColumnName;

			c.BindingContext = new BindingContext ();
			cm = (CurrencyManager) c.BindingContext[dataSet1, dataSet1.Tables[0].TableName];

			binding = c.DataBindings.Add ("Text", dataSet1.Tables[0], column_name);

			HookupCurrencyManager (cm);
			HookupBinding (binding);

			cm.Position = 0;

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

			event_log = "";
			event_num = 0;

			DataRowView row = (DataRowView)cm.Current;
			row.BeginEdit ();
			row[column_name] = "hi";
			cm.CancelCurrentEdit ();

			Console.WriteLine (event_log);
			Assert.AreEqual ("0: ItemChanged (index = 0)\n", event_log, "2");

			Assert.AreEqual (1, cm.Count, "3");
		}
Exemplo n.º 33
0
		public void TestColumnChangeName ()
		{
			Control c = new Control ();
			c.CreateControl ();
			Binding binding;
			CurrencyManager cm;

			DataSet dataSet1 = new DataSet();
			dataSet1.Tables.Add();

			dataSet1.Tables [0].Columns.CollectionChanged += new CollectionChangeEventHandler (
				DataColumnCollection_CollectionChanged);

			dataSet1.Tables[0].Columns.Add();

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

			HookupCurrencyManager (cm);
			HookupBinding (binding);

			cm.Position = 0;

			Assert.IsFalse (binding.IsBinding, "1");
			Assert.AreEqual (0, cm.Count, "2");

			event_log = "";
			event_num = 0;

			dataSet1.Tables [0].DefaultView.ListChanged += new ListChangedEventHandler (
				DataView_ListChanged);

			dataSet1.Tables[0].Columns[0].ColumnName = "new name";

			Console.WriteLine (event_log);
			
			Assert.AreEqual ("0: MetaDataChanged\n", event_log, "3");

			Assert.AreEqual (0, cm.Count, "4");

			Assert.IsFalse (binding.IsBinding, "5");
		}
Exemplo n.º 34
0
            /// <summary>
            /// Implements remote server.
            /// </summary>
            private static void RunServer(string serverPort, string semaphoreName, int clientProcessId)
            {
                if (!AttachToClientProcess(clientProcessId))
                {
                    return;
                }

                // Disables Windows Error Reporting for the process, so that the process fails fast.
                // Unfortunately, this doesn't work on Windows Server 2008 (OS v6.0), Vista (OS v6.0) and XP (OS v5.1)
                // Note that GetErrorMode is not available on XP at all.
                if (Environment.OSVersion.Version >= new Version(6, 1, 0, 0))
                {
                    SetErrorMode(GetErrorMode() | ErrorMode.SEM_FAILCRITICALERRORS | ErrorMode.SEM_NOOPENFILEERRORBOX | ErrorMode.SEM_NOGPFAULTERRORBOX);
                }

                IpcServerChannel serverChannel = null;
                IpcClientChannel clientChannel = null;
                try
                {
                    using (var semaphore = Semaphore.OpenExisting(semaphoreName))
                    {
                        // DEBUG: semaphore.WaitOne();

                        var serverProvider = new BinaryServerFormatterSinkProvider();
                        serverProvider.TypeFilterLevel = TypeFilterLevel.Full;

                        var clientProvider = new BinaryClientFormatterSinkProvider();

                        clientChannel = new IpcClientChannel(GenerateUniqueChannelLocalName(), clientProvider);
                        ChannelServices.RegisterChannel(clientChannel, ensureSecurity: false);

                        serverChannel = new IpcServerChannel(GenerateUniqueChannelLocalName(), serverPort, serverProvider);
                        ChannelServices.RegisterChannel(serverChannel, ensureSecurity: false);

                        RemotingConfiguration.RegisterWellKnownServiceType(
                            typeof(Service),
                            ServiceName,
                            WellKnownObjectMode.Singleton);

                        using (var resetEvent = new ManualResetEventSlim(false))
                        {
                            var uiThread = new Thread(() =>
                            {
                                s_control = new Control();
                                s_control.CreateControl();
                                resetEvent.Set();
                                Application.Run();
                            });
                            uiThread.SetApartmentState(ApartmentState.STA);
                            uiThread.IsBackground = true;
                            uiThread.Start();
                            resetEvent.Wait();
                        }

                        // the client can instantiate interactive host now:
                        semaphore.Release();
                    }

                    s_clientExited.Wait();
                }
                finally
                {
                    if (serverChannel != null)
                    {
                        ChannelServices.UnregisterChannel(serverChannel);
                    }

                    if (clientChannel != null)
                    {
                        ChannelServices.UnregisterChannel(clientChannel);
                    }
                }

                // force exit even if there are foreground threads running:
                Environment.Exit(0);
            }
Exemplo n.º 35
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");
		}
Exemplo n.º 36
0
 void timer_Tick(object sender, EventArgs e)
 {
     timer.Stop();
     //create invoker in main UI therad
     invokerControl = new Control();
     invokerControl.CreateControl();
     //
     Start();
 }