private void alignmentToolStripMenuItem_Click(object sender, EventArgs e) { behaviourChanged = true; steeringBehaviour = SB.Alignment; if (sBC != null) sBC.FirstVehicle.SteeringBehaviour = SB.Alignment; }
public SBC(Graphics g, Size ClientSize, SB steeringBehaviour, int NumberOfVehicles) { cars = new Vehicle[NumberOfVehicles]; SBs = steeringBehaviour; clientSize = ClientSize; this.g = g; InitializeCars(); }
public static string WindowText(IntPtr hwnd) { const int W_GETTEXT = 0xd; const int W_GETTEXTLENGTH = 0xe; var SB = new System.Text.StringBuilder(); var length = SendMessage(hwnd, W_GETTEXTLENGTH, 0, 0); if (length > 0) { SB = new System.Text.StringBuilder(length + 1); SendMessage(hwnd, W_GETTEXT, SB.Capacity, SB); } return(SB.ToString()); }
//--------------------------------------------------------------------- public override Task OnDeactivateAsync() { if (Random != null) { Random = null; } if (SB != null) { SB.Clear(); SB = null; } return(base.OnDeactivateAsync()); }
private void GenProc(ShaderProgram Program, ProcInfo Proc) { SB.AppendLine($"void {Proc.Name}() {{"); Ident = "\t"; GenProcBody(Program, Proc); if (string.Compare(Proc.Name, "main", true) == 0) { SB.AppendLine($"{Ident}gl_Position = {OutputNames[0]};"); } SB.AppendLine("}"); }
public override void Draw(GameTime gameTime) { G.Clear(Color.Black); if (ShouldRebuild) { Rebuild(fIn, fOut); } if (rtHeight != null) { SB.Begin(); SB.Draw(rtHeight, G.Viewport.TitleSafeArea, Color.White); SB.End(); } }
public void useSB() { if (SB > 0) { player.addSpeedEffect(); PlayerPrefs.SetInt("SB", PlayerPrefs.GetInt("SB") - 1); SB -= 1; } textSB.text = SB.ToString(); if (SB == 0) { imageSB.sprite = eSB; } }
public UserView() { InitializeComponent(); dG = new DG(dgUser, snack, snackMessage); dataBaseQuery = new DataBaseQuery(snack, snackMessage); myListBox = new MyListBox(lbRole, snack, snackMessage); comboBoxAddRole = new CB(cbRole, snack, snackMessage); comboBoxEditRole = new CB(cbEditRole, snack, snackMessage); sB = new SB(snack, snackMessage); }
//--------------------------------------------------------------------- public override Task OnDeactivateAsync() { if (MapCache != null) { MapCache.Clear(); MapCache = null; } if (SB != null) { SB.Clear(); SB = null; } return(base.OnDeactivateAsync()); }
public void Stop(int L) { if (SB != null) { if (SB.GetCurrentState() != ClockState.Stopped) { SB.Stop(); if (StopFunctionId != 0) { LuaManager.GetLuaManager(L).ExecuteCallBackFunctionWithParam(StopFunctionId, this);// //StopFunctionId = 0; } } } Dispose(); }
//--------------------------------------------------------------------- public override Task OnDeactivateAsync() { if (SB != null) { SB.Clear(); SB = null; } if (ListCountTask != null) { ListCountTask.Clear(); ListCountTask = null; } return(base.OnDeactivateAsync()); }
public Vehicle(Vehicle target, SB sb) { this.sb = sb; mass = World.Instance.random.Next(20, 80); max_force = 20; max_speed = 10; velocity = new Vector2D(5, 5); acceleration = Vector2D.None(); heading = Vector2D.Normalize(velocity); CurrentPosition = new Vector2D(World.Instance.random.Next(World.Instance.ClientSize.Width), World.Instance.random.Next(World.Instance.ClientSize.Height)); steerForce = Vector2D.None(); brushVehicle = Brushes.Red; brushTarget = Brushes.Blue; whitePen = Pens.White; this.target = target; }
private void AddRecipe(IRecipe recipe) { string id = recipe.ID.ToLower(); string recipeFolder = Path.Combine(SiteFolder, "source"); string codeFilePath = Path.Combine(recipeFolder, id + ExtCode); string imageUrl = id + ExtImage; string[] raw = File.ReadAllLines(codeFilePath); string code = string.Join("\n", raw.Skip(2)); AddHTML($"<h2><a href='#{id}' name='{id}' style='color: black;'>{recipe.Title}</a></h2>"); AddHTML(recipe.Description); AddCode(code); SB.AppendLine($"<div class='center'><img src='source/{imageUrl}' /></div>"); }
static unsafe void FixedSizeBuffers_Test() { var a1 = new SB() { arr = new int[5] }; var a2 = new FSB(); Print.Address((long)&a2); Print.Address((long)a2.arr); Print.Address((long)&a2.arr);//数组指针变量的地址 Print.Address((long)&a2.x); //Console.WriteLine(sizeof(SB));//SB作为托管类型不能计算大小 Console.WriteLine(sizeof(FSB)); }
protected override void OnCompile() { int val = 0; int num2 = 0; int num3 = 0; if (this.LineIndex > 0) { val = 1; } if (this.FillIndex0 > 0) { num2 = 1; } if (this.FillIndex1 > 0) { num3 = 1; } this.Append(new UB(1, 0)); this.Append(new UB(1, 0)); this.Append(new UB(1, val)); this.Append(new UB(1, num2)); this.Append(new UB(1, num3)); this.Append(new UB(1, Convert.ToInt32(this.MoveTo))); if (this.MoveTo) { BitCounter.Init(); BitCounter.Push(SB.NumBits(this.MoveX)); BitCounter.Push(SB.NumBits(this.MoveY)); int maxim = BitCounter.Maxim; this.Append(new UB(5, maxim)); this.Append(new SB(maxim, this.MoveX)); this.Append(new SB(maxim, this.MoveY)); } if (num2 == 1) { this.Append(new UB(this.Parent.NumFillBits, this.FillIndex0)); } if (num3 == 1) { this.Append(new UB(this.Parent.NumFillBits, this.FillIndex1)); } if (val == 1) { this.Append(new UB(this.Parent.NumLineBits, this.LineIndex)); } }
private void DrawLightning(LightningData data, float w) { SB.Begin(SpriteSortMode.Immediate, BlendState.Additive, SamplerState.LinearClamp, DepthStencilState.None, RasterizerState.CullNone); for (int i = 0; i < data.Lines.Count;) { Vector2 s = data.Lines[i++]; Vector2 e = data.Lines[i++]; Vector2 d = e - s; float dist = d.Length(); d /= dist; float r = (float)Math.Atan2(d.Y, d.X); SB.Draw(tLightning, s, rsLEndL, data.Color, r, originLEndL, new Vector2(w, w) * scaleLEnd, SpriteEffects.None, 0); SB.Draw(tLightning, s, rsLMid, data.Color, r, originLMid, new Vector2(dist, w) * scaleLMid, SpriteEffects.None, 0); SB.Draw(tLightning, e, rsLEndR, data.Color, r, originLEndR, new Vector2(w, w) * scaleLEnd, SpriteEffects.None, 0); } SB.End(); }
void Update() { velocity += SB.Arrive(this, target, 3); velocity += SB.Flee(this, target, 1); velocity += SB.Separate(this, GameManager.agents, 2f); transform.position += velocity * Time.deltaTime; if (transform.position.y < -2 || transform.position.y > 2) { velocity.y *= 0; } if (transform.position.x < -2 || transform.position.x > 2) { velocity.x *= 0; } }
public SupplierView() { InitializeComponent(); dG = new DG(dgSupplier, snack, snackMessage); sB = new SB(snack, snackMessage); dataBaseQuery = new DataBaseQuery(snack, snackMessage); this.Loaded += delegate { dG.Loader("SELECT * FROM dbo.[Supplier]"); }; snackMessage.ActionClick += delegate { dG.CloseSnackbar(); }; }
protected override void OnCompile() { this.Append(new UB(1, 1)); this.Append(new UB(1, 0)); BitCounter.Init(); BitCounter.Push(SB.NumBits(this.posX)); BitCounter.Push(SB.NumBits(this.posY)); BitCounter.Push(SB.NumBits(this.anchX)); BitCounter.Push(SB.NumBits(this.anchY)); int maxim = BitCounter.Maxim; this.Append(new UB(4, maxim - 2)); this.Append(new SB(maxim, this.posX)); this.Append(new SB(maxim, this.posY)); this.Append(new SB(maxim, this.anchX)); this.Append(new SB(maxim, this.anchY)); }
public RecipientView() { InitializeComponent(); dG = new DG(dgRecipient, snack, snackMessage); sB = new SB(snack, snackMessage); dataBaseQuery = new DataBaseQuery(snack, snackMessage); this.Loaded += delegate { dG.Loader("SELECT Id, FirstName + N' ' + LastName as Recipient," + " Address, PhoneNumber, Email FROM dbo.Recipient"); }; snackMessage.ActionClick += delegate { dG.CloseSnackbar(); }; }
//--------------------------------------------------------------------- // add数据到Map中 async Task <string> IGrainDCache.addToMap(string map_name, string ticket, string key, byte[] value) { if (string.IsNullOrEmpty(ticket)) { int map_index = Random.Next(1, DCacheMapCount + 1); SB.Clear(); SB.Append(map_name); SB.Append("_"); SB.Append(map_index); ticket = SB.ToString(); } var grain_map = this.GrainFactory.GetGrain <IGrainDCacheMap>(ticket); var tick = await grain_map.addToMap(key, value); return(tick); }
//=========================================================// public CustomObject(Graphics graphicsObject, Size clientSize, SB SteeringBehavior, int vehicleNumber) { //=========================================================// //general initialization _vehicleNo = vehicleNumber; _random = new Random(GetSeed()); _xDirectionPositive = Convert.ToBoolean(_random.Next(0, 2)); _yDirectionPositive = Convert.ToBoolean(_random.Next(0, 2)); _graphic = graphicsObject; _clientSize = clientSize; _mass = _random.Next(20, 80); max_force = 20; max_speed = 10; velocity = new Vector2(_random.Next(0, 10), _random.Next(0, 10)); acceleration = new Vector2(0, 0); heading = Vector2.Normalize(velocity); _currentCoordinates = new Point(_random.Next(0, _clientSize.Width), _random.Next(0, _clientSize.Height)); steerForce = new Vector2(0); //targetPosition = SBC.targetPosition; brushBack = Brushes.Black; brushWhite = Brushes.White; brushCar = Brushes.Blue; whitePen = Pens.White; targetChanged = false; SB = SteeringBehavior; //=========================================================// //=========================================================// //wander specific variables wanderTarget = new Vector2(0); //=========================================================// //=========================================================// //=========================================================// //pathfollowing s maxSpecialPathPoints = 40; maxPathPoints = 10; currentPathPoint = 0; specialPathPoints = new Point[maxSpecialPathPoints]; pathPoints = new Point[maxPathPoints]; sP1 = new Point[22]; sP2 = new Point[18]; NewPosition(); }
//--------------------------------------------------------------------- // 从MasteSlave中获取数据 async Task <byte[]> IGrainDCache.getFromMasteSlave(string maste_name, string key) { int slave_count = (int)Math.Pow(DCacheMasterSlaveCount, DCacheMasterSlaveMaxDeep - 1); int slave_index = Random.Next(1, slave_count + 1); SB.Clear(); SB.Append(maste_name); SB.Append("_"); SB.Append(SLAVE_MAP_NAME); SB.Append("_"); SB.Append(DCacheMasterSlaveMaxDeep); SB.Append("_"); SB.Append(slave_index); var grain_slave = this.GrainFactory.GetGrain <IGrainDCacheSlave>(SB.ToString()); var result = await grain_slave.getFromSlave(key); return(result); }
public void setSuccess() { if (!explode.activeSelf && AS.switchCondition && BS.switchCondition && CS.switchCondition && DS.switchCondition) { Success.SetActive(true); Banner.SetActive(false); A.SetActive(false); B.SetActive(false); C.SetActive(false); D.SetActive(false); SA.SetActive(false); SB.SetActive(false); SC.SetActive(false); SD.SetActive(false); light.color = Color.green; Update(); } }
public static GpioSequence ShiftOutHardWare(Nusbio nusbio, int dataPin , int clockPin, int val, GpioSequence gs = null, bool send = true, SB bitOrder = SB.MSBFIRST) { if(gs == null) gs = new GpioSequence(nusbio.GetGpioMask()); for (var i = 0; i < 8; i++) { int a = 0; if (bitOrder == SB.LSBFIRST) a = (val & (1 << i)); else a = (val & (1 << (7 - i))); gs.ClockBit(nusbio[clockPin], nusbio[dataPin], a > 0); } if(send) nusbio.SetGpioMask(gs.ToArray()); return gs; }
public static string GetShortPathName(string strLongPath) { StringBuilder SB = new StringBuilder(260); uint uiResult = GetShortPathName(strLongPath, SB, SB.Capacity); if (uiResult > SB.Capacity) { SB = new StringBuilder((int)uiResult + 1); uiResult = GetShortPathName(strLongPath, SB, SB.Capacity); } if (uiResult == 0) { throw new ArgumentException("Unable to get the short path name for: " + strLongPath); } return(SB.ToString()); }
public static void ShiftOutDataClockOptimized(IDigitalWriteRead dwr, int dataPin , int clockPin, int val, SB bitOrder = SB.MSBFIRST) { int i; for (i = 0; i < 8; i++) { if (bitOrder == SB.LSBFIRST) { var a = (val & (1 << i)); dwr.DigitalWrite(dataPin, Nusbio.ConvertToPinState(a)); } else { var b = (val & (1 << (7 - i))); dwr.DigitalWrite(dataPin, Nusbio.ConvertToPinState(b)); } ClockIt(dwr, clockPin); } }
protected void GridResult_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { if (e.Row.Cells[3].Text == "PartI") { if (e.Row.Cells[5].Text == "Pass") { PI += 1; } e.Row.BackColor = System.Drawing.Color.AntiqueWhite; } else if (e.Row.Cells[3].Text == "PartII") { if (e.Row.Cells[5].Text == "Pass") { PII += 1; } e.Row.BackColor = System.Drawing.Color.Aquamarine; } else if (e.Row.Cells[3].Text == "SectionA") { if (e.Row.Cells[5].Text == "Pass") { SA += 1; } e.Row.BackColor = System.Drawing.Color.AliceBlue; } else if (e.Row.Cells[3].Text == "SectionB") { if (e.Row.Cells[5].Text == "Pass") { SB += 1; } e.Row.BackColor = System.Drawing.Color.LightCoral; } } lblPartICount.Text = PI.ToString(); lblPartIICount.Text = PII.ToString(); lblSectionACount.Text = SA.ToString(); lblSectionBCount.Text = SB.ToString(); }
public override void Update(float timeElapsed) { SteeringForce = SteeringForce.Zero(); try { foreach (SteeringBehaviour SB in SteeringBehaviors) { SteeringForce += SB.Calculate(); } } catch (Exception e) { Console.WriteLine("MovingEntity: " + e.Message); } if (SteeringForce.isZero()) { Velocity = Velocity.Zero(); } SteeringForce = Vector2D.truncate(SteeringForce, Max_Force); SteeringForce = SteeringForce / Mass; SteeringForce = SteeringForce.Multiply(timeElapsed); //Update velocity and truncate Velocity = Vector2D.truncate(Velocity + SteeringForce, arriveSpeed); Pos = Pos + Velocity; //Update heading if (Velocity.LengthSquared() > 0.00000001) { Heading = Velocity.Normalize(); Side = Heading.PerpRightHand(); } //treat the screen as a toroid Vector2D.WrapAround(this.Pos, MyWorld.Width, MyWorld.Height); }
// keep incase we dont need to traverse the visual tree recursively (itll output last first so be aware) //static private IEnumerable<DependencyObject> FindInputElements(DependencyObject parent) //{ // if (parent == null) // yield break; // for (int i = 0; i < VisualTreeHelper.GetChildrenCount(parent); i++) // { // DependencyObject o = VisualTreeHelper.GetChild(parent, i); // foreach (DependencyObject obj in FindInputElements(o)) // yield return (UIElement)obj; // } // yield return parent; //} public static void PerformPageEntranceAnimation(Page page) { //traverse the visual tree of a page and perform the fade in and translate in on each frameworkitem // general idea from EntranceThemeTransition and rebuilt as a behavior here // https://jeremiahmorrill.wordpress.com/2014/04/02/entrancethemetransitionbehavior-behavior-for-wpf/ List <Storyboard> StoryBoardCollection = new List <Storyboard>(); List <UIElement> AnimatableChildren = new List <UIElement>(); double StaggerDelay = 0.0; double TotalStagger = (((Windows.UI.Xaml.Controls.Panel)page.Content).Children.Count * 100d) + 500d; double distanceToTranslate; // Traverses the first content area on the page in linear order to show everything foreach (UIElement child in ((Windows.UI.Xaml.Controls.Panel)page.Content).Children) { if (null != child && child != page && (child is IAnimate || child is Canvas || child is Grid))// handle special case for canvas// dont do the page either { ParseAnimatableChildren(child, ref AnimatableChildren); } } TotalStagger = AnimatableChildren.Count * 100d + 500d; foreach (UIElement OrderedChild in AnimatableChildren) { Storyboard storyboard = null; IAnimate AnimatedOrderedChild = (IAnimate)OrderedChild; distanceToTranslate = 100 * (AnimatedOrderedChild.Direction() != AnimationDirection.Left ? 1 : -1); storyboard = CreateEasingAnimation(OrderedChild, "Opacity", 0.0, 0.0, 1.0, TotalStagger, StaggerDelay, false, false, new RepeatBehavior(1d)); StoryBoardCollection.Add(storyboard); if (AnimatedOrderedChild.HasPageEntranceTranslation()) { storyboard = CreateTranslateAnimation(OrderedChild, "X", distanceToTranslate, distanceToTranslate, 0.0, TotalStagger, StaggerDelay, false, false, new RepeatBehavior(1d)); StoryBoardCollection.Add(storyboard); } StaggerDelay += 100; } foreach (Storyboard SB in StoryBoardCollection) { SB.Begin(); } }
public OrderView() { InitializeComponent(); dG = new DG(dgOrder, snack, snackMessage); sB = new SB(snack, snackMessage); lb = new MyListBox(lbSortingCenter, snack, snackMessage); comboBoxEmployee = new CB(cbEmployee, snack, snackMessage); comboBoxClient = new CB(cbClient, snack, snackMessage); comboBoxRecipient = new CB(cbRecipient, snack, snackMessage); comboBoxSupplier = new CB(cbSupplier, snack, snackMessage); comboBoxArticle = new CB(cbArticle, snack, snackMessage); comboBoxSortingCenter = new CB(cbSortingCenter, snack, snackMessage); comboBoxNameOrderTiming = new CB(cbNameOrderTiming, snack, snackMessage); comboBoxEditEmployee = new CB(cbEditEmployee, snack, snackMessage); comboBoxEditClient = new CB(cbEditClient, snack, snackMessage); comboBoxEditRecipient = new CB(cbEditRecipient, snack, snackMessage); comboBoxEditSupplier = new CB(cbEditSupplier, snack, snackMessage); comboBoxEditArticle = new CB(cbEditArticle, snack, snackMessage); comboBoxEditSortingCenter = new CB(cbEditSortingCenter, snack, snackMessage); comboBoxEditNameOrderTiming = new CB(cbEditNameOrderTiming, snack, snackMessage); dataBaseQuery = new DataBaseQuery(snack, snackMessage); snackMessage.ActionClick += delegate { dG.CloseSnackbar(); }; }
//--------------------------------------------------------------------- // add数据到MasteSlave中 Task IGrainDCacheMaster.addToMasteSlave(string key, byte[] value) { MapCache[key] = value; for (int i = 1; i <= SlaveCount; i++) { SB.Clear(); SB.Append(MasterName); SB.Append("_"); SB.Append(GrainDCache.SLAVE_MAP_NAME); SB.Append("_"); SB.Append(GrainDCache.SLAVE_ROOT_DEEP); SB.Append("_"); SB.Append(i); var grain_slave = this.GrainFactory.GetGrain <IGrainDCacheSlave>(SB.ToString()); grain_slave.addToSlave(key, value); } return(TaskDone.Done); }
public void correlateMapToImage(string mapPath, string assetName, int startTime, int iterations) { // Will correspond a collision map to an asset. // Iterations are series of measures. // Collision map sprite is going to move around. // Initialization clearMap(); addRegion(mapPath, startTime); var mapSprite = SB.Sprite(assetName, SB.Foreground, SB.Centre); mapSprite.move(0, 0, 320, 330, 320, 330); mapSprite.fade(0, 0, 0, 0, 0); mapSprite.fade(0, startTime, startTime, 1, 1); // Movement: // Movement is randomized // --> During each iteration... // --> The sprite spawns at location x (only horizontal shift) // --> After a measure, the location... // ----> will shift (if mapSprite.x is past 400, it moves left, otherwise it moves right) // ----> this distance is randomized, and then an addshift node is also considered with // ----> with the same distance moved. // ----> mapSprite.x moves from cur -> [random], addShift x |(cur - [random])| * (-1) or (1) if L/R for (int i = 0; i < iterations; i++) { int distTravel = rng.Next(-400, 400); // Used for [random] if (mapSprite.X > (int)(BeatmapConstants.SCREEN_WIDTH) / 2) { distTravel *= -1; // It would move left instead } // Moving right or left? Collision map needs to shift corresponding to that mapSprite.move(startTime, startTime, mapSprite.X + distTravel, mapSprite.Y, mapSprite.X + distTravel, mapSprite.Y); //addShift(50000, 5000, 5000, -300, true); addShift(startTime, 16, distTravel, 0, false); // The collision map isn't updated enough :( WHATEVER startTime += (int)BeatmapConstants.BEAT_QUARTER * 4; } mapSprite.fade(0, startTime, startTime, 0, 0); }
protected void Button1_Click(object sender, EventArgs e) { SB db = new SB(); string strusername = this.textusername.Text.Trim(); //获取输入的用户名和密码 string strpassword = this.textpassword.Text.Trim(); SqlDataReader dr = db.reDr("select * from Test2 where Topic='" + strusername + "'and Sender='" + strpassword + "'"); //在数据库中select dr.Read(); //dr对象读取数据集 if (dr.HasRows) { Session["Topic"] = dr.GetValue(1); Session["Sender"] = dr.GetValue(2); Response.Write("<script>alert('登录成功!')</script>"); } else { //Response.Write("<script>alert('登录失败!');location='Login.aspx'</script>"); } dr.Close(); }
public void Ejercicio2_4() { //Sentence: //Escribir un programa en C# que calcule sueldo bruto (SB), sueldo neto (SN) y descuento (DD). Las //tarifas por horas(HT) y horas trabajadas(TH) se ingresan por teclado. El descuento aplicar a todos los //sueldos calculados es del 10 %.Imprimir sueldo bruto, descuento y sueldo neto. double SB, SN, DD, HT, TH; Console.WriteLine("===============>> PROGRAMA QUE CALCULA SUELDO <<==============="); Console.WriteLine("Ingrese costo de tarifa por hora: "); HT = Convert.ToDouble(Console.ReadLine()); Console.WriteLine("Ingrese total de horas trabajadas: "); TH = Convert.ToDouble(Console.ReadLine()); SB = HT * TH; Console.WriteLine("El sueldo bruto es: ${0}", SB.ToString("N")); DD = SB * 0.10; Console.WriteLine("El descuento es: ${0}", DD.ToString("N")); SN = SB - DD; Console.WriteLine("El sueldo neto es: ${0}", SN.ToString("N")); }
public static extern int GetScrollPos(IntPtr hWnd, SB nBar);
/// <summary> /// Coder-friendly version of SetScrollInfo. /// </summary> /// <param name="hwnd">The window handle of the window to set scroll information for.</param> /// <param name="fnBar">Which scroll bar to set information for.</param> /// <param name="lpsi">The information to set.</param> /// <param name="fRedraw">Whether to repaint the window after changing the information.</param> private static void SetScrollPos(IntPtr hwnd, SB fnBar, SCROLLINFO lpsi, bool fRedraw) { int iSize = System.Runtime.InteropServices.Marshal.SizeOf(typeof(SCROLLINFO)); IntPtr buffer = System.Runtime.InteropServices.Marshal.AllocHGlobal(iSize); System.Runtime.InteropServices.Marshal.StructureToPtr( lpsi, buffer, false); SetScrollInfo(hwnd, fnBar, buffer, 0); System.Runtime.InteropServices.Marshal.DestroyStructure(buffer, typeof(SCROLLINFO)); }
private static extern int GetScrollInfo(IntPtr hwnd, SB fnBar, ref SCROLLINFO lpsi);
/// <summary> /// Coder-friendly version of GetScrollInfo. /// </summary> /// <param name="hwnd">The window handle of the window to get scroll information for.</param> /// <param name="axis">Which axis to get information for.</param> /// <returns>A SCROLLINFO structure containing the requested information.</returns> private static SCROLLINFO? GetScrollInfo(IntPtr hwnd, SB fnBar) { SCROLLINFO hScrollInfo = new SCROLLINFO(); hScrollInfo.cbSize = 28; hScrollInfo.fMask = SIF.POS | SIF.RANGE | SIF.PAGE; int result = GetScrollInfo(hwnd, fnBar, ref hScrollInfo); if (result == 0) { int error = System.Runtime.InteropServices.Marshal.GetLastWin32Error(); if (error == 1447) { return null; } else { throw new ApplicationException("Call to GetScrollInfo failed with error code " + error); } } return hScrollInfo; }
private static List<SB> NumberingSB(int RbNum, int SizeOfSb) { List<SB> list = new List<SB>(); if (SizeOfSb != 0) { SB sb; int rbnumber = RbNum % SizeOfSb; int num2 = RbNum / SizeOfSb; byte index = 0; index = 0; while (index < num2) { sb = new SB(index, SizeOfSb, SizeOfSb); list.Add(sb); index = (byte) (index + 1); } if (rbnumber > 0) { sb = new SB(index, SizeOfSb, rbnumber); list.Add(sb); } } return list; }
//the constructor public Vehicle(Graphics GraphicsObject, Size ClientSize, SB SteeringBehavior, int VehicleNumber) { //=========================================================// //general initialization g = GraphicsObject; clientSize = ClientSize; random = new Random(); mass = random.Next(20, 80); max_force = 20; vehicleNo = VehicleNumber; max_speed = 10; if (mainForm.identicalVehicles) { velocity = new Vector2(5, 5); } else { velocity = new Vector2(random.Next(0, 10), random.Next(0, 10)); } acceleration = new Vector2(0, 0); heading = Vector2.Normalize(velocity); currentPosition = new Vector2(random.Next(clientSize.Width), random.Next(clientSize.Height)); steerForce = new Vector2(0); targetPosition = SBC.targetPosition; brushBack = Brushes.Black; brushWhite = Brushes.White; brushCar = Brushes.Blue; whitePen = Pens.White; targetChanged = false; SB = SteeringBehavior; //=========================================================// //=========================================================// //wander specific variables wanderTarget = new Vector2(0); //=========================================================// //=========================================================// //=========================================================// //pathfollowing s maxSpecialPathPoints = 40; maxPathPoints = 10; currentPathPoint = 0; specialPathPoints = new Point[maxSpecialPathPoints]; pathPoints = new Point[maxPathPoints]; sP1 = new Point[22]; sP2 = new Point[18]; NewPath(); }
private void fleeToolStripMenuItem1_Click(object sender, EventArgs e) { behaviourChanged = true; steeringBehaviour = SB.Flee; if (sBC != null) sBC.FirstVehicle.SteeringBehaviour = SB.Flee; }
public static extern bool GetScrollInfo(IntPtr hwnd, SB fnBar, ref SCROLLINFO lpsi);
private void separationToolStripMenuItem_Click(object sender, EventArgs e) { behaviourChanged = true; steeringBehaviour = SB.Separation; if (sBC != null) sBC.FirstVehicle.SteeringBehaviour = SB.Separation; }
private void pathFollowingToolStripMenuItem1_Click(object sender, EventArgs e) { behaviourChanged = true; steeringBehaviour = SB.PathFollowing; if (sBC != null) sBC.FirstVehicle.SteeringBehaviour = SB.PathFollowing; }
private static extern int SetScrollInfo(IntPtr hwnd, SB fnBar, IntPtr lpsi, int fRedraw);
public static int ShiftIn(IDigitalWriteRead dwr, int dataPin, int clockPin, SB bitOrder) { int value = 0; int i; for (i = 0; i < 8; ++i) { dwr.DigitalWrite(clockPin, PinState.High); if (bitOrder == SB.LSBFIRST) value |= Nusbio.ConvertTo1Or0(dwr.DigitalRead(dataPin)) << i; else value |= Nusbio.ConvertTo1Or0(dwr.DigitalRead(dataPin)) << (7 - i); dwr.DigitalWrite(dataPin, PinState.Low); } return value; }