コード例 #1
0
        private void OnRecentFileClick(object sender, MouseButtonEventArgs e)
        {
            string            filePath          = null;
            TextEditorControl textEditorControl = TextEditorControl.Instance;

            if (null != lstRecentFiles.SelectedItem)
            {
                filePath = ((RecentFile)lstRecentFiles.SelectedItem).FilePath;
            }

            if (string.IsNullOrEmpty(filePath))
            {
                return;
            }

            if (!System.IO.File.Exists(filePath))
            {
                // @TODO(Ananya): Ask if the user wants to remove the file from list.
                string           message          = string.Format("File '{0}' cannot be found! Do you want to remove the file from the Recent file list", filePath);
                MessageBoxResult messageBoxResult = MessageBox.Show(message, " ", MessageBoxButton.YesNo);
                if (messageBoxResult.Equals(MessageBoxResult.Yes))
                {
                    textEditorControl.TextCore.Data.RemoveFromRecentFileList(((RecentFile)lstRecentFiles.SelectedItem).FilePath);
                }

                recentFileList.Clear();
                recentFileList.AddRange(textEditorControl.TextCore.Data.RecentFiles);
                recentFileList.Reverse();

                lstRecentFiles.Items.Refresh();

                return;
            }

            if (textEditorControl.TextCore.LoadScriptFromFile(filePath))
            {
                textEditorControl.SetupTabInternal(filePath);
            }
            else
            {
                int index = Solution.Current.GetScriptIndexFromPath(filePath);
                if (index >= 0)
                {
                    textEditorControl.ScriptTabControl.ActivateTab(index);
                }
                else
                {
                    MessageBox.Show(Configurations.UnsupportedFileType);
                    return;
                }
            }

            textEditorControl.HandleScriptActivation();
            textEditorControl.grid.UpdateLayout();
            CommandManager.InvalidateRequerySuggested();
            textEditorControl.textCanvas.Focus();
        }
コード例 #2
0
        private void MadTypistBeingMad()
        {
            textEditorCore.EnableRegularCommands = false;
            // Close the default script that is open
            command = new TextEditorCommand(TextEditorCommand.Method.CloseScript);
            command.AppendArgument(0);
            textEditorCore.PlaybackCommand(command);
            textEditorControl.PlaybackCloseTab(0);
            command = new TextEditorCommand(TextEditorCommand.Method.ChangeScript);
            command.AppendArgument(0);
            textEditorCore.PlaybackCommand(command);
            textEditorControl.HandleScriptActivation();
            dispatchTimer       = new DispatcherTimer();
            dispatchTimer.Tick += new EventHandler(OnDispatchTimerTick);

            fileList = Directory.GetFiles(filePath,
                                          "*.ds", SearchOption.AllDirectories);
            dispatchTimer.Start();
        }
コード例 #3
0
        private void OnSampleFileClick(object sender, MouseButtonEventArgs e)
        {
            string            filePath          = null;
            TextEditorControl textEditorControl = TextEditorControl.Instance;

            if (null != InternalTreeView.SelectedItem)
            {
                filePath = ((SampleFileProperty)InternalTreeView.SelectedItem).FilePath;
            }

            if (string.IsNullOrEmpty(filePath) || !filePath.Contains(".ds"))
            {
                return;
            }

            if (!System.IO.File.Exists(filePath))
            {
                MessageBox.Show(string.Format("File '{0}' cannot be found!", filePath));
                return;
            }

            // @TODO(Ben): PRIORITY: Consolidate all these.
            if (textEditorControl.TextCore.LoadScriptFromFile(filePath))
            {
                textEditorControl.SetupTabInternal(filePath);
            }
            else
            {
                int index = Solution.Current.GetScriptIndexFromPath(filePath);
                if (index < 0)
                {
                    return;
                }

                textEditorControl.ScriptTabControl.ActivateTab(index);
            }

            textEditorControl.HandleScriptActivation();
            textEditorControl.grid.UpdateLayout();
            CommandManager.InvalidateRequerySuggested();
            textEditorControl.textCanvas.Focus();
        }