Esempio n. 1
0
        public SearchController(ICookieStorageService cookieStorageService,
            PropertyControllerConfigurationProvider configurationProvider,
            PropertyService service)
            : base(cookieStorageService)
        {
            if (configurationProvider == null)
                throw new ArgumentNullException("configurationProvider");

            _configurationProvider = configurationProvider;

            if (service == null)
                throw new ArgumentNullException("service");

            _service = service;
        }
Esempio n. 2
0
 void SetIsRegexSearch(bool value)
 {
     PropertyService.Set("BufferSearchEngine", value ? RegexSearchEngine :
                         DefaultSearchEngine);
     SetSearchOptions();
 }
Esempio n. 3
0
 static void StoreHistory(string propertyKey, List <string> history)
 {
     PropertyService.Set(propertyKey, history != null ? String.Join(historySeparator.ToString(), history.ToArray()) : null);
 }
Esempio n. 4
0
 protected void UpdateSeverity()
 {
     severity = PropertyService.Get <Severity> (IdString, DefaultSeverity);
 }
Esempio n. 5
0
        protected void MyInitializeComponents()
        {
            InitializeComponent();

            foreach (Control ctl in Controls.GetRecursive())
            {
                ctl.Text = StringParser.Parse(ctl.Text);
            }
            this.Text = StringParser.Parse(this.Text);

            ImageList imglist = new ImageList();

            imglist.ColorDepth = ColorDepth.Depth32Bit;
            imglist.Images.Add(IconService.GetBitmap("Icons.16x16.OpenFolderBitmap"));
            imglist.Images.Add(IconService.GetBitmap("Icons.16x16.ClosedFolderBitmap"));
            categoryTreeView.ImageList = imglist;

            templateListView.SelectedIndexChanged += new EventHandler(SelectedIndexChange);
            categoryTreeView.AfterSelect          += new TreeViewEventHandler(CategoryChange);
            categoryTreeView.BeforeSelect         += new TreeViewCancelEventHandler(OnBeforeExpand);
            categoryTreeView.BeforeExpand         += new TreeViewCancelEventHandler(OnBeforeExpand);
            categoryTreeView.BeforeCollapse       += new TreeViewCancelEventHandler(OnBeforeCollapse);
            solutionNameTextBox.TextChanged       += new EventHandler(PathChanged);
            nameTextBox.TextChanged     += new EventHandler(PathChanged);
            locationTextBox.TextChanged += new EventHandler(PathChanged);

            if (createNewSolution)
            {
                createDirectoryForSolutionCheckBox.Checked         = CreateDirectoryForSolution;
                createDirectoryForSolutionCheckBox.CheckedChanged += delegate {
                    CreateDirectoryForSolution = createDirectoryForSolutionCheckBox.Checked;
                };
            }
            else
            {
                solutionNameTextBox.Visible = false;
                solutionNameLabel.Visible   = false;
                createDirectoryForSolutionCheckBox.Visible = false;
                bottomPanel.Height -= solutionNameTextBox.Height;

                createDirectoryForSolutionCheckBox.Checked = false;
            }

            largeIconsRadioButton.Checked         = PropertyService.Get("Dialogs.NewProjectDialog.LargeImages", true);
            largeIconsRadioButton.CheckedChanged += new EventHandler(IconSizeChange);
            largeIconsRadioButton.Image           = IconService.GetBitmap("Icons.16x16.LargeIconsIcon");

            smallIconsRadioButton.Checked         = !PropertyService.Get("Dialogs.NewProjectDialog.LargeImages", true);
            smallIconsRadioButton.CheckedChanged += new EventHandler(IconSizeChange);
            smallIconsRadioButton.Image           = IconService.GetBitmap("Icons.16x16.SmallIconsIcon");

            openButton.Click   += new EventHandler(OpenEvent);
            browseButton.Click += new EventHandler(BrowseDirectories);
            createDirectoryForSolutionCheckBox.CheckedChanged += new EventHandler(PathChanged);

            ToolTip tooltip = new ToolTip();

            tooltip.SetToolTip(largeIconsRadioButton, StringParser.Parse("${res:Global.LargeIconToolTip}"));
            tooltip.SetToolTip(smallIconsRadioButton, StringParser.Parse("${res:Global.SmallIconToolTip}"));
            tooltip.Active = true;

            IconSizeChange(this, EventArgs.Empty);
        }
 void UpdateDefaultGitSettings()
 {
     PropertyService.Set(UseGitPropertyName, projectConfiguration.UseGit);
     PropertyService.Set(CreateGitIgnoreFilePropertyName, projectConfiguration.CreateGitIgnoreFile);
 }
        public override bool KeyPress(KeyDescriptor descriptor)
        {
            completionWindowWasVisible   = CompletionWindowManager.IsVisible;
            cursorPositionBeforeKeyPress = Editor.CaretOffset;
            bool isSomethingSelected = Editor.IsSomethingSelected;

            if (descriptor.SpecialKey == SpecialKey.BackSpace && Editor.CaretOffset == lastInsertedSemicolon)
            {
                EditActions.Undo(Editor);
                lastInsertedSemicolon = -1;
                return(false);
            }

            lastInsertedSemicolon = -1;
            if (descriptor.KeyChar == ';' && Editor.EditMode == EditMode.Edit && !DoInsertTemplate() && !isSomethingSelected && PropertyService.Get(
                    "SmartSemicolonPlacement",
                    false
                    ) && !(stateTracker.IsInsideComment || stateTracker.IsInsideString))
            {
                bool   retval  = base.KeyPress(descriptor);
                var    curLine = Editor.GetLine(Editor.CaretLine);
                string text    = Editor.GetTextAt(curLine);
                if (!(text.EndsWith(";", StringComparison.Ordinal) || text.Trim().StartsWith("for", StringComparison.Ordinal)))
                {
                    int guessedOffset;

                    if (GuessSemicolonInsertionOffset(Editor, curLine, Editor.CaretOffset, out guessedOffset))
                    {
                        using (var undo = Editor.OpenUndoGroup()) {
                            Editor.RemoveText(Editor.CaretOffset - 1, 1);
                            Editor.CaretOffset    = guessedOffset;
                            lastInsertedSemicolon = Editor.CaretOffset + 1;
                            retval = base.KeyPress(descriptor);
                        }
                    }
                }
                using (var undo = Editor.OpenUndoGroup()) {
                    if (OnTheFlyFormatting && Editor != null && Editor.EditMode == EditMode.Edit)
                    {
                        OnTheFlyFormatter.FormatStatmentAt(Editor, DocumentContext, Editor.CaretLocation, optionSet: optionSet);
                    }
                }
                return(retval);
            }

            if (descriptor.SpecialKey == SpecialKey.Tab && descriptor.ModifierKeys == ModifierKeys.None && !CompletionWindowManager.IsVisible)
            {
                SafeUpdateIndentEngine(Editor.CaretOffset);
                if (stateTracker.IsInsideStringLiteral && !Editor.IsSomethingSelected)
                {
                    var lexer = new ICSharpCode.NRefactory.CSharp.Completion.CSharpCompletionEngineBase.MiniLexer(Editor.GetTextAt(0, Editor.CaretOffset));
                    lexer.Parse();
                    if (lexer.IsInString)
                    {
                        Editor.InsertAtCaret("\\t");
                        return(false);
                    }
                }
            }


            if (descriptor.SpecialKey == SpecialKey.Tab && DefaultSourceEditorOptions.Instance.TabIsReindent && !CompletionWindowManager.IsVisible && Editor.EditMode == EditMode.Edit && !DoInsertTemplate() && !isSomethingSelected)
            {
                ReindentOnTab();

                return(false);
            }

            SafeUpdateIndentEngine(Editor.CaretOffset);
            if (!stateTracker.IsInsideOrdinaryCommentOrString)
            {
                if (descriptor.KeyChar == '@')
                {
                    var retval = base.KeyPress(descriptor);
                    int cursor = Editor.CaretOffset;
                    if (cursor < Editor.Length && Editor.GetCharAt(cursor) == '"')
                    {
                        ConvertNormalToVerbatimString(Editor, cursor + 1);
                    }
                    return(retval);
                }
            }


            //do the smart indent
            if (!indentationDisabled)
            {
                bool retval;
                //capture some of the current state
                int  oldBufLen = Editor.Length;
                int  oldLine   = Editor.CaretLine + 1;
                bool reIndent  = false;

                //pass through to the base class, which actually inserts the character
                //and calls HandleCodeCompletion etc to handles completion
                using (var undo = Editor.OpenUndoGroup()) {
                    DoPreInsertionSmartIndent(descriptor.SpecialKey);
                }
                wasInStringLiteral = stateTracker.IsInsideStringLiteral;


                bool returnBetweenBraces =
                    descriptor.SpecialKey == SpecialKey.Return &&
                    descriptor.ModifierKeys == ModifierKeys.None &&
                    Editor.CaretOffset > 0 && Editor.CaretOffset < Editor.Length &&
                    Editor.GetCharAt(Editor.CaretOffset - 1) == '{' && Editor.GetCharAt(Editor.CaretOffset) == '}' && !stateTracker.IsInsideOrdinaryCommentOrString;

                bool automaticReindent;
                // need to be outside of an undo group - otherwise it interferes with other text editor extension
                // esp. the documentation insertion undo steps.
                retval = base.KeyPress(descriptor);


                if (descriptor.KeyChar == '/' && stateTracker.IsInsideMultiLineComment)
                {
                    if (Editor.CaretOffset - 3 >= 0 && Editor.GetCharAt(Editor.CaretOffset - 3) == '*' && Editor.GetCharAt(Editor.CaretOffset - 2) == ' ')
                    {
                        using (var undo = Editor.OpenUndoGroup()) {
                            Editor.RemoveText(Editor.CaretOffset - 2, 1);
                        }
                    }
                }

                //handle inserted characters
                if (Editor.CaretOffset <= 0 || Editor.IsSomethingSelected)
                {
                    return(retval);
                }

                lastCharInserted = TranslateKeyCharForIndenter(descriptor.SpecialKey, descriptor.KeyChar, Editor.GetCharAt(Editor.CaretOffset - 1));
                if (lastCharInserted == '\0')
                {
                    return(retval);
                }
                using (var undo = Editor.OpenUndoGroup()) {
                    if (returnBetweenBraces)
                    {
                        var oldOffset = Editor.CaretOffset;
                        Editor.InsertAtCaret(Editor.EolMarker);
                        DoReSmartIndent();
                        Editor.CaretOffset = oldOffset;
                    }

                    SafeUpdateIndentEngine(Editor.CaretOffset);

                    if (descriptor.SpecialKey == SpecialKey.Return && descriptor.ModifierKeys == ModifierKeys.Control)
                    {
                        FixLineStart(Editor, stateTracker, Editor.CaretLine + 1);
                    }
                    else
                    {
                        if (!(oldLine == Editor.CaretLine + 1 && lastCharInserted == '\n') && (oldBufLen != Editor.Length || lastCharInserted != '\0'))
                        {
                            DoPostInsertionSmartIndent(lastCharInserted, out reIndent);
                        }
                        else
                        {
                            reIndent = lastCharInserted == '\n';
                        }
                    }
                    //reindent the line after the insertion, if needed
                    //N.B. if the engine says we need to reindent, make sure that it's because a char was
                    //inserted rather than just updating the stack due to moving around

                    SafeUpdateIndentEngine(Editor.CaretOffset);
                    // Automatically reindent in text link mode will cause the mode exiting, therefore we need to prevent that.
                    automaticReindent = (stateTracker.NeedsReindent && lastCharInserted != '\0') && Editor.EditMode == EditMode.Edit;
                    if (descriptor.SpecialKey == SpecialKey.Return && (reIndent || automaticReindent))
                    {
                        if (Editor.Options.IndentStyle == IndentStyle.Virtual)
                        {
                            if (Editor.GetLine(Editor.CaretLine).Length == 0)
                            {
                                Editor.CaretColumn = Editor.GetVirtualIndentationColumn(Editor.CaretLine);
                            }
                        }
                        else
                        {
                            DoReSmartIndent();
                        }
                    }
                }

                const string reindentChars = ";){}";
                if (reIndent || descriptor.SpecialKey != SpecialKey.Return && descriptor.SpecialKey != SpecialKey.Tab && automaticReindent && reindentChars.Contains(descriptor.KeyChar))
                {
                    using (var undo = Editor.OpenUndoGroup()) {
                        DoReSmartIndent();
                    }
                }

                HandleOnTheFlyFormatting(descriptor);
                SafeUpdateIndentEngine(Editor.CaretOffset);
                lastCharInserted = '\0';
                CheckXmlCommentCloseTag(descriptor.KeyChar);
                return(retval);
            }

            if (Editor.Options.IndentStyle == IndentStyle.Auto && DefaultSourceEditorOptions.Instance.TabIsReindent && descriptor.SpecialKey == SpecialKey.Tab)
            {
                bool retval = base.KeyPress(descriptor);
                DoReSmartIndent();
                CheckXmlCommentCloseTag(descriptor.KeyChar);
                return(retval);
            }

            //pass through to the base class, which actually inserts the character
            //and calls HandleCodeCompletion etc to handles completion
            var result = base.KeyPress(descriptor);

            if (!indentationDisabled && (descriptor.SpecialKey == SpecialKey.Return))
            {
                DoReSmartIndent();
            }

            CheckXmlCommentCloseTag(descriptor.KeyChar);

            HandleOnTheFlyFormatting(descriptor);

            return(result);
        }
 internal static void StoreConfiguration()
 {
     PropertyService.Set("MonoDevelop.GtkCore.ShowNonContainerWarning", steticApp.ShowNonContainerWarning);
     PropertyService.SaveProperties();
 }
 public static IReadOnlyList <CustomizedHighlightingColor> LoadColors()
 {
     return(PropertyService.GetList <CustomizedHighlightingColor>("CustomizedHighlightingRules"));
 }
