示例#1
0
 protected override void InitializeComponents()
 {
     base.InitializeComponents();
     this.Text        = AppString.Dialog.NewOpenWithItem;
     btnBrowse.Click += (sender, e) => BrowseFile();
     btnOk.Click     += (sender, e) =>
     {
         if (string.IsNullOrEmpty(ItemText))
         {
             MessageBoxEx.Show(AppString.MessageBox.TextCannotBeEmpty);
             return;
         }
         if (ItemCommand.IsNullOrWhiteSpace())
         {
             MessageBoxEx.Show(AppString.MessageBox.TextCannotBeEmpty);
             return;
         }
         FilePath   = ObjectPath.ExtractFilePath(ItemCommand);
         AppRegPath = $@"HKEY_CLASSES_ROOT\Applications\{Path.GetFileName(FilePath)}";
         if (FilePath == null || RegistryEx.GetRegistryKey(AppRegPath) != null)
         {
             MessageBoxEx.Show(AppString.MessageBox.UnsupportedFilename);
             return;
         }
         AddNewItem();
         this.DialogResult = DialogResult.OK;
     };
 }
            private void AddNewItem()
            {
                using (var shellKey = RegistryEx.GetRegistryKey(ShellPath, true, true))
                {
                    string keyName = ItemText.Replace("\\", "").Trim();
                    NewItemRegPath = ObjectPath.GetNewPathWithIndex($@"{ShellPath}\{keyName}", ObjectPath.PathType.Registry);
                    keyName        = RegistryEx.GetKeyName(NewItemRegPath);

                    using (var key = shellKey.CreateSubKey(keyName, true))
                    {
                        key.SetValue("MUIVerb", ItemText);
                        if (rdoMulti.Checked)
                        {
                            key.SetValue("SubCommands", "");
                        }
                        else
                        {
                            if (!ItemCommand.IsNullOrWhiteSpace())
                            {
                                key.CreateSubKey("command", true).SetValue("", ItemCommand);
                            }
                        }
                    }
                }
            }
示例#3
0
        public HttpResponseMessage MoveFolder(ItemCommand itemCommand)
        {
            try
            {
                string folderPath = PathUtils.Instance.FormatFolderPath(itemCommand.Path);
                string toPath     = PathUtils.Instance.FormatFolderPath(itemCommand.ToPath);

                IFolderInfo folder = FolderManager.Instance.GetFolder(PortalSettings.PortalId, folderPath);

                if (folder == null)
                {
                    return(Request.CreateResponse(HttpStatusCode.NotFound, folderPath));
                }

                IFolderInfo destination = FolderManager.Instance.GetFolder(PortalSettings.PortalId, toPath);

                if (destination == null)
                {
                    return(Request.CreateResponse(HttpStatusCode.NotFound, toPath));
                }

                FolderManager.Instance.MoveFolder(folder, destination);

                return(Request.CreateResponse(HttpStatusCode.OK));
            }
            catch
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, LocalizeString("UnattentedError")));
            }
        }
        /// <summary>
        /// Handle request to invoke an item command
        /// </summary>
        /// <param name="itemCommand"></param>
        /// <param name="origin"></param>
        public CoreUseItemEvent HandleUseItemCommand(ItemCommand itemCommand, Item origin)
        {
            CoreUseItemEvent continueIfNull = null;

            if (itemCommand.Id == CommandTake)
            {
                var itemManager    = ModuleManager.GetManager <IItemManager>();
                var messageManager = ModuleManager.GetManager <IMessageManager>();
                var item           = itemManager.Read(itemCommand.ItemId.Value);
                itemManager.Move(item, origin, origin);
                continueIfNull = new CoreUseItemEvent()
                {
                    Success = true,
                    Used    = item,
                    Using   = origin,
                    Use     = itemCommand
                };
            }
            if (itemCommand.Id == CommandDrop)
            {
                var itemManager    = ModuleManager.GetManager <IItemManager>();
                var messageManager = ModuleManager.GetManager <IMessageManager>();
                var item           = itemManager.Read(itemCommand.ItemId.Value);
                var location       = itemManager.Read(origin.ParentId.Value);
                itemManager.Move(item, location, origin);
                continueIfNull = new CoreUseItemEvent()
                {
                    Success = true,
                    Used    = item,
                    Using   = origin,
                    Use     = itemCommand
                };
            }
            return(continueIfNull);
        }
