Beispiel #1
0
        public FightersList()
        {
            _editableData = new FighterData();

            Fighters         = new ObservableCollection <FighterData>();
            FilteredFighters = new ObservableCollection <FighterData>();
            Fighters.Add(new FighterData());
            Fighters.Add(new FighterData());
            Fighters.Add(new FighterData());

            SelectedCity = SelectedClub = "*";
            ApplyFilter();

            _addCmd  = new AddCmd(this);
            _delCmd  = new DeleteCmd(this);
            _saveCmd = new SaveCmd(this);
            _loadCmd = new LoadCmd(this);

            Clubs  = new ObservableCollection <string> {
            };
            Cities = new ObservableCollection <string> {
            };
            Fighters.CollectionChanged += UpdateClubs;
            Fighters.CollectionChanged += UpdateCities;

            UpdateCities(this, null);
            UpdateClubs(this, null);
        }
Beispiel #2
0
 void ExecCancel()
 {
     if (AddMode)
     {
         AddMode = false;
         AddCmd.RaiseCanExecuteChanged();
         RemoveCmd.RaiseCanExecuteChanged();
         NormalUIState();
         if (Temp != null)
         {
             SelectedItem = Temp;
             Temp         = null;
         }
         else
         {
             CurrentObject = null;
         }
         return;
     }
     if (EditMode)
     {
         EditMode = false;
         AddCmd.RaiseCanExecuteChanged();
         RemoveCmd.RaiseCanExecuteChanged();
         NormalUIState();
         _dataService.GetPartition(SelectedItem.Id, (data, error) =>
         {
             if (error != null)
             {
                 return;
             }                                   // Report error here
             CurrentObject = data;
         });
     }
 }
Beispiel #3
0
 void ExecEdit()
 {
     if (SelectedItem != null)
     {
         EditMode = true;
         AddCmd.RaiseCanExecuteChanged();
         RemoveCmd.RaiseCanExecuteChanged();
         AddUIState();
         MessengerInstance.Send("focus", "PartitionFocus");
     }
 }
Beispiel #4
0
 public void Add(int value)
 {
     AddUndo(new CommandLog
     {
         Type  = CommandType.Add,
         Value = value
     });
     RedoList.Clear();
     sum = AddCmd.Execute(sum, value);
     System.Console.WriteLine("Execute Add({0}), result is : {1}", value, sum);
     RedoList.Clear();
 }
Beispiel #5
0
        public override string createEntry(string _name, string type)
        {
            int         parent = -1;
            UndoableCmd cmd1   = new EditCmd(node);

            if (_name != null)                                                           //点击文件夹创建
            {
                parent = MemoryInterface.getInstance().getInodeIndexByName(node, _name); //选中文件夹为父目录
            }
            else                                                                         //直接新建
            {
                parent = node;                                                           //当前目录为父目录
            }

            List <int> nodeLoc  = MemoryInterface.getInstance().getRequireInodes(1);      //找到未使用的inode节点
            List <int> blockLoc = MemoryInterface.getInstance().getRequireBlocks(1);      //找到空闲磁盘块


            if (nodeLoc == null || blockLoc == null)        //inodeMap或blockMap用尽
            {
                return(null);
            }
            string name = null;

            if (type.Equals("文件夹"))
            {
                name = initDir(blockLoc, parent, nodeLoc[0]);
                entries.Add(new Directory(nodeLoc[0], name));
            }
            else
            {
                name = "新建文件";
                name = MemoryInterface.getInstance().addNewInodeTableItem(MemoryInterface.getInstance().getInodeByIndex(parent).getBlock(0), name, nodeLoc[0]);
                inode temp = MemoryInterface.getInstance().getInodeByIndex(nodeLoc[0]);
                temp.init(nodeLoc[0], blockLoc, "文件", DateTime.Now);
                entries.Add(new File(temp, name));
            }
            UndoableCmd cmd2 = new AddCmd(nodeLoc[0]);
            CompoundCmd cmd3 = new CompoundCmd();

            cmd3.newOpe(cmd1);
            cmd3.newOpe(cmd2);
            UndoManager.getInstance().newOpe(cmd3);
            MemoryInterface.getInstance().write();

            return(name);
        }
