Exemplo n.º 1
0
 public IFormItem GetFormItem(IToolboxItem toolboxItem)
 {
     return(toolboxItem switch
     {
         MeasurementToolboxItem measurement => CreateMeasurementFormItem(),
         _ => null
     });
Exemplo n.º 2
0
 public static void CallUseToolBoxItem(IToolboxItem item)
 {
     if (UseToolBoxItem != null)
     {
         UseToolBoxItem(item);
     }
 }
        /// <summary>
        /// Determines whether a tool (a.k.a toolbox item) should be visible in the <see cref="ZoneEditor"/>.
        /// </summary>
        /// <param name="tool">The tool in question.</param>
        /// <returns><c>true</c> if it should be visible.</returns>
        public bool IsToolVisible(IToolboxItem tool)
        {
            if (tool == null)
                return true;

            var currentFramework = this.frameworkExtractor();

            // Everything works for Hybrid mode. No need to reflect on the specific item.
            if (currentFramework == PageTemplateFramework.Hybrid)
                return true;

            if (!tool.ControlType.IsNullOrEmpty())
            {
                var controlType = TypeResolutionService.ResolveType(tool.ControlType, throwOnError: false);
                if (controlType == null)
                    return true;

                var isLayoutControl = typeof(LayoutControl).IsAssignableFrom(controlType);
                var isGridControl = typeof(GridControl).IsAssignableFrom(controlType);

                if (currentFramework == PageTemplateFramework.WebForms && isGridControl)
                    return false;

                if (currentFramework == PageTemplateFramework.Mvc && isLayoutControl && !isGridControl)
                    return false;
            }

            return true;
        }
Exemplo n.º 4
0
 private bool CheckItemUp(IToolboxItem item)
 {
     if (item.Parent.Items.IndexOf(item) <= 0)
     {
         return(false);
     }
     return(true);
 }
Exemplo n.º 5
0
 private bool CheckItemDown(IToolboxItem item)
 {
     if (item.Parent.Items.IndexOf(item) >= item.Parent.Items.Count - 1)
     {
         return(false);
     }
     return(true);
 }
Exemplo n.º 6
0
        private void CreateFormItem(IToolboxItem toolboxItem)
        {
            IFormItem formItem = m_formItemFactory.GetFormItem(toolboxItem);

            FormItems.Add(formItem);

            SelectFormItem(formItem);
        }
Exemplo n.º 7
0
 private void Border_Drop(object sender, DragEventArgs e)
 {
     if (e.Data.GetDataPresent(typeof(IToolboxItem)))
     {
         IToolboxItem toolBoxItem = (IToolboxItem)e.Data.GetData(typeof(IToolboxItem));
         m_formSurfaceViewModel.CreateFormItemCommand.Execute(toolBoxItem);
     }
 }
Exemplo n.º 8
0
        private void MoveItemUp(IToolboxItem item)
        {
            if (item.Parent == null)
            {
                return;
            }
            var parent = item.Parent;
            var index  = item.Parent.Items.IndexOf(item);

            parent.Items.RemoveAt(index);
            parent.Items.Insert(index - 1, item);
            _toolbox.SelectedNode = item;
        }
Exemplo n.º 9
0
        /// <inheritdoc />
        public virtual bool IsToolVisible(IToolboxItem tool)
        {
            var isFeatherDeactivated = SystemManager.GetModule("Feather") == null;

            if (isFeatherDeactivated)
            {
                var isFeatherWidget = tool.ControllerType.StartsWith("Telerik.Sitefinity.Frontend", StringComparison.Ordinal);
                if (isFeatherWidget)
                {
                    return(false);
                }
            }

            return(true);
        }
Exemplo n.º 10
0
        void HToolbox_UseToolBoxItem(IToolboxItem obj)
        {
            if (!EnabledDesign)
            {
                return;
            }
            if (!IsContentVisible)
            {
                return;
            }
            var wt = obj as WidgetToolboxItem;

            if (wt == null)
            {
                return;
            }
            AddWidget(wt.CreateWidget());
        }
Exemplo n.º 11
0
        private void AddItem(IToolboxItem src)
        {
            string tabName = Texts.Get(src.Category);
            var    item    = new ToolboxItem(src.ItemType);

            item.Bitmap      = src.Image;
            item.DisplayName = Texts.Get(src.DisplayName);
            item.Description = Texts.Get(src.Description);
            Toolbox.Tab tab = hostToolbox1.Categories[tabName];
            if (tab == null)
            {
                tab        = new Toolbox.Tab(tabName);
                tab.Opened = true;
                hostToolbox1.Categories.Add(tab);
            }
            var hostitem = new HostToolbox.HostItem(item);

            hostitem.Tag = src;
            tab.Items.Add(hostitem);
        }
Exemplo n.º 12
0
        /// <summary>
        /// Determines whether a tool (a.k.a toolbox item) should be visible in the <see cref="ZoneEditor"/>.
        /// </summary>
        /// <param name="tool">The tool in question.</param>
        /// <returns><c>true</c> if it should be visible.</returns>
        public bool IsToolVisible(IToolboxItem tool)
        {
            if (tool == null)
            {
                return(true);
            }

            var currentFramework = this.frameworkExtractor();

            // Everything works for Hybrid mode. No need to reflect on the specific item.
            if (currentFramework == PageTemplateFramework.Hybrid)
            {
                return(true);
            }

            if (!tool.ControlType.IsNullOrEmpty())
            {
                var controlType = TypeResolutionService.ResolveType(tool.ControlType, throwOnError: false);
                if (controlType == null)
                {
                    return(true);
                }

                var isLayoutControl = typeof(LayoutControl).IsAssignableFrom(controlType);
                var isGridControl   = typeof(GridControl).IsAssignableFrom(controlType);

                if (currentFramework == PageTemplateFramework.WebForms && isGridControl)
                {
                    return(false);
                }

                if (currentFramework == PageTemplateFramework.Mvc && isLayoutControl && !isGridControl)
                {
                    return(false);
                }
            }

            return(true);
        }
Exemplo n.º 13
0
 public static MessageBoxResult AskUserForRemove(IToolboxItem item)
 {
     IoC.Get <IMafUIShell>().GetAppName(out var name);
     return(MessageBox.Show(string.Format(ToolboxResources.ToolboxItemDeleteMessage, item.Name), name,
                            MessageBoxButton.OKCancel, MessageBoxImage.Warning, MessageBoxResult.OK));
 }