示例#1
0
        internal override void SetChildBounds()
        {
            var location = Vector2.Zero;

            foreach (var child in UIComponents)
            {
                var extra = child.PaddingInternal.Size + child.Border.Size + child.Margin.Size;

                var defaultSize = DefaultChildSizes;
                if (defaultSize.X == 0)
                {
                    defaultSize.X = AbsolutePaddingRect.Size.X - extra.X - ExtraChildMargin.Size.X;
                }
                if (defaultSize.Y == 0)
                {
                    defaultSize.Y = AbsolutePaddingRect.Size.Y - extra.Y - ExtraChildMargin.Size.Y;
                }

                var size = child.Size;
                if (size.X == 0)
                {
                    size.X = defaultSize.X;
                }
                if (size.Y == 0)
                {
                    size.Y = defaultSize.Y;
                }

                size += extra;
                child.AbsoluteOuterRect = BoxHelper.FromSize(AbsolutePaddingRect.Min + location + ExtraChildMargin.Min, size);
                location.Y += size.Y + ExtraChildMargin.Size.Y; // TODO: Use X for other alignment
            }
        }
示例#2
0
        private void BtnSelect_Click(object sender, RoutedEventArgs e)
        {
            FolderBrowserDialog floderDialog = new FolderBrowserDialog
            {
                Description = App.Current.Resources["selectingLineFlashPackageDesc"].ToString()
            };

            if (floderDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                var floderInfo = new LineFlashPackageParser(floderDialog.SelectedPath)
                {
                    DescSetter = (batname) =>
                    {
                        return(App.Current.Resources["mfb" + batname]?.ToString() ?? batname);
                    }
                }.Parse();
                if (floderInfo.IsRight)
                {
                    TBFilePath.Text = floderDialog.SelectedPath;
                    ChangeState(State.Ready);
                    CBFlashType.ItemsSource   = floderInfo.Bats;
                    CBFlashType.SelectedIndex = 0;
                }
                else if (!floderInfo.PathIsRight)
                {
                    BoxHelper.ShowMessageDialog("Warning", "msgPathError");
                }
                else
                {
                    BoxHelper.ShowMessageDialog("Warning", "msgPlzSelectARightFloder");
                }
            }
        }
        private void FlowFinished(object sender, FinishedEventArgs <FlowResult> e)
        {
            this.Dispatcher.Invoke(() =>
            {
                switch (sender.GetType().Name)
                {
                case nameof(IslandActivator):
                case nameof(IceBoxActivator):
                case nameof(StopAppActivator):
                case nameof(AirForzenActivator):
                case nameof(BlackHoleActivator):
                case nameof(AnzenbokusuActivator):
                case nameof(FreezeYouActivator):
                case nameof(AnzenbokusuFakeActivator):
                case nameof(UsersirActivator):
                    DevicesOwnerSetted((DeviceOwnerSetter)sender, (DeviceOwnerSetterResult)e.Result);
                    break;

                case nameof(RecoveryFlasher):
                    BoxHelper.ShowMessageDialog("Notice", "msgFlashOK");
                    break;

                case nameof(FilePusher):
                    PushFinished((AdvanceResult)e.Result);
                    break;

                default:
                    new FlowResultWindow(e.Result).ShowDialog();
                    break;
                }
            });
        }
 public void ShowLoadingWindow(Context context, ICompletable completable)
 {
     App.Current.Dispatcher.Invoke(() =>
     {
         BoxHelper.ShowLoadingDialog(completable);
     });
 }
示例#5
0
        public override bool Check(DeviceBasicInfo targetDevice)
        {
            Logger.Debug(this, "android version checking");
            Version result = new Version(1, 0);

            Task.Run(() =>
            {
                Thread.Sleep(1000);
                result = new DeviceBuildPropGetter(targetDevice.Serial).GetAndroidVersion();
                BoxHelper.CloseLoadingDialog();
            });
            BoxHelper.ShowLoadingDialog();
            Logger.Debug(this, $"Min{version} Device{result}");
            if (result == null)
            {
                var fmt = App.Current.Resources["msgAndroidVersionCheckFailedFormat"].ToString();
                return(BoxHelper.ShowChoiceDialog(
                           "Warning", String.Format(fmt, version.ToString(3)),
                           "btnCancel", "btnContinue").ToBool());
            }
            if (result < version)
            {
                string tooLowFmt = App.Current.Resources["msgAndroidVersionTooLowFmt"].ToString();
                string msg       = String.Format(tooLowFmt, version.ToString(3));
                BoxHelper.ShowMessageDialog("Warning", msg);
                return(false);
            }
            return(true);
        }
