public KnowledgesWindow(BaseControl owner)
            : base(owner)
        {
            Font        = CtlCommon.SmFont;
            Width       = 600;
            Height      = 460;
            WindowStyle = new WindowStyles(WindowStyles.wsModal, WindowStyles.wsKeyPreview, WindowStyles.wsScreenCenter);
            Shifted     = true;
            BackDraw    = false;

            fReady = false;

            fList              = new ListBox(this);
            fList.Bounds       = ExtRect.Create(10, 10, 589, 199);
            fList.OnItemSelect = Knowledges_Select;
            fList.Columns      = 2;
            fList.Visible      = true;
            fList.Items.Sorted = true;

            fText             = new TextBox(this);
            fText.Bounds      = ExtRect.Create(10, 202, 589, 449);
            fText.Visible     = true;
            fText.Links       = true;
            fText.OnLinkClick = OnLinkClick;
            fText.TextColor   = Colors.Gold;
        }
Esempio n. 2
0
        public ExchangeWindow(BaseControl owner)
            : base(owner)
        {
            fPackList             = new ListBox(this);
            fPackList.Bounds      = ExtRect.Create(309, 28, 589, 398);
            fPackList.Visible     = true;
            fPackList.OnDragDrop  = OnPackDragDrop;
            fPackList.OnDragOver  = OnPackDragOver;
            fPackList.OnDragStart = OnPackDragStart;
            fPackList.OnMouseDown = OnListMouseDown;
            fPackList.OnMouseMove = OnListMouseMove;
            fPackList.OnKeyDown   = null;
            fPackList.ShowHints   = true;
            fPackList.Options.Include(LBOptions.lboIcons);

            fColList             = new ListBox(this);
            fColList.Bounds      = ExtRect.Create(10, 28, 290, 398);
            fColList.Visible     = true;
            fColList.OnDragDrop  = OnColDragDrop;
            fColList.OnDragOver  = OnColDragOver;
            fColList.OnDragStart = OnColDragStart;
            fColList.OnMouseDown = OnListMouseDown;
            fColList.OnMouseMove = OnListMouseMove;
            fColList.OnKeyDown   = null;
            fColList.ShowHints   = true;
            fColList.Options.Include(LBOptions.lboIcons);
        }
Esempio n. 3
0
        private void btnAccept_Click(object sender, EventArgs e)
        {
            try
            {
                RectangleF selectRegion = imageView1.SelectionRegion;

                if (!selectRegion.IsEmpty)
                {
                    fMultimediaLink.IsPrimaryCutout      = true;
                    fMultimediaLink.CutoutPosition.Value =
                        ExtRect.Create((int)selectRegion.Left, (int)selectRegion.Top, (int)selectRegion.Right, (int)selectRegion.Bottom);
                }
                else
                {
                    fMultimediaLink.IsPrimaryCutout      = false;
                    fMultimediaLink.CutoutPosition.Value = ExtRect.CreateEmpty();
                }

                PortraitsCache.Instance.RemoveObsolete(fMultimediaLink);

                DialogResult = DialogResult.Ok;
            }
            catch (Exception ex)
            {
                Logger.LogWrite("PortraitSelectDlg.btnAccept_Click(): " + ex.Message);
                DialogResult = DialogResult.None;
            }
        }
Esempio n. 4
0
        public override void Draw(BaseScreen screen)
        {
            if (InvItem == null)
            {
                return;
            }

            string iName = InvItem.Name;
            int    c;

            if (Accepted)
            {
                c = Colors.Green;
            }
            else
            {
                c = Colors.Red;
            }
            int     h = CtlCommon.SmFont.Height + 10;
            int     w = CtlCommon.SmFont.GetTextWidth(iName) + 10;
            ExtRect r = ExtRect.Create(DragPos.X, DragPos.Y, DragPos.X + w, DragPos.Y + h);

            screen.DrawRectangle(r, c, Colors.Yellow);
            CtlCommon.SmFont.Color = BaseScreen.RGB(1, 1, 1);
            screen.DrawText(DragPos.X + 5, DragPos.Y + 5, iName, 0);
        }
Esempio n. 5
0
        private static SearchResult SearchMapLocation(int aX, int aY)
        {
            aX -= 8;
            aY -= 8;

            int num = GlobalVars.nwrGame.LayersCount;

            for (int idx = 0; idx < num; idx++)
            {
                NWLayer    layer      = GlobalVars.nwrGame.GetLayer(idx);
                LayerEntry layerEntry = layer.Entry;

                ExtRect rt = ExtRect.Create(layerEntry.MSX, layerEntry.MSY, layerEntry.MSX + (layerEntry.W << 5), layerEntry.MSY + layerEntry.H * 30);

                if (rt.Contains(aX, aY))
                {
                    int xx = (aX - layerEntry.MSX) / 32;
                    int yy = (aY - layerEntry.MSY) / 30;

                    NWField fld = layer.GetField(xx, yy);
                    if (fld != null)
                    {
                        SearchResult result = new SearchResult();
                        result.LID    = layerEntry.GUID;
                        result.FieldX = xx;
                        result.FieldY = yy;
                        return(result);
                    }
                }
            }

            return(null);
        }
