public RenamePresenterFactory(IVBE vbe, RenameDialog view, RubberduckParserState state, IMessageBox messageBox)
 {
     _vbe        = vbe;
     _view       = view;
     _state      = state;
     _messageBox = messageBox;
 }
        protected override void ExecuteImpl(object parameter)
        {
            if (Vbe.ActiveCodePane == null)
            {
                return;
            }

            Declaration target;

            if (parameter != null)
            {
                target = parameter as Declaration;
            }
            else
            {
                target = _state.FindSelectedDeclaration(Vbe.ActiveCodePane);
            }

            if (target == null)
            {
                return;
            }

            using (var view = new RenameDialog())
            {
                var factory     = new RenamePresenterFactory(Vbe, view, _state, new MessageBox());
                var refactoring = new RenameRefactoring(Vbe, factory, new MessageBox(), _state);

                refactoring.Refactor(target);
            }
        }
 public void Rename()
 {
     using (RenameDialog dlg = new RenameDialog())
     {
         dlg.ShowDialog(MainForm.Instance, _resource);
     }
 }
Beispiel #4
0
        public override void OnExecute(CommandEventArgs e)
        {
            ISvnRepositoryItem item = EnumTools.GetSingle(e.Selection.GetSelection <ISvnRepositoryItem>());

            if (item == null)
            {
                return;
            }

            string newName = item.Origin.Target.FileName;

            if (e.Argument != null)
            {
                string[] items = e.Argument as string[];

                if (items != null)
                {
                    if (items.Length == 1)
                    {
                        newName = items[0];
                    }
                    else if (items.Length > 1)
                    {
                        newName = items[1];
                    }
                }
            }

            string logMessage;

            using (RenameDialog dlg = new RenameDialog())
            {
                dlg.Context = e.Context;
                dlg.OldName = item.Origin.Target.FileName;
                dlg.NewName = newName;

                if (DialogResult.OK != dlg.ShowDialog(e.Context))
                {
                    return;
                }
                newName    = dlg.NewName;
                logMessage = dlg.LogMessage;
            }

            try
            {
                Uri itemUri = SvnTools.GetNormalizedUri(item.Origin.Uri);
                e.GetService <IProgressRunner>().RunModal(CommandStrings.RenamingNodes,
                                                          delegate(object sender, ProgressWorkerArgs we)
                {
                    SvnMoveArgs ma = new SvnMoveArgs();
                    ma.LogMessage  = logMessage;
                    we.Client.RemoteMove(itemUri, new Uri(itemUri, newName), ma);
                });
            }
            finally
            {
                item.RefreshItem(true);
            }
        }
        public void RenameConnection(object sender, ExecutedRoutedEventArgs e)
        {
            var databaseInfo = ValidateMenuInfo(sender);

            if (databaseInfo == null)
            {
                return;
            }
            if (databaseInfo.DatabaseInfo.FromServerExplorer)
            {
                return;
            }
            try
            {
                var ro = new RenameDialog(databaseInfo.DatabaseInfo.Caption);
                ro.ShowModal();
                if (ro.DialogResult.HasValue && ro.DialogResult.Value && !string.IsNullOrWhiteSpace(ro.NewName) && !databaseInfo.DatabaseInfo.Caption.Equals(ro.NewName))
                {
                    DataConnectionHelper.RenameDataConnection(databaseInfo.DatabaseInfo.ConnectionString, ro.NewName);
                    var control = _parentWindow.Content as ExplorerControl;
                    if (control != null)
                    {
                        control.BuildDatabaseTree();
                    }
                    DataConnectionHelper.LogUsage("DatabaseRenameConnection");
                }
            }
            catch (Exception ex)
            {
                DataConnectionHelper.SendError(ex, databaseInfo.DatabaseInfo.DatabaseType);
            }
        }