Esempio n. 10
0
        public void Initialize(IPadWindow window)
        {
            this.window      = window;
            window.PadShown += delegate {
                if (needsReload)
                {
                    Refresh();
                }
            };

            DockItemToolbar toolbar = window.GetToolbar(PositionType.Top);

            errorBtn        = new ToggleButton();
            errorBtn.Active = (bool)PropertyService.Get(showErrorsPropertyName, true);
            string errorTipText;

            if ((InternalLog.EnabledLoggingLevel & EnabledLoggingLevel.Error) != EnabledLoggingLevel.Error &&
                (InternalLog.EnabledLoggingLevel & EnabledLoggingLevel.Fatal) != EnabledLoggingLevel.Fatal)
            {
                errorBtn.Sensitive = false;
                errorTipText       = GettextCatalog.GetString("Logging of errors is not enabled");
            }
            else
            {
                errorTipText = GettextCatalog.GetString("Show errors");
            }
            errorBtn.Image = new Gtk.Image(Gtk.Stock.DialogError, Gtk.IconSize.Menu);
            errorBtn.Image.Show();
            errorBtn.Toggled    += new EventHandler(FilterChanged);
            errorBtn.TooltipText = errorTipText;
            UpdateErrorsNum();
            toolbar.Add(errorBtn);

            warnBtn        = new ToggleButton();
            warnBtn.Active = (bool)PropertyService.Get(showWarningsPropertyName, true);
            string warnTipText;

            if ((InternalLog.EnabledLoggingLevel & EnabledLoggingLevel.Warn) != EnabledLoggingLevel.Warn)
            {
                warnBtn.Sensitive = false;
                warnTipText       = GettextCatalog.GetString("Logging of warnings is not enabled");
            }
            else
            {
                warnTipText = GettextCatalog.GetString("Show warnings");
            }
            warnBtn.Image = new Gtk.Image(Gtk.Stock.DialogWarning, Gtk.IconSize.Menu);
            warnBtn.Image.Show();
            warnBtn.Toggled    += new EventHandler(FilterChanged);
            warnBtn.TooltipText = warnTipText;
            UpdateWarningsNum();
            toolbar.Add(warnBtn);

            msgBtn        = new ToggleButton();
            msgBtn.Active = (bool)PropertyService.Get(showMessagesPropertyName, true);
            string msgTipText;

            if ((InternalLog.EnabledLoggingLevel & EnabledLoggingLevel.Info) != EnabledLoggingLevel.Info)
            {
                msgBtn.Sensitive = false;
                msgTipText       = GettextCatalog.GetString("Logging of informational messages is not enabled");
            }
            else
            {
                msgTipText = GettextCatalog.GetString("Show messages");
            }
            msgBtn.Image = new Gtk.Image(Gtk.Stock.DialogInfo, Gtk.IconSize.Menu);
            msgBtn.Image.Show();
            msgBtn.Toggled    += new EventHandler(FilterChanged);
            msgBtn.TooltipText = msgTipText;
            UpdateMessagesNum();
            toolbar.Add(msgBtn);

            debugBtn        = new ToggleButton();
            debugBtn.Active = (bool)PropertyService.Get(showDebugPropertyName, true);
            string debugTipText;

            if ((InternalLog.EnabledLoggingLevel & EnabledLoggingLevel.Debug) != EnabledLoggingLevel.Debug)
            {
                debugBtn.Sensitive = false;
                debugTipText       = GettextCatalog.GetString("Logging of debug messages is not enabled");
            }
            else
            {
                debugTipText = GettextCatalog.GetString("Show debug");
            }
            debugBtn.Image = new Gtk.Image(Gtk.Stock.DialogQuestion, Gtk.IconSize.Menu);
            debugBtn.Image.Show();
            debugBtn.Toggled    += new EventHandler(FilterChanged);
            debugBtn.TooltipText = debugTipText;
            UpdateDebugNum();
            toolbar.Add(debugBtn);

            toolbar.Add(new SeparatorToolItem());

            Gtk.Button clearBtn = new Gtk.Button(new Gtk.Image(Gtk.Stock.Clear, Gtk.IconSize.Menu));
            clearBtn.Clicked += new EventHandler(OnClearList);
            toolbar.Add(clearBtn);
            toolbar.ShowAll();

            // Content

            store = new Gtk.ListStore(typeof(Gdk.Pixbuf),                    // image - type
                                      typeof(string),                        // desc
                                      typeof(string),                        // time
                                      typeof(string),                        // type string
                                      typeof(LogMessage));                   // message

            TreeModelFilterVisibleFunc filterFunct = new TreeModelFilterVisibleFunc(FilterTaskTypes);

            filter             = new TreeModelFilter(store, null);
            filter.VisibleFunc = filterFunct;

            view                   = new MonoDevelop.Ide.Gui.Components.PadTreeView(new Gtk.TreeModelSort(filter));
            view.RulesHint         = true;
            view.PopupMenu        += new PopupMenuHandler(OnPopupMenu);
            view.ButtonPressEvent += new ButtonPressEventHandler(OnButtonPressed);
            view.HeadersClickable  = true;
            view.Selection.Mode    = SelectionMode.Multiple;

            AddColumns();

            sw            = new Gtk.ScrolledWindow();
            sw.ShadowType = ShadowType.None;
            sw.Add(view);

            LoggingService.AddLogger(this);

            iconWarning = sw.RenderIcon(Gtk.Stock.DialogWarning, Gtk.IconSize.Menu, "");
            iconError   = sw.RenderIcon(Gtk.Stock.DialogError, Gtk.IconSize.Menu, "");
            iconInfo    = sw.RenderIcon(Gtk.Stock.DialogInfo, Gtk.IconSize.Menu, "");
            iconDebug   = sw.RenderIcon(Gtk.Stock.DialogQuestion, Gtk.IconSize.Menu, "");

            control = sw;
            sw.ShowAll();

            Refresh();

            store.SetSortFunc((int)Columns.Time, TimeSortFunc);
            ((TreeModelSort)view.Model).SetSortColumnId((int)Columns.Time, SortType.Descending);
        }
        public CSharpSyntaxMode(Document document)
        {
            this.guiDocument                 = document;
            guiDocument.DocumentParsed      += HandleDocumentParsed;
            SemanticHighlightingEnabled      = PropertyService.Get("EnableSemanticHighlighting", true);
            PropertyService.PropertyChanged += HandlePropertyChanged;
            if (guiDocument.ParsedDocument != null)
            {
                HandleDocumentParsed(this, EventArgs.Empty);
            }

            bool loadRules = _rules == null;

            if (loadRules)
            {
                var provider = new ResourceStreamProvider(typeof(ResourceStreamProvider).Assembly, typeof(ResourceStreamProvider).Assembly.GetManifestResourceNames().First(s => s.Contains("CSharpSyntaxMode")));
                using (var reader = provider.Open()) {
                    SyntaxMode baseMode = SyntaxMode.Read(reader);
                    _rules = new List <Rule> (baseMode.Rules.Where(r => r.Name != "Comment"));
                    _rules.Add(new Rule(this)
                    {
                        Name = "PreProcessorComment"
                    });

                    _commentRule = new Rule(this)
                    {
                        Name       = "Comment",
                        IgnoreCase = true
                    };
                    UpdateCommentRule();

                    _rules.Add(_commentRule);
                    _keywords               = new List <Keywords> (baseMode.Keywords);
                    _spans                  = new List <Span> (baseMode.Spans.Where(span => span.Begin.Pattern != "#")).ToArray();
                    _matches                = baseMode.Matches;
                    _prevMarker             = baseMode.PrevMarker;
                    _SemanticRules          = new List <SemanticRule> (baseMode.SemanticRules);
                    _keywordTable           = baseMode.keywordTable;
                    _keywordTableIgnoreCase = baseMode.keywordTableIgnoreCase;
                    _properties             = baseMode.Properties;
                }

                contextualHighlightKeywords = new Dictionary <string, string> ();
                foreach (var word in ContextualKeywords)
                {
                    if (_keywordTable.ContainsKey(word))
                    {
                        contextualHighlightKeywords[word] = _keywordTable[word].Color;
                    }
                    else
                    {
                        Console.WriteLine("missing keyword:" + word);
                    }
                }

                foreach (var word in ContextualKeywords)
                {
                    _keywordTable.Remove(word);
                }
            }

            rules                  = _rules;
            keywords               = _keywords;
            spans                  = _spans;
            matches                = _matches;
            prevMarker             = _prevMarker;
            SemanticRules          = _SemanticRules;
            keywordTable           = _keywordTable;
            keywordTableIgnoreCase = _keywordTableIgnoreCase;
            properties             = _properties;

            if (loadRules)
            {
                AddSemanticRule("Comment", new HighlightUrlSemanticRule("Comment(Line)"));
                AddSemanticRule("XmlDocumentation", new HighlightUrlSemanticRule("Comment(Doc)"));
                AddSemanticRule("String", new HighlightUrlSemanticRule("String"));
            }
        }
