void ReleaseDesignerOutlets()
        {
            if (ArrowLabel != null)
            {
                ArrowLabel.Dispose();
                ArrowLabel = null;
            }

            if (ProjectIcon != null)
            {
                ProjectIcon.Dispose();
                ProjectIcon = null;
            }

            if (TitleLabel != null)
            {
                TitleLabel.Dispose();
                TitleLabel = null;
            }
        }
Example #2
0
        public override void CheckOrder(IDesktop desktop)
        {
            Control desk = desktop as Control;

            foreach (Control c in desk.Controls)
            {
                if (!(c is ArrowLabel))
                {
                    continue;
                }
                ArrowLabel     l = c as ArrowLabel;
                ICategoryArrow a = l.Arrow;
                if (!(a is DataLink))
                {
                    continue;
                }
                if (l.Source.Root.Ord < l.Target.Root.Ord)
                {
                    a.Throw(new Exception(DataLink.SetProviderBefore));
                }
            }
        }
Example #3
0
        public override bool Initialize(IBioDataLoader data)
        {
            Dictionary <int, SSBasePairViewModel> basePairVMs = new Dictionary <int, SSBasePairViewModel>();

            var sdloader = data as IBioDataLoader <IStructureModelBioEntity>;

            if (sdloader != null)
            {
                var basePairs = from bp in sdloader.Entities.OfType <XRNABasePair>()
                                select bp;

                foreach (XRNABasePair bp in basePairs)
                {
                    SSBasePairViewModel bpvm = BuildBasePairViewModel(bp);
                    ModelElements.Add(bpvm);
                    ModelElements.Add(bpvm.FivePrimeNucleotide);
                    ModelElements.Add(bpvm.ThreePrimeNucleotide);
                    basePairVMs.Add(bpvm.FivePrimeNucleotide.Index, bpvm);
                }

                var unpairedNt = from nt in sdloader.Entities.OfType <XRNANucleotide>()
                                 select nt;
                foreach (XRNANucleotide nt in unpairedNt)
                {
                    SSSymbolViewModel svm = BuildSymbolViewModel(nt);
                    ModelElements.Add(svm);
                }

                var allEntities = from entity in sdloader.Entities
                                  select entity;

                foreach (IStructureModelBioEntity entity in allEntities)
                {
                    if (entity is XRNABasePairConnector)
                    {
                        XRNABasePairConnector lc = (XRNABasePairConnector)entity;
                        ModelElements.Add(new SSBasePairLineConnectorViewModel(basePairVMs[lc.BasePair.FivePrimeIndex + 1])
                        {
                            Color     = lc.Color,
                            Thickness = lc.Thickness,
                            Visible   = lc.Visible
                        });
                    }
                    else if (entity is XRNABasePairConnectorCircle)
                    {
                        XRNABasePairConnectorCircle cc = (XRNABasePairConnectorCircle)entity;
                        ModelElements.Add(new SSBasePairCircleConnectorViewModel(basePairVMs[cc.BasePair.FivePrimeIndex + 1])
                        {
                            Color     = cc.Color,
                            Radius    = cc.Radius,
                            Filled    = cc.Filled,
                            Thickness = cc.Thickness
                        });
                    }
                    else if (entity is TextLabel)
                    {
                        TextLabel lc = (TextLabel)entity;
                        ModelElements.Add(new SSTextLabelViewModel(lc.Start.X, lc.Start.Y, lc.Text, new FontFamily(lc.FontFace), (FontStyle)_fscvtr.ConvertFrom(lc.FontStyle),
                                                                   (FontWeight)_fwcvtr.ConvertFrom(lc.FontWeight), lc.FontSize, (Brush)_colorCvtr.ConvertFrom(lc.Color)));
                    }
                    else if (entity is LineLabel)
                    {
                        LineLabel ll = (LineLabel)entity;
                        ModelElements.Add(new SSLineLabelViewModel()
                        {
                            X         = ll.Start.X,
                            Y         = ll.Start.Y,
                            X1        = ll.End.X - ll.Start.X,
                            Y1        = ll.End.Y - ll.Start.Y,
                            Color     = (Brush)_colorCvtr.ConvertFrom(ll.Color),
                            Thickness = ll.LineWeight
                        });
                    }
                    else if (entity is ParallelogramLabel)
                    {
                        ParallelogramLabel            lc = (ParallelogramLabel)entity;
                        SSParallelogramLabelViewModel vm = new SSParallelogramLabelViewModel()
                        {
                            CenterX            = lc.Center.X,
                            CenterY            = lc.Center.Y,
                            Side1Length        = lc.Side1Length,
                            RotationAngle      = lc.Side1Angle,
                            Side2Length        = lc.Side2Length,
                            ParallelogramAngle = lc.Side2Angle,
                            Color      = (Brush)_colorCvtr.ConvertFrom(lc.Color),
                            LineWeight = lc.LineWeight
                        };
                        vm.ComputeParallelogram();
                        ModelElements.Add(vm);
                    }
                    else if (entity is ArcLabel)
                    {
                        ArcLabel            ac = (ArcLabel)entity;
                        SSArcLabelViewModel vm = new SSArcLabelViewModel()
                        {
                            CenterX    = ac.Center.X,
                            CenterY    = ac.Center.Y,
                            Color      = (Brush)_colorCvtr.ConvertFrom(ac.Color),
                            LineWeight = ac.LineWeight,
                            Radius     = ac.Radius,
                            Angle1     = ac.Angle1,
                            Angle2     = ac.Angle2,
                        };
                        vm.ComputeArc();
                        ModelElements.Add(vm);
                    }
                    else if (entity is ArrowLabel)
                    {
                        ArrowLabel            al = (ArrowLabel)entity;
                        SSArrowLabelViewModel vm = new SSArrowLabelViewModel()
                        {
                            ArrowTipX     = al.ArrowTip.X,
                            ArrowTipY     = al.ArrowTip.Y,
                            LeftTipX      = al.LeftTip.X,
                            LeftTipY      = al.LeftTip.Y,
                            Color         = (Brush)_colorCvtr.ConvertFrom(al.Color),
                            LineWeight    = al.LineWeight,
                            TailLength    = al.TailLength,
                            RotationAngle = al.Angle
                        };
                        vm.ComputeArrow();
                        ModelElements.Add(vm);
                    }
                }

                MeasureAndArrangeCanvas();

                return(base.Initialize(data));
            }
            return(false);
        }