Exemplo n.º 1
0
        public override bool Accept()
        {
            try {
                ExtRect selectRegion = fView.ImageCtl.SelectionRegion;

                if (!selectRegion.IsEmpty())
                {
                    fMultimediaLink.IsPrimaryCutout      = true;
                    fMultimediaLink.CutoutPosition.Value = selectRegion;
                }
                else
                {
                    fMultimediaLink.IsPrimaryCutout      = false;
                    fMultimediaLink.CutoutPosition.Value = ExtRect.CreateEmpty();
                }

                var uid = fMultimediaLink.GetUID(fBase.Context.Tree);
                PortraitsCache.Instance.RemoveObsolete(uid);

                return(true);
            } catch (Exception ex) {
                Logger.WriteError("PortraitSelectDlgController.Accept()", ex);
                return(false);
            }
        }
Exemplo n.º 2
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));
        }
Exemplo n.º 3
0
        public string GetUID()
        {
            string result = null;

            try {
                if (Value != null)
                {
                    ExtRect cutoutArea;
                    if (IsPrimaryCutout)
                    {
                        cutoutArea = CutoutPosition.Value;
                    }
                    else
                    {
                        cutoutArea = ExtRect.CreateEmpty();
                    }

                    GDMMultimediaRecord mmRec = (GDMMultimediaRecord)Value;
                    result = mmRec.UID + "-" + GKUtils.GetRectUID(cutoutArea.Left, cutoutArea.Top, cutoutArea.Right, cutoutArea.Bottom);
                }
            } catch (Exception ex) {
                Logger.WriteError("GDMMultimediaLink.GetUID()", ex);
                result = null;
            }
            return(result);
        }
Exemplo n.º 4
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;
            }
        }
Exemplo n.º 5
0
        public string GetUID(GDMTree tree)
        {
            string result = null;

            try {
                var mmRec = tree.GetPtrValue <GDMMultimediaRecord>(this);
                if (mmRec != null)
                {
                    ExtRect cutoutArea = IsPrimaryCutout ? CutoutPosition.Value : ExtRect.CreateEmpty();
                    result = mmRec.UID + "-" + GKUtils.GetRectUID(cutoutArea.Left, cutoutArea.Top, cutoutArea.Right, cutoutArea.Bottom);
                }
            } catch (Exception ex) {
                Logger.WriteError("GDMMultimediaLink.GetUID()", ex);
                result = null;
            }
            return(result);
        }
Exemplo n.º 6
0
        public void Test_ExtRect()
        {
            ExtRect rt = ExtRect.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 = ExtRect.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 = ExtRect.CreateEmpty();
            Assert.IsTrue(rt.IsEmpty());

            Assert.IsFalse(rt.Contains(5, 5));
        }
        public override bool Accept()
        {
            try {
                ExtRect selectRegion = fView.ImageCtl.SelectionRegion;

                if (!selectRegion.IsEmpty())
                {
                    fMultimediaLink.IsPrimaryCutout      = true;
                    fMultimediaLink.CutoutPosition.Value = selectRegion;
                }
                else
                {
                    fMultimediaLink.IsPrimaryCutout      = false;
                    fMultimediaLink.CutoutPosition.Value = ExtRect.CreateEmpty();
                }

                PortraitsCache.Instance.RemoveObsolete(fMultimediaLink);

                return(true);
            } catch (Exception ex) {
                Logger.LogWrite("PortraitSelectDlgController.Accept(): " + ex.Message);
                return(false);
            }
        }
