public class ImageCellRenderer : TextCellRenderer
{
const int _defaultHeight = 55;
- Dictionary<EvasObject, Native.Image> _realizedViews = new Dictionary<EvasObject, Native.Image>();
public ImageCellRenderer() : this(Device.Idiom == TargetIdiom.Watch ? "1icon_2text" : "default")
{
// In .NETCore, AppDomain feature is not supported.
// The list of assemblies returned by AppDomain.GetAssemblies() method should be registered manually.
// The assembly of the executing application and referenced assemblies of it are added into the list here.
- // TODO: AppDomain is comming back in NETStandard2.0. This logic should be changed at that time.
TizenPlatformServices.AppDomain.CurrentDomain.RegisterAssemblyRecursively(application.GetType().GetTypeInfo().Assembly);
- Device.PlatformServices = new TizenPlatformServices(); ;
+ Device.PlatformServices = new TizenPlatformServices();
if (Device.info != null)
{
((TizenDeviceInfo)Device.info).Dispose();
});
}
- // TODO: We should consider various tizen profiles such as TV, Wearable and so on.
string profile = ((TizenDeviceInfo)Device.Info).Profile;
if (profile == "mobile")
{
if (null == MainWindow)
{
- throw new NullReferenceException("MainWindow is not prepared. This method should be called in OnCreated().");
+ throw new InvalidOperationException("MainWindow is not prepared. This method should be called in OnCreated().");
}
if (null == application)
{
- throw new ArgumentNullException("application");
+ throw new ArgumentNullException(nameof(application));
}
_application = application;
Application.Current = application;
{
internal class GestureDetector
{
- IDictionary<EGestureType, List<GestureHandler>> _handlerCache = new Dictionary<EGestureType, List<GestureHandler>>();
+ readonly IDictionary<EGestureType, List<GestureHandler>> _handlerCache = new Dictionary<EGestureType, List<GestureHandler>>();
readonly IVisualElementRenderer _renderer;
GestureLayer _gestureLayer;
double _doubleTapTime = 0;
double _longTapTime = 0;
- int _horizontalSwipeTime = 0;
- int _verticalSwipeTime = 0;
bool _inputTransparent = false;
- bool _isEnabled = true;
+ bool _isEnabled;
View View => _renderer.Element as View;
{
foreach (var handler in handlers)
{
- (handler as GestureHandler).PropertyChanged -= OnGestureRecognizerPropertyChanged;
+ handler.PropertyChanged -= OnGestureRecognizerPropertyChanged;
}
}
_handlerCache.Clear();
}
}
- void OnFlickStarted(EGestureType type, object data)
- {
- var lineData = (GestureLayer.LineData)data;
- _horizontalSwipeTime = Convert.ToInt32(lineData.HorizontalSwipeTimestamp);
- _verticalSwipeTime = Convert.ToInt32(lineData.VerticalSwipeTimestamp);
- OnGestureStarted(type, data);
- }
-
- void OnFlickCompleted(EGestureType type, object data)
- {
- var lineData = (GestureLayer.LineData)data;
- _horizontalSwipeTime = Convert.ToInt32(lineData.HorizontalSwipeTimestamp - _horizontalSwipeTime);
- _verticalSwipeTime = Convert.ToInt32(lineData.VerticalSwipeTimestamp - _verticalSwipeTime);
- var cache = _handlerCache;
-
- if (cache.ContainsKey(type))
- {
- foreach (var handler in cache[type])
- {
- if ((handler.Timeout * 1000) >= _horizontalSwipeTime ||
- (handler.Timeout * 1000) >= _verticalSwipeTime)
- (handler as IGestureController)?.SendCompleted(View, data);
- else
- (handler as IGestureController)?.SendCanceled(View, data);
- }
- }
- }
-
#endregion GestureCallback
GestureHandler CreateHandler(IGestureRecognizer recognizer)
Recognizer.PropertyChanged += OnRecognizerPropertyChanged;
}
- public virtual event PropertyChangedEventHandler PropertyChanged;
+ public event PropertyChangedEventHandler PropertyChanged;
protected abstract void OnStarted(View sender, object data);
/// </summary>
public static class Log
{
- static String _tag = "Xamarin";
-
- static ILogger _logger = IsTizen() ? (ILogger)new DlogLogger() : (ILogger)new ConsoleLogger();
/// <summary>
/// Gets or sets the log tag.
/// </summary>
- public static String Tag
- {
- get
- {
- return _tag;
- }
- set
- {
- _tag = value;
- }
- }
+ public static string Tag { get; set; } = "Xamarin";
- /// <summary>
- /// Gets or sets the logger used to report messages.
- /// It's DlogLogger on a Tizen platform, ConsoleLogger on any other.
- /// </summary>
- public static ILogger Logger
- {
- get
- {
- return _logger;
- }
- set
- {
- _logger = value;
- }
- }
+ /// <summary>
+ /// Gets or sets the logger used to report messages.
+ /// It's DlogLogger on a Tizen platform, ConsoleLogger on any other.
+ /// </summary>
+ public static ILogger Logger { get; set; } = IsTizen() ? (ILogger)new DlogLogger() : (ILogger)new ConsoleLogger();
public static void Debug(string message,
Guardian _ = default(Guardian),
[CallerMemberName] string func = "",
[CallerLineNumber] int line = 0)
{
- _logger.Debug(_tag, message, file, func, line);
+ Logger.Debug(Tag, message, file, func, line);
}
public static void Debug<T0>(string message,
[CallerMemberName] string func = "",
[CallerLineNumber] int line = 0)
{
- _logger.Verbose(_tag, message, file, func, line);
+ Logger.Verbose(Tag, message, file, func, line);
}
public static void Verbose<T0>(string message,
[CallerMemberName] string func = "",
[CallerLineNumber] int line = 0)
{
- _logger.Info(_tag, message, file, func, line);
+ Logger.Info(Tag, message, file, func, line);
}
public static void Info<T0>(string message,
[CallerMemberName] string func = "",
[CallerLineNumber] int line = 0)
{
- _logger.Warn(_tag, message, file, func, line);
+ Logger.Warn(Tag, message, file, func, line);
}
public static void Warn<T0>(string message,
[CallerMemberName] string func = "",
[CallerLineNumber] int line = 0)
{
- _logger.Error(_tag, message, file, func, line);
+ Logger.Error(Tag, message, file, func, line);
}
public static void Error<T0>(string message,
[CallerMemberName] string func = "",
[CallerLineNumber] int line = 0)
{
- _logger.Fatal(_tag, message, file, func, line);
+ Logger.Fatal(Tag, message, file, func, line);
}
public static void Fatal<T0>(string message,
part = "button2";
break;
- case ButtonPosition.Negative:
default:
part = "button1";
break;
/// </summary>
public class Entry : EEntry, IMeasurable, IBatchable
{
- static readonly int s_VariationNormal = 0;
- static readonly int s_VariationSignedAndDecimal = 3;
+ const int VariationNormal = 0;
+ const int VariationSignedAndDecimal = 3;
/// <summary>
/// Holds the formatted text of the entry.
/// <param name="keyboard">Keyboard type to be used.</param>
void ApplyKeyboard(Keyboard keyboard)
{
- SetInternalKeyboard(_keyboard = keyboard);
+ _keyboard = keyboard;
+ SetInternalKeyboard(keyboard);
}
/// <summary>
SetInputPanelEnabled(true);
SetInputPanelLayout(InputPanelLayout.NumberOnly);
// InputPanelVariation is used to allow using deciaml point.
- InputPanelVariation = s_VariationSignedAndDecimal;
+ InputPanelVariation = VariationSignedAndDecimal;
}
else
{
SetInputPanelEnabled(true);
SetInputPanelLayout((InputPanelLayout)keyboard);
- InputPanelVariation = s_VariationNormal;
+ InputPanelVariation = VariationNormal;
}
}
/// <summary>
/// Adds elements to the list and defines its presentation based on Cell type.
/// </summary>
- /// <param name="_source">IEnumerable on Cell collection.</param>
+ /// <param name="source">IEnumerable on Cell collection.</param>
/// <param name="beforeCell">Cell before which new items will be placed.
/// Null value may also be passed as this parameter, which results in appending new items to the end.
/// </param>
- public void AddSource(IEnumerable _source, Cell beforeCell = null)
+ public void AddSource(IEnumerable source, Cell beforeCell = null)
{
- foreach (var data in _source)
+ foreach (var data in source)
{
GroupList groupList = data as GroupList;
if (groupList != null)
AddGroupItem(groupList, beforeCell);
foreach (var item in groupList)
{
- AddItem(item as Cell, groupList.HeaderContent);
+ AddItem(item, groupList.HeaderContent);
}
}
else
if (renderer == null)
{
Log.Error("Cell type is not handled: {0}", cell.GetType());
- throw new ArgumentNullException("Unsupported cell type");
+ throw new ArgumentException("Unsupported cell type");
}
renderer.SetGroupMode(isGroup);
public class Scroller : EScroller
{
TaskCompletionSource<bool> _animationTaskComplateSource;
- SmartEvent _scrollAnimationStart, _scrollAnimationStop;
bool _isAnimation = false;
public Scroller(EvasObject parent) : base(parent)
protected override void OnRealized()
{
base.OnRealized();
- _scrollAnimationStart = new SmartEvent(this, RealHandle, "scroll,anim,start");
- _scrollAnimationStop = new SmartEvent(this, RealHandle, "scroll,anim,stop");
- _scrollAnimationStart.On += (s, e) => _isAnimation = true;
- _scrollAnimationStop.On += (s, e) =>
+ new SmartEvent(this, RealHandle, "scroll,anim,start").On += (s, e) => _isAnimation = true;
+ new SmartEvent(this, RealHandle, "scroll,anim,stop").On += (s, e) =>
{
if (_animationTaskComplateSource != null)
{
internal string GetMarkupText()
{
StringBuilder sb = new StringBuilder();
-
- sb.AppendFormat("<span ");
-
+ sb.Append("<span ");
sb = PrepareFormattingString(sb);
-
sb.Append(">");
-
sb.Append(GetDecoratedText());
-
sb.Append("</span>");
-
return sb.ToString();
}
public bool ConvertTo(object value, Type toType, out object nativeValue)
{
nativeValue = null;
- if (typeof(EObject).IsInstanceOfType(value) && toType.IsAssignableFrom(typeof(View)))
+ if ((value is EObject) && toType.IsAssignableFrom(typeof(View)))
{
nativeValue = ((EObject)value).ToView();
return true;
bool _disposed;
Native.Dialog _pageBusyDialog;
int _pageBusyCount;
- Naviframe _internalNaviframe;
+ readonly Naviframe _internalNaviframe;
- HashSet<EvasObject> _alerts = new HashSet<EvasObject>();
+ readonly HashSet<EvasObject> _alerts = new HashSet<EvasObject>();
public event EventHandler<RootNativeViewChangedEventArgs> RootNativeViewChanged;
public bool HasAlpha { get; set; }
- Action BackPressedAction { get; set; }
-
Task CurrentModalNavigationTask { get; set; }
TaskCompletionSource<bool> CurrentTaskCompletionSource { get; set; }
IPageController CurrentPageController => _navModel.CurrentPage as IPageController;
namespace Xamarin.Forms.Platform.Tizen.Renderers
{
- public class MasterDetailContainer : ElmSharp.Box
+ public class MasterDetailContainer : ElmSharp.Box, IDisposable
{
- MasterDetailPage _parent;
+ readonly MasterDetailPage _parent;
+ readonly bool _isMaster;
+
VisualElement _childView;
bool _disposed;
- bool _isMaster;
bool _hasAppearedToParent;
IPageController PageController => ChildView as IPageController;
void OnInsertPageBeforeRequested(object sender, NavigationRequestedEventArgs nre)
{
if (nre.BeforePage == null)
- throw new ArgumentNullException("before");
+ throw new ArgumentException("BeforePage is null");
if (nre.Page == null)
- throw new ArgumentNullException("page");
+ throw new ArgumentException("Page is null");
_naviItemMap[nre.Page] = _naviFrame.InsertBefore(GetNaviItemForPage(nre.BeforePage), CreateNavItem(nre.Page), SpanTitle(nre.Page.Title));
UpdateHasNavigationBar(nre.Page);
EvasObject CreateNavItem(Page page)
{
- View titleView = NavigationPage.GetTitleView(page) as View;
+ View titleView = NavigationPage.GetTitleView(page);
EvasObject nativeView = null;
if (titleView != null)
{
/// </summary>
public abstract class VisualElementRenderer<TElement> : IVisualElementRenderer, IEffectControlProvider where TElement : VisualElement
{
- /// <summary>
- /// Holds registered element changed handlers.
- /// </summary>
readonly List<EventHandler<VisualElementChangedEventArgs>> _elementChangedHandlers = new List<EventHandler<VisualElementChangedEventArgs>>();
- /// <summary>
- /// Flags which control status of renderer.
- /// </summary>
- VisualElementRendererFlags _flags = VisualElementRendererFlags.None;
-
- /// <summary>
- /// Holds the native view.
- /// </summary>
- EvasObject _view;
+ readonly Dictionary<string, Action<bool>> _propertyHandlersWithInit = new Dictionary<string, Action<bool>>();
- Dictionary<string, Action<bool>> _propertyHandlersWithInit = new Dictionary<string, Action<bool>>();
+ readonly Dictionary<string, Action> _propertyHandlers = new Dictionary<string, Action>();
- Dictionary<string, Action> _propertyHandlers = new Dictionary<string, Action>();
+ readonly HashSet<string> _batchedProperties = new HashSet<string>();
- HashSet<string> _batchedProperties = new HashSet<string>();
+ VisualElementRendererFlags _flags = VisualElementRendererFlags.None;
bool _movedCallbackEnabled = false;
}
}
- public EvasObject NativeView
- {
- get
- {
- return _view;
- }
- }
+ public EvasObject NativeView { get; private set; }
protected bool IsDisposed => _flags.HasFlag(VisualElementRendererFlags.Disposed);
/// the memory that the <see cref="Xamarin.Forms.Platform.Tizen.VisualElementRenderer"/> was occupying.</remarks>
public void Dispose()
{
- // This is the reason why I call SendDisappearing() here.
- // When OnChildRemove is called first like how it is called in Navigation.PopToRootAsync(),
- // you can not controll using SendDisappearing() on the lower class.
- (Element as IPageController)?.SendDisappearing();
Dispose(true);
GC.SuppressFinalize(this);
}
{
if (newElement == null)
{
- throw new ArgumentNullException("newElement");
+ throw new ArgumentNullException(nameof(newElement));
}
TElement oldElement = Element;
TElement tElement = element as TElement;
if (tElement == null)
{
- throw new ArgumentException("Element is not of type " + typeof(TElement), "Element");
+ throw new ArgumentException("Element is not of type " + typeof(TElement), nameof(element));
}
SetElement(tElement);
}
if (disposing)
{
+ // This is the reason why I call SendDisappearing() here.
+ // When OnChildRemove is called first like how it is called in Navigation.PopToRootAsync(),
+ // you can not controll using SendDisappearing() on the lower class.
+ (Element as IPageController)?.SendDisappearing();
+
if (Element != null)
{
Element.PropertyChanged -= OnElementPropertyChanged;
{
NativeView.Deleted -= NativeViewDeleted;
NativeView.Unrealize();
- _view = null;
+ NativeView = null;
}
if (_customFocusManager.IsValueCreated)
controller.EffectControlProvider = this;
}
}
-
- // TODO: handle the event
}
/// <summary>
widget.Focused -= OnFocused;
widget.Unfocused -= OnUnfocused;
}
- _view = control;
+ NativeView = control;
if (NativeView != null)
{
NativeView.Deleted += NativeViewDeleted;
_dictionary[Device.Styles.ListItemDetailTextStyleKey] = GetStyleByKey(Device.Styles.ListItemDetailTextStyleKey);
}
- //TODO: need Tizen API to get system values
Style GetStyleByKey(string key)
{
Style style = null;
{
internal class TizenIsolatedStorageFile : IIsolatedStorageFile
{
- string _rootPath;
+ readonly string _rootPath;
internal TizenIsolatedStorageFile()
{
public void CreateDirectory(string path)
{
if (path == null)
- throw new ArgumentNullException("path");
+ throw new ArgumentNullException(nameof(path));
Directory.CreateDirectory(Path.Combine(_rootPath, path));
}
public void MoveFile(string source, string dest)
{
if (source == null)
- throw new ArgumentNullException("source");
+ throw new ArgumentNullException(nameof(source));
if (dest == null)
- throw new ArgumentNullException("dest");
+ throw new ArgumentNullException(nameof(dest));
File.Move(Path.Combine(_rootPath, source), Path.Combine(_rootPath, dest));
}
public void DeleteFile(string path)
{
if (path == null)
- throw new ArgumentNullException("path");
+ throw new ArgumentNullException(nameof(path));
if (path.Trim().Length == 0)
throw new ArgumentException("An empty path is not valid.");
public bool DirectoryExists(string path)
{
if (path == null)
- throw new ArgumentNullException("path");
+ throw new ArgumentNullException(nameof(path));
return Directory.Exists(Path.Combine(_rootPath, path));
}
public bool FileExists(string path)
{
if (path == null)
- throw new ArgumentNullException("path");
+ throw new ArgumentNullException(nameof(path));
return File.Exists(Path.Combine(_rootPath, path));
}
public DateTimeOffset GetLastWriteTime(string path)
{
if (path == null)
- throw new ArgumentNullException("path");
+ throw new ArgumentNullException(nameof(path));
if (path.Trim().Length == 0)
throw new ArgumentException("An empty path is not valid.");
public Stream OpenFile(string path, FileMode mode, FileAccess access, FileShare share)
{
if (path == null)
- throw new ArgumentNullException("path");
+ throw new ArgumentNullException(nameof(path));
if (path.Trim().Length == 0)
throw new ArgumentException("An empty path is not valid.");
pt = Device.Idiom == TargetIdiom.TV ? 84 : (Device.Idiom == TargetIdiom.Watch ? 36 : 31);
break;
default:
- throw new ArgumentOutOfRangeException();
+ throw new ArgumentOutOfRangeException(nameof(size));
}
return Forms.ConvertToDPFont(pt);
}
}
TAppControl tAppControl = new TAppControl() { Operation = "%", Uri = uri.AbsoluteUri };
var matchedApplications = TAppControl.GetMatchedApplicationIds(tAppControl);
- if (matchedApplications.Count() > 0)
+ if (matchedApplications.Any())
{
TAppControl.SendLaunchRequest(tAppControl);
return;
{
public static AppDomain CurrentDomain { get; private set; }
- List<Assembly> _assemblies;
+ readonly List<Assembly> _assemblies;
static AppDomain()
{