Beispiel #6
0
        public void Redo()
        {
            var cmdCnt = GetRedoCount();

            if (cmdCnt < 1)
            {
                System.Console.WriteLine("Not found redo.");
            }
            else
            {
                var log = GetRedo(cmdCnt);
                if (log != null)
                {
                    if ((log.Type == CommandType.Add || log.Type == CommandType.AddUndo || log.Type == CommandType.AddRedo) && AddCmd != null)
                    {
                        RemoveRedo();
                        AddUndo(new CommandLog
                        {
                            Type  = CommandType.AddRedo,
                            Value = log.Value
                        });
                        sum = AddCmd.Redo(sum, log.Value);
                        System.Console.WriteLine("Execute redo, result is : {0}", sum);
                    }
                    else if ((log.Type == CommandType.Minus || log.Type == CommandType.MinusUndo || log.Type == CommandType.MinusRedo) && MinusCmd != null)
                    {
                        RemoveRedo();
                        AddUndo(new CommandLog
                        {
                            Type  = CommandType.MinusRedo,
                            Value = log.Value
                        });
                        sum = MinusCmd.Redo(sum, log.Value);
                        System.Console.WriteLine("Execute redo, result is : {0}", sum);
                    }
                    else
                    {
                        System.Console.WriteLine("Invalid redo.");
                    }
                }
                else
                {
                    System.Console.WriteLine("You have no valid undo.");
                }
            }
        }
Beispiel #7
0
        void ExecSave()
        {
            int i = 0;

            if (AddMode)
            {
                AddMode = false;
                AddCmd.RaiseCanExecuteChanged();
                RemoveCmd.RaiseCanExecuteChanged();
                _dataService.UpdatePartition(CurrentObject, (data, error) =>
                {
                    if (error != null)
                    {
                        return;
                    }                              // Report error here
                    i = data;
                });
                Partitions.Add(CurrentObject);
                SelectedItem = CurrentObject;
                NormalUIState();
                MessengerInstance.Send(SelectedItem, AppContext.PartitionAddedMsg);
                return;
            }
            if (EditMode)
            {
                EditMode = false;
                AddCmd.RaiseCanExecuteChanged();
                RemoveCmd.RaiseCanExecuteChanged();
                _dataService.UpdatePartition(CurrentObject, (data, error) =>
                {
                    if (error != null)
                    {
                        return;
                    }                              // Report error here
                    i = data;
                });

                int ix = Partitions.IndexOf(SelectedItem);
                Partitions[ix] = CurrentObject;
                SelectedItem   = CurrentObject;

                NormalUIState();
                MessengerInstance.Send(SelectedItem, AppContext.PartitionChangedMsg);
                return;
            }
        }
        public DataAnalysisVM(BaseEntity entityToFocusOn, string dbcontextName) : base(dbcontextName)
        {
            //commands
            GoToEntityCmd = new GoToEntityCmd(this);
            RemoveCmd     = new RemoveCmd(this);
            AddCmd        = new AddCmd(this);

            //initialize
            UpdateHeader();
            try
            {
                User     = (Lecturer)App.AppUser;
                UserRole = Role.Lecturer;
                rowLimit = 30;
                Groups   = new ObservableCollection <Group>(UnitOfWork.GroupRepository.GetTopXFromSearch(GroupSearchTxt, rowLimit));
                if (entityToFocusOn is Group)
                {
                    SelectedGroup = UnitOfWork.GroupRepository.Get(entityToFocusOn.Id);
                }
                else if (entityToFocusOn is Session)
                {
                    Session session = (Session)entityToFocusOn;
                    SelectedGroup = UnitOfWork.GroupRepository.Get(session.Group.Id);
                    if (SelectedGroup != null)
                    {
                        SelectedSession = UnitOfWork.SessionRepository.Get(entityToFocusOn.Id);
                    }
                }
                //Register for pooling update signals
                Mediator.Register(MediatorChannels.PoolingUpdate.ToString(), PoolingUpdate);
            }
            catch (Exception ex)
            {
                ShowFeedback(ex.Message, FeedbackType.Error);
            }
        }
