public void SetUpFixture()
		{
			Form parentForm = new Form();
			parentForm.CreateControl();
			
			XmlSchemaCompletionData schema = new XmlSchemaCompletionData(ResourceManager.GetXhtmlStrictSchema());
			XmlSchemaCompletionDataCollection schemas = new XmlSchemaCompletionDataCollection();
			schemas.Add(schema);
			provider = new XmlCompletionDataProvider(schemas, schema, String.Empty);
			TextEditorControl textEditor = new TextEditorControl();
			completionDataItems = provider.GenerateCompletionData(@"C:\Test.xml", textEditor.ActiveTextAreaControl.TextArea, '<');
			using (CodeCompletionWindow completionWindow = CodeCompletionWindow.ShowCompletionWindow(parentForm, textEditor, @"C:\Test.xml", provider, '<')) {
				CodeCompletionListView listView = (CodeCompletionListView)completionWindow.Controls[0];
				selectedCompletionData = listView.SelectedCompletionData;
				completionWindow.Close();
			}
		}
示例#2
0
        //=====================================================================

        /// <summary>
        /// Show a help topic in the SHFB help file
        /// </summary>
        /// <param name="topic">The topic ID to display (will be formatted as "html/[Topic_ID].htm")</param>
        /// <remarks>Since the standalone GUI already has a Help 1 file, we'll just display the topic
        /// that it contains rather than integrating an MSHC help file into the VS 2010 collection.</remarks>
        public static void ShowHelpTopic(string topic)
        {
            string path = null, anchor = String.Empty;
            int pos;

            if(String.IsNullOrEmpty(topic))
                throw new ArgumentException("A topic must be specified", "topic");

            try
            {
                path = Path.Combine(ComponentUtilities.ToolsFolder, @"Help\SandcastleBuilder.chm");

                // It may not be there in development builds so look in the release folder.  If still not found,
                // just ignore it.
                if(!File.Exists(path))
                {
                    path = Path.Combine(Environment.GetFolderPath(Environment.Is64BitProcess ?
                        Environment.SpecialFolder.ProgramFilesX86 : Environment.SpecialFolder.ProgramFiles),
                        @"EWSoftware\Sandcastle Help File Builder\Help\SandcastleBuilder.chm");

                    if(!File.Exists(path))
                        return;
                }

                // If there's an anchor, split it off
                pos = topic.IndexOf('#');

                if(pos != -1)
                {
                    anchor = topic.Substring(pos);
                    topic = topic.Substring(0, pos);
                }

                Form form = new Form();
                form.CreateControl();
                Help.ShowHelp(form, path, HelpNavigator.Topic, "html/" + topic + ".htm" + anchor);
            }
            catch(Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.ToString());
            }
        }
