public override void Create() { base.Create(); cControl = new XboxController(SlimDX.XInput.UserIndex.One); pControl = new XboxController(SlimDX.XInput.UserIndex.Two); GameObject cursor = new Cursor(cControl); GameObject player = new Player(pControl); GameObject cannon1 = new Cannon(); cannon1.Position.X = 365; cannon1.Position.Y = -265; GameObject cannon2 = new Cannon(); cannon2.Position.X = 365; cannon2.Position.Y = 265; GameObject cannon3 = new Cannon(); cannon3.Position.X = -365; cannon3.Position.Y = 265; GameObject cannon4 = new Cannon(); cannon4.Position.X = -365; cannon4.Position.Y = -265; ObjectManager.AddGameObject(cursor); ObjectManager.AddGameObject(player); ObjectManager.AddGameObject(cannon1); ObjectManager.AddGameObject(cannon2); ObjectManager.AddGameObject(cannon3); ObjectManager.AddGameObject(cannon4); }
public void Constructor_WhenGivenANullExpression_ThrowsException() { var start = new Cursor("OK"); var end = start.Advance(2); var codeSpan = new CodeSpan("OK", start, end); Assert.That(() => new TypedExpression(codeSpan, null), Throws.InstanceOf<ArgumentNullException>()); }
public void ToString_WhenConstructedWithANullValue_ReturnsTheCodeVerbatim() { var start = new Cursor("OK"); var end = start.Advance(2); var codeSpan = new CodeSpan("OK", start, end); Assert.That(codeSpan.ToString(), Is.EqualTo("OK")); }
internal CursorContainer(Form argForm, Cursor argCursor) { theForm = argForm; if (theForm == null) return; theCursor = theForm.Cursor; theForm.Cursor = argCursor; }
public void Parse(Cursor cursor) { if (String.IsNullOrEmpty(cursor.Name)) return; String enumName = cursor.Name.Substring(2).Replace("_", ""); if (enumName == "ChildVisitResult") enumName = "CursorVisitResult"; if (enumName == "CallingConv") enumName = "CallingConvention"; String filename = Path.Combine(_di.FullName, enumName + ".h"); var contents = new StringBuilder(); contents.AppendLine(Template.Template.Header); if (enumName.EndsWith("Flags")) contents.AppendLine(" [System::Flags]"); contents.Append(" public enum class "); contents.Append(enumName); contents.AppendLine(" {"); // add values _sb = contents; cursor.VisitChildren(EnumVisitor); contents.AppendLine(" };"); contents.AppendLine(Template.Template.Footer); File.WriteAllText(filename, contents.ToString()); }
static int Main (string [] args) { string icoFile = Path.Combine (AppDomain.CurrentDomain.BaseDirectory, "earth.ico"); Icon ico1 = new Icon (icoFile); if (ico1.Size != new Size (32, 32)) return 1; #if NET_2_0 Icon ico2 = new Icon (icoFile, 20, 40); if (ico2.Size != new Size (32, 32)) return 2; Icon ico3 = new Icon (icoFile, new Size (20, 40)); if (ico3.Size != new Size (32, 32)) return 3; #endif string curFile = Path.Combine (AppDomain.CurrentDomain.BaseDirectory, "text.cur"); Cursor cursor = new Cursor (curFile); if (cursor.Size != new Size (32, 32)) return 4; return 0; }
protected override void InitializeGame() { System.Windows.Forms.Cursor.Hide(); renderer.ProjectionMode = ProjectionMode.Orthogonal; renderer.ViewMatrix = Matrix.LookAtLH( new Vector3( 0, 0, -5.0f ), new Vector3(), new Vector3( 0, 1, 0 ) ); renderer.Device.RenderState.Lighting = false; showFPS = config.GetSetting<bool>( "ShowFPS" ); fpsFont = renderer.CreateFont( "Arial", 16 ); fpsFont.ShadowColor = Color.Gray; cursor = new Cursor( renderer, "cursor", new Size( 10, 10 ) ); useBloom = config.GetSetting<bool>( "UseBloom" ); sceneTex = new Gas.Graphics.Texture( renderer, renderer.FullscreenSize.Width, renderer.FullscreenSize.Height, true ); bloomProcessor = new BloomPostProcessor( renderer ); bloomProcessor.Blur = config.GetSetting<float>( "BloomBlur" ); bloomProcessor.BloomScale = config.GetSetting<float>( "BloomScale" ); bloomProcessor.BrightPassThreshold = config.GetSetting<float>( "BloomBrightPassThreshold" ); cursorInfluenceMagnitude = config.GetSetting<int>( "CursorInfluenceMagnitude" ); InitializeGrid(); this.KeyDown += new KeyEventHandler( OnKeyDown ); }
void CreateUI() { var cache = ResourceCache; // Set up global UI style into the root UI element XmlFile style = cache.GetXmlFile("UI/DefaultStyle.xml"); UI.Root.SetDefaultStyle(style); // Create a Cursor UI element because we want to be able to hide and show it at will. When hidden, the mouse cursor will // control the camera, and when visible, it will interact with the UI Cursor cursor=new Cursor(); cursor.SetStyleAuto(null); UI.Cursor=cursor; // Set starting position of the cursor at the rendering window center var graphics = Graphics; cursor.SetPosition(graphics.Width / 2, graphics.Height / 2); // Load UI content prepared in the editor and add to the UI hierarchy UI.LoadLayoutToElement(UI.Root, cache, "UI/UILoadExample.xml"); // Subscribe to button actions (toggle scene lights when pressed then released) var button1 = (Button) UI.Root.GetChild("ToggleLight1", true); var button2 = (Button) UI.Root.GetChild("ToggleLight2", true); button1.SubscribeToReleased (args => ToggleLight1 ()); button2.SubscribeToReleased (args => ToggleLight2 ()); }
protected virtual void Awake() { blockLayer = 1 << LayerMask.NameToLayer("Block"); buildController = FindObjectOfType<BuildController>(); buildController.InputModeSelected += (sender, args) => { currentBuildMode = args.buildMode; }; cursor = GetComponent<Cursor>(); }
public static Vector2 ReadVector2(byte[] data, Cursor cursor) { Vector2 retVal = new Vector2(); retVal.x = Utils.ReadFloat (data, cursor); retVal.y = Utils.ReadFloat (data, cursor); return retVal; }
public void ExpectEvent() { var test = @" # This is an event template for testing EventForTesting { uint16 MyUnsignedInteger16; int16 MyInteger16; uint32 MyUnsignedInteger32; int32 MyInteger32; string MyString; ip_addr MyIPAddr; int64 MyInteger64; uint64 MyUnsignedInteger64; boolean MyBoolean; }"; Cursor cursor = new Cursor(); EventTemplate evt = EventTemplate.ExpectEvent(test.ToCharArray(), ref cursor); Assert.IsNotNull(evt); Assert.AreEqual("EventForTesting", evt.Name); Assert.AreEqual(9, evt.Attributes.Count()); evt["MyUnsignedInteger16"].IsAssignable<ushort>(0); evt["MyInteger16"].IsAssignable<short>(0); evt["MyUnsignedInteger32"].IsAssignable<uint>(0); evt["MyInteger32"].IsAssignable<int>(0); evt["MyString"].IsAssignable<string>(String.Empty); evt["MyIPAddr"].IsAssignable<IPAddress>(null); evt["MyInteger64"].IsAssignable<long>(0); evt["MyUnsignedInteger64"].IsAssignable<ulong>(0); evt["MyBoolean"].IsAssignable<bool>(false); }
public void Constructor_WhenGivenNullStartCursor_ThrowsException() { var start = new Cursor("OK"); var end = start.Advance(2); Assert.That(() => new CodeSpan("OK", null, end), Throws.InstanceOf<ArgumentNullException>()); }
public GUIPlayer( Simulator simulator, Dictionary<TurretType, bool> availableTurrets, Dictionary<string, LevelDescriptor> levelsDescriptors, Color color, string representation, InputType inputType) { Simulator = simulator; SelectedCelestialBodyAnimation = new SelectedCelestialBodyAnimation(Simulator); Cursor = new SpaceshipCursor(Simulator.Scene, Vector3.Zero, 2, VisualPriorities.Default.PlayerCursor, color, representation, true); Crosshair = new Cursor(Simulator.Scene, Vector3.Zero, 2, VisualPriorities.Default.PlayerCursor, "crosshairRailGun", false); TurretMenu = new TurretMenu(Simulator, VisualPriorities.Default.TurretMenu, color, inputType); CelestialBodyMenu = new CelestialBodyMenu(Simulator, VisualPriorities.Default.CelestialBodyMenu, color, inputType); FinalSolutionPreview = new FinalSolutionPreview(Simulator); CelestialBodyMenu.AvailableTurrets = availableTurrets; CelestialBodyMenu.Initialize(); WorldMenu = new WorldMenu(Simulator, VisualPriorities.Default.CelestialBodyMenu, levelsDescriptors, color); NewGameMenu = new NewGameMenu(Simulator, VisualPriorities.Default.CelestialBodyMenu, color); PowerUpInputMode = false; PowerUpFinalSolution = false; }
public void Constructor_WhenGivenANullExpression_ThrowsException() { var start = new Cursor("OK"); var end = start.Advance(2); Assert.That(() => new Identifier(null, start, end), Throws.InstanceOf<ArgumentNullException>()); }
public void Constructor_WhenGivenASpecificLocation_SetsTheCorrectLineAndColumn(string subject, int location, int line, int column) { var cursor = new Cursor(subject, location); Assert.That(cursor.Line, Is.EqualTo(line)); Assert.That(cursor.Column, Is.EqualTo(column)); }
public void GetHashCode_WithEqualSubjectsAndIndexesAndStateKey_ReturnsSameValue([Values(0, 1, 2)] int index) { var subjectA = new Cursor("OK", index); var subjectB = subjectA.Advance(0); Assert.That(subjectB.GetHashCode(), Is.EqualTo(subjectA.GetHashCode())); }
/// <summary> /// Initializes a new instance of the <see cref="Quantifier"/> class. /// </summary> /// <param name="start">The cursor just before the <see cref="Quantifier"/>.</param> /// <param name="end">The cursor just after the <see cref="Quantifier"/>.</param> /// <param name="min">The minimum number of times to match.</param> /// <param name="max">The maximum number of times to match, if limited; or null, otherwise.</param> /// <param name="delimiter">The expression to use as a delimiter.</param> public Quantifier(Cursor start, Cursor end, int min, int? max = null, Expression delimiter = null) { if (start == null) { throw new ArgumentNullException(nameof(start)); } if (end == null) { throw new ArgumentNullException(nameof(end)); } this.Start = start; this.End = end; this.Min = min; this.Max = max; if (delimiter != null) { SequenceExpression sequenceExpression; if ((sequenceExpression = delimiter as SequenceExpression) == null || sequenceExpression.Sequence.Count != 0) { this.Delimiter = delimiter; } } }
public SimpleKey(bool isPossible, bool isRequired, int tokenNumber, Cursor cursor) { IsPossible = isPossible; IsRequired = isRequired; TokenNumber = tokenNumber; this.cursor = new Cursor(cursor); }
public void Constructor_WhenGivenANullFlagsCollection_DoesNotThrow() { var start = new Cursor("OK"); var end = start.Advance(2); Assert.That(() => new Rule(new Identifier("OK", start, end), new WildcardExpression(), null), Throws.Nothing); }
public Define init(Flash flash, byte[] data, Cursor cursor){ //parse _flash = flash; parse (data, cursor); return this; }
public Aheui() { this.codeSpace = null; this.storage = new Storage(); this._cursor = new Cursor(0, 0); this.init(); }
public Aheui(int MinStackSize, int MaxStackSize) { this.codeSpace = null; this.storage = new Storage(MinStackSize, MaxStackSize); this._cursor = new Cursor(0, 0); this.init(); }
internal void AddCompilerError(Cursor cursor, System.Linq.Expressions.Expression<Func<string>> error, params object[] args) { var parts = ((System.Linq.Expressions.MemberExpression)error.Body).Member.Name.Split('_'); var errorId = parts[0]; bool? isWarning = null; switch (parts[1]) { case "ERROR": isWarning = false; break; case "WARNING": isWarning = true; break; #if DEBUG default: throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Unknown error type '{0}'.", parts[1]), "error"); #endif } var errorFormat = error.Compile()(); var errorText = string.Format(CultureInfo.CurrentCulture, errorFormat, args); this.Errors.Add(new CompilerError(cursor.FileName ?? string.Empty, cursor.Line, cursor.Column, errorId, errorText) { IsWarning = isWarning ?? true }); }
public void Constructor_WhenGivenANullSettingsCollection_DoesNotThrow() { var start = new Cursor("OK"); var end = start.Advance(2); Assert.That(() => new Grammar(new Rule[0], null, end), Throws.Nothing); }
protected override IEnumerable<Token> Tokenize(string source) { Cursor c = new Cursor(source); while (c.Offset < source.Length) { var currentChar = source[c.Offset]; if (operators.Contains(currentChar)) { yield return new Token(c.Offset, c.Offset + 1, "Operator.Symbol"); c.Advance(1); continue; } if (grouping.Contains(currentChar)) { yield return new Token(c.Offset, c.Offset + 1, "Grouping.Statements"); c.Advance(1); continue; } var match = whitespace.Match(source, c.Offset); if (match.Success && match.Index == c.Offset) { yield return new Token(c.Offset, c.Offset + match.Length, "Whitespace.Insignificant"); c.Advance(match.Length); continue; } match = nonOperator.Match(source, c.Offset); yield return new Token(c.Offset, c.Offset + match.Length, "Comment.Block"); c.Advance(match.Length); } }
/// <summary> /// Initializes a new instance of the <see cref="CodeSpan"/> class. /// </summary> /// <param name="code">The string contents of the code span.</param> /// <param name="start">The start of the code region.</param> /// <param name="end">The end of the code region.</param> /// <param name="value">The value of the code span.</param> public CodeSpan(string code, Cursor start, Cursor end, string value = null) { this.code = code; this.start = start; this.end = end; this.value = value ?? code; }
public void Constructor_WhenGivenANullCollectionOfRules_ThrowsException() { var start = new Cursor("OK"); var end = start.Advance(2); Assert.That(() => new Grammar(null, new Dictionary<Identifier, object>(), end), Throws.InstanceOf<ArgumentNullException>()); }
void Awake() { Instance = this; GetComponent<FsmBehaviour>().GlobalState = new CursorGlobalFsm(); GetComponent<FsmBehaviour>().CurrentState = new CursorDefaultFsm(); }
public void Constructor_WhenGivenANullValue_ThrowsException(bool ignoreCase, bool fromResource) { var start = new Cursor("OK"); var end = start.Advance(2); Assert.That(() => new LiteralExpression(start, end, null, ignoreCase, fromResource), Throws.InstanceOf<ArgumentNullException>()); }
public override Cursor Query(string sql) { OracleConnection oracleConnection = (OracleConnection) Open(); OracleCommand oracleCommand = new OracleCommand(sql,oracleConnection); OracleDataReader oracleDataReader = oracleCommand.ExecuteReader(); Cursor cursor = new Cursor(oracleDataReader); return cursor; }
public override string SwitchCursor(Cursor cursor) => $"{Switch()}-{ToCursor( cursor )}";
private void ShowMouseBusy() { defaultcursor = Mouse.OverrideCursor; Mouse.OverrideCursor = System.Windows.Input.Cursors.Wait; }
public WaitCursor() { _previousCursor = Mouse.OverrideCursor; Mouse.OverrideCursor = Cursors.Wait; }
static SledgeCursors() { RotateCursor = new Cursor(new MemoryStream(Resources.Cursor_Rotate)); }
private void UpdateCursor(Transform transformUnderCoursor, bool highlighted) { var interactable = transformUnderCoursor?.GetComponent <Interactable>(); Cursor.SetCursor(highlighted && interactable != null && interactable.Active ? _highlightCursorTexture : null, new Vector2(13, 16), CursorMode.ForceSoftware); }
public StatusBusy() { this.c = Cursor.Current; Cursor.Current = Cursors.WaitCursor; }
void OnMouseExit() { Cursor.SetCursor(null, Vector2.zero, cursorMode); }
void OnMouseEnter() { Cursor.SetCursor(cursorTexture2, Vector2.zero, cursorMode); }
private void SetCursor(Cursor cursor, StreamSequenceToken sequenceToken) { // If nothing in cache, unset token, and wait for more data. if (messageBlocks.Count == 0) { cursor.State = Cursor.States.Unset; cursor.SequenceToken = sequenceToken; return; } LinkedListNode <CachedMessageBlock <TQueueMessage, TCachedMessage> > newestBlock = messageBlocks.First; // if sequenceToken is null, iterate from newest message in cache if (sequenceToken == null) { cursor.State = Cursor.States.Idle; cursor.CurrentBlock = newestBlock; cursor.Index = newestBlock.Value.NewestMessageIndex; cursor.SequenceToken = newestBlock.Value.NewestSequenceToken; return; } // If sequenceToken is too new to be in cache, unset token, and wait for more data. TCachedMessage newestMessage = newestBlock.Value.NewestMessage; if (cacheDataAdapter.CompareCachedMessageToSequenceToken(ref newestMessage, sequenceToken) < 0) { cursor.State = Cursor.States.Unset; cursor.SequenceToken = sequenceToken; return; } // Check to see if sequenceToken is too old to be in cache TCachedMessage oldestMessage = messageBlocks.Last.Value.OldestMessage; if (cacheDataAdapter.CompareCachedMessageToSequenceToken(ref oldestMessage, sequenceToken) > 0) { // throw cache miss exception throw new QueueCacheMissException(sequenceToken, messageBlocks.Last.Value.OldestSequenceToken, messageBlocks.First.Value.NewestSequenceToken); } // Find block containing sequence number, starting from the newest and working back to oldest LinkedListNode <CachedMessageBlock <TQueueMessage, TCachedMessage> > node = messageBlocks.First; while (true) { TCachedMessage oldestMessageInBlock = node.Value.OldestMessage; if (cacheDataAdapter.CompareCachedMessageToSequenceToken(ref oldestMessageInBlock, sequenceToken) <= 0) { break; } node = node.Next; } // return cursor from start. cursor.CurrentBlock = node; cursor.Index = node.Value.GetIndexOfFirstMessageLessThanOrEqualTo(sequenceToken); // if cursor has been idle, move to next message after message specified by sequenceToken if (cursor.State == Cursor.States.Idle) { // if there are more messages in this block, move to next message if (!cursor.IsNewestInBlock) { cursor.Index++; } // if this is the newest message in this block, move to oldest message in newer block else if (node.Previous != null) { cursor.CurrentBlock = node.Previous; cursor.Index = cursor.CurrentBlock.Value.OldestMessageIndex; } else { cursor.State = Cursor.States.Idle; return; } } cursor.SequenceToken = cursor.CurrentBlock.Value.GetSequenceToken(cursor.Index); cursor.State = Cursor.States.Set; }
///<summary> ///Default constructor ///</summary> public CursorEventArgs(Cursor cursor) { this.mCursor = cursor; }
//////////////////////////////////////////////////////////////////// // Font info form initialization //////////////////////////////////////////////////////////////////// private void OnLoad ( object sender, EventArgs e ) { // wait coursor Cursor SaveCursor = Cursor; Cursor = Cursors.WaitCursor; ViewButton.Enabled = false; ExitButton.Enabled = false; // try regulaar, bold, italic and bold-italic Int32 StyleIndex; for (StyleIndex = 0; StyleIndex < 4 && !FontFamily.IsStyleAvailable((FontStyle)StyleIndex); StyleIndex++) { ; } Style = (FontStyle)StyleIndex; // design height DesignHeight = FontFamily.GetEmHeight(Style); // create font DesignFont = new Font(FontFamily, DesignHeight, Style, GraphicsUnit.Pixel); // create windows sdk font info object FontInfo = new FontApi(DesignFont, DesignHeight); // get outline text metrics structure WinOutlineTextMetric OTM = FontInfo.GetOutlineTextMetricsApi(); // first and last character available FirstChar = OTM.otmTextMetric.tmFirstChar; LastChar = OTM.otmTextMetric.tmLastChar; // get font and glyph information GlyphCode = FontInfo.GetGlyphIndicesApi(FirstChar, LastChar); // create and load data grid DataGrid = new CustomDataGridView(this, true); DataGrid.CellMouseDoubleClick += new DataGridViewCellMouseEventHandler(OnMouseDoubleClick); // add columns DataGrid.Columns.Add("CharCode", "Char\nCode"); DataGrid.Columns.Add("GlyphCode", "Glyph\nCode"); DataGrid.Columns.Add("Glyph", "Glyph"); DataGrid.Columns.Add("AdvanceWidth", "Advance\nWidth"); DataGrid.Columns.Add("BBoxLeft", "BBox\nLeft"); DataGrid.Columns.Add("BBoxBottom", "BBox\nBottom"); DataGrid.Columns.Add("BBoxRight", "BBox\nRight"); DataGrid.Columns.Add("BBoxTop", "BBox\nTop"); // change the font for the display of the character to the current font DataGridViewCellStyle GlyphCellStyle = new DataGridViewCellStyle(DataGrid.DefaultCellStyle); GlyphCellStyle.Font = new Font(FontFamily, 12.0F, Style); DataGrid.Columns[(Int32)FontInfoColumn.Glyph].DefaultCellStyle = GlyphCellStyle; // load one row at a time to data grid for (Int32 CharPtr = 0; CharPtr < GlyphCode.Length; CharPtr++) { if (GlyphCode[CharPtr] == 0) { continue; } LoadDataGridRow(FirstChar + CharPtr, GlyphCode[CharPtr], FontInfo.GetGlyphMetricsApi((Char)(FirstChar + CharPtr))); } // select first row if (DataGrid.Rows.Count > 0) { DataGrid.Rows[0].Selected = true; } OnResize(null, null); // normal cursor Cursor = SaveCursor; ViewButton.Enabled = true; ExitButton.Enabled = true; return; }
public void OnPointerEnter(PointerEventData eventData) { Cursor.SetCursor(cursorTexture, hotSpot, CursorMode.Auto); isOutside = false; }
public void AddCursor(object key, Cursor cursor) { m_map[key] = cursor; }
public void SpecialCursor() { // Debug.Log("SpecialCursor"); hotspot = new Vector2(specialCursor.width - 1, 0); Cursor.SetCursor(specialCursor, hotspot, CursorMode.Auto); }
// --- Private Static Methods --- #region bool CreateGLWindow(string title, int width, int height, int bits, bool fullscreenflag) /// <summary> /// Creates our OpenGL Window. /// </summary> /// <param name="title"> /// The title to appear at the top of the window. /// </param> /// <param name="width"> /// The width of the GL window or fullscreen mode. /// </param> /// <param name="height"> /// The height of the GL window or fullscreen mode. /// </param> /// <param name="bits"> /// The number of bits to use for color (8/16/24/32). /// </param> /// <param name="fullscreenflag"> /// Use fullscreen mode (<c>true</c>) or windowed mode (<c>false</c>). /// </param> /// <returns> /// <c>true</c> on successful window creation, otherwise <c>false</c>. /// </returns> private static bool CreateGLWindow(string title, int width, int height, int bits, bool fullscreenflag) { int pixelFormat; // Holds The Results After Searching For A Match fullscreen = fullscreenflag; // Set The Global Fullscreen Flag form = null; // Null The Form GC.Collect(); // Request A Collection // This Forces A Swap Kernel.SetProcessWorkingSetSize(Process.GetCurrentProcess().Handle, -1, -1); if (fullscreen) // Attempt Fullscreen Mode? { Gdi.DEVMODE dmScreenSettings = new Gdi.DEVMODE(); // Device Mode // Size Of The Devmode Structure dmScreenSettings.dmSize = (short)Marshal.SizeOf(dmScreenSettings); dmScreenSettings.dmPelsWidth = width; // Selected Screen Width dmScreenSettings.dmPelsHeight = height; // Selected Screen Height dmScreenSettings.dmBitsPerPel = bits; // Selected Bits Per Pixel dmScreenSettings.dmFields = Gdi.DM_BITSPERPEL | Gdi.DM_PELSWIDTH | Gdi.DM_PELSHEIGHT; // Try To Set Selected Mode And Get Results. NOTE: CDS_FULLSCREEN Gets Rid Of Start Bar. if (User.ChangeDisplaySettings(ref dmScreenSettings, User.CDS_FULLSCREEN) != User.DISP_CHANGE_SUCCESSFUL) { // If The Mode Fails, Offer Two Options. Quit Or Use Windowed Mode. if (MessageBox.Show("The Requested Fullscreen Mode Is Not Supported By\nYour Video Card. Use Windowed Mode Instead?", "NeHe GL", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.Yes) { fullscreen = false; // Windowed Mode Selected. Fullscreen = false } else { // Pop up A Message Box Lessing User Know The Program Is Closing. MessageBox.Show("Program Will Now Close.", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Stop); return(false); // Return false } } } form = new Lesson20(); // Create The Window if (fullscreen) // Are We Still In Fullscreen Mode? { form.FormBorderStyle = FormBorderStyle.None; // No Border Cursor.Hide(); // Hide Mouse Pointer } else // If Windowed { form.FormBorderStyle = FormBorderStyle.Sizable; // Sizable Cursor.Show(); // Show Mouse Pointer } form.Width = width; // Set Window Width form.Height = height; // Set Window Height form.Text = title; // Set Window Title Gdi.PIXELFORMATDESCRIPTOR pfd = new Gdi.PIXELFORMATDESCRIPTOR(); // pfd Tells Windows How We Want Things To Be pfd.nSize = (short)Marshal.SizeOf(pfd); // Size Of This Pixel Format Descriptor pfd.nVersion = 1; // Version Number pfd.dwFlags = Gdi.PFD_DRAW_TO_WINDOW | // Format Must Support Window Gdi.PFD_SUPPORT_OPENGL | // Format Must Support OpenGL Gdi.PFD_DOUBLEBUFFER; // Format Must Support Double Buffering pfd.iPixelType = (byte)Gdi.PFD_TYPE_RGBA; // Request An RGBA Format pfd.cColorBits = (byte)bits; // Select Our Color Depth pfd.cRedBits = 0; // Color Bits Ignored pfd.cRedShift = 0; pfd.cGreenBits = 0; pfd.cGreenShift = 0; pfd.cBlueBits = 0; pfd.cBlueShift = 0; pfd.cAlphaBits = 0; // No Alpha Buffer pfd.cAlphaShift = 0; // Shift Bit Ignored pfd.cAccumBits = 0; // No Accumulation Buffer pfd.cAccumRedBits = 0; // Accumulation Bits Ignored pfd.cAccumGreenBits = 0; pfd.cAccumBlueBits = 0; pfd.cAccumAlphaBits = 0; pfd.cDepthBits = 16; // 16Bit Z-Buffer (Depth Buffer) pfd.cStencilBits = 0; // No Stencil Buffer pfd.cAuxBuffers = 0; // No Auxiliary Buffer pfd.iLayerType = (byte)Gdi.PFD_MAIN_PLANE; // Main Drawing Layer pfd.bReserved = 0; // Reserved pfd.dwLayerMask = 0; // Layer Masks Ignored pfd.dwVisibleMask = 0; pfd.dwDamageMask = 0; hDC = User.GetDC(form.Handle); // Attempt To Get A Device Context if (hDC == IntPtr.Zero) // Did We Get A Device Context? { KillGLWindow(); // Reset The Display MessageBox.Show("Can't Create A GL Device Context.", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } pixelFormat = Gdi.ChoosePixelFormat(hDC, ref pfd); // Attempt To Find An Appropriate Pixel Format if (pixelFormat == 0) // Did Windows Find A Matching Pixel Format? { KillGLWindow(); // Reset The Display MessageBox.Show("Can't Find A Suitable PixelFormat.", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } if (!Gdi.SetPixelFormat(hDC, pixelFormat, ref pfd)) // Are We Able To Set The Pixel Format? { KillGLWindow(); // Reset The Display MessageBox.Show("Can't Set The PixelFormat.", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } hRC = Wgl.wglCreateContext(hDC); // Attempt To Get The Rendering Context if (hRC == IntPtr.Zero) // Are We Able To Get A Rendering Context? { KillGLWindow(); // Reset The Display MessageBox.Show("Can't Create A GL Rendering Context.", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } if (!Wgl.wglMakeCurrent(hDC, hRC)) // Try To Activate The Rendering Context { KillGLWindow(); // Reset The Display MessageBox.Show("Can't Activate The GL Rendering Context.", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } form.Show(); // Show The Window form.TopMost = true; // Topmost Window form.Focus(); // Focus The Window if (fullscreen) // This Shouldn't Be Necessary, But Is { Cursor.Hide(); } ReSizeGLScene(width, height); // Set Up Our Perspective GL Screen if (!InitGL()) // Initialize Our Newly Created GL Window { KillGLWindow(); // Reset The Display MessageBox.Show("Initialization Failed.", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } return(true); // Success }
public override string CheckCursor(Cursor cursor) => $"{Check()}-{ToCursor( cursor )}";
// Use this for initialization void Start() { Cursor.SetCursor(myszka, v, cursor); }
public override string RadioCursor(Cursor cursor) => $"{( UseCustomInputStyles ? "custom-control-input" : "form-check-input" )}-{ToCursor( cursor )}";
public void SetEnterCursor() { Cursor.SetCursor(cursors[5], new Vector2(), CursorMode.ForceSoftware); }
protected virtual void UICursor(Cursor cursor) { this.Cursor = cursor; }
// FixedUpdate is called before any Update public void Update() { // if we are in capture we freeze the cursor plane if (Scene.InCapture == false) { Vector3 camPos = camera.gameObject.transform.position; Vector3 forward = camera.gameObject.transform.forward; // orient Y-up plane so that it is in front of eye, perp to camera direction xformObject.transform.position = camPos + 10 * forward; xformObject.transform.LookAt(camera.gameObject.transform); xformObject.transform.RotateAround(xformObject.transform.position, xformObject.transform.right, 90); // that plane is the plane the mouse cursor moves on this.vCursorPlaneOrigin = xformObject.transform.position; this.vCursorPlaneRight = xformObject.transform.right; this.vCursorPlaneForward = xformObject.transform.forward; this.vRaySourcePosition = camera.transform.position; } Vector3 curPos = new Vector3(Input.GetAxis("Mouse X"), Input.GetAxis("Mouse Y"), 0); dx -= 0.3f * curPos.x; dy -= 0.3f * curPos.y; vPlaneCursorPos = vCursorPlaneOrigin + dx * vCursorPlaneRight + dy * vCursorPlaneForward; vSceneCursorPos = vPlaneCursorPos; bool bHit = false; if (Scene != null) { Ray r = new Ray(camera.transform.position, (vPlaneCursorPos - camera.transform.position).normalized); AnyRayHit hit = null; if (Scene.FindAnyRayIntersection(r, out hit)) { vSceneCursorPos = hit.hitPos; bHit = true; } else { GameObjectRayHit ghit = null; if (Scene.GetScene().FindWorldBoundsHit(r, out ghit)) { vSceneCursorPos = ghit.hitPos; } } } this.CurrentCursorPosWorld = vPlaneCursorPos; this.CurrentCursorRaySourceWorld = this.vRaySourcePosition; Cursor.transform.position = vSceneCursorPos; if (Scene.InCapture) { Cursor.GetComponent <MeshRenderer> ().material = CursorCapturingMaterial; } else if (bHit) { Cursor.GetComponent <MeshRenderer> ().material = CursorHitMaterial; } else { Cursor.GetComponent <MeshRenderer> ().material = CursorDefaultMaterial; } Cursor.layer = (bHit || Scene.InCapture) ? LayerMask.NameToLayer(SceneGraphConfig.WidgetOverlayLayerName) : 0; // maintain a consistent visual size for 3D cursor sphere float fScaling = MathUtil.GetVRRadiusForVisualAngle(vSceneCursorPos, camera.transform.position, CursorVisualAngleInDegrees); Cursor.transform.localScale = new Vector3(fScaling, fScaling, fScaling); }
public void SetCursor(int n = 0) { Cursor.SetCursor(cursors[n], new Vector2(16f, 16f), CursorMode.ForceSoftware); }
private void LoadContent(ContentManager Content) { cursor = new Cursor(Content.Load <Texture2D>("small crosshair")); gameobject = new GameObject(Content.Load <Texture2D>("GameResources/Player_temp"), objectPosition); }
public void SetMenuCursor() { Cursor.SetCursor(cursors[4], new Vector2(), CursorMode.ForceSoftware); }
void SetCursor(Texture2D texture) { Cursor.SetCursor(texture, _hotspot, CursorMode.Auto); }
private void timer1_Tick(object sender, EventArgs e) { racket.Left = Cursor.Position.X - (racket.Width / 4); ball.Left += Speed_left; ball.Top += Speed_top; if (label2.Text == "5") { Speed_left = 5; Speed_top = 5; spd = 5; } if (label2.Text == "10") { Speed_left = 6; Speed_top = 6; spd = 6; } if (label2.Text == "20") { Speed_left = 7; Speed_top = 7; spd = 7; } if (label2.Text == "40") { Speed_left = 8; Speed_top = 8; spd = 8; } if (label2.Text == "60") { Speed_left = 9; Speed_top = 9; spd = 9; } if (label2.Text == "80") { Speed_left = 10; Speed_top = 10; spd = 10; } if (label2.Text == "120") { Speed_left = 11; Speed_top = 11; spd = 11; } if (label2.Text == "170") { Speed_left = 12; Speed_top = 12; spd = 12; } if (label2.Text == "220") { Speed_left = 13; Speed_top = 13; spd = 13; } if (label2.Text == "300") { Speed_left = 15; Speed_top = 15; spd = 15; } if (label2.Text == "400") { Speed_left = 17; Speed_top = 17; spd = 17; } if (label2.Text == "500") { Speed_left = 19; Speed_top = 19; spd = 19; } if (label2.Text == "600") { Speed_left = 22; Speed_top = 22; spd = 22; } if (ball.Bottom >= racket.Top && ball.Bottom <= racket.Bottom && ball.Left >= racket.Left && ball.Right <= racket.Right) { Speed_top += 0; Speed_left += 0; Speed_top = -Speed_top; point += 1; ball.Location = new Point(297, 30); label2.Text = point.ToString(); } if (ball.Left <= playground.Left) { Speed_left = -Speed_left; } if (ball.Right >= playground.Right) { Speed_left = -Speed_left; } if (ball.Top <= playground.Top) { int rInt = r.Next(0, 500); //for ints int range = 500; int x = r.Next(range); ball.Left = x; Speed_top = -Speed_top; } if (ball.Bottom >= playground.Bottom) { timer1.Enabled = false; } if (timer1.Enabled == false) { Cursor.Show(); axWindowsMediaPlayer1.settings.volume = 100; axWindowsMediaPlayer1.Ctlcontrols.play(); DialogResult GameOver = MessageBox.Show("Oh! Earth has been destroyed. Would you like to try again?", "Game Over", MessageBoxButtons.YesNo); if (GameOver == DialogResult.Yes) { Application.Restart(); } else if (GameOver == DialogResult.No) { Application.Exit(); } } }
/// <summary> /// 保存 /// </summary> /// <returns>保存成功</returns> private bool SaveEntity(bool close) { bool returnValue = false; // 设置鼠标繁忙状态,并保留原先的状态 Cursor holdCursor = this.Cursor; this.Cursor = Cursors.WaitCursor; // 转换数据 BaseOrganizeEntity entity = this.GetEntity(); string statusCode = string.Empty; string statusMessage = string.Empty; this.EntityId = DotNetService.Instance.OrganizeService.Add(UserInfo, entity, out statusCode, out statusMessage); this.FullName = this.txtFullName.Text; if (statusCode == StatusCode.OKAdd.ToString()) { if (this.Owner != null && !close) { if (this.Owner is FrmOrganizeAdmin) { ((FrmOrganizeAdmin)this.Owner).FormOnLoad(); } } if (BaseSystemInfo.ShowInformation) { // 添加成功,进行提示 MessageBox.Show(statusMessage, AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Information); } returnValue = true; if (close) { this.DialogResult = DialogResult.OK; } if (OnAdded != null) { this.OnAdded(this.ParentId, this.FullName, this.EntityId); } } else { MessageBox.Show(statusMessage, AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Information); // 是否名称重复了,提高友善性 if (statusCode == StatusCode.ErrorNameExist.ToString()) { this.txtFullName.SelectAll(); this.txtFullName.Focus(); } else { // 是否编号重复了,提高友善性 if (statusCode == StatusCode.ErrorCodeExist.ToString()) { this.txtCode.SelectAll(); this.txtCode.Focus(); } } } // 设置鼠标默认状态,原来的光标状态 this.Cursor = holdCursor; return(returnValue); }
private void FixedUpdate() { RaycastHit[] hits; Ray ray = mainCamera.ScreenPointToRay(Input.mousePosition); bool tagDetected = false; hits = Physics.RaycastAll(ray, 100); if (hits.Length > 0) { int currentPriority = int.MaxValue; foreach (RaycastHit hit in hits) { int priority = System.Array.IndexOf(interactionTagsInPriorityOrder, hit.transform.tag); if (priority >= 0 && priority < currentPriority) { currentPriority = priority; tagDetected = true; } } if (tagDetected) { string tagPrioritary = null; for (int i = 0; i < hits.Length; i++) { if (hits[i].transform.tag == interactionTagsInPriorityOrder[currentPriority]) { Transform objectHit = hits[i].transform; if (!justChangeCursor) { crosshairInstance.transform.position = hits[i].point; } tagPrioritary = hits[i].transform.tag; if (Sinput.GetButtonDown(leftMouseInput)) { crowdSystem.AssignTargetToRandomElement(objectHit); onElementClicked?.Invoke(); } break; } } //Debug.Log(tagPrioritary); if (!hovering && tagPrioritary != "RaycastMinion") { onElementHover?.Invoke(); hovering = true; //Debug.Log("HOVER"); if (!justChangeCursor) { crosshairInstance.SetActive(true); } else { Cursor.SetCursor(aimCursor, new Vector2(aimCursor.width / 2, aimCursor.height / 2), CursorMode.Auto); } } } else { if (hovering) { onElementUnhover.Invoke(); //Debug.Log("UNHOVER"); hovering = false; if (!justChangeCursor) { crosshairInstance.SetActive(false); } else { Cursor.SetCursor(defaultCursor, Vector2.zero, CursorMode.Auto); } } } } }
public void GameClosed(object sender, EventArgs e) { Visible = true; Cursor.Show(); }
protected override UIElement InitializeUI(Loader loader, DrawingContext context, int screenWidth, int screenHeight) { Cursor.Hide(); context.NewNinePartsBitmap("Panel", loader.LoadBitmapFromFile(@"Resources\UI\panel.png"), 30, 98, 30, 98); context.NewBitmap("Heart", loader.LoadBitmapFromFile(@"Resources\UI\heart.png")); context.NewBitmap("ArrowStandart", loader.LoadBitmapFromFile(@"Resources\UI\arrowStandart.png")); context.NewBitmap("ArrowPoison", loader.LoadBitmapFromFile(@"Resources\UI\arrowPoison.png")); context.NewBitmap("WolfIcon", loader.LoadBitmapFromFile(@"Resources\UI\wolfIcon.png")); var header1 = new UISequentialContainer(new Vector2(0.0f, 0.0f), new Vector2(screenWidth, 100.0f), false); // здоровье var counter = new UISequentialContainer(Vector2.Zero, new Vector2(300.0f, 100.0f), false) { Background = new NinePartsTextureBackground("Panel"), MainAxis = UISequentialContainer.Alignment.Center, CrossAxis = UISequentialContainer.Alignment.Center }; var image = new UIPanel(Vector2.Zero, new Vector2(80.0f, 80.0f)) { Background = new TextureBackground("Heart") }; context.NewSolidBrush("HealthBarBack", new RawColor4(144.0f / 255.0f, 31.0f / 255.0f, 61.0f / 255.0f, 1.0f)); context.NewSolidBrush("HealthBar", new RawColor4(187.0f / 255.0f, 48.0f / 255.0f, 48.0f / 255.0f, 1.0f)); _healthProgressBar = new UIProgressBar(Vector2.Zero, new Vector2(180.0f, 20.0f), "HealthBar") { Background = new ColorBackground("HealthBarBack"), MaxValue = 100.0f, Value = 50.0f }; counter.Add(image); counter.Add(_healthProgressBar); header1.Add(new UIMarginContainer(counter, 5.0f, 0.0f)); // обычные стрелы counter = new UISequentialContainer(Vector2.Zero, new Vector2(200.0f, 100.0f), false) { Background = new NinePartsTextureBackground("Panel"), MainAxis = UISequentialContainer.Alignment.Center, CrossAxis = UISequentialContainer.Alignment.Center }; image = new UIPanel(Vector2.Zero, new Vector2(80.0f, 80.0f)) { Background = new TextureBackground("ArrowStandart") }; context.NewSolidBrush("Text", new RawColor4(1.0f, 1.0f, 1.0f, 1.0f)); context.NewTextFormat("Text", fontSize: 40.0f, textAlignment: SharpDX.DirectWrite.TextAlignment.Center); _arrowStandartText = new UIText("0", new Vector2(50.0f, 50.0f), "Text", "Text"); counter.Add(image); counter.Add(_arrowStandartText); header1.Add(new UIMarginContainer(counter, 5.0f, 0.0f)); // стрелы яда counter = new UISequentialContainer(Vector2.Zero, new Vector2(200.0f, 100.0f), false) { Background = new NinePartsTextureBackground("Panel"), MainAxis = UISequentialContainer.Alignment.Center, CrossAxis = UISequentialContainer.Alignment.Center }; image = new UIPanel(Vector2.Zero, new Vector2(80.0f, 80.0f)) { Background = new TextureBackground("ArrowPoison") }; _arrowPoisonText = new UIText("0", new Vector2(50.0f, 50.0f), "Text", "Text"); counter.Add(image); counter.Add(_arrowPoisonText); header1.Add(new UIMarginContainer(counter, 5.0f, 0.0f)); var header2 = new UISequentialContainer(new Vector2(5.0f, 110.0f), new Vector2(screenWidth, 100.0f), false); // счет врагов counter = new UISequentialContainer(Vector2.Zero, new Vector2(200.0f, 100.0f), false) { Background = new NinePartsTextureBackground("Panel"), MainAxis = UISequentialContainer.Alignment.Center, CrossAxis = UISequentialContainer.Alignment.Center }; image = new UIPanel(Vector2.Zero, new Vector2(80.0f, 80.0f)) { Background = new TextureBackground("WolfIcon") }; _wolfCounter = new UIText("0", new Vector2(100.0f, 50.0f), "Text", "Text"); counter.Add(image); counter.Add(_wolfCounter); header2.Add(counter); var ui = new UIMultiElementsContainer(Vector2.Zero, new Vector2(screenWidth, screenHeight)); ui.OnResized += () => header1.Size = ui.Size; ui.OnResized += () => header2.Size = ui.Size; ui.Add(header1); ui.Add(header2); return(ui); }