Exemple #1
0
 public void ChangeSkin(int skinID, bool reloadApp = false)
 {
     if (Settings.Default.Skin != skinID)
     {
         Settings.Default.Skin = skinID;
         Settings.Default.Save();
         ((App)Application.Current).ChangeSkin();
         if (reloadApp)
         {
             string s = AppState.Current.Save();
             this._forceClose = true;
             AppEvents.InvokeExit();
             Application.Current.ShutdownMode = ShutdownMode.OnExplicitShutdown;
             this.Close();
             new MainWindow()
             {
                 OldWindowSaveData = s
             }.Show();
             Application.Current.ShutdownMode = ShutdownMode.OnMainWindowClose;
             return;
         }
     }
 }
 public MovementController(
     IAntiforgery antiForgery,
     IHttpContextAccessor httpContextAccessor,
     IHostingEnvironment env,
     IMapper mapper,
     IAppSettings appSettings,
     IServiceProvider serviceProvider,
     ILoggerFactory loggerFactory,
     AppEvents appEvents,
     UserManager userManager,
     IService <Movement> service
     ) : base(
         antiForgery,
         httpContextAccessor,
         env,
         mapper,
         appSettings,
         loggerFactory,
         serviceProvider,
         service)
 {
     this.userManager = userManager;
 }
 public OrderController(
     UserManager userManager,
     IAntiforgery antiForgery,
     IHttpContextAccessor httpContextAccessor,
     IHostingEnvironment env,
     IMapper mapper,
     IAppSettings appSettings,
     IServiceProvider serviceProvider,
     ILoggerFactory loggerFactory,
     OrderService orderService,
     AppEvents appEvents
     ) : base(
         antiForgery,
         httpContextAccessor,
         env,
         mapper,
         appSettings,
         loggerFactory,
         serviceProvider,
         orderService)
 {
     this.orderService = orderService;
     this.userManager  = userManager;
 }
 public void LogPurchase()
 {
     AppEvents.LogPurchase(1.0, "USD");
 }
 /// <summary>
 /// Initializes a new <see cref="OurOrdersBuilder"/> instance.
 /// </summary>
 /// <param name="appSettings"></param>
 /// <param name="appEvents"></param>
 /// <param name="hostServices"></param>
 internal OurOrdersBuilder(IAppSettings appSettings, AppEvents appEvents, IServiceCollection hostServices)
 {
     this.AppSettings = appSettings;
     this.appEvents   = appEvents;
     HostServices     = hostServices;
 }
Exemple #6
0
        public AutoMapperProfile(IServiceProvider sp, IAppSettings appsettings, Configuration configuration, AppEvents appEvents, IRoleStore <Role> roleStore)
        {
            // https://github.com/aspnet/JsonPatch/issues/31
            CreateMap(typeof(JsonPatchDocument <>), typeof(JsonPatchDocument <>));
            CreateMap(typeof(Operation <>), typeof(Operation <>));

            CreateMap <User, AccountDto>();
            CreateMap <AccountDto, User>();

            CreateMap <User, UserDto>();
            CreateMap <UserDto, User>();

            CreateMap(typeof(OrderDto), appsettings.OrderType);
            CreateMap <IOrder, OrderDto>();
            CreateMap(typeof(OrderDto), typeof(IOrder)).As(appsettings.OrderType);

            CreateMap <IPerson, Person>();
            // CreateMap<IPerson, PersonDto>();

            CreateMap <Person, IPerson>();
            // CreateMap<PersonDto, IPerson>();

            CreateMap(typeof(ProductDto), appsettings.ProductType);
            CreateMap <IProduct, ProductDto>();
            CreateMap <IProduct, ProductPreviewDto>();
            CreateMap(typeof(ProductDto), typeof(IProduct)).As(appsettings.ProductType);


            CreateMap <IClient, ClientDto>();

            CreateMap(typeof(ClientDto), appsettings.ClientType);
            CreateMap(typeof(ClientDto), typeof(IClient))
            .As(appsettings.ClientType);

            // mapper from order to product
            CreateMap <IProduct, OrderItem>();


            CreateMap <Configuration, ConfigurationDto>();

            appEvents.OnTypeMapping(this, this);
        }
