Пример #1
0
        private void HighlightCenter(PointCollection col, IEnumerable <TabWellItem> sourceTabs, TabWellItem item)
        {
            var relativeOrigin = (UIElement)DockHost?.ContentHost ?? Window.GetWindow(TargetHost);
            var hostOffset     = TargetHost.TranslatePoint(new Point(), relativeOrigin);

            if (TargetHost is DocumentContainer)
            {
                col.Add(hostOffset);
                col.Add(new Point(hostOffset.X + TargetArea.Width, hostOffset.Y));
                col.Add(new Point(hostOffset.X + TargetArea.Width, hostOffset.Y + TargetArea.Height));
                col.Add(new Point(hostOffset.X, hostOffset.Y + TargetArea.Height));
            }
            else
            {
                var well  = TargetHost as TabWellBase;
                var first = well.FirstContainer;
                if (item == null)
                {
                    item = first;
                }

                var firstOffset = first?.TranslatePoint(new Point(), relativeOrigin) ?? hostOffset;
                var itemOffset  = item?.TranslatePoint(new Point(), relativeOrigin) ?? hostOffset;
                var itemHeight  = sourceTabs.Max(t => t.ActualHeight);
                var itemWidth   = sourceTabs.Sum(t => t.ActualWidth);

                if (TargetHost is DocumentWell)
                {
                    col.Add(new Point(hostOffset.X, firstOffset.Y + itemHeight));                                      //well top-left
                    col.Add(new Point(itemOffset.X, itemOffset.Y + itemHeight));                                       //item bottom-left
                    col.Add(new Point(itemOffset.X, itemOffset.Y));                                                    //item top-left
                    col.Add(new Point(itemOffset.X + itemWidth, itemOffset.Y));                                        //item top-right
                    col.Add(new Point(itemOffset.X + itemWidth, itemOffset.Y + itemHeight));                           //item bottom-right
                    col.Add(new Point(hostOffset.X + TargetHost.ActualWidth, itemOffset.Y + itemHeight));              //well top-right
                    col.Add(new Point(hostOffset.X + TargetHost.ActualWidth, hostOffset.Y + TargetHost.ActualHeight)); //well bottom-right
                    col.Add(new Point(hostOffset.X, hostOffset.Y + TargetHost.ActualHeight));                          //well bottom-left
                }
                else
                {
                    col.Add(new Point(hostOffset.X, hostOffset.Y));                              //well top-left
                    col.Add(new Point(hostOffset.X + TargetHost.ActualWidth, hostOffset.Y));     //well top-right
                    col.Add(new Point(hostOffset.X + TargetHost.ActualWidth, itemOffset.Y));     //well bottom-right
                    if (well.Items.Count > 1)                                                    //tab panel visible
                    {
                        col.Add(new Point(itemOffset.X + itemWidth, itemOffset.Y));              //item top-right
                        col.Add(new Point(itemOffset.X + itemWidth, itemOffset.Y + itemHeight)); //item bottom-right
                        col.Add(new Point(itemOffset.X, itemOffset.Y + itemHeight));             //item bottom-left
                        col.Add(new Point(itemOffset.X, itemOffset.Y));                          //item top-left
                    }
                    col.Add(new Point(hostOffset.X, itemOffset.Y));                              //well bottom-left
                }
            }
        }
Пример #2
0
        void InitializeConnection()
        {
            ctx = new MonoBtlsSslCtx();

#if MARTIN_DEBUG
            errbio = MonoBtlsBio.CreateMonoStream(Console.OpenStandardError());
            ctx.SetDebugBio(errbio);
#endif

            SetupCertificateStore();

            if (!IsServer || AskForClientCertificate)
            {
                ctx.SetVerifyCallback(VerifyCallback, false);
            }
            if (!IsServer)
            {
                ctx.SetSelectCallback(SelectCallback);
            }

            var host = TargetHost;
            if (!string.IsNullOrEmpty(host))
            {
                var pos = TargetHost.IndexOf(':');
                if (pos > 0)
                {
                    host = host.Substring(0, pos);
                }
            }

            ctx.SetVerifyParam(MonoBtlsProvider.GetVerifyParam(host, IsServer));

            TlsProtocolCode minProtocol, maxProtocol;
            GetProtocolVersions(out minProtocol, out maxProtocol);

            ctx.SetMinVersion((int)minProtocol);
            ctx.SetMaxVersion((int)maxProtocol);

            if (Settings != null && Settings.EnabledCiphers != null)
            {
                var ciphers = new short [Settings.EnabledCiphers.Length];
                for (int i = 0; i < ciphers.Length; i++)
                {
                    ciphers [i] = (short)Settings.EnabledCiphers [i];
                }
                ctx.SetCiphers(ciphers, true);
            }
        }