示例#3
0
        private static GameSettings GenerateSettingsAndHost()
        {
            if (hiddenHost == null)
            {
                hiddenHost = new Form();

                hiddenHost.Width = 4;
                hiddenHost.Height = 4;

                hiddenHost.Visible = false;

                hiddenHost.CreateControl();

                DeviceHandle = hiddenHost.Handle;
            }

            var result = new GameSettings();

            result.FullScreen = false;
            result.ResolutionWidth = 4;
            result.ResolutionHeight = 4;

            return result;
        }
        /// <summary>
        /// View help for this form
        /// </summary>
        /// <param name="sender">The sender of the event</param>
        /// <param name="e">The event arguments</param>
        private void btnHelp_Click(object sender, EventArgs e)
        {
            string path = Path.GetDirectoryName(
                Assembly.GetExecutingAssembly().Location);

            try
            {
            #if DEBUG
                path += @"\..\..\..\Doc\Help\SandcastleBuilder.chm";
            #else
                path += @"\SandcastleBuilder.chm";
            #endif
                Form form = new Form();
                form.CreateControl();
                Help.ShowHelp(form, path, HelpNavigator.Topic,
                    "html/7d28bf8f-923f-44c1-83e1-337a416947a1.htm#HelpAttributes");
            }
            catch(Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.ToString());
                MessageBox.Show(String.Format(CultureInfo.CurrentCulture,
                    "Unable to open help file '{0}'.  Reason: {1}",
                    path, ex.Message), Constants.AppName,
                    MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
		public void TestSetup()
		{
			m_ctrlOwner = new Form();

			m_scp = new DummyScrPassageControl(new ScrReference(01001001, ScrVers.English));
			m_filteredScp = new DummyScrPassageControl(new ScrReference(01001001, ScrVers.English));
			m_filteredScp.Initialize(m_filteredScp.ScReference, new [] {57, 59, 65});

			m_ctrlOwner.Controls.Add(m_scp);
			m_ctrlOwner.Controls.Add(m_filteredScp);
			m_ctrlOwner.CreateControl();

			if (m_scp.DropDownWindow != null)
				m_scp.DropDownWindow.Close();

			if (m_filteredScp.DropDownWindow != null)
				m_filteredScp.DropDownWindow.Close();
		}
示例#6
0
 /// <summary>
 /// Hack to get around the fact that Help.ShowHelp can make the help window
 /// modal over the application window
 /// </summary>
 private Form GetHelpParentWindow()
 {
     if (_agsEditor.Preferences.KeepHelpOnTop)
     {
         return Form.ActiveForm;
     }
     if (_dummyHelpForm == null)
     {
         _dummyHelpForm = new Form();
         _dummyHelpForm.CreateControl();
     }
     return _dummyHelpForm;
 }
示例#7
0
		public void TestPublicMethods ()
		{
			// Public Methods that force Handle creation:
			// - CreateGraphics ()
			// - GetChildAtPoint ()
			// - Invoke, BeginInvoke throws InvalidOperationException if Handle has not been created
			// - PointToClient ()
			// - PointToScreen ()
			// - RectangleToClient ()
			// - RectangleToScreen ()
			// - Select ()
			// - Show (IWin32Window)
			// Notes:
			// - CreateControl does NOT force Handle creation!
			
			Form c = new Form ();

			c.BringToFront ();
			Assert.IsFalse (c.IsHandleCreated, "A1");
			
			c.Contains (new Form ());
			Assert.IsFalse (c.IsHandleCreated, "A2");
			
			c.CreateControl ();
			Assert.IsFalse (c.IsHandleCreated, "A3");
			
			c = new Form ();
			Graphics g = c.CreateGraphics ();
			g.Dispose ();
			Assert.IsTrue (c.IsHandleCreated, "A4");
			c.Dispose ();
			c = new Form ();
			
			c.Dispose ();
			Assert.IsFalse (c.IsHandleCreated, "A5");
			c = new Form ();

			// This is weird, it causes a form to appear that won't go away until you move the mouse over it, 
			// but it doesn't create a handle??
			//DragDropEffects d = c.DoDragDrop ("yo", DragDropEffects.None);
			//Assert.IsFalse (c.IsHandleCreated, "A6");
			//Assert.AreEqual (DragDropEffects.None, d, "A6b");
			
			//Bitmap b = new Bitmap (100, 100);
			//c.DrawToBitmap (b, new Rectangle (0, 0, 100, 100));
			//Assert.IsFalse (c.IsHandleCreated, "A7");
			//b.Dispose ();
			c.FindForm ();
			Assert.IsFalse (c.IsHandleCreated, "A8");
			
			c.Focus ();
			Assert.IsFalse (c.IsHandleCreated, "A9");

			c.GetChildAtPoint (new Point (10, 10));
			Assert.IsTrue (c.IsHandleCreated, "A10");
			c.Dispose ();
			c = new Form ();
			
			c.GetContainerControl ();
			Assert.IsFalse (c.IsHandleCreated, "A11");
			c.Dispose ();
			
			c = new Form ();
			c.GetNextControl (new Control (), true);
			Assert.IsFalse (c.IsHandleCreated, "A12");
			c.GetPreferredSize (Size.Empty);
			Assert.IsFalse (c.IsHandleCreated, "A13");
			c.Hide ();
			Assert.IsFalse (c.IsHandleCreated, "A14");
			
			c.Invalidate ();
			Assert.IsFalse (c.IsHandleCreated, "A15");
			
			//c.Invoke (new InvokeDelegate (InvokeMethod));
			//Assert.IsFalse (c.IsHandleCreated, "A16");
			c.PerformLayout ();
			Assert.IsFalse (c.IsHandleCreated, "A17");
			
			c.PointToClient (new Point (100, 100));
			Assert.IsTrue (c.IsHandleCreated, "A18");
			c.Dispose ();
			c = new Form ();
			
			c.PointToScreen (new Point (100, 100));
			Assert.IsTrue (c.IsHandleCreated, "A19");
			c.Dispose ();
			
			c = new Form ();
			
			//c.PreProcessControlMessage   ???
			//c.PreProcessMessage          ???
			c.RectangleToClient (new Rectangle (0, 0, 100, 100));
			Assert.IsTrue (c.IsHandleCreated, "A20");
			c.Dispose ();
			c = new Form ();
			c.RectangleToScreen (new Rectangle (0, 0, 100, 100));
			Assert.IsTrue (c.IsHandleCreated, "A21");
			c.Dispose ();
			c = new Form ();
			c.Refresh ();
			Assert.IsFalse (c.IsHandleCreated, "A22");
			c.ResetBackColor ();
			Assert.IsFalse (c.IsHandleCreated, "A23");
			c.ResetBindings ();
			Assert.IsFalse (c.IsHandleCreated, "A24");
			c.ResetCursor ();
			Assert.IsFalse (c.IsHandleCreated, "A25");
			c.ResetFont ();
			Assert.IsFalse (c.IsHandleCreated, "A26");
			c.ResetForeColor ();
			Assert.IsFalse (c.IsHandleCreated, "A27");
			c.ResetImeMode ();
			Assert.IsFalse (c.IsHandleCreated, "A28");
			c.ResetRightToLeft ();
			Assert.IsFalse (c.IsHandleCreated, "A29");
			c.ResetText ();
			Assert.IsFalse (c.IsHandleCreated, "A30");
			c.SuspendLayout ();
			Assert.IsFalse (c.IsHandleCreated, "A31");
			c.ResumeLayout ();
			Assert.IsFalse (c.IsHandleCreated, "A32");
			c.Scale (new SizeF (1.5f, 1.5f));
			Assert.IsFalse (c.IsHandleCreated, "A33");
			c.Select ();
			Assert.IsTrue (c.IsHandleCreated, "A34");
			c.Dispose ();
			
			c = new Form ();
			
			c.SelectNextControl (new Control (), true, true, true, true);
			Assert.IsFalse (c.IsHandleCreated, "A35");
			c.SetBounds (0, 0, 100, 100);
			Assert.IsFalse (c.IsHandleCreated, "A36");
			c.Update ();
			Assert.IsFalse (c.IsHandleCreated, "A37");
			
			// Form
			
			c.Activate ();
			Assert.IsFalse (c.IsHandleCreated, "F1");
			
			c.AddOwnedForm (new Form ());
			Assert.IsFalse (c.IsHandleCreated, "F2");
			
			c.Close ();
			Assert.IsFalse (c.IsHandleCreated, "F3");
			
			c.Hide ();
			Assert.IsFalse (c.IsHandleCreated, "F4");
			
			c.LayoutMdi (MdiLayout.Cascade);
			Assert.IsFalse (c.IsHandleCreated, "F5");

#if !MONO
			c.PerformAutoScale ();
			Assert.IsFalse (c.IsHandleCreated, "F6"); 
#endif
			
			c.PerformLayout ();
			Assert.IsFalse (c.IsHandleCreated, "F7");
			
			c.AddOwnedForm (new Form ());
			c.RemoveOwnedForm (c.OwnedForms [c.OwnedForms.Length - 1]);
			Assert.IsFalse (c.IsHandleCreated, "F8");
			
			c.ScrollControlIntoView (null);
			Assert.IsFalse (c.IsHandleCreated, "F9");
			
			c.SetAutoScrollMargin (7, 13);
			Assert.IsFalse (c.IsHandleCreated, "F10");
			
			c.SetDesktopBounds (-1, -1, 144, 169);
			Assert.IsFalse (c.IsHandleCreated, "F11");
			
			c.SetDesktopLocation (7, 13);
			Assert.IsFalse (c.IsHandleCreated, "F12");

			c = new Form ();
			c.Show (null);
			Assert.IsTrue (c.IsHandleCreated, "F13");
			c.Close ();
			c = new Form (); 
			
			//c.ShowDialog ()
			
			c.ToString ();
			Assert.IsFalse (c.IsHandleCreated, "F14");
			
			c.Validate ();
			Assert.IsFalse (c.IsHandleCreated, "F15");

#if !MONO
			c.ValidateChildren ();
			Assert.IsFalse (c.IsHandleCreated, "F16"); 
#endif

			c.Close ();
		}
		public void TestSetup()
		{
		    m_versification = new TestScrVers();
            m_ctrlOwner = new Form();

			m_scp = new DummyScrPassageControl();
		    m_scp.Initialize(new BCVRef(01001001), m_versification);
			m_filteredScp = new DummyScrPassageControl();
            m_filteredScp.Initialize(new BCVRef(01001001), m_versification, new[] { 57, 59, 65 });

			m_ctrlOwner.Controls.Add(m_scp);
			m_ctrlOwner.Controls.Add(m_filteredScp);
			m_ctrlOwner.CreateControl();

			if (m_scp.DropDownWindow != null)
				m_scp.DropDownWindow.Close();

			if (m_filteredScp.DropDownWindow != null)
				m_filteredScp.DropDownWindow.Close();
		}
示例#9
0
        public Framework(string title, int width, int height, bool depth, bool stencil, bool _VSync)
        {
            // Create the display to display on
            Window = new Form()
            {
                StartPosition = FormStartPosition.CenterScreen,
                ClientSize = new Size(width, height),
                Text = title,
                TopMost = true,
            };
            Window.StartPosition = FormStartPosition.Manual;
            Window.Location = new Point(1100, 80);
            Window.FormBorderStyle = FormBorderStyle.Fixed3D;
            Window.WindowState =FormWindowState.Normal;
            Window.CreateControl();
            VerticalSyncEnabled = _VSync;
            CreateDevice();

            // Create a description of the display mode
            var modeDescription = new ModeDescription()
            {
                Format = Format.R8G8B8A8_UNorm,
                RefreshRate = new Rational(60, 1),
                Scaling = DisplayModeScaling.Unspecified,
                ScanlineOrdering = DisplayModeScanlineOrder.Unspecified,
                Width = width,
                Height = height,
            };

            // Create a description of the sampling for multisampling or antialiasing
            var sampleDescription = new SampleDescription()
            {
                Count = 1,
                Quality = 0,
            };

            // Create a description of the swap chain or front and back buffers
            var swapDescription = new SwapChainDescription()
            {
                ModeDescription = modeDescription,
                SampleDescription = sampleDescription,
                BufferCount = 1,
                Flags = SwapChainFlags.None,
                IsWindowed = true,
                OutputHandle = Window.Handle,
                SwapEffect = SwapEffect.Discard,
                Usage = Usage.RenderTargetOutput,
            };

            // Create the DirectX 11 Device
            SharpDX.Direct3D11.Device.CreateWithSwapChain(SharpDX.Direct3D.DriverType.Hardware, DeviceCreationFlags.BgraSupport|DeviceCreationFlags.Debug, swapDescription, out Device, out swapChain);

            DContext = Device.ImmediateContext;
            // Create the factory which manages general graphics resources
            // Ignore all windows events
            Factory = swapChain.GetParent<Factory>();
            Factory.MakeWindowAssociation(Window.Handle, WindowAssociationFlags.IgnoreAll);
            Factory.Dispose();
            // New RenderTargetView from the backbuffer
            var backBuffer = Texture2D.FromSwapChain<Texture2D>(swapChain, 0);
            RenderTargetView = new RenderTargetView(Device, backBuffer);
            RenderTargetView.DebugName = "std";
            // Release pointer to the back buffer as we no longer need it.
            backBuffer.Dispose();

            frame_width=Window.ClientSize.Width;
            frame_height=Window.ClientSize.Height;

            #region Zdepth
            if (depth || stencil)
            {
                _depth=true;
                var textureDescription = new Texture2DDescription()
                {
                    Width = frame_width,
                    Height = frame_height,
                    MipLevels = 1,
                    ArraySize = 1,
                    Format = (stencil) ? Format.D32_Float : Format.D24_UNorm_S8_UInt,
                    SampleDescription = sampleDescription,
                    Usage = ResourceUsage.Default,
                    BindFlags = BindFlags.DepthStencil,
                    CpuAccessFlags = CpuAccessFlags.None,
                    OptionFlags = ResourceOptionFlags.None,
                };

                var texture = new Texture2D(Device, textureDescription);

                var depthStencilViewDescription = new DepthStencilViewDescription()
                {
                    Format = textureDescription.Format,
                    Dimension = DepthStencilViewDimension.Texture2DMultisampled
                };

                DepthStencilView = new DepthStencilView(Device, texture, depthStencilViewDescription);
                DContext.OutputMerger.SetTargets(DepthStencilView, RenderTargetView);
            }
            else
            {
                DContext.OutputMerger.SetTargets(RenderTargetView);
            }

            if (depth && !stencil)
                depthStencilClear = DepthStencilClearFlags.Depth;
            else if (stencil && !depth)
                depthStencilClear = DepthStencilClearFlags.Stencil;
            else if (stencil && depth)
                depthStencilClear = DepthStencilClearFlags.Stencil | DepthStencilClearFlags.Depth;
            #endregion

            #region Rasterizer
            RasterizerStateDescription RAS = new RasterizerStateDescription();
            RAS.IsMultisampleEnabled = true; //important for AA
            RAS.CullMode = CullMode.Back;
            RAS.DepthBias = 0;
            RAS.DepthBiasClamp = 0.0f;
            RAS.FillMode = FillMode.Solid;
            RAS.IsDepthClipEnabled = false;
            RAS.IsFrontCounterClockwise = true;
            DContext.Rasterizer.State = new RasterizerState(Device, RAS);
            #endregion

            // Setup the camera viewport
            var viewport = new Viewport()
            {
                TopLeftX = 0,
                TopLeftY = 0,
                Width = width,
                Height = height,
                MinDepth = 0.0f,
                MaxDepth = 1.0f,
            };
            DContext.Rasterizer.SetViewports(viewport);

            Stopwatch = new Stopwatch();
        }
示例#10
0
 public static System.Windows.Forms.Form CreateOutlineForm()
 {
     System.Windows.Forms.Form form = new System.Windows.Forms.Form();
     try
     {
         form.Size = new Size(0, 0);
     }
     catch
     {
         form = new System.Windows.Forms.Form();
     }
     form.BackColor = SystemColors.Highlight;
     form.MinimizeBox = false;
     form.MaximizeBox = false;
     form.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
     if (NativeFunctions.AlphaBlendingSupported)
         form.Opacity = .5;
     else
         form.BackColor = System.Windows.Forms.ControlPaint.LightLight(SystemColors.Highlight);
     form.ShowInTaskbar = false;
     form.Text = "";
     form.CreateControl();
     return form;
 }
示例#11
0
        private void MessagePump(object arg)
        {
            try {
                OnThreadStarted();

                Type windowType = (Type)arg;

                window = (Form)windowType.Assembly.CreateInstance(windowType.FullName);

                MSG m;

                // Create message queue
                PeekMessage(out m, IntPtr.Zero, 0, 0, PM_NOREMOVE);

                // Create window and obtain its handle
                window.CreateControl();
                IntPtr handle = window.Handle;

                // Set created event
                windowCreatedEvent.Set();

                // Message pump
                while (GetMessage(out m, IntPtr.Zero, 0, 0)) {
                    TranslateMessage(ref m);
                    DispatchMessage(ref m);
                }
            }
            catch (Exception e) {
                FatalExceptionDialog dlg = new FatalExceptionDialog();
                dlg.Exception = e;
                dlg.TryToContinueEnabled = false;
                dlg.ShowDialog();
                dlg.Dispose();
                Environment.Exit(-1);
            }
            finally {
                // Dispose closed window
                if (window != null)
                    window.Dispose();
            }
        }
示例#12
0
		public void Init()
		{
			m_inMemoryCache = ScrInMemoryFdoCache.Create(this);
			m_inMemoryCache.InitializeLangProject();
			m_inMemoryCache.InitializeScripture();
			m_inMemoryCache.AddBookToMockedScripture(1, "Genesis");
			m_inMemoryCache.AddBookToMockedScripture(2, "Exodus");
			m_inMemoryCache.AddBookToMockedScripture(5, "Deuteronomy");
			m_James = m_inMemoryCache.AddBookToMockedScripture(59, "James");
			m_inMemoryCache.AddBookToMockedScripture(66, "Revelation");
			m_fdoCache = m_inMemoryCache.Cache;

			m_scr = (Scripture)m_fdoCache.LangProject.TranslatedScriptureOA;

			m_ctrlOwner = new Form();

			ILgWritingSystemFactory wsf = m_fdoCache.LanguageWritingSystemFactoryAccessor;
			m_scp = new DummyScrPassageControl(null, m_scr, false);
			m_dbScp = new DummyScrPassageControl(null, m_scr, true);

			m_ctrlOwner.Controls.Add(m_scp);
			m_ctrlOwner.Controls.Add(m_dbScp);
			m_ctrlOwner.CreateControl();

			if (m_scp.DropDownWindow != null)
				m_scp.DropDownWindow.Close();

			if (m_dbScp.DropDownWindow != null)
				m_dbScp.DropDownWindow.Close();

			// Forcing the reference to this should reset the ScrReference object for us
			// which, we hope will cause some strange errors to occur when running in
			// console mode. The tests seem to always work in gui mode but not console mode.
			m_scp.ScReference = new ScrReference(01001001, m_scr.Versification);
			m_dbScp.ScReference = new ScrReference(01001001, m_scr.Versification);
		}
示例#13
0
        /// <summary>
        /// View the help file
        /// </summary>
        /// <param name="sender">The sender of the event</param>
        /// <param name="e">The event arguments</param>
        private void miHelp_Click(object sender, EventArgs e)
        {
            string topic, path = Path.GetDirectoryName(
                Assembly.GetExecutingAssembly().Location);

            try
            {
            #if DEBUG
                path += @"\..\..\..\Doc\Help\SandcastleBuilder.chm";
            #else
                path += @"\SandcastleBuilder.chm";
            #endif

                if(sender == miHelp || sender == tsbAbout)
                    topic = "html/bd1ddb51-1c4f-434f-bb1a-ce2135d3a909.htm";
                else
                    topic = "html/1aea789d-b226-4b39-b534-4c97c256fac8.htm";

                Form form = new Form();
                form.CreateControl();
                Help.ShowHelp(form, path, HelpNavigator.Topic, topic);
            }
            catch(Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.ToString());
                MessageBox.Show(String.Format(CultureInfo.CurrentCulture,
                    "Unable to open help file '{0}'.  Reason: {1}",
                    path, ex.Message), Constants.AppName,
                    MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }