Пример #1
0
        /// <summary>
        /// Starts the actor renaming action.
        /// </summary>
        public void StartRenaming()
        {
            // Block renaming during scripts reload
            if (Editor.Instance.ProgressReporting.CompileScripts.IsActive)
            {
                return;
            }

            Select();

            // Start renaming the actor
            var dialog = RenamePopup.Show(this, HeaderRect, _actorNode.Name, false);

            dialog.Renamed += OnRenamed;
        }
Пример #2
0
            private void OnParameterRenamed(RenamePopup renamePopup)
            {
                var window = (VisjectSurfaceWindow <TAsset, TSurface, TPreview>)Values[0];
                var index  = (int)renamePopup.Tag;
                var action = new RenameParamAction
                {
                    Window = window,
                    Index  = index,
                    Before = window.Surface.Parameters[index].Name,
                    After  = renamePopup.Text,
                };

                window.Surface.Undo.AddAction(action);
                action.Do();
            }
Пример #3
0
        void renameAnimation_Click(object sender, EventArgs e)
        {
            var         animation = (AnimatedSurface)animations.SelectedItem;
            RenamePopup popup     = new RenamePopup(animation.Name);

            popup.Closed += (o, e2) =>
            {
                if (popup.DialogResult)
                {
                    entity.Animations.Remove(animation.Name);
                    animation.Name = popup.NewName;
                    entity.Animations[animation.Name] = animation;
                    animations.IsDirty = true;
                }
            };
            popup.Show(true);
            popup.Center();
        }
Пример #4
0
        void RenameEntity_Click(object sender, EventArgs e)
        {
            var         entity = (ResizableObject)GameObjectList.SelectedItem;
            RenamePopup popup  = new RenamePopup(entity.Name);

            popup.Closed += (o, e2) =>
            {
                if (popup.DialogResult)
                {
                    var editor = (Editors.SceneEditor)MainScreen.Instance.ActiveEditor;
                    editor.RenameGameObject(entity, popup.NewName);
                }

                GameObjectList.IsDirty = true;
            };
            popup.Show(true);
            popup.Center();
        }
Пример #5
0
        protected void RenameOKButton_Click(object sender, EventArgs e)
        {
            string targetFileName = FileHelper.GetSafeBaseImageName(RenameName.Text, true);

            if (!string.IsNullOrEmpty(targetFileName) && FileHelper.IsExtensionValid(targetFileName, AbleContext.Current.Store.Settings.FileExt_Themes))
            {
                string fullTargetFileName = Path.Combine(this.FullCurrentPath, targetFileName);
                if (fullTargetFileName != this.FullCurrentFileName)
                {
                    if (!File.Exists(fullTargetFileName))
                    {
                        File.Move(this.FullCurrentFileName, fullTargetFileName);
                        this.CurrentFileName = targetFileName;
                        BindCurrentFile();
                        BindFileListRepeater(true);
                    }
                    else
                    {
                        FileErrorMessage.Text    = "Target file already exists.";
                        FileErrorMessage.Visible = true;
                    }
                }
                else
                {
                    FileErrorMessage.Text    = "Souce and target file names are same.";
                    FileErrorMessage.Visible = true;
                }
            }
            else
            {
                FileErrorMessage.Text    = "File name is missing or invalid.";
                FileErrorMessage.Visible = true;
                CustomValidator filetype = new CustomValidator();
                filetype.IsValid           = false;
                filetype.ControlToValidate = "RenameName";
                filetype.ErrorMessage      = "'" + targetFileName + "' is not a valid file name.";
                filetype.Text            = "*";
                filetype.ValidationGroup = "Rename";
                phRenameValidFiles.Controls.Add(filetype);
                RenamePopup.Show();
            }
            RenameName.Text = string.Empty;
        }