Esempio n. 6
0
        public SelfWindow(BaseControl owner)
            : base(owner)
        {
            Font        = CtlCommon.SmFont;
            Width       = 640;
            Height      = 480;
            WindowStyle = new WindowStyles(WindowStyles.wsScreenCenter, WindowStyles.wsModal, WindowStyles.wsKeyPreview);
            //super.Shifted = true;

            fDiagnosisCtl         = new ListBox(this);
            fDiagnosisCtl.Bounds  = ExtRect.Create(10, 130 + StaticData.RsFontHeight, 212, 469); // 3
            fDiagnosisCtl.Visible = true;

            fSkillsCtl         = new ListBox(this);
            fSkillsCtl.Bounds  = ExtRect.Create(218, 130 + StaticData.RsFontHeight, 421, 469); // 4
            fSkillsCtl.Visible = true;

            fAbilitiesCtl         = new ListBox(this);
            fAbilitiesCtl.Bounds  = ExtRect.Create(427, 130 + StaticData.RsFontHeight, 629, 469); // 5
            fAbilitiesCtl.Visible = true;

            fDiagnosisCtl.ControlStyle.Exclude(ControlStyles.сsOpaque);
            fSkillsCtl.ControlStyle.Exclude(ControlStyles.сsOpaque);
            fAbilitiesCtl.ControlStyle.Exclude(ControlStyles.сsOpaque);
        }
Esempio n. 7
0
        public static ExtRect GetFormRect(Form form)
        {
            if (form == null)
            {
                return(ExtRect.CreateEmpty());
            }

            // You must not expect user has a top window located on the primary
            // monitor. If a top window ain't on the primary monitor,
            // `x` and `y` may be negative numbers.

            // 2016-09-30 Ruslan Garipov <*****@*****.**>
            // GK doesn't check size and position of the `form` here anymore.
            // `GetFormRect` is called **before** closing the application, but
            // there's no guarantees that user won't change a monitor settings
            // after that. GK should restrict position of a top window on the
            // application startup. And I'm still not sured GK should constrain
            // a window size (either top one or child).
            // FIXME: If `Control::Left`, `Control::Top`, `Control::Width` and
            // `Control::Height` return physical values (device depended), code
            // here or code that uses the result of `GetFormRect` must convert
            // them to logical values (device independed) before storing it as
            // the application settings. Had GK been a native Windows
            // application, it had to do that. But since it's a .NET application
            // I don't know is it a true.
            return(ExtRect.Create(form.Left, form.Top, form.Right, form.Bottom));
        }
        public AlchemyWindow(BaseControl owner)
            : base(owner)
        {
            Font        = CtlCommon.SmFont;
            Width       = 600;
            Height      = 460;
            WindowStyle = new WindowStyles(WindowStyles.wsScreenCenter, WindowStyles.wsModal, WindowStyles.wsKeyPreview);
            Shifted     = true;

            fPackList              = new ListBox(this);
            fPackList.Bounds       = ExtRect.Create(309, 28, 589, 398);
            fPackList.OnItemSelect = null;
            fPackList.Visible      = true;
            fPackList.OnDragDrop   = OnPackDragDrop;
            fPackList.OnDragOver   = OnPackDragOver;
            fPackList.OnDragStart  = OnPackDragStart;
            fPackList.OnMouseDown  = OnListMouseDown;
            fPackList.ShowHints    = true;
            fPackList.OnMouseMove  = OnListMouseMove;

            fIngredientsList              = new ListBox(this);
            fIngredientsList.Bounds       = ExtRect.Create(10, 28, 290, 207);
            fIngredientsList.OnItemSelect = null;
            fIngredientsList.Visible      = true;
            fIngredientsList.OnDragDrop   = OnIngrDragDrop;
            fIngredientsList.OnDragOver   = OnIngrDragOver;
            fIngredientsList.OnDragStart  = OnIngrDragStart;
            fIngredientsList.OnMouseDown  = OnListMouseDown;
            fIngredientsList.ShowHints    = true;
            fIngredientsList.OnMouseMove  = OnListMouseMove;

            fResList             = new ListBox(this);
            fResList.Bounds      = ExtRect.Create(10, 225, 290, 398); // 7
            fResList.Visible     = true;
            fResList.ShowHints   = true;
            fResList.OnMouseMove = OnListMouseMove;

            NWButton btnAlchemy = new NWButton(this);

            btnAlchemy.Width        = 90;
            btnAlchemy.Height       = 30;
            btnAlchemy.Left         = fPackList.Left + 20;
            btnAlchemy.Top          = Height - 30 - 20;
            btnAlchemy.OnClick      = OnBtnAlchemy;
            btnAlchemy.OnLangChange = GlobalVars.nwrWin.LangChange;
            btnAlchemy.LangResID    = 131;
            btnAlchemy.ImageFile    = "itf/DlgBtn.tga";

            NWButton btnClose = new NWButton(this);

            btnClose.Width        = 90;
            btnClose.Height       = 30;
            btnClose.Left         = Width - 90 - 20;
            btnClose.Top          = Height - 30 - 20;
            btnClose.OnClick      = OnBtnClose;
            btnClose.OnLangChange = GlobalVars.nwrWin.LangChange;
            btnClose.LangResID    = 8;
            btnClose.ImageFile    = "itf/DlgBtn.tga";
        }
