public MapMakerViewModel(MapSdk sdk)
        {
            _sdk = sdk;
            AppMessages.DialogAnwer.Register(this, MessageHandler);

            CommandSelectBitmapMap = new RelayCommand(()=> AppMessages.DialogRequest.Send(new MessageDialogRequest("SelectBitmapMap")));

            CommandSelectBitmapZ = new RelayCommand(() => AppMessages.DialogRequest.Send(new MessageDialogRequest("SelectBitmapMapZ")));

            CommandSelectOutputFolder = new RelayCommand(()=>AppMessages.DialogRequest.Send(new MessageDialogRequest("OpenFolderOutput")));

            CommandGenerateMap = new RelayCommand(()=> AppMessages.MapGeneratorMessage.Send(new MapMakeMessage(){Index = _selectedIndex}),
                ()=> !string.IsNullOrEmpty(LocationBitmapMap) &&
                     !string.IsNullOrEmpty(LocationBitmapZ) &&
            !string.IsNullOrEmpty(OutputFolder) &&
            _sdk.CollectionColorArea.List.Count>0);
            
        }
Example #2
0
        /// <summary>
        /// Initializes a new instance of the SdkView class.
        /// </summary>
        public SdkViewModel(MapSdk makeMapSdk)
            : this()
        {
            _makeMapSDK = makeMapSdk;

        }