Beispiel #9
0
        internal static void Register(CommandLineApplication app,
                                      Func <ILogger> getLogger)
        {
            app.Command("add", AddCmd =>
            {
                AddCmd.Command("source", SourceCmd =>
                {
                    CommandArgument Source = SourceCmd.Argument(
                        "PackageSourcePath", Strings.SourcesCommandSourceDescription);
                    CommandOption name = SourceCmd.Option(
                        "-n|--name",
                        Strings.SourcesCommandNameDescription,
                        CommandOptionType.SingleValue);
                    CommandOption username = SourceCmd.Option(
                        "-u|--username",
                        Strings.SourcesCommandUserNameDescription,
                        CommandOptionType.SingleValue);
                    CommandOption password = SourceCmd.Option(
                        "-p|--password",
                        Strings.SourcesCommandPasswordDescription,
                        CommandOptionType.SingleValue);
                    CommandOption storePasswordInClearText = SourceCmd.Option(
                        "--store-password-in-clear-text",
                        Strings.SourcesCommandStorePasswordInClearTextDescription,
                        CommandOptionType.NoValue);
                    CommandOption validAuthenticationTypes = SourceCmd.Option(
                        "--valid-authentication-types",
                        Strings.SourcesCommandValidAuthenticationTypesDescription,
                        CommandOptionType.SingleValue);
                    CommandOption configfile = SourceCmd.Option(
                        "--configfile",
                        Strings.Option_ConfigFile,
                        CommandOptionType.SingleValue);
                    SourceCmd.HelpOption("-h|--help");
                    SourceCmd.Description = Strings.AddSourceCommandDescription;
                    SourceCmd.OnExecute(() =>
                    {
                        var args = new AddSourceArgs()
                        {
                            Source   = Source.Value,
                            Name     = name.Value(),
                            Username = username.Value(),
                            Password = password.Value(),
                            StorePasswordInClearText = storePasswordInClearText.HasValue(),
                            ValidAuthenticationTypes = validAuthenticationTypes.Value(),
                            Configfile = configfile.Value(),
                        };

                        AddSourceRunner.Run(args, getLogger);
                        return(0);
                    });
                });
                AddCmd.HelpOption("-h|--help");
                AddCmd.Description = Strings.Add_Description;
                AddCmd.OnExecute(() =>
                {
                    app.ShowHelp("add");
                    return(0);
                });
            });
        }
 public int Add(FAKategorie faKategorie)
 {
     FillCommandParameter(AddCmd, faKategorie);
     faKategorie.FAKategorieId = (int)AddCmd.ExecuteScalar();
     return(faKategorie.FAKategorieId);
 }
        internal static void Register(CommandLineApplication app,
                                      Func <ILogger> getLogger)
        {
            app.Command("add", AddCmd =>
            {
                AddCmd.Command("source", SourceCmd =>
                {
                    CommandArgument Source = SourceCmd.Argument(
                        "PackageSourcePath", Strings.SourcesCommandSourceDescription);
                    CommandOption name = SourceCmd.Option(
                        "-n|--name",
                        Strings.SourcesCommandNameDescription,
                        CommandOptionType.SingleValue);
                    CommandOption username = SourceCmd.Option(
                        "-u|--username",
                        Strings.SourcesCommandUsernameDescription,
                        CommandOptionType.SingleValue);
                    CommandOption password = SourceCmd.Option(
                        "-p|--password",
                        Strings.SourcesCommandPasswordDescription,
                        CommandOptionType.SingleValue);
                    CommandOption storePasswordInClearText = SourceCmd.Option(
                        "--store-password-in-clear-text",
                        Strings.SourcesCommandStorePasswordInClearTextDescription,
                        CommandOptionType.NoValue);
                    CommandOption validAuthenticationTypes = SourceCmd.Option(
                        "--valid-authentication-types",
                        Strings.SourcesCommandValidAuthenticationTypesDescription,
                        CommandOptionType.SingleValue);
                    CommandOption configfile = SourceCmd.Option(
                        "--configfile",
                        Strings.Option_ConfigFile,
                        CommandOptionType.SingleValue);
                    SourceCmd.HelpOption("-h|--help");
                    SourceCmd.Description = Strings.AddSourceCommandDescription;
                    SourceCmd.OnExecute(() =>
                    {
                        var args = new AddSourceArgs()
                        {
                            Source   = Source.Value,
                            Name     = name.Value(),
                            Username = username.Value(),
                            Password = password.Value(),
                            StorePasswordInClearText = storePasswordInClearText.HasValue(),
                            ValidAuthenticationTypes = validAuthenticationTypes.Value(),
                            Configfile = configfile.Value(),
                        };

                        AddSourceRunner.Run(args, getLogger);
                        return(0);
                    });
                });
                AddCmd.Command("client-cert", ClientCertCmd =>
                {
                    CommandOption packagesource = ClientCertCmd.Option(
                        "-s|--package-source",
                        Strings.Option_PackageSource,
                        CommandOptionType.SingleValue);
                    CommandOption path = ClientCertCmd.Option(
                        "--path",
                        Strings.Option_Path,
                        CommandOptionType.SingleValue);
                    CommandOption password = ClientCertCmd.Option(
                        "--password",
                        Strings.Option_Password,
                        CommandOptionType.SingleValue);
                    CommandOption storepasswordincleartext = ClientCertCmd.Option(
                        "--store-password-in-clear-text",
                        Strings.Option_StorePasswordInClearText,
                        CommandOptionType.NoValue);
                    CommandOption storelocation = ClientCertCmd.Option(
                        "--store-location",
                        Strings.Option_StoreLocation,
                        CommandOptionType.SingleValue);
                    CommandOption storename = ClientCertCmd.Option(
                        "--store-name",
                        Strings.Option_StoreName,
                        CommandOptionType.SingleValue);
                    CommandOption findby = ClientCertCmd.Option(
                        "--find-by",
                        Strings.Option_FindBy,
                        CommandOptionType.SingleValue);
                    CommandOption findvalue = ClientCertCmd.Option(
                        "--find-value",
                        Strings.Option_FindValue,
                        CommandOptionType.SingleValue);
                    CommandOption force = ClientCertCmd.Option(
                        "-f|--force",
                        Strings.Option_Force,
                        CommandOptionType.NoValue);
                    CommandOption configfile = ClientCertCmd.Option(
                        "--configfile",
                        Strings.Option_ConfigFile,
                        CommandOptionType.SingleValue);
                    ClientCertCmd.HelpOption("-h|--help");
                    ClientCertCmd.Description = Strings.AddClientCertCommandDescription;
                    ClientCertCmd.OnExecute(() =>
                    {
                        var args = new AddClientCertArgs()
                        {
                            PackageSource            = packagesource.Value(),
                            Path                     = path.Value(),
                            Password                 = password.Value(),
                            StorePasswordInClearText = storepasswordincleartext.HasValue(),
                            StoreLocation            = storelocation.Value(),
                            StoreName                = storename.Value(),
                            FindBy                   = findby.Value(),
                            FindValue                = findvalue.Value(),
                            Force                    = force.HasValue(),
                            Configfile               = configfile.Value(),
                        };

                        AddClientCertRunner.Run(args, getLogger);
                        return(0);
                    });
                });
                AddCmd.HelpOption("-h|--help");
                AddCmd.Description = Strings.Add_Description;
                AddCmd.OnExecute(() =>
                {
                    app.ShowHelp("add");
                    return(0);
                });
            });
        }
Beispiel #12
0
        private void _addNode(ProtocolNode parent, ProtocolNode childNode)
        {
            AddCmd cmd = new AddCmd(parent, childNode);

            cmd.Execute();
        }