예제 #1
0
 private void OnExportClick(CommandBarButton Ctrl, ref bool CancelDefault)
 {
     using (var command = new ExportCommand(base.IDE))
     {
         command.Execute();
     }
 }
예제 #2
0
        public void LoadCommands()
        {
            ResetFilterCommand = new RelayCommand(parameter =>
            {
                FilterText = string.Empty;
            });

            LoadModalCommand = new RelayCommand(parameter =>
            {
                if (parameter == null)
                {
                    return;
                }

                ModalPage page;
                if (Enum.TryParse(parameter.ToString(), out page))
                {
                    if (page != ModalPage.None)
                    {
                        SelectedModalPage = page;
                        IsModalVisible    = true;
                    }

                    ExportCode = string.Empty;

                    if (page == ModalPage.Export)
                    {
                        ExportCommand.Execute(parameter);
                    }
                }

                Logger.Log("Selecting modal content... {0}", parameter.ToString());
            });

            CloseModalCommand = new RelayCommand(parameter =>
            {
                IsModalVisible = false;
            });

            ImportCommand = new RelayCommand(parameter =>
            {
                Logger.Log("Importing ItemList...");

                var oldSlected = _selectedItems.Count;

                ImportFromCode(ExportCode);

                Logger.Log("Selected Before = {0} After = {1}", oldSlected, _selectedItems.Count);

                IsModalVisible = false;
            });

            ExportCommand = new RelayCommand(parameter =>
            {
                Logger.Log("Exporting ItemList... {0}", parameter);
                ExportCode = CreateExportCode();
            });
        }
        public void ProjectExport_Execute_ReturnsNotFoundMessage()
        {
            var command = new ExportCommand(_console, LoggerMock.GetLogger <ExportCommand>().Object, _projectService.Object, _templateWriter.Object)
            {
                Name = "Project 2",
            };

            var resultMessage = command.Execute();

            Assert.Equal("Project Project 2 was not found", resultMessage);
        }
        public void ProjectExport_Execute_ReturnsSuccessMessage()
        {
            var command = new ExportCommand(_console, LoggerMock.GetLogger <ExportCommand>().Object, _projectService.Object, _templateWriter.Object)
            {
                Name = "Project 1"
            };

            var resultMessage = command.Execute();

            Assert.Equal("Project has been exported to Project 1", resultMessage);
        }
예제 #5
0
        public void Export_Execute_Simple()
        {
            string executable = null;
            string arguments  = null;

            Program.Exec = (cmd, args) => { executable = cmd; arguments = args; return(127); };
            var c = new ExportCommand();

            c.Parse("--uri mongodb://host:28123/database --collection Countries --query {a:1}".Split(' '));
            c.Execute();

            Assert.Equal(ExportCommand.COMMAND, executable);
            Assert.Equal($"--db database --host host:28123 --collection Countries --query {{a:1}} --type json --out {c.TimePrefix}.Countries.Insert.json", arguments);
        }