Пример #6
0
        private void ShowRenameForm(string fileName)
        {
            FileInfo fi = new FileInfo(Path.Combine(_DigitalGoodPath, fileName));

            RenameDialogCaption.Text = string.Format(RenameDialogCaption.Text, fileName);
            RenameFileName.Text      = fileName;
            RenameFileSize.Text      = FileHelper.FormatFileSize(fi.Length);
            RenameNewFilename.Text   = fileName;
            RenameOverwrite.Checked  = false;
            IList <DigitalGood> goods = GetFileDigitalGoods(fi.Name);

            if (goods.Count > 0)
            {
                RenameDigitalGoodsList.DataSource = goods;
                RenameDigitalGoodsList.DataBind();
                // ALWAYS DEFAULT TO UPDATE THE GOODS
                UpdateDigitalGoodsOnRename.Checked = true;
                RenameGoodsMessage.Visible         = true;
                trRenameGoods.Visible = true;
            }
            else
            {
                RenameGoodsMessage.Visible = false;
                trRenameGoods.Visible      = false;
            }
            List <ListItem> folderList = GetFolderListItems(_BaseDigitalGoodPath, string.Empty, 0);

            folderList.Insert(0, new ListItem("(root)", string.Empty));
            RenameFileNewFolder.Items.Clear();
            RenameFileNewFolder.Items.AddRange(folderList.ToArray());
            ListItem selected = RenameFileNewFolder.Items.FindByValue(_RelativeDigitalGoodPath);

            if (selected != null)
            {
                RenameFileNewFolder.SelectedIndex = RenameFileNewFolder.Items.IndexOf(selected);
            }
            RenamePopup.Show();
        }
Пример #7
0
        private bool OnParameterRenameValidate(RenamePopup popup, string value)
        {
            var window = (IVisjectSurfaceWindow)Values[0];

            return(!string.IsNullOrWhiteSpace(value) && window.VisjectSurface.Parameters.All(x => x.Name != value));
        }
Пример #8
0
 private void OnRenamed(RenamePopup renamePopup)
 {
     using (new UndoBlock(ActorNode.Root.Undo, Actor, "Rename"))
         Actor.Name = renamePopup.Text;
 }
Пример #9
0
 private bool OnParameterRenameValidate(RenamePopup popup, string value)
 {
     return(!string.IsNullOrWhiteSpace(value) && !_proxy.DefaultValues.ContainsKey(value));
 }
Пример #10
0
 private bool OnRenameValidate(RenamePopup popup, string value)
 {
     return(Editor.ContentEditing.IsValidAssetName((ContentItem)popup.Tag, value, out _));
 }
Пример #11
0
            private void OnEditClicked(ContextMenuButton button)
            {
                var keyType = _editor.Values.Type.GetGenericArguments()[0];

                if (keyType == typeof(string) || keyType.IsPrimitive)
                {
                    var popup = RenamePopup.Show(Parent, Rectangle.Margin(Bounds, Margin), Text, false);
                    popup.Validate += (renamePopup, value) =>
                    {
                        object newKey;
                        if (keyType.IsPrimitive)
                        {
                            newKey = JsonSerializer.Deserialize(value, keyType);
                        }
                        else
                        {
                            newKey = value;
                        }
                        return(!((IDictionary)_editor.Values[0]).Contains(newKey));
                    };
                    popup.Renamed += renamePopup =>
                    {
                        object newKey;
                        if (keyType.IsPrimitive)
                        {
                            newKey = JsonSerializer.Deserialize(renamePopup.Text, keyType);
                        }
                        else
                        {
                            newKey = renamePopup.Text;
                        }

                        _editor.ChangeKey(_key, newKey);
                        _key = newKey;
                        Text = _key.ToString();
                    };
                }
                else if (keyType.IsEnum)
                {
                    var popup  = RenamePopup.Show(Parent, Rectangle.Margin(Bounds, Margin), Text, false);
                    var picker = new EnumComboBox(keyType)
                    {
                        AnchorPreset  = AnchorPresets.StretchAll,
                        Offsets       = Margin.Zero,
                        Parent        = popup,
                        EnumTypeValue = _key,
                    };
                    picker.ValueChanged += () =>
                    {
                        popup.Hide();
                        object newKey = picker.EnumTypeValue;
                        if (!((IDictionary)_editor.Values[0]).Contains(newKey))
                        {
                            _editor.ChangeKey(_key, newKey);
                            _key = newKey;
                            Text = _key.ToString();
                        }
                    };
                }
                else
                {
                    throw new NotImplementedException("Missing editing for dictionary key type " + keyType);
                }
            }