Esempio n. 12
0
        void CreateView()
        {
            if (view != null)
            {
                return;
            }

            ReloadPriorities();

            ProjectDomService.CommentTasksChanged       += OnCommentTasksChanged;
            ProjectDomService.SpecialCommentTagsChanged += OnCommentTagsChanged;
            IdeApp.Workspace.WorkspaceItemLoaded        += OnWorkspaceItemLoaded;
            IdeApp.Workspace.WorkspaceItemUnloaded      += OnWorkspaceItemUnloaded;

            highPrioColor   = StringToColor((string)PropertyService.Get("Monodevelop.UserTasksHighPrioColor", ""));
            normalPrioColor = StringToColor((string)PropertyService.Get("Monodevelop.UserTasksNormalPrioColor", ""));
            lowPrioColor    = StringToColor((string)PropertyService.Get("Monodevelop.UserTasksLowPrioColor", ""));

            store = new Gtk.ListStore(
                typeof(int),                         // line
                typeof(string),                      // desc
                typeof(string),                      // file
                typeof(string),                      // path
                typeof(Task),                        // task
                typeof(Gdk.Color),                   // foreground color
                typeof(int));                        // font weight

            view               = new MonoDevelop.Ide.Gui.Components.PadTreeView(store);
            view.RulesHint     = true;
            view.SearchColumn  = (int)Columns.Description;
            view.DoPopupMenu   = (evt) => IdeApp.CommandService.ShowContextMenu(view, evt, menu);
            view.RowActivated += new RowActivatedHandler(OnRowActivated);

            TreeViewColumn col;

            col           = view.AppendColumn(GettextCatalog.GetString("Line"), view.TextRenderer, "text", Columns.Line, "foreground-gdk", Columns.Foreground, "weight", Columns.Bold);
            col.Clickable = false;

            col              = view.AppendColumn(GettextCatalog.GetString("Description"), view.TextRenderer, "text", Columns.Description, "foreground-gdk", Columns.Foreground, "weight", Columns.Bold);
            col.Clickable    = true;
            col.SortColumnId = (int)Columns.Description;
            col.Resizable    = true;
            col.Clicked     += Resort;

            col              = view.AppendColumn(GettextCatalog.GetString("File"), view.TextRenderer, "text", Columns.File, "foreground-gdk", Columns.Foreground, "weight", Columns.Bold);
            col.Clickable    = true;
            col.SortColumnId = (int)Columns.File;
            col.Resizable    = true;
            col.Clicked     += Resort;

            col              = view.AppendColumn(GettextCatalog.GetString("Path"), view.TextRenderer, "text", Columns.Path, "foreground-gdk", Columns.Foreground, "weight", Columns.Bold);
            col.Clickable    = true;
            col.SortColumnId = (int)Columns.Path;
            col.Resizable    = true;
            col.Clicked     += Resort;

            LoadColumnsVisibility();

            comments.BeginTaskUpdates();
            try {
                foreach (var item in IdeApp.Workspace.Items)
                {
                    LoadWorkspaceItemContents(item);
                }
            } finally {
                comments.EndTaskUpdates();
            }

            comments.TasksAdded   += DispatchService.GuiDispatch <TaskEventHandler> (GeneratedTaskAdded);
            comments.TasksRemoved += DispatchService.GuiDispatch <TaskEventHandler> (GeneratedTaskRemoved);

            PropertyService.PropertyChanged += DispatchService.GuiDispatch <EventHandler <PropertyChangedEventArgs> > (OnPropertyUpdated);

            // Initialize with existing tags.
            foreach (Task t in comments)
            {
                AddGeneratedTask(t);
            }
        }
