Пример #1
0
        void TabItem_Click(object sender, EventArgs e)
        {
            iApp.CurrentNavContext.ActivePane = Pane.Tabs;
            var selected = Selected;

            if (selected == null)
            {
                var stack = (HistoryStack)PaneManager.Instance.FromNavContext(Pane.Master, Index);
                if (Index == PaneManager.Instance.CurrentTab || stack.CurrentView == null)
                {
                    PaneManager.Instance.CurrentTab = Index;
                    CompactFactory.Navigate(NavigationLink, View);
                }
                else
                {
                    iApp.CurrentNavContext.ActivePane = Pane.Master;
                    PaneManager.Instance.CurrentTab   = Index;
                    ((RootForm)CompactFactory.Instance.RootForm).Attach(stack.CurrentView, stack);
                }
            }
            else
            {
                selected(this, EventArgs.Empty);
            }
        }
Пример #2
0
        public IMXView[] PopToRoot()
        {
            if (Context.ActivePane == Pane.Popover)
            {
                var views = Views.ToArray();
                foreach (var view in views)
                {
                    _views.Remove(view);
                    var d = view is IListView?CompactFactory.GetNativeObject <SmoothListbox>(view, "view") : null;

                    if (d != null)
                    {
                        d.Parent = null;
                        d.animationTimer.Enabled = false;
                        d.Dispose();
                    }
                }
                if (views.Any())
                {
                    var master = (HistoryStack)PaneManager.Instance.FromNavContext(Pane.Master, PaneManager.Instance.CurrentTab);
                    master.Align(NavigationType.Back);
                }
                return(views);
            }

            var root = Views.FirstOrDefault();

            return(PopToView(root));
        }
Пример #3
0
        protected override void OnClick(EventArgs e)
        {
            base.OnClick(e);
            var clicked = Clicked;

            if (clicked != null)
            {
                clicked(this, e);
            }
            else
            {
                IMXView view;
                var     parent = Parent as IGridBase;
                if (parent is IMXView)
                {
                    view = parent as IMXView;
                }
                else
                {
                    var control = CompactFactory.GetNativeObject <GridCell>(parent, "Parent");
                    view = control.Parent as IMXView ?? control.Parent.Parent as IMXView;
                }
                CompactFactory.Navigate(NavigationLink, view);
            }
        }
Пример #4
0
        public void Layout()
        {
            Columns.Clear();

            var childControls = Children.ToList();

            foreach (var childControl in childControls)
            {
                RemoveChild(childControl);
            }

            if (PrimaryItems != null)
            {
                foreach (var toolbarItem in PrimaryItems)
                {
                    IElement item = toolbarItem is IToolbarButton || toolbarItem.Pair is IToolbarButton
                        ? CompactFactory.GetNativeObject <ToolbarButton>(toolbarItem, "toolbarItem")
                        : null;

                    //toolbarItem is IToolbarSeparator || toolbarItem.Pair is IToolbarSeparator ? CompactFactory.GetNativeObject<ToolbarSeparator>(toolbarItem, "toolbarItem") : null;
                    if (item != null)
                    {
                        Columns.Add(Column.AutoSized);
                        AddChild(item);
                    }
                }
            }

            if (SecondaryItems != null)
            {
                foreach (var toolbarItem in SecondaryItems)
                {
                    IElement item = toolbarItem is IToolbarButton || toolbarItem.Pair is IToolbarButton
                        ? CompactFactory.GetNativeObject <ToolbarButton>(toolbarItem, "toolbarItem")
                        : null;

                    //toolbarItem is IToolbarSeparator || toolbarItem.Pair is IToolbarSeparator ? CompactFactory.GetNativeObject<ToolbarSeparator>(toolbarItem, "toolbarItem") : null;
                    if (item != null)
                    {
                        Columns.Add(Column.AutoSized);
                        AddChild(item);
                    }
                }
            }

            var minSize = new Size(MinWidth, MinHeight);
            var maxSize = new Size(MaxWidth, MaxHeight);
            var newSize = this.PerformLayout(minSize, maxSize);

            if ((int)newSize.Height == 0)
            {
                return;
            }
            Size   = newSize.ToSize();
            _width = Width;
        }