Exemple #7
0
 public Service(IRepository <TModel> provider, AppEvents appEvents)
 {
     this.provider  = provider;
     this.appEvents = appEvents;
 }
 public void PublishInstall()
 {
     AppEvents.ActivateApp();
 }
Exemple #9
0
 public static void OnActivated(UIApplication application)
 {
     AppEvents.ActivateApp();
 }
Exemple #10
0
 public override void OnActivated(UIApplication application) => AppEvents.ActivateApp();
Exemple #11
0
 public static void OnActivated()
 {
     AppEvents.ActivateApp();
 }
Exemple #12
0
 public void LogEvent(string name)
 {
     AppEvents.LogEvent(name);
 }
 public override void OnActivated(UIApplication application)
 {
     // Call the 'ActivateApp' method to log an app event for use
     // in analytics and advertising reporting. This is optional
     AppEvents.ActivateApp();
 }
Exemple #14
0
 // Start is called before the first frame update
 void Start()
 {
     AppEvents.Invoke_OnMouseCursorEnable(true);
 }
Exemple #15
0
        private void OpenChat(AppEvent e)
        {
            this._chat = (Dialog)e.Data[0];

            (new Thread(async() =>
            {
                List <Message> messages = await this._chat.GetMessages();

                List <int> ids = new List <int>();

                lock (_messages_lock)
                {
                    this._messages = messages;

                    if (this._chat.Crypt)
                    {
                        this.InvokeEx(t =>
                        {
                            DecryptMessagesForm frm = new DecryptMessagesForm();
                            if (frm.ShowDialog(t.FindForm()) == DialogResult.OK)
                            {
                                t._chat.CryptKey = frm.Passphrase;
                            }
                        });
                    }

                    this._so = 0;
                    this._oldH = 0;
                    if (this._messages != null)
                    {
                        this._messages = this._messages.Reverse <Message>().ToList();

                        foreach (Message msg in this._messages)
                        {
                            if (!ids.Contains(msg.UserID))
                            {
                                ids.Add(msg.UserID);
                            }

                            if (msg.CryptedNow && this._chat.CryptKey != null)
                            {
                                msg.Decrypt(this._chat.CryptKey);
                            }

                            if (msg.Attachments != null && msg.Attachments.Length > 0)
                            {
                                foreach (Attachment a in msg.Attachments)
                                {
                                    if (a.Type == "photo" && a.Photo != null)
                                    {
                                        a.Photo.Load();
                                    }
                                }
                            }
                        }
                    }
                }

                User[] users = await User.GetAll(ids);

                if (users != null)
                {
                    foreach (User u in users)
                    {
                        u.GetPhoto();
                    }
                }

                this._loaded = true;

                this._heightCalculated = false;

                AppEvents.Dispatch(AppEventType.ChatOpened, this._chat);

                this.InvokeEx(t =>
                {
                    t.Invalidate();
                });
            })).Start();
        }
Exemple #16
0
        protected override void OnPaint(PaintEventArgs e)
        {
            this.OnPaintBackground(e);

            Graphics g = e.Graphics;

            g.SmoothingMode = SmoothingMode.HighQuality;

            if (!loaded)
            {
                g.FillRectangle(new SolidBrush(Color.FromArgb(164, Color.White)), this.ClientRectangle);
                Drawer.DrawString(g, "Loading chats...", this.Font, Brushes.Black, this.ClientRectangle);
            }
            else
            {
                int y = -this.ScrollOffset;

                int i = -1;
                foreach (Dialog chat in this.chats)
                {
                    i++;

                    if (y < -50)
                    {
                        y += 50;
                        continue;
                    }

                    if (y > this.Height)
                    {
                        break;
                    }

                    ControlState s = ControlState.Idle;

                    int my = this.Mouse.Position.Y;

                    if (this.Mouse.Position.X != -1 && my > y && my < y + 50)
                    {
                        s = ControlState.Hover;

                        if (this.Mouse.Clicked)
                        {
                            s = ControlState.Pressed;

                            this._cActive = i;

                            AppEvents.Dispatch(AppEventType.OpenChat, chat);

                            this.Mouse.Clicked = false;

                            this.Invalidate();
                        }
                    }

                    if (i == this._cActive)
                    {
                        s = ControlState.Active;
                    }

                    Drawer.DrawChat(g, chat, this.Font, s, y, this.Width);

                    y += 50;
                }
            }

            base.OnPaint(e);
        }
 public TestService(IRepository <TestServiceModel> provider, AppEvents appEvents) : base(provider, appEvents)
 {
 }
 public void LogCustomEvent(string eventName)
 {
     AppEvents.LogEvent(eventName);
 }
 public override void OnActivated(UIApplication uiApplication)
 {
     base.OnActivated(uiApplication);
     AppEvents.ActivateApp();
 }
 public void ActivateApp()
 {
     AppEvents.ActivateApp();
 }
 public override void OnActivated(UIApplication uiApplication)
 {
     base.OnActivated(uiApplication);
     AppEvents.ActivateApp();
     appIsStarting = false;
 }