Esempio n. 13
0
 public PropertyController()
 {
     propertyService = new PropertyService();
 }
Esempio n. 14
0
        int Run(MonoDevelopOptions options)
        {
            UnsetEnvironmentVariables();

            CompositionManager.ConfigureUninitializedMefHandling(throwException: true);

            LoggingService.LogInfo("Starting {0} {1}", BrandingService.ApplicationLongName, IdeVersionInfo.MonoDevelopVersion);
            LoggingService.LogInfo("Build Information{0}{1}", Environment.NewLine, SystemInformation.GetBuildInformation());
            LoggingService.LogInfo("Running on {0}", RuntimeVersionInfo.GetRuntimeInfo());

            //ensure native libs initialized before we hit anything that p/invokes
            Platform.Initialize();
            IdeStartupTracker.StartupTracker.MarkSection("PlatformInitialization");

            GettextCatalog.Initialize();
            IdeStartupTracker.StartupTracker.MarkSection("GettextInitialization");

            LoggingService.LogInfo("Operating System: {0}", SystemInformation.GetOperatingSystemDescription());

            // The assembly resolver for MSBuild 15 assemblies needs to be defined early on.
            // Whilst Runtime.Initialize loads the MSBuild 15 assemblies from Mono this seems
            // to be too late to prevent the MEF composition and the static registrar from
            // failing to load the MonoDevelop.Ide assembly which now uses MSBuild 15 assemblies.
            ResolveMSBuildAssemblies();

            Counters.InitializationTracker = Counters.Initialization.BeginTiming();

            if (options.PerfLog)
            {
                string logFile = Path.Combine(Environment.CurrentDirectory, "monodevelop.perf-log");
                LoggingService.LogInfo("Logging instrumentation service data to file: " + logFile);
                InstrumentationService.StartAutoSave(logFile, 1000);
            }

            Counters.InitializationTracker.Trace("Initializing GTK");
            if (Platform.IsWindows && !CheckWindowsGtk())
            {
                return(1);
            }
            SetupExceptionManager();

            // explicit GLib type system initialization for GLib < 2.36 before any other type system access
            GLib.GType.Init();

            var args = options.RemainingArgs.ToArray();

            IdeTheme.InitializeGtk(BrandingService.ApplicationName, ref args);

            startupInfo = new StartupInfo(options, args);
            if (startupInfo.HasFiles)
            {
                // If files are present, consider started from the commandline as being the same as file manager.
                // On macOS, we need to wait until the DidFinishLaunching notification to find out we were launched from the Finder
                IdeApp.LaunchReason = IdeApp.LaunchType.LaunchedFromFileManager;
            }
            else if (!Platform.IsMac)
            {
                IdeApp.LaunchReason = IdeApp.LaunchType.Normal;
            }

            IdeApp.Customizer = options.IdeCustomizer ?? new IdeCustomizer();
            try {
                IdeApp.Customizer.Initialize(startupInfo);
            } catch (UnauthorizedAccessException ua) {
                LoggingService.LogError("Unauthorized access: " + ua.Message);
                return(1);
            }

            try {
                GLibLogging.Enabled = true;
            } catch (Exception ex) {
                LoggingService.LogError("Error initialising GLib logging.", ex);
            }

            IdeStartupTracker.StartupTracker.MarkSection("GtkInitialization");
            LoggingService.LogInfo("Using GTK+ {0}", IdeVersionInfo.GetGtkVersion());

            // XWT initialization
            FilePath p = typeof(IdeStartup).Assembly.Location;

            Runtime.LoadAssemblyFrom(p.ParentDirectory.Combine("Xwt.Gtk.dll"));
            Xwt.Application.InitializeAsGuest(Xwt.ToolkitType.Gtk);
            Xwt.Toolkit.CurrentEngine.RegisterBackend <IExtendedTitleBarWindowBackend, GtkExtendedTitleBarWindowBackend> ();
            Xwt.Toolkit.CurrentEngine.RegisterBackend <IExtendedTitleBarDialogBackend, GtkExtendedTitleBarDialogBackend> ();
            IdeTheme.SetupXwtTheme();

            IdeStartupTracker.StartupTracker.MarkSection("XwtInitialization");

            //default to Windows IME on Windows
            if (Platform.IsWindows && GtkWorkarounds.GtkMinorVersion >= 16)
            {
                var settings = Gtk.Settings.Default;
                var val      = GtkWorkarounds.GetProperty(settings, "gtk-im-module");
                if (string.IsNullOrEmpty(val.Val as string))
                {
                    GtkWorkarounds.SetProperty(settings, "gtk-im-module", new GLib.Value("ime"));
                }
            }

            DispatchService.Initialize();

            // Set a synchronization context for the main gtk thread
            SynchronizationContext.SetSynchronizationContext(DispatchService.SynchronizationContext);
            Runtime.MainSynchronizationContext = SynchronizationContext.Current;

            IdeStartupTracker.StartupTracker.MarkSection("DispatchInitialization");

            // Initialize Roslyn's synchronization context
            RoslynServices.RoslynService.Initialize();

            IdeStartupTracker.StartupTracker.MarkSection("RoslynInitialization");

            AddinManager.AddinLoadError += OnAddinError;

            Counters.InitializationTracker.Trace("Initializing Runtime");
            Runtime.Initialize(true);

            // Register services used by the IDE

            RegisterServices();

            // If a combine was specified, force --newwindow.

            if (!options.NewWindow && startupInfo.HasFiles)
            {
                foreach (var file in startupInfo.RequestedFileList)
                {
                    try {
                        if (MonoDevelop.Projects.Services.ProjectService.IsWorkspaceItemFile(file.FileName))
                        {
                            options.NewWindow = true;
                            break;
                        }
                    } catch (UnauthorizedAccessException ex) {
                        LoggingService.LogError(string.Format("Unable to check startup file is a workspace item '{0}'", file.FileName), ex);
                        return(1);
                    }
                }
            }

            instanceConnection = new IdeInstanceConnection(options.IpcTcp);

            // If not opening a combine, connect to existing monodevelop and pass filename(s) and exit
            if (!options.NewWindow && startupInfo.HasFiles && instanceConnection.TryConnect(startupInfo))
            {
                return(0);
            }

            IdeStartupTracker.StartupTracker.MarkSection("RuntimeInitialization");

            bool restartRequested = PropertyService.Get("MonoDevelop.Core.RestartRequested", false);

            startupInfo.Restarted = restartRequested;
            PropertyService.Set("MonoDevelop.Core.RestartRequested", false);

            Counters.InitializationTracker.Trace("Initializing theme");

            IdeTheme.SetupGtkTheme();

            IdeApp.Customizer.OnCoreInitialized();

            IdeStartupTracker.StartupTracker.MarkSection("ThemeInitialized");

            IdeApp.IsRunning = true;

            Xwt.Application.TranslationCatalog = new XwtTranslationCatalog();

            // Load the main menu before running the main loop
            var commandService = Runtime.GetService <CommandManager> ().Result;
            var desktopService = Runtime.GetService <DesktopService> ().Result;

            desktopService.SetGlobalMenu(commandService, DefaultWorkbench.MainMenuPath, DefaultWorkbench.AppMenuPath);

            // Run the main loop
            Gtk.Application.Invoke((s, e) => {
                MainLoop(options, startupInfo).Ignore();
            });
            Gtk.Application.Run();

            IdeApp.IsRunning = false;

            IdeApp.Customizer.OnIdeShutdown();

            instanceConnection.Dispose();

            lockupCheckRunning = false;
            Runtime.Shutdown();

            IdeApp.Customizer.OnCoreShutdown();

            InstrumentationService.Stop();

            MonoDevelop.Components.GtkWorkarounds.Terminate();

            return(0);
        }
