Ejemplo n.º 1
0
        private void MovePageTo(PageSliderPage page, PageSlider slider, int newIndex)
        {
            IDesignerHost dh = this.GetService(typeof(IDesignerHost)) as IDesignerHost;
            IComponentChangeService cc = this.GetService(typeof(IComponentChangeService)) as IComponentChangeService;
            ISelectionService ss = this.GetService(typeof(ISelectionService)) as ISelectionService;

            DesignerTransaction dt = dh.CreateTransaction("Moving page");
            if (cc != null)
                cc.OnComponentChanging(slider, TypeDescriptor.GetProperties(slider)["Controls"]);
            slider.Controls.SetChildIndex(page, newIndex);
            if (cc != null)
                cc.OnComponentChanged(slider, TypeDescriptor.GetProperties(slider)["Controls"], null, null);
            dt.Commit();
        }
Ejemplo n.º 2
0
 internal static bool SelectNextPage(PageSlider slider)
 {
     if (slider == null)
         return false;
     if (slider.PageCount > 0)
     {
         if (slider.SelectedPageIndex < slider.PageCount - 1)
             slider.SelectedPageIndex++;
         else
             slider.SelectedPageIndex = 0;
         return true;
     }
     return false;
 }
Ejemplo n.º 3
0
 internal static bool SelectPreviousPage(PageSlider slider)
 {
     if (slider == null)
         return false;
     if (slider.PageCount > 0)
     {
         if (slider.SelectedPageIndex > 0)
             slider.SelectedPageIndex--;
         else
             slider.SelectedPageIndex = slider.PageCount - 1;
         return true;
     }
     return false;
 }
Ejemplo n.º 4
0
        internal static PageSliderPage CreatePage(PageSlider parent, IDesignerHost dh, IComponentChangeService cc, ISelectionService ss)
        {
            DesignerTransaction dt = dh.CreateTransaction();
            PageSliderPage page = null;
            try
            {
                page = dh.CreateComponent(typeof(PageSliderPage)) as PageSliderPage;

                if (cc != null)
                    cc.OnComponentChanging(parent, TypeDescriptor.GetProperties(parent)["Controls"]);
                parent.Controls.Add(page);
                if (cc != null)
                    cc.OnComponentChanged(parent, TypeDescriptor.GetProperties(parent)["Controls"], null, null);

                if (ss != null)
                    ss.SetSelectedComponents(new PageSliderPage[] { page }, SelectionTypes.Replace);

                TypeDescriptor.GetProperties(parent)["SelectedPage"].SetValue(parent, page);
            }
            catch
            {
                dt.Cancel();
            }
            finally
            {
                if (!dt.Canceled)
                    dt.Commit();
            }

            return page;
        }