Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove redundant casts #19

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.idea
bin
obj
2 changes: 1 addition & 1 deletion maui/samples/Gallery/Platforms/iOS/PreviewControllerDS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public PreviewControllerDS(QLPreviewItem item)

public override nint PreviewItemCount(QLPreviewController controller)
{
return (nint)1;
return 1;
}

public override IQLPreviewItem GetPreviewItem(QLPreviewController controller, nint index)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ protected override void OnLayout()
if (Series is CartesianSeries series && series.ActualYAxis is NumericalAxis yAxis)
{
var top = yAxis.ValueToPoint(Convert.ToDouble(yAxis.Maximum ?? double.NaN));
trackRect = new RectF() { Left = Left, Top = Top, Right = (float)top, Bottom = Bottom };
trackRect = new RectF() { Left = Left, Top = Top, Right = top, Bottom = Bottom };
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ protected override void Draw(ICanvas canvas)
{
var top = yAxis.ValueToPoint(Convert.ToDouble(yAxis.Maximum ?? double.NaN));

var trackRect = new RectF() { Left = Left, Top = (float)top, Right = Right, Bottom = Bottom };
curveHeight = (float)trackRect.Height / curveYGape;
var width = (float)trackRect.Width + (float)Math.Sqrt((trackRect.Width * trackRect.Width) + (trackRect.Height * trackRect.Height));
var trackRect = new RectF() { Left = Left, Top = top, Right = Right, Bottom = Bottom };
curveHeight = trackRect.Height / curveYGape;
var width = trackRect.Width + (float)Math.Sqrt((trackRect.Width * trackRect.Width) + (trackRect.Height * trackRect.Height));
var waveLeft = trackRect.Left;
var waveRight = waveLeft + width;
var waveTop = trackRect.Bottom;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ private void ShimmerColor_Clicked(object sender, EventArgs e)

private void SfTabView_SelectionChanged(object sender, Syncfusion.Maui.Toolkit.TabView.TabSelectionChangedEventArgs e)
{
string type = viewModel.ShimmerTypes[(int)e.NewIndex];
string type = viewModel.ShimmerTypes[e.NewIndex];

switch (type)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ private void SfTabView_SelectionChanged(object sender, Syncfusion.Maui.Toolkit.T
{
var view = (Syncfusion.Maui.Toolkit.TabView.SfTabView)sender;

SfTabItem item = view.Items[(int)e.NewIndex];
SfTabItem item = view.Items[e.NewIndex];

var selectedFile = item.Header;

Expand Down
5 changes: 2 additions & 3 deletions maui/samples/Gallery/ViewModel/SamplesViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -589,10 +589,9 @@ public void ReadStream(Stream controlListStream)
{
if (xmlItem.Name == "ControlCategory")
{
XmlElement xmlControlCategoryItem = (XmlElement)xmlItem;
var xmlControlCategoryItemName = xmlControlCategoryItem.GetAttribute("Name");
var xmlControlCategoryItemName = xmlItem.GetAttribute("Name");
var controlCatagoryObj = GetControlCategoryModel(xmlControlCategoryItemName);
foreach (var controlItem in xmlControlCategoryItem.ChildNodes)
foreach (var controlItem in xmlItem.ChildNodes)
{
if (controlItem is XmlElement xmlControlItem)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2099,8 +2099,8 @@ void ArrangeDefaultViewMode()
}
if (item != null)
{
double x = (m + (((double)b * Offset) + (SelectedItemOffset * mu))) - (item.ActualWidth / 2);
double x1 = (m1 + (((double)b * Offset) + (SelectedItemOffset * mu))) - (item.ActualHeight / 2);
double x = (m + ((b * Offset) + (SelectedItemOffset * mu))) - (item.ActualWidth / 2);
double x1 = (m1 + ((b * Offset) + (SelectedItemOffset * mu))) - (item.ActualHeight / 2);
double s = mu == 0 ? 1 : ScaleOffset;
if (Orientation == Orientation.Vertical)
{
Expand Down Expand Up @@ -3226,8 +3226,8 @@ void UpdateDefautStartEndPosition(double horizontalCenterPoint, double verticalC
{
indexFactor = 1;
}
hCenter = (horizontalCenterPoint + (((double)selectedIndex * Offset) + (SelectedItemOffset * indexFactor))) - (ItemWidth / 2);
vCenter = (verticalCenterPoint + (((double)selectedIndex * Offset) + (SelectedItemOffset * indexFactor))) - (ItemHeight / 2);
hCenter = (horizontalCenterPoint + ((selectedIndex * Offset) + (SelectedItemOffset * indexFactor))) - (ItemWidth / 2);
vCenter = (verticalCenterPoint + ((selectedIndex * Offset) + (SelectedItemOffset * indexFactor))) - (ItemHeight / 2);
if (Orientation == Orientation.Horizontal)
{
double startRegion = -horizontalCenterPoint;
Expand Down
6 changes: 3 additions & 3 deletions maui/src/Carousel/Platform/iOS/LinearViewMode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ UICollectionViewCell GetVirtualizedCell(UICollectionViewCell cell, UICollectionV
ClearExistingSubviews(cell);
if(_carousel.LinearVirtualDataSource != null)
{
object? convertitem = ((IList)_carousel.LinearVirtualDataSource)[(int)indexPath.Row];
object? convertitem = ((IList)_carousel.LinearVirtualDataSource)[indexPath.Row];
if (convertitem != null)
{
ConvertItem(convertitem, indexPath.Row);
Expand Down Expand Up @@ -409,7 +409,7 @@ void ConvertVirtualItemForLoadMore(NSIndexPath indexPath)
{
if(_carousel.LinearVirtualDataSource != null)
{
object? convertitem = ((IList)_carousel.LinearVirtualDataSource)[(int)indexPath.Row];
object? convertitem = ((IList)_carousel.LinearVirtualDataSource)[indexPath.Row];
if (convertitem != null)
{
ConvertItem(convertitem, indexPath.Row);
Expand All @@ -431,7 +431,7 @@ void ConfigureCellAccessibility(UICollectionViewCell cell, PlatformCarouselItem
cell.IsAccessibilityElement = true;
if (_carousel.DataSource != null)
{
string accessibilityText = $"{carouselItem.AutomationId} PlatformCarouselItem {(int)indexPath.Row + 1} of {(int)_carousel.DataSource.Count}";
string accessibilityText = $"{carouselItem.AutomationId} PlatformCarouselItem {indexPath.Row + 1} of {(int)_carousel.DataSource.Count}";
cell.AccessibilityLabel = accessibilityText;
cell.AccessibilityIdentifier = accessibilityText;
}
Expand Down
54 changes: 27 additions & 27 deletions maui/src/Carousel/Platform/iOS/PlatformCarousel.iOS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ void OnDataSourcePropertyChanged(NSMutableArray? value)
if (LoadMoreItemsCount > 0)
{
var count = _maximumVisibleCount;
if (_dataSource != null && count > (int)GetItemCount())
if (_dataSource != null && count > GetItemCount())
{
count = (int)_dataSource.Count;
}
Expand Down Expand Up @@ -1585,20 +1585,20 @@ internal void LoadOtherItem()
int count = _maximumVisibleCount;
int tempCount = GetItemCount();

if (((int)tempCount - _dataSourceEndIndex - 1) < _maximumVisibleCount)
if ((tempCount - _dataSourceEndIndex - 1) < _maximumVisibleCount)
{
count = (int)((int)tempCount - _dataSourceEndIndex - 1);
count = (int)(tempCount - _dataSourceEndIndex - 1);
}

if (_viewMode == ViewMode.Default)
{
if (((int)tempCount - _dataSourceEndIndex - 1) > 0)
if ((tempCount - _dataSourceEndIndex - 1) > 0)
{
LoadMoreItem.RemoveFromSuperview();
}

object? convertItem;
for (int i = 0; i < (int)count; i++)
for (int i = 0; i < count; i++)
{
_dataSourceEndIndex++;

Expand All @@ -1625,7 +1625,7 @@ internal void LoadOtherItem()

if (_allowLoadMore && _dataSourceEndIndex + 1 < tempCount)
{
if (i + 1 == (int)count)
if (i + 1 == count)
{
AddLoadMoreItem();
}
Expand Down Expand Up @@ -1663,14 +1663,14 @@ void LoadItemsForLinearMode(int tempCount, ref PlatformCarouselItem item)
int count = _maximumVisibleCount;
if (_linearDataSource != null)
{
if (((int)tempCount - (int)_linearDataSource.Count - 1) < _maximumVisibleCount)
if ((tempCount - (int)_linearDataSource.Count - 1) < _maximumVisibleCount)
{
count = (int)((int)tempCount - (int)_linearDataSource.Count);
count = tempCount - (int)_linearDataSource.Count;
}

count = count + (int)_linearDataSource.Count;

for (int i = (int)_linearDataSource.Count; i < ((int)count); i++)
for (int i = (int)_linearDataSource.Count; i < count; i++)
{
if (_dataSource != null && IsDataSourceAvailable())
{
Expand Down Expand Up @@ -2152,13 +2152,13 @@ void SetSelectedIndex(nint value)
{
int tempCount = GetItemCount();

_updatedSelectedValue = (nint)value;
_updatedSelectedValue = value;
if (value < tempCount)
{
_tappedDifference = value - _selectedIndex;
if (IsDataSourceAvailable())
{
int count = (int)tempCount - 1;
int count = tempCount - 1;
if (LoadMoreItemsCount > 0 && _viewMode == ViewMode.Default)
{
count = (int)_dataSourceEndIndex;
Expand All @@ -2168,7 +2168,7 @@ void SetSelectedIndex(nint value)
count = (int)_linearDataSource.Count;
}

if ((int)count >= value)
if (count >= value)
{
_isSelectedUpdated = true;
SelectionChangedEventArgs args = new SelectionChangedEventArgs();
Expand Down Expand Up @@ -2261,7 +2261,7 @@ void HandleViewModeUpdate(int tempCount, SelectionChangedEventArgs args)
{
if (LinearMode != null)
{
NSIndexPath pathValue = NSIndexPath.FromRowSection((nint)_selectedIndex, 0);
NSIndexPath pathValue = NSIndexPath.FromRowSection(_selectedIndex, 0);
LinearMode.ViewCollection?.ScrollToItem(pathValue, UICollectionViewScrollPosition.CenteredHorizontally, false);
args.NewItem = GetMauiItem((int)SelectedIndex);
OnSelectionChanged(args);
Expand Down Expand Up @@ -2449,7 +2449,7 @@ void LoadForwardItemsWithoutXForms(int tempCount)
for (int i = 0; i < Math.Abs(_tappedDifference); i++)
{
PlatformCarouselItem item;
if (_dataSourceEndIndex + 1 < (int)tempCount)
if (_dataSourceEndIndex + 1 < tempCount)
{
_dataSourceEndIndex++;
if (_dataSource != null)
Expand Down Expand Up @@ -2892,7 +2892,7 @@ void ArrangeItem()

if (!_isVirtualization && !_allowLoadMore && !_isLinearVirtual)
{
for (nint i = 0; i < (nint)tempCount; i++)
for (nint i = 0; i < tempCount; i++)
{
PlatformCarouselItem? item = null;
if (_dataSource != null)
Expand Down Expand Up @@ -2950,7 +2950,7 @@ void UpdateLinearCenterPosition(PlatformCarouselItem view)
int tempCount = GetItemCount();
nint j = 0;

for (nint i = (nint)_selectedIndex + 1; i < (nint)tempCount; i++)
for (nint i = _selectedIndex + 1; i < tempCount; i++)
{
PlatformCarouselItem? rightItem = GetLeftAndRightItem(i);
if (rightItem != null)
Expand All @@ -2960,15 +2960,15 @@ void UpdateLinearCenterPosition(PlatformCarouselItem view)
j++;
if (_allowLoadMore)
{
if (i + 1 == (int)tempCount)
if (i + 1 == tempCount)
{
PlatformCarouselItem item = LoadMoreItem;
UpdateLinearRightPosition(item, _offset * j);
}
}
}

j = (nint)_selectedIndex - 1;
j = _selectedIndex - 1;
for (nint i = 0; i < _selectedIndex; i++)
{
PlatformCarouselItem? leftItem = GetLeftAndRightItem(i);
Expand Down Expand Up @@ -3523,7 +3523,7 @@ void ConfigureLinearMode(int tempCount)
/// </summary>
void AddLinearModeToView()
{
NSIndexPath pathValue = NSIndexPath.FromRowSection((nint)_selectedIndex, 0);
NSIndexPath pathValue = NSIndexPath.FromRowSection(_selectedIndex, 0);
LinearMode.ViewCollection?.ScrollToItem(pathValue, UICollectionViewScrollPosition.CenteredHorizontally, false);
AddSubview(LinearMode);
}
Expand Down Expand Up @@ -3624,12 +3624,12 @@ void LoadItemsWithLoadMore(int tempCount, PlatformCarouselItem item)
{
_dataSourceStartIndex = 0;
_dataSourceEndIndex = 0;
if (_maximumVisibleCount > (int)tempCount)
if (_maximumVisibleCount > tempCount)
{
_maximumVisibleCount = (int)tempCount;
_maximumVisibleCount = tempCount;
}

for (nint i = 0; i < (nint)_maximumVisibleCount; i++)
for (nint i = 0; i < _maximumVisibleCount; i++)
{
item = new PlatformCarouselItem();
if (_dataSource != null)
Expand All @@ -3641,7 +3641,7 @@ void LoadItemsWithLoadMore(int tempCount, PlatformCarouselItem item)
_dataSourceEndIndex = i;
if (_allowLoadMore)
{
if (i + 1 == (int)_maximumVisibleCount)
if (i + 1 == _maximumVisibleCount)
{
InitializeLoadMoreItem();
}
Expand Down Expand Up @@ -3682,12 +3682,12 @@ void LoadDataSourceAndAddItems()
object? convertItem;
_dataSourceStartIndex = 0;
_dataSourceEndIndex = 0;
if (_maximumVisibleCount > (int)((IList)_linearVirtualDataSource).Count)
if (_maximumVisibleCount > ((IList)_linearVirtualDataSource).Count)
{
_maximumVisibleCount = (int)((IList)_linearVirtualDataSource).Count;
_maximumVisibleCount = ((IList)_linearVirtualDataSource).Count;
}

for (nint i = 0; i < (nint)_maximumVisibleCount; i++)
for (nint i = 0; i < _maximumVisibleCount; i++)
{
if (_dataSource != null && _linearVirtualDataSource != null && _linearVirtualDataSource is IList list)
{
Expand All @@ -3699,7 +3699,7 @@ void LoadDataSourceAndAddItems()
}
if (_allowLoadMore)
{
if (i + 1 == (int)_maximumVisibleCount)
if (i + 1 == _maximumVisibleCount)
{
InitializeLoadMoreItem();
}
Expand Down
4 changes: 2 additions & 2 deletions maui/src/Carousel/Platform/iOS/PlatformCarouselItem.iOS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public nint Index
{
internal get
{
return (nint)_index;
return _index;
}

set
Expand Down Expand Up @@ -191,7 +191,7 @@ public override void TouchesEnded(NSSet touches, UIEvent evt)
#pragma warning restore CS8765
{
UITouch touch = (UITouch)touches.AnyObject;
CGPoint touchPoint = (CGPoint)touch.LocationInView(this);
CGPoint touchPoint = touch.LocationInView(this);
UIView? subView = HitTest(touchPoint, null);
UIView? topView = GetTopView(subView);

Expand Down
2 changes: 1 addition & 1 deletion maui/src/Charts/Annotation/ChartAnnotation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ public bool IsVisible
/// </example>
public object X1
{
get { return (object)GetValue(X1Property); }
get { return GetValue(X1Property); }
set { SetValue(X1Property, value); }
}

Expand Down
2 changes: 1 addition & 1 deletion maui/src/Charts/Annotation/VerticalLineAnnotation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ void CalculateVerticalAxisLabelPosition(ChartAxis xAxis, Rect actualSeriesClipRe
}
else
{
x = (float)(XPosition1);
x = XPosition1;
y = (float)(xAxis.ArrangeRect.Y + labelSize.Height / 2 + marginBottom);
}

Expand Down
2 changes: 1 addition & 1 deletion maui/src/Charts/Axis/CategoryAxis.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ internal override void GenerateVisibleLabels()

if (!isOverriddenOnCreateLabelsMethod && LabelPlacement != LabelPlacement.BetweenTicks)
{
TickPositions.Add((double)pos);
TickPositions.Add(pos);
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions maui/src/Charts/Axis/ChartAxis.cs
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,8 @@ internal Rect ArrangeRect
RenderedRect = new Rect(left, top, _arrangeRect.Width, height);
}

LeftOffset = (float)(RenderedRect.Left - _arrangeRect.Left);
TopOffset = (float)(RenderedRect.Top - _arrangeRect.Top);
LeftOffset = RenderedRect.Left - _arrangeRect.Left;
TopOffset = RenderedRect.Top - _arrangeRect.Top;
UpdateAxisLayout();
}
}
Expand Down Expand Up @@ -206,10 +206,10 @@ public float ValueToPoint(double value)

if (!IsVertical)
{
return (float)(RenderedRect.Width * coefficient) + LeftOffset;
return RenderedRect.Width * coefficient + LeftOffset;
}

return (float)(RenderedRect.Height * (1 - coefficient)) + TopOffset;
return RenderedRect.Height * (1 - coefficient) + TopOffset;
}

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion maui/src/Charts/Axis/DateTimeAxis.cs
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ internal override void UpdateAutoScrollingDelta(DoubleRange actualRange, double
var dateTime = DateTime.FromOADate(actualRange.End);
if (double.IsNaN(autoScrollingDelta)) return;

var ActualScrollingDelta = (double)AutoScrollingDelta;
var ActualScrollingDelta = AutoScrollingDelta;

switch (GetActualAutoScrollingDeltaType())
{
Expand Down
Loading