public static XmlDocument Transform(ShellDrillDownMenuItem topMenuItem)
        {
            XmlDocument document = new XmlDocument();

            document.AppendChild(AddChild(document, topMenuItem));
            return(document);
        }
Beispiel #2
0
        public override object Clone()
        {
            ShellDrillDownMenuItem clone = new ShellDrillDownMenuItem
            {
                Caption      = this.Caption,
                Id           = this.Id,
                IsBackItem   = this.IsBackItem,
                IsEnabled    = this.IsEnabled,
                IsFolder     = this.IsFolder,
                IsReadOnly   = this.IsReadOnly,
                AssemblyFile = this.AssemblyFile,
                IsAuthorized = this.IsAuthorized,
                Operation    = this.Operation,
                Parameters   = this.Parameters,
                EventTopic   = this.EventTopic,
            };


            BindingOperations.ClearAllBindings(clone);

            ObservableCollection <DrillDownMenuItem> children = new ObservableCollection <DrillDownMenuItem>();

            foreach (DrillDownMenuItem child in this.Children)
            {
                DrillDownMenuItem childClone = child.Clone() as DrillDownMenuItem;
                childClone.Parent = clone;
                children.Add(childClone);
            }

            clone.Children = children;

            return(clone);
        }
        public static ShellDrillDownMenuItem Transform(XmlDocument document)
        {
            XmlNode xmlDocumentRoot      = document.SelectSingleNode("/folder");
            ShellDrillDownMenuItem entry = AddMenuItem(xmlDocumentRoot, null);

            return(entry);
        }
        private static XmlElement AddChild(XmlDocument document, DrillDownMenuItem menuItem)
        {
            string name = menuItem.IsFolder ? "folder" : "item";

            XmlElement node = document.CreateElement(name);

            XmlAttribute a = document.CreateAttribute("caption");

            a.Value = menuItem.Caption;
            node.Attributes.Append(a);

            if (!string.IsNullOrEmpty(menuItem.Id))
            {
                a       = document.CreateAttribute("id");
                a.Value = menuItem.Id;
                node.Attributes.Append(a);
            }

            if ((!menuItem.IsFolder) && (menuItem is ShellDrillDownMenuItem))
            {
                ShellDrillDownMenuItem shellMenuItem = (menuItem as ShellDrillDownMenuItem);

                a       = document.CreateAttribute("operation");
                a.Value = shellMenuItem.Operation;
                node.Attributes.Append(a);

                a       = document.CreateAttribute("assemblyFile");
                a.Value = shellMenuItem.AssemblyFile;
                node.Attributes.Append(a);

                a       = document.CreateAttribute("topicIdentity");
                a.Value = shellMenuItem.EventTopic;
                node.Attributes.Append(a);

                a       = document.CreateAttribute("parameters");
                a.Value = shellMenuItem.Parameters;
                node.Attributes.Append(a);
            }

            if (menuItem.IsFolder)
            {
                foreach (DrillDownMenuItem child in menuItem.Children)
                {
                    if (!child.IsBackItem)
                    {
                        node.AppendChild(AddChild(document, child));
                    }
                }
            }

            return(node);
        }
        private static void AddBackMenuItem(ShellDrillDownMenuItem parentMenuItem)
        {
            ShellDrillDownMenuItem menuItem = new ShellDrillDownMenuItem();

            menuItem.Parent = parentMenuItem;

            menuItem.IsEnabled    = true;
            menuItem.IsAuthorized = true;
            menuItem.IsFolder     = false;
            menuItem.IsBackItem   = true;

            menuItem.Caption = parentMenuItem.Parent.Caption;

            parentMenuItem.Children.Add(menuItem);
        }
Beispiel #6
0
        public void ActionExecutedEventHandler(object sender, DataEventArgs <ShellDrillDownMenuItem> e)
        {
            ShellDrillDownMenuItem action = e.Data;

            if (!action.IsAuthorized)
            {
                IMessageBoxView messageBoxView = WorkItem.SmartParts.AddNew <MessageBoxView>();
                messageBoxView.Show(StringResources.Authorization_NotAuhtorized
                                    , StringResources.Authorization_Message
                                    , null
                                    , Infrastructure.MessageBoxButton.Ok
                                    , Infrastructure.MessageBoxImage.Warning);

                return;
            }
            else if (!action.IsEnabled)
            {
                return;
            }

            try
            {
                _shellView.ShowProgress();

                try
                {
                    IActionCatalogService actionCatalog = action.WorkItem.Services.Get <IActionCatalogService>();
                    actionCatalog.Execute(action.Id, action.WorkItem, this, action.Parameters);
                }
                finally
                {
                    _shellView.HideProgress();
                }
            }
            catch (Exception ex)
            {
                IMessageBoxView messageBoxView = WorkItem.SmartParts.AddNew <MessageBoxView>();
                messageBoxView.Show(StringResources.ActionException_Text, ex.Message, ex.ToString(), Infrastructure.MessageBoxButton.Ok, Infrastructure.MessageBoxImage.Error);
            }
        }
Beispiel #7
0
 public StartMenuItemExecutedEventArgs(ShellDrillDownMenuItem menuItem, IShellModule module, StartOption startOption)
 {
     MenuItem    = menuItem;
     Module      = module;
     StartOption = startOption;
 }
        private static ShellDrillDownMenuItem AddMenuItem(XmlNode currentXmlNode, ShellDrillDownMenuItem parentMenuItem)
        {
            ShellDrillDownMenuItem menuItem = new ShellDrillDownMenuItem();

            menuItem.Parent = parentMenuItem;

            menuItem.IsEnabled    = true;
            menuItem.IsAuthorized = true;
            menuItem.IsFolder     = (currentXmlNode.Name == "folder");

            foreach (XmlAttribute attribute in currentXmlNode.Attributes)
            {
                if (attribute.Name == "caption")
                {
                    menuItem.Caption = attribute.Value;
                }

                if (attribute.Name == "assemblyFile")
                {
                    menuItem.AssemblyFile = attribute.Value;
                }

                if (attribute.Name == "id")
                {
                    string id = attribute.Value;

                    if (!string.IsNullOrEmpty(id))
                    {
                        menuItem.Id = id;
                    }
                }

                if (attribute.Name == "operation")
                {
                    menuItem.Operation = attribute.Value;
                }

                if (attribute.Name == "topicIdentity")
                {
                    menuItem.EventTopic = attribute.Value;
                }

                if (attribute.Name == "parameters")
                {
                    menuItem.Parameters = attribute.Value;
                }
            }

            if (parentMenuItem != null)
            {
                parentMenuItem.Children.Add(menuItem);

                if (menuItem.IsFolder)
                {
                    AddBackMenuItem(menuItem);
                }
            }

            if (menuItem.IsFolder)
            {
                foreach (XmlNode childXmlNode in currentXmlNode.ChildNodes)
                {
                    AddMenuItem(childXmlNode, menuItem);
                }
            }

            return(menuItem);
        }