예제 #1
0
        public EmguImage CreateBitmap(Image image, Palette palette)
        {
            EmguImage  bitmap     = new EmguImage(512, 256);
            List <Obj> sortedObjs = new List <Obj>(this.objects);

            sortedObjs.Sort((a, b) => b.GetPriority().CompareTo(a.GetPriority()));

            foreach (Obj obj in sortedObjs)
            {
                EmguImage objBitmap = obj.CreateBitmap(image, palette, this.tileSize);

                // Get first palette color
                Color transparent = palette.GetColor(obj.PaletteIndex, 0);

                // Set first palette color as transparent
                var mask = objBitmap.InRange(transparent, transparent);
                objBitmap.SetValue(0, mask);

                // Copy the object image to the frame
                Point position = obj.GetReferencePoint();
                position.Offset(256, 128);                      // Only positive coordinate values
                bitmap.Overlay(position.X, position.Y, objBitmap);

                objBitmap.Dispose();
            }

            //Rectangle absArea = this.VisibleArea;
            //absArea.Offset(512, 128); // Only positive coordinate values
            //EmguImage roiBitmap = bitmap.Copy(absArea);
            //bitmap.Dispose();
            return(bitmap);
        }
예제 #2
0
        protected override void OnPaint(PaintEventArgs pe)
        {
            if (DesignMode)
            {
                base.OnPaint(pe); return;
            }

            var checkboxLocation = new System.Drawing.Rectangle(0, 0, 10, 10);

            checkboxLocation.Offset(pe.ClipRectangle.Location);
            var innerLocation = new System.Drawing.Rectangle(3, 3, 5, 5);

            innerLocation.Offset(pe.ClipRectangle.Location);
            var textLocation = new System.Drawing.Point(pe.ClipRectangle.Location.X, pe.ClipRectangle.Location.Y);

            textLocation.Offset(15, 0);

            if (this.Checked)
            {
                pe.Graphics.FillRectangle(InkCheckedCheckBox.AsBrush(), checkboxLocation);
                pe.Graphics.FillRectangle(InkCheckedCheckBoxInner.AsBrush(), innerLocation);
                pe.Graphics.DrawRectangle(InkCheckedCheckBoxBorder.AsPen(), checkboxLocation);
            }
            else
            {
                pe.Graphics.FillRectangle(InkEmptyCheckBox.AsBrush(), checkboxLocation);
                pe.Graphics.DrawRectangle(InkEmptyCheckBoxBorder.AsPen(), checkboxLocation);
            }

            pe.Graphics.TextRenderingHint = TextRenderingHint.SingleBitPerPixelGridFit;
            pe.Graphics.DrawString(this.Text, this.Font, InkTextColor.AsBrush(), textLocation);
        }
예제 #3
0
        public void TestGesture_ZoomWithInertialMotion_ViewportUpdatesCorrectly()
        {
            IWebElement vcElem = Driver.FindElement(By.Id("vc"));

            Assert.IsNotNull(vcElem, "err: cannot find canvas element");
            Assert.IsTrue(vcElem.Size.Width > 10 && vcElem.Size.Height > 10, "err: canvas size should be atleast (10px,10px) to run test");

            int width  = vcElem.Size.Width - 10; // assuming a max border width of 5px on each side
            int height = vcElem.Size.Height - 10;

            VirtualCanvasComponent vc = new VirtualCanvasComponent(Driver);

            vc.SetVisible(new JsVisible(-3194.8898068225376, 401.0288546497742, 0.38537988462392836));
            vc.UpdateViewport();

            Random rnd    = new Random();
            Point  zoomPt = new Point(rnd.Next(0, width), rnd.Next(0, height));

            zoomPt.Offset(5, 5);

            JsCoordinates p1 = vc.PointScreenToVirtual(new JsCoordinates(zoomPt.X, zoomPt.Y));

            action = new ActionsExtension(Driver);
            action.MoveToElement(vcElem, Convert.ToInt32(zoomPt.X), Convert.ToInt32(zoomPt.Y));
            action.DoubleClick();
            action.Perform();
            vc.WaitAnimation();

            JsCoordinates p2 = vc.PointVirtualToScreen(p1);

            // Assert that the zoom-pt remains fixed after zooming.
            Assert.AreEqual(zoomPt.X, p2.X, 5);
            Assert.AreEqual(zoomPt.Y, p2.Y, 5);
        }
        public void ScrollBrowser(int delta)
        {
            Point newOffset = _webKitBrowser1.ScrollOffset;

            newOffset.Offset(0, -delta);
            ScrollBrowserTo(newOffset);
        }
예제 #5
0
 private void _MouseMove(object sender, MouseEventArgs e)
 {
     if (_isDown)
     {
         _oldForm.Offset(e.X - _oldPoint.X, e.Y - _oldPoint.Y);
         this.Location = _oldForm;
     }
 }
예제 #6
0
 private void Header_MouseMove(object sender, MouseEventArgs e)
 {
     if (wIsMoving)
     {
         System.Drawing.Point mousePos = MousePosition;
         mousePos.Offset(wMouseOffset.X, wMouseOffset.Y);
         Location = mousePos;
     }
 }
예제 #7
0
 private void Form_MouseMove(object sender, MouseEventArgs e)
 {
     if (e.Button == MouseButtons.Left)
     {
         System.Drawing.Point mousePose = System.Windows.Forms.Control.MousePosition;
         mousePose.Offset(mouseLocation.X, mouseLocation.Y);
         Location = mousePose;
     }
 }
        public void Offset(int lineOffset,
                           int columnOffset)
        {
            if ((lineOffset == 0) && (columnOffset == 0))
            {
                return;
            }

            m_Location.Offset(lineOffset, columnOffset);
        }