Esempio n. 15
0
        private void tsbSave_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(cbeArkCode.Text.ToString().Trim()))
            {
                MessageService.ShowMessage("请输入柜号。", "${res:Global.SystemInfo}");
                return;
            }
            if (cbeArkCode.Enabled == false)
            {
                if (MessageService.AskQuestion("你确定要保存当前界面的数据吗?", "保存"))
                {
                    //获取对应柜号主键,然后修改明细表信息,保存界面托信息,修改包装表中状态为已组柜
                    GroupArkEntity arkEntity = new GroupArkEntity();
                    DataSet        ds        = arkEntity.GetArkNumber(cbeArkCode.Text.Trim());
                    int            flag      = 0;
                    if (ds.Tables[0].Rows.Count > 1)
                    {
                        MessageService.ShowMessage("柜号存在重复或不存在请重新输入", "${res:Global.SystemInfo}");
                        return;
                    }
                    #region
                    //可以查到抬头表中存在柜
                    else if (ds.Tables[0].Rows.Count == 1)
                    {
                        flag = 0;
                        DataTable dt = new DataTable();
                        //获取界面数据表信息
                        if (gvArk.DataSource != null)
                        {
                            dt = ((DataView)gvArk.DataSource).Table.GetChanges(DataRowState.Modified);
                        }
                        else
                        {
                            dt = null;
                        }

                        //查询明细表中柜主键为同一个且托状态为可用的托号
                        DataSet   dsCdetail = arkEntity.GetContainerDetailInf(ds.Tables[0].Rows[0]["CONTAINER_KEY"].ToString().Trim());
                        DataTable dtCdetail = dsCdetail.Tables[0];
                        dtCdetail.TableName = "DETAILPALLNO";

                        DataSet dsIn = new DataSet();
                        dsIn.Merge(dtCdetail);
                        Hashtable hashTable = new Hashtable();
                        hashTable.Add("CREATOR", PropertyService.Get(PROPERTY_FIELDS.USER_NAME));
                        hashTable.Add("CONTAINER_CODE", cbeArkCode.Text.Trim());
                        DataTable tableParam = SolarViewer.Hemera.Share.Common.CommonUtils.ParseToDataTable(hashTable);
                        tableParam.TableName = "HASH";
                        dsIn.Merge(tableParam);
                        DataTable dtArkKey = ds.Tables[0];
                        dtArkKey.TableName = "ARKKEY";
                        dsIn.Merge(dtArkKey);

                        bool bo = arkEntity.UpdateArkInf(dsIn, dt, flag);
                        if (bo)
                        {
                            MessageService.ShowMessage("保存成功。", "${res:Global.SystemInfo}");
                            cbeArkCode.Enabled = true;
                            BindArkCode();
                            gcArk.DataSource = null;     //清空datasource
                        }
                        else
                        {
                            MessageService.ShowMessage("保存失败。", "${res:Global.SystemInfo}");
                        }
                    }
                    #endregion
                    #region
                    else if (ds.Tables[0].Rows.Count < 1)
                    {
                        flag = 1;
                        DataTable dt = new DataTable();
                        //获取界面数据表信息
                        if (gvArk.DataSource != null)
                        {
                            dt = ((DataView)gvArk.DataSource).Table.GetChanges(DataRowState.Modified);
                        }
                        else
                        {
                            dt = null;
                        }

                        if (dt != null)
                        {
                            DataSet dsIn = new DataSet();

                            Hashtable hashTable = new Hashtable();
                            hashTable.Add("CREATOR", PropertyService.Get(PROPERTY_FIELDS.USER_NAME));
                            hashTable.Add("CONTAINER_CODE", cbeArkCode.Text.Trim());
                            DataTable tableParam = SolarViewer.Hemera.Share.Common.CommonUtils.ParseToDataTable(hashTable);
                            tableParam.TableName = "HASH";
                            dsIn.Merge(tableParam);
                            bool bo = arkEntity.UpdateArkInf(dsIn, dt, flag);
                            if (bo)
                            {
                                MessageService.ShowMessage("保存成功。", "${res:Global.SystemInfo}");
                                cbeArkCode.Enabled = true;
                                BindArkCode();
                                gcArk.DataSource = null;     //清空datasource
                            }
                            else
                            {
                                MessageService.ShowMessage("保存失败。", "${res:Global.SystemInfo}");
                            }
                        }
                        else
                        {
                            MessageService.ShowMessage("无保存信息", "${res:Global.SystemInfo}");
                            return;
                        }
                    }
                    #endregion
                }
            }
            else
            {
                MessageService.ShowMessage("请在选择柜号后回车。", "${res:Global.SystemInfo}");
            }
        }
Esempio n. 16
0
        /// <summary>
        /// Handles the Activated event of the LoginForm control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void LoginForm_Activated(object sender, EventArgs e)
        {
            using (PropertyService propertyService = new PropertyService()) {
                ShellLayout layout = propertyService.Get(UIExtensionSiteNames.Shell_Property_ShellLayout) as ShellLayout;
                if (layout != null)
                    UserLookAndFeel.Default.SetSkinStyle(layout.DefaultSkin);
            }

            txtUser.Focus();
        }
