Пример #1
0
 private void OnTextChanged(object sender, EventArgs e)
 {
     if (runChangedHandler)
     {
         IDEUtils.SetCommandArgs(CmdArgs.Text);
     }
 }
Пример #2
0
        private void savedMI_OnClick(object sender, RoutedEventArgs e)
        {
            if (!CmdArgsCtxMenu_SavedMenu.IsEnabled)
            {
                return;
            }

            MenuItem mi   = sender as MenuItem;
            string   args = ((TextBlock)mi.ToolTip).Text;

            IDEUtils.SetCommandArgs(args);

            foreach (MenuItem savedMI in CmdArgsCtxMenu_SavedMenu.Items)
            {
                if (((TextBlock)savedMI.ToolTip).Text == args)
                {
                    savedMI.IsChecked = true;
                }
                else
                {
                    savedMI.IsChecked = false;
                }
            }

            runChangedHandler = false;
            CmdArgs.Text      = IDEUtils.GetCommandArgs();
            runChangedHandler = true;
        }
Пример #3
0
        public static void Init()
        {
            history = new AutoSavingFixedSizeQueue <string>(Settings.Default.HistorySize);

            history.Path = Path.Combine(IDEUtils.GetStartupProjectDirectory(), "DockableCLArgsHistory.user");
            history.Load();
        }
Пример #4
0
        private void OnFocus(object sender, RoutedEventArgs e)
        {
            SetTextBoxProperties();

            runChangedHandler = false;
            CmdArgs.Text      = IDEUtils.GetCommandArgs();
            runChangedHandler = true;
        }
Пример #5
0
        private void SolutionEvents_OnAfterClosing()
        {
            lang = IDEUtils.ProjLang.UNKNOWN;

            runChangedHandler = false;
            CmdArgs.Text      = IDEUtils.GetCommandArgs();
            runChangedHandler = true;

            CmdArgs.IsEnabled = false;
        }
Пример #6
0
        public static void SetCommandArgs(string value)
        {
            EnvDTE.Properties props = IDEUtils.GetDtePropertiesFromHierarchy();
            if (props == null)
            {
                return;
            }
            switch (lang)
            {
            case ProjLang.CPP:
                IDEUtils.SetProperty(props, "CommandArguments", value);
                break;

            case ProjLang.CS:
                IDEUtils.SetProperty(props, "StartArguments", value);
                break;
            }
        }
Пример #7
0
        public DockableCLArgsControl()
        {
            InitializeComponent();

            savedArgs = new NamedArgsDictionary();

            debugEvents = IDEUtils.DTE.Events.DebuggerEvents;
            debugEvents.OnEnterRunMode += DebuggerEvents_OnEnterRunMode;

            solutionEvents               = IDEUtils.DTE.Events.SolutionEvents;
            solutionEvents.Opened       += SolutionEvents_OnOpened;
            solutionEvents.AfterClosing += SolutionEvents_OnAfterClosing;

            Properties.Settings.Default.PropertyChanged += OnSettingChanged;

            foreach (var commandBinding in CmdArgs.TextArea.CommandBindings.Cast <CommandBinding>())
            {
                if (commandBinding.Command == ApplicationCommands.Paste)
                {
                    commandBinding.PreviewCanExecute += new CanExecuteRoutedEventHandler(pasteCommandBinding_PreviewCanExecute);
                    break;
                }
            }

            SetTextBoxProperties();

            runChangedHandler = false;
            CmdArgs.Text      = IDEUtils.GetCommandArgs();
            runChangedHandler = true;

            CmdArgs.IsEnabled = false;

            try
            {
                Init();
            }
            catch (Exception)
            {
                throw;// Don't care if it fails here
            }
        }
Пример #8
0
        private void Init()
        {
            lang = IDEUtils.LANG;

            CmdArgs.FontFamily = new FontFamily(Properties.Settings.Default.Font.FontFamily.Name);
            CmdArgs.FontSize   = Properties.Settings.Default.Font.SizeInPoints;

            EnvDTE.Properties props = IDEUtils.GetDtePropertiesFromHierarchy();
            if (props == null)
            {
                runChangedHandler = false;
                CmdArgs.Text      = DockableCLArgs.Resources.StartupMessage;
                runChangedHandler = true;
            }
            else
            {
                if (lang != IDEUtils.ProjLang.UNKNOWN)
                {
                    runChangedHandler = false;
                    CmdArgs.Text      = IDEUtils.GetCommandArgs();
                    runChangedHandler = true;

                    CmdArgs.IsEnabled = true;

                    History.Init();

                    savedArgs.Path = Path.Combine(IDEUtils.GetStartupProjectDirectory(), "DockableCLArgsSavedArgs.user");
                    savedArgs.Load();
                }
                else
                {
                    runChangedHandler = false;
                    CmdArgs.Text      = DockableCLArgs.Resources.UnsupportedProjectType;
                    runChangedHandler = true;
                }
            }

            SetTextBoxProperties();
        }
Пример #9
0
        public static string GetCommandArgs()
        {
            EnvDTE.Properties props = IDEUtils.GetDtePropertiesFromHierarchy();
            if (props == null)
            {
                return(DockableCLArgs.Resources.StartupMessage);
            }

            string commandArgs = string.Empty;

            switch (lang)
            {
            case ProjLang.CPP:
                commandArgs = IDEUtils.GetProperty(props, "CommandArguments") as string ?? string.Empty;
                break;

            case ProjLang.CS:
                commandArgs = IDEUtils.GetProperty(props, "StartArguments") as string ?? string.Empty;
                break;
            }

            return(commandArgs);
        }