예제 #9
0
 void Form1MouseMove(object sender, MouseEventArgs e)
 {
     ((Control)sender).Cursor = Cursors.Arrow;    //设置拖动时鼠标箭头
     if (e.Button == MouseButtons.Left)
     {
         System.Drawing.Point mousePos = Control.MousePosition;
         mousePos.Offset(mouse_offset.X, mouse_offset.Y);        //设置偏移
         ((Control)sender).Location = ((Control)sender).Parent.PointToClient(mousePos);
     }
 }
예제 #10
0
        private object Move(object[] arguments)
        {
            int x = (int)arguments[0];
            int y = (int)arguments[1];

            System.Drawing.Point pos = Cursor.Position;
            pos.Offset(x, y);
            Cursor.Position = pos;
            return(true);
        }
        /// <summary>
        /// 显示报警提示
        /// </summary>
        /// <param name="sTip"></param>
        private void ShowToolTip(string sTip)
        {
            System.Drawing.Point pt = new System.Drawing.Point(0, 0);
            pt.Offset(0, this.Height);

            _tip.UseFading = true;                      //逐渐消失效果
            _tip.RemoveAll();

            _tip.ForeColor = System.Drawing.Color.Red;
            _tip.Show(sTip, this, pt, 1000);
        }
예제 #12
0
 private void HistoryListView_ItemMouseHover(object sender, ListViewItemMouseHoverEventArgs e)
 {
     if (this.UseCustomToolTips)
     {
         System.Drawing.Point position = this.PointToClient(Cursor.Position);
         position.Offset(0, Cursor.Current.Size.Height - 10);
         IntPtr handle = (IntPtr)typeof(ToolTip).GetProperty("Handle", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance).GetValue(this.tooltip, null);
         this.tooltip.Show(e.Item.ToolTipText, this, position, this.tooltip.AutoPopDelay);
         Growl.DisplayStyle.Win32.SetWindowPos(handle, Growl.DisplayStyle.Win32.HWND_TOPMOST, 0, 0, 0, 0, Growl.DisplayStyle.Win32.SWP_NOACTIVATE | Growl.DisplayStyle.Win32.SWP_NOMOVE | Growl.DisplayStyle.Win32.SWP_NOSIZE);
     }
 }
예제 #13
0
 public void OffsetSource(int dx, int dy, bool Remark)
 {
     if (Remark)
     {
         mySourceOffsetBack.Offset(dx, dy);
     }
     foreach (SimpleRectangleTransform item in this)
     {
         System.Drawing.Rectangle rect = item.SourceRect;
         rect.Offset(dx, dy);
         item.SourceRect = rect;
     }
 }
예제 #14
0
        public virtual void DrawBorders(System.Windows.Forms.Control control, System.Windows.Forms.PaintEventArgs pevent)
        {
            //calculate the 4 points or coordinates of the border
            System.Drawing.Point p1 = control.Bounds.Location;             //top left

            System.Drawing.Point p2 = control.Bounds.Location;
            p2.Offset(control.Width, 0);                       //top right

            System.Drawing.Point p3 = control.Bounds.Location; //bottom left
            p2.Offset(0, control.Height * -1);                 //top right

            System.Drawing.Point p4 = control.Bounds.Location; //bottom right
            p2.Offset(control.Width, control.Height * -1);     //top right

            //draw custom border here
            if (((IControl)control).BorderColor != null && ((IControl)control).BorderWidth != null)
            {
                pevent.Graphics.DrawLine(new System.Drawing.Pen(Platform.Current.Parse(((IControl)control).BorderColor), (float)((IControl)control).BorderWidth.Left), p4, p1);                 //left
                pevent.Graphics.DrawLine(new System.Drawing.Pen(Platform.Current.Parse(((IControl)control).BorderColor), (float)((IControl)control).BorderWidth.Left), p1, p2);                 //top
                pevent.Graphics.DrawLine(new System.Drawing.Pen(Platform.Current.Parse(((IControl)control).BorderColor), (float)((IControl)control).BorderWidth.Left), p2, p3);                 //right
                pevent.Graphics.DrawLine(new System.Drawing.Pen(Platform.Current.Parse(((IControl)control).BorderColor), (float)((IControl)control).BorderWidth.Left), p3, p4);                 //bottom
            }
        }
예제 #15
0
파일: Form1.cs 프로젝트: meoti/TBARP
        private async void ExecuteButton_ClickAsync(object sender, EventArgs e)
        {
            i = 0;
            animatepanel.Visible = true;
            labelf.Text          = "Processing PDFs ...";
            Thread.Sleep(1);
            circleProgressbar.Value = 1;

            // _files contains all the files.
            _files.Clear();
            foreach (string filePath in DropBox.Items)
            {
                if (!pdfData.Keys.Contains(System.IO.Path.GetFileNameWithoutExtension(filePath)))
                {
                    _files.Add(filePath);
                }
            }

            await WorkAsync();

            circleProgressbar.Value = 100;
            Thread.Sleep(1200);
            animatepanel.Visible = false;
            homePanel.Visible    = false;

            // add dynamically the custom buttons
            //dynaPdfListPanel.Controls.Clear();
            //dynaPdfBtns.Clear();
            System.Drawing.Point newLoc = new System.Drawing.Point(-2, 3);
            foreach (string pdfname in pdfData.Keys.Where(pdfname => !dynaPdfListPanel.Controls.ToString().Contains(pdfname)))
            {
                var b = new Listbutton(pdfname, pdfname);
                newLoc.Offset(0, b.Height + 2);
                b.Click += new EventHandler(DynaDataExtract);
                dynaPdfListPanel.Controls.Add(b);

                //dynaPdfBtns.Add(b);
                b.Location = newLoc;
            }
            //dynaPdfListPanel.Visible = true;
            //pdfFlatButton_Click(sender, e);
            settingPanel.Visible = true;
            homeTransition.ShowSync(dynaPdfListPanel);
            pdfFlatButton.selected      = true;
            homeButton.selected         = false;
            templateFlatButton.selected = false;
            bunifuFlatButton1.selected  = false;
            bunifuFlatButton3.selected  = false;
        }