示例#5
0
        public HttpResponseMessage Pack(ItemCommand itemCommand)
        {
            string      folderPath = PathUtils.Instance.FormatFolderPath(itemCommand.Path);
            IFolderInfo folder     = FolderManager.Instance.GetFolder(PortalSettings.PortalId, folderPath);

            if (folder != null)
            {
                string        fileName = itemCommand.ToPath;
                List <string> files    = itemCommand.Files;

                if (files.Count > 0 && !string.IsNullOrEmpty(fileName))
                {
                    if (!fileName.EndsWith(".zip", StringComparison.OrdinalIgnoreCase))
                    {
                        fileName += ".zip";
                    }

                    string error = ZipFiles(files, folder, fileName);

                    if (string.IsNullOrEmpty(error))
                    {
                        return(Request.CreateResponse(HttpStatusCode.OK));
                    }

                    return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, LocalizeString("UnattentedError")));
                }
            }

            return(Request.CreateResponse(HttpStatusCode.NotFound));
        }
示例#6
0
            protected override void InitializeComponents()
            {
                base.InitializeComponents();
                btnOK.Click += (sender, e) =>
                {
                    if (ItemText.IsNullOrWhiteSpace())
                    {
                        AppMessageBox.Show(AppString.Message.TextCannotBeEmpty);
                        return;
                    }
                    if (ItemCommand.IsNullOrWhiteSpace())
                    {
                        AppMessageBox.Show(AppString.Message.CommandCannotBeEmpty);
                        return;
                    }
                    AddNewItem();
                    DialogResult = DialogResult.OK;
                };

                btnBrowse.Click += (sender, e) =>
                {
                    using (OpenFileDialog dlg = new OpenFileDialog())
                    {
                        if (dlg.ShowDialog() != DialogResult.OK)
                        {
                            return;
                        }
                        this.ItemFilePath = dlg.FileName;
                        this.ItemText     = Path.GetFileNameWithoutExtension(dlg.FileName);
                    }
                };
            }
示例#7
0
        public HttpResponseMessage Files([FromUri] ItemCommand itemCommand)
        {
            try
            {
                string      folderPath = PathUtils.Instance.FormatFolderPath(itemCommand.Path);
                IFolderInfo parent     = FolderManager.Instance.GetFolder(PortalSettings.PortalId, folderPath);

                if (parent != null)
                {
                    IEnumerable <FileDTO> files = FolderManager.Instance.GetFiles(parent).Select(f => new FileDTO
                    {
                        Icon      = itemCommand.Flag ? GetFileIcon(f) : null,
                        Name      = f.FileName,
                        Extension = f.Extension,
                        Modified  = f.LastModifiedOnDate,
                        Size      = f.Size
                    });

                    return(Request.CreateResponse(HttpStatusCode.OK, files, GetFormatter()));
                }

                return(Request.CreateResponse(HttpStatusCode.NotFound, folderPath));
            }
            catch
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, LocalizeString("UnattentedError")));
            }
        }
示例#8
0
        public HttpResponseMessage Thumbnail([FromUri] ItemCommand itemCommand)
        {
            try
            {
                string    folderPath = PathUtils.Instance.FormatFolderPath(itemCommand.Path);
                string    filePath   = folderPath + itemCommand.Files[0];
                IFileInfo file       = FileManager.Instance.GetFile(PortalSettings.PortalId, filePath);

                if (file != null)
                {
                    DocumentSettings settings = new DocumentSettings(ActiveModule);
                    int    height             = settings.ThumbnailHeight;
                    int    width     = settings.ThumbnailWidth;
                    string extension = "." + file.Extension;

                    using (Stream content = FileManager.Instance.GetFileContent(file))
                    {
                        using (Stream thumbnail = ImageUtils.CreateImage(content, height, width, extension))
                        {
                            string img64 = string.Format("data:{0};base64,{1}", file.ContentType, ReadFullyAsBase64(thumbnail));

                            return(Request.CreateResponse(HttpStatusCode.OK, img64));
                        }
                    }
                }

                return(Request.CreateResponse(HttpStatusCode.NotFound, filePath));
            }
            catch
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, LocalizeString("UnattentedError")));
            }
        }
