public static void AccessToStructs() { // Using a Struct var rectangleStruct = new RectangleStruct(11, 33, "RectangleStruct") { Width = 1, Height = 3, }; var rectangleStruct2 = new RectangleStruct { Width = 1, Height = 3, }; Console.WriteLine("rectangleStruct: {0}:{1}", rectangleStruct.Width, rectangleStruct.Height); // Calling a struct Method var rectangleStruct3 = rectangleStruct.Add(rectangleStruct2); Console.WriteLine("rectangleStruct: {0}:{1}", rectangleStruct3.Width, rectangleStruct3.Height); var rectangleClass = new RectangleClass("RectangleClass") { Width = 1, Height = 3, }; Console.WriteLine("rectangleClass: {0}:{1}", rectangleClass.Width, rectangleClass.Height); }
public unsafe RectangleStruct GetFrameBounds(int idxFrame) { RectangleStruct tmp = default; var func = (delegate * unmanaged[Thiscall] < ref SHPStruct, ref RectangleStruct, int, IntPtr >) 0x69E7E0; func(ref this, ref tmp, idxFrame); return(tmp); }
public static void OnChange(Entity sender, Int32PropertyChangeEventArgs args) { var hero = sender as Hero; if (hero == null) { return; } if (hero.Team != Members.MyHero.Team || hero.IsIllusion()) { return; } if (args.PropertyName != "m_iTaggedAsVisibleByTeam") { return; } DelayAction.Add(50, () => { var visible = args.NewValue == 0x1E; var player = hero.Player; RectangleStruct st; if (!RectDictionary.TryGetValue(player, out st)) { var newRect = new Rectangle( new Vector2((float)HudInfoNew.GetTopPanelSizeX(hero), (float)HUDInfo.GetTopPanelSizeY(hero)), Clr) { Position = HudInfoNew.GetTopPanelPosition(hero) }; st = new RectangleStruct(newRect, eventArgs => newRect.Render()); RectDictionary.Add(player, st); //Log.Info($"Init new player {player.Name}({hero.GetRealName()})"); } var rect = st.Rect; var draw = st.Draw; if (visible) { if (IsEnable) { if (!rect.IsInitialized) { rect.Initialize(); rect.Color = Clr; //new ColorBGRA(0,155,255,10); Drawing.OnEndScene += draw; } } } else { if (rect.IsInitialized) { rect.Dispose(); Drawing.OnEndScene -= draw; } } }); }
// Adding a Method to a struct public RectangleStruct Add(RectangleStruct rect) { // create instance of rectangle struct with default constructor var newRect = new RectangleStruct(); // add matching axes and assign to new Rectangle struct newRect.Width = Width + rect.Width; newRect.Height = Height + rect.Height; // return new Rectangle struct return(newRect); }
public static extern bool GetClientRect(IntPtr hwind, out RectangleStruct lpRect);
public Rectangle(System.IntPtr i, bool owned) { rawStruct = ((RectangleStruct)(Marshal.PtrToStructure(i, typeof(RectangleStruct)))); }
internal static extern int GetWindowRect(IntPtr hwnd, out RectangleStruct lpRect);