예제 #16
0
 private static void DrawCkBox(System.Windows.Forms.DataGridView dgv)
 {
     System.Windows.Forms.CheckBox ckBox = new System.Windows.Forms.CheckBox();
     System.Drawing.Point          p     = dgv.GetCellDisplayRectangle(0, -1, true).Location;
     ckBox.Size = new System.Drawing.Size(18, 18);
     p.Offset(((dgv.Columns[0].Width - ckBox.Width) / 2) + 4, 2);
     ckBox.Location = p;
     ckBox.Visible  = true;
     ckBox.BringToFront();
     ckBox.BackColor       = System.Drawing.Color.White;
     ckBox.ThreeState      = false;
     ckBox.Checked         = false;
     ckBox.CheckedChanged += new EventHandler(ckBox_CheckedChanged);
     dgv.Controls.Add(ckBox);
 }
예제 #17
0
    public IEnumerable<DPoint> EnumerateObjectTileLocations(ObjectMeasureData measureData) {
      DPoint origin = measureData.OriginTileLocation;

      if (
        (measureData.BlockType == TileID.OpenDoor &&
        this.GetDoorDirection(measureData.OriginTileLocation) == Direction.Left) ||
        (measureData.BlockType == TileID.TrapdoorOpen &&
        this.GetDoorDirection(measureData.OriginTileLocation) == Direction.Down )
      ) {
        origin.Offset(-1, 0);
      }

      for (int x = origin.X; x < origin.X + measureData.Size.X; x++)
        for (int y = origin.Y; y < origin.Y + measureData.Size.Y; y++)
          yield return new DPoint(x, y);
    }
예제 #18
0
        public void DragAWorkflowIntoAndOutOfAForEach_Expected_NoErrors()
        {
            // Create the workflow
            RibbonUIMap.CreateNewWorkflow();

            // Get some variables
            UITestControl theTab         = TabManagerUIMap.GetActiveTab();
            UITestControl theStartButton = WorkflowDesignerUIMap.FindControlByAutomationId(theTab, "Start");
            Point         workflowPoint1 = new Point(theStartButton.BoundingRectangle.X, theStartButton.BoundingRectangle.Y + 200);

            Point requiredPoint = WorkflowDesignerUIMap.GetPointUnderStartNode(theTab);

            requiredPoint.Offset(20, 50);

            // Drag a ForEach onto the Workflow
            ToolboxUIMap.DragControlToWorkflowDesigner(ToolType.ForEach, workflowPoint1, "For Each");

            // Get a sample workflow, and drag it onto the "Drop Activity Here" part of the ForEach box
            ExplorerUIMap.EnterExplorerSearchText("CalculateTaxReturns");
            var targetPoint = new Point(workflowPoint1.X + 25, workflowPoint1.Y + 25);

            ExplorerUIMap.DragControlToWorkflowDesigner("localhost", "WORKFLOWS", "MO", "CalculateTaxReturns", targetPoint);

            // Now - Onto Part 2!

            // 5792.2

            // Get the location of the ForEach box
            UITestControl forEachControl = WorkflowDesignerUIMap.FindControlByAutomationId(theTab, "ForEach");

            MouseCommands.MoveAndClick(new Point(forEachControl.BoundingRectangle.X + 175, forEachControl.BoundingRectangle.Y + 75));

            // And drag it down
            Mouse.StartDragging();
            Mouse.StopDragging(new Point(workflowPoint1.X - 200, workflowPoint1.Y + 100));

            // Now get its position
            UITestControl calcTaxReturnsControl = WorkflowDesignerUIMap.FindControlByAutomationId(theTab, "CalculateTaxReturns");

            // Its not on the design surface, must be in foreach
            Assert.IsNotNull(calcTaxReturnsControl, "Could not drop it ;(");
        }
예제 #19
0
        public void TestGesture_PanWithInertialMotion_ViewportUpdatesCorrectly()
        {
            IWebElement vcElem = Driver.FindElement(By.Id("vc"));

            Assert.IsNotNull(vcElem, "err: cannot find canvas element");
            Assert.IsTrue(vcElem.Size.Width > 10 && vcElem.Size.Height > 10, "err: canvas size should be atleast (10px,10px) to run test");

            int width  = vcElem.Size.Width - 10; // assuming a max border width of 5px on each side
            int height = vcElem.Size.Height - 10;

            VirtualCanvasComponent vc = new VirtualCanvasComponent(Driver);

            vc.SetVisible(new JsVisible(-3194.8898068225376, 401.0288546497742, 0.38537988462392836));
            vc.UpdateViewport();

            Random rnd      = new Random();
            Point  panStart = new Point(rnd.Next(width), rnd.Next(height));

            panStart.Offset(5, 5);
            Point panEnd = new Point(rnd.Next(width), rnd.Next(height));

            panEnd.Offset(5, 5);
            Vector pan = new Vector(panEnd.X - panStart.X, panEnd.Y - panStart.Y);

            JsCoordinates p1 = vc.PointScreenToVirtual(new JsCoordinates(panStart.X, panStart.Y));

            action = new ActionsExtension(Driver);
            action.MoveToElement(vcElem, panStart.X, panStart.Y);
            action.ClickAndHold();
            action.MoveByOffset(Convert.ToInt32(pan.X), Convert.ToInt32(pan.Y));
            action.Release();
            action.Perform();
            vc.WaitAnimation();

            JsCoordinates p2 = vc.PointVirtualToScreen(p1);

            // Assert that start-pt wrt the newViewport corresponds to end-pt in the oldViewport
            Assert.AreEqual(panEnd.X, p2.X, 5);
            Assert.AreEqual(panEnd.Y, p2.Y, 5);
        }