Esempio n. 9
0
        public void Generate(NWField field, int pX, int pY)
        {
            ExtRect area = ExtRect.Create(pX - 7, pY - 7, pX + 7, pY + 7);

            field.Gen_RarefySpace(area, ChangeFCTile, 8, 50);

            field.NormalizeFog();
        }
Esempio n. 10
0
        public void Test_GEDCOMMultimediaLink()
        {
            var iRec = new GDMIndividualRecord(fContext.Tree);

            using (GDMMultimediaLink mmLink = new GDMMultimediaLink()) {
                Assert.IsNotNull(mmLink);
                Assert.IsTrue(mmLink.IsEmpty());

                // extensions
                Assert.IsFalse(mmLink.IsPrimaryCutout);
                mmLink.IsPrimaryCutout = true;
                Assert.IsTrue(mmLink.IsPrimaryCutout);

                mmLink.CutoutPosition.Value = ExtRect.Create(10, 15, 500, 600);
                ExtRect rt = mmLink.CutoutPosition.Value;
                Assert.AreEqual(10, rt.Left);
                Assert.AreEqual(15, rt.Top);
                Assert.AreEqual(500, rt.Right);
                Assert.AreEqual(600, rt.Bottom);

                Assert.AreEqual(10, mmLink.CutoutPosition.X1);
                Assert.AreEqual(15, mmLink.CutoutPosition.Y1);
                Assert.AreEqual(500, mmLink.CutoutPosition.X2);
                Assert.AreEqual(600, mmLink.CutoutPosition.Y2);

                mmLink.CutoutPosition.X1 = 10;
                mmLink.CutoutPosition.Y1 = 10;
                mmLink.CutoutPosition.X2 = 300;
                mmLink.CutoutPosition.Y2 = 400;
                Assert.AreEqual(10, mmLink.CutoutPosition.X1);
                Assert.AreEqual(10, mmLink.CutoutPosition.Y1);
                Assert.AreEqual(300, mmLink.CutoutPosition.X2);
                Assert.AreEqual(400, mmLink.CutoutPosition.Y2);

                mmLink.CutoutPosition.ParseString("11 15 576 611");
                Assert.IsFalse(mmLink.CutoutPosition.IsEmpty());
                Assert.AreEqual("11 15 576 611", mmLink.CutoutPosition.StringValue);

                Assert.Throws(typeof(ArgumentException), () => {
                    mmLink.Assign(null);
                });

                using (var mmRec = new GDMMultimediaRecord(fContext.Tree)) {
                    fContext.Tree.NewXRef(mmRec);
                    Assert.IsNull(mmLink.GetUID(fContext.Tree));

                    mmLink.XRef = mmRec.XRef;

                    Assert.IsNotNull(mmLink.GetUID(fContext.Tree));
                }

                mmLink.CutoutPosition.Clear();
                Assert.IsTrue(mmLink.CutoutPosition.IsEmpty());
                Assert.AreEqual("", mmLink.CutoutPosition.StringValue);
            }
        }