Beispiel #6
0
        public void Rename(object sender, ExecutedRoutedEventArgs e)
        {
            var menuInfo = ValidateMenuInfo(sender);

            if (menuInfo != null)
            {
                try
                {
                    using (IRepository repository = RepoHelper.CreateRepository(menuInfo.Connectionstring))
                    {
                        RenameDialog ro = new RenameDialog(menuInfo.Name);
                        ro.Owner = Application.Current.MainWindow;
                        ro.ShowDialog();
                        if (ro.DialogResult.HasValue && ro.DialogResult.Value && !string.IsNullOrWhiteSpace(ro.NewName))
                        {
                            repository.RenameTable(menuInfo.Name, ro.NewName);
                            if (_parent != null)
                            {
                                _parent.BuildDatabaseTree();
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(DataConnectionHelper.ShowErrors(ex));
                }
            }
        }
    private void ExecuteRenameProjectFile(PrintElementFile file)
    {
        string Validation(string newName)
        {
            if (string.Equals(file.FileName, newName, StringComparison.OrdinalIgnoreCase))
            {
                return(null);
            }

            var path = Path.Combine(Path.GetDirectoryName(file.FilePath), newName + file.FileExtension);

            if (File.Exists(path))
            {
                return(string.Format(_translationManager.GetTranslation(nameof(StringTable.Msg_FileAlreadyExists)), $"{newName}{file.FileExtension}"));
            }

            return(null);
        }

        var dialog = new RenameDialog(
            _translationManager.GetTranslation(nameof(StringTable.Title_RenameFile)),
            string.Format(_translationManager.GetTranslation(nameof(StringTable.Desc_RenameFile)), $"{file.FileName}{file.FileExtension}"),
            file.FileName,
            Validation)
        {
            Owner = Application.Current.MainWindow,
        };

        if (dialog.ShowDialog() == true)
        {
            var newPath = Path.Combine(Path.GetDirectoryName(file.FilePath), dialog.NewName + file.FileExtension);
            File.Move(file.FilePath, newPath);
        }
    }
Beispiel #8
0
        protected override void OnExecute(object parameter)
        {
            if (Vbe.ActiveCodePane == null)
            {
                return;
            }

            Declaration target;

            if (parameter != null)
            {
                target = parameter as Declaration;
            }
            else
            {
                target = _state.FindSelectedDeclaration(Vbe.ActiveCodePane);
            }

            if (target == null || !target.IsUserDefined)
            {
                return;
            }

            using (var view = new RenameDialog(new RenameViewModel(_state)))
            {
                var factory     = new RenamePresenterFactory(Vbe, view, _state);
                var refactoring = new RenameRefactoring(Vbe, factory, _messageBox, _state);

                refactoring.Refactor(target);
            }
        }
Beispiel #9
0
        public void Rename(object sender, ExecutedRoutedEventArgs e)
        {
            var menuInfo = ValidateMenuInfo(sender);

            if (menuInfo == null)
            {
                return;
            }
            try
            {
                using (IRepository repository = Helpers.DataConnectionHelper.CreateRepository(menuInfo.DatabaseInfo))
                {
                    RenameDialog ro = new RenameDialog(menuInfo.Name);
                    ro.ShowModal();
                    if (ro.DialogResult.HasValue && ro.DialogResult.Value == true && !string.IsNullOrWhiteSpace(ro.NewName) && !menuInfo.Name.Equals(ro.NewName))
                    {
                        repository.RenameTable(menuInfo.Name, ro.NewName);
                        if (ParentWindow != null && ParentWindow.Content != null)
                        {
                            ExplorerControl control = ParentWindow.Content as ExplorerControl;
                            control.RefreshTables(menuInfo.DatabaseInfo);
                        }
                        Helpers.DataConnectionHelper.LogUsage("TableRename");
                    }
                }
            }
            catch (Exception ex)
            {
                Helpers.DataConnectionHelper.SendError(ex, menuInfo.DatabaseInfo.DatabaseType, false);
            }
        }
Beispiel #10
0
        private void Rename()
        {
            var progress = new ParsingProgressPresenter();
            var result   = progress.Parse(_parser, _vbe.ActiveVBProject);

            var designer = (dynamic)_vbe.SelectedVBComponent.Designer;

            foreach (var control in designer.Controls)
            {
                if (!control.InSelection)
                {
                    continue;
                }

                var controlToRename =
                    result.Declarations.Items
                    .FirstOrDefault(item => item.IdentifierName == control.Name &&
                                    item.ComponentName == _vbe.SelectedVBComponent.Name &&
                                    _vbe.ActiveVBProject.Equals(item.Project));

                using (var view = new RenameDialog())
                {
                    var factory     = new RenamePresenterFactory(_vbe, view, result);
                    var refactoring = new RenameRefactoring(factory);
                    refactoring.Refactor(controlToRename);
                }
            }
        }
Beispiel #11
0
        public void RenameNode(object sender, ExecutedRoutedEventArgs e)
        {
            var menuInfo = ValidateMenuInfo(sender);

            if (menuInfo == null)
            {
                return;
            }

            try
            {
                var ro = new RenameDialog(menuInfo.Name);
                ro.ShowModal();
                if (ro.DialogResult.HasValue && ro.DialogResult.Value == true && !string.IsNullOrWhiteSpace(ro.NewName) && !menuInfo.Name.Equals(ro.NewName))
                {
                    UmbracoApplicationContext.Current.Rename(menuInfo.NodeType, ro.NewName, menuInfo.NodeId);

                    if (_parentWindow != null && _parentWindow.Content != null)
                    {
                        var control = _parentWindow.Content as ExplorerControl;
                        control.RefreshItems(menuInfo.NodeType, menuInfo.NodeTypeName, ro.NewName);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("An error occured: " + ex.Message);
            }
        }
        protected override void OnExecute(object parameter)
        {
            Declaration target;

            using (var activePane = Vbe.ActiveCodePane)
            {
                if (activePane == null || activePane.IsWrappingNullReference)
                {
                    return;
                }

                if (parameter != null)
                {
                    target = parameter as Declaration;
                }
                else
                {
                    target = _state.FindSelectedDeclaration(activePane);
                }
            }

            if (target == null || !target.IsUserDefined)
            {
                return;
            }

            using (var view = new RenameDialog(new RenameViewModel(_state)))
            {
                var factory     = new RenamePresenterFactory(Vbe, view, _state);
                var refactoring = new RenameRefactoring(Vbe, factory, _messageBox, _state, _state.ProjectsProvider, _rewritingManager);

                refactoring.Refactor(target);
            }
        }
        private void RenameActors(object sender, EventArgs args)
        {
            string ActorName = Path.GetFileNameWithoutExtension(Text);

            RenameDialog dialog = new RenameDialog();

            dialog.SetString(ActorName);

            if (dialog.ShowDialog() == DialogResult.OK)
            {
                string NewActorName = dialog.textBox1.Text;
                Text = NewActorName + ".szs";

                foreach (TreeNode node in Nodes)
                {
                    string NodeName = Path.GetFileNameWithoutExtension(node.Text);
                    string ext      = Utils.GetExtension(node.Text);
                    if (NodeName == ActorName)
                    {
                        node.Text = $"{NewActorName}{ext}";
                    }
                    else if (node.Text.Contains("Attribute.byml"))
                    {
                        node.Text = $"{NewActorName}Attribute.byml";
                    }
                }
            }
        }
Beispiel #14
0
 public RenameCommand(IVBE vbe, RenameDialog view, RubberduckParserState state, IMessageBox msgBox) : base(LogManager.GetCurrentClassLogger())
 {
     _vbe    = vbe;
     _state  = state;
     _view   = view;
     _msgBox = msgBox;
 }
Beispiel #15
0
 public bool CanEnterCharacter(RenameDialog dialog, int index, char c)
 {
     if (controllerDelegate != null)
     {
         return(controllerDelegate.IsCharacterValidForName(this, c));
     }
     return(false);
 }
Beispiel #16
0
        /// <summary>
        /// Renames an individual file.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void renameToolStripMenuItem_Click(object sender, EventArgs e)
        {
            // Get file name.
            RenameDialog searchBufferDialog = new RenameDialog(ArchiveFile.Name);

            ArchiveFile.Name = searchBufferDialog.ShowDialog();
            UpdateGUI(ref Archive);
        }
Beispiel #17
0
 public void Rename(Declaration target)
 {
     using (var view = new RenameDialog())
     {
         var parseResult = _parser.Parse(IDE.ActiveVBProject);
         var presenter   = new RenamePresenter(IDE, view, parseResult, new QualifiedSelection(target.QualifiedName.QualifiedModuleName, target.Selection));
         presenter.Show(target);
     }
 }
Beispiel #18
0
 //The rewriteSession is optional since it is not used in this particular quickfix because it is a refactoring quickfix.
 public override void Fix(IInspectionResult result, IRewriteSession rewriteSession = null)
 {
     using (var view = new RenameDialog(new RenameViewModel(_state)))
     {
         var factory     = new RenamePresenterFactory(_vbe, view, _state);
         var refactoring = new RenameRefactoring(_vbe, factory, _messageBox, _state, _state.ProjectsProvider, _rewritingManager);
         refactoring.Refactor(result.Target);
     }
 }
Beispiel #19
0
 public override void Fix(IInspectionResult result)
 {
     using (var view = new RenameDialog(new RenameViewModel(_state)))
     {
         var factory     = new RenamePresenterFactory(_vbe, view, _state);
         var refactoring = new RenameRefactoring(_vbe, factory, _messageBox, _state);
         refactoring.Refactor(result.Target);
     }
 }
Beispiel #20
0
 public void Rename(QualifiedSelection selection)
 {
     using (var view = new RenameDialog())
     {
         var parseResult = _parser.Parse(IDE.ActiveVBProject);
         var presenter   = new RenamePresenter(IDE, view, parseResult, selection);
         presenter.Show();
     }
 }
Beispiel #21
0
 private void RenameVideoInList()
 {
     if (SelectedVideo.Path != null)
     {
         var renameVideoDialog = new RenameDialog(SelectedVideo.Path);
         renameVideoDialog.ShowDialog();
         CheckForJdownloaderVideos();
         InitialiseVideoList();
     }
 }
Beispiel #22
0
        private void RenameFont(TreeNode selectedNode, int index)
        {
            RenameDialog dlg = new RenameDialog();

            dlg.SetString(selectedNode.Text);
            if (dlg.ShowDialog() == DialogResult.OK)
            {
                ActiveLayout.Fonts[index] = dlg.textBox1.Text;
                selectedNode.Text         = dlg.textBox1.Text;
            }
        }
Beispiel #23
0
        private void OnCancelRename(object parameter)
        {
            Log.Instance.LogInfo(string.Format("RenameViewModel.OnCancelRename {0}", parameter));

            RenameDialog w = parameter as RenameDialog;

            if (w != null)
            {
                w.Close();
            }
        }
Beispiel #24
0
 private void RenameDialogKeyDown(object sender, KeyEventArgs e)
 {
     if (e.Key == Key.Enter)
     {
         RenameDialog.OkButtonClick(null, null);
     }
     if (e.Key == Key.Escape)
     {
         RenameDialog.CancelButtonClick(null, null);
     }
 }
Beispiel #25
0
        //When rename is clicked on the flyout menu, you can rename your list into something different
        private async void Rename_Click(object sender, RoutedEventArgs e)
        {
            NewNameBox.Text = "";
            ContentDialogResult result = await RenameDialog.ShowAsync();

            if (result == ContentDialogResult.Primary && NewNameBox.Text != "")
            {
                handledDat.Title = NewNameBox.Text;
            }
            handledDat = null;
        }
Beispiel #26
0
 void Awake()
 {
     if (shared == null || shared == this)
     {
         shared = this;
     }
     else
     {
         Destroy(this.gameObject);
     }
 }
            private void Rename(object sender, EventArgs args)
            {
                RenameDialog dialog = new RenameDialog();

                dialog.SetString(Text);

                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    Text = dialog.textBox1.Text;
                }
            }
Beispiel #28
0
        public void Rename()
        {
            RenameDialog dialog = new RenameDialog();

            dialog.SetString(Text);

            if (dialog.ShowDialog() == DialogResult.OK)
            {
                RenameBone(dialog.textBox1.Text);
            }
        }
 private async void RenameFile_Click(object sender, RoutedEventArgs e)
 {
     if (SecureGridView.SelectedItem is FileSystemStorageItemBase RenameItem)
     {
         RenameDialog dialog = new RenameDialog(await RenameItem.GetStorageItem().ConfigureAwait(true));
         if ((await dialog.ShowAsync().ConfigureAwait(true)) == ContentDialogResult.Primary)
         {
             await(await RenameItem.GetStorageItem().ConfigureAwait(true)).RenameAsync(dialog.DesireName);
         }
     }
 }
Beispiel #30
0
        public virtual void Rename()
        {
            RenameDialog dialog = new RenameDialog();

            dialog.SetString(Text);

            if (dialog.ShowDialog() == DialogResult.OK)
            {
                Text = dialog.textBox1.Text;
            }
        }
Beispiel #31
0
        public override void OnExecute(CommandEventArgs e)
        {
            ISvnRepositoryItem item = EnumTools.GetSingle(e.Selection.GetSelection<ISvnRepositoryItem>());

            if (item == null)
                return;

            string newName = item.Origin.Target.FileName;

            if (e.Argument != null)
            {
                string[] items = e.Argument as string[];

                if (items != null)
                {
                    if (items.Length == 1)
                        newName = items[0];
                    else if (items.Length > 1)
                        newName = items[1];
                }
            }

            string logMessage;
            using (RenameDialog dlg = new RenameDialog())
            {
                dlg.Context = e.Context;
                dlg.OldName = item.Origin.Target.FileName;
                dlg.NewName = newName;

                if (DialogResult.OK != dlg.ShowDialog(e.Context))
                {
                    return;
                }
                newName = dlg.NewName;
                logMessage = dlg.LogMessage;
            }

            try
            {
                Uri itemUri = SvnTools.GetNormalizedUri(item.Origin.Uri);
                e.GetService<IProgressRunner>().RunModal(CommandStrings.RenamingNodes,
                    delegate(object sender, ProgressWorkerArgs we)
                    {
                        SvnMoveArgs ma = new SvnMoveArgs();
                        ma.LogMessage = logMessage;
                        we.Client.RemoteMove(itemUri, new Uri(itemUri, newName), ma);
                    });
            }
            finally
            {
                item.RefreshItem(true);
            }
        }
        public override void Fix()
        {
            var vbe = Selection.QualifiedName.Project.VBE;

            using (var view = new RenameDialog())
            {
                var factory = new RenamePresenterFactory(vbe, view, _state, _messageBox, _wrapperFactory);
                var refactoring = new RenameRefactoring(factory, new ActiveCodePaneEditor(vbe, _wrapperFactory), _messageBox, _state);
                refactoring.Refactor(_target);
                IsCancelled = view.DialogResult == DialogResult.Cancel;
            }
        }
        /// <summary>
        /// Provides core for the rename event
        /// </summary>
        protected void RenameCore()
        {
            IBoxModule box;
            if (Hover == null)
            {
                box = SelectedBoxes[0];
            }
            else
            {
                BoxNode bn = Hover as BoxNode;
                box= bn.Box;
            }

            RenameDialog renameDialog = new RenameDialog(box.UserName, ResManager);

            renameDialog.ShowDialog();
            if (renameDialog.DialogResult == DialogResult.OK)
            {
                if (box.TryWriteEnter())
                {
                    Text = renameDialog.NewName;
                    box.UserName = renameDialog.NewName;
                    box.WriteExit();

                    //refresh all the views
                    foreach (Desktop.IViewDisplayer view in Views)
                    {
                        view.Adapt();
                    }
                    archiveDisplayer.RefreshBoxNames();

                    //forcing the propertygrid to adapt
                    PropertiesDisplayer.SelectedBox = box;
                    PropertiesDisplayer.IsOneBoxSelected = true;
                    PropertiesDisplayer.Adapt();

                    //here we dont have to adapt the user note, the box
                    //remains the same

                    //selecting the box which name was changed
                    SelectBox(box);
                }
                else
                {
                    //set a message that it cannot happen
                    FrontEndCommon.CannotWriteToBox(box, ResManager);
                }
            }
        }
Beispiel #34
0
        private void c_RenameSelectedMenuItem_Click(object sender, EventArgs e)
        {
            if (this.c_FlowInterfaceControl.SelectedElement == null)
                return;

            var renameDialog = new RenameDialog(this.c_FlowInterfaceControl.SelectedElement.Name);
            if (renameDialog.ShowDialog() == DialogResult.OK)
            {
                this.c_FlowInterfaceControl.SelectedElement.Name = renameDialog.Name;
                this.c_FlowInterfaceControl.Invalidate();
            }
        }
 private void btnRename_Click(object sender, EventArgs e)
 {
     if ((lbxLogicTrees.Items.Count > 0) && (lbxLogicTrees.SelectedIndex >= 0))
     {
         RenameDialog newName = new RenameDialog();
         DialogResult result = newName.ShowDialog();
         if (result == System.Windows.Forms.DialogResult.OK)
         {
             try
             {
                 #region New Logic Tree
                 if (prntForm.mod.moduleLogicTreesList[prntForm._selectedLbxLogicTreeIndex] == "newLogicTree")
                 {
                     //if file exists, rename the file
                     string filePath = prntForm._mainDirectory + "\\modules\\" + prntForm.mod.moduleName + "\\logictree";
                     if (File.Exists(filePath + "\\" + prntForm.mod.moduleLogicTreesList[prntForm._selectedLbxLogicTreeIndex] + ".json"))
                     {
                         try
                         {
                             //rename file
                             File.Move(filePath + "\\" + prntForm.mod.moduleLogicTreesList[prntForm._selectedLbxLogicTreeIndex] + ".json", filePath + "\\" + newName.RenameText + ".json"); // Try to move
                             try
                             {
                                 //load area
                                 LogicTree newConvo = new LogicTree();
                                 newConvo = newConvo.GetLogicTree(filePath, "\\" + newName.RenameText + ".json");
                                 if (newConvo == null)
                                 {
                                     MessageBox.Show("returned a null LogicTree");
                                 }
                                 //change area file name in area file object properties
                                 newConvo.Filename = newName.RenameText;
                                 newConvo.SaveLogicTree(filePath, "\\" + newName.RenameText + ".json");
                                 prntForm.mod.moduleLogicTreesList[prntForm._selectedLbxLogicTreeIndex] = newName.RenameText;
                             }
                             catch (Exception ex)
                             {
                                 MessageBox.Show("failed to open file: " + ex.ToString());
                             }
                         }
                         catch (Exception ex)
                         {
                             MessageBox.Show(ex.ToString()); // Write error
                         }
                     }
                     else
                     {
                         prntForm.mod.moduleLogicTreesList[prntForm._selectedLbxLogicTreeIndex] = newName.RenameText;
                     }
                     refreshListBoxLogicTrees();
                 }
                 #endregion
                 #region Existing Logic Tree
                 else
                 {
                     DialogResult sure = MessageBox.Show("Are you sure you wish to change the Logic Tree name and the LogicTree file name? (make sure to update any references to this LogicTree name such as script hooks and trigger events)", "Are you sure?", MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk);
                     if (sure == System.Windows.Forms.DialogResult.Yes)
                     {
                         //if file exists, rename the file
                         string filePath = prntForm._mainDirectory + "\\modules\\" + prntForm.mod.moduleName + "\\logictree";
                         if (File.Exists(filePath + "\\" + prntForm.mod.moduleLogicTreesList[prntForm._selectedLbxLogicTreeIndex] + ".json"))
                         {
                             try
                             {
                                 //rename file
                                 File.Move(filePath + "\\" + prntForm.mod.moduleLogicTreesList[prntForm._selectedLbxLogicTreeIndex] + ".json", filePath + "\\" + newName.RenameText + ".json"); // Try to move
                                 try
                                 {
                                     //load convo
                                     LogicTree newConvo = new LogicTree();
                                     newConvo = newConvo.GetLogicTree(filePath, "\\" + newName.RenameText + ".json");
                                     if (newConvo == null)
                                     {
                                         MessageBox.Show("returned a null LogicTree");
                                     }
                                     //change convo file name in convo file object properties
                                     newConvo.Filename = newName.RenameText;
                                     newConvo.SaveLogicTree(filePath, "\\" + newName.RenameText + ".json");
                                     prntForm.mod.moduleLogicTreesList[prntForm._selectedLbxLogicTreeIndex] = newName.RenameText;
                                 }
                                 catch (Exception ex)
                                 {
                                     MessageBox.Show("failed to open file: " + ex.ToString());
                                 }
                             }
                             catch (Exception ex)
                             {
                                 MessageBox.Show(ex.ToString()); // Write error
                             }
                         }
                         else
                         {
                             prntForm.mod.moduleLogicTreesList[prntForm._selectedLbxLogicTreeIndex] = newName.RenameText;
                         }
                         refreshListBoxLogicTrees();
                     }
                 }
                 #endregion
             }
             catch { }
         }
     }
 }
Beispiel #36
0
 private void RenameTab(TabPage tab)
 {
     using (var dlg = new RenameDialog())
     {
         dlg.NameText = tab.Text;
         if (dlg.ShowDialog(this) == DialogResult.OK)
         {
             tab.Text = dlg.NameText;
         }
     }
 }
        private void OnRenameNode(object sender, EventArgs e)
        {
            var node = GetTreeNodeForContextMenuEvent(sender);
            if (node == null || (node.Tag as Node) == null)
            {
                return;
            }
            var sceneNode = (Node)node.Tag;

            SafeRenamer renamer = new SafeRenamer(_scene);
            HashSet<string> greylist = renamer.GetAllMeshNames();
            greylist.UnionWith(renamer.GetAllMaterialNames());
            greylist.UnionWith(renamer.GetAllAnimationNames());
            RenameDialog dialog = new RenameDialog(sceneNode.Name, renamer.GetAllNodeNames(), greylist);
            
            if (dialog.ShowDialog() == DialogResult.OK)
            {
                string newName = dialog.NewName;
                string oldName = sceneNode.Name;
                _scene.UndoStack.PushAndDo("Rename Node",
                    () =>
                    {
                        renamer.RenameNode(sceneNode, newName);
                        node.Text = newName;
                    },
                    () =>
                    {
                        renamer.RenameNode(sceneNode, oldName);
                        node.Text = oldName;
                    });
            }
        }
Beispiel #38
0
 private void btnRename_Click(object sender, EventArgs e)
 {
     if ((lbxIBScripts.Items.Count > 0) && (lbxIBScripts.SelectedIndex >= 0))
     {
         string scriptname = prntForm.mod.moduleIBScriptsList[prntForm._selectedLbxIBScriptIndex];
         RenameDialog newName = new RenameDialog();
         DialogResult result = newName.ShowDialog();
         if (result == System.Windows.Forms.DialogResult.OK)
         {
             try
             {
                 #region New IB Script
                 if (scriptname == "newIBScript")
                 {
                     //if file exists, rename the file
                     string filePath = prntForm._mainDirectory + "\\modules\\" + prntForm.mod.moduleName + "\\ibscript";
                     if (File.Exists(filePath + "\\" + scriptname + ".ibs"))
                     {
                         try
                         {
                             //rename file
                             File.Move(filePath + "\\" + scriptname + ".ibs", filePath + "\\" + newName.RenameText + ".ibs");
                             try
                             {
                                 prntForm.mod.moduleIBScriptsList[prntForm._selectedLbxIBScriptIndex] = newName.RenameText;
                             }
                             catch (Exception ex)
                             {
                                 MessageBox.Show("failed to open file: " + ex.ToString());
                             }
                         }
                         catch (Exception ex)
                         {
                             MessageBox.Show(ex.ToString()); // Write error
                         }
                     }
                     else
                     {
                         prntForm.mod.moduleIBScriptsList[prntForm._selectedLbxIBScriptIndex] = newName.RenameText;
                     }
                     refreshListBoxIBScripts();
                 }
                 #endregion
                 #region Existing IB Script
                 else
                 {
                     DialogResult sure = MessageBox.Show("Are you sure you wish to change this IB Script's file name? (make sure to update any references to this LogicTree name such as script hooks and trigger events)", "Are you sure?", MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk);
                     if (sure == System.Windows.Forms.DialogResult.Yes)
                     {
                         //if file exists, rename the file
                         string filePath = prntForm._mainDirectory + "\\modules\\" + prntForm.mod.moduleName + "\\ibscript";
                         if (File.Exists(filePath + "\\" + scriptname + ".ibs"))
                         {
                             try
                             {
                                 //rename file
                                 File.Move(filePath + "\\" + scriptname + ".ibs", filePath + "\\" + newName.RenameText + ".ibs");
                                 try
                                 {
                                     prntForm.mod.moduleIBScriptsList[prntForm._selectedLbxIBScriptIndex] = newName.RenameText;
                                 }
                                 catch (Exception ex)
                                 {
                                     MessageBox.Show("failed to open file: " + ex.ToString());
                                 }
                             }
                             catch (Exception ex)
                             {
                                 MessageBox.Show(ex.ToString()); // Write error
                             }
                         }
                         else
                         {
                             prntForm.mod.moduleIBScriptsList[prntForm._selectedLbxIBScriptIndex] = newName.RenameText;
                         }
                         refreshListBoxIBScripts();
                     }
                 }
                 #endregion
             }
             catch { }
         }
     }
 }
        private void OnRenameAnimation(object sender, EventArgs e)
        {
            if (ActiveRawAnimation == null)
            {
                return;
            }
            Animation animation = ActiveRawAnimation;

            SafeRenamer renamer = new SafeRenamer(_scene);
            // Animations names need not be unique even amongst themselves, but it's good if they are.
            // Put all names in the entire scene into the greylist.           
            RenameDialog dialog = new RenameDialog(animation.Name, new HashSet<string>(),
                renamer.GetAllAnimationNames());

            if (dialog.ShowDialog() == DialogResult.OK)
            {
                string newName = dialog.NewName;
                string oldName = animation.Name;
                _scene.UndoStack.PushAndDo("Rename Animation",
                    // Do
                    () => renamer.RenameAnimation(animation, newName),
                    // Undo
                    () => renamer.RenameAnimation(animation, oldName),
                    // Update
                    () => listBoxAnimations.Items[FindAnimationIndex(animation) + 1] = FormatAnimationName(animation));
            }
        }
        private void cm_OnCreateFolder(object sender, EventArgs e)
        {
            if (_currentNode != null &&
                _selectedNode != null &&
                _currentNode == _selectedNode)
            {
                FileBrowserNode node = _currentNode as FileBrowserNode;
                string newName = "";

                if (node != null)
                {
                    // Determine destingation to copy to
                    RenameDialog renameDialog = new RenameDialog("New Folder", RenameDialog.RENAME_OPERATION.NEW_FOLDER_NAME, this);

                    if (renameDialog.ShowDialog() == DialogResult.OK)
                    {
                        newName = node.Path + PathSeparator + renameDialog.GetName();

                        WinError error = FileClient.FileClient.CreateDirectory(newName);

                        if (error != WinError.NO_ERROR)
                        {
                            string message = "Create directory operation failed. Error: " + error.ToString();
                            MessageBox.Show(message, "Could not create new directory", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                }
            }
        }
        private void cm_OnRename(object sender, EventArgs e)
        {
            if (_currentNode != null &&
                _selectedNode != null &&
                _currentNode == _selectedNode)
            {
                FileBrowserNode node = _currentNode as FileBrowserNode;
                FileBrowserNode parent = _currentNode.Parent as FileBrowserNode;
                string newName = "";

                if (node != null &&
                    parent != null)
                {
                    // Determine destingation to copy to
                    RenameDialog renameDialog = new RenameDialog(node.Name, RenameDialog.RENAME_OPERATION.RENAME_DIRECTORY, this);

                    if (renameDialog.ShowDialog() == DialogResult.OK)
                    {
                        newName = renameDialog.GetName();

                        WinError error = FileClient.FileClient.MoveDirectory(parent.Path, parent.Path, node.Name, newName, true);

                        if (error != WinError.NO_ERROR)
                        {
                            string message = "Rename directory operation failed. Error: " + error.ToString();
                            MessageBox.Show(message, "Could not rename directory", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                }
            }
        }
Beispiel #42
0
        public void Rename(Declaration target)
        {
            var progress = new ParsingProgressPresenter();
            var result = progress.Parse(_parser, IDE.ActiveVBProject);

            using (var view = new RenameDialog())
            {
                var factory = new RenamePresenterFactory(IDE, view, result);
                var refactoring = new RenameRefactoring(factory);
                refactoring.Refactor(target);
            }
        }
Beispiel #43
0
        private void renameBreakpointToolStripMenuItem_Click( object sender, EventArgs e )
        {
            Instruction instr = this.GetContextInstruction();
            if( instr == null )
                return;

            Breakpoint bp = instr.Breakpoint;
            RenameDialog dialog = new RenameDialog();
            dialog.Target = RenameTarget.Breakpoint;
            dialog.Value = bp.Name ?? "";
            if( dialog.ShowDialog( this.FindForm() ) == DialogResult.OK )
            {
                bp.Name = dialog.Value;
                _debugger.Breakpoints.Save();
            }

            this.ContextReturn();
        }
Beispiel #44
0
 private void btnRename_Click(object sender, EventArgs e)
 {
     if ((lbxAreas.Items.Count > 0) && (lbxAreas.SelectedIndex >= 0))
     {
         RenameDialog newName = new RenameDialog();
         DialogResult result = newName.ShowDialog();
         if (result == System.Windows.Forms.DialogResult.OK)
         {
             try
             {
                 #region New Area
                 if (prntForm.mod.moduleAreasList[prntForm._selectedLbxAreaIndex] == "new area")
                 {
                     //if file exists, rename the file
                     string filePath = prntForm._mainDirectory + "\\modules\\" + prntForm.mod.moduleName + "\\areas";
                     if (File.Exists(filePath + "\\" + prntForm.mod.moduleAreasList[prntForm._selectedLbxAreaIndex] + ".lvl"))
                     {
                         try
                         {
                             //rename file
                             File.Move(filePath + "\\" + prntForm.mod.moduleAreasList[prntForm._selectedLbxAreaIndex] + ".lvl", filePath + "\\" + newName.RenameText + ".lvl"); // Try to move
                             try
                             {
                                 //load area
                                 Area newArea = new Area();
                                 newArea = newArea.loadAreaFile(filePath + "\\" + newName.RenameText + ".lvl");
                                 if (newArea == null)
                                 {
                                     MessageBox.Show("returned a null area");
                                 }
                                 //change area file name in area file object properties
                                 newArea.Filename = newName.RenameText;
                                 newArea.saveAreaFile(filePath + "\\" + newName.RenameText + ".lvl");
                                 prntForm.mod.moduleAreasList[prntForm._selectedLbxAreaIndex] = newName.RenameText;
                             }
                             catch (Exception ex)
                             {
                                 MessageBox.Show("failed to open file: " + ex.ToString());
                             }
                         }
                         catch (Exception ex)
                         {
                             MessageBox.Show(ex.ToString()); // Write error
                         }
                     }
                     else
                     {
                         prntForm.mod.moduleAreasList[prntForm._selectedLbxAreaIndex] = newName.RenameText;
                     }
                     refreshListBoxAreas();
                 }
                 #endregion
                 #region Existing Area
                 else
                 {
                     DialogResult sure = MessageBox.Show("Are you sure you wish to change the area name and the area file name? (make sure to update any references to this area name such as transitions and scripts)", "Are you sure?", MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk);
                     if (sure == System.Windows.Forms.DialogResult.Yes)
                     {
                         //if file exists, rename the file
                         string filePath = prntForm._mainDirectory + "\\modules\\" + prntForm.mod.moduleName + "\\areas";
                         if (File.Exists(filePath + "\\" + prntForm.mod.moduleAreasList[prntForm._selectedLbxAreaIndex] + ".lvl"))
                         {
                             try
                             {
                                 //rename file
                                 File.Move(filePath + "\\" + prntForm.mod.moduleAreasList[prntForm._selectedLbxAreaIndex] + ".lvl", filePath + "\\" + newName.RenameText + ".lvl"); // Try to move
                                 try
                                 {
                                     //load area
                                     Area newArea = new Area();
                                     newArea = newArea.loadAreaFile(filePath + "\\" + newName.RenameText + ".lvl");
                                     if (newArea == null)
                                     {
                                         MessageBox.Show("returned a null area");
                                     }
                                     //change area file name in area file object properties
                                     newArea.Filename = newName.RenameText;
                                     newArea.saveAreaFile(filePath + "\\" + newName.RenameText + ".lvl");
                                     prntForm.mod.moduleAreasList[prntForm._selectedLbxAreaIndex] = newName.RenameText;
                                 }
                                 catch (Exception ex)
                                 {
                                     MessageBox.Show("failed to open file: " + ex.ToString());
                                 }
                             }
                             catch (Exception ex)
                             {
                                 MessageBox.Show(ex.ToString()); // Write error
                             }
                         }
                         else
                         {
                             prntForm.mod.moduleAreasList[prntForm._selectedLbxAreaIndex] = newName.RenameText;
                         }
                         refreshListBoxAreas();
                     }
                 }
                 #endregion
             }
             catch { }
         }
     }
 }
        //THIS HAS BEEN CHENGED BY FEDRA
        public void RenameClick(object sender, EventArgs e)
        {
            if (activePanel == null)
                return;

            //setting the old name
            activePanel.Form.OldText = activePanel.Form.Text;

            //invoking a rename dialog
            RenameDialog dialog = new RenameDialog(activePanel.Form.Text);

            dialog.ShowDialog();
            if (dialog.DialogResult == DialogResult.OK)
            {
                activePanel.Form.Text = dialog.NewName;
            }
        }
Beispiel #46
0
        private void renameToolStripMenuItem_Click( object sender, System.EventArgs e )
        {
            MethodBody method;
            Line line = this.GetContextLine( out method );
            if( line == null )
                return;
            RenameTarget target = RenameTarget.Method;
            string value = "";
            switch( line.Type )
            {
                case LineType.Header:
                    target = RenameTarget.Method;
                    value = method.Name;
                    break;
                case LineType.Label:
                    target = RenameTarget.Label;
                    value = line.Instruction.Label.Name;
                    break;
                default:
                    return;
            }

            RenameDialog dialog = new RenameDialog();
            dialog.Target = target;
            dialog.Value = value;
            if( dialog.ShowDialog( this.FindForm() ) == DialogResult.OK )
            {
                switch( line.Type )
                {
                    case LineType.Header:
                        method.Name = dialog.Value;
                        {
                            bool found = false;
                            foreach( TagInfo tag in _debugger.UserData.CodeTags.MethodNames )
                            {
                                if( tag.Address == method.Address )
                                {
                                    found = true;
                                    tag.Value = dialog.Value;
                                    break;
                                }
                            }
                            if( found == false )
                            {
                                TagInfo tag = new TagInfo();
                                tag.Address = method.Address;
                                tag.Value = dialog.Value;
                                _debugger.UserData.CodeTags.MethodNames.Add( tag );
                            }
                            _debugger.CodeCache.Version++;
                            _debugger.UserData.Save();
                        }
                        break;
                    case LineType.Label:
                        line.Instruction.Label.Name = dialog.Value;
                        {
                            bool found = false;
                            foreach( TagInfo tag in _debugger.UserData.CodeTags.LabelNames )
                            {
                                if( tag.Address == line.Instruction.Address )
                                {
                                    found = true;
                                    tag.Value = dialog.Value;
                                    break;
                                }
                            }
                            if( found == false )
                            {
                                TagInfo tag = new TagInfo();
                                tag.Address = line.Instruction.Address;
                                tag.Value = dialog.Value;
                                _debugger.UserData.CodeTags.LabelNames.Add( tag );
                            }
                            _debugger.CodeCache.Version++;
                            _debugger.UserData.Save();
                        }
                        break;
                }
                this.Invalidate();
            }

            this.ContextReturn();
        }
 private void btnRename_Click(object sender, EventArgs e)
 {
     if ((lbxContainers.Items.Count > 0) && (lbxContainers.SelectedIndex >= 0))
     {
         RenameDialog newName = new RenameDialog();
         DialogResult result = newName.ShowDialog();
         if (result == System.Windows.Forms.DialogResult.OK)
         {
             try
             {
                 prntForm.containersList[prntForm._selectedLbxContainerIndex].containerTag = newName.RenameText;
                 refreshListBoxContainers();
             }
             catch { }
         }
     }
 }
Beispiel #48
0
 private void RenameVideoInList()
 {
     if(SelectedVideo.Path != null)
        {
        var renameVideoDialog = new RenameDialog(SelectedVideo.Path);
        renameVideoDialog.ShowDialog();
        CheckForJdownloaderVideos();
        InitialiseVideoList();
        }
 }
        private void OnRenameMesh(object sender, EventArgs e)
        {
            var node = GetTreeNodeForContextMenuEvent(sender);
            if (node == null || !(node.Tag as KeyValuePair<Node, Mesh>?).HasValue)
            {
                return;
            }
            var nodeMeshPair = (KeyValuePair<Node, Mesh>)node.Tag;
            var mesh = nodeMeshPair.Value;

            SafeRenamer renamer = new SafeRenamer(_scene);
            HashSet<string> greylist = renamer.GetAllNodeNames();
            greylist.UnionWith(renamer.GetAllMaterialNames());
            greylist.UnionWith(renamer.GetAllAnimationNames());
            // Mesh names need not be unique, but it's good if they are.
            // Don't put in blacklist though.
            greylist.UnionWith(renamer.GetAllMeshNames());
            RenameDialog dialog = new RenameDialog(mesh.Name, new HashSet<string>(), greylist);

            if (dialog.ShowDialog() == DialogResult.OK)
            {
                string newName = dialog.NewName;
                string oldName = mesh.Name;
                _scene.UndoStack.PushAndDo("Rename Mesh",
                    () =>
                    {
                        renamer.RenameMesh(mesh, newName);                       
                    },
                    () =>
                    {
                        renamer.RenameMesh(mesh, oldName);
                    },
                    () =>
                    {
                        node.Text = GetMeshDisplayName(mesh, GetIndexForMesh(mesh));
                    });
            }
        }
Beispiel #50
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {

                pbImage.Image.Save(_savepath + "/" + _keyword + "_" + _id + "." + _ext_tmp);
                MessageBox.Show("저장하였습니다.", "알림", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception)
            {
                try
                {
                    RenameDialog rd = new RenameDialog(_keyword + "_" + _id + "." + _ext_tmp);
                    if (rd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                    {
                        pbImage.Image.Save(_savepath + "/" + rd.NewFilename);
                        MessageBox.Show("저장하였습니다.", "알림", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
                catch
                {
                    MessageBox.Show("저장하지 못했습니다. 파일 이름을 다시 확인해 주세요.", "알림", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }
Beispiel #51
0
        void Rename()
        {
            RenameDialog dlg = new RenameDialog("Name: ");

            if (false == dlg.ShowDialog())
                return;

            Name = dlg.Value;
        }
 private void RenameExecuted(object sender, ExecutedRoutedEventArgs e)
 {
     if (ListViewExplorer.SelectedItems.Count > 1)
     {
         CustomErrorPopupTextBlock.Text = Properties.Resources.MwRenameError;
         CustomErrorPopup.IsOpen = true;
         SystemSounds.Exclamation.Play();
         return;
     }
     var listViewItem = e.OriginalSource as ListViewItem;
     var fsEntry = listViewItem?.DataContext as FileSystemInfo;
     if (fsEntry != null)
     {
         var renameDialog = new RenameDialog(fsEntry.Name)
         {
             WindowStartupLocation = WindowStartupLocation.CenterOwner,
             Owner = this
         };
         if (renameDialog.ShowDialog() != true) return;
         try
         {
             var dialogRes = renameDialog.Filename.Clone().ToString();
             var dirName = fsEntry.FullName.Substring(0, fsEntry.FullName.Length - fsEntry.Name.Length);
             Directory.Move(fsEntry.FullName, dirName + dialogRes);
             ListViewExplorer_Refresh();
         }
         catch (Exception)
         {
             ErrorPopup.IsOpen = true;
             SystemSounds.Exclamation.Play();
         }
     }
     else
     {
         var selectedItem = ListViewExplorer.SelectedItem as FileSystemInfo;
         if (selectedItem != null)
         {
             var renameDialog = new RenameDialog(selectedItem.Name)
             {
                 WindowStartupLocation = WindowStartupLocation.CenterOwner,
                 Owner = this
             };
             if (renameDialog.ShowDialog() != true) return;
             try
             {
                 var dialogRes = renameDialog.Filename.Clone().ToString();
                 var dirName = selectedItem.FullName.Substring(0, selectedItem.FullName.Length - selectedItem.Name.Length);
                 Directory.Move(selectedItem.FullName, dirName + dialogRes);
                 ListViewExplorer_Refresh();
             }
             catch (Exception)
             {
                 ErrorPopup.IsOpen = true;
                 SystemSounds.Exclamation.Play();
             }
         }
     }
 }
Beispiel #53
0
 private void renameButton_Click(object sender, EventArgs e)
 {
     RenameDialog d = new RenameDialog();
     d.ShowDialog(this);
     if (!d.Result) return;
     Rename();
     fnames.Clear();
     ReloadData();
 }