Esempio n. 17
0
 public void Save()
 {
     PropertyService.Set(KEY_IS_GROUPED, IsGrouped);
     PropertyService.Set(KEY_IS_SORTED, IsSorted);
     PropertyService.Set(KEY_GROUP_ORDER, string.Join(",", GroupOrder));
 }
        public override bool KeyPress(Gdk.Key key, char keyChar, Gdk.ModifierType modifier)
        {
            bool skipFormatting = StateTracker.Engine.IsInsideOrdinaryCommentOrString ||
                                  StateTracker.Engine.IsInsidePreprocessorDirective;

            cursorPositionBeforeKeyPress = textEditorData.Caret.Offset;
            bool isSomethingSelected = textEditorData.IsSomethingSelected;

            if (key == Gdk.Key.BackSpace && textEditorData.Caret.Offset == lastInsertedSemicolon)
            {
                textEditorData.Document.Undo();
                lastInsertedSemicolon = -1;
                return(false);
            }
            lastInsertedSemicolon = -1;
            if (keyChar == ';' && !(textEditorData.CurrentMode is TextLinkEditMode) && !DoInsertTemplate() && !isSomethingSelected && PropertyService.Get(
                    "SmartSemicolonPlacement",
                    false
                    ))
            {
                bool         retval  = base.KeyPress(key, keyChar, modifier);
                DocumentLine curLine = textEditorData.Document.GetLine(textEditorData.Caret.Line);
                string       text    = textEditorData.Document.GetTextAt(curLine);
                if (!(text.EndsWith(";", StringComparison.Ordinal) || text.Trim().StartsWith("for", StringComparison.Ordinal)))
                {
                    int guessedOffset;

                    if (GuessSemicolonInsertionOffset(textEditorData, curLine, textEditorData.Caret.Offset, out guessedOffset))
                    {
                        using (var undo = textEditorData.OpenUndoGroup()) {
                            textEditorData.Remove(textEditorData.Caret.Offset - 1, 1);
                            textEditorData.Caret.Offset = guessedOffset;
                            lastInsertedSemicolon       = textEditorData.Caret.Offset + 1;
                            retval = base.KeyPress(key, keyChar, modifier);
                        }
                    }
                }
                using (var undo = textEditorData.OpenUndoGroup()) {
                    if (OnTheFlyFormatting && textEditorData != null && !(textEditorData.CurrentMode is TextLinkEditMode) && !(textEditorData.CurrentMode is InsertionCursorEditMode))
                    {
                        OnTheFlyFormatter.FormatStatmentAt(Document, textEditorData.Caret.Location);
                    }
                }
                return(retval);
            }

            if (key == Gdk.Key.Tab)
            {
                stateTracker.UpdateEngine();
                if (stateTracker.Engine.IsInsideStringLiteral && !textEditorData.IsSomethingSelected)
                {
                    var lexer = new CSharpCompletionEngineBase.MiniLexer(textEditorData.Document.GetTextAt(0, textEditorData.Caret.Offset));
                    lexer.Parse();
                    if (lexer.IsInString)
                    {
                        textEditorData.InsertAtCaret("\\t");
                        return(false);
                    }
                }
            }


            if (key == Gdk.Key.Tab && DefaultSourceEditorOptions.Instance.TabIsReindent && !CompletionWindowManager.IsVisible && !(textEditorData.CurrentMode is TextLinkEditMode) && !DoInsertTemplate() && !isSomethingSelected)
            {
                int cursor = textEditorData.Caret.Offset;
                if (stateTracker.Engine.IsInsideVerbatimString && cursor > 0 && cursor < textEditorData.Document.TextLength && textEditorData.GetCharAt(cursor - 1) == '"')
                {
                    stateTracker.UpdateEngine(cursor + 1);
                }

                if (stateTracker.Engine.IsInsideVerbatimString)
                {
                    // insert normal tab inside @" ... "
                    if (textEditorData.IsSomethingSelected)
                    {
                        textEditorData.SelectedText = "\t";
                    }
                    else
                    {
                        textEditorData.Insert(cursor, "\t");
                    }
                    textEditorData.Document.CommitLineUpdate(textEditorData.Caret.Line);
                }
                else if (cursor >= 1)
                {
                    if (textEditorData.Caret.Column > 1)
                    {
                        int delta = cursor - cursorPositionBeforeKeyPress;
                        if (delta < 2 && delta > 0)
                        {
                            textEditorData.Remove(cursor - delta, delta);
                            textEditorData.Caret.Offset = cursor - delta;
                            textEditorData.Document.CommitLineUpdate(textEditorData.Caret.Line);
                        }
                    }
                    stateTracker.UpdateEngine();
                    DoReSmartIndent();
                }
                return(false);
            }

            stateTracker.UpdateEngine();
            if (!stateTracker.Engine.IsInsideOrdinaryCommentOrString)
            {
                if (keyChar == '@')
                {
                    var retval = base.KeyPress(key, keyChar, modifier);
                    int cursor = textEditorData.Caret.Offset;
                    if (cursor < textEditorData.Length && textEditorData.GetCharAt(cursor) == '"')
                    {
                        ConvertNormalToVerbatimString(textEditorData, cursor + 1);
                    }
                    return(retval);
                }
            }


            //do the smart indent
            if (textEditorData.Options.IndentStyle == IndentStyle.Smart || textEditorData.Options.IndentStyle == IndentStyle.Virtual)
            {
                bool retval;
                //capture some of the current state
                int  oldBufLen    = textEditorData.Length;
                int  oldLine      = textEditorData.Caret.Line + 1;
                bool hadSelection = textEditorData.IsSomethingSelected;
                bool reIndent     = false;

                //pass through to the base class, which actually inserts the character
                //and calls HandleCodeCompletion etc to handles completion
                using (var undo = textEditorData.OpenUndoGroup()) {
                    DoPreInsertionSmartIndent(key);
                }

                bool automaticReindent;
                // need to be outside of an undo group - otherwise it interferes with other text editor extension
                // esp. the documentation insertion undo steps.
                retval = base.KeyPress(key, keyChar, modifier);
                //handle inserted characters
                if (textEditorData.Caret.Offset <= 0 || textEditorData.IsSomethingSelected)
                {
                    return(retval);
                }

                lastCharInserted = TranslateKeyCharForIndenter(key, keyChar, textEditorData.GetCharAt(textEditorData.Caret.Offset - 1));
                if (lastCharInserted == '\0')
                {
                    return(retval);
                }

                using (var undo = textEditorData.OpenUndoGroup()) {
                    stateTracker.UpdateEngine();

                    if (key == Gdk.Key.Return && modifier == Gdk.ModifierType.ControlMask)
                    {
                        FixLineStart(textEditorData, stateTracker, textEditorData.Caret.Line + 1);
                    }
                    else
                    {
                        if (!(oldLine == textEditorData.Caret.Line + 1 && lastCharInserted == '\n') && (oldBufLen != textEditorData.Length || lastCharInserted != '\0'))
                        {
                            DoPostInsertionSmartIndent(lastCharInserted, hadSelection, out reIndent);
                        }
                    }
                    //reindent the line after the insertion, if needed
                    //N.B. if the engine says we need to reindent, make sure that it's because a char was
                    //inserted rather than just updating the stack due to moving around

                    stateTracker.UpdateEngine();
                    automaticReindent = (stateTracker.Engine.NeedsReindent && lastCharInserted != '\0');
                    if (key == Gdk.Key.Return && (reIndent || automaticReindent))
                    {
                        DoReSmartIndent();
                    }
                }

                if (key != Gdk.Key.Return && (reIndent || automaticReindent))
                {
                    using (var undo = textEditorData.OpenUndoGroup()) {
                        DoReSmartIndent();
                    }
                }
                if (!skipFormatting)
                {
                    if (keyChar == ';' || keyChar == '}')
                    {
                        using (var undo = textEditorData.OpenUndoGroup()) {
                            if (OnTheFlyFormatting && textEditorData != null && !(textEditorData.CurrentMode is TextLinkEditMode) && !(textEditorData.CurrentMode is InsertionCursorEditMode))
                            {
                                OnTheFlyFormatter.FormatStatmentAt(Document, textEditorData.Caret.Location);
                            }
                        }
                    }
                }

                stateTracker.UpdateEngine();
                lastCharInserted = '\0';
                CheckXmlCommentCloseTag(keyChar);
                return(retval);
            }

            if (textEditorData.Options.IndentStyle == IndentStyle.Auto && DefaultSourceEditorOptions.Instance.TabIsReindent && key == Gdk.Key.Tab)
            {
                bool retval = base.KeyPress(key, keyChar, modifier);
                DoReSmartIndent();
                CheckXmlCommentCloseTag(keyChar);
                return(retval);
            }

            //pass through to the base class, which actually inserts the character
            //and calls HandleCodeCompletion etc to handles completion
            var result = base.KeyPress(key, keyChar, modifier);

            CheckXmlCommentCloseTag(keyChar);

            if (!skipFormatting && keyChar == '}')
            {
                RunFormatter(new DocumentLocation(textEditorData.Caret.Location.Line, textEditorData.Caret.Location.Column));
            }
            return(result);
        }
Esempio n. 19
0
 internal DiagnosticSeverity GetSeverity(DiagnosticDescriptor diagnostic)
 {
     return(PropertyService.Get("CodeIssues." + Languages + "." + IdString + "." + diagnostic.Id + ".severity", diagnostic.DefaultSeverity));
 }
 void SetDefaultGitSettings()
 {
     projectConfiguration.UseGit = PropertyService.Get(UseGitPropertyName, false);
     projectConfiguration.CreateGitIgnoreFile = PropertyService.Get(CreateGitIgnoreFilePropertyName, true);
 }
Esempio n. 21
0
 internal void SetSeverity(DiagnosticDescriptor diagnostic, DiagnosticSeverity severity)
 {
     PropertyService.Set("CodeIssues." + Languages + "." + IdString + "." + diagnostic.Id + ".severity", severity);
 }