Esempio n. 11
0
        private void ResetAbsClip(BaseScreen screen)
        {
            int al = fAbsLeft;
            int at = fAbsTop;

            screen.SetOffset(al, at);
            ExtRect absRect = ExtRect.Create(al, at, al + fWidth - 1, at + fHeight - 1);

            screen.InitClip(absRect);
        }
        public PartyWindow(BaseControl owner)
            : base(owner)
        {
            Font        = CtlCommon.SmFont;
            Width       = 600;
            Height      = 460;
            WindowStyle = new WindowStyles(WindowStyles.wsModal, WindowStyles.wsKeyPreview);
            Shifted     = true;

            fFormationList              = new ListBox(this);
            fFormationList.Mode         = ListBox.MODE_LIST;
            fFormationList.Bounds       = ExtRect.Create(10, 28, 290, 157);
            fFormationList.OnItemSelect = OnFormationSelect;
            fFormationList.Options      = new LBOptions(LBOptions.lboChecks, LBOptions.lboRadioChecks);

            fMercenariesList              = new ListBox(this);
            fMercenariesList.Mode         = ListBox.MODE_LIST;
            fMercenariesList.Bounds       = ExtRect.Create(10, 179, 290, 398); // 370
            fMercenariesList.OnItemSelect = OnMercenarySelect;

            fMercenaryPropsList        = new ListBox(this);
            fMercenaryPropsList.Mode   = ListBox.MODE_LIST;
            fMercenaryPropsList.Bounds = ExtRect.Create(309, 28, 589, 398);

            NWButton btn = new NWButton(this);

            btn.Width        = 90;
            btn.Height       = 30;
            btn.Left         = Width - 90 - 20;
            btn.Top          = Height - 30 - 20;
            btn.ImageFile    = "itf/DlgBtn.tga";
            btn.OnClick      = OnBtnClose;
            btn.OnLangChange = GlobalVars.nwrWin.LangChange;
            btn.LangResID    = 8;

            btn              = new NWButton(this);
            btn.Width        = 90;
            btn.Height       = 30;
            btn.Left         = 20;
            btn.Top          = Height - 30 - 20;
            btn.ImageFile    = "itf/DlgBtn.tga";
            btn.OnClick      = OnBtnExchange;
            btn.OnLangChange = GlobalVars.nwrWin.LangChange;
            btn.LangResID    = (int)RS.rs_Exchange;

            btn              = new NWButton(this);
            btn.Width        = 90;
            btn.Height       = 30;
            btn.Left         = 20 + 90 + 20;
            btn.Top          = Height - 30 - 20;
            btn.ImageFile    = "itf/DlgBtn.tga";
            btn.OnClick      = OnBtnTeach;
            btn.OnLangChange = GlobalVars.nwrWin.LangChange;
            btn.LangResID    = (int)RS.rs_Teach;
        }
Esempio n. 13
0
        public void InitLayer()
        {
            LayerEntry layer_entry = (LayerEntry)GlobalVars.nwrDB.GetEntry(EntryID);
            string     entry_sign  = layer_entry.Sign;

            try {
                for (int y = 0; y < fH; y++)
                {
                    for (int x = 0; x < fW; x++)
                    {
                        fFields[y, x].Clear();
                        GlobalVars.nwrWin.ProgressStep();
                    }
                }

                if (EntryID == GlobalVars.Layer_Svartalfheim1 || EntryID == GlobalVars.Layer_Svartalfheim2)
                {
                    UniverseBuilder.Build_Dungeon(this, AreaRect);
                }
                else
                {
                    if (EntryID == GlobalVars.Layer_Svartalfheim3)
                    {
                        ExtRect area = ExtRect.Create(0, 0, StaticData.FieldWidth - 1, StaticData.FieldHeight * 3 - 1);
                        UniverseBuilder.Build_Dungeon(this, area);

                        area = ExtRect.Create(StaticData.FieldWidth, StaticData.FieldHeight * 2, StaticData.FieldWidth * 2 - 1, StaticData.FieldHeight * 3 - 1);
                        UniverseBuilder.Build_Dungeon(this, area);

                        area = ExtRect.Create(StaticData.FieldWidth, 0, StaticData.FieldWidth * 3 - 1, StaticData.FieldHeight * 2 - 1);
                        UniverseBuilder.Build_Caves(this, area);
                    }
                }

                for (int y = 0; y < fH; y++)
                {
                    for (int x = 0; x < fW; x++)
                    {
                        fFields[y, x].InitField();
                        GlobalVars.nwrWin.ProgressStep();
                    }
                }

                for (int y = 0; y < fH; y++)
                {
                    for (int x = 0; x < fW; x++)
                    {
                        fFields[y, x].Normalize();
                        GlobalVars.nwrWin.ProgressStep();
                    }
                }
            } catch (Exception ex) {
                Logger.Write("NWLayer.InitLayer(" + entry_sign + "): " + ex.Message);
            }
        }
        protected BaseMainWindow(int width, int height)
            : base(null)
        {
            fPrevPos        = new ExtPoint();
            fFrameCount     = 0;
            fFrameStartTime = 0;
            FPS             = 0f;
            fSystem         = new SDL2System(this, width, height, false);

            Bounds = ExtRect.Create(0, 0, width - 1, height - 1);

            fHintWindow = CreateHintWindow(this);
        }
        public ProgressWindow(BaseControl owner)
            : base(owner)
        {
            Font        = CtlCommon.SmFont;
            Width       = 320;
            Height      = CtlCommon.SmFont.Height + 60;
            WindowStyle = new WindowStyles(WindowStyles.wsScreenCenter, WindowStyles.wsModal, WindowStyles.wsKeyPreview);

            fGaugeRect = ExtRect.Create(20, 20 + CtlCommon.SmFont.Height, 300, 40 + CtlCommon.SmFont.Height);

            fBar        = new ProgressBar(this);
            fBar.Bounds = fGaugeRect;
            StageCount  = 100;
        }
        public virtual void Draw(BaseScreen screen)
        {
            int c;

            if (Accepted)
            {
                c = Colors.Green;
            }
            else
            {
                c = Colors.Red;
            }
            screen.DrawRectangle(ExtRect.Create(DragPos.X, DragPos.Y, DragPos.X + 10, DragPos.Y + 10), c, Colors.Yellow);
        }
        private static ExtRect GetFileOpRect(int i, int op)
        {
            ExtRect result = ExtRect.Empty;

            switch (op)
            {
            case MI_FILEDELETE:
                result = ExtRect.Create(30, 86 + i * 24, 52, 86 + i * 24 + 22);
                break;

            case MI_FILENUM:
                result = ExtRect.Create(56, 86 + i * 24, 78, 86 + i * 24 + 22);
                break;
            }

            return(result);
        }
        public NPCWindow(BaseControl owner)
            : base(owner)
        {
            fServices              = new ListBox(this);
            fServices.Bounds       = ExtRect.Create(429, 50, 589, 140); // w=160, h=90
            fServices.OnItemSelect = OnServiceSelect;

            fConversations              = new ListBox(this);
            fConversations.Bounds       = ExtRect.Create(429, 144, 589, 398);
            fConversations.OnItemSelect = OnConversationSelect;

            fTextBox               = new TextBox(this);
            fTextBox.Bounds        = ExtRect.Create(10, 50, 425, 398);
            fTextBox.Links         = true;
            fTextBox.OnGetVariable = OnGetVar;
            fTextBox.OnLinkClick   = OnLinkClick;
        }
