コード例 #1
0
ファイル: PaneManager.cs プロジェクト: pdougla002/iFactr-UI
        /// <summary>
        /// Inserts the specified <see cref="IMXView"/> object into an appropriate stack and renders it.
        /// </summary>
        /// <param name="view">The view to be inserted into a stack.</param>
        /// <exception cref="ArgumentNullException">Thrown when the <paramref name="view"/> is <c>null</c>.</exception>
        public void DisplayView(IMXView view)
        {
            if (view == null)
            {
                throw new ArgumentNullException("view");
            }

            var entry = view as IHistoryEntry;

            if (entry != null && entry.StackID == null)
            {
                entry.StackID = view.GetType().FullName;
            }

            var navContext = new iLayer.NavigationContext
            {
                OutputOnPane        = GetPreferredPaneForView(view),
                NavigatedActiveTab  = iApp.CurrentNavContext.ActiveTab,
                NavigatedActivePane = iApp.CurrentNavContext.ActivePane,
            };

            var stack = FindStack(view);
            var layer = view.GetModel() as iLayer;

            if (layer != null)
            {
                if (stack.Contains(view))
                {
                    layer.NavContext.NavigatedActivePane      = navContext.NavigatedActivePane;
                    layer.NavContext.ClearPaneHistoryOnOutput = false;
                }
                layer.NavContext.OutputOnPane       = navContext.OutputOnPane;
                layer.NavContext.NavigatedActiveTab = navContext.NavigatedActiveTab;
                navContext = layer.NavContext;
            }

            var originalPane = navContext.OutputOnPane;

            if (stack.Contains(view))
            {
                originalPane = stack.FindPane();
                iApp.CurrentNavContext.ActivePane = originalPane;
                navContext.NavigatedActivePane    = originalPane;
                if (entry != null)
                {
                    entry.OutputPane = originalPane;
                }
            }

            for (navContext.OutputOnPane = Pane.Popover; navContext.OutputOnPane > originalPane; navContext.OutputOnPane--)
            {
                var clearStack = FromNavContext(navContext);
                if (clearStack != null && clearStack.FindPane() > originalPane)
                {
                    clearStack.PopToRoot();
                }
            }

            stack.DisplayView(view, navContext.NavigatedActivePane < navContext.OutputOnPane || navContext.ClearPaneHistoryOnOutput);
        }
コード例 #2
0
ファイル: ImagePicker.cs プロジェクト: chencai01/iFactr-WPF
        public ImagePicker(iLayer.NavigationContext navContext, Dictionary <string, string> parameters = null)
        {
            string callbackUri = null;
            bool   camera      = false;
            bool   gallery     = true;

            if (parameters != null)
            {
                if (parameters.ContainsKey(CallbackUri))
                {
                    callbackUri = parameters[CallbackUri];
                }
                if (parameters.ContainsKey(Camera))
                {
                    bool.TryParse(parameters[Camera], out camera);
                }
                if (parameters.ContainsKey(Gallery))
                {
                    bool.TryParse(parameters[Gallery], out gallery);
                }
            }

            //TODO: If camera and gallery are both enabled, allow user to pick.

            if (camera)
            {
                //TODO: Camera support.
            }

            if (gallery)
            {
                var openFileDialog1 = new OpenFileDialog
                {
#if !SILVERLIGHT
                    Filter           = "Image Files (*.png, *.jpg, *.jpeg, *.tif, *.tiff, *.gif)|*.png;*.jpg;*.jpeg;*.tif;*.tiff,*.gif|All Files (*.*)|*.*",
                    InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures),
#endif
                    Multiselect = false,
                };

#if SILVERLIGHT
                try
                {
                    if (openFileDialog1.ShowDialog() != true)
                    {
                        return;
                    }
                }
                catch (Exception)
                {
                    return;
                }
                var fileStream = openFileDialog1.File.OpenRead();
                var extension  = openFileDialog1.File.Extension.Trim(new[] { '.' });
                ImageUri = openFileDialog1.File.Name;
#else
                iApp.Factory.StopBlockingUserInput();
                if (openFileDialog1.ShowDialog() != DialogResult.OK)
                {
                    return;
                }
                var location = new FileInfo(openFileDialog1.FileName);
                ImageUri = location.FullName;
                var extension  = location.Extension.Trim(new[] { '.' });
                var fileStream = new MemoryStream(iApp.File.Read(ImageUri, EncryptionMode.NoEncryption));
#endif
                ImageId = WpfFactory.Instance.StoreImage(fileStream, extension);
                fileStream.Close();

                if (callbackUri != null)
                {
                    WpfFactory.Instance.IsBusy = true;
                    iApp.SetNavigationContext(navContext);
                    iApp.Navigate(callbackUri, new Dictionary <string, string> {
                        { "PhotoImage", ImageId },
                    });
                }
            }
        }
コード例 #3
0
ファイル: iApp.cs プロジェクト: Zebra/iFactr-Android
 /// <summary>
 /// Sets the application's navigation context using the specified layer navigation context.
 /// </summary>
 /// <param name="navContext">The layer navigation context to set the application's navigation context with.</param>
 public static void SetNavigationContext(iLayer.NavigationContext navContext)
 {
     CurrentNavContext.ActiveTab  = navContext.NavigatedActiveTab;
     CurrentNavContext.ActivePane = navContext.OutputOnPane;
 }
コード例 #4
0
ファイル: PaneManager.cs プロジェクト: pdougla002/iFactr-UI
 public IHistoryStack FromNavContext(iLayer.NavigationContext navContext)
 {
     return(FromNavContext(navContext.OutputOnPane, navContext.NavigatedActiveTab));
 }