示例#9
0
        /// <summary>
        /// Process an item command
        /// </summary>
        /// <param name="itemCommand"></param>
        private async Task OnItemCommand(ItemCommand itemCommand)
        {
            if (itemCommand.Id == new Guid("0db8f80d-0ea8-4cbf-80ba-b37cab739391"))
            {
                var jsonEditorPage = new JsonEditorPage(Container);
                jsonEditorPage.ViewModel.ItemId  = itemCommand.ItemId.ToString();
                jsonEditorPage.ViewModel.PreLoad = true;
                jsonEditorPage.Disappearing     += (disSender, disE) =>
                {
                    MessageService.Send(new WorldReadLocationSummaryRequest()
                    {
                    });
                };
                await Page.Navigation.PushModalAsync(jsonEditorPage);
            }
            else
            {
                var useRequest = new CoreUseItemRequest()
                {
                    ItemId = itemCommand.ItemId,
                    Use    = itemCommand
                };
                var result = await MessageService.SendRequestAsync <CoreUseItemResponse>(useRequest);

                if (!result.IsSuccess())
                {
                    throw new BeforeOurTimeException(result._responseMessage);
                }
            }
        }
示例#10
0
        public void Initalize()
        {
            var tasksSection = new MenuSection <ItemCommand <ClientViewModel> >();

            var tasksSubMenu = new NavigationalEntry <ItemCommand <ClientViewModel> >
            {
                Header = Tx.T("TasksInfrastructure:CreateTask.Commands", 2), IsOrdered = true, Icon = _icons.SelectCommandColumn
            };

            InitializeCommands(tasksSubMenu);
            tasksSection.Add(tasksSubMenu);

            var createTaskCommand = new ItemCommand <ClientViewModel>
            {
                Header  = Tx.T("TasksInfrastructure:CreateTask"),
                Icon    = _icons.NewCatalog,
                Command = new DelegateCommand <ClientViewModel>(client => CreateTaskCommand(new List <ClientViewModel> {
                    client
                })),
                MultipleCommand = new DelegateCommand <IList <ClientViewModel> >(CreateTaskCommand)
            };

            tasksSection.Add(createTaskCommand);

            _clientsContextMenu.Add(tasksSection);
        }
            private void AddNewItem()
            {
                using (var shellKey = RegistryEx.GetRegistryKey(ShellPath, true, true))
                {
                    string keyName = "Item";
                    NewItemRegPath = ObjectPath.GetNewPathWithIndex($@"{ShellPath}\{keyName}", ObjectPath.PathType.Registry, 0);
                    keyName        = RegistryEx.GetKeyName(NewItemRegPath);

                    using (var key = shellKey.CreateSubKey(keyName, true))
                    {
                        key.SetValue("MUIVerb", ItemText);
                        if (rdoMulti.Checked)
                        {
                            key.SetValue("SubCommands", "");
                        }
                        else
                        {
                            if (!ItemCommand.IsNullOrWhiteSpace())
                            {
                                string command;
                                if (!chkSE.Checked)
                                {
                                    command = ItemCommand;
                                }
                                else
                                {
                                    command = ShellExecuteDialog.GetCommand(ItemFilePath, Arguments, chkSE.Verb, chkSE.WindowStyle);
                                }
                                key.CreateSubKey("command", true).SetValue("", command);
                            }
                        }
                    }
                }
            }
示例#12
0
 public void UpdateItemCommand(ItemCommand itemCommand, int pageIndex, int commandIndex, string rules, string comment)
 {
     itemCommand.PageIndex                   = pageIndex;
     itemCommand.CommandIndex                = commandIndex;
     itemCommand.optionDialogInfo.Rules      = rules;
     itemCommand.optionDialogInfo.TemplateId = comment;
 }