Esempio n. 19
0
        public void CalcBounds(int lines, ChartRenderer renderer)
        {
            try
            {
                InitInfo(lines);
                DefineExpands();

                int maxwid = 0;
                for (int k = 0; k < lines; k++)
                {
                    int wt = renderer.GetTextWidth(Lines[k], fModel.DrawFont);
                    if (maxwid < wt)
                    {
                        maxwid = wt;
                    }
                }

                int pad2side = (fModel.NodePadding * 2);

                fWidth  = pad2side + maxwid;
                fHeight = pad2side + renderer.GetTextHeight(fModel.DrawFont) * lines;

                if (fPortrait != null)
                {
                    ExtRect portRt = ExtRect.Create(0, 0, fHeight - 1, fHeight - 1);
                    portRt.Inflate(3, 3);

                    int   rtW   = portRt.GetWidth();
                    int   rtH   = portRt.GetHeight();
                    int   imgW  = fPortrait.Width;
                    int   imgH  = fPortrait.Height;
                    float ratio = SysUtils.ZoomToFit(imgW, imgH, rtW, rtH);
                    imgW = (int)Math.Round(imgW * ratio);
                    imgH = (int)Math.Round(imgH * ratio);

                    PortraitArea   = ExtRect.CreateBounds(portRt.Left, portRt.Top, imgW, imgH);
                    fPortraitWidth = imgW;

                    fWidth += imgW;
                }
            }
            catch (Exception ex)
            {
                Logger.LogWrite("TreeChartPerson.CalcBounds(): " + ex.Message);
            }
        }
        protected override void DoPaintEvent(BaseScreen screen)
        {
            base.DoPaintEvent(screen);

            ExtRect crt = ClientRect;
            ExtRect cr  = new ExtRect();

            cr.Left   = crt.Left + 10;
            cr.Right  = crt.Right - 10;
            cr.Top    = crt.Top + 10;
            cr.Bottom = cr.Top + 36 - 1;
            CtlCommon.DrawCtlBorder(screen, cr);
            crt = ExtRect.Create(cr.Left + 2, cr.Top + 2, cr.Left + 2 + 32 - 1, cr.Top + 2 + 32 - 1);
            screen.FillRect(crt, Colors.White);
            GlobalVars.nwrWin.Resources.DrawImage(screen, cr.Left + 2, cr.Top + 3, fCollocutor.Entry.ImageIndex, 255);
            screen.DrawText(crt.Right + 10, cr.Top + (36 - screen.GetTextHeight("A")) / 2, fCollocutor.Name, 0);
        }
Esempio n. 21
0
        public static void DrawGauge(BaseScreen screen, ExtRect R, int cur, int max, int cBorder, int cUnready, int cReady)
        {
            try {
                if (cur < 0)
                {
                    cur = 0;
                }
                if (cur > max)
                {
                    if (max > 0)
                    {
                        cur %= max;
                    }
                    else
                    {
                        cur = max;
                    }
                }

                int   L = R.Width;
                float percent;

                if (max == 0)
                {
                    percent = 0f;
                }
                else
                {
                    percent = (((float)cur / (float)max));
                }

                int rw = (int)Math.Round((float)L * percent);

                if (rw > 0)
                {
                    screen.DrawRectangle(ExtRect.Create(R.Left, R.Top, R.Left + rw, R.Bottom), cReady, cBorder);
                }
                if (rw < L)
                {
                    screen.DrawRectangle(ExtRect.Create(R.Left + rw - 1, R.Top, R.Right, R.Bottom), cUnready, cBorder);
                }
            } catch (Exception ex) {
                Logger.Write("ProgressBar.drawGauge(): " + ex.Message);
            }
        }
