public TreeChartBox() { SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.OptimizedDoubleBuffer | ControlStyles.ResizeRedraw, true); UpdateStyles(); BorderStyle = BorderStyle.Fixed3D; DoubleBuffered = true; TabStop = true; BackColor = Color.White; fModel = new TreeChartModel(); fRenderer = null; fSelected = null; fToolTip = new ToolTip(); fTraceSelected = true; fTreeControls = new TreeControlsList <ITreeControl>(); fTreeControls.Add(new TCScaleControl(this)); fTreeControls.Add(new TCGenerationsControl(this, TreeChartKind.ckDescendants)); //fPersonControl = new PersonControl(this); InitTimer(); fTween = new TweenLibrary(); SetLayout(new NativeTreeLayout()); }
public void RequestInfo(TreeChartPerson person) { if (person != null) { BaseController.ViewRecordInfo(fBase, person.Rec); } }
public void GenChart(GEDCOMIndividualRecord iRec, TreeChartKind kind, bool rootCenter) { if (iRec == null) { return; } try { fSelected = null; fModel.GenChart(iRec, kind, rootCenter); RecalcChart(); if (rootCenter) { CenterPerson(fModel.Root, false); } NavAdd(iRec); DoRootChanged(fModel.Root); } catch (Exception ex) { Logger.LogWrite("TreeChartBox.GenChart(): " + ex.Message); } }
public void SelectByRec(GEDCOMIndividualRecord iRec) { if (iRec == null) { return; } int num = fModel.Persons.Count; for (int i = 0; i < num; i++) { TreeChartPerson p = fModel.Persons[i]; if (p.Rec == iRec) { SetSelected(p); if (fTraceSelected) { CenterPerson(p); } return; } } SetSelected(null); }
private void CenterPerson(TreeChartPerson person, bool animation = true) { if (person == null) { return; } Rectangle viewport = this.Viewport; int widthMax = fModel.ImageWidth - viewport.Width; int heightMax = fModel.ImageHeight - viewport.Height; int oldX = viewport.Left; int oldY = viewport.Top; int newX = Math.Min(Math.Max(0, ((person.PtX) - (viewport.Width / 2))), widthMax); int newY = Math.Min(Math.Max(0, ((person.PtY + (person.Height / 2)) - (viewport.Height / 2))), heightMax); if ((oldX == newX) && (oldY == newY)) { return; } if (animation) { fTween.StartTween(SetScroll, oldX, oldY, newX, newY, TweenAnimation.EaseInOutQuad, 20); } else { fTween.StopTween(); UpdateScrollPosition(newX, newY); } }
public bool ParentIsRequired(GDMSex needSex) { TreeChartPerson p = fView.TreeBox.Selected; if (p == null || p.Rec == null) { return(false); } bool familyExist = p.Rec.GetParentsFamily() != null; if (!familyExist) { return(true); } GDMIndividualRecord mother, father; GDMFamilyRecord fam = p.Rec.GetParentsFamily(); if (fam == null) { father = null; mother = null; } else { father = fam.Husband.Individual; mother = fam.Wife.Individual; } bool needParent = (father == null && needSex == GDMSex.svMale) || (mother == null && needSex == GDMSex.svFemale); return(needParent); }
private void ImageTree_InfoRequest(object sender, TreeChartPerson person) { if (person != null && person.Rec != null) { fController.RequestInfo(person); } }
private bool ParentIsRequired(GEDCOMSex needSex) { TreeChartPerson p = fTreeBox.Selected; if (p == null || p.Rec == null) { return(false); } bool familyExist = p.Rec.GetParentsFamily() != null; if (!familyExist) { return(true); } GEDCOMIndividualRecord mother, father; GEDCOMFamilyRecord fam = p.Rec.GetParentsFamily(); if (fam == null) { father = null; mother = null; } else { father = fam.GetHusband(); mother = fam.GetWife(); } bool needParent = (father == null && needSex == GEDCOMSex.svMale) || (mother == null && needSex == GEDCOMSex.svFemale); return(needParent); }
public bool ParentIsRequired(GDMSex needSex) { TreeChartPerson p = fView.TreeBox.Selected; if (p == null || p.Rec == null) { return(false); } bool familyExist = fBase.Context.Tree.GetParentsFamily(p.Rec) != null; if (!familyExist) { return(true); } GDMIndividualRecord father, mother; fBase.Context.Tree.GetParents(p.Rec, out father, out mother); bool needParent = (father == null && needSex == GDMSex.svMale) || (mother == null && needSex == GDMSex.svFemale); return(needParent); }
protected override void OnDoubleClick(EventArgs e) { TreeChartPerson p = fSelected; DoPersonModify(new PersonModifyEventArgs(p)); base.OnDoubleClick(e); }
private void ImageTree_RootChanged(object sender, TreeChartPerson person) { if (person != null && person.Rec != null) { fPerson = person.Rec; UpdateControls(); } }
private MouseAction GetMouseAction(MouseEventArgs e, MouseEvent mouseEvent, out TreeChartPerson person) { var result = MouseAction.maNone; person = null; Point mpt = GetImageRelativeLocation(e.Location); int aX = mpt.X; int aY = mpt.Y; int num = fModel.Persons.Count; for (int i = 0; i < num; i++) { TreeChartPerson p = fModel.Persons[i]; ExtRect persRt = p.Rect; if (persRt.Contains(aX, aY)) { person = p; if (e.Buttons == MouseButtons.Primary && mouseEvent == MouseEvent.meDown) { result = MouseAction.maSelect; break; } else if (e.Buttons == MouseButtons.Alternate && mouseEvent == MouseEvent.meUp) { result = MouseAction.maProperties; break; } else if (mouseEvent == MouseEvent.meMove) { result = MouseAction.maHighlight; break; } } ExtRect expRt = TreeChartModel.GetExpanderRect(persRt); if ((e.Buttons == MouseButtons.Primary && mouseEvent == MouseEvent.meUp) && expRt.Contains(aX, aY)) { person = p; result = MouseAction.maExpand; break; } } if (result == MouseAction.maNone && person == null) { if (e.Buttons == MouseButtons.Alternate && mouseEvent == MouseEvent.meDown) { result = MouseAction.maDrag; } } return(result); }
protected override void OnMouseDoubleClick(MouseEventArgs e) { TreeChartPerson p = fSelected; DoPersonModify(new PersonModifyEventArgs(p)); e.Handled = true; base.OnMouseDoubleClick(e); }
private void DoInfoRequest(TreeChartPerson person) { var eventHandler = (InfoRequestEventHandler)InfoRequest; if (eventHandler != null) { eventHandler(this, person); } }
private void DoRootChanged(TreeChartPerson person) { var eventHandler = (RootChangedEventHandler)Events[EventRootChanged]; if (eventHandler != null) { eventHandler(this, person); } }
private MouseActionRet GetMouseAction(MouseEventArgs e, MouseEvent mouseEvent) { MouseAction action = MouseAction.maNone; TreeChartPerson person = null; ExtPoint offsets = fModel.GetOffsets(); int aX = e.X - offsets.X; int aY = e.Y - offsets.Y; int num = fModel.Persons.Count; for (int i = 0; i < num; i++) { TreeChartPerson p = fModel.Persons[i]; ExtRect persRt = p.Rect; if (persRt.Contains(aX, aY)) { person = p; if (e.Button == MouseButtons.Left && mouseEvent == MouseEvent.meDown) { action = MouseAction.maSelect; break; } else if (e.Button == MouseButtons.Right && mouseEvent == MouseEvent.meUp) { action = MouseAction.maProperties; break; } else if (mouseEvent == MouseEvent.meMove) { action = MouseAction.maHighlight; break; } } ExtRect expRt = TreeChartModel.GetExpanderRect(persRt); if ((e.Button == MouseButtons.Left && mouseEvent == MouseEvent.meUp) && expRt.Contains(aX, aY)) { person = p; action = MouseAction.maExpand; break; } } if (action == MouseAction.maNone && person == null) { if (e.Button == MouseButtons.Right && mouseEvent == MouseEvent.meDown) { action = MouseAction.maDrag; } } return(new MouseActionRet(action, person)); }
private void miDelete_Click(object sender, EventArgs e) { TreeChartPerson p = fTreeBox.Selected; if (p == null || p.Rec == null || p == fTreeBox.Model.Root) { return; } BaseController.DeleteRecord(fBase, p.Rec, true); GenChart(); }
private void ImageTree_RootChanged(object sender, TreeChartPerson person) { if (person == null || person.Rec == null) { return; } fPerson = person.Rec; AppHost.Instance.UpdateControls(false); UpdateNavControls(); }
public void SelectColor() { TreeChartPerson p = fView.TreeBox.Selected; if (p == null || p.Rec == null) { return; } p.UserColor = AppHost.StdDialogs.SelectColor(p.UserColor); fView.TreeBox.Invalidate(); }
public void GoToRecord() { TreeChartPerson p = fView.TreeBox.Selected; if (p == null || p.Rec == null) { return; } fBase.SelectRecordByXRef(p.Rec.XRef, false); fBase.Activate(); }
public void Delete() { TreeChartPerson p = fView.TreeBox.Selected; if (p == null || p.Rec == null || p == fView.TreeBox.Model.Root) { return; } BaseController.DeleteRecord(fBase, p.Rec, true); UpdateChart(); }
private void SetSelected(TreeChartPerson value) { if (fSelected != null) { fSelected.Selected = false; } fSelected = value; if (fSelected != null) { fSelected.Selected = true; } Invalidate(); }
private void miRebuildTree_Click(object sender, EventArgs e) { try { TreeChartPerson p = fTreeBox.Selected; if (p == null || p.Rec == null) { return; } fPerson = p.Rec; GenChart(); } catch (Exception ex) { Logger.LogWrite("TreeChartWin.miRebuildTree_Click(): " + ex.Message); } }
public void ToggleCollapse(TreeChartPerson person) { try { if (person != null) { fModel.ToggleCollapse(person); SaveSelection(); RecalcChart(false); RestoreSelection(); } } catch (Exception ex) { Logger.LogWrite("TreeChartBox.ToggleCollapse(): " + ex.Message); } }
private void ParentAdd(GDMSex needSex) { TreeChartPerson p = fView.TreeBox.Selected; if (p == null || p.Rec == null) { return; } bool needParent = false; bool familyExist = p.Rec.GetParentsFamily() != null; if (familyExist) { GDMIndividualRecord mother, father; GDMFamilyRecord fam = p.Rec.GetParentsFamily(); if (fam == null) { father = null; mother = null; } else { father = fam.Husband.Individual; mother = fam.Wife.Individual; } needParent = (father == null && needSex == GDMSex.svMale) || (mother == null && needSex == GDMSex.svFemale); } if (!familyExist || needParent) { GDMIndividualRecord child = p.Rec; GDMFamilyRecord fam = (familyExist) ? p.Rec.GetParentsFamily() : fBase.Context.Tree.CreateFamily(); GDMIndividualRecord parent = fBase.Context.SelectPerson(null, TargetMode.tmParent, needSex); if (parent != null) { fam.AddSpouse(parent); if (!familyExist) { fam.AddChild(child); } UpdateChart(); } } }
private void SelectBy(TreeChartPerson person, bool needCenter) { if (person == null) { return; } SetSelected(person); //if (fTraceKinships && fOptions.Kinship) RebuildKinships(true); if (needCenter && fTraceSelected) { CenterPerson(person); } }
private void miEdit_Click(object sender, EventArgs e) { TreeChartPerson p = fTreeBox.Selected; if (p == null || p.Rec == null) { return; } GEDCOMIndividualRecord iRec = p.Rec; if (BaseController.ModifyIndividual(fBase, ref iRec, null, TargetMode.tmNone, GEDCOMSex.svNone)) { UpdateChart(); } }
public void Edit() { TreeChartPerson p = fView.TreeBox.Selected; if (p == null || p.Rec == null) { return; } GDMIndividualRecord iRec = p.Rec; if (BaseController.ModifyIndividual(fBase, ref iRec, null, TargetMode.tmNone, GDMSex.svUnknown)) { UpdateChart(); } }
public TreeChartBox() : base() { BackgroundColor = Colors.White; fModel = new TreeChartModel(); fRenderer = null; fSelected = null; fTraceSelected = true; fTreeControls = new TreeControlsList <ITreeControl>(); fTreeControls.Add(new TCScaleControl(this)); fTreeControls.Add(new TCGenerationsControl(this)); //fPersonControl = new PersonControl(this); InitTimer(); fTween = new TweenLibrary(); }
public void RequestInfo(TreeChartPerson person) { if (person == null) { return; } if (person.Rec != null) { GDMIndividualRecord iRec = person.Rec; using (var dlg = AppHost.ResolveDialog <IRecordInfoDlg>(fBase)) { dlg.Record = iRec; AppHost.Instance.ShowModalX(dlg, false); } } }