Пример #3
0
        private async Task InitializeDatabaseAsync(IServiceProvider serviceProvider)
        {
            using (var serviceScope = serviceProvider.GetRequiredService <IServiceScopeFactory>().CreateScope())
            {
                var db = serviceScope.ServiceProvider.GetService <ApplicationContext>();

                if (await db.Database.EnsureCreatedAsync())
                {
                    TargetHost targetHost = new TargetHost()
                    {
                        Id = 1,
                        IP = "127.0.0.1"
                    };

                    Check check1 = new Check()
                    {
                        Id            = 1,
                        Cron          = @"*/1 * * * *",
                        HelthCheckUrl = "test",
                        Status        = CheckStatus.Active,
                        TargetHost    = targetHost
                    };

                    Check check2 = new Check()
                    {
                        Id            = 2,
                        Cron          = @"*/1 * * * *",
                        HelthCheckUrl = "test2",
                        Status        = CheckStatus.Active,
                        TargetHost    = targetHost
                    };

                    CheckResult checkResult = new CheckResult()
                    {
                        Check  = check1,
                        Status = CheckResultStatus.Success
                    };

                    db.TargetHosts.Add(targetHost);
                    db.Checks.Add(check1);
                    db.Checks.Add(check2);
                    db.CheckResults.Add(checkResult);
                    await db.SaveChangesAsync();
                }
            }
        }
Пример #4
0
        private async void OnLoaded(object sender, RoutedEventArgs e)
        {
            Loaded -= OnLoaded;

            await TargetHost.SetChildAsync(() =>
            {
                var box = new TextBox
                {
                    Text       = "吕毅 - walterlv",
                    Width      = 300,
                    Height     = 120,
                    Background = new SolidColorBrush(Colors.White)
                    {
                        Opacity = 0.5
                    },
                };
                return(box);
            });


            await TestLoadUnloadIssueAsync();
        }
Пример #5
0
        public WebRequest getTargetWebRequest(HttpListenerContext context)
        {
            TargetHost          host        = workspace.TargetHost;
            HttpWebRequest      destination = (HttpWebRequest)WebRequest.Create(host.Protocol + "://" + host.Host + ((host.Port > 0) ? (host.Port + "") : ("")));
            HttpListenerRequest request     = context.Request;

            System.Collections.Specialized.NameValueCollection headers = request.Headers;
            if (headers != null)
            {
//                destination.Headers = new WebHeaderCollection();
                foreach (String name in headers)
                {
                    if (WebHeaderCollection.IsRestricted(name))
                    {
                        continue;
                    }
                    destination.Headers.Add(name, headers[name]);
                }
            }

            if (request.AcceptTypes != null && request.AcceptTypes.Any())
            {
                destination.Accept = string.Join(",", request.AcceptTypes);
            }
            destination.ContentType = request.ContentType;
            destination.Referer     = request.UrlReferrer != null?request.UrlReferrer.AbsoluteUri : string.Empty;
            destination.UserAgent   = request.UserAgent;
            destination.Method      = request.HttpMethod;
            if (destination.CookieContainer == null)
            {
                destination.CookieContainer = new CookieContainer();
            }
            foreach (Cookie cookie in request.Cookies)
            {
                destination.CookieContainer.Add(destination.Address, cookie);
            }
            return(destination);
        }
Пример #6
0
        internal void AlignToTarget(TargetArgs args)
        {
            if (args.DockContainer != DockHost)
            {
                DockHost = args.DockContainer;
                if (DockHost == null)
                {
                    DockArea = Rect.Empty;
                }
                else
                {
                    DockArea = new Rect(
                        DockHost.ContentHost.TranslatePoint(new Point(), this),
                        DockHost.ContentHost.RenderSize
                        );
                }
            }

            var host = args.TabWell as FrameworkElement ?? args.DocumentContainer;

            if (host != TargetHost)
            {
                TargetHost = host;
                if (TargetHost == null)
                {
                    TargetArea = Rect.Empty;
                }
                else
                {
                    TargetArea = new Rect(
                        TargetHost.TranslatePoint(new Point(), this),
                        TargetHost.RenderSize
                        );
                }
            }

            var isAllTools = args.SourceItems.All(i => i.ItemType == TabItemType.Tool);

            CanDockOuter = isAllTools;

            if (TargetHost is DocumentWell)
            {
                CanDropCenter = true;
                CanDockTarget = isAllTools;

                var panel = TargetHost.FindVisualAncestor <DocumentContainer>();
                CanSplitHorizontal = panel?.Orientation == Orientation.Horizontal || panel?.Items.Count <= 1;
                CanSplitVertical   = panel?.Orientation == Orientation.Vertical || panel?.Items.Count <= 1;
            }
            else if (TargetHost is DocumentContainer)
            {
                CanDropCenter      = true;
                CanDockTarget      = isAllTools;
                CanSplitHorizontal = CanSplitVertical = false;
            }
            else if (TargetHost is ToolWell)
            {
                CanDockTarget      = false;
                CanSplitHorizontal = CanSplitVertical = CanDropCenter = isAllTools;
            }
            else
            {
                CanDockTarget = CanSplitHorizontal = CanSplitVertical = CanDropCenter = false;
            }

            DockTargetButton.UpdateCursor();
            UpdateHighlightPath(args.SourceItems, args.TabItem);
        }