Esempio n. 22
0
        public void Test_ExtRectF()
        {
            ExtRectF rt = ExtRectF.Create(0, 0, 9, 9);

            Assert.AreEqual(0, rt.Left);
            Assert.AreEqual(0, rt.Top);
            Assert.AreEqual(9, rt.Right);
            Assert.AreEqual(9, rt.Bottom);
            Assert.AreEqual(10, rt.GetHeight());
            Assert.AreEqual(10, rt.GetWidth());

            rt = ExtRectF.CreateBounds(0, 0, 10, 10);

            Assert.AreEqual(0, rt.Left);
            Assert.AreEqual(0, rt.Top);
            Assert.AreEqual(9, rt.Right);
            Assert.AreEqual(9, rt.Bottom);
            Assert.AreEqual(10, rt.GetHeight());
            Assert.AreEqual(10, rt.GetWidth());

            Assert.AreEqual("{X=0,Y=0,Width=10,Height=10}", rt.ToString());

            Assert.IsTrue(rt.Contains(5, 5));

            rt.Inflate(3, -2);
            Assert.AreEqual("{X=3,Y=-2,Width=4,Height=14}", rt.ToString());

            rt.Offset(2, 5);
            Assert.AreEqual("{X=5,Y=3,Width=4,Height=14}", rt.ToString());

            rt = rt.GetOffset(10, 10);
            Assert.AreEqual("{X=15,Y=13,Width=4,Height=14}", rt.ToString());

            Assert.IsTrue(rt.IntersectsWith(ExtRect.Create(16, 14, 20, 20)));

            rt = ExtRectF.CreateEmpty();
            Assert.IsTrue(rt.IsEmpty());

            Assert.IsFalse(rt.Contains(5, 5));

            // implicit
            ExtRectF rtf = ExtRect.CreateBounds(11, 11, 20, 20);

            Assert.AreEqual("{X=11,Y=11,Width=20,Height=20}", rtf.ToString());
        }
Esempio n. 23
0
        protected override void DoPaintEvent(BaseScreen screen)
        {
            ExtRect crt = ClientRect;
            int     L   = crt.Left;
            int     T   = crt.Top;
            int     R   = crt.Right;
            int     B   = crt.Bottom;
            int     h   = 8;

            if (Font != null)
            {
                h += Font.Height;
            }
            int mw = 0;

            ExtRect tsr;
            int     num = PagesCount;

            for (int idx = 0; idx < num; idx++)
            {
                TabSheet page = GetPage(idx);
                int      tw   = screen.GetTextWidth(page.Caption) + 16;
                tsr = ExtRect.Create(L + mw, T + 0, L + mw + tw - 1, T + h - 1);
                mw += tw;

                CtlBorders brd;
                if (idx == TabIndex)
                {
                    brd = new CtlBorders(CtlBorders.cbLeft, CtlBorders.cbTop, CtlBorders.cbRight);
                }
                else
                {
                    brd = new CtlBorders(CtlBorders.cbLeft, CtlBorders.cbTop, CtlBorders.cbRight, CtlBorders.cbBottom);
                }
                CtlCommon.DrawCtlBorder(screen, tsr, brd);
                screen.DrawText(tsr.Left + 8, tsr.Top + 4, page.Caption, 0);
            }

            tsr = ExtRect.Create(L + mw, T + h - 2, R, B);
            screen.DrawFilled(tsr, BaseScreen.FILL_HORZ, 2, 0, 31, 2, mw, T + h - 2, CtlCommon.CtlDecor);
            tsr = ExtRect.Create(L, T + h, R, B);
            CtlCommon.DrawCtlBorder(screen, tsr, new CtlBorders(CtlBorders.cbLeft, CtlBorders.cbRight, CtlBorders.cbBottom));
        }
Esempio n. 24
0
        public TeachWindow(BaseControl owner)
            : base(owner)
        {
            fDisciplinesList         = new ListBox(this);
            fDisciplinesList.Mode    = ListBox.MODE_REPORT;
            fDisciplinesList.Columns = 2;

            fDisciplinesList.Bounds = ExtRect.Create(10, 10, 589, 398);

            fDisciplinesList.ItemHeight = 34;
            fDisciplinesList.IconHeight = 30;
            fDisciplinesList.IconWidth  = 32;
            fDisciplinesList.Options.Include(LBOptions.lboIcons);
            fDisciplinesList.ColumnTitles.Add("", 460);
            fDisciplinesList.ColumnTitles.Add("", 72);
            fDisciplinesList.Visible      = true;
            fDisciplinesList.Columns      = 1;
            fDisciplinesList.OnItemSelect = OnDisciplineSelect;
        }
