예제 #1
0
        public void AddCustomControl(Func<double> getTop, Func<double> getLeft, UIElement control)
        {
            if (_customControls.Any(it => it.Control == control))
                throw new Exception("The custom control is already placed on the surface.");

            var customControlInfo = new CustomControlInfo(control, getTop, getLeft);
            _customControlSurface.AddControl(customControlInfo);
            _customControls.Add(customControlInfo);
        }
        public void AddControl(CustomControlInfo customControlInfo)
        {
            if (_customControlInfos.Any(it => it.Control == customControlInfo.Control))
                throw new Exception("Custom Control is already added.");

            UpdatePosition(customControlInfo);
            customControlInfo.RefreshRequest = () => UpdatePosition(customControlInfo);
            canvas.Children.Add(customControlInfo.Control);
            _customControlInfos.Add(customControlInfo);
        }
 private static void UpdatePosition(CustomControlInfo customControlInfo)
 {
     Canvas.SetTop(customControlInfo.Control, customControlInfo.Top);
     Canvas.SetLeft(customControlInfo.Control, customControlInfo.Left);
 }