示例#13
0
        public void Kit(Player player, int kitId)
        {
            var inventory = player.Inventory;

            switch (kitId)
            {
            case 0:
                // Kit leather tier
                break;

            case 1:
                // Kit gold tier
                break;

            case 2:
                // Kit chain tier
                break;

            case 3:
                // Kit iron tier
                inventory.Boots    = new ItemIronBoots(0);
                inventory.Leggings = new ItemIronLeggings(0);
                inventory.Chest    = new ItemIronChestplate(0);
                inventory.Helmet   = new ItemIronHelmet(0);
                break;

            case 4:
                // Kit diamond tier
                inventory.Boots    = new ItemDiamondBoots(0);
                inventory.Leggings = new ItemDiamondLeggings(0);
                inventory.Chest    = new ItemDiamondChestplate(0);
                inventory.Helmet   = new ItemDiamondHelmet(0);
                break;
            }

            byte c       = 0;
            var  command = new ItemCommand(41, 0, delegate(ItemCommand itemCommand, Level level, Player arg3, BlockCoordinates arg4) { Log.Info("Clicked on command"); });

            inventory.Slots[c++] = new ItemStack(command, 1);         // Wooden Sword
            inventory.Slots[c++] = new ItemStack(268, 1);             // Wooden Sword
            inventory.Slots[c++] = new ItemStack(283, 1);             // Golden Sword
            inventory.Slots[c++] = new ItemStack(272, 1);             // Stone Sword
            inventory.Slots[c++] = new ItemStack(267, 1);             // Iron Sword
            inventory.Slots[c++] = new ItemStack(276, 1);             // Diamond Sword

            inventory.Slots[c++] = new ItemStack(261, 1);             // Bow
            inventory.Slots[c++] = new ItemStack(262, 64);            // Arrows
            inventory.Slots[c++] = new ItemStack(344, 64);            // Eggs
            inventory.Slots[c++] = new ItemStack(332, 64);            // Snowballs

            inventory.Slots[c++] = new ItemStack(new ItemStoneAxe(0), 1);
            inventory.Slots[c++] = new ItemStack(new ItemWoodenPickaxe(0), 1);
            inventory.Slots[c++] = new ItemStack(new ItemBread(), 5);

            player.SendPlayerInventory();
            SendEquipmentForPlayer(player);
            SendArmorForPlayer(player);

            player.Level.BroadcastMessage(string.Format("Player {0} changed kit.", player.Username), type: MessageType.Raw);
        }
示例#14
0
        /// <summary>
        /// Handle request to invoke an item command
        /// </summary>
        /// <param name="itemCommand"></param>
        /// <param name="origin"></param>
        public CoreUseItemEvent HandleUseItemCommand(ItemCommand itemCommand, Item origin)
        {
            CoreUseItemEvent continueIfNull = null;

            if (itemCommand.Id == CommandGo)
            {
                var itemManager     = ModuleManager.GetManager <IItemManager>();
                var messageManager  = ModuleManager.GetManager <IMessageManager>();
                var exitItem        = itemManager.Read(itemCommand.ItemId.Value);
                var destinationItem = itemManager.Read(Guid.Parse(exitItem.GetProperty <ExitItemProperty>().DestinationId));
                itemManager.Move(origin, destinationItem, exitItem);
                IResponse mockResponse    = new Response();
                var       locationSummary = ModuleManager.GetManager <ILocationItemDataManager>()
                                            .HandleReadLocationSummaryRequest(new WorldReadLocationSummaryRequest()
                {
                }, origin, ModuleManager, mockResponse);
                messageManager.SendMessage(new List <IMessage>()
                {
                    locationSummary
                }, new List <Item>()
                {
                    origin
                });
                continueIfNull = new CoreUseItemEvent()
                {
                    Success = true,
                    Used    = exitItem,
                    Using   = origin,
                    Use     = itemCommand
                };
            }
            return(continueIfNull);
        }
示例#15
0
        protected internal override bool HandleItemCommand(ItemCommand command)
        {
            if (focusMarkers.Count == 0)
            {
                return(false);
            }

            var marker = focusMarkers[focusedIndex] as MarginMarker;

            if (marker == null)
            {
                return(false);
            }

            switch (command)
            {
            case ItemCommand.ActivateCurrentItem:
                var lineNumber = marker.LineSegment.LineNumber;
                var y          = editor.LineToY(lineNumber);
                MousePressed(new MarginMouseEventArgs(editor, EventType.ButtonPress, 1, 0, y, ModifierType.None));

                if (focusedIndex >= focusMarkers.Count)
                {
                    focusedIndex = focusMarkers.Count - 1;
                }

                editor.RedrawMargin(this);
                break;

            case ItemCommand.FocusNextItem:
                focusedIndex++;

                SanitizeFocusedIndex();

                marker = focusMarkers[focusedIndex] as MarginMarker;
                editor.CenterTo(marker.LineSegment.LineNumber, 1);
                break;

            case ItemCommand.FocusPreviousItem:
                focusedIndex--;

                SanitizeFocusedIndex();

                marker = focusMarkers[focusedIndex] as MarginMarker;
                editor.CenterTo(marker.LineSegment.LineNumber, 1);
                break;
            }

            if (marker != null && markerToAccessible != null)
            {
                var accessible = markerToAccessible[marker];
                if (accessible != null)
                {
                    AtkCocoaExtensions.SetCurrentFocus(accessible.Accessible);
                }
            }
            return(true);
        }