Esempio n. 25
0
        public RecruitWindow(BaseControl owner)
            : base(owner)
        {
            fMercenariesList        = new ListBox(this);
            fMercenariesList.Mode   = ListBox.MODE_REPORT;
            fMercenariesList.Bounds = ExtRect.Create(10, 10, 589, 398);
            fMercenariesList.ColumnTitles.Add("name", 400);
            fMercenariesList.ColumnTitles.Add("cost", 150);

            fRecruitBtn              = new NWButton(this);
            fRecruitBtn.OnClick      = OnBtnRecruit;
            fRecruitBtn.OnLangChange = GlobalVars.nwrWin.LangChange;
            fRecruitBtn.LangResID    = 49;
            fRecruitBtn.Width        = 90;
            fRecruitBtn.Height       = 30;
            fRecruitBtn.Left         = Width - 210;
            fRecruitBtn.Top          = Height - 30 - 20;
            fRecruitBtn.ImageFile    = "itf/DlgBtn.tga";
        }
Esempio n. 26
0
        public void Test_BorderPainter()
        {
            var chartRenderer = Substitute.For <ChartRenderer>();

            var rect = ExtRect.Create(0, 0, 99, 99);

            BorderPainter.DrawBorder(chartRenderer, rect, GfxBorderStyle.Single);
            BorderPainter.DrawBorder(chartRenderer, rect, GfxBorderStyle.Double);
            BorderPainter.DrawBorder(chartRenderer, rect, GfxBorderStyle.Triple);
            BorderPainter.DrawBorder(chartRenderer, rect, GfxBorderStyle.Sunken3D);
            BorderPainter.DrawBorder(chartRenderer, rect, GfxBorderStyle.Raised3D);
            BorderPainter.DrawBorder(chartRenderer, rect, GfxBorderStyle.SingleSquareCuts);
            BorderPainter.DrawBorder(chartRenderer, rect, GfxBorderStyle.DoubleSquareCuts);
            BorderPainter.DrawBorder(chartRenderer, rect, GfxBorderStyle.SingleRoundCuts);
            BorderPainter.DrawBorder(chartRenderer, rect, GfxBorderStyle.DoubleRoundCuts);
            BorderPainter.DrawBorder(chartRenderer, rect, GfxBorderStyle.SingleBevels);
            BorderPainter.DrawBorder(chartRenderer, rect, GfxBorderStyle.DoubleBevels);
            BorderPainter.DrawBorder(chartRenderer, rect, GfxBorderStyle.CrossCorners);
        }
Esempio n. 27
0
        public ExtRect GetTabRect(int index)
        {
            int h  = Font.Height + 8;
            int mw = 0;

            int num = PagesCount;

            for (int i = 0; i < num; i++)
            {
                int     tw = Font.GetTextWidth(GetPage(i).Caption) + 16;
                ExtRect rt = ExtRect.Create(mw, 0, mw + tw - 1, h - 1);
                mw += tw;

                if (i == index)
                {
                    return(rt);
                }
            }

            return(ExtRect.Empty);
        }
Esempio n. 28
0
 protected override void DoMouseDownEvent(MouseEventArgs eventArgs)
 {
     if (eventArgs.Button == MouseButton.mbLeft) {
         int t = ThumbPos;
         if (fKind == SBK_VERTICAL) {
             ExtRect rBeg = ExtRect.Create(0, 0, Width, ArrowHeight);
             ExtRect rEnd = ExtRect.Create(0, Height - ArrowHeight, Width, Height);
             ExtRect tt = ExtRect.Create(0, t, Width, t + ThumbHeight);
             if (rBeg.Contains(eventArgs.X, eventArgs.Y) && fPos > fMin) {
                 Pos = Pos - 1;
             } else {
                 if (rEnd.Contains(eventArgs.X, eventArgs.Y) && fPos < fMax) {
                     Pos = Pos + 1;
                 } else {
                     if (tt.Contains(eventArgs.X, eventArgs.Y)) {
                         fOldThumbY = eventArgs.Y;
                         fOldThumbPos = t;
                     }
                 }
             }
         } else {
             ExtRect rBeg = ExtRect.Create(0, 0, ArrowWidth, Height);
             ExtRect rEnd = ExtRect.Create(Width - ArrowWidth, 0, Width, Height);
             ExtRect tt = ExtRect.Create(t, 0, t + ThumbWidth, Height);
             if (rBeg.Contains(eventArgs.X, eventArgs.Y) && fPos > fMin) {
                 Pos = Pos - 1;
             } else {
                 if (rEnd.Contains(eventArgs.X, eventArgs.Y) && fPos < fMax) {
                     Pos = Pos + 1;
                 } else {
                     if (tt.Contains(eventArgs.X, eventArgs.Y)) {
                         fOldThumbX = eventArgs.X;
                         fOldThumbPos = t;
                     }
                 }
             }
         }
     }
     base.DoMouseDownEvent(eventArgs);
 }
