override public void Run(string[] args) { options = new CmdParserOptionSet() { { "h|help", "Display this help information. To see online help, use: git help <command>", v => OfflineHelp() }, { "q|quiet", "Quiet, suppress feedback messages", v => cmd.Quiet = false }, #if ported { "f|force", "Force checkout and ignore unmerged changes", v => { isForced = true; } }, { "ours", "For unmerged paths, checkout stage #2 from the index", v => { isOurs = true; } }, { "theirs", "For unmerged paths, checkout stage #3 from the index", v => { isTheirs = true; } }, { "b|branch=", "Create a new {branch}", (string v) => branchName = v }, { "t|track", "Set the upstream configuration", v => { isTracked = true; } }, { "no-track", "Do not set the upstream configuration", v => { isNoTrack = true; } }, { "l", "Create the new branch's reflog", v => RefLog() }, { "m|merge", "Perform a three-way merge between the current branch, your working tree contents " + "and the new branch", v => { isMerging = true; } }, { "conflict", "Same as merge above, but changes how the conflicting hunks are presented", isConflict = true }, { "p|patch", "Creates a diff and applies it in reverse order to the working tree", v => Patch() } // [Mr Happy] this should be compatible w/ the CommandStub, haven't checked yet tho. //{ "f|force", "When switching branches, proceed even if the index or the working tree differs from HEAD", v => cmd.Force = true }, //{ "ours", "When checking out paths from the index, check out stage #2 ('ours') or #3 ('theirs') for unmerged paths", v => cmd.Ours = true }, //{ "theirs", "When checking out paths from the index, check out stage #2 ('ours') or #3 ('theirs') for unmerged paths", v => cmd.Theirs = true }, //{ "b=", "Create a new branch named <new_branch> and start it at <start_point>; see linkgit:git-branch[1] for details", v => cmd.B = v }, //{ "t|track", "When creating a new branch, set up "upstream" configuration", v => cmd.Track = true }, //{ "no-track", "Do not set up "upstream" configuration, even if the branch", v => cmd.NoTrack = true }, //{ "l", "Create the new branch's reflog; see linkgit:git-branch[1] for details", v => cmd.L = true }, //{ "m|merge", "When switching branches, if you have local modifications to one or more files that are different between the current branch and the branch to which you are switching, the command refuses to switch branches in order to preserve your modifications in context", v => cmd.Merge = true }, //{ "conflict=", "The same as --merge option above, but changes the way the conflicting hunks are presented, overriding the merge", v => cmd.Conflict = v }, //{ "p|patch", "Interactively select hunks in the difference between the <tree-ish> (or the index, if unspecified) and the working tree", v => cmd.Patch = true }, #endif }; try { List <String> arguments = ParseOptions(args); if ((arguments.Count > 0) || (args.Length <= 0)) { //Checkout the new repository cmd.Arguments = arguments; cmd.Execute(); if (!cmd.Quiet) { //Display FileNotFound errors, but process checkout request for all found files first. foreach (string file in cmd.Results.FileNotFoundList) { OutputStream.WriteLine("error: pathspec '" + file + "' did not match any file(s) known to GitSharp."); } } } else { OfflineHelp(); } } catch (OptionException e) { Console.WriteLine(e.Message); } }
public ServiceWizardViewModel(PanaceaServices core, TaskCompletionSource <bool> source) { _core = core; _source = source; SelectedItems = new ObservableCollection <Service>(); RemoveServiceCommand = new RelayCommand(args => { SelectedItems.Remove(args as Service); if (!SelectedItems.Any()) { CartBoxIsOpen = false; } }); SwitchToServicesCommand = new RelayCommand(args => { if (SelectedIndex == 0) { SelectedIndex = 1; } else { SelectedIndex = 0; } }); BuyServiceCommand = new RelayCommand(arg => { SelectedItems.Clear(); TabsSelectedIndex = 0; }); CompleteCommand = new RelayCommand(arg => { source.TrySetResult(true); }); ToggleCartBoxCommand = new RelayCommand(arg => { CartBoxIsOpen = !CartBoxIsOpen; }); CheckoutCommand = new RelayCommand(async args => { if (Packages != null && Packages.Any(p => p.IsChecked) || Services != null && Services.Any(s => s.IsChecked)) { CartBoxIsOpen = false; if (core.UserService.User.Id == null) { if (core.TryGetUserAccountManager(out IUserAccountManager account)) { _waitingForAnotherTask = true; if (await account.RequestLoginAsync("In order to continue, you need to sign in with your user account")) { _waitingForAnotherTask = false; TabsSelectedIndex = 1; CreateWebBrowser(); BuyService(); } } //todo TabsSelectedIndex = 1; } else { var pop = new UserConfirmationViewModel(_core.UserService.User); if (_core.TryGetUiManager(out IUiManager ui)) { var res = await ui.ShowPopup(pop); if (res == UserConfirmationResult.Confirm) { TabsSelectedIndex = 1; CreateWebBrowser(); BuyService(); //CheckUserService(() => //{ // }); } else if (res == UserConfirmationResult.NotMe) { if (!(_core.TryGetUserAccountManager(out IUserAccountManager user) && await user.LogoutAsync())) { await _core.UserService.LogoutAsync(); //todo (true) } CheckoutCommand.Execute(null); } else { CartBoxIsOpen = true; } } } } else { if (core.TryGetUiManager(out IUiManager ui)) { await ui.ShowPopup(new NoServiceSelectedPopupViewModel()); } } }); SelectCommand = new RelayCommand(args => { var package = args as Service; if (package == null) { return; } CancelButtonVisibility = Visibility.Collapsed; CancelButtonServicesVisibility = Visibility.Visible; if (package is Package) { CancelButtonVisibility = Visibility.Visible; CancelButtonServicesVisibility = Visibility.Collapsed; SelectedItems.Clear(); Packages.ForEach(lp => lp.IsChecked = false); Services.ForEach(lp => lp.IsChecked = false); package.IsChecked = true; } else if (SelectedItems.Any(i => i is Package)) { SelectedItems.Clear(); Packages.ForEach(lp => lp.IsChecked = false); Services.ForEach(lp => lp.IsChecked = false); package.IsChecked = true; } if (SelectedItems.Contains(package)) { SelectedItems.Remove(package); package.IsChecked = false; CartBoxIsOpen = SelectedItems.Count > 0; HasSelectedPerDay = SelectedItems.All(i => i.IsPricePerDay); UpdateSum(); TotalPanelVisibility = SelectedItems.Any(i => i.IsPricePerDay) || SelectedItems.Count > 1 ? Visibility.Visible : Visibility.Collapsed; return; } if ((package.IsPricePerDay && SelectedItems.Any(s => !s.IsPricePerDay)) || (!package.IsPricePerDay && SelectedItems.Any(s => s.IsPricePerDay))) { /*todo * var warning = new ChangeServiceTypeWarning(); * warning.Continue += (oo, ee) => * { * window.ThemeManager.HidePopup(warning); * SelectedItems.Clear(); * packages.ForEach(lp => lp.IsChecked = false); * services.ForEach(lp => lp.IsChecked = false); * package.IsChecked = true; * SelectedItems.Add(package); * CartBox.IsOpen = SelectedItems.Count > 0; * HasSelectedPerDay = SelectedItems.All(i => i.IsPricePerDay); * UpdateSum(); * TotalPanel.Visibility = SelectedItems.Any(i => i.IsPricePerDay) || SelectedItems.Count > 1 * ? Visibility.Visible * : Visibility.Collapsed; * }; * * warning.Cancel += (oo, ee) => * { * window.ThemeManager.HidePopup(warning); * package.IsChecked = false; * CartBox.IsOpen = SelectedItems.Count > 0; * }; * CartBoxIsOpen = false; * * window.ThemeManager.ShowPopup(warning).Closed += (oo, ee) => * { * package.IsChecked = false; * }; */ } else { SelectedItems.Add(package); CartBoxIsOpen = SelectedItems.Count > 0; HasSelectedPerDay = SelectedItems.All(i => i.IsPricePerDay); UpdateSum(); TotalPanelVisibility = SelectedItems.Any(i => i.IsPricePerDay) || SelectedItems.Count > 1 ? Visibility.Visible : Visibility.Collapsed; } }); }
public void CheckoutCommand() { var command = new CheckoutCommand(@"C:\Users\jeffr\Documents\EChest\Big Blocks\Resource Packs\FormatTest"); command.Execute(ViewModel.CheckoutCommand.Type.Branch, "test_branch"); }
/// <summary> /// 处理KEY /// </summary> /// <param name="args"></param> internal void HandleKey(KeyEventArgs args) { // 如果是功能(如上下左右,换页) if (args.Key >= Key.PageUp && args.Key <= Key.Down) { switch (args.Key) { case Key.Right: GoRight(); break; case Key.Left: GoLeft(); break; case Key.Up: GoUp(); break; case Key.Down: GoDown(); break; case Key.PageUp: GoLastPage(); break; case Key.PageDown: GoNextPage(); break; } } // 如果要增加数量或减少数量 else if (args.Key == Key.Add || args.Key == Key.Subtract || args.Key == Key.Delete) { if (CurrentSelectedListNew.Count > 0 && CurrentSelectedListNew[CurrentIndex].NavigateMode == 0) { if (args.Key == Key.Delete) { var lastIndex = CurrentIndex == 0 ? 1 : CurrentIndex; var lastPage = CurrentPage; CurrentSelectedListNew[CurrentIndex].Delete.Execute(CurrentSelectedListNew[CurrentIndex]); if (this.CurrentSelectedListNew.Count > 1 && CurrentPage == lastPage) { bool findIt = false; for (int i = CurrentSelectedListNew.Count - 1; i >= 0; i--) { if (i < lastIndex && !findIt) { findIt = true; CurrentIndex = i; CurrentSelectedListNew[i].IsNavigated = true; CurrentSelectedListNew[i].NavigateMode = 0; } else { CurrentSelectedListNew[i].IsNavigated = false; CurrentSelectedListNew[i].NavigateMode = 0; } } } //CalcAndResetPage(); } else { double count = double.Parse(CurrentSelectedListNew[CurrentIndex].CountPos); if (args.Key == Key.Add) { if (count < 99999) { CurrentSelectedListNew[CurrentIndex].CountPos = (++count).ToString(); } if (count == 0) { CurrentSelectedListNew[CurrentIndex].CountPos = (1).ToString(); } } else if (args.Key == Key.Subtract) { if (count <= 1 && Common.GetCommon().IsDecreaseProductCount()) { if (count == 1) { CurrentSelectedListNew[CurrentIndex].CountPos = (-1).ToString(); } else { CurrentSelectedListNew[CurrentIndex].CountPos = (--count).ToString(); } } if (count > 1) { CurrentSelectedListNew[CurrentIndex].CountPos = (--count).ToString(); } } } } } // 如果是改动数字 else if ((args.Key >= Key.D0 && args.Key <= Key.D9) || (args.Key >= Key.NumPad0 && args.Key <= Key.NumPad9) || args.Key == Key.OemPeriod || args.Key == Key.Decimal || args.Key == Key.Back) { if (CurrentSelectedListNew.Count > 0) { if (CurrentSelectedListNew[CurrentIndex].NavigateMode == 0) { if (args.Key == Key.Back) { string countStr = CurrentSelectedListNew[CurrentIndex].CountPos; if (countStr.Length > 1) { CurrentSelectedListNew[CurrentIndex].CountPos = countStr.Remove(countStr.Length - 1); } else { CurrentSelectedListNew[CurrentIndex].CountPos = "0"; } } else { string keyChar = Common.GetCommon().GetStrFromKey(args.Key); string[] split = CurrentSelectedListNew[CurrentIndex].CountPos.Split('.'); if (split.Length > 1) { if (keyChar == "." || split[1].Length >= 3) { return; } } else if (CurrentSelectedListNew[CurrentIndex].CountPos.Length >= 8) { return; } if (CurrentSelectedListNew[CurrentIndex].CountPos == "0" && keyChar != ".") { CurrentSelectedListNew[CurrentIndex].CountPos = keyChar; } else { CurrentSelectedListNew[CurrentIndex].CountPos += keyChar; } } } else if (CurrentSelectedListNew[CurrentIndex].NavigateMode == 1) { if (args.Key == Key.Back) { string unitPriceStr = CurrentSelectedListNew[CurrentIndex].UnitPricePos; if (unitPriceStr.Length > 1) { CurrentSelectedListNew[CurrentIndex].UnitPricePos = unitPriceStr.Remove(unitPriceStr.Length - 1); } else { CurrentSelectedListNew[CurrentIndex].UnitPricePos = "0"; } } else { string keyChar = Common.GetCommon().GetStrFromKey(args.Key); string[] split = CurrentSelectedListNew[CurrentIndex].UnitPricePos.Split('.'); if (split.Length > 1) { if (keyChar == "." || split[1].Length >= 2) { return; } } else if (CurrentSelectedListNew[CurrentIndex].UnitPricePos.Length >= 8) { return; } if (CurrentSelectedListNew[CurrentIndex].UnitPricePos == "0" && keyChar != ".") { CurrentSelectedListNew[CurrentIndex].UnitPricePos = keyChar; } else { CurrentSelectedListNew[CurrentIndex].UnitPricePos += keyChar; } } } } } else if (args.Key == Key.Enter) { // 回车结账 if (this.CurrentSelectedList.Count > 0) { CheckoutCommand.Execute(null); } } }