예제 #20
0
        public override bool Layout(object Container, System.Windows.Forms.LayoutEventArgs LayoutEventArgs)
        {
            System.Windows.Forms.Control Container_          = Container as System.Windows.Forms.Control;
            System.Drawing.Point         NextControlLocation = Container_.DisplayRectangle.Location;

            foreach (System.Windows.Forms.Control Control in Container_.Controls)
            {
                if (!Control.Visible)
                {
                    continue;
                }
                NextControlLocation.Offset(Control.Margin.Left, Control.Margin.Top);
                Control.Location = NextControlLocation;
                if (Control.AutoSize)
                {
                    Control.Size = Control.GetPreferredSize(Container_.DisplayRectangle.Size);
                }
                NextControlLocation.X  = Container_.DisplayRectangle.X;
                NextControlLocation.Y += Control.Height + Control.Margin.Bottom;
            }

            return(false);
        }
예제 #21
0
 /// <summary>
 ///     从窗口坐标转为相对屏幕的绝对坐标
 /// </summary>
 /// <param name="hWnd"></param>
 /// <param name="point"></param>
 /// <returns></returns>
 private static System.Drawing.Point ToAbsolutePoint(IntPtr hWnd, System.Drawing.Point point)
 {
     User32.GetWindowRect(hWnd, out var windowPoint);
     point.Offset(windowPoint.left, windowPoint.top);
     return(point);
 }
예제 #22
0
 public static DPoint OffsetEx(this DPoint point, int xOffset, int yOffset)
 {
     point.Offset(xOffset, yOffset);
     return(point);
 }
예제 #23
0
        protected override void Process(System.Web.HttpContext context)
        {
            context.Response.ContentType  = MediaTypeNames.Text.Plain;
            context.Response.BufferOutput = false;

            ResourceManager resourceManager = new ResourceManager(context.Server);

            string sectorName = GetStringOption(context, "sector");
            string type       = GetStringOption(context, "type");
            string milieu     = GetStringOption(context, "milieu");
            string tag        = GetStringOption(context, "tag");

            // NOTE: This (re)initializes a static data structure used for
            // resolving names into sector locations, so needs to be run
            // before any other objects (e.g. Worlds) are loaded.
            SectorMap.Flush();
            SectorMap map = SectorMap.GetInstance(resourceManager);

            var sectorQuery = from sector in map.Sectors
                              where (sectorName == null || sector.Names[0].Text.StartsWith(sectorName, ignoreCase: true, culture: CultureInfo.InvariantCulture)) &&
                              (sector.DataFile != null) &&
                              (type == null || sector.DataFile.Type == type) &&
                              (milieu == null || sector.CanonicalMilieu == milieu) &&
                              (tag == null || sector.Tags.Contains(tag)) &&
                              (sector.Tags.Contains("OTU") || sector.Tags.Contains("Apocryphal") || sector.Tags.Contains("Faraway"))
                              orderby sector.Names[0].Text
                              select sector;

            foreach (var sector in sectorQuery)
            {
                context.Response.Output.WriteLine(sector.Names[0].Text);
#if DEBUG
                WorldCollection worlds = sector.GetWorlds(resourceManager, cacheResults: false);

                if (worlds != null)
                {
                    double pop = worlds.Select(w => w.Population).Sum();
                    if (pop > 0)
                    {
                        context.Response.Output.WriteLine($"{worlds.Count()} world(s) - population: {pop / 1e9:#,###.##} billion");
                    }
                    else
                    {
                        context.Response.Output.WriteLine($"{worlds.Count()} world(s) - population: N/A");
                    }
                    worlds.ErrorList.Report(context.Response.Output);
                }
                else
                {
                    context.Response.Output.WriteLine("0 world(s)");
                }

                foreach (IAllegiance item in sector.Borders.AsEnumerable <IAllegiance>()
                         .Concat(sector.Routes.AsEnumerable <IAllegiance>())
                         .Concat(sector.Labels.AsEnumerable <IAllegiance>()))
                {
                    if (string.IsNullOrWhiteSpace(item.Allegiance))
                    {
                        continue;
                    }
                    if (sector.GetAllegianceFromCode(item.Allegiance) == null)
                    {
                        context.Response.Output.WriteLine($"Undefined allegiance code: {item.Allegiance} (on {item.GetType().Name})");
                    }
                }

                foreach (var route in sector.Routes)
                {
                    System.Drawing.Point startSector = sector.Location, endSector = sector.Location;
                    startSector.Offset(route.StartOffset);
                    endSector.Offset(route.EndOffset);

                    Location startLocation = new Location(startSector, route.Start);
                    Location endLocation   = new Location(endSector, route.End);
                    int      distance = Astrometrics.HexDistance(Astrometrics.LocationToCoordinates(startLocation),
                                                                 Astrometrics.LocationToCoordinates(endLocation));
                    if (distance == 0)
                    {
                        context.Response.Output.WriteLine($"Error: Route length {distance}: {route.ToString()}");
                    }
                    else if (distance > 4)
                    {
                        context.Response.Output.WriteLine($"Warning: Route length {distance}: {route.ToString()}");
                    }

                    /*
                     * This fails because of routes that use e.g. 3341-style coordinates
                     * It will also be extremely slow due to loading world lists w/o caching
                     *                  {
                     *                      var w = map.FromLocation(startSector).GetWorlds(resourceManager, cacheResults: false);
                     *                      if (w != null)
                     *                      {
                     *                          if (w[route.StartPoint.X, route.StartPoint.Y] == null)
                     *                              context.Response.Output.WriteLine($"Route start empty hex: {route.ToString()}");
                     *                      }
                     *                  }
                     *                  {
                     *                      var w = map.FromLocation(endSector).GetWorlds(resourceManager, cacheResults: false);
                     *                      if (w != null)
                     *                      {
                     *                          if (w[route.EndPoint.X, route.EndPoint.Y] == null)
                     *                              context.Response.Output.WriteLine($"Route end empty hex: {route.ToString()}");
                     *                      }
                     *                  }
                     */
                }
#endif
                context.Response.Output.WriteLine();
            }
            return;
        }