Пример #12
0
 private void OnRenamed(RenamePopup renamePopup)
 {
     using (new UndoBlock(Editor.Instance.Undo, Actor, "Rename"))
         Actor.Name = renamePopup.Text;
 }
Пример #13
0
            private void OnRenamed(RenamePopup popup)
            {
                var entry = (ImportFileEntry)Tag;

                entry.ModifyResultFilename(popup.Text);
            }
Пример #14
0
        protected void RenameButton_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                string sourceFileName = Path.GetFileName(RenameFileName.Text);
                string sourcePath     = Path.Combine(_DigitalGoodPath, sourceFileName);
                if (File.Exists(sourcePath))
                {
                    // FIGURE OUT THE TARGET FILENAME
                    string targetFileName = Path.GetFileName(RenameNewFilename.Text);
                    string targetFolder   = Path.Combine(_BaseDigitalGoodPath, RenameFileNewFolder.SelectedValue);
                    string targetPath     = Path.Combine(targetFolder, targetFileName);

                    if (FileHelper.IsExtensionValid(targetFileName, AbleContext.Current.Store.Settings.FileExt_DigitalGoods))
                    {
                        if (!File.Exists(targetPath) || RenameOverwrite.Checked)
                        {
                            // IF NECESSARY, REMOVE THE EXISTING TARGET FILE FROM DISK AND IN-MEMORY LIST
                            if (File.Exists(targetPath))
                            {
                                int targetIndex = IndexOfFile(targetFileName);
                                if (targetIndex > -1)
                                {
                                    _FileList.RemoveAt(targetIndex);
                                }
                                File.Delete(targetPath);
                            }
                            // MOVE THE FILE TO THE NEW NAME
                            File.Move(sourcePath, targetPath);
                            // UPDATE THE FILE IN THE LIST
                            int index = IndexOfFile(sourceFileName);
                            if (index > -1)
                            {
                                FileDigitalGood fdg = _FileList[index];
                                // SEE IF WE NEED TO UPDATE THE ASSOCIATED DIGITAL GOODS
                                if (UpdateDigitalGoodsOnRename.Checked)
                                {
                                    IList <DigitalGood> goods = GetFileDigitalGoods(sourceFileName);
                                    foreach (DigitalGood dg in goods)
                                    {
                                        dg.ServerFileName = RenameFileNewFolder.SelectedValue + targetFileName;
                                        if (dg.FileName == sourceFileName)
                                        {
                                            dg.FileName = targetFileName;
                                        }
                                        dg.Save();
                                    }
                                }
                                else
                                {
                                    fdg.DigitalGoods = null;
                                }
                                fdg.FileName = targetFileName;
                                RebindFileGrid();
                            }
                        }
                        else
                        {
                            CustomValidator overwrite = new CustomValidator();
                            overwrite.IsValid           = false;
                            overwrite.ControlToValidate = "RenameNewFileName";
                            overwrite.ErrorMessage      = "The target file '" + targetFileName + "' already exists.  Either allow overwrite or use an alternate file name.";
                            overwrite.Text            = "*";
                            overwrite.ValidationGroup = "Rename";
                            phRenameOverwrite.Controls.Add(overwrite);
                            RenamePopup.Show();
                        }
                    }
                    else
                    {
                        CustomValidator filetype = new CustomValidator();
                        filetype.IsValid           = false;
                        filetype.ControlToValidate = "RenameNewFileName";
                        filetype.ErrorMessage      = "The target file '" + targetFileName + "' does not have a valid file extension.";
                        filetype.Text            = "*";
                        filetype.ValidationGroup = "Rename";
                        phRenameFileExtensions.Controls.Add(filetype);
                        RenamePopup.Show();
                    }
                }
            }
            else
            {
                RenamePopup.Show();
            }
        }