Esempio n. 29
0
        protected ExtRect GetItemRect(int itemIndex, int subIndex)
        {
            ExtRect r   = base.IntRect;
            int     idx = itemIndex - fTopIndex;
            int     row = idx % fColumnSize;
            int     ax  = r.Left;
            int     ay  = r.Top;

            ExtRect result = ExtRect.Empty;

            if (fMode != MODE_LIST)
            {
                if (fMode == MODE_REPORT)
                {
                    if (subIndex < 0)
                    {
                        LBColumnTitle title = fColumnTitles.GetItem(0);
                        if (title == null)
                        {
                            result = ExtRect.Create(ax, ay + row * ItemHeight, ax + (r.Right - r.Left + 1), ay + (row + 1) * ItemHeight);
                        }
                        else
                        {
                            result = ExtRect.Create(ax, ay + row * ItemHeight, ax + title.Width, ay + (row + 1) * ItemHeight);
                        }
                    }
                    else
                    {
                        int offset = 0;
                        int i      = 0;
                        if (subIndex >= i)
                        {
                            int num = subIndex + 1;
                            do
                            {
                                LBColumnTitle title = fColumnTitles.GetItem(i);
                                offset += title.Width;
                                i++;
                            } while (i != num);
                        }
                        int w;
                        if (subIndex == fItems.GetItem(itemIndex).SubItems.Count - 1)
                        {
                            w = r.Right - r.Left + 1 - offset;
                        }
                        else
                        {
                            LBColumnTitle title = fColumnTitles.GetItem(subIndex + 1);
                            if (title == null)
                            {
                                w = 0;
                            }
                            else
                            {
                                w = title.Width;
                            }
                        }
                        result = ExtRect.Create(ax + offset, ay + row * ItemHeight, ax + offset + w, ay + (row + 1) * ItemHeight);
                    }
                    return(result);
                }

                if (fMode != MODE_ICONS)
                {
                    return(result);
                }
            }
            int col = idx / fColumnSize;

            result = ExtRect.Create(ax + col * fColumnWidth, ay + row * ItemHeight, ax + (col + 1) * fColumnWidth, ay + (row + 1) * ItemHeight);
            return(result);
        }
Esempio n. 30
0
        public void Test_TreeChartModel()
        {
            using (var model = new TreeChartModel())
            {
                Assert.IsNotNull(model);

                model.Base = fBase;
                Assert.AreEqual(fBase, model.Base);

                model.BranchDistance = TreeChartModel.DEF_BRANCH_DISTANCE;
                Assert.AreEqual(TreeChartModel.DEF_BRANCH_DISTANCE, model.BranchDistance);

                model.CertaintyIndex = true;
                Assert.AreEqual(true, model.CertaintyIndex);

                model.DepthLimit = 8;
                Assert.AreEqual(8, model.DepthLimit);

                model.DepthLimit = 8;
                Assert.AreEqual(8, model.DepthLimit);

                Assert.IsNotNull(model.Filter);

                model.HighlightedPerson = null;
                Assert.AreEqual(null, model.HighlightedPerson);

                Assert.AreEqual(0, model.ImageHeight);
                Assert.AreEqual(0, model.ImageWidth);

                model.KinRoot = null;
                Assert.AreEqual(null, model.KinRoot);

                model.Kind = TreeChartKind.ckAncestors;
                Assert.AreEqual(TreeChartKind.ckAncestors, model.Kind);

                model.Margins = 15;
                Assert.AreEqual(15, model.Margins);

                Assert.IsNull(model.Options);

                model.PathDebug = true;
                Assert.AreEqual(true, model.PathDebug);

                Assert.IsNotNull(model.Persons);

                Assert.IsNotNull(model.PreparedIndividuals);

                Assert.IsNull(model.Root);

                model.Scale = 1.3f;
                Assert.AreEqual(1.3f, model.Scale);

                model.Scale = 0.1f;
                Assert.AreEqual(0.5f, model.Scale);

                model.Scale = 1.7f;
                Assert.AreEqual(1.5f, model.Scale);

                Assert.Throws(typeof(ArgumentNullException), () => { model.DoFilter(null); });

                Assert.IsNull(model.FindPersonByCoords(0, 0));

                Assert.AreEqual(ExtRect.Create(0, -18, 15, -2), TreeChartModel.GetExpanderRect(ExtRect.Create(0, 0, 0, 0)));
                Assert.AreEqual(ExtRect.Create(-8, -18, 7, -2), TreeChartModel.GetPersonExpandRect(ExtRect.Create(0, 0, 0, 0)));

                ExtRect rt = model.VisibleArea;
                Assert.IsTrue(rt.IsEmpty());
            }
        }