Exemplo n.º 8
0
        public void Test_Options()
        {
            using (IniFile iniFile = new IniFile()) {
                GlobalOptions globalOptions = GlobalOptions.Instance;
                Assert.IsNotNull(globalOptions);

                Assert.IsNotNull(globalOptions.TreeChartOptions);
                Assert.IsNotNull(globalOptions.CircleChartOptions);

                /*globalOptions.DefCharacterSet = GEDCOMCharacterSet.csUNICODE;
                 * Assert.AreEqual(GEDCOMCharacterSet.csUNICODE, globalOptions.DefCharacterSet);*/
                Assert.AreEqual(GEDCOMCharacterSet.csUTF8, globalOptions.DefCharacterSet);

                globalOptions.DefDateFormat = DateFormat.dfDD_MM_YYYY;
                Assert.AreEqual(DateFormat.dfDD_MM_YYYY, globalOptions.DefDateFormat);

                globalOptions.ShowDatesSign = true;
                Assert.AreEqual(true, globalOptions.ShowDatesSign);

                globalOptions.DefNameFormat = NameFormat.nfF_N_P;
                Assert.AreEqual(NameFormat.nfF_N_P, globalOptions.DefNameFormat);

                Assert.IsNotNull(globalOptions.EventFilters);

                globalOptions.InterfaceLang = 1000;
                Assert.AreEqual(1000, globalOptions.InterfaceLang);

                globalOptions.LastDir = "c:\\";
                Assert.AreEqual("c:\\", globalOptions.LastDir);

                Assert.IsNotNull(globalOptions.MRUFiles);

                globalOptions.MWinRect = ExtRect.CreateEmpty();
                Assert.IsTrue(globalOptions.MWinRect.IsEmpty());

                globalOptions.MWinState = WindowState.Maximized;
                Assert.AreEqual(WindowState.Maximized, globalOptions.MWinState);

                Assert.IsNotNull(globalOptions.NameFilters);

                Assert.IsNotNull(globalOptions.PedigreeOptions);

                globalOptions.PlacesWithAddress = true;
                Assert.AreEqual(true, globalOptions.PlacesWithAddress);

                Assert.IsNotNull(globalOptions.Proxy);

                Assert.IsNotNull(globalOptions.Relations);

                Assert.IsNotNull(globalOptions.ResidenceFilters);

                globalOptions.FileBackup = FileBackup.fbOnlyPrev;
                Assert.AreEqual(FileBackup.fbOnlyPrev, globalOptions.FileBackup);

                globalOptions.ShowTips = true;
                Assert.AreEqual(true, globalOptions.ShowTips);

                globalOptions.ListHighlightUnmarriedPersons = true;
                Assert.AreEqual(true, globalOptions.ListHighlightUnmarriedPersons);

                globalOptions.ListHighlightUnparentedPersons = true;
                Assert.AreEqual(true, globalOptions.ListHighlightUnparentedPersons);

                Assert.IsNotNull(globalOptions.IndividualListColumns);

                globalOptions.ShowDatesCalendar = true;
                Assert.AreEqual(true, globalOptions.ShowDatesCalendar);

                globalOptions.Autosave = true;
                Assert.AreEqual(true, globalOptions.Autosave);

                globalOptions.AutosaveInterval = 10;
                Assert.AreEqual(10, globalOptions.AutosaveInterval);

                globalOptions.ExtendedNames = true;
                Assert.AreEqual(true, globalOptions.ExtendedNames);

                globalOptions.UseExtendedNotes = true;
                Assert.AreEqual(true, globalOptions.UseExtendedNotes);
                globalOptions.UseExtendedNotes = false;

                globalOptions.WomanSurnameFormat = WomanSurnameFormat.wsfMaiden;
                Assert.AreEqual(WomanSurnameFormat.wsfMaiden, globalOptions.WomanSurnameFormat);

                globalOptions.AddLastBase("sample.ged");
                Assert.AreEqual(1, globalOptions.GetLastBasesCount());
                Assert.AreEqual("sample.ged", globalOptions.GetLastBase(0));
                globalOptions.ClearLastBases();

                Assert.IsNotNull(globalOptions.Languages);

                globalOptions.FindLanguages();


                globalOptions.SaveToFile(iniFile);
                globalOptions.LoadFromFile(iniFile);

                IniFile ini = null;
                Assert.Throws(typeof(ArgumentNullException), () => { globalOptions.SaveToFile(ini); });
                Assert.Throws(typeof(ArgumentNullException), () => { globalOptions.LoadFromFile(ini); });

                string iniFN = null;
                Assert.Throws(typeof(ArgumentNullException), () => { globalOptions.SaveToFile(iniFN); });
                Assert.Throws(typeof(ArgumentNullException), () => { globalOptions.LoadFromFile(iniFN); });

                iniFN = TestUtils.GetTempFilePath("options.ini");
                globalOptions.SaveToFile(iniFN);
                globalOptions.LoadFromFile(iniFN);


                MRUFile mruFile = new MRUFile();
                Assert.IsNotNull(mruFile);

                mruFile = new MRUFile("test.ged");
                Assert.IsNotNull(mruFile);
                Assert.AreEqual(-1, globalOptions.MRUFiles_IndexOf("test.ged"));
                globalOptions.MRUFiles.Add(mruFile);
                Assert.AreEqual(0, globalOptions.MRUFiles_IndexOf("test.ged"));

                mruFile.SaveToFile(iniFile, "xxx");
                mruFile.LoadFromFile(iniFile, "xxx");
                MRUFile.DeleteKeys(iniFile, "xxx");
                Assert.Throws(typeof(ArgumentNullException), () => { mruFile.SaveToFile(null, "xxx"); });
                Assert.Throws(typeof(ArgumentNullException), () => { mruFile.LoadFromFile(null, "xxx"); });
                Assert.Throws(typeof(ArgumentNullException), () => { MRUFile.DeleteKeys(null, "xxx"); });
            }
        }