Exemple #22
0
 private void Awake()
 {
     AppEvents.Invoke_OnMouseCursorEnable(true);
 }
 public static void UIApplicationDelegateOnActivated()
 {
     AppEvents.ActivateApp();
 }
 public ProductService(IRepository <IProduct> provider, AppEvents appEvents, IMapper mapper, Configuration configuration) : base(provider, appEvents)
 {
     this.mapper        = mapper;
     this.configuration = configuration;
 }
        public OrderService(IRepository <IOrder> orderProvider, IRepository <IShippingTemplate> shippingTemplateProvider, AppEvents appEvents, IAppSettings appSettings, Configuration configuration) : base(orderProvider, appEvents)
        {
            this.appSettings   = appSettings;
            this.configuration = configuration;

            this.shippingTemplateProvider = shippingTemplateProvider;
        }
Exemple #26
0
        internal static IWebHost MakeWebHost(IApplicationBuilder builder, IAppSettings appSettings, AppEvents appEvents, IHostingEnvironment env, Startup startup)
        {
            var hostServiceProvider = builder.ApplicationServices;

            var appKey = typeof(Startup).GetTypeInfo().Assembly.FullName;

            return(WebHost
                   .CreateDefaultBuilder()
                   .ConfigureServices(s =>
            {
                // we need to keep the context accessor
                // in order to access the right singleton containing
                // the http context.
                var contextaccessor = hostServiceProvider.GetService <IHttpContextAccessor>();
                s.TryAddSingleton(contextaccessor);

                // make appsettings available in the client appp
                s.TryAddSingleton <IAppSettings>(appSettings);

                // make appevents available in the client app
                // using IAppEvents and the implementation type
                s.TryAddSingleton <IAppEvents>(appEvents);
                s.TryAddSingleton <AppEvents>(appEvents);
                startup.ConfigureServices(s);
            })
                   .UseSetting(WebHostDefaults.ApplicationKey, appKey)
                   .UseStartup <EmptyStartup>()
                   .Build());
        }