示例#6
0
        private bool Login()
        {
            var am = App.Current.AccountManager;

            try
            {
                am.Init();
                am.AutoLogin();
                return(true);
            }
            catch (Exception ex) { Logger.Warn(this, "Auto login failed", ex); }
            App.Current.Dispatcher.Invoke(() =>
            {
                new LoginWindow(am)
                {
                    Owner = App.Current.MainWindow
                }.ShowDialog();
            });
            bool accountOk = (am.Current?.IsActivated == true && am.Current?.IsPaid == true);

            if (!accountOk)
            {
                var result = BoxHelper.ShowChoiceDialog("Warrning", "msgNotActivated", "btnExitSoftware", "btnGotoPay");
                if (result == ChoiceResult.BtnRight)
                {
                    Process.Start(App.Current.Resources["urlDvWebsite"].ToString());
                }
            }
            return(accountOk);
        }
示例#7
0
        private void ButtonStartShell_Click(object sender, RoutedEventArgs e)
        {
            ProcessStartInfo info = new ProcessStartInfo
            {
                WorkingDirectory = AdbConstants.toolsPath,
                FileName         = "cmd",
                UseShellExecute  = false,
                Verb             = "runas",
            };

            if (SystemHelper.IsWin10)
            {
                var result = BoxHelper.ShowChoiceDialog("Notice", "msgShellChoiceTip", "Powershell", "CMD");
                switch (result)
                {
                case ChoiceResult.BtnRight:
                    break;

                case ChoiceResult.BtnLeft:
                    info.FileName = "powershell.exe";
                    break;

                case ChoiceResult.BtnCancel:
                    return;
                }
            }
            Process.Start(info);
        }
        public async Task <ActionResult> Upload(HttpPostedFileBase file)
        {
            if (file != null && file.ContentLength > 0)
            {
                var fileName = file.FileName;
                using (var fs = file.InputStream)
                {
                    // Create request object with name and parent folder the file should be uploaded to
                    BoxFileRequest request = new BoxFileRequest()
                    {
                        Name   = fileName,
                        Parent = new BoxRequestEntity()
                        {
                            Id = "0"
                        }
                    };
                    string email   = this.GetCurrentUserEmail();
                    var    boxUser = await BoxHelper.GetOrCreateBoxUser(email);

                    var boxFile = await BoxHelper.UserClient(boxUser.Id).FilesManager.UploadAsync(request, fs);
                }
            }

            return(RedirectToAction("Index"));
        }
 public void ShowMessageBox(Context context, string title, string msg)
 {
     App.Current.Dispatcher.Invoke(() =>
     {
         BoxHelper.ShowMessageDialog(title, msg);
     });
 }
示例#10
0
        public void ActivateShizukuManager(DeviceBasicInfo targetDevice)
        {
            bool fixAndroidO = false;

            if (new DeviceBuildPropGetter(targetDevice.Serial).GetAndroidVersion() >= new Version("8.0.0"))
            {
                var result = BoxHelper.ShowChoiceDialog("msgNotice", "msgFixAndroidO", "btnDoNotOpen", "btnOpen");
                switch (result)
                {
                case ChoiceResult.BtnCancel:
                    return;

                case ChoiceResult.BtnLeft:
                    fixAndroidO = false;
                    break;

                case ChoiceResult.BtnRight:
                    fixAndroidO = true;
                    break;
                }
            }
            var args = new ShScriptExecuterArgs()
            {
                DevBasicInfo = targetDevice, FixAndroidOAdb = fixAndroidO
            };
            /*开始操作*/
            ShizukuManagerActivator activator = new ShizukuManagerActivator();

            activator.Init(args);
            activator.RunAsync();
            BoxHelper.ShowLoadingDialog(activator);
        }