示例#16
0
 private void HohoemaListView_ItemClick(object sender, ItemClickEventArgs e)
 {
     if (ItemCommand != null)
     {
         if (ItemCommand.CanExecute(e.ClickedItem))
         {
             ItemCommand.Execute(e.ClickedItem);
         }
     }
 }
示例#17
0
        public ItemDialog(OperateRecordManager operateRecordManager, int pageIndex, int commandIndex, string prevCommand, int preUniqueId)
        {
            InitializeComponent();
            this.operateRecordManager = operateRecordManager;
            this.PageIndex            = pageIndex;
            this.CommandIndex         = commandIndex;
            this.prevCommand          = prevCommand;
            this.PreUniqueId          = preUniqueId;
            this.UniqueId             = UniqueIdManager.Create();

            ItemCommand = operateRecordManager.AddItemCommand(this.PageIndex, this.CommandIndex, this.Rule.Text, this.Comment.Text, prevCommand, preUniqueId, UniqueId);
        }
示例#18
0
        protected void ContextMenuClickHandler(object sender, RoutedEventArgs e)
        {
            MenuItem m = (MenuItem)sender;

            if (!(m.Tag is CadObjTreeItem.ContextMenuTag))
            {
                return;
            }

            CadObjTreeItem.ContextMenuTag tag = (CadObjTreeItem.ContextMenuTag)m.Tag;

            ItemCommand?.Invoke(tag.TreeItem, tag.Tag);
        }
示例#19
0
 // Command를 할수 있는지 없는지만 검사합니다.
 // 생성자대용으로 사용합니다.
 public static bool CreateCommand(Unit unit, Item item, List <Cube> useCubes, out ItemCommand itemCommand)
 {
     if (unit.itemBag.Contains(item))
     {
         itemCommand = new ItemCommand(item, useCubes);
         return(true);
     }
     else
     {
         itemCommand = null;
         return(false);
     }
 }
示例#20
0
    public IEnumerator Item(ItemCommand itemCommand)
    {
        string itemName    = itemCommand.item.itemName;
        string itemMessage = itemCommand.owner.CharacterName + "は" + itemName + "をつかった";

        yield return(StartCoroutine(message.ShowAuto(itemMessage)));

        GameController.GetInventorySystem().UseItem(itemCommand.item);

        yield return(StartCoroutine(effectExecutor.Execution(itemCommand)));

        yield break;
    }
示例#21
0
        public HttpResponseMessage Delete(ItemCommand itemCommand)
        {
            try
            {
                string folderPath = PathUtils.Instance.FormatFolderPath(itemCommand.Path);

                if (itemCommand.Files == null)
                {
                    IFolderInfo folder = FolderManager.Instance.GetFolder(PortalSettings.PortalId, folderPath);

                    if (folder != null)
                    {
                        int fileCounter = FolderManager.Instance.GetFiles(folder).ToList().Count;

                        if (folder.HasChildren || fileCounter > 0)
                        {
                            return(Request.CreateResponse(HttpStatusCode.Conflict, LocalizeString("FolderNotEmpty")));
                        }

                        FolderManager.Instance.DeleteFolder(folder);
                    }
                    else
                    {
                        return(Request.CreateResponse(HttpStatusCode.NotFound, folderPath));
                    }
                }
                else
                {
                    foreach (string fileName in itemCommand.Files)
                    {
                        string    filePath = folderPath + fileName;
                        IFileInfo file     = FileManager.Instance.GetFile(PortalSettings.PortalId, filePath);

                        if (file != null)
                        {
                            FileManager.Instance.DeleteFile(file);
                        }
                        else
                        {
                            return(Request.CreateResponse(HttpStatusCode.NotFound, fileName));
                        }
                    }
                }

                return(Request.CreateResponse(HttpStatusCode.OK));
            }
            catch
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, LocalizeString("UnattentedError")));
            }
        }