Exemple #27
0
        public override async void DidReceiveRemoteNotification(UIApplication application, NSDictionary userInfo, Action <UIBackgroundFetchResult> completionHandler)
        {
            var notificationType = userInfo["nt"]?.ToString();

            Logger.Log("AppDelegate.DidReceiveRemoteNotification: NT: {0}", notificationType);

            try
            {
                switch (notificationType)
                {
                case RemoteNotificationType.Notification:
                    var nid = userInfo["nid"]?.ToString();
                    Logger.Log("AppDelegate.DidReceiveRemoteNotification: NID: {0}", nid);

                    var waitHandle = new TaskCompletionSource <bool>();
                    if (RemoteNotificationsService.Instance.FireNotificationReceived(new AppNotificationMessage()
                    {
                        ID = nid, Type = AppNotificationType.RemoteNotification, WaitHandle = waitHandle
                    }))
                    {
                        await waitHandle.Task;
                    }

                    Logger.Log("AppDelegate.DidReceiveRemoteNotification: Invoking completion handler");
                    completionHandler?.Invoke(UIBackgroundFetchResult.NewData);
                    break;

                case RemoteNotificationType.Link:
                    AppEvents.LogPushNotificationOpen(userInfo);
                    var lnk = userInfo["lnk"]?.ToString();

                    bool result = false;
                    if (!string.IsNullOrEmpty(lnk))
                    {
                        if (application.ApplicationState == UIApplicationState.Active)
                        {
                            var aps   = userInfo["aps"] as NSDictionary;
                            var alert = aps["alert"];

                            var title   = "Notification";
                            var message = string.Empty;
                            var action  = "Open";

                            if (alert is NSDictionary)
                            {
                                var alertDictionary = alert as NSDictionary;
                                var alertTitle      = alertDictionary["title"]?.ToString();
                                var alertBody       = alertDictionary["body"]?.ToString();
                                var alertAction     = alertDictionary["action-loc-key"]?.ToString();

                                if (!string.IsNullOrEmpty(alertTitle))
                                {
                                    title = alertTitle;
                                }

                                if (!string.IsNullOrEmpty(alertBody))
                                {
                                    message = alertBody;
                                }

                                if (!string.IsNullOrEmpty(alertAction))
                                {
                                    action = alertAction;
                                }
                            }
                            else
                            {
                                message = alert.ToString();
                            }

                            if (!string.IsNullOrEmpty(title) && !string.IsNullOrEmpty(message) && !string.IsNullOrEmpty(action))
                            {
                                var close           = "Close";
                                var closeLocalized  = NSBundle.MainBundle.LocalizedString(close, close, null);
                                var actionLocalized = NSBundle.MainBundle.LocalizedString(action, action, null);
                                var av = new UIAlertView(title, message, null, closeLocalized, actionLocalized);
                                av.Clicked += (s, e) =>
                                {
                                    if (e.ButtonIndex == 1)
                                    {
                                        if (!OpenUrl(application, new NSUrl(lnk), NSBundle.MainBundle.BundleIdentifier, userInfo))
                                        {
                                            Logger.Log("AppDelegate.DidReceiveRemoteNotification: There was an error executing OpenUrl");
                                        }
                                    }
                                };
                                av.Show();
                                result = true;
                            }
                        }
                        else
                        {
                            BeginInvokeOnMainThread(() =>
                            {
                                if (!OpenUrl(application, new NSUrl(lnk), NSBundle.MainBundle.BundleIdentifier, userInfo))
                                {
                                    Logger.Log("AppDelegate.DidReceiveRemoteNotification: There was an error executing OpenUrl");
                                }
                            });
                            result = true;
                        }
                    }

                    completionHandler?.Invoke(result ? UIBackgroundFetchResult.NewData : UIBackgroundFetchResult.NoData);
                    break;

                case RemoteNotificationType.Card:
                    AppEvents.LogPushNotificationOpen(userInfo);

#if __FBNOTIFICATIONS__
                    FBNotificationsBindings.FBNotificationsManager.SharedManager()
                    .PresentPushCardForRemoteNotificationPayload(userInfo,
                                                                 null,
                                                                 (c, e) =>
                    {
                        if (e != null)
                        {
                            Logger.Log("AppDelegate.DidReceiveRemoteNotification: There was an error displaying Facebook advertising notification");
                            completionHandler?.Invoke(UIBackgroundFetchResult.Failed);
                            Logger.Log("AppDelegate.DidReceiveRemoteNotification: Invoking completion handler");
                        }
                        else
                        {
                            Logger.Log("AppDelegate.DidReceiveRemoteNotification: Facebook advertising notification displayed successfully");
                            completionHandler?.Invoke(UIBackgroundFetchResult.NewData);
                            Logger.Log("AppDelegate.DidReceiveRemoteNotification: Invoking completion handler");
                        }
                    }
                                                                 );
#else
                    Logger.Log("AppDelegate.DidReceiveRemoteNotification: Invoking completion handler");
                    completionHandler?.Invoke(UIBackgroundFetchResult.NoData);
#endif
                    break;

                default:
                    Logger.Log("AppDelegate.DidReceiveRemoteNotification: Unrecognized notification type");
                    completionHandler?.Invoke(UIBackgroundFetchResult.NoData);
                    break;
                }
            }
            catch (Exception ex)
            {
                Logger.Log("ERROR: AppDelegate.DidReceiveRemoteNotification: " + ex);
                completionHandler?.Invoke(UIBackgroundFetchResult.Failed);
            }

            if (backgroundTaskId != 0)
            {
                UIApplication.SharedApplication.EndBackgroundTask(backgroundTaskId);
                backgroundTaskId = 0;
            }

            Logger.Log("AppDelegate.DidReceiveRemoteNotification: Event dispatch complete");
        }