예제 #24
0
    private void AC_WirelessTransmitter(TestContext context) {
      DPoint testOffset = new DPoint(422, 371);

      context.Phase = "1-1";
      this.Config.WirelessTransmitterConfigs[ComponentConfigProfile.Default].Range = 3;
      this.Config.WirelessTransmitterConfigs[ComponentConfigProfile.Default].Cooldown = 0;
      this.MetadataHandler.Metadata.WirelessTransmitters.Clear();
      this.MetadataHandler.Metadata.WirelessTransmitters.Add(testOffset, this.GetTestPlayer().Name);
      this.MetadataHandler.Metadata.WirelessTransmitters.Add(testOffset.OffsetEx(2, 0), this.GetTestPlayer().Name);

      this.QuickProcessCircuit(testOffset.X, testOffset.Y + 3);
      TAssert.IsObjectInactive(testOffset.X + 2, testOffset.Y + 3);

      context.Phase = "1-2";
      this.QuickProcessCircuit(testOffset.X, testOffset.Y + 3);
      TAssert.IsObjectActive(testOffset.X + 2, testOffset.Y + 3);

      context.Phase = "1-3";
      this.QuickProcessCircuit(testOffset.X, testOffset.Y + 3);
      TAssert.IsObjectInactive(testOffset.X + 2, testOffset.Y + 3);

      context.Phase = "2-1";
      testOffset.Offset(5, 0);
      this.MetadataHandler.Metadata.WirelessTransmitters.Add(testOffset, this.GetTestPlayer().Name);
      this.MetadataHandler.Metadata.WirelessTransmitters.Add(testOffset.OffsetEx(2, 0), this.GetTestPlayer().Name);

      this.QuickProcessCircuit(testOffset.X, testOffset.Y + 3);
      TAssert.IsObjectActive(testOffset.X + 2, testOffset.Y + 3);

      context.Phase = "2-2";
      this.QuickProcessCircuit(testOffset.X, testOffset.Y + 3);
      TAssert.IsObjectActive(testOffset.X + 2, testOffset.Y + 3);

      context.Phase = "2-3";
      this.QuickProcessCircuit(testOffset.X, testOffset.Y + 3);
      TAssert.IsObjectActive(testOffset.X + 2, testOffset.Y + 3);

      context.Phase = "3-1";
      this.Config.WirelessTransmitterConfigs[ComponentConfigProfile.Default].Range = 6;
      testOffset.Offset(5, 0);
      this.MetadataHandler.Metadata.WirelessTransmitters.Add(testOffset, this.GetTestPlayer().Name);
      this.MetadataHandler.Metadata.WirelessTransmitters.Add(testOffset.OffsetEx(2, 0), this.GetTestPlayer().Name);
      this.MetadataHandler.Metadata.WirelessTransmitters.Add(testOffset.OffsetEx(4, 0), this.GetTestPlayer().Name);

      this.QuickProcessCircuit(testOffset.X, testOffset.Y + 3);
      TAssert.IsObjectInactive(testOffset.X + 2, testOffset.Y + 3);
      TAssert.IsObjectActive(testOffset.X + 4, testOffset.Y + 3);

      context.Phase = "3-2";
      this.QuickProcessCircuit(testOffset.X, testOffset.Y + 3);
      TAssert.IsObjectActive(testOffset.X + 2, testOffset.Y + 3);
      TAssert.IsObjectInactive(testOffset.X + 4, testOffset.Y + 3);

      context.Phase = "3-3";
      this.QuickProcessCircuit(testOffset.X, testOffset.Y + 3);
      TAssert.IsObjectInactive(testOffset.X + 2, testOffset.Y + 3);
      TAssert.IsObjectActive(testOffset.X + 4, testOffset.Y + 3);
    }
