Exemplo n.º 1
0
        private void OpenButton_Click(object sender, RoutedEventArgs e)
        {
            // we need to begin edit to force addition of new row
            DataGrid.BeginEdit();
#if SILVERLIGHT
            BatchCharacter batchCharacter = (BatchCharacter)DataGrid.SelectedItem;
#else
            BatchCharacter batchCharacter = (BatchCharacter)DataGrid.CurrentItem;
#endif

            OpenFileDialog dialog = new OpenFileDialog();
#if !SILVERLIGHT
            dialog.DefaultExt = ".xml";
#endif
            dialog.Filter      = "Rawr Xml Character Files | *.xml";
            dialog.Multiselect = false;
            if (dialog.ShowDialog().GetValueOrDefault())
            {
#if SILVERLIGHT
                batchCharacter.RelativePath = dialog.File.Name;
                using (StreamReader reader = dialog.File.OpenText())
                {
                    batchCharacter.Character = Character.LoadFromXml(reader.ReadToEnd());
                }
#else
                batchCharacter.RelativePath = RelativePath(dialog.FileName, AppDomain.CurrentDomain.BaseDirectory);
#endif
            }
        }
Exemplo n.º 2
0
 public void BatchCharacterSaved(BatchCharacter character)
 {
     if (_batchCharacter == character)
     {
         //_unsavedChanges = false;
         //SetTitle();
     }
 }
Exemplo n.º 3
0
        private void ShowButton_Click(object sender, RoutedEventArgs e)
        {
#if SILVERLIGHT
            BatchCharacter batchCharacter = (BatchCharacter)DataGrid.SelectedItem;
#else
            BatchCharacter batchCharacter = (BatchCharacter)DataGrid.CurrentItem;
#endif
            MainPage.Instance.LoadBatchCharacter(batchCharacter);
            App.Current.ShowWindow(MainPage.Instance);
        }
Exemplo n.º 4
0
 public void UnloadBatchCharacter()
 {
     if (_batchCharacter != null)
     {
         _batchCharacter = null;
         //_characterPath = _storedCharacterPath;
         //LoadCharacterIntoForm(_storedCharacter, _storedUnsavedChanged);
         Character        = _storedCharacter;
         _storedCharacter = null;
     }
 }
Exemplo n.º 5
0
 private void ButtonUp_Click(object sender, RoutedEventArgs e)
 {
     if (DataGrid.SelectedItems.Count == 1)
     {
         int index = DataGrid.SelectedIndex;
         if (index > 0)
         {
             BatchCharacter b = batchTools.BatchCharacterList[index - 1];
             batchTools.BatchCharacterList.RemoveAt(index - 1);
             batchTools.BatchCharacterList.Insert(index, b);
             DataGrid_SelectionChanged(null, null);
         }
     }
 }
Exemplo n.º 6
0
 public void LoadBatchCharacter(BatchCharacter character)
 {
     if (character.Character != null)
     {
         if (_batchCharacter == null)
         {
             _storedCharacter = this.character;
             //_storedCharacterPath = _characterPath;
             //_storedUnsavedChanged = _unsavedChanges;
         }
         _batchCharacter = character;
         //_characterPath = character.AbsulutePath;
         EnsureItemsLoaded(character.Character.GetAllEquippedAndAvailableGearIds());
         //LoadCharacterIntoForm(character.Character, character.UnsavedChanges);
         Character = character.Character;
     }
 }
Exemplo n.º 7
0
        private void DiffButton_Click(object sender, RoutedEventArgs e)
        {
#if SILVERLIGHT
            BatchCharacter character = (BatchCharacter)DataGrid.SelectedItem;
#else
            BatchCharacter character = (BatchCharacter)DataGrid.CurrentItem;
#endif
            Character before;
#if SILVERLIGHT
            before = character.OriginalCharacter;
#else
            using (StreamReader reader = new StreamReader(character.AbsolutePath))
            {
                before = Character.LoadFromXml(reader.ReadToEnd());                 // load clean version for comparison
            }
#endif
            Character after = character.Character;

            OptimizerResults results = new OptimizerResults(before, after, false);
            results.Closed += (object csender, EventArgs ce) =>
            {
                if (!results.DialogResult.GetValueOrDefault())
                {
                    // we don't want the new character, reload the old one
                    Character _character = character.Character;
                    _character.IsLoading = true;
                    _character.SetItems(before);
                    _character.ActiveBuffs = before.ActiveBuffs;
                    //_character.CurrentTalents = before.CurrentTalents; // let's not play with talents for now
                    _character.IsLoading = false;
                    _character.OnCalculationsInvalidated();
                    character.UnsavedChanges = false;                             // reset the dirty flag and update ui
                }
            };
            //results.SetOptimizerScores(character.Score, character.NewScore.GetValueOrDefault(character.Score));
            results.Show();
        }
Exemplo n.º 8
0
 public void UnloadBatchCharacter()
 {
     if (_batchCharacter != null)
     {
         _batchCharacter = null;
         lastSavedPath = _storedLastSavedPath;
         _unsavedChanges = _storedUnsavedChanged;
         Character = _storedCharacter;
         _storedCharacter = null;
         SetTitle();
     }
 }
Exemplo n.º 9
0
 public void LoadBatchCharacter(BatchCharacter character)
 {
     if (character.Character != null)
     {
         if (_batchCharacter == null)
         {
             _storedCharacter = this.character;
             _storedLastSavedPath = lastSavedPath;
             _storedUnsavedChanged = _unsavedChanges;
         }
         _batchCharacter = character;
         lastSavedPath = character.AbsolutePath;
         _unsavedChanges = character.UnsavedChanges;
         EnsureItemsLoaded(character.Character.GetAllEquippedAndAvailableGearIds());
         Character = character.Character;
         SetTitle();
     }
 }
Exemplo n.º 10
0
 public void BatchCharacterSaved(BatchCharacter character)
 {
     if (_batchCharacter == character)
     {
         _unsavedChanges = false;
         SetTitle();
     }
 }