Esempio n. 22
0
        void OpenEvent(object sender, EventArgs e)
        {
            if (categoryTreeView.SelectedNode != null)
            {
                PropertyService.Set("Dialogs.NewProjectDialog.LastSelectedCategory", TreeViewHelper.GetPath(categoryTreeView.SelectedNode));
                PropertyService.Set("Dialogs.NewProjectDialog.CategoryTreeState", TreeViewHelper.GetViewStateString(categoryTreeView));
                PropertyService.Set("Dialogs.NewProjectDialog.LargeImages", largeIconsRadioButton.Checked);
            }


            string solution         = solutionNameTextBox.Text.Trim();
            string name             = nameTextBox.Text.Trim();
            string location         = locationTextBox.Text.Trim();
            string projectNameError = CheckProjectName(solution, name, location);

            if (projectNameError != null)
            {
                MessageService.ShowError(projectNameError);
                return;
            }

            if (templateListView.SelectedItems.Count == 1 && locationTextBox.Text.Length > 0 && solutionNameTextBox.Text.Length > 0)
            {
                TemplateItem item = (TemplateItem)templateListView.SelectedItems[0];
                try {
                    System.IO.Directory.CreateDirectory(NewProjectDirectory);
                } catch (Exception) {
                    MessageService.ShowError("${res:ICSharpCode.SharpDevelop.Gui.Dialogs.NewProjectDialog.CantCreateDirectoryError}");
                    return;
                }

                ProjectCreateInformation cinfo = new ProjectCreateInformation();
                if (!createNewSolution)
                {
                    cinfo.Solution     = ProjectService.OpenSolution;
                    cinfo.SolutionPath = Path.GetDirectoryName(cinfo.Solution.FileName);
                    cinfo.SolutionName = cinfo.Solution.Name;
                }
                else
                {
                    cinfo.SolutionPath = NewSolutionDirectory;
                }

                if (item.Template.HasSupportedTargetFrameworks)
                {
                    cinfo.TargetFramework = ((TargetFramework)targetFrameworkComboBox.SelectedItem).Name;
                    PropertyService.Set("Dialogs.NewProjectDialog.TargetFramework", cinfo.TargetFramework);
                }

                cinfo.ProjectBasePath = NewProjectDirectory;

                cinfo.SolutionName = solution;
                cinfo.ProjectName  = name;

                NewSolutionLocation = item.Template.CreateProject(cinfo);
                if (NewSolutionLocation == null || NewSolutionLocation.Length == 0)
                {
                    return;
                }
                if (createNewSolution)
                {
                    ProjectService.LoadSolution(NewSolutionLocation);
                }
                item.Template.RunOpenActions(cinfo);

                NewProjectLocation = cinfo.createdProjects.Count > 0 ? cinfo.createdProjects[0].FileName : "";
                DialogResult       = DialogResult.OK;
            }
        }
Esempio n. 23
0
 internal bool GetIsEnabled(DiagnosticDescriptor diagnostic)
 {
     return(PropertyService.Get("CodeIssues." + Languages + "." + IdString + "." + diagnostic.Id + ".enabled", true));
 }
Esempio n. 24
0
        protected virtual void InitializeView()
        {
            ImageList smalllist = new ImageList();
            ImageList imglist   = new ImageList();

            smalllist.ColorDepth = ColorDepth.Depth32Bit;
            imglist.ColorDepth   = ColorDepth.Depth32Bit;
            imglist.ImageSize    = new Size(32, 32);
            smalllist.ImageSize  = new Size(16, 16);

            smalllist.Images.Add(WinFormsResourceService.GetBitmap("Icons.32x32.EmptyProjectIcon"));

            imglist.Images.Add(WinFormsResourceService.GetBitmap("Icons.32x32.EmptyProjectIcon"));

            // load the icons and set their index from the image list in the hashtable
            int i = 0;
            Dictionary <string, int> tmp = new Dictionary <string, int>(icons);

            foreach (KeyValuePair <string, int> entry in icons)
            {
                Bitmap bitmap = IconService.GetBitmap(entry.Key);
                if (bitmap != null)
                {
                    smalllist.Images.Add(bitmap);
                    imglist.Images.Add(bitmap);
                    tmp[entry.Key] = ++i;
                }
                else
                {
                    LoggingService.Warn("NewProjectDialog: can't load bitmap " + entry.Key.ToString() + " using default");
                }
            }

            // set the correct imageindex for all templates
            icons = tmp;
            foreach (TemplateItem item in alltemplates)
            {
                if (item.Template.Icon == null)
                {
                    item.ImageIndex = 0;
                }
                else
                {
                    item.ImageIndex = icons[item.Template.Icon];
                }
            }

            templateListView.LargeImageList = imglist;
            templateListView.SmallImageList = smalllist;

            InsertCategories(null, categories);
            categoryTreeView.TreeViewNodeSorter = new TemplateCategoryComparer();
            categoryTreeView.Sort();
            string initialSelectedCategory = StringParser.Parse("C#\\${res:Templates.File.Categories.WindowsApplications}");

            TreeViewHelper.ApplyViewStateString(PropertyService.Get("Dialogs.NewProjectDialog.CategoryTreeState", ""), categoryTreeView);
            categoryTreeView.SelectedNode = TreeViewHelper.GetNodeByPath(categoryTreeView, PropertyService.Get("Dialogs.NewProjectDialog.LastSelectedCategory", initialSelectedCategory));
        }
Esempio n. 25
0
 internal void SetIsEnabled(DiagnosticDescriptor diagnostic, bool value)
 {
     PropertyService.Set("CodeIssues." + Languages + "." + IdString + "." + diagnostic.Id + ".enabled", value);
 }
Esempio n. 26
0
 /// <summary>
 /// Sets the user defined severity.
 /// </summary>
 public void SetSeverity(Severity severity)
 {
     this.severity = severity;
     PropertyService.Set(IdString, severity);
 }
Esempio n. 27
0
        public ExtractMethodDialog(RefactoringOptions options, ExtractMethodRefactoring extractMethod, ExtractMethodRefactoring.ExtractMethodParameters properties)
        {
            this.Build();
            this.options       = options;
            this.properties    = properties;
            this.extractMethod = extractMethod;

            store = new ListStore(typeof(string), typeof(string));
            treeviewParameters.Model = store;
            treeviewParameters.AppendColumn("Type", new CellRendererText(), "text", 0);
            treeviewParameters.AppendColumn("Name", new CellRendererText(), "text", 1);
            FillStore();
            buttonPreview.Sensitive = buttonOk.Sensitive = false;
            entry.Changed          += delegate { buttonPreview.Sensitive = buttonOk.Sensitive = ValidateName(); };
            ValidateName();

            buttonOk.Clicked      += OnOKClicked;
            buttonCancel.Clicked  += OnCancelClicked;
            buttonPreview.Clicked += OnPreviewClicked;

            buttonUp.Clicked += delegate {
                List <int> indices = new List <int> ();
                foreach (TreePath path in treeviewParameters.Selection.GetSelectedRows())
                {
                    int index = Int32.Parse(path.ToString());
                    if (index > 0)
                    {
                        VariableDescriptor tmp = properties.Parameters [index - 1];
                        properties.Parameters [index - 1] = properties.Parameters [index];
                        properties.Parameters [index]     = tmp;
                        indices.Add(index - 1);
                    }
                }
                FillStore();
                treeviewParameters.Selection.SelectPath(new TreePath(indices.ToArray()));
            };
            buttonDown.Clicked += delegate {
                List <int> indices = new List <int> ();
                foreach (TreePath path in treeviewParameters.Selection.GetSelectedRows())
                {
                    int index = Int32.Parse(path.ToString());
                    if (index + 1 < properties.Parameters.Count)
                    {
                        VariableDescriptor tmp = properties.Parameters [index + 1];
                        properties.Parameters [index + 1] = properties.Parameters [index];
                        properties.Parameters [index]     = tmp;
                        indices.Add(index + 1);
                    }
                }
                FillStore();
                treeviewParameters.Selection.SelectPath(new TreePath(indices.ToArray()));
            };
            ListStore modifiers = new ListStore(typeof(string));

            modifiers.AppendValues("");
            modifiers.AppendValues("public");
            modifiers.AppendValues("private");
            modifiers.AppendValues("protected");
            modifiers.AppendValues("internal");
            comboboxModifiers.Model  = modifiers;
            comboboxModifiers.Active = PropertyService.Get <int> ("MonoDevelop.Refactoring.ExtractMethod.ExtractMethodDialog.DefaultModifier");
            entry.Activated         += delegate {
                if (buttonOk.Sensitive)
                {
                    buttonOk.Click();
                }
            };
        }