示例#22
0
        public HttpResponseMessage CreateFolder(ItemCommand itemCommand)
        {
            try
            {
                string folderPath = PathUtils.Instance.FormatFolderPath(itemCommand.Path);
                string newFolder  = folderPath + itemCommand.ToPath;

                FolderManager.Instance.AddFolder(PortalSettings.PortalId, newFolder);

                return(Request.CreateResponse(HttpStatusCode.OK));
            }
            catch
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, LocalizeString("UnattentedError")));
            }
        }
示例#23
0
        public HttpResponseMessage Synchronize(ItemCommand itemCommand)
        {
            try
            {
                string folderPath = PathUtils.Instance.FormatFolderPath(itemCommand.Path);
                bool   recursive  = itemCommand.Flag;

                FolderManager.Instance.Synchronize(PortalSettings.PortalId, folderPath, recursive, true);

                return(Request.CreateResponse(HttpStatusCode.OK));
            }
            catch
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, LocalizeString("UnattentedError")));
            }
        }
示例#24
0
        public ItemViewModel()
        {
            database = new DBContext();

            item = new Item()
            {
                Description = ""
            };

            itemsList        = new ObservableCollection <Item>();
            itemsHistoryList = new ObservableCollection <Item>();

            initLists();

            AddCommand  = new ItemCommand(InsertItem);
            DelCommand  = new ItemCommand(RemoveItem);
            DoneCommand = new ItemCommand(SetDoneItem);
        }
示例#25
0
        public void MSTest_ItemCommand()
        {
            Node    node         = new Node();
            Item    item         = new HealingPotion("hpPotion");
            Command itemCom      = new ItemCommand(0, "");
            uint    healingpower = (item as HealingPotion).HPvalue;

            Assert.IsTrue(itemCom.ToString() == "use item " + 0 + " in player bag");
            Player player = new Player();

            player.location = node;
            player.bag.Add(item);
            player.HP -= 20;
            int pHP = player.HP;

            itemCom.ExecuteCommand(player);
            Assert.IsTrue(player.HP == pHP + healingpower);
        }
示例#26
0
    void UseItem(Item item)
    {
        turnMgr = gameMgr._turnMgr;

        TurnMgr_State_ nextState = new TurnMgr_PlayerBegin_(turnMgr, turnMgr.turns.Peek());

        turnMgr.stateMachine.ChangeState(
            new TurnMgr_WaitSingleEvent_(turnMgr, turnMgr.turns.Peek(), EventMgr.Instance.onUnitIdleEnter, nextState),
            StateMachine <TurnMgr> .StateTransitionMethod.JustPush);


        ItemCommand itemCommand;

        if (ItemCommand.CreateCommand(turnMgr.turns.Peek(), item, out itemCommand))
        {
            turnMgr.turns.Peek().EnqueueCommand(itemCommand);
        }
    }
示例#27
0
        public HttpResponseMessage PasteFiles(ItemCommand itemCommand)
        {
            try
            {
                string      toPath      = PathUtils.Instance.FormatFolderPath(itemCommand.ToPath);
                IFolderInfo destination = FolderManager.Instance.GetFolder(PortalSettings.PortalId, toPath);

                if (destination == null)
                {
                    return(Request.CreateResponse(HttpStatusCode.NotFound, toPath));
                }

                string folderPath = PathUtils.Instance.FormatFolderPath(itemCommand.Path);
                bool   moveFiles  = itemCommand.Flag;

                foreach (string fileName in itemCommand.Files)
                {
                    string    filePath = folderPath + fileName;
                    IFileInfo file     = FileManager.Instance.GetFile(PortalSettings.PortalId, filePath);

                    if (file != null)
                    {
                        if (moveFiles)
                        {
                            FileManager.Instance.MoveFile(file, destination);
                        }
                        else
                        {
                            FileManager.Instance.CopyFile(file, destination);
                        }
                    }
                    else
                    {
                        return(Request.CreateResponse(HttpStatusCode.NotFound, fileName));
                    }
                }

                return(Request.CreateResponse(HttpStatusCode.OK));
            }
            catch
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, LocalizeString("UnattentedError")));
            }
        }