Пример #5
0
 private void Draw(Graphics grp)
 {
     foreach (var paint in Children
              .Select(element => element is IPaintable ||
                      element.Pair is IPaintable ? CompactFactory.GetNativeObject <IPaintable>(element, "element") : null)
              .Where(paint => paint != null))
     {
         paint.Paint(grp);
     }
 }
Пример #6
0
        public void Render()
        {
            lock (SyncRoot) if (_instance == null)
                {
                    _instance = this;
                }

            Rendering.Raise(this, EventArgs.Empty);
            if (!TabItems.Any())
            {
                return;
            }
            if (string.IsNullOrEmpty(Text))
            {
                Text = "Go to...";
            }

            PaneManager.Instance.Clear();
            var tabs = TabItems.Select(item => CompactFactory.GetNativeObject <TabItem>(item, item.Title)).ToList();

            for (int i = 0; i < tabs.Count; i++)
            {
                var tab = tabs[i];
                if (tab == null)
                {
                    continue;
                }
                tab.View  = this;
                tab.Index = i;
                MenuItems.Add(tab);
                var context = new iApp.AppNavigationContext {
                    ActivePane = Pane.Master, ActiveTab = i
                };
                PaneManager.Instance.AddStack(new HistoryStack {
                    Context = context
                }, context);
            }

            var cxt = new iApp.AppNavigationContext {
                ActivePane = Pane.Popover,
            };

            PaneManager.Instance.AddStack(new HistoryStack {
                Context = cxt
            }, cxt);
            if (PaneManager.Instance.CurrentTab > TabItems.Count() || PaneManager.Instance.CurrentTab < 0)
            {
                PaneManager.Instance.CurrentTab = 0;
            }
            CompactFactory.Navigate(TabItems.ElementAt(PaneManager.Instance.CurrentTab).NavigationLink, this);
        }
Пример #7
0
        protected override void OnClick(EventArgs e)
        {
            base.OnClick(e);
            var click = Clicked;

            if (click != null)
            {
                click(this, e);
            }
            else
            {
                CompactFactory.Navigate(NavigationLink, PaneManager.Instance.FromNavContext(PaneManager.Instance.TopmostPane).CurrentView);
            }
        }
Пример #8
0
        public void Select()
        {
            Highlight();

            var selected = Selected;

            if (selected != null)
            {
                selected(Pair ?? this, EventArgs.Empty);
            }
            else
            {
                CompactFactory.Navigate(NavigationLink, Parent.Parent as IMXView);
            }
        }
Пример #9
0
        public void RemoveChild(IElement element)
        {
            _children.Remove(element);

            if (element is Control || element.Pair is Control)
            {
                var control = CompactFactory.GetNativeObject <Control>(element, "element");
                if (control != null)
                {
                    control.Parent = null;
                }
            }

            _forceLayout = true;
        }
Пример #10
0
        public void Submit(Link link)
        {
            var submitValues = (_model is iLayer) ? ((iLayer)_model).GetFieldValues() : GetSubmissionValues();

            var args = new SubmissionEventArgs(link, ValidationErrors);

            Submitting.Raise(this, args);

            if (args.Cancel)
            {
                return;
            }

            link.Parameters.AddRange(submitValues);
            CompactFactory.Navigate(link, this);
        }
