Example #1
0
        private void shape_MouseDown(object sender, MouseButtonEventArgs e)
        {
            selectedRectangle = (Rectangle)e.Source;
            var recname = selectedRectangle.Name;

            var previousLe = selectedLe;

            previousLe.LeRectangle.Opacity = 0.5;
            previousLe.LeRectangle.Fill    = new SolidColorBrush(Colors.White);

            var le = GetSelectedLE(selectedRectangle.Name);

            if (le == null)
            {
                selectedLe = previousLe;
                return;
            }
            ;
            le.LeRectangle.Opacity = 1;
            le.LeRectangle.Fill    = new SolidColorBrush(Colors.Yellow);

            DataContext = le;
        }
Example #2
0
        public Visualiser(ColdPlate coldplate, ObservableCollection <LossElementInstance> lossElementInstances, Collection <LossElement> lossElements)
        {
            this.coldplate            = coldplate;
            this.LossElementInstances = lossElementInstances;
            this.lossElements         = lossElements;


            InitializeComponent();

            int offsetMarginX = 10;
            int offsetMarginY = 10;

            leDetails = new Collection <LossElementDetail>();

            // create coldplates sides Upper plate  / Lower plate
            CreateRectangle(coldplate.Name.Key + " Upper plate", offsetMarginX, offsetMarginY, (int)coldplate.Dimension.X, (int)coldplate.Dimension.Y, Brushes.Gray, Brushes.DarkGray, 1);
            CreateRectangle(coldplate.Name.Key + " Lower plate", offsetMarginX * 2 + (int)coldplate.Dimension.X, offsetMarginY, (int)coldplate.Dimension.X, (int)coldplate.Dimension.Y, Brushes.Gray, Brushes.DarkGray, 1);


            for (int i = 0; i < lossElementInstances.Count(); i++)
            {
                // Create the rectangle
                var nval = lossElementInstances.ElementAt(i).Name;
                var xval = (int)lossElementInstances.ElementAt(i).Position.X;
                var yval = (int)lossElementInstances.ElementAt(i).Position.Y;
                var wval = (int)lossElements.ElementAt(i).Dimension.X;
                var hval = (int)lossElements.ElementAt(i).Dimension.Y;


                var tuple = CreateRectangle(
                    nval,
                    xval
                    ,
                    yval
                    ,
                    wval,
                    hval
                    , Brushes.WhiteSmoke, Brushes.DarkGray, 2);


                var ldetail = new LossElementDetail()
                {
                    LossElementName = nval,
                    LeRectangle     = tuple.Item1,
                    LeTextBloc      = tuple.Item2,
                    X      = xval,
                    Y      = yval,
                    Width  = wval,
                    Height = hval,

                    Type = "le"
                };


                leDetails.Add(ldetail);
                // distinct position for upper and lower plate
            }
            selectedLe = leDetails.First();
            selectedLe.LeRectangle.Opacity = 1;
            selectedLe.LeRectangle.Fill    = new SolidColorBrush(Colors.Yellow);

            previousLe  = selectedLe;
            DataContext = selectedLe;
        }
Example #3
0
 private LossElementDetail GetSelectedLE(string name)
 {
     selectedLe = leDetails.FirstOrDefault(l => l.LossElementName == name.Replace("_", " "));
     return(selectedLe);
 }