Пример #10
0
        private void historyMI_OnClick(object sender, RoutedEventArgs e)
        {
            MenuItem mi   = sender as MenuItem;
            string   args = ((TextBlock)mi.Header).Text;

            IDEUtils.SetCommandArgs(args);

            foreach (MenuItem historyMI in CmdArgsCtxMenu_HistoryMenu.Items)
            {
                if (((TextBlock)historyMI.Header).Text == args)
                {
                    historyMI.IsChecked = true;
                }
                else
                {
                    historyMI.IsChecked = false;
                }
            }

            runChangedHandler = false;
            CmdArgs.Text      = IDEUtils.GetCommandArgs();
            runChangedHandler = true;
        }
Пример #11
0
 private void OnCmdArgsCtxMenu_Paste(object sender, RoutedEventArgs e)
 {
     CmdArgs.Paste();
     IDEUtils.SetCommandArgs(CmdArgs.Text);
 }
Пример #12
0
        private void BuildContextMenu()
        {
            CmdArgsCtxMenu_Cut.IsEnabled   = true;
            CmdArgsCtxMenu_Copy.IsEnabled  = true;
            CmdArgsCtxMenu_Paste.IsEnabled = true;

            CmdArgsCtxMenu_SavedMenu.IsEnabled   = false;
            CmdArgsCtxMenu_SavedMenu.Header      = "Saved";
            CmdArgsCtxMenu_HistoryMenu.IsEnabled = false;
            CmdArgsCtxMenu_HistoryMenu.Header    = "History";

            if (String.IsNullOrEmpty(CmdArgs.SelectedText))
            {
                CmdArgsCtxMenu_Cut.IsEnabled  = false;
                CmdArgsCtxMenu_Copy.IsEnabled = false;
            }
            if (!Clipboard.ContainsText())
            {
                CmdArgsCtxMenu_Paste.IsEnabled = false;
            }

            if (savedArgs.Count > 0)
            {
                CmdArgsCtxMenu_SavedMenu.IsEnabled = true;

                CmdArgsCtxMenu_SavedMenu.Items.Clear();
                foreach (KeyValuePair <string, string> kvp in savedArgs)
                {
                    MenuItem savedMI = new MenuItem();

                    DockPanel savedMIPanel = new DockPanel();
                    savedMIPanel.LastChildFill       = false;
                    savedMIPanel.HorizontalAlignment = System.Windows.HorizontalAlignment.Right;

                    TextBlock textBlock = new TextBlock();
                    textBlock.Text = kvp.Key;
                    savedMIPanel.Children.Add(textBlock);

                    Button deleteButton = new Button();
                    deleteButton.Content = new System.Windows.Controls.Image
                    {
                        Source = new BitmapImage(new Uri("Resources/Delete.png", UriKind.Relative))
                    };
                    deleteButton.Margin = new Thickness(20, 0, 0, 0);
                    deleteButton.Click += deleteButton_OnClick;
                    savedMIPanel.Children.Add(deleteButton);

                    savedMI.Header      = savedMIPanel;
                    savedMI.Name        = "SavedEntry";
                    savedMI.IsCheckable = true;
                    if (kvp.Value == IDEUtils.GetCommandArgs())
                    {
                        savedMI.IsChecked = true;
                    }
                    savedMI.Click += savedMI_OnClick;

                    TextBlock toolTipTextBlock = new TextBlock();
                    toolTipTextBlock.Text         = kvp.Value;
                    toolTipTextBlock.TextWrapping = TextWrapping.Wrap;
                    savedMI.ToolTip = toolTipTextBlock;
                    ToolTipService.SetShowDuration(savedMI, 3600000);

                    CmdArgsCtxMenu_SavedMenu.Items.Add(savedMI);
                }

                CmdArgsCtxMenu_SavedMenu.Header = string.Format(CultureInfo.CurrentCulture, "Saved ({0})", CmdArgsCtxMenu_SavedMenu.Items.Count);

                CmdArgsCtxMenu_SavedMenu.UpdateLayout();
            }

            if (History.GetHistory.Count > 0)
            {
                CmdArgsCtxMenu_HistoryMenu.IsEnabled = true;

                CmdArgsCtxMenu_HistoryMenu.Items.Clear();
                foreach (string historyEntry in History.GetHistory)
                {
                    MenuItem  historyMI = new MenuItem();
                    TextBlock textBlock = new TextBlock();
                    textBlock.Text        = historyEntry;
                    historyMI.Header      = textBlock;
                    historyMI.Name        = "HistoryEntry";
                    historyMI.IsCheckable = true;
                    if (historyEntry == IDEUtils.GetCommandArgs())
                    {
                        historyMI.IsChecked = true;
                    }
                    historyMI.Click += historyMI_OnClick;

                    TextBlock toolTipTextBlock = new TextBlock();
                    toolTipTextBlock.Text         = historyEntry;
                    toolTipTextBlock.TextWrapping = TextWrapping.Wrap;
                    historyMI.ToolTip             = toolTipTextBlock;
                    ToolTipService.SetShowDuration(historyMI, 3600000);

                    CmdArgsCtxMenu_HistoryMenu.Items.Add(historyMI);
                }

                CmdArgsCtxMenu_HistoryMenu.Header = string.Format(CultureInfo.CurrentCulture, "History ({0}/{1})", CmdArgsCtxMenu_HistoryMenu.Items.Count, History.GetHistory.Size);

                CmdArgsCtxMenu_HistoryMenu.UpdateLayout();
            }
        }