Пример #11
0
        public IMXView[] PopToView(IMXView view)
        {
            if (view == null)
            {
                return(null);
            }
            if (!Views.Contains(view))
            {
                throw new ArgumentException();
            }

            var removed = new List <IMXView>();
            var layer   = CurrentLayer;

            // Perform pop on Views collection
            IMXView current;

            while (!Equals(current = _views.LastOrDefault(), view))
            {
                _views.Remove(current);
                var d = current is IListView?CompactFactory.GetNativeObject <SmoothListbox>(current, "view") : null;

                if (d != null)
                {
                    d.Parent = null;
                    d.animationTimer.Enabled = false;
                    d.Dispose();
                }
                removed.Add(current);
            }

            if (removed.Count <= 0)
            {
                return(removed.ToArray());
            }

            Align(NavigationType.Back);
            if (layer != null)
            {
                layer.Unload();
            }
            var iview = removed.First() as IView;

            iview.RaiseEvent("Deactivated", EventArgs.Empty);
            return(removed.ToArray());
        }
Пример #12
0
        public void AddChild(IElement element)
        {
            _children.Add(element);

            if (element is Control || element.Pair is Control)
            {
                var control = CompactFactory.GetNativeObject <Control>(element, "element");
                if (control != null)
                {
                    control.Parent = this;
                }
            }
            else if (element is IPaintable || element.Pair is IPaintable)
            {
                var paint = CompactFactory.GetNativeObject <IPaintable>(element, "element");
                if (paint != null)
                {
                    paint.SetParent(this);
                }
            }
            _forceLayout = true;
        }
Пример #13
0
        /// <summary>
        /// Syncronize the rendered stack with the <see cref="Views"/> collection
        /// </summary>
        public void Align(NavigationType navType)
        {
            var view = _views.LastOrDefault();

            if (view == null)
            {
                return;
            }
            var monoView = view as IView;

            if (monoView != null && monoView.Pair is Control)
            {
                view = CompactFactory.GetNativeObject <Control>(monoView, "view") as IMXView;
            }

            if (!(view is Control))
            {
                _views.Remove(view);
                return;
            }

            ((RootForm)CompactFactory.Instance.RootForm).Attach(view, this);
        }
Пример #14
0
        public void Add(IMenuButton menuButton)
        {
            var button = CompactFactory.GetNativeObject <MenuButton>(menuButton, "menuButton");

            _buttons.Add(button);
        }