예제 #6
0
        public void Export_Execute_Atlas()
        {
            string executable = null;
            string arguments  = null;

            Program.Exec = (cmd, args) => { executable = cmd; arguments = args; return(127); };
            var c = new ExportCommand();

            c.Parse("--uri mongodb://user:password@host:28123,host2:28125/database?replicaSet=Atlas1-shard-0&ssl=true true --collection Countries --query {a:1} --authenticationDatabase admin".Split(' '));
            c.Execute();

            Assert.Equal(ExportCommand.COMMAND, executable);
            Assert.Equal($"--db database --host Atlas1-shard-0/host:28123,host2:28125 --username user --password password --ssl --authenticationDatabase admin --collection Countries --query {{a:1}} --type json --out {c.TimePrefix}.Countries.Insert.json", arguments);
        }
        public void LoadCommands()
        {
            LoadEquippedItemsCommand = new RelayCommand(parameter =>
            {
                try
                {
                    if (ZetaDia.Me == null || !ZetaDia.IsInGame)
                    {
                        if (!ChangeEvents.IsInGame.Value)
                        {
                            Core.Logger.Log("Must be in a game to use this feature");
                        }
                        else
                        {
                            using (ZetaDia.Memory.AcquireFrame())
                            {
                                ZetaDia.Actors.Update();
                                Core.Logger.Log("Scanning Character for Equipped Items");
                                SelectItems(InventoryManager.Equipped);
                            }
                        }
                    }
                    else
                    {
                        if (!BotMain.IsRunning)
                        {
                            ZetaDia.Actors.Update();
                        }

                        Core.Logger.Log("Scanning Character for Equipped Items");
                        SelectItems(InventoryManager.Equipped);
                    }
                }
                catch (Exception ex)
                {
                    Core.Logger.Error("Exception in SelectAllCommand {0}", ex);
                }
            });

            LoadStashedItemsCommand = new RelayCommand(parameter =>
            {
                try
                {
                    if (ZetaDia.Me == null || !ZetaDia.IsInGame)
                    {
                        if (BotMain.IsRunning)
                        {
                            Core.Logger.Log("Must be in a game to use this feature");
                        }
                        else
                        {
                            using (ZetaDia.Memory.AcquireFrame())
                            {
                                ZetaDia.Actors.Update();
                                Core.Logger.Log("Scanning Character for Stashed Items");
                                SelectItems(InventoryManager.StashItems);
                            }
                        }
                    }
                    else
                    {
                        ZetaDia.Actors.Update();
                        Core.Logger.Log("Scanning Character for Stashed Items");
                        SelectItems(InventoryManager.StashItems);
                    }
                }
                catch (Exception ex)
                {
                    Core.Logger.Error("Exception in SelectAllCommand {0}", ex);
                }
            });

            AdvancedOptionCommand = new RelayCommand(parameter =>
            {
                try
                {
                    if (parameter == null)
                    {
                        return;
                    }

                    Core.Logger.Verbose("AdvancedOptionCommand Fired {0}", parameter.ToString());

                    var item = parameter as ComboBoxItem;
                    var selectedPropertyName = item != null ? item.Tag.ToString() : parameter.ToString();

                    switch (selectedPropertyName)
                    {
                    case "SelectAllCommand":
                        SelectAllCommand.Execute(null);
                        break;

                    case "SelectNoneCommand":
                        SelectNoneCommand.Execute(null);
                        break;

                    case "ClearRulesCommand":
                        ClearRulesCommand.Execute(null);
                        break;

                    case "AddAllSetsCommand":
                        AddAllSetsCommand.Execute(null);
                        break;

                    case "AddAllLegendaryAffixCommand":
                        AddAllLegendaryAffixCommand.Execute(null);
                        break;

                    case "Add24ItemsCommand":
                        Add24ItemsCommand.Execute(null);
                        break;
                    }
                }
                catch (Exception ex)
                {
                    Core.Logger.Error("Exception in AdvancedOptionCommand: {0} {1}", ex.Message, ex.InnerException);
                }
            });

            SelectAllCommand = new RelayCommand(parameter =>
            {
                try
                {
                    if (SelectedTab == Tab.Legendary)
                    {
                        Core.Logger.Log("Selecting all items");
                        using (Collection.DeferRefresh())
                        {
                            SelectedItems = new List <LItem>(DisplayItems);
                            UpdateSelectedItems();
                        }
                        return;
                    }

                    if (SelectedTab == Tab.ItemType)
                    {
                        Core.Logger.Log("Selecting all item types.");
                        ItemTypes.ForEach(i => i.IsSelected = true);
                    }
                }
                catch (Exception ex)
                {
                    Core.Logger.Error("Exception in SelectAllCommand {0}", ex);
                }
            });

            Add24ItemsCommand = new RelayCommand(parameter =>
            {
                try
                {
                    Core.Logger.Log("Add24ItemsCommand Not Implemented");
                    AddToSelection(item => ItemListPresets.Patch24Items.Contains(item.Id));
                }
                catch (Exception ex)
                {
                    Core.Logger.Error("Exception in SelectAllCommand {0}", ex);
                }
            });

            AddAllSetsCommand = new RelayCommand(parameter =>
            {
                try
                {
                    Core.Logger.Log("AddAllSetsCommand Not Implemented");
                    AddToSelection(item => item.IsSetItem);
                }
                catch (Exception ex)
                {
                    Core.Logger.Error("Exception in SelectAllCommand {0}", ex);
                }
            });

            AddAllLegendaryAffixCommand = new RelayCommand(parameter =>
            {
                try
                {
                    Core.Logger.Log("Selecting all items with a legendary affix");
                    AddToSelection(item => !string.IsNullOrEmpty(item.LegendaryAffix));
                }
                catch (Exception ex)
                {
                    Core.Logger.Error("Exception in SelectAllLegendaryAffixCommand {0}", ex);
                }
            });

            SelectNoneCommand = new RelayCommand(parameter =>
            {
                try
                {
                    if (SelectedTab == Tab.Legendary)
                    {
                        Core.Logger.Log("Deselecting all legendary items");
                        using (Collection.DeferRefresh())
                        {
                            SelectedItems = new List <LItem>();
                            CreateView();
                            UpdateSelectedItems();
                        }
                        return;
                    }

                    if (SelectedTab == Tab.ItemType)
                    {
                        using (ItemTypes.ViewSource.DeferRefresh())
                        {
                            foreach (var itemType in ItemTypes)
                            {
                                itemType.IsSelected = false;
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    Core.Logger.Error("Exception in SelectNoneCommand {0}", ex);
                }
            });

            ClearRulesCommand = new RelayCommand(parameter =>
            {
                try
                {
                    if (SelectedTab == Tab.Legendary)
                    {
                        Core.Logger.Log("Removing rules from all legendary items.");
                        using (Collection.DeferRefresh())
                        {
                            SelectedItems.ForEach(i => i.Rules = new ObservableCollection <LRule>());
                            UpdateSelectedItems();
                        }
                        return;
                    }

                    if (SelectedTab == Tab.ItemType)
                    {
                        Core.Logger.Log("Removing rules from all item types.");
                        ItemTypes.ForEach(i => i.Rules = new FullyObservableCollection <LRule>());
                    }
                }
                catch (Exception ex)
                {
                    Core.Logger.Error("Exception in ClearAllRulesCommand {0}", ex);
                }
            });

            ResetFilterCommand = new RelayCommand(parameter => { FilterText = string.Empty; });

            EnableItemListCommand = new RelayCommand(parameter =>
            {
                Core.Logger.Log("Setting ItemFilterMode to ItemList");
                UILoader.DataContext.Items.LegendaryMode = LegendaryMode.ItemList;
            });

            LoadModalCommand = new RelayCommand(parameter =>
            {
                if (parameter == null)
                {
                    return;
                }

                ModalPage page;
                if (Enum.TryParse(parameter.ToString(), out page))
                {
                    if (page != ModalPage.None)
                    {
                        SelectedModalPage = page;
                        IsModalVisible    = true;
                    }

                    ExportCode = string.Empty;

                    if (page == ModalPage.Export)
                    {
                        ExportCommand.Execute(parameter);
                    }
                }

                Core.Logger.Log("Selecting modal content... {0}", parameter.ToString());
            });

            CloseModalCommand = new RelayCommand(parameter => { IsModalVisible = false; });

            ImportCommand = new RelayCommand(parameter =>
            {
                Core.Logger.Log("Importing ItemList...");

                var oldSlected = _selectedItems.Count;

                ImportFromCode(ExportCode);

                Core.Logger.Log("Selected Before = {0} After = {1}", oldSlected, _selectedItems.Count);

                IsModalVisible = false;
            });

            ExportCommand = new RelayCommand(parameter =>
            {
                Core.Logger.Log("Exporting ItemList... {0}", parameter);
                ExportCode = CreateExportCode();
            });
        }
예제 #8
0
        private void InitializeXukSpines()
        {
            ShowXukSpineCommand = new RichDelegateCommand(
                Tobi_Plugin_Urakawa_Lang.CmdShowXukSpine_ShortDesc,
                Tobi_Plugin_Urakawa_Lang.CmdShowXukSpine_LongDesc,
                null, // KeyGesture obtained from settings (see last parameters below)
                m_ShellView.LoadTangoIcon(@"preferences-desktop-locale"),
                () =>
            {
                m_Logger.Log("UrakawaSession.ShowXukSpineCommand", Category.Debug, Priority.Medium);

                var view = m_Container.Resolve <XukSpineView>();

                var windowPopup = new PopupModalWindow(m_ShellView,
                                                       UserInterfaceStrings.EscapeMnemonic(
                                                           Tobi_Plugin_Urakawa_Lang.CmdShowXukSpine_ShortDesc
                                                           //Tobi_Plugin_Urakawa_Lang.CmdOpenRecent_ShortDesc
                                                           ),
                                                       view,
                                                       PopupModalWindow.DialogButtonsSet.OkCancel,
                                                       PopupModalWindow.DialogButton.Ok,
                                                       true, 400, 600, null, 0, null);
                //view.OwnerWindow = windowPopup;

                windowPopup.EnableEnterKeyDefault = true;

                windowPopup.ShowModal();

                if (windowPopup.ClickedDialogButton == PopupModalWindow.DialogButton.Ok)
                {
                    if (view.XukSpineItemsList.SelectedItem != null)
                    {
                        var item   = (XukSpineItemWrapper)view.XukSpineItemsList.SelectedItem;
                        string str = item.Data.Uri.IsFile ? item.Data.Uri.LocalPath : item.Data.Uri.ToString();

                        if (view.check.IsChecked.GetValueOrDefault() && item.SplitMerged)
                        {
                            string parentDir           = Path.GetDirectoryName(str);
                            string fileNameWithoutExtn = Path.GetFileNameWithoutExtension(str);

                            string mergedDirName = MERGE_PREFIX + @"_" + fileNameWithoutExtn;
                            string mergedDir     = Path.Combine(parentDir, mergedDirName);

                            str = Path.Combine(mergedDir, Path.GetFileName(str));
                        }

                        try
                        {
                            OpenFile(str);
                        }
                        catch (Exception ex)
                        {
                            ExceptionHandler.Handle(ex, false, m_ShellView);
                        }
                    }
                }
                else if (windowPopup.ClickedDialogButton == PopupModalWindow.DialogButton.Apply)
                {
                    // IsXukSpine ? DocumentFilePath : XukSpineProjectPath

                    bool opened = true;
                    if (!IsXukSpine)
                    {
                        opened = false;
                        try
                        {
                            opened = OpenFile(XukSpineProjectPath, false);
                        }
                        catch (Exception ex)
                        {
                            ExceptionHandler.Handle(ex, false, m_ShellView);
                        }
                    }

                    if (opened)
                    {
                        ExportCommand.Execute();
                    }
                }
                else if (windowPopup.ClickedDialogButton == PopupModalWindow.DialogButton.Close)
                {
                    // IsXukSpine ? DocumentFilePath : XukSpineProjectPath

                    bool opened = true;
                    if (!IsXukSpine)
                    {
                        opened = false;
                        try
                        {
                            opened = OpenFile(XukSpineProjectPath, false);
                        }
                        catch (Exception ex)
                        {
                            ExceptionHandler.Handle(ex, false, m_ShellView);
                        }
                    }

                    if (opened)
                    {
                        MergeProjectCommand.Execute();
                    }
                }
                else if (windowPopup.ClickedDialogButton == PopupModalWindow.DialogButton.No)
                {
                    // IsXukSpine ? DocumentFilePath : XukSpineProjectPath

                    bool opened = true;
                    if (!IsXukSpine)
                    {
                        opened = false;
                        try
                        {
                            opened = OpenFile(XukSpineProjectPath, true);
                        }
                        catch (Exception ex)
                        {
                            ExceptionHandler.Handle(ex, false, m_ShellView);
                        }
                    }

                    //if (opened)
                    //{
                    //    ShowXukSpineCommand.Execute();
                    //}
                }
            },
                () => HasXukSpine && !isAudioRecording,
                Settings_KeyGestures.Default,
                PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_ShowXukSpine)
                );

            m_ShellView.RegisterRichCommand(ShowXukSpineCommand);
        }