Example #3
0
        public SdkViewModel()
        {
            if (IsInDesignMode)
            {
                //_makeMapSDK = new MakeMapSDK(@"C:\Users\Xen\Desktop\scripts-08-06-10");
                //_makeMapSDK.Populate();
            }
            else
            {
                if (_makeMapSDK == null)
                    _makeMapSDK = new MapSdk();
            }
            _transation = new TransationEditorViewModel();

            #region Commands


            #region CollectionAreaColor
            #region Commands

            CommandCollectionAreaColorRemove = new RelayCommand(() => CollectionAreaColorCommandRemoveExecuted(), () => CollectionAreaColorIsSelected());

            CommandCollectionAreaColorAdd = new RelayCommand(() => CollectionAreaColorCommandAddExecuted());

            CommandCollectionAreaColorMoveDown = new RelayCommand(() => CollectionAreaMoveCommandExecuted(-1), () => CollectionAreaColorCanMoveDown());

            CommandCollectionAreaColorMoveUp = new RelayCommand(() => CollectionAreaMoveCommandExecuted(+1), () => CollectionAreaColorCanMoveUp());

            #endregion
            #endregion

            #region Grown/Smooth Circle Commands

            CommmandRemoveGrownCircle = new RelayCommand(() => CollectionAreaColorSelected.List.Remove((CircleMountain)SelectedGrownCircle), CommandCanRemoveGrownCircle);

            CommandAddGrownCircle = new RelayCommand(CommandAddGrownCircleExecuted, CommandCanAddGrownCircle);
            
            
            CommandMoveDownGrownCircle=
                new RelayCommand(()=>
                                                     {
                                                         var selected = SelectedGrownCircle;
                                                         CollectionAreaColorSelected.List.Remove((CircleMountain)selected);
                                                         
                                                         CollectionAreaColorSelected.List.Insert(IndexGrownCircle + 1, (CircleMountain)selected);
                                                     },CommandCanMoveDownGrownCircle);

            CommandMoveUpGrownCircle =
                new RelayCommand(CommandGrownCircleMoveUpExecuted, CommandCanMoveUpGrownCircle);



            CommmandRemoveSmoothCircle = new RelayCommand(() => CollectionAreaColorSelected.CoastSmoothCircles.Remove((CircleMountain)SelectedSmoothCoast), CommandCanRemoveSmoothCircle);

            CommandAddSmoothCircle = new RelayCommand(CommandAddSmoothCircleExecuted, CommandCanAddSmoothCircle);


            CommandMoveDownSmoothCircle =
                new RelayCommand(() =>
                {
                    var selected = SelectedSmoothCoast;
                    CollectionAreaColorSelected.CoastSmoothCircles.Remove((CircleMountain)selected);

                    CollectionAreaColorSelected.CoastSmoothCircles.Insert(IndexSmoothCircle + 1, (CircleMountain)selected);
                }, CommandCanMoveDownSmoothCircle);

            CommandMoveUpSmoothCircle =
                new RelayCommand(CommandSmoothCircleMoveUpExecuted, CommandCanMoveUpSmoothCircle);

            

            #endregion //Grown/Smooth Circle Commands

            #region ContexMenu Copy&Paste

            CommandCopyColor = new RelayCommand(()=>
                                                    {
                                                        AreaColorCopied = CollectionAreaColorSelected;

                                                    },()=> CollectionAreaColorSelected != null);

            CommandCopyTexture = new RelayCommand(() =>
            {
                AreaTextureCopied = (AreaTextures)SelectedAreaTexture;

            }, () => SelectedAreaTexture as AreaTextures != null);

            #endregion //ContexMenu Copy&Paste

            #region Collection Area Textures
            CommandTextureAdd = new RelayCommand(CommandAreaTextureAddExecuted);

            CommandTextureRemove = new RelayCommand(CommandAreaTextureRemoveExecuted, CommandAreaTextureRemoveCan);

            CommandTextureTileAdd = new RelayCommand(CommandAreaTextureTileAddExecuted, CommandAreaTextureTileAddCan);

            CommandTextureTileRemove = new RelayCommand(CommandAreaTextureTileRemove, CommandAreaTextureTileRemoveCan);

            CommandTextureTileAddString = new RelayCommand(()=>
                                                               {
                                                                   var decValue = ParseStringToInt(SelectedTextureString);
                                                                 
                                                                   if(decValue != -1)
                                                                   {
                                                                       var selected = SelectedAreaTexture as AreaTextures;
                                                                       selected.List.Add(decValue);
                                                                   }
                                                               },()=>
                                                                     {
                                                                         var t = SelectedAreaTexture != null
                                                                                 &&
                                                                                 !string.IsNullOrWhiteSpace(
                                                                                     SelectedTextureString);
                                                                         if (!t) return false;
                                                                         var value = ParseStringToInt(SelectedTextureString);
                                                                         if(value < 0)
                                                                             return false;
                                                                         var selected =
                                                                             SelectedAreaTexture as AreaTextures;

                                                                         if (selected == null)
                                                                             return false;
                                                                         if (selected.List.Contains(value))
                                                                             return false;
                                                                         if (ApplicationController.manager.GetLandTile().Count() < value)
                                                                             return false;
                                                                         return true;
                                                                     });


            CommandCoastAddString = new RelayCommand(()=>
                                                         {
                                                             var value = ParseStringToInt(_stringCoast);
                                                                 switch (SelectedCoastType)
                                                                 {
                                                                     case 0:
                                                                         {
                                                                             SelectedWater.Add(value);
                                                                         }
                                                                         break;

                                                                     case 1:
                                                                         {
                                                                             SelectedGround.Add(value);
                                                                         }
                                                                         break;
                                                                 }
                                                         },()=>
                                                               {
                                                                   if (string.IsNullOrWhiteSpace(_stringCoast))
                                                                       return false;
                                                                   var value = ParseStringToInt(_stringCoast);
                                                                   if (value < 0)
                                                                       return false;
                                                                   switch (SelectedCoastType)
                                                                   {
                                                                       case 0:
                                                                           {
                                                                               if (SelectedWater == null)
                                                                                   return false;
                                                                               if (value > ApplicationController.manager.GetItemTile().Count())
                                                                                   return false;
                                                                               if (SelectedWater.Contains(value))
                                                                                   return false;
                                                                           }
                                                                           break;

                                                                       case 1:
                                                                           {
                                                                               if (value > ApplicationController.manager.GetLandTile().Count())
                                                                                   return false;
                                                                               if (SelectedGround.Contains(value))
                                                                                   return false;
                                                                           }
                                                                           break;
                                                                   }
                                                                   return true;
                                                               });
            #endregion //Collection Area Textures

            #region Collection Area item

            CommandAreaItemCollectionAdd = new RelayCommand(CommandAreaItemCollectionAddExecuted, CommandAreaItemCollectionAddCan);

            CommandAreaItemCollectionRemove = new RelayCommand(CommandAreaItemCollectionRemoveExecuted, CommandAreaItemCollectionRemoveCan);

            CommandAreaItemTileAdd = new RelayCommand(CommandAreaItemTileAddExecuted, CommandAreaItemTileAddCan);

            CommandAreaItemTileRemove = new RelayCommand(CommandAreaItemTileRemoveExecuted, CommandAreaItemTileRemoveCan);

            #endregion //Collection Area Item

            #region Coasts

            CommandCoastRemoveTile = new RelayCommand(CommandCoastRemoveTileExecuted, CommandCoastRemoveTileCan);

            CommandCoastAddTile = new RelayCommand(CommandCoastAddTileExecuted, CommandCoastAddTileCan);

            CommandCoastSetAsDefault = new RelayCommand(CommandCoastSetAsDefaultExecuted, CommandCoastSetAsDefaultCan);
            #endregion //Coasts

            #region ContexMenu Copy&Paste
            CommandPasteCoast = new RelayCommand(CommandPasteCoastExecuted, CommandCanPasteCoast);
            CommandPasteWaterCoast = new RelayCommand(CommandPasteWaterCoastExecuted, CommandCanPasteCoast);
            CommandPasteCoastSpecialOptions = new RelayCommand(CommandPasteCoastSpecialOptionsExecuted, CommandCanPasteCoast);
            CommandPasteWaterCliff = new RelayCommand(CommandPasteWaterCliffExecuted,CommandCanPasteCoast);
           
            CommandPasteCliffs = new RelayCommand(() =>
                                                      {
                                                          var cloned = (AreaColor) MapSdk.CloneSdkObject(AreaColorCopied);
                                                          CollectionAreaColorSelected.TransitionCliffTextures =
                                                              new ObservableCollection<AreaTransitionCliffTexture>(cloned.TransitionCliffTextures);
                                                          RaisePropertyChanged(null);
                                                      },
                                                  () => CollectionAreaColorSelected != null && AreaColorCopied != null);


            CommandPasteTextureTransitions = new RelayCommand(() => 
                                                 {
                                                     SelectedTextures.AreaTransitionTexture = (CollectionAreaTransitionTexture) MapSdk.CloneSdkObject(SelectedTextures.AreaTransitionTexture);
                                                     RaisePropertyChanged(null);
                                                 },()=>SelectedAreaTexture != null && AreaTextureCopied!=null);
            CommandPasteItemTransitions = new RelayCommand(() =>
            {
                SelectedTextures.CollectionAreaItems = (CollectionAreaTransitionItems) MapSdk.CloneSdkObject(SelectedTextures.CollectionAreaItems);
                RaisePropertyChanged(()=>SelectedTextures.CollectionAreaItems);

            }, () => SelectedAreaTexture != null && AreaTextureCopied != null);


            CommandPasteTextureId = new RelayCommand(() => CollectionAreaColorSelected.TextureIndex = AreaTextureCopied.Index, () => CollectionAreaColorSelected != null && AreaTextureCopied!=null);

            CommandPasteTextures=new RelayCommand(()=>
                                                      {
                                                          SelectedTextures.List=new ObservableCollection<int>();
                                                          foreach (var textureName in AreaTextureCopied.List)
                                                          {
                                                              SelectedTextures.List.Add(textureName);
                                                          }
                                                          RaisePropertyChanged(null);
                                                      },()=>SelectedTextures!=null && _copiedTexture != null);
            #endregion //ContexMenu Copy&Paste
            #endregion //Commands

            #region Save Commands
            CommandSaveAco =
                new RelayCommand
                    (
                        () => AppMessages.DialogRequest.Send(new MessageDialogRequest("ACO")),
                        () => CollectionColorArea.List.Count > 0
                    );
            CommandOpenScriptFolder =
                new RelayCommand(
                () => AppMessages.DialogRequest.Send(new MessageDialogRequest("FOLDER"))
                );

            CommandSave = new RelayCommand(() => AppMessages.DialogRequest.Send(new MessageDialogRequest("SAVE")));

            CommandFileOpen = new RelayCommand(() => AppMessages.DialogRequest.Send(new MessageDialogRequest("LOAD")));
            #endregion //Save Commands

            #region Cliffs Commands
            CommandAddCliff = new RelayCommand(() => CollectionAreaColorSelected.TransitionCliffTextures.Add(new AreaTransitionCliffTexture()), () => CollectionAreaColorSelected!=null);

            CommandDeleteCliff = new RelayCommand(() =>
            {
                try
                {
                    var cliff = SelectedCliff as AreaTransitionCliffTexture;
                    CollectionAreaColorSelected.TransitionCliffTextures.Remove(cliff);
                }
                catch (Exception e)
                {
                    AppMessages.DialogRequest.Send(new MessageDialogRequest(e.Message));
                }

            }, () => SelectedCliff != null);

            CommandAddCliffTexture = new RelayCommand(() =>
            {
                try
                {
                    var tile = SelectedTextureForCliff as IEntryTile;
                    var collection =
                        SelectedCliff as AreaTransitionCliffTexture;

                    if (tile != null)
                        if (collection != null)
                            collection.List.Add((int)tile.EntryId);
                }
                catch (Exception e)
                {
                    AppMessages.DialogRequest.Send(new MessageDialogRequest(e.Message));
                }
            
            }, () => SelectedTextureForCliff != null &&
                                                                 SelectedCliff != null && CollectionAreaColorSelected != null);

            CommandRemoveCliffTexture = new RelayCommand(() =>
            {
                try
                {
                    var number = (int)SelectedTextureInCliffList;
                    var collection =
                      SelectedCliff as AreaTransitionCliffTexture;
                    if (collection != null) collection.List.Remove(number);
                }
                catch (Exception e)
                {
                    AppMessages.DialogRequest.Send(new MessageDialogRequest(e.Message));
                }
                
               
            }, () => SelectedCliff != null && SelectedTextureInCliffList != null && CollectionAreaColorSelected != null);


            CommandAddCliffString = new RelayCommand(()=>
                                                         {
                                                             var val = ParseStringToInt(StringSelectedCliff);
                                                             var collection =
                                                                 SelectedCliff as AreaTransitionCliffTexture;
                                                             if (collection != null) collection.List.Add(val);
                                                         },()=>
                                                               {
                                                                   if (SelectedCliff == null)
                                                                       return false;
                                                                   var collection =
                                                                 SelectedCliff as AreaTransitionCliffTexture;
                                                                   if (collection == null)
                                                                       return false;
                                                                   var value = ParseStringToInt(StringSelectedCliff);
                                                                   if (value < 0) return false;
                                                                   if (value > ApplicationController.manager.GetLandTile().Count())
                                                                       return false;
                                                                   if (collection.List.Contains(value))
                                                                       return false;
                                                                   return true;
                                                               });
            #endregion //Cliff Commands


            CommandExportTransations =
                new RelayCommand(
                    () => AppMessages.DialogRequest.Send(
                        new MessageDialogRequest("OpenFileXmlExport")),
                    () => _selectedAreaColor != null
                    );

            CommandOpenOptionWindow = new RelayCommand(() => AppMessages.DialogRequest.Send(new MessageDialogRequest("OpenOptionWindow")));

            AppMessages.OptionAnswer.Register(this, HandlerOptionResults);
            AppMessages.DialogAnwer.Register(this, HandlerDialogResults);
            AppMessages.MapGeneratorMessage.Register(this, HandlerGenerateMap);

        }
 public static void CreateMapMakerView(MapSdk sdk)
 {
     if (_mapMaker == null)
     {
         _mapMaker = new MapMakerViewModel(sdk);
     }
 }