Пример #1
0
        /// <summary>
        /// Loads a login dialog that forces the user
        /// to log into the application before using it. If the login is
        /// successful (Meaning the DialogResult is set to
        /// OK) then the Main Form is loaded.
        /// </summary>
        /// <param name="loginForm">Login form</param>
        /// <param name="mainForm">Main form</param>
        /// <param name="enableKioskMode">Set to <c>true</c> to run the application in kiosk mode, otherwise <c>false</c></param>
        public static void RunWithLogin(MobileForm loginForm, MobileForm mainForm, bool enableKioskMode)
        {
            var loginHwnd = SystemWindow.FindWindow(loginForm.Name, loginForm.Text);
            var mainHwnd  = SystemWindow.FindWindow(mainForm.Name, mainForm.Text);

            if (loginHwnd != IntPtr.Zero || mainHwnd != IntPtr.Zero)
            {
                return;
            }

            SplashScreen.Show();

            if (enableKioskMode)
            {
                loginForm.Load += (sender, e) => ForceKioskMode(loginForm);
            }
            var dialogResult = loginForm.ShowDialog();

            if (dialogResult != DialogResult.OK)
            {
                return;
            }

            SplashScreen.Hide();
            Run(mainForm);
        }
Пример #2
0
        /// <summary>
        /// Loads a login dialog that forces the user
        /// to log into the application before using it. If the login is
        /// successful (Meaning the DialogResult is set to
        /// OK) then the Main Form is loaded.
        /// </summary>
        /// <param name="loginForm">Login form</param>
        /// <param name="enableKioskMode">Set to <c>true</c> to run the application in kiosk mode, otherwise <c>false</c></param>
        public static void RunWithLogin(MobileForm loginForm, bool enableKioskMode)
        {
            SplashScreen.Show();

            loginForm.Load += (sender, e) => ForceKioskMode(loginForm);
            using (var presenter = new SmartMenuPresenter())
            {
                var hwnd = SystemWindow.FindWindow(presenter.View.Name, presenter.View.Text);
                if (hwnd != IntPtr.Zero)
                {
                    return;
                }

                var smartMenuView = (MobileForm)presenter.View;
                if (enableKioskMode)
                {
                    ForceKioskMode(smartMenuView);
                }

                SplashScreen.Hide();

                var dialogResult = loginForm.ShowDialog();
                if (dialogResult == DialogResult.OK)
                {
                    Application.Run(smartMenuView);
                }
            }
        }
Пример #3
0
 public Mobile(MobileForm mobile)
 {
     Id          = mobile.Id;
     Name        = mobile.Name;
     Price       = mobile.Price;
     Instock     = mobile.Instock;
     Description = mobile.Description;
     ImageSource = mobile.ImageSource;
 }
Пример #4
0
        public async Task <IActionResult> Add(MobileForm form)
        {
            if (form.Id != 0)
            {
                return(BadRequest($"Can not add new mobile with Id"));
            }

            _logger.LogInformation("Create new mobile is called");

            _context.Mobiles.Add(new Mobile(form));
            await _context.SaveChangesAsync();

            return(CreatedAtAction(nameof(GetById), new { id = form.Id }, form));
        }
Пример #5
0
        public ActionResult PutMobile([FromBody] MobileForm model)
        {
            var dbModel = mobileRepository.Get(model.Id);

            if (dbModel == null)
            {
                return(NotFound());
            }

            mapper.Map <MobileForm, Mobile>(model, dbModel);
            mobileRepository.Update(dbModel);

            return(Ok());
        }
Пример #6
0
        public async Task <IActionResult> Update(MobileForm form)
        {
            var mobile = await _context.Mobiles.FindAsync(form.Id);

            if (mobile == null)
            {
                return(NotFound("Not found mobile to update"));
            }

            _logger.LogInformation("Update a mobile is called");
            _context.Entry(mobile).State = EntityState.Modified;

            await _context.SaveChangesAsync();

            return(CreatedAtAction(nameof(GetById), new { id = form.Id }, form));
        }
Пример #7
0
        /// <summary>
        /// Begins running a standard application message loop on the current
        /// thread, and makes the specified form visible.
        /// </summary>
        /// <param name="form">
        /// A <see cref="MobileForm"/> that represents the main form of the
        /// application to make visible.
        /// </param>
        /// <param name="enableKioskMode">Set to <c>true</c> to run the application in kiosk mode, otherwise <c>false</c></param>
        public static void Run(MobileForm form, bool enableKioskMode)
        {
            var hwnd = SystemWindow.FindWindow(form.Name, form.Text);

            if (hwnd != IntPtr.Zero)
            {
                return;
            }

            form.Load += delegate
            {
                if (enableKioskMode)
                {
                    ForceKioskMode(form);
                }
                SplashScreen.Hide();
            };

            Application.Run(form);
        }
Пример #8
0
        public ActionResult CreateMobile([FromBody] MobileForm model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }
            Mobile dbModel = mapper.Map <Mobile>(model);

            dbModel.VideoThumb = UploadFile(model.Video);
            foreach (var pic in model.Pictures)
            {
                dbModel.MobilePictures.Add(new MobilePictures()
                {
                    MobileId = model.Id, Thumb = UploadFile(pic)
                });
            }

            mobileRepository.Create(dbModel);

            return(Ok());
        }
Пример #9
0
        private void iconMenuView1_ItemPress(object sender, IconMenuViewItemPressEventArgs e)
        {
            MobileForm demoForm = Activator.CreateInstance((Type)e.Item.Tag) as MobileForm;

            this.Show(demoForm);
        }
Пример #10
0
 /// <summary>
 /// Begins running a standard application message loop on the current
 /// thread, and makes the specified form visible.
 /// </summary>
 /// <param name="form">
 /// A <see cref="MobileForm"/> that represents the main form of the
 /// application to make visible.
 /// </param>
 public static void Run(MobileForm form)
 {
     Run(form, false);
 }
Пример #11
0
 /// <summary>
 /// Loads a login dialog that forces the user
 /// to log into the application before using it. If the login is
 /// successful (Meaning the DialogResult is set to
 /// OK) then the Main Form is loaded.
 /// </summary>
 /// <param name="loginForm">Login form</param>
 /// <param name="mainForm">Main form</param>
 public static void RunWithLogin(MobileForm loginForm, MobileForm mainForm)
 {
     RunWithLogin(loginForm, mainForm, false);
 }