Пример #15
0
        internal void Attach(IMXView view, HistoryStack stack)
        {
            if (GridControl.Bitmaps.Any())
            {
                var bitmaps = new Dictionary <GridControl, System.Drawing.Bitmap>(GridControl.Bitmaps);
                GridControl.Bitmaps.Clear();
                GridControl.mem = 0;
                foreach (var bit in bitmaps)
                {
                    bit.Value.Dispose();
                }
            }

            Device.Thread.ExecuteOnMainThread(() =>
            {
                if (view == null)
                {
                    return;
                }
                iApp.CurrentNavContext.ActivePane = stack.Context.ActivePane;
                var t            = CompactFactory.MetricStopwatch.ElapsedTicks;
                var absView      = view as IView;
                var list         = view as IListView;
                var grid         = view as IGridView;
                var browser      = view as IBrowserView;
                var history      = view as IHistoryEntry;
                var concreteView = view as System.Windows.Forms.Control ?? (view is IPairable ? ((IPairable)view).Pair as System.Windows.Forms.Control : null);

                if (absView != null)
                {
                    Text = absView.Title;
                }
                var listbox = ActiveView as SmoothListbox;
                if (listbox != null)
                {
                    listbox.animationTimer.Enabled = false;
                }
                Controls.Clear();
                int top = CompactFactory.TopPadding;
                if (list != null && list.SearchBox != null)
                {
                    var box    = CompactFactory.GetNativeObject <System.Windows.Forms.Control>(list.SearchBox, "SearchBox");
                    box.Parent = this;
                    var min    = new Size(Width, 0);
                    var max    = new Size(Width, 50 * CompactFactory.Instance.DpiScale);
                    box.Size   = ((IGridBase)box).PerformLayout(min, max).ToSize();
                    box.Top    = top;
                    top        = box.Bottom;
                }

                if (concreteView != null)
                {
                    var h                 = Screen.PrimaryScreen.WorkingArea.Height - SystemInformation.MenuHeight;
                    concreteView.Size     = new System.Drawing.Size(Width, h);
                    concreteView.Parent   = this;
                    concreteView.Location = new Point(0, top);
                }

                Menu.MenuItems.Clear();

                var back       = history == null ? null : history.BackLink;
                var backButton = new MenuItem {
                    Text = iApp.Factory.GetResourceString("Back")
                };
                backButton.Click += (sender, args) => stack.HandleBackLink(back, stack.Context.ActivePane);
                Menu.MenuItems.Add(backButton);
                var layer          = view.GetModel() as iLayer;
                backButton.Enabled = stack.DisplayBackButton(back) || stack.Context.ActivePane == Pane.Popover && !(layer is LoginLayer) && stack.Views.Count() < 2;
                if (MenuTabView.Instance != null && !(layer is LoginLayer) && (layer == null || stack.Context.ActivePane != Pane.Popover))
                {
                    Menu.MenuItems.Add(MenuTabView.Instance);
                }

                var menu = (list != null ? list.Menu : grid != null ? grid.Menu : browser != null ? browser.Menu : null);
                if (menu != null)
                {
                    MenuItem menuButton;
                    if (menu.ButtonCount == 1)
                    {
                        menuButton = CompactFactory.GetNativeObject <MenuItem>(menu.GetButton(0), "menu[0]");
                    }
                    else
                    {
                        menuButton = new MenuItem {
                            Text = iApp.Factory.GetResourceString("Menu")
                        };
                        for (int i = 0; i < menu.ButtonCount; i++)
                        {
                            menuButton.MenuItems.Add(CompactFactory.GetNativeObject <MenuItem>(menu.GetButton(i), "menu[" + i + "]"));
                        }
                    }
                    Menu.MenuItems.Add(menuButton);
                }

                MinimizeBox = layer == null || layer.ActionButtons.All(b => b.Action != Button.ActionType.Submit);

                listbox = ActiveView as SmoothListbox;
                if (listbox != null)
                {
                    listbox.animationTimer.Enabled = true;
                }

                CompactFactory.NavigatedAddresses.Clear();

                Debug.WriteLineIf(CompactFactory.MetricStopwatch.IsRunning, string.Format("[{1}] Attach IMXView took {0}ms", new TimeSpan(CompactFactory.MetricStopwatch.ElapsedTicks - t).TotalMilliseconds, CompactFactory.MetricStopwatch.ElapsedMilliseconds));
                Debug.WriteLineIf(CompactFactory.MetricStopwatch.IsRunning, string.Format("Total elapsed layer load time: {0}ms", CompactFactory.MetricStopwatch.ElapsedMilliseconds));

                CompactFactory.MetricStopwatch.Stop();
            });
        }
