Skip to content

Commit

Permalink
Small refactoring: variables initialization was simplified (#5489)
Browse files Browse the repository at this point in the history
  • Loading branch information
ArtemTatarinov authored Sep 7, 2021
1 parent bcc8ca1 commit 9b1c202
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ public override Rectangle Bounds
{
get
{
int left = 0;
int top = 0;
int width = 0;
int height = 0;
var systemIAccessible = GetSystemIAccessibleInternal();
systemIAccessible?.accLocation(out left, out top, out width, out height, COMBOBOX_DROPDOWN_BUTTON_ACC_ITEM_INDEX);
return new Rectangle(left, top, width, height);
if (GetSystemIAccessibleInternal() is not Accessibility.IAccessible systemIAccessible)
{
return Rectangle.Empty;
}

systemIAccessible.accLocation(out int left, out int top, out int width, out int height, COMBOBOX_DROPDOWN_BUTTON_ACC_ITEM_INDEX);
return new(left, top, width, height);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,16 @@ public override Rectangle Bounds
{
get
{
if (!OwningScrollBar.IsHandleCreated || !IsDisplayed)
if (!OwningScrollBar.IsHandleCreated || !IsDisplayed || ParentInternal.GetSystemIAccessibleInternal() is not Accessibility.IAccessible systemIAccessible)
{
return Rectangle.Empty;
}

int left = 0;
int top = 0;
int width = 0;
int height = 0;

// The "GetChildId" method returns to the id of the ScrollBar element,
// which allows to use the native "accLocation" method to get the "Bounds" property
ParentInternal.GetSystemIAccessibleInternal()?.accLocation(out left, out top, out width, out height, GetChildId());
systemIAccessible.accLocation(out int left, out int top, out int width, out int height, GetChildId());

return new Rectangle(left, top, width, height);
return new(left, top, width, height);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,14 @@ public override Rectangle Bounds
{
get
{
if (!_owningTrackBar.IsHandleCreated)
if (!_owningTrackBar.IsHandleCreated || GetSystemIAccessibleInternal() is not Accessibility.IAccessible systemIAccessible)
{
return Rectangle.Empty;
}

int left = 0;
int top = 0;
int width = 0;
int height = 0;

// The "NativeMethods.CHILDID_SELF" constant returns to the id of the trackbar,
// which allows to use the native "accLocation" method to get the "Bounds" property
GetSystemIAccessibleInternal()?.accLocation(out left, out top, out width, out height, NativeMethods.CHILDID_SELF);
systemIAccessible.accLocation(out int left, out int top, out int width, out int height, NativeMethods.CHILDID_SELF);

return new(left, top, width, height);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,14 @@ public override Rectangle Bounds
{
get
{
if (!OwningTrackBar.IsHandleCreated || !IsDisplayed)
if (!OwningTrackBar.IsHandleCreated || !IsDisplayed || ParentInternal.GetSystemIAccessibleInternal() is not Accessibility.IAccessible systemIAccessible)
{
return Rectangle.Empty;
}

int left = 0;
int top = 0;
int width = 0;
int height = 0;

// The "GetChildId" method returns to the id of the trackbar element,
// which allows to use the native "accLocation" method to get the "Bounds" property
ParentInternal.GetSystemIAccessibleInternal()?.accLocation(out left, out top, out width, out height, GetChildId());
systemIAccessible.accLocation(out int left, out int top, out int width, out int height, GetChildId());

return new(left, top, width, height);
}
Expand Down

0 comments on commit 9b1c202

Please sign in to comment.