コード例 #1
0
 public static void SendRequest(IMessagingService daemon, FocusEditorRequest request)
 {
     Task.Run(
         async() =>
     {
         try
         {
             var response = await daemon.Request(request);
             if (response.FocusHwnd.HasValue && Environment.OSVersion.Platform == PlatformID.Win32NT)
             {
                 SwitchToThisWindow(new IntPtr(response.FocusHwnd.Value), true);
             }
         }
         catch (RequestFailed)
         {
             // Just ignore for now..
         }
     });
 }
コード例 #2
0
        IControl CreateItemRow(ErrorItem e)
        {
            var locateInEditor = Command.Create(_projectFile.Select(
                                                    projFile => e.Source.Select(
                                                        source =>
            {
                return((Action)(() =>
                {
                    var request = new FocusEditorRequest()
                    {
                        Column = source.Column,
                        Line = source.Line,
                        File = source.File.NativePath,
                        Project = projFile.NativePath
                    };
                    FocusEditorCommand.SendRequest(_daemon, request);
                }));
            })));

            var tags =
                Layout.StackFromLeft(e.Tags.Select(
                                         tag => Layout.StackFromLeft(
                                             Label.Create(tag.Name, font: Theme.DefaultFontBold)
                                             .WithPadding(new Thickness <Points>(4, 2))
                                             .WithBackground(
                                                 Shapes.Rectangle(fill: tag.Brush, cornerRadius: Observable.Return(new CornerRadius(10))))).WithPadding(right: new Points(4.0))));

            var lineInfoControl = _projectFile.Select(projFile => e.Source.Select(
                                                          source =>
            {
                return(Layout.StackFromLeft(
                           Control.Empty.WithWidth(16),
                           Layout.StackFromLeft(
                               Label.Create("File: ", color: Theme.DescriptorText).CenterVertically(),
                               Label.Create(
                                   source.File.RelativeTo(projFile.ContainingDirectory).NativeRelativePath,
                                   color: Theme.DefaultText,
                                   lineBreakMode: LineBreakMode.TruncateHead)
                               .CenterVertically().WithWidth(200)),
                           Layout.StackFromLeft(
                               Label.Create("Line: ", color: Theme.DescriptorText).CenterVertically(),
                               Label.Create(
                                   source.Line.ToString() + " : " + source.Column.ToString(),
                                   color: Theme.DefaultText).CenterVertically(),
                               Button.Create(
                                   clicked: locateInEditor,
                                   content: states =>
                                   Label.Create("Locate", color: Theme.Link)).WithPadding(new Thickness <Points>(10, 0)).CenterVertically()),
                           Control.Empty.WithWidth(8)));
            }).Or(() => Control.Empty));

            return(Layout.StackFromLeft(Layout.StackFromTop(
                                            Control.Empty.WithHeight(8),
                                            Label.Create(
                                                e.Title,
                                                color: Theme.DefaultText,
                                                //lineBreakMode: LineBreakMode.Wrap,
                                                font: Font.SystemDefault(Observable.Return(19.0))).CenterVertically(),
                                            Control.Empty.WithHeight(16),
                                            Layout.StackFromLeft(tags, lineInfoControl.Switch()),
                                            Control.Empty.WithHeight(8),
                                            Layout.StackFromLeft(
                                                Label.Create(e.Message, lineBreakMode: LineBreakMode.Wrap, color: Theme.DescriptorText)
                                                .WithPadding(new Thickness <Points>(10, 20))).WithBackground(
                                                Shapes.Rectangle(fill: Theme.FaintBackground, cornerRadius: Observable.Return(new CornerRadius(2)))))));
        }