コード例 #1
0
ファイル: MenuTabView.cs プロジェクト: wyh0395/iFactr-NETCF
        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);
        }
コード例 #2
0
        public static void Initialize()
        {
            Device.Initialize(new CompactDevice());
            Initialize(new RootForm());

            IntPtr    HWND_BROADCAST = (IntPtr)0xFFFF;
            const int WM_Fontchange  = 0x001D;
            IntPtr    thir           = (IntPtr)0;
            IntPtr    fourth         = (IntPtr)0;
            var       fontName       = Font.PreferredLabelFont.Name + ".ttf";
            var       fontPath       = "\\Windows\\Fonts\\".AppendPath(fontName);

            if (!Device.File.Exists(fontPath))
            {
                var fontStream = Assembly.GetExecutingAssembly().GetManifestResourceStream("iFactr.Compact.Resources." + fontName);
                if (fontStream != null)
                {
                    Device.File.Save(fontPath, fontStream);
                }
            }

            if (Device.File.Exists(fontPath))
            {
                CoreDll.AddFontResource(fontPath);
                CoreDll.SendMessage(HWND_BROADCAST, WM_Fontchange, thir, fourth);
            }
            CoreDll.SystemParametersInfo(CoreDll.SPI_SETFONTSMOOTHING, -1, IntPtr.Zero, 0);

            var context = new iApp.AppNavigationContext {
                ActivePane = Pane.Master
            };

            PaneManager.Instance.AddStack(new HistoryStack {
                Context = context
            }, context);
            context = new iApp.AppNavigationContext {
                ActivePane = Pane.Popover
            };
            PaneManager.Instance.AddStack(new HistoryStack {
                Context = context
            }, context);
        }
コード例 #3
0
        public FragmentHistoryStack(Pane pane, int tab)
        {
            Context = new iApp.AppNavigationContext {
                ActivePane = pane, ActiveTab = tab,
            };
            switch (pane)
            {
            case Pane.Master:
                BackgroundId = Resource.Id.master_background;
                break;

            case Pane.Detail:
                BackgroundId = Resource.Id.detail_background;
                break;

            case Pane.Popover:
                BackgroundId = Resource.Id.popover_background;
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(pane), "Cannot create stacked view: " + pane);
            }
        }