Пример #16
0
        private void HookEvent(HookEventArgs hookEventArgs, KeyBoardInfo keyBoardInfo)
        {
            var vkey = (Keys)keyBoardInfo.vkCode;

            if (!_keys.Contains(vkey))
            {
                _keys.Add(vkey);
            }

            if (_collecting)
            {
                return;
            }
            _collecting = true;

            var layer = ActiveView == null ? null : ActiveView.GetModel() as iLayer;
            var list  = ActiveView as SmoothListbox;

            Device.Thread.QueueWorker(o =>
            {
                Thread.Sleep(40);
                Device.Thread.ExecuteOnMainThread(new Action(() =>
                {
                    var currentKeystroke = new Keystroke(_keys.Cast <int>());
                    var candidateKeys    = new List <Keystroke> {
                        currentKeystroke
                    };
                    candidateKeys.AddRange(_keys.Select(k => new Keystroke((int)k)));

                    if (layer != null)
                    {
                        foreach (var key in candidateKeys)
                        {
                            var keyChord = new Gesture(key);

                            var link = layer.ShortcutGestures.GetValueOrDefault(keyChord, null);
                            if (link == null && _lastKeystroke != null)
                            {
                                keyChord = new Gesture(_lastKeystroke, key);
                                link     = layer.ShortcutGestures.GetValueOrDefault(keyChord, null);
                            }

                            if (link == null)
                            {
                                continue;
                            }
                            _keys.Clear();
                            currentKeystroke = null;
                            CompactFactory.Navigate(link, ActiveView);
                            break;
                        }
                    }

                    if (_keys.Contains(Keys.Tab))
                    {
                        if (list == null || list.IsDisposed)
                        {
                            return;
                        }
                        if (_keys.Contains(Keys.ShiftKey))
                        {
                            list.HighlightPrevious();
                        }
                        else
                        {
                            list.HighlightNext();
                        }
                        _keys.Clear();
                        currentKeystroke = null;
                    }
                    else if (_keys.Any())
                    {
                        UI.Controls.TextBox text     = null;
                        UI.Controls.TextArea area    = null;
                        UI.Controls.PasswordBox pass = null;
                        UI.Controls.DatePicker date  = null;
                        UI.Controls.TimePicker time  = null;

                        var item = list == null || list.IsDisposed ? null : list.SelectedItem;
                        if (item != null)
                        {
                            text = item.GetChild <UI.Controls.TextBox>();
                            area = item.GetChild <UI.Controls.TextArea>();
                            pass = item.GetChild <UI.Controls.PasswordBox>();
                            date = item.GetChild <UI.Controls.DatePicker>();
                            time = item.GetChild <UI.Controls.TimePicker>();
                        }

                        if (item == null || text == null && area == null && pass == null)
                        {
                            foreach (var key in _keys)
                            {
                                switch (key)
                                {
                                case Keys.Home:
                                    if (list != null && !list.IsDisposed)
                                    {
                                        list.ScrollToHome(true);
                                        _keys.Clear();
                                        currentKeystroke = null;
                                    }
                                    break;

                                case Keys.End:
                                    if (list != null && !list.IsDisposed)
                                    {
                                        list.ScrollToEnd(true);
                                        _keys.Clear();
                                        currentKeystroke = null;
                                    }
                                    break;

                                case Keys.F23:
                                case Keys.Select:
                                case Keys.Enter:
                                case Keys.Space:
                                    if (item != null)
                                    {
                                        item.Select();
                                    }
                                    _keys.Clear();
                                    currentKeystroke = null;
                                    break;
                                }

                                if (currentKeystroke == null)
                                {
                                    break;                           // _keys was modified
                                }
                            }
                        }

                        if (item == null || area == null && date == null && time == null)
                        {
                            foreach (var key in _keys)
                            {
                                switch (key)
                                {
                                case Keys.Up:
                                    if (list != null && !list.IsDisposed)
                                    {
                                        list.HighlightPrevious();
                                        _keys.Clear();
                                        currentKeystroke = null;
                                    }
                                    break;

                                case Keys.Down:
                                    if (list != null && !list.IsDisposed)
                                    {
                                        list.HighlightNext();
                                        _keys.Clear();
                                        currentKeystroke = null;
                                    }
                                    break;
                                }

                                if (currentKeystroke == null)
                                {
                                    break;                           // _keys was modified
                                }
                            }
                        }

                        if (area == null && text != null && (_keys.Contains(Keys.Enter) || _keys.Contains(Keys.F23)))
                        {
                            list.HighlightNext();
                            _keys.Clear();
                            currentKeystroke = null;
                        }

                        CommonKeys(list == null || list.IsDisposed ? null : list, ref currentKeystroke);
                    }

                    _lastKeystroke = currentKeystroke;

                    Device.Thread.QueueWorker(p =>
                    {
                        Thread.Sleep(40);
                        _keys.Clear();
                        _collecting = false;
                    });
                }));
            });
        }