public void Construct()
		{
			using (HotSpotProvider hotSpotProvider = new HotSpotProvider())
			{
				Assert.IsNotNull(hotSpotProvider);
			}
		}
		public void CanExtend_CalledAfterDisposed_Throws()
		{
			HotSpotProvider hotSpotProvider = new HotSpotProvider();
			hotSpotProvider.Dispose();
			using (TextBox textBox = new TextBox())
			{
				Assert.Throws<ObjectDisposedException>(() =>
 hotSpotProvider.CanExtend(textBox));
			}
		}
Exemple #3
0
		static void Main()
		{
			// Is mercurial set up?
			var readinessMessage = HgRepository.GetEnvironmentReadinessMessage("en");
			if (!string.IsNullOrEmpty(readinessMessage))
			{
				MessageBox.Show(readinessMessage, CommonResources.kFLExBridge, MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
				return;
			}

			Application.EnableVisualStyles();
			Application.SetCompatibleTextRenderingDefault(false);

			using (var hotspot = new HotSpotProvider())
			{
				// This is a kludge to make sure we have a real reference to PalasoUIWindowsForms.
				// Without this call, although PalasoUIWindowsForms is listed in the References of this project,
				// since we don't actually use it directly, it does not show up when calling GetReferencedAssemblies on this assembly.
				// But we need it to show up in that list so that ExceptionHandler.Init can install the intended PalasoUIWindowsForms
				// exception handler.
			}

			if (Settings.Default.CallUpgrade)
			{
				Settings.Default.Upgrade();
				Settings.Default.CallUpgrade = false;
			}

			SetUpErrorHandling();

#if MONO
			// Set up Xpcom for geckofx (used by some Chorus dialogs that we may invoke).
			Xpcom.Initialize(XULRunnerLocator.GetXULRunnerLocation());
			GeckoPreferences.User["gfx.font_rendering.graphite.enabled"] = true;
			Application.ApplicationExit += (sender, e) => { Xpcom.Shutdown(); };
#endif

			// An aggregate catalog that combines multiple catalogs
			using (var catalog = new AggregateCatalog())
			{
				var thisAssembly = Assembly.GetExecutingAssembly();
				catalog.Catalogs.Add(new DirectoryCatalog(
					Path.GetDirectoryName(Utilities.StripFilePrefix(thisAssembly.CodeBase)),
					"*-ChorusPlugin.dll"));
				catalog.Catalogs.Add(new AssemblyCatalog(thisAssembly));

				// Create the CompositionContainer with the parts in the catalog
				using (var container = new CompositionContainer(catalog))
				{
					Application.Run(container.GetExportedValue<RepositoryUtilityForm>());
				}
			}
			Settings.Default.Save();
		}
            public HotSpotPainter(HotSpotProvider parent, TextBoxBase c)
            {
                if (c.IsHandleCreated)
                {
                    AssignHandle(c.Handle);
                }
                c.HandleCreated   += ControlHandleCreated;
                c.HandleDestroyed += ControlHandleDestroyed;

                c.TextChanged += OnTextChanged;
                c.MouseMove   += OnMouseMove;
                c.MouseDown   += OnMouseDown;
                c.MouseClick  += OnMouseClick;
                c.MouseUp     += OnMouseUp;
                c.MouseHover  += OnMouseHover;
                c.MouseLeave  += OnMouseLeave;

                _control         = c;
                HotSpots         = new List <HotSpotInternal>();
                _currentHotSpots = new List <HotSpotInternal>();
                _parent          = parent;
            }
		public void Setup()
		{
			_hotSpotProvider = new HotSpotProvider();
			_textBox = new ClickableTextBox();
			_textBox.Width = 350;
			_textBox.Text = "Now is the time for ...";
			_spot1 = new HotSpot(_textBox, 7, 3);
			_spot2 = new HotSpot(_textBox, 16, 3);

			_hotSpotProvider.SetEnableHotSpots(_textBox, true);
			_hotSpotProvider.RetrieveHotSpots +=
				delegate(object sender, RetrieveHotSpotsEventArgs e)
					{
						e.AddHotSpot(_spot1);
						e.AddHotSpot(_spot2);
						e.Color = Color.Yellow;
					};
			_originalCursorPosition = Cursor.Position;

			_form = new Form();
			_form.Controls.Add(_textBox);
			_form.Show();
		}
			public HotSpotPainter(HotSpotProvider parent, TextBoxBase c)
			{
				if (c.IsHandleCreated)
				{
					AssignHandle(c.Handle);
				}
				c.HandleCreated += ControlHandleCreated;
				c.HandleDestroyed += ControlHandleDestroyed;

				c.TextChanged += OnTextChanged;
				c.MouseMove += OnMouseMove;
				c.MouseDown += OnMouseDown;
				c.MouseClick += OnMouseClick;
				c.MouseUp += OnMouseUp;
				c.MouseHover += OnMouseHover;
				c.MouseLeave += OnMouseLeave;

				_control = c;
				HotSpots = new List<HotSpotInternal>();
				_currentHotSpots = new List<HotSpotInternal>();
				_parent = parent;
			}
		public void SetSite_CalledAfterDisposed_Throws()
		{
			HotSpotProvider hotSpotProvider = new HotSpotProvider();
			hotSpotProvider.Dispose();
			Assert.Throws<ObjectDisposedException>(() =>
			hotSpotProvider.Site = null);
		}
		public void GetSite_CalledAfterDisposed_Throws()
		{
			HotSpotProvider hotSpotProvider = new HotSpotProvider();
			hotSpotProvider.Dispose();
			ISite x;
			Assert.Throws<ObjectDisposedException>(() =>
				 x = hotSpotProvider.Site);
		}
		public void Dispose_CalledTwice_CallsHandlerOnce()
		{
			HotSpotProvider hotSpotProvider = new HotSpotProvider();
			int disposedCalledCount = 0;
			hotSpotProvider.Disposed += delegate { ++disposedCalledCount; };
			Assert.AreEqual(0, disposedCalledCount);
			hotSpotProvider.Dispose();
			Assert.AreEqual(1, disposedCalledCount);
			hotSpotProvider.Dispose();
			Assert.AreEqual(1, disposedCalledCount);
		}
		public void Dispose_HasDisposedEventHandler_CallsHandler()
		{
			HotSpotProvider hotSpotProvider = new HotSpotProvider();
			bool disposedCalled = false;
			hotSpotProvider.Disposed += delegate { disposedCalled = true; };
			Assert.IsFalse(disposedCalled);
			hotSpotProvider.Dispose();
			Assert.IsTrue(disposedCalled);
		}
		public void SetEnableHotSpots_CalledAfterDisposed_Throws()
		{
			HotSpotProvider hotSpotProvider = new HotSpotProvider();
			hotSpotProvider.Dispose();
			using (TextBox textBox = new TextBox())
			{
				Assert.Throws<ObjectDisposedException>(() =>
hotSpotProvider.SetEnableHotSpots(textBox, false));
			}
		}
		public void Setup()
		{
			_hotSpotProvider = new HotSpotProvider();
		}
Exemple #13
0
		static void Main(string[] args)
		{
			//MessageBox.Show(@"Get ready to debug FB exe.");
			Application.EnableVisualStyles();
			Application.SetCompatibleTextRenderingDefault(false);

			if(args.Length == 0)
			{
				MessageBox.Show(CommonResources.kNoCommandLineOptions, CommonResources.kFLExBridge, MessageBoxButtons.OK, MessageBoxIcon.Error);
				return;
			}

			using (var hotspot = new HotSpotProvider())
			{
				// This is a kludge to make sure we have a real reference to PalasoUIWindowsForms.
				// Without this call, although PalasoUIWindowsForms is listed in the References of this project,
				// since we don't actually use it directly, it does not show up when calling GetReferencedAssemblies on this assembly.
				// But we need it to show up in that list so that ExceptionHandler.Init can install the intended PalasoUIWindowsForms
				// exception handler.
			}

			if (Settings.Default.CallUpgrade)
			{
				Settings.Default.Upgrade();
				Settings.Default.CallUpgrade = false;
			}

			SetUpErrorHandling();

			var commandLineArgs = CommandLineProcessor.ParseCommandLineArgs(args);

#if MONO
			// Set up Xpcom for geckofx (used by some Chorus dialogs that we may invoke).
			Xpcom.Initialize(XULRunnerLocator.GetXULRunnerLocation());
			GeckoPreferences.User["gfx.font_rendering.graphite.enabled"] = true;
			Application.ApplicationExit += (sender, e) => { Xpcom.Shutdown(); };
#endif

			// An aggregate catalog that combines multiple catalogs
			using (var catalog = new AggregateCatalog())
			{
				catalog.Catalogs.Add(new DirectoryCatalog(
					Path.GetDirectoryName(Utilities.StripFilePrefix(typeof(ActionTypeHandlerRepository).Assembly.CodeBase)),
					"*-ChorusPlugin.dll"));

				// Create the CompositionContainer with the parts in the catalog
				using (var container = new CompositionContainer(catalog))
				{
					var connHelper = container.GetExportedValue<FLExConnectionHelper>();
					if (!connHelper.Init(commandLineArgs))
						return;

					// Is mercurial set up?
					var readinessMessage = HgRepository.GetEnvironmentReadinessMessage("en");
					if (!string.IsNullOrEmpty(readinessMessage))
					{
						MessageBox.Show(readinessMessage, CommonResources.kFLExBridge, MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
						return;
					}

					var l10Managers = Utilities.SetupLocalization(commandLineArgs);

					try
					{
						var handlerRepository = container.GetExportedValue<ActionTypeHandlerRepository>();
						var currentHandler = handlerRepository.GetHandler(commandLineArgs);
						currentHandler.StartWorking(commandLineArgs);
						var bridgeActionTypeHandlerShowWindow = currentHandler as IBridgeActionTypeHandlerShowWindow;
						if (bridgeActionTypeHandlerShowWindow != null)
						{
							Application.Run(bridgeActionTypeHandlerShowWindow.MainForm);
						}
						var bridgeActionTypeHandlerCallEndWork = currentHandler as IBridgeActionTypeHandlerCallEndWork;
						if (bridgeActionTypeHandlerCallEndWork != null)
						{
							bridgeActionTypeHandlerCallEndWork.EndWork();
						}
					}
					catch
					{
						connHelper.SignalBridgeWorkComplete(false);
						throw; // Re-throw the original exception, so the crash dlg has something to display.
					}
					finally
					{
						foreach (var manager in l10Managers.Values)
						{
							manager.Dispose();
						}

					}
				}
			}
			Settings.Default.Save();
		}