Inheritance: NotifyableBase
Exemplo n.º 1
0
        public ActionsManager(VidyanoPage page, ActionBase[] actions, ActionBase[] pinnedActions)
        {
            this.page = page.Page;
            this.actions = actions;
            this.pinnedActions = pinnedActions;

            if( (Settings.Current.StartupPageType == Settings.StartupPageTypeEnum.PersistenObjectPage && page is PersistentObjectPage && ((PersistentObjectPage)page).PersistentObject.Type == Settings.Current.StartupPageArgument) ||
                (Settings.Current.StartupPageType == Settings.StartupPageTypeEnum.QueryPage && page is QueryPage && ((QueryPage)page).Query.Name == Settings.Current.StartupPageArgument))
                ((PhoneHooks)Service.Current.Hooks).OnCreateHomePageApplicationBar(homePageButtons, homePageMenuItems);

            GenerateActionBar();

            actions.Run(a => a.PropertyChanged += ActionPropertyChanged);
            pinnedActions.Run(a => a.PropertyChanged += ActionPropertyChanged);
        }
Exemplo n.º 2
0
        public AddAndNewAction(ActionBase newAction, ActionBase addAction)
            : base(addAction.definition, addAction.Parent, addAction.Query)
        {
            this.newAction = newAction;
            this.addAction = addAction;

            newAction.IsVisible = false;
            addAction.IsVisible = false;

            CanExecute = IsVisible = true;

            var options = new List<string>();
            if (newAction.Options != null && newAction.Options.Length > 0)
                options.AddRange(newAction.Options.Select(o => newAction.DisplayName + " " + o));
            else
                options.Add(newAction.DisplayName);

            options.Add(Service.Current.Messages["Existing"]);
            Options = options.ToArray();
        }
Exemplo n.º 3
0
        internal PersistentObject(JObject model)
            : base(model)
        {
            JToken attributesToken;
            if (model.TryGetValue("attributes", out attributesToken))
            {
                var attributes = (JArray)attributesToken;
                Attributes = attributes.Select(jAttr => jAttr["lookup"] != null ? new PersistentObjectAttributeWithReference((JObject)jAttr, this) : new PersistentObjectAttribute((JObject)jAttr, this)).ToArray();
            }
            else
                Attributes = new PersistentObjectAttribute[0];

            JToken queriesToken;
            if (model.TryGetValue("queries", out queriesToken))
            {
                var queries = (JArray)queriesToken;
                Queries = new KeyValueList<string, Query>(queries.Select(jQuery /* :-) */ => Service.Current.Hooks.OnConstruct((JObject)jQuery, this, false)).ToDictionary(q => q.Name, q => q));
            }
            else
                Queries = new KeyValueList<string, Query>(new Dictionary<string, Query>());

            var parent = (JObject)model["parent"];
            if (parent != null)
                Parent = Service.Current.Hooks.OnConstruct(parent);

            // Initialize Tabs and Groups
            var tabIndex = 0;
            var attributeTabs = !IsHidden ? Attributes.OrderBy(attr => attr.Offset).GroupBy(attr => attr.Tab).Select(tab =>
            {
                var groups = tab.OrderBy(attr => attr.Offset).GroupBy(attr => attr.GroupName).Select(group => new PersistentObjectAttributeGroup(group.Key, group.ToArray())).ToArray();
                if (groups.Length == 1)
                    groups[0].IsNameVisible = false;

                var t = (PersistentObjectTab)CreateAttributesTab(groups.SelectMany(g => g.Attributes).ToArray(), string.IsNullOrEmpty(tab.Key) ? Label : tab.Key, this);
                t.Index = tabIndex++;
                return t;
            }) : new PersistentObjectTabAttributes[0];

            Tabs = attributeTabs.Concat(Queries.OrderBy(q => q.Value.Offset).Select(q => CreateQueryTab(q.Value))).ToList();

            if (!IsHidden)
            {
                // Initialize Action
                JToken actionsToken;
                if (model.TryGetValue("actions", out actionsToken))
                {
                    var actions = ActionBase.GetActions(actionsToken, this);

                    Actions = actions.Where(a => !a.IsPinned).ToArray();
                    PinnedActions = actions.Where(a => a.IsPinned).ToArray();

                    Actions.Run(a => a.Initialize());
                    PinnedActions.Run(a => a.Initialize());
                }
                else
                    Actions = PinnedActions = new ActionBase[0];
            }
            else
                Actions = PinnedActions = new ActionBase[0];

            // Also check IsInEdit (Object could have been reconstructed after suspend/resume)
            IsInEdit = IsInEdit || IsNew || StateBehavior.HasFlag(StateBehavior.OpenInEdit) || StateBehavior.HasFlag(StateBehavior.StayInEdit);
            IsDirty = IsDirty; // Also triggers reconstructed changes

            // Specials
            HasNotification = !string.IsNullOrWhiteSpace(Notification);

            Service.Current.Hooks.OnConstruct(this);

            Tabs.Select((tab, n) => tab.Index = n).Run();
        }