예제 #25
0
        protected override void OnPaint(PaintEventArgs args)
        {
            base.OnPaint(args);

            var tmpGraphicsState = args.Graphics.Save( );

            args.Graphics.PixelOffsetMode   = System.Drawing.Drawing2D.PixelOffsetMode.HighQuality;
            args.Graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor;

            if (this.Orientation == Orientation.Horizontal)
            {
                args.Graphics.DrawImage(this.colorBitmap, SliderMarkerSize, SliderMarkerSize, this.Width - 2 * (SliderMarkerSize + BorderOffsetSize / 2), this.Height - 2 * (SliderMarkerSize + 1));
            }
            else
            {
                args.Graphics.Transform = new System.Drawing.Drawing2D.Matrix(0f, 1f, 1f, 0f, 0f, 0f);
                args.Graphics.DrawImage(this.colorBitmap, SliderMarkerSize - 1, SliderMarkerSize, this.Height - 2 * SliderMarkerSize, this.Width - 2 * (SliderMarkerSize + BorderOffsetSize / 2));
            }
            args.Graphics.Restore(tmpGraphicsState);

            using (var tmpDrawPenObject = new System.Drawing.Pen(System.Drawing.Color.Black))
            {
                tmpDrawPenObject.Color = System.Drawing.Color.FromArgb(172, 168, 153);
                var tempLeftTop     = new System.Drawing.Point(SliderMarkerSize, BorderOffsetSize);
                var tempRightTop    = new System.Drawing.Point(this.Width - (SliderMarkerSize + BorderOffsetSize), BorderOffsetSize);
                var tempLeftBottom  = new System.Drawing.Point(SliderMarkerSize, this.Height - (SliderMarkerSize + BorderOffsetSize));
                var tempRightBottom = new System.Drawing.Point(this.Width - (SliderMarkerSize + BorderOffsetSize), this.Height - (SliderMarkerSize + BorderOffsetSize));

                if (this.Orientation == Orientation.Horizontal)
                {
                    tempLeftTop.Offset(0, 1); tempRightTop.Offset(0, 1); tempLeftBottom.Offset(0, 1); tempRightBottom.Offset(0, 1);
                }

                args.Graphics.DrawLine(tmpDrawPenObject, tempLeftTop, tempRightTop);                //	Draw top line
                args.Graphics.DrawLine(tmpDrawPenObject, tempLeftTop, tempLeftBottom);              //	Draw left hand line

                tmpDrawPenObject.Color = System.Drawing.Color.White;
                args.Graphics.DrawLine(tmpDrawPenObject, tempRightTop, tempRightBottom);         //	Draw right hand line
                args.Graphics.DrawLine(tmpDrawPenObject, tempLeftBottom, tempRightBottom);       //	Draw bottome line

                tmpDrawPenObject.Color = System.Drawing.Color.Black;
                var tmpInnerBorder = new System.Drawing.Rectangle(tempLeftTop, new System.Drawing.Size(System.Math.Abs(tempRightBottom.X - tempLeftBottom.X), System.Math.Abs(tempRightBottom.Y - tempLeftTop.Y)));
                tmpInnerBorder.Inflate(-1, -1);
                args.Graphics.DrawRectangle(tmpDrawPenObject, tmpInnerBorder);          //	Draw inner black rectangle

                //draw gridlines
                if ((ModifierKeys & System.Windows.Forms.Keys.Shift) != 0)
                {
                    tmpDrawPenObject.Brush = new System.Drawing.Drawing2D.HatchBrush(System.Drawing.Drawing2D.HatchStyle.SmallCheckerBoard, System.Drawing.Color.FromArgb(80, 255, 255, 255), System.Drawing.Color.FromArgb(0, 0, 0, 0));

                    float dy = (float)(this.Height - 2 * (SliderMarkerSize + 1)) / 8f, y = 5f;
                    for (int index = 0; index <= 8; index++, y += dy)
                    {
                        args.Graphics.DrawLine(tmpDrawPenObject, SliderMarkerSize, (int)y, this.Width - (SliderMarkerSize + 1), (int)y);
                    }
                }
            }

            //draw fader
            var tempFaderBounds = this.GetScrollerRectangle( );

            args.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;

            if (this.Orientation == Orientation.Vertical)
            {
                tempFaderBounds.Offset(0, -BorderOffsetSize / 2);
                System.Drawing.Point[] tempPolygonPoints =
                    new System.Drawing.Point[]
                {
                    new System.Drawing.Point(tempFaderBounds.X + 1, tempFaderBounds.Y),
                    new System.Drawing.Point(tempFaderBounds.X + 4, tempFaderBounds.Y),
                    new System.Drawing.Point(tempFaderBounds.X + 9, tempFaderBounds.Y + SliderMarkerSize),
                    new System.Drawing.Point(tempFaderBounds.X + 4, tempFaderBounds.Bottom),
                    new System.Drawing.Point(tempFaderBounds.X + 1, tempFaderBounds.Bottom),
                    new System.Drawing.Point(tempFaderBounds.X + 0, tempFaderBounds.Bottom - 1),
                    new System.Drawing.Point(tempFaderBounds.X + 0, tempFaderBounds.Y + 1)
                };
                args.Graphics.FillPolygon(System.Drawing.Brushes.White, tempPolygonPoints);
                args.Graphics.DrawPolygon(System.Drawing.Pens.Silver, tempPolygonPoints);

                tempPolygonPoints =
                    new System.Drawing.Point[]
                {
                    new System.Drawing.Point(tempFaderBounds.Right - 1, tempFaderBounds.Y),
                    new System.Drawing.Point(tempFaderBounds.Right - 4, tempFaderBounds.Y),
                    new System.Drawing.Point(tempFaderBounds.Right - 9, tempFaderBounds.Y + SliderMarkerSize),
                    new System.Drawing.Point(tempFaderBounds.Right - 4, tempFaderBounds.Bottom),
                    new System.Drawing.Point(tempFaderBounds.Right - 1, tempFaderBounds.Bottom),
                    new System.Drawing.Point(tempFaderBounds.Right - 0, tempFaderBounds.Bottom - 1),
                    new System.Drawing.Point(tempFaderBounds.Right - 0, tempFaderBounds.Y + 1)
                };

                args.Graphics.FillPolygon(System.Drawing.Brushes.White, tempPolygonPoints);
                args.Graphics.DrawPolygon(System.Drawing.Pens.Silver, tempPolygonPoints);
            }
            else
            {
                tempFaderBounds.Offset(-BorderOffsetSize / 2, 0);
                System.Drawing.Point[] tempPolygonPoints =
                    new System.Drawing.Point[]
                {
                    new System.Drawing.Point(tempFaderBounds.X + 1, tempFaderBounds.Y),
                    new System.Drawing.Point(tempFaderBounds.X + 0, tempFaderBounds.Y + 1),
                    new System.Drawing.Point(tempFaderBounds.X + 0, tempFaderBounds.Y + 4),
                    new System.Drawing.Point(tempFaderBounds.X + 1 * SliderMarkerSize, tempFaderBounds.Y + 9),
                    new System.Drawing.Point(tempFaderBounds.X + 2 * SliderMarkerSize, tempFaderBounds.Y + 4),
                    new System.Drawing.Point(tempFaderBounds.X + 2 * SliderMarkerSize, tempFaderBounds.Y + 1),
                    new System.Drawing.Point(tempFaderBounds.X + 2 * SliderMarkerSize - 1, tempFaderBounds.Y),
                };
                args.Graphics.FillPolygon(System.Drawing.Brushes.White, tempPolygonPoints);
                args.Graphics.DrawPolygon(System.Drawing.Pens.Silver, tempPolygonPoints);

                tempPolygonPoints =
                    new System.Drawing.Point[]
                {
                    new System.Drawing.Point(tempFaderBounds.X + 1, tempFaderBounds.Bottom),
                    new System.Drawing.Point(tempFaderBounds.X + 0, tempFaderBounds.Bottom - 1),
                    new System.Drawing.Point(tempFaderBounds.X + 0, tempFaderBounds.Bottom - 4),
                    new System.Drawing.Point(tempFaderBounds.X + 1 * SliderMarkerSize, tempFaderBounds.Bottom - 9),
                    new System.Drawing.Point(tempFaderBounds.X + 2 * SliderMarkerSize, tempFaderBounds.Bottom - 4),
                    new System.Drawing.Point(tempFaderBounds.X + 2 * SliderMarkerSize, tempFaderBounds.Bottom - 1),
                    new System.Drawing.Point(tempFaderBounds.X + 2 * SliderMarkerSize - 1, tempFaderBounds.Bottom)
                };
                args.Graphics.FillPolygon(System.Drawing.Brushes.White, tempPolygonPoints);
                args.Graphics.DrawPolygon(System.Drawing.Pens.Silver, tempPolygonPoints);
            }
        }
 /// <summary>
 /// Changes the magnifier position by the given delta
 /// Magnifier position is limited to original screenshot size + border width/height
 /// </summary>
 /// <param name="dx">x delta to add</param>
 /// <param name="dy">y delta to add</param>
 private void ChangeMagnifierPositionBy(int dx, int dy)
 {
     magnifierPosition.Offset(dx, dy);
     UpdateMagnifierLocation(magnifierPosition.X, magnifierPosition.Y);
 }