示例#11
0
        public override void UpdateFrame()
        {
            if (Parent == null || !(Parent is UIComponent))
            {
                var size = Size;
                if (size.X == 0)
                {
                    size.X = SceneContext.Current.ScreenScaledSize.X;
                }
                if (size.Y == 0)
                {
                    size.Y = SceneContext.Current.ScreenScaledSize.Y;
                }

                var newAbsoluteOuterRect = BoxHelper.FromSize(Location, size);
                //if (newAbsoluteOuterRect == AbsoluteOuterRect) // TODO: Fix
                //    return;

                AbsoluteOuterRect = newAbsoluteOuterRect;

                CalculateSizes();
            }

            Material.UseTransparency = true; // TODO: Set only where required
        }
示例#12
0
        public async Task <ActionResult> Doc(string id)
        {
            var file = await BoxHelper.UserClient().FilesManager.GetInformationAsync(id);

            ViewBag.BoxFile = file;

            return(View());
        }
示例#13
0
 public override bool Check(DeviceBasicInfo tragetDevice)
 {
     if (!((MainWindow)App.Current.MainWindow).DevInfoPanel.CurrentDeviceIsRoot)
     {
         return(BoxHelper.ShowChoiceDialog("Warning", "warrningNeedRootAccess").ToBool());
     }
     return(true);
 }
        public async Task <ActionResult> Download(string id)
        {
            string email   = this.GetCurrentUserEmail();
            var    boxUser = await BoxHelper.GetOrCreateBoxUser(email);

            var downloadUrl = await BoxHelper.UserClient(boxUser.Id).FilesManager.GetDownloadUriAsync(id);

            return(Redirect(downloadUrl.ToString()));
        }
        public async Task <ActionResult> Preview(string id)
        {
            string email   = this.GetCurrentUserEmail();
            var    boxUser = await BoxHelper.GetOrCreateBoxUser(email);

            var previewUrl = await BoxHelper.UserClient(boxUser.Id).FilesManager.GetPreviewLinkAsync(id);

            return(Redirect(previewUrl.ToString()));
        }
        public async Task <FileStreamResult> Thumbnail(string id)
        {
            string email   = this.GetCurrentUserEmail();
            var    boxUser = await BoxHelper.GetOrCreateBoxUser(email);

            var thumbBytes = await BoxHelper.UserClient(boxUser.Id).FilesManager.GetThumbnailAsync(id, minHeight: 256, minWidth: 256, maxHeight: 256, maxWidth: 256);

            return(new FileStreamResult(thumbBytes, "image/png"));
        }
示例#17
0
            public bool?ShowChoiceBox(Context context, string title, string msg, string btnLeft = null, string btnRight = null)
            {
                bool?result = null;

                App.Current.Dispatcher.Invoke(() =>
                {
                    result = BoxHelper.ShowChoiceDialog(title, msg, btnLeft, btnRight).ToBool();
                });
                return(result);
            }
        public async Task <ActionResult> Setup()
        {
            string  email = this.GetCurrentUserEmail();
            BoxUser user  = await BoxHelper.CreateBoxUser(email);

            BoxClient userClient = BoxHelper.UserClient(user.Id);
            await BoxHelper.Setup(userClient);

            return(RedirectToAction("index", "home"));
        }
示例#19
0
        public void ActivateBlackHole(DeviceBasicInfo targetDevice)
        {
            BlackHoleActivator activator = new BlackHoleActivator();

            activator.Init(new FlowArgs()
            {
                DevBasicInfo = targetDevice
            });
            activator.RunAsync();
            BoxHelper.ShowLoadingDialog(activator);
        }
示例#20
0
        public void ActivateFreezeYou(DeviceBasicInfo targetDevice)
        {
            FreezeYouActivator activator = new FreezeYouActivator();

            activator.Init(new FlowArgs()
            {
                DevBasicInfo = targetDevice
            });
            activator.RunAsync();
            BoxHelper.ShowLoadingDialog(activator);
        }