示例#28
0
        public HttpResponseMessage Rename(ItemCommand itemCommand)
        {
            try
            {
                string folderPath = PathUtils.Instance.FormatFolderPath(itemCommand.Path);

                // Rename folder
                if (itemCommand.Files == null)
                {
                    IFolderInfo folder = FolderManager.Instance.GetFolder(PortalSettings.PortalId, folderPath);

                    if (folder != null)
                    {
                        FolderManager.Instance.RenameFolder(folder, itemCommand.ToPath);
                    }
                    else
                    {
                        return(Request.CreateResponse(HttpStatusCode.NotFound, folderPath));
                    }
                }
                else // Rename file
                {
                    string    fileName = itemCommand.Files[0];
                    string    filePath = Path.Combine(folderPath, fileName);
                    IFileInfo file     = FileManager.Instance.GetFile(PortalSettings.PortalId, filePath);

                    if (file != null)
                    {
                        FileManager.Instance.RenameFile(file, itemCommand.ToPath);
                    }
                    else
                    {
                        return(Request.CreateResponse(HttpStatusCode.NotFound, fileName));
                    }
                }

                return(Request.CreateResponse(HttpStatusCode.OK));
            }
            catch
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, LocalizeString("UnattentedError")));
            }
        }
示例#29
0
        /// <summary>
        /// Handle request to invoke an item command
        /// </summary>
        /// <param name="itemCommand"></param>
        /// <param name="origin"></param>
        public CoreUseItemEvent HandleUseItemCommand(ItemCommand itemCommand, Item origin)
        {
            CoreUseItemEvent continueIfNull = null;

            if (itemCommand.Id == CommandJavascript)
            {
                var itemManager = ModuleManager.GetManager <IItemManager>();
                var item        = itemManager.Read(itemCommand.ItemId.Value);
                ExecuteFunction(item, "onUse", itemCommand, origin);
                continueIfNull = new CoreUseItemEvent()
                {
                    Success = true,
                    Used    = item,
                    Using   = origin,
                    Use     = itemCommand
                };
            }
            return(continueIfNull);
        }
示例#30
0
            protected override void InitializeComponents()
            {
                base.InitializeComponents();
                this.Text = AppString.Dialog.NewSendToItem;
                this.Controls.AddRange(new[] { rdoFile, rdoFolder });
                rdoFile.Top    = rdoFolder.Top = btnOk.Top;
                rdoFile.Left   = lblCommand.Left;
                rdoFolder.Left = rdoFile.Right + 20.DpiZoom();

                btnBrowse.Click += (sender, e) =>
                {
                    if (rdoFile.Checked)
                    {
                        BrowseFile();
                    }
                    else
                    {
                        BrowseFolder();
                    }
                };

                btnOk.Click += (sender, e) =>
                {
                    if (ItemText.IsNullOrWhiteSpace())
                    {
                        MessageBoxEx.Show(AppString.MessageBox.TextCannotBeEmpty);
                        return;
                    }
                    if (ItemCommand.IsNullOrWhiteSpace())
                    {
                        MessageBoxEx.Show(AppString.MessageBox.CommandCannotBeEmpty);
                        return;
                    }
                    if (ObjectPath.ExtractFilePath(ItemCommand) == null && !Directory.Exists(ItemCommand))
                    {
                        MessageBoxEx.Show(AppString.MessageBox.FileOrFolderNotExists);
                        return;
                    }
                    AddNewItem();
                    DialogResult = DialogResult.OK;
                };
            }