예제 #27
0
        protected override void Process(System.Web.HttpContext context, ResourceManager resourceManager)
        {
            context.Response.ContentType  = ContentTypes.Text.Plain;
            context.Response.BufferOutput = false;

            string sectorName   = GetStringOption(context, "sector");
            string type         = GetStringOption(context, "type");
            string milieu       = GetStringOption(context, "milieu");
            string tag          = GetStringOption(context, "tag");
            bool   hide_tl      = GetBoolOption(context, "hide-tl");
            bool   hide_gov     = GetBoolOption(context, "hide-gov");
            bool   hide_stellar = GetBoolOption(context, "hide-stellar");

            ErrorLogger.Severity severity = GetBoolOption(context, "warnings", true) ? 0 : ErrorLogger.Severity.Error;

            // NOTE: This (re)initializes a static data structure used for
            // resolving names into sector locations, so needs to be run
            // before any other objects (e.g. Worlds) are loaded.
            SectorMap.Flush();
            SectorMap map = SectorMap.GetInstance(resourceManager);

            var sectorQuery = from sector in map.Sectors
                              where (sectorName == null || sector.Names[0].Text.StartsWith(sectorName, ignoreCase: true, culture: CultureInfo.InvariantCulture)) &&
                              (sector.DataFile != null) &&
                              (type == null || sector.DataFile.Type == type) &&
                              (milieu == null || sector.CanonicalMilieu == milieu) &&
                              (tag == null || sector.Tags.Contains(tag)) &&
                              (sector.Tags.Contains("OTU") || sector.Tags.Contains("Apocryphal") || sector.Tags.Contains("Faraway"))
                              orderby sector.Names[0].Text
                              select sector;

            foreach (var sector in sectorQuery)
            {
                context.Response.Output.WriteLine($"{sector.Names[0].Text} - {sector.Milieu}");
#if DEBUG
                int error_count   = 0;
                int warning_count = 0;

                try
                {
                    WorldCollection worlds = sector.GetWorlds(resourceManager, cacheResults: false);
                    if (worlds != null)
                    {
                        double pop = worlds.Select(w => w.Population).Sum();
                        if (pop > 0)
                        {
                            context.Response.Output.WriteLine($"{worlds.Count()} world(s) - population: {pop / 1e9:#,###.##} billion");
                        }
                        else
                        {
                            context.Response.Output.WriteLine($"{worlds.Count()} world(s) - population: N/A");
                        }
                        worlds.ErrorList.Report(context.Response.Output, severity, (ErrorLogger.Record record) =>
                        {
                            if (hide_gov && (record.message.StartsWith("UWP: Gov") || record.message.StartsWith("Gov")))
                            {
                                return(false);
                            }
                            if (hide_tl && record.message.StartsWith("UWP: TL"))
                            {
                                return(false);
                            }
                            if (hide_stellar && record.message.StartsWith("Invalid stellar data:"))
                            {
                                return(false);
                            }
                            return(true);
                        });
                        error_count   += worlds.ErrorList.CountOf(ErrorLogger.Severity.Error);
                        warning_count += worlds.ErrorList.CountOf(ErrorLogger.Severity.Warning);
                    }
                    else
                    {
                        context.Response.Output.WriteLine("0 world(s)");
                    }
                }
                catch (ParseException ex)
                {
                    context.Response.Output.WriteLine($"Bad data file: {ex.Message}");
                }

                foreach (IAllegiance item in sector.Borders.AsEnumerable <IAllegiance>()
                         .Concat(sector.Routes.AsEnumerable <IAllegiance>())
                         .Concat(sector.Labels.AsEnumerable <IAllegiance>()))
                {
                    if (string.IsNullOrWhiteSpace(item.Allegiance))
                    {
                        continue;
                    }
                    if (sector.GetAllegianceFromCode(item.Allegiance) == null)
                    {
                        context.Response.Output.WriteLine($"Undefined allegiance code: {item.Allegiance} (on {item.GetType().Name})");
                    }
                }

                foreach (var route in sector.Routes)
                {
                    System.Drawing.Point startSector = sector.Location, endSector = sector.Location;
                    startSector.Offset(route.StartOffset);
                    endSector.Offset(route.EndOffset);

                    int distance = Astrometrics.HexDistance(
                        Astrometrics.LocationToCoordinates(new Location(startSector, route.Start)),
                        Astrometrics.LocationToCoordinates(new Location(endSector, route.End)));
                    if (distance == 0)
                    {
                        context.Response.Output.WriteLine($"Error: Route length {distance}: {route.ToString()}");
                        ++error_count;
                    }
                    else if (distance > 4)
                    {
                        if (severity <= ErrorLogger.Severity.Warning)
                        {
                            context.Response.Output.WriteLine($"Warning: Route length {distance}: {route.ToString()}");
                        }
                        ++warning_count;
                    }

                    /*
                     * This fails because of routes that use e.g. 3341-style coordinates
                     * It will also be extremely slow due to loading world lists w/o caching
                     *                  {
                     *                      var w = map.FromLocation(startSector).GetWorlds(resourceManager, cacheResults: false);
                     *                      if (w != null)
                     *                      {
                     *                          if (w[route.StartPoint.X, route.StartPoint.Y] == null)
                     *                              context.Response.Output.WriteLine($"Route start empty hex: {route.ToString()}");
                     *                      }
                     *                  }
                     *                  {
                     *                      var w = map.FromLocation(endSector).GetWorlds(resourceManager, cacheResults: false);
                     *                      if (w != null)
                     *                      {
                     *                          if (w[route.EndPoint.X, route.EndPoint.Y] == null)
                     *                              context.Response.Output.WriteLine($"Route end empty hex: {route.ToString()}");
                     *                      }
                     *                  }
                     */
                }
                context.Response.Output.WriteLine($"{error_count} errors, {warning_count} warnings.");
#endif
                context.Response.Output.WriteLine();
            }
            return;
        }