Exemplo n.º 4
0
        private void AddButton(ActionBase action, ApplicationBar appBar)
        {
            if (action == null || actionButtons.ContainsKey(action))
                return;

            var btn = new ApplicationBarIconButton();
            btn.IconUri = new Uri("/Assets/ActionIcons/" + action.Name + ".png", UriKind.RelativeOrAbsolute);
            btn.Text = action.DisplayName;
            btn.Click += Action_Clicked;
            btn.IsEnabled = action.CanExecute;
            appBar.Buttons.Add(btn);

            actionButtons[action] = btn;
        }
Exemplo n.º 5
0
        private void AddMenu(ActionBase action, ApplicationBar appBar)
        {
            if (action == null || actionButtons.ContainsKey(action))
                return;

            var menuItem = new ApplicationBarMenuItem();
            menuItem.Text = action.DisplayName;
            menuItem.Click += Action_Clicked;
            menuItem.IsEnabled = action.CanExecute;
            appBar.MenuItems.Add(menuItem);

            actionButtons[action] = menuItem;
        }
Exemplo n.º 6
0
 internal virtual async Task OnActionCommand(ActionBase action, object obj)
 {
     await action.Execute(null);
 }
Exemplo n.º 7
0
 internal static void ArrangeActions(ActionBase[] normalActions, ActionBase[] pinndActions, out ActionBase[] leftActions, out ActionBase[] rightActions)
 {
     if (Settings.Current.NormalActionsAlignment == Settings.NormalActionsAlignmentEnum.Right)
     {
         leftActions = (pinndActions ?? new ActionBase[0]).OrderByDescending(a => a.Offset).ThenBy(a => a.IsDependent).ToArray();
         rightActions = (normalActions ?? new ActionBase[0]).OrderByDescending(a => a.Offset).ThenBy(a => a.IsDependent).ToArray();
     }
     else
     {
         leftActions = normalActions;
         rightActions = pinndActions;
     }
 }
Exemplo n.º 8
0
 internal static void CloseActionsBar(ActionBase action)
 {
     if (action.Query == null && action.Parent != null)
     {
         ((StorePersistentObject)action.Parent).IsActionsBarSticky = false;
         ((StorePersistentObject)action.Parent).IsActionsBarOpen = false;
     }
     else if (action.Query != null)
     {
         ((StoreQuery)action.Query).IsActionsBarSticky = false;
         ((StoreQuery)action.Query).IsActionsBarOpen = false;
     }
 }
Exemplo n.º 9
0
 internal static void OpenActionsBar(ActionBase action, bool asSticky = false)
 {
     if (action.Query == null && action.Parent != null)
     {
         ((StorePersistentObject)action.Parent).IsActionsBarSticky = asSticky;
         ((StorePersistentObject)action.Parent).IsActionsBarOpen = true;
     }
     else if (action.Query != null)
     {
         ((StoreQuery)action.Query).IsActionsBarSticky = asSticky;
         ((StoreQuery)action.Query).IsActionsBarOpen = true;
     }
 }
Exemplo n.º 10
0
        internal override async Task OnActionCommand(ActionBase action, object obj)
        {
            if (action.Options != null && action.Options.Length > 0)
            {
                var button = obj as Button;
                if (button != null)
                {
                    var popupMenu = new PopupMenu();
                    foreach (var option in action.Options)
                        popupMenu.Commands.Add(new UICommand(option, async c => await action.Execute(c.Label)));

                    var point = button.TransformToVisual(null).TransformPoint(new Point(button.ActualWidth, 0d));
                    await popupMenu.ShowAsync(point);
                    return;
                }
            }

            await action.Execute(null);
        }