示例#31
0
    public void Draw()
    {
        GUITool.DrawRect(controlArea, Color.gray);

        float rowWidth = controlArea.width - 20;
        float rowHeight = Constants.Instance.Font.Block * 2;
        Rect rowRect = new Rect(controlArea.x + 10, controlArea.y + 10, rowWidth, rowHeight);

        int j = 0;
        foreach (var type in buttonTypes)
        {
            string buttonName = type.ToString();
            if (type is BlockEntity2)
            {
                BlockEntity2 blockEntity = type as BlockEntity2;
                int minCount = 3;
                int maxCount = 7;
                var counts = Enumerable.Range(minCount, maxCount - minCount + 1);

                Rect buttonRect = new Rect(rowRect.x, rowRect.y, rowRect.width / counts.Count(), rowRect.height);
                foreach (var count in counts)
                {
                    if (GUITool.Button(buttonRect, Color.white, buttonName + count, Color.black, Constants.Instance.Font.Block, isEnable))
                    {
                        bool isCharged = ((int)count == 7);
                        blockQueue.TryAdd(new BlockCommand(blockEntity, count, isCharged, -1));
                    }

                    buttonRect.x += buttonRect.width;
                }
            }
            else if (type as string == "damage")
            {
                /*
                if (GUITool.Button(rowRect, Color.white, "damage", Color.black, Constants.Instance.Font.Block, isEnable))
                {
                    int damage = 100;
                    Command.FireCondition condition = delegate(Automaton firer)
                    {
                        return (firer as HeroCharacter).HP > damage;
                    };
                    string actionPattern = string.Format("Action( Self; RecoverHP; -{0})", damage);
                    //blockQueue.TryAdd(new Command(string.Empty, actionPattern, 0, 0, 0, false, condition));
                    heroCharacter.ApplyAction(ActionPattern.Create(actionPattern).Generate(heroCharacter.Stat) as ActionSingle, null);
                }
                */
            }
            else if (type as string == "item")
            {
                var groupTypes = EnumTool.GetValues<ConsumableType>();

                Rect buttonRect = new Rect(rowRect.x, rowRect.y, rowRect.width / groupTypes.Count(), rowRect.height);
                foreach(var entity in groupTypes)
                {
                    string label = StringTool.SplitCamelNotation(entity.ToString())[0];
                    if (GUITool.Button(buttonRect, Color.white, label, Color.black, Constants.Instance.Font.Block, isEnable))
                    {
                        //ItemCommand itemCommand = itemDropManager.DropItem(entity, itemDropTier);
                        ItemCommand itemCommand = new ItemCommand(itemDropManager.Pick());
                        heroCharacter.TryAddItem(itemCommand);
                    }
                    buttonRect.x += buttonRect.width;
                }
            }

            rowRect.y += rowRect.height;
            j++;
        }
    }
示例#32
0
文件: FieldItem.cs 项目: pb0/ID0_Test
 public FieldItem(FieldInstance parent, ItemCommand item)
     : base(E_OverlapEvent.Trigger, 1, 1, WorldAnchor.BottomLeft)
 {
     this.item = item;
 }
示例#33
0
    static HeroCharacter CreateCharacter(FieldObjectEntity objectField, ClassLevelEntity levelEntity, TrainLevelEntity trainLevelEntity, SubClassEntity subClassEntity, InGameUser user, PuzzlePanel puzzlePanel, ConsumableSpawn itemDropManager, System.Action<StatusEffectEntity2> addBuffIcon, System.Action<StatusEffectEntity2> removeBuffIcon, FSM parentFsm)
    {
        Buff.Handle onBuff = delegate(Buff buff)
        {
            if (addBuffIcon != null)
            {
                addBuffIcon(buff.statusEffectEntity);
            }
        };
        Buff.Handle onDeBuff = delegate(Buff buff)
        {
            if (removeBuffIcon != null)
            {
                removeBuffIcon(buff.statusEffectEntity);
            }
        };
        HeroCharacter heroCharacter = new HeroCharacter(objectField, subClassEntity, levelEntity, trainLevelEntity, false, user, puzzlePanel, onBuff, onDeBuff, parentFsm);

        {
            Action action = ActionPattern.Create("Vector(Self; [HeroStatType.moveSpeed]; 0; 0; false)").Generate(heroCharacter.Stat);
            heroCharacter.Fire(action, null);
            heroCharacter.PauseMoving();
        }

        for (int i = 0; i < 4; i++)
        {
            heroCharacter.AddItemSlot(i, user.commandQueue);
        }

        {
            heroCharacter.AddAction(Action.E_Type.Money,
                delegate(float value, GameInstance firer, string[] param)
                {
                    Action action = ActionPattern.Create("Action(User; Money; {0})").Generate(heroCharacter.Stat, value);
                    if (action != null)
                    {
                        heroCharacter.Fire(action, null);
                    }
                    return null;
                }
            );
            heroCharacter.AddAction(Action.E_Type.Exp,
                delegate(float value, GameInstance firer, string[] param)
                {
                    Action action = ActionPattern.Create("Action(User; Exp; {0})").Generate(heroCharacter.Stat, value);
                    if (action != null)
                    {
                        heroCharacter.Fire(action, null);
                    }
                    return null;
                }
            );
            heroCharacter.AddAction(Action.E_Type.GetConsumable,
                delegate(float value, GameInstance firer, string[] param)
                {
                    if (RandomTool.IsIn(value))
                    {
                        var itemCommand = new ItemCommand(itemDropManager.Pick());
                        if (itemCommand != null)
                        {
                            heroCharacter.TryAddItem(itemCommand);
                        }
                    }
                    return null;
                }
            );
        }

        return heroCharacter;
    }