예제 #28
0
        public void TestGesture_PanWithInertialMotion_ViewportUpdatesCorrectly()
        {
            IWebElement vcElem = Driver.FindElement(By.Id("vc"));
            Assert.IsNotNull(vcElem, "err: cannot find canvas element");
            Assert.IsTrue(vcElem.Size.Width > 10 && vcElem.Size.Height > 10, "err: canvas size should be atleast (10px,10px) to run test");

            int width = vcElem.Size.Width - 10; // assuming a max border width of 5px on each side
            int height = vcElem.Size.Height - 10;

            VirtualCanvasComponent vc = new VirtualCanvasComponent(Driver);
            vc.SetVisible(new JsVisible(-3194.8898068225376, 401.0288546497742, 0.38537988462392836));
            vc.UpdateViewport();

            Random rnd = new Random();
            Point panStart = new Point(rnd.Next(width), rnd.Next(height));
            panStart.Offset(5, 5);
            Point panEnd = new Point(rnd.Next(width), rnd.Next(height));
            panEnd.Offset(5, 5);
            Vector pan = new Vector(panEnd.X - panStart.X, panEnd.Y - panStart.Y);

            JsCoordinates p1 = vc.PointScreenToVirtual(new JsCoordinates(panStart.X, panStart.Y));

            action = new ActionsExtension(Driver);
            action.MoveToElement(vcElem, panStart.X, panStart.Y);
            action.ClickAndHold();
            action.MoveByOffset(Convert.ToInt32(pan.X), Convert.ToInt32(pan.Y));
            action.Release();
            action.Perform();
            vc.WaitAnimation();

            JsCoordinates p2 = vc.PointVirtualToScreen(p1);

            // Assert that start-pt wrt the newViewport corresponds to end-pt in the oldViewport
            Assert.AreEqual(panEnd.X, p2.X, 5);
            Assert.AreEqual(panEnd.Y, p2.Y, 5);
        }
예제 #29
0
        public void TestGesture_ZoomWithInertialMotion_ViewportUpdatesCorrectly()
        {
            IWebElement vcElem = Driver.FindElement(By.Id("vc"));
            Assert.IsNotNull(vcElem, "err: cannot find canvas element");
            Assert.IsTrue(vcElem.Size.Width > 10 && vcElem.Size.Height > 10, "err: canvas size should be atleast (10px,10px) to run test");

            int width = vcElem.Size.Width - 10; // assuming a max border width of 5px on each side
            int height = vcElem.Size.Height - 10;

            VirtualCanvasComponent vc = new VirtualCanvasComponent(Driver);
            vc.SetVisible(new JsVisible(-3194.8898068225376, 401.0288546497742, 0.38537988462392836));
            vc.UpdateViewport();

            Random rnd = new Random();
            Point zoomPt = new Point(rnd.Next(0, width), rnd.Next(0, height));
            zoomPt.Offset(5, 5);

            JsCoordinates p1 = vc.PointScreenToVirtual(new JsCoordinates(zoomPt.X, zoomPt.Y));

            action = new ActionsExtension(Driver);
            action.MoveToElement(vcElem, Convert.ToInt32(zoomPt.X), Convert.ToInt32(zoomPt.Y));
            action.DoubleClick();
            action.Perform();
            vc.WaitAnimation();

            JsCoordinates p2 = vc.PointVirtualToScreen(p1);

            // Assert that the zoom-pt remains fixed after zooming.
            Assert.AreEqual(zoomPt.X, p2.X, 5);
            Assert.AreEqual(zoomPt.Y, p2.Y, 5);
        }