示例#21
0
        public void ActivateGreenifyAggressiveDoze(DeviceBasicInfo targetDevice)
        {
            var activator = new GreenifyAggressiveDozeActivator();

            activator.Init(new FlowArgs()
            {
                DevBasicInfo = targetDevice
            });
            activator.RunAsync();
            BoxHelper.ShowLoadingDialog(activator);
        }
示例#22
0
        public void ActivateUsersir(DeviceBasicInfo targetDevice)
        {
            var activator = new UsersirActivator();

            activator.Init(new FlowArgs()
            {
                DevBasicInfo = targetDevice
            });
            activator.RunAsync();
            BoxHelper.ShowLoadingDialog(activator);
        }
示例#23
0
        public void DeleteScreenLock(DeviceBasicInfo targetDevice)
        {
            var screenLockDeleter = new ScreenLockDeleter();

            screenLockDeleter.Init(new FlowArgs()
            {
                DevBasicInfo = targetDevice,
            });
            screenLockDeleter.RunAsync();
            BoxHelper.ShowLoadingDialog(screenLockDeleter);
        }
示例#24
0
        // GET: App
        public async Task <ActionResult> Index()
        {
            var items = await BoxHelper.UserClient().FoldersManager.GetFolderItemsAsync("0", 100);

            ViewBag.Folders = items.Entries.Where(item => item.Type == "folder");
            ViewBag.Files   = items.Entries.Where(item => item.Type == "file");

            ViewBag.AccessToken = BoxHelper.UserToken();

            return(View());
        }
示例#25
0
        public void UnlockSystemParation(DeviceBasicInfo targetDevice)
        {
            var unlocker = new SystemPartitionUnlocker();

            unlocker.Init(new FlowArgs()
            {
                DevBasicInfo = targetDevice
            });
            unlocker.RunAsync();
            BoxHelper.ShowLoadingDialog(unlocker);
        }
示例#26
0
        public void ActivateAnzenbokusuFake(DeviceBasicInfo targetDevice)
        {
            AnzenbokusuFakeActivator activator = new AnzenbokusuFakeActivator();

            activator.Init(new FlowArgs()
            {
                DevBasicInfo = targetDevice
            });
            activator.RunAsync();
            BoxHelper.ShowLoadingDialog(activator);
        }
示例#27
0
        public void ActivateIceBox(DeviceBasicInfo targetDevice)
        {
            IceBoxActivator iceBoxActivator = new IceBoxActivator();

            iceBoxActivator.Init(new FlowArgs()
            {
                DevBasicInfo = targetDevice
            });
            iceBoxActivator.RunAsync();
            BoxHelper.ShowLoadingDialog(iceBoxActivator);
        }
示例#28
0
        public void ActivateAirForzen(DeviceBasicInfo targetDevice)
        {
            AirForzenActivator airForzenActivator = new AirForzenActivator();

            airForzenActivator.Init(new FlowArgs()
            {
                DevBasicInfo = targetDevice
            });
            airForzenActivator.RunAsync();
            BoxHelper.ShowLoadingDialog(airForzenActivator);
        }
 private void PushFinished(AdvanceResult result)
 {
     if (result.ResultType == ResultType.Successful)
     {
         BoxHelper.ShowMessageDialog("Notice", "msgPushOK");
     }
     else
     {
         new FlowResultWindow(result).ShowDialog();
     }
 }
        public async Task <ActionResult> Doc(string id)
        {
            string email   = this.GetCurrentUserEmail();
            var    boxUser = await BoxHelper.GetOrCreateBoxUser(email);

            var file = await BoxHelper.UserClient(boxUser.Id).FilesManager.GetInformationAsync(id);

            ViewBag.BoxFile = file;

            return(View());
        }
示例#31
0
        public BoxBackend(string url, Dictionary<string, string> options)
        {
            var uri = new Utility.Uri(url);

            m_path = uri.HostAndPath;
            if (!m_path.EndsWith("/"))
                m_path += "/";
            
            string authid = null;
            if (options.ContainsKey(AUTHID_OPTION))
                authid = options[AUTHID_OPTION];

            m_deleteFromTrash = Library.Utility.Utility.ParseBoolOption(options, REALLY_DELETE_OPTION);

            m_oauth = new BoxHelper(authid);
        }