Esempio n. 28
0
 void SetIsWholeWordOnly(bool value)
 {
     PropertyService.Set("IsWholeWordOnly", value);
     SetSearchOptions();
 }
Esempio n. 29
0
 static QuickTaskStrip()
 {
     EnableFancyFeatures.Changed += delegate {
         PropertyService.Set("ScrollBar.Mode", EnableFancyFeatures ? ScrollBarMode.Overview : ScrollBarMode.Normal);
     };
 }
Esempio n. 30
0
        public AddLeaseWindow(LeaseService leaseService, TenantService tenantService, PropertyService propertyService,
                              AppSettings appSettings)
        {
            SetupStructure(leaseService, appSettings);
            InitializeComponent();

            PropertyCBox.ItemsSource = propertyService.Properties;
            TenantCBox.ItemsSource   = tenantService.Tenants;
            MonthsBox.Text           = _minLeaseMonths.ToString();
        }
Esempio n. 31
0
 public void Save()
 {
     PropertyService.Set(GlobalPropertyName, this);
     PropertyService.SaveProperties();
 }
Esempio n. 32
0
		public void InitSharpDevelopCore(SharpDevelopHost.CallbackHelper callback, StartupSettings properties)
		{
			// Initialize the most important services:
			var container = new SharpDevelopServiceContainer(ServiceSingleton.FallbackServiceProvider);
			container.AddService(typeof(IMessageService), new SDMessageService());
			container.AddService(typeof(ILoggingService), new log4netLoggingService());
			ServiceSingleton.ServiceProvider = container;
			
			LoggingService.Info("InitSharpDevelop...");
			this.callback = callback;
			CoreStartup startup = new CoreStartup(properties.ApplicationName);
			if (properties.UseSharpDevelopErrorHandler) {
				this.useSharpDevelopErrorHandler = true;
				ExceptionBox.RegisterExceptionBoxForUnhandledExceptions();
			}
			string configDirectory = properties.ConfigDirectory;
			string dataDirectory = properties.DataDirectory;
			string propertiesName;
			if (properties.PropertiesName != null) {
				propertiesName = properties.PropertiesName;
			} else {
				propertiesName = properties.ApplicationName + "Properties";
			}
			
			if (properties.ApplicationRootPath != null) {
				FileUtility.ApplicationRootPath = properties.ApplicationRootPath;
			}
			
			if (configDirectory == null)
				configDirectory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
				                               properties.ApplicationName);
			var propertyService = new PropertyService(
				DirectoryName.Create(configDirectory),
				DirectoryName.Create(dataDirectory ?? Path.Combine(FileUtility.ApplicationRootPath, "data")),
				propertiesName);
			
			startup.StartCoreServices(propertyService);
			Assembly exe = Assembly.Load(properties.ResourceAssemblyName);
			SD.ResourceService.RegisterNeutralStrings(new ResourceManager("ICSharpCode.SharpDevelop.Resources.StringResources", exe));
			SD.ResourceService.RegisterNeutralImages(new ResourceManager("ICSharpCode.SharpDevelop.Resources.BitmapResources", exe));
			
			CommandWrapper.LinkCommandCreator = (link => new LinkCommand(link));
			CommandWrapper.WellKnownCommandCreator = Core.Presentation.MenuService.GetKnownCommand;
			CommandWrapper.RegisterConditionRequerySuggestedHandler = (eh => CommandManager.RequerySuggested += eh);
			CommandWrapper.UnregisterConditionRequerySuggestedHandler = (eh => CommandManager.RequerySuggested -= eh);
			StringParser.RegisterStringTagProvider(new SharpDevelopStringTagProvider());
			
			LoggingService.Info("Looking for AddIns...");
			foreach (string file in properties.addInFiles) {
				startup.AddAddInFile(file);
			}
			foreach (string dir in properties.addInDirectories) {
				startup.AddAddInsFromDirectory(dir);
			}
			
			if (properties.AllowAddInConfigurationAndExternalAddIns) {
				startup.ConfigureExternalAddIns(Path.Combine(configDirectory, "AddIns.xml"));
			}
			if (properties.AllowUserAddIns) {
				startup.ConfigureUserAddIns(Path.Combine(configDirectory, "AddInInstallTemp"),
					Path.Combine(configDirectory, "AddIns"));
			}
			
			LoggingService.Info("Loading AddInTree...");
			startup.RunInitialization();
			
			((AssemblyParserService)SD.AssemblyParserService).DomPersistencePath = properties.DomPersistencePath;
			
			// Register events to marshal back
			Project.ProjectService.BuildStarted   += delegate { this.callback.StartBuild(); };
			Project.ProjectService.BuildFinished  += delegate { this.callback.EndBuild(); };
			Project.ProjectService.SolutionLoaded += delegate { this.callback.SolutionLoaded(); };
			Project.ProjectService.SolutionClosed += delegate { this.callback.SolutionClosed(); };
			FileUtility.FileLoaded += delegate(object sender, FileNameEventArgs e) { this.callback.FileLoaded(e.FileName); };
			FileUtility.FileSaved  += delegate(object sender, FileNameEventArgs e) { this.callback.FileSaved(e.FileName); };
			
			LoggingService.Info("InitSharpDevelop finished");
		}
Esempio n. 33
0
        protected override void Run()
        {
            var lang = "text/x-csharp";

            OpenFileDialog dlg = new OpenFileDialog("Export Rules", FileChooserAction.Save);

            dlg.InitialFileName = "rules.html";
            if (!dlg.Run())
            {
                return;
            }

            Dictionary <BaseCodeIssueProvider, Severity> severities = new Dictionary <BaseCodeIssueProvider, Severity> ();

            foreach (var node in RefactoringService.GetInspectors(lang))
            {
                severities [node] = node.GetSeverity();
                if (node.HasSubIssues)
                {
                    foreach (var subIssue in node.SubIssues)
                    {
                        severities [subIssue] = subIssue.GetSeverity();
                    }
                }
            }

            var grouped = severities.Keys.OfType <CodeIssueProvider> ()
                          .GroupBy(node => node.Category)
                          .OrderBy(g => g.Key, StringComparer.Ordinal);

            using (var sw = new StreamWriter(dlg.SelectedFile)) {
                sw.WriteLine("<h1>Code Rules</h1>");
                foreach (var g in grouped)
                {
                    sw.WriteLine("<h2>" + g.Key + "</h2>");
                    sw.WriteLine("<table border='1'>");

                    foreach (var node in g.OrderBy(n => n.Title, StringComparer.Ordinal))
                    {
                        var title = node.Title;
                        var desc  = node.Description != title ? node.Description : "";
                        sw.WriteLine("<tr><td>" + title + "</td><td>" + desc + "</td><td>" + node.GetSeverity() + "</td></tr>");
                        if (node.HasSubIssues)
                        {
                            foreach (var subIssue in node.SubIssues)
                            {
                                title = subIssue.Title;
                                desc  = subIssue.Description != title ? subIssue.Description : "";
                                sw.WriteLine("<tr><td> - " + title + "</td><td>" + desc + "</td><td>" + subIssue.GetSeverity() + "</td></tr>");
                            }
                        }
                    }
                    sw.WriteLine("</table>");
                }

                Dictionary <CodeActionProvider, bool> providerStates = new Dictionary <CodeActionProvider, bool> ();
                string disabledNodes = PropertyService.Get("ContextActions." + lang, "");
                foreach (var node in RefactoringService.ContextAddinNodes.Where(n => n.MimeType == lang))
                {
                    providerStates [node] = disabledNodes.IndexOf(node.IdString, StringComparison.Ordinal) < 0;
                }

                sw.WriteLine("<h1>Code Actions</h1>");
                sw.WriteLine("<table border='1'>");
                var sortedAndFiltered = providerStates.Keys.OrderBy(n => n.Title, StringComparer.Ordinal);
                foreach (var node in sortedAndFiltered)
                {
                    var desc = node.Title != node.Description ? node.Description : "";
                    sw.WriteLine("<tr><td>" + node.Title + "</td><td>" + desc + "</td></tr>");
                }
                sw.WriteLine("</table>");
            }
        }