Inheritance: INotifyPropertyChanged
        public ActionResult CommentsAJS(int ParentId)
        {
            ItemViewModel<int> model = new ItemViewModel<int>();
            model.Item = ParentId;

            return View(model);
        }
Esempio n. 2
0
        private void ButtonScript_Click(object sender, RoutedEventArgs e)
        {
            //NavigationService.Navigate();
            var d = new Utils.ScriptDownloader();
            var item = (sender as Button).Tag as OnlineScriptViewModel;
            d.Download(item, this.Dispatcher,
                (simpleScriptDetail) =>
                {
                    var baseItem = new ItemViewModel()
                    {
                        CategoryTag = simpleScriptDetail.TagsAsText,
                        Code = simpleScriptDetail.Code,
                        Title = simpleScriptDetail.Title,
                        UniqueId = simpleScriptDetail.ScriptId
                    };

                    bool sameAuthor = false;
                    if (App.ViewModel.Account.UserName != null)
                        sameAuthor = (simpleScriptDetail.AuthorName.ToLowerInvariant() == App.ViewModel.Account.UserName.ToLowerInvariant());

                    if (sameAuthor)
                    {
                        var existing = App.ViewModel.Items.Where(x => x.UniqueId == simpleScriptDetail.ScriptId).FirstOrDefault();
                        if (existing != null)
                        {
                            var result = MessageBox.Show("Replace your current script?", Iron7.Common.Constants.Title, MessageBoxButton.OKCancel);
                            if (result != MessageBoxResult.OK)
                                return;
                            App.ViewModel.Items.Remove(existing);
                        }                        
                    }
                    App.ViewModel.CreateNewItemBasedOn(baseItem, NavigationService, !sameAuthor, sameAuthor);
                });
        }
        private static string ConstructSamePageUrl(ItemViewModel item)
        {
            var appRelativeUrl = DataResolver.Resolve(item.DataItem, "URL");
            var url = UrlPath.ResolveUrl(appRelativeUrl, true);

            return url;
        }
        public ActionResult Address(int Id)
        {
            ItemViewModel<int> model = new ItemViewModel<int>();
            model.Item = Id;

            return View(model);
        }
        /// <summary>
        /// Gets the detail page URL for blog item.
        /// </summary>
        /// <param name="item">The item.</param>
        /// <param name="detailsPageId">The details page identifier.</param>
        /// <param name="blogDetailLocationMode">The blog detail location mode.</param>
        /// <returns></returns>
        public static string GetDetailPageUrl(ItemViewModel item, Guid detailsPageId, BlogDetailLocationMode blogDetailLocationMode)
        {
            string url = null;
            if (blogDetailLocationMode == BlogDetailLocationMode.SelectedExistingPage)
            {
                url = HyperLinkHelpers.GetDetailPageUrl(item.DataItem, detailsPageId);
            }
            else if (blogDetailLocationMode == BlogDetailLocationMode.PerItem)
            {
                var blog = item.DataItem as Blog;

                if (blog != null)
                {
                    var blogPageId = blog.DefaultPageId;

                    if (blogPageId.HasValue)
                        url = HyperLinkHelpers.GetDetailPageUrl(item.DataItem, blogPageId.Value);
                }

            }
            else if (blogDetailLocationMode == BlogDetailLocationMode.SamePage)
            {
                url = DetailLocationHyperLinkHelper.ConstructSamePageUrl(item);
            }

            return url;
        }
Esempio n. 6
0
        public static IList<ItemViewModel> GetItems(JObject json)
        {
            var items = new List<ItemViewModel>();
            JToken tokens = json["data"]["children"];
            foreach (JToken token in tokens)
            {
                string title = ProcessString(token["data"]["title"].Value<string>());
                string thumbnail = token["Thumbnail"].Value<string>();
                var itemViewModel = new ItemViewModel
                {
                    Title = title,
                    Url = token["data"]["url"].Value<string>(),
                    Domain = token["data"]["domain"].Value<string>()
                };

                if (thumbnail != "default")
                {
                    itemViewModel.Thumbnail = thumbnail;
                }

                if (!token["data"]["stickied"].Value<bool>())
                {
                    items.Add(itemViewModel);
                }
            }
            return items;
        }
        public ActionResult Index()
        {
            ItemViewModel<WikiPageContentType> model = new ItemViewModel<WikiPageContentType>();
            model.Item = WikiPageContentType.NotSet;

            return View(model);
        }
Esempio n. 8
0
        public static IList<ItemViewModel> GetItems(JObject json)
        {
            var items = new List<ItemViewModel>();
            JToken tokens = json["data"]["children"];
            foreach (JToken token in tokens)
            {
                try
                {
                    string title = ProcessString(token["data"]["title"].Value<string>());
                    var itemViewModel = new ItemViewModel
                    {
                        Title = title,
                        Url = token["data"]["url"].Value<string>(),
                        Domain = token["data"]["domain"].Value<string>(),
                    };

                    var thumbnail = token["data"]["thumbnail"].Value<string>();
                    if (thumbnail != "default")
                    {
                        itemViewModel.Thumbnail = thumbnail;
                    }

                    if (!token["data"]["stickied"].Value<bool>())
                    {
                        items.Add(itemViewModel);
                    }
                }
                catch (Exception)
                {
                    // it's not that great, but we'll eat parsing exception for now
                }
            }
            return items;
        }
        public ActionResult EditFaq(int? faqId = 0)
        {
            ItemViewModel<int?> model = new ItemViewModel<int?>();

            model.Item = faqId;

            return View(model);
        }
Esempio n. 10
0
 internal static void ShareViaClipBoard(ItemViewModel model)
 {
     string text = model.Title + "\n" + model.Url;
     if (MessageBox.Show(text, "Copy to Clipboard?", MessageBoxButton.OKCancel) == MessageBoxResult.OK)
     {
         Clipboard.SetText(text);
     }
 }
        public ActionResult AllByOwnerTypeId(int OwnerId, bool isAdmin = true)
        {
            ItemViewModel<int> model = new ItemViewModel<int>();
            model.Item = OwnerId;
            model.IsAdmin = isAdmin;

            return View(model);
        }
        public ActionResult Index(int planId)
        {
            ItemViewModel<int> model = new ItemViewModel<int>();

            model.Item = planId;

            return View(model);
        }
Esempio n. 13
0
        public static ItemViewModel ConvertDoubanUnionStatues(Statuses statues)
        {
            ItemViewModel model = new ItemViewModel();
            model.IconURL = statues.user.small_avatar;
            model.LargeIconURL = PreferenceHelper.GetPreference("Douban_FollowerAvatar2");
            model.Title = statues.user.screen_name;
            String attachTitle = "";
            if (statues.attachments != null && statues.attachments.Count > 0)
            {
                foreach (Statuses.Attachment attach in statues.attachments)
                {
                    attachTitle = attach.title;
                }
            }
            model.Content = TrimMark(statues.title) + " " + attachTitle + " " + statues.text;
            model.TimeObject = ExtHelpers.GetDoubanTimeFullObject(statues.created_at);
            model.Type = EntryType.Douban;
            model.ID = statues.id;
            model.Comments = new ObservableCollection<CommentViewModel>();
            model.CommentCount = statues.comments_count;
            model.SharedCount = statues.reshared_count;

            if (statues.reshared_status != null)
            {
                Statuses forwardStatus = statues.reshared_status;
                ItemViewModel forwardModel = new ItemViewModel();
                forwardModel.IconURL = forwardStatus.user.small_avatar;
                forwardModel.LargeIconURL = PreferenceHelper.GetPreference("Douban_FollowerAvatar2");
                forwardModel.Title = forwardStatus.user.screen_name;
                String forwardAttachTitle = "";
                if (forwardStatus.attachments != null && forwardStatus.attachments.Count > 0)
                {
                    foreach (Statuses.Attachment attach in forwardStatus.attachments)
                    {
                        forwardAttachTitle = attach.title;
                    }
                }
                forwardModel.Content = TrimMark(forwardStatus.title) + " " + forwardAttachTitle + " " + forwardStatus.text;
                forwardModel.TimeObject = ExtHelpers.GetDoubanTimeFullObject(forwardStatus.created_at);
                forwardModel.Type = EntryType.Douban;
                forwardModel.ID = forwardStatus.id;
                forwardModel.Comments = new ObservableCollection<CommentViewModel>();
                forwardModel.CommentCount = forwardStatus.comments_count;
                forwardModel.SharedCount = forwardStatus.reshared_count;

                if (PreferenceHelper.GetPreference("Global_NeedFetchImageInRetweet") != "False")
                {
                    FiltPicture(forwardStatus, forwardModel);
                }
                // 如果是转播的话,把model的text改成“转播”两字,不然空在那里很奇怪
                model.Content = "转播";
                model.CommentCount = forwardModel.CommentCount;
                model.SharedCount = forwardModel.SharedCount;
                model.ForwardItem = forwardModel;
            }
            FiltPicture(statues, model);
            return model;
        }
Esempio n. 14
0
 protected override void OnCreate(Bundle bundle)
 {
     App.Invoker = RunOnUiThread;
     App.Init ();
     base.OnCreate (bundle);
     ListAdapter = new ItemViewModel {
         Context = this,
         ListView = ListView,
     };
 }
Esempio n. 15
0
        public void OnDataContextChanged(object o, DependencyPropertyChangedEventArgs eventArgs)
        {
            var item = (Item)this.DataContext;

            if (item != null)
            {
                this.viewModel = new ItemViewModel(item);
                this.root.DataContext = this.viewModel;
            }
        }
Esempio n. 16
0
 public HttpResponseMessage Upsert(ItemViewModel item)
 {
     if (item.Id > 0)
     {
         var t = Update(item);
         return Request.CreateResponse(System.Net.HttpStatusCode.NoContent);
     }
     else
     {
         var t = Create(item);
         return Request.CreateResponse(t.ItemId);
     }
 }
        public ActionResult ResetPassword(Guid resetToken)
        {
            bool exists = TokensService.Exists(resetToken);

            if (!exists)
            {
                 return View("Error_404");
            }

            ItemViewModel<Guid> model = new ItemViewModel<Guid>();
            model.Item = resetToken;
            return View(model);
        }
Esempio n. 18
0
        public async Task AddOrRemoveToFavoritesAsync(string sectionName, ItemViewModel item)
        {
            CheckInitialized();

            if (IsOnFavorites(sectionName, item))
            {
                _userFavorites.Remove(sectionName, item.Id);
            }
            else
            {
                _userFavorites.Add(sectionName, item.Id);
            }
            await Singleton<RoamingService>.Instance.SaveAsync(FavFileName, _userFavorites);
        }
        protected void ShareContent(DataRequest dataRequest, ItemViewModel item, bool supportsHtml)
        {
            try
            {
                if (item != null)
                {
                    dataRequest.Data.Properties.Title = string.IsNullOrEmpty(item.Title) ? Title : item.Title;

                    if (!string.IsNullOrEmpty(item.SubTitle))
                    {
                        SetContent(dataRequest, item.SubTitle, false);
                    }

                    if (!string.IsNullOrEmpty(item.Description))
                    {
                        SetContent(dataRequest, item.Description, supportsHtml);
                    }

                    if (!string.IsNullOrEmpty(item.Content))
                    {
                        SetContent(dataRequest, item.Content, supportsHtml);
                    }

                    if (!string.IsNullOrEmpty(item.Source))
                    {
                        dataRequest.Data.SetWebLink(new Uri(item.Source));
                    }

                    var imageUrl = item.ImageUrl;
                    if (!string.IsNullOrEmpty(imageUrl))
                    {
                        if (imageUrl.StartsWith("http", StringComparison.OrdinalIgnoreCase))
                        {
                            if (string.IsNullOrEmpty(item.Source))
                            {
                                dataRequest.Data.SetWebLink(new Uri(imageUrl));
                            }
                        }
                        else
                        {
                            imageUrl = string.Format("ms-appx://{0}", imageUrl);
                        }
                        dataRequest.Data.SetBitmap(Windows.Storage.Streams.RandomAccessStreamReference.CreateFromUri(new Uri(imageUrl)));
                    }
                }
            }
            catch (UriFormatException)
            {
            }
        }
Esempio n. 20
0
 internal static void ShareViaSms(ItemViewModel model)
 {
     try
     {
         var task = new SmsComposeTask()
         {
             Body = model.Title + "\n" + model.Url
         };
         task.Show();
     }
     catch (Exception)
     {
         // fast-clicking can result in exception, so we just handle it
     }
 }
Esempio n. 21
0
        public static string GetDetailPageUrl(ItemViewModel item, Guid detailsPageId, bool openInSamePage)
        {
            string url;
            if (openInSamePage)
            {
                var appRelativeUrl = DataResolver.Resolve(item.DataItem, "URL");
                url = UrlPath.ResolveUrl(appRelativeUrl, true);
            }
            else
            {
                url = HyperLinkHelpers.GetDetailPageUrl(item.DataItem, detailsPageId);
            }

            return url;
        }
Esempio n. 22
0
 internal static void ShareViaEmail(ItemViewModel model)
 {
     try
     {
         var task = new EmailComposeTask
         {
             Subject = model.Title,
             Body = model.Title + "\n\n" + model.Url + "\n\n" + "Shared via Trivia Buff\nhttp://www.triviabuffapp.com"
         };
         task.Show();
     }
     catch (Exception)
     {
         // fast-clicking can result in exception, so we just handle it
     }
 }
Esempio n. 23
0
 public static IEnumerable<ItemViewModel> GetItems(JArray tokens)
 {
     var items = new List<ItemViewModel>();
     foreach (JToken token in tokens)
     {
         string title = ProcessString(token["Title"].Value<string>());
         var itemViewModel = new ItemViewModel
         {
             Title = title,
             Url = token["Url"].Value<string>(),
             Domain = token["Domain"].Value<string>(),
             Thumbnail = token["Thumbnail"].Value<string>()
         };
         items.Add(itemViewModel);
     }
     return items;
 }
Esempio n. 24
0
 internal static void ShareViaSocial(ItemViewModel model)
 {
     try
     {
         var task = new ShareLinkTask()
         {
             Title = model.Title,
             Message = model.Title,
             LinkUri = new Uri(model.Url, UriKind.Absolute)
         };
         task.Show();
     }
     catch (Exception)
     {
         // fast-clicking can result in exception, so we just handle it
     }
 }
Esempio n. 25
0
        /// <summary>
        /// Gets the serialized image.
        /// </summary>
        /// <param name="helper">The helper.</param>
        /// <param name="item">The item.</param>
        /// <returns></returns>
        public static string GetSerializedImage(this HtmlHelper helper, ItemViewModel item)
        {
            var image = (Image)item.DataItem;

            var itemViewModel = new
            {
                Title = image.Title.Value,
                AlternativeText = image.AlternativeText.Value,
                Description = image.Description.Value,
                MediaUrl = ((ThumbnailViewModel)item).MediaUrl,
                DateCreated = image.DateCreated,
                Author = image.Author.Value
            };

            var serializedItemViewModel = new JavaScriptSerializer().Serialize(itemViewModel);

            return serializedItemViewModel;
        }
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            Window.RequestFeature(WindowFeatures.Progress);
            SetContentView(Resource.Layout.TriviaDetails);

            var json = Intent.Extras.GetString("json");
            _trivia = JsonConvert.DeserializeObject<ItemViewModel>(json);
            FindViewById<TextView>(Resource.Id.titleTextView).Text = _trivia.Title;

            var webView = FindViewById<WebView>(Resource.Id.webView);

            webView.SetWebViewClient(new WebViewClient());
            webView.SetWebChromeClient(new ProgressClient(this));
            webView.Settings.JavaScriptEnabled = true;

            webView.LoadUrl(_trivia.Url);
        }
Esempio n. 27
0
        protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            string scriptIndex = NavigationContext.QueryString["ScriptIndex"];

            CurrentItem = App.ViewModel.Items.FirstOrDefault(x => x.UniqueId == scriptIndex);

            if (CurrentItem == null)
            {
                MessageBox.Show("Sorry - script not found", Common.Constants.Title, MessageBoxButton.OK);
                try
                {
                    NavigationService.GoBack();
                }
                catch (InvalidOperationException)
                {
                    // just mask this problem
                }
                return;
            }

            DataContext = CurrentItem;
        }
Esempio n. 28
0
        // Constructor for Delete takes a view model of what to delete
        public ItemDeletePage(ItemViewModel data)
        {
            InitializeComponent();

            BindingContext = this.viewModel = data;
        }
Esempio n. 29
0
 public static List <ContextMenuFlyoutItemViewModel> GetBaseLayoutMenuItems(CurrentInstanceViewModel currentInstanceViewModel, ItemViewModel itemViewModel, BaseLayoutCommandsViewModel commandsViewModel)
 {
     return(new List <ContextMenuFlyoutItemViewModel>()
     {
         new ContextMenuFlyoutItemViewModel()
         {
             Text = "ContextMenuMoreItemsLabel".GetLocalized(),
             Glyph = "\xE712",
             ID = "ItemOverflow"
         },
         new ContextMenuFlyoutItemViewModel()
         {
             Text = "BaseLayoutContextFlyoutLayoutMode/Text".GetLocalized(),
             Glyph = "\uE152",
             ShowInRecycleBin = true,
             Items = new List <ContextMenuFlyoutItemViewModel>()
             {
                 // Grid view large
                 new ContextMenuFlyoutItemViewModel()
                 {
                     Text = "BaseLayoutContextFlyoutGridViewLarge/Text".GetLocalized(),
                     Glyph = "\uE739",
                     ShowInRecycleBin = true,
                     Command = currentInstanceViewModel.FolderSettings.ToggleLayoutModeGridViewLarge,
                     CommandParameter = true,
                 },
                 // Grid view medium
                 new ContextMenuFlyoutItemViewModel()
                 {
                     Text = "BaseLayoutContextFlyoutGridViewMedium/Text".GetLocalized(),
                     Glyph = "\uF0E2",
                     ShowInRecycleBin = true,
                     Command = currentInstanceViewModel.FolderSettings.ToggleLayoutModeGridViewMedium,
                     CommandParameter = true,
                 },
                 // Grid view small
                 new ContextMenuFlyoutItemViewModel()
                 {
                     Text = "BaseLayoutContextFlyoutGridViewSmall/Text".GetLocalized(),
                     Glyph = "\uE80A",
                     ShowInRecycleBin = true,
                     Command = currentInstanceViewModel.FolderSettings.ToggleLayoutModeGridViewSmall,
                     CommandParameter = true,
                 },
                 // Tiles view
                 new ContextMenuFlyoutItemViewModel()
                 {
                     Text = "BaseLayoutContextFlyoutTilesView/Text".GetLocalized(),
                     Glyph = "\uE15C",
                     ShowInRecycleBin = true,
                     Command = currentInstanceViewModel.FolderSettings.ToggleLayoutModeTiles,
                     CommandParameter = true,
                 },
                 // Details view
                 new ContextMenuFlyoutItemViewModel()
                 {
                     Text = "BaseLayoutContextFlyoutDetails/Text".GetLocalized(),
                     Glyph = "\uE179",
                     ShowInRecycleBin = true,
                     Command = currentInstanceViewModel.FolderSettings.ToggleLayoutModeDetailsView,
                     CommandParameter = true,
                 },
                 // Column view
                 new ContextMenuFlyoutItemViewModel()
                 {
                     Text = "BaseLayoutContextFlyoutColumn/Text".GetLocalized(),
                     Glyph = "\uF115",
                     GlyphFontFamilyName = "CustomGlyph",
                     ShowInRecycleBin = true,
                     Command = currentInstanceViewModel.FolderSettings.ToggleLayoutModeColumnView,
                     CommandParameter = true,
                 },
             }
         },
         new ContextMenuFlyoutItemViewModel()
         {
             Text = "BaseLayoutContextFlyoutSortBy/Text".GetLocalized(),
             Glyph = "\uE8CB",
             ShowInRecycleBin = true,
             Items = new List <ContextMenuFlyoutItemViewModel>()
             {
                 new ContextMenuFlyoutItemViewModel()
                 {
                     Text = "BaseLayoutContextFlyoutSortByName/Text".GetLocalized(),
                     IsChecked = itemViewModel.IsSortedByName,
                     ShowInRecycleBin = true,
                     Command = new RelayCommand(() => itemViewModel.IsSortedByName = true),
                     ItemType = ItemType.Toggle,
                 },
                 new ContextMenuFlyoutItemViewModel()
                 {
                     Text = "BaseLayoutContextFlyoutSortByOriginalPath/Text".GetLocalized(),
                     IsChecked = itemViewModel.IsSortedByOriginalPath,
                     ShowInRecycleBin = true,
                     Command = new RelayCommand(() => itemViewModel.IsSortedByOriginalPath = true),
                     ShowItem = currentInstanceViewModel.IsPageTypeRecycleBin,
                     ItemType = ItemType.Toggle,
                 },
                 new ContextMenuFlyoutItemViewModel()
                 {
                     Text = "BaseLayoutContextFlyoutSortByDateDeleted/Text".GetLocalized(),
                     IsChecked = itemViewModel.IsSortedByDateDeleted,
                     Command = new RelayCommand(() => itemViewModel.IsSortedByDateDeleted = true),
                     ShowInRecycleBin = true,
                     ShowItem = currentInstanceViewModel.IsPageTypeRecycleBin,
                     ItemType = ItemType.Toggle
                 },
                 new ContextMenuFlyoutItemViewModel()
                 {
                     Text = "BaseLayoutContextFlyoutSortByType/Text".GetLocalized(),
                     IsChecked = itemViewModel.IsSortedByType,
                     Command = new RelayCommand(() => itemViewModel.IsSortedByType = true),
                     ShowInRecycleBin = true,
                     ItemType = ItemType.Toggle
                 },
                 new ContextMenuFlyoutItemViewModel()
                 {
                     Text = "BaseLayoutContextFlyoutSortBySize/Text".GetLocalized(),
                     IsChecked = itemViewModel.IsSortedBySize,
                     Command = new RelayCommand(() => itemViewModel.IsSortedBySize = true),
                     ShowInRecycleBin = true,
                     ItemType = ItemType.Toggle
                 },
                 new ContextMenuFlyoutItemViewModel()
                 {
                     Text = "BaseLayoutContextFlyoutSortByDate/Text".GetLocalized(),
                     IsChecked = itemViewModel.IsSortedByDate,
                     Command = new RelayCommand(() => itemViewModel.IsSortedByDate = true),
                     ShowInRecycleBin = true,
                     ItemType = ItemType.Toggle
                 },
                 new ContextMenuFlyoutItemViewModel()
                 {
                     Text = "BaseLayoutContextFlyoutSortByDateCreated/Text".GetLocalized(),
                     IsChecked = itemViewModel.IsSortedByDateCreated,
                     Command = new RelayCommand(() => itemViewModel.IsSortedByDateCreated = true),
                     ShowInRecycleBin = true,
                     ItemType = ItemType.Toggle
                 },
                 new ContextMenuFlyoutItemViewModel()
                 {
                     ItemType = ItemType.Separator,
                     ShowInRecycleBin = true,
                 },
                 new ContextMenuFlyoutItemViewModel()
                 {
                     Text = "BaseLayoutContextFlyoutSortByAscending/Text".GetLocalized(),
                     IsChecked = itemViewModel.IsSortedAscending,
                     Command = new RelayCommand(() => itemViewModel.IsSortedAscending = true),
                     ShowInRecycleBin = true,
                     ItemType = ItemType.Toggle
                 },
                 new ContextMenuFlyoutItemViewModel()
                 {
                     Text = "BaseLayoutContextFlyoutSortByDescending/Text".GetLocalized(),
                     IsChecked = itemViewModel.IsSortedDescending,
                     Command = new RelayCommand(() => itemViewModel.IsSortedDescending = true),
                     ShowInRecycleBin = true,
                     ItemType = ItemType.Toggle
                 },
             }
         },
         new ContextMenuFlyoutItemViewModel()
         {
             Text = "BaseLayoutContextFlyoutRefresh/Text".GetLocalized(),
             Glyph = "\uE72C",
             ShowInRecycleBin = true,
             Command = commandsViewModel.RefreshCommand,
             KeyboardAccelerator = new KeyboardAccelerator
             {
                 Key = Windows.System.VirtualKey.F5,
                 IsEnabled = false,
             }
         },
         new ContextMenuFlyoutItemViewModel()
         {
             Text = "BaseLayoutContextFlyoutPaste/Text".GetLocalized(),
             Glyph = "\uE16D",
             Command = commandsViewModel.PasteItemsFromClipboardCommand,
             IsEnabled = currentInstanceViewModel.CanPasteInPage && App.InteractionViewModel.IsPasteEnabled,
             KeyboardAccelerator = new KeyboardAccelerator
             {
                 Key = Windows.System.VirtualKey.V,
                 Modifiers = Windows.System.VirtualKeyModifiers.Control,
                 IsEnabled = false,
             }
         },
         new ContextMenuFlyoutItemViewModel()
         {
             Text = "BaseLayoutContextFlyoutOpenInTerminal/Text".GetLocalized(),
             Glyph = "\uE756",
             Command = commandsViewModel.OpenDirectoryInDefaultTerminalCommand,
         },
         new ContextMenuFlyoutItemViewModel()
         {
             ItemType = ItemType.Separator,
         },
         new ContextMenuFlyoutItemViewModel()
         {
             Text = "BaseLayoutContextFlyoutNew/Text".GetLocalized(),
             Glyph = "\uE710",
             KeyboardAccelerator = new KeyboardAccelerator
             {
                 Key = Windows.System.VirtualKey.N,
                 Modifiers = Windows.System.VirtualKeyModifiers.Control,
                 IsEnabled = false,
             },
             Items = GetNewItemItems(commandsViewModel),
         },
         new ContextMenuFlyoutItemViewModel()
         {
             Text = "BaseLayoutContextFlyoutPinDirectoryToSidebar/Text".GetLocalized(),
             Glyph = "\uE840",
             Command = commandsViewModel.SidebarPinItemCommand,
             ShowItem = !itemViewModel.CurrentFolder.IsPinned
         },
         new ContextMenuFlyoutItemViewModel()
         {
             Text = "BaseLayoutContextFlyoutUnpinDirectoryFromSidebar/Text".GetLocalized(),
             Glyph = "\uE77A",
             Command = commandsViewModel.SidebarUnpinItemCommand,
             ShowItem = itemViewModel.CurrentFolder.IsPinned
         },
         new ContextMenuFlyoutItemViewModel()
         {
             Text = "PinItemToStart/Text".GetLocalized(),
             Glyph = "\uE840",
             Command = commandsViewModel.PinItemToStartCommand,
             ShowOnShift = true,
             ShowItem = !itemViewModel.CurrentFolder.IsItemPinnedToStart,
         },
         new ContextMenuFlyoutItemViewModel()
         {
             Text = "UnpinItemFromStart/Text".GetLocalized(),
             Glyph = "\uE77A",
             Command = commandsViewModel.UnpinItemFromStartCommand,
             ShowOnShift = true,
             ShowItem = itemViewModel.CurrentFolder.IsItemPinnedToStart,
         },
         new ContextMenuFlyoutItemViewModel()
         {
             Text = "BaseLayoutContextFlyoutPropertiesFolder/Text".GetLocalized(),
             Glyph = "\uE946",
             Command = commandsViewModel.ShowFolderPropertiesCommand,
         },
         new ContextMenuFlyoutItemViewModel()
         {
             Text = "BaseLayoutContextFlyoutEmptyRecycleBin/Text".GetLocalized(),
             Glyph = "\uEF88",
             GlyphFontFamilyName = "RecycleBinIcons",
             Command = commandsViewModel.EmptyRecycleBinCommand,
             ShowItem = currentInstanceViewModel.IsPageTypeRecycleBin,
             ShowInRecycleBin = true,
         },
     });
 }
Esempio n. 30
0
 private void UpdateIsSelected(IEnumerable<ItemViewModel> collection, ItemViewModel value)
 {
     foreach (var i in collection)
     {
         i.SetIsSelected(i == value || (value == null && i.Value == null));
     }
 }
 private void AddNewItem(ItemViewModel item)
 {
     App.CurrentScene.Items.Add(item);
     ItemViewModel.ItemAdded(item);
 }
Esempio n. 32
0
        private void MovieListBox_ItemTap(object sender, Telerik.Windows.Controls.ListBoxItemTapEventArgs e)
        {
            ItemViewModel movieCategory = this.MovieListBox.SelectedItem as ItemViewModel;

            NavigationService.Navigate(new Uri("/VideoPage.xaml?name=" + HttpUtility.UrlEncode(movieCategory.Title) + "&url=" + HttpUtility.UrlEncode(movieCategory.URL) + "&avatar=" + HttpUtility.UrlEncode(movieCategory.ImageSource.ToString()), UriKind.Relative));
        }
Esempio n. 33
0
 private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
 {
     ItemViewModel.CleanUp();
 }
Esempio n. 34
0
        public override async void GetSpecialProperties()
        {
            ViewModel.ItemSizeVisibility = Visibility.Visible;
            ViewModel.ItemSize           = ByteSize.FromBytes(Item.FileSizeBytes).ToBinaryString().ConvertSizeAbbreviation()
                                           + " (" + ByteSize.FromBytes(Item.FileSizeBytes).Bytes.ToString("#,##0") + " " + ResourceController.GetTranslation("ItemSizeBytes") + ")";

            if (Item.IsShortcutItem)
            {
                ViewModel.ItemCreatedTimestamp  = Item.ItemDateCreated;
                ViewModel.ItemAccessedTimestamp = Item.ItemDateAccessed;
                ViewModel.LoadLinkIcon          = Item.IsLinkItem;
                if (Item.IsLinkItem || string.IsNullOrWhiteSpace(((ShortcutItem)Item).TargetPath))
                {
                    // Can't show any other property
                    return;
                }
            }

            StorageFile file = null;

            try
            {
                file = await ItemViewModel.GetFileFromPathAsync((Item as ShortcutItem)?.TargetPath ?? Item.ItemPath);
            }
            catch (Exception ex)
            {
                NLog.LogManager.GetCurrentClassLogger().Error(ex, ex.Message);
                // Could not access file, can't show any other property
                return;
            }

            using (var Thumbnail = await file.GetThumbnailAsync(ThumbnailMode.SingleItem, 80, ThumbnailOptions.UseCurrentScale))
            {
                BitmapImage icon = new BitmapImage();
                if (Thumbnail != null)
                {
                    ViewModel.FileIconSource = icon;
                    await icon.SetSourceAsync(Thumbnail);

                    ViewModel.LoadUnknownTypeGlyph = false;
                    ViewModel.LoadFileIcon         = true;
                }
            }

            if (Item.IsShortcutItem)
            {
                // Can't show any other property
                return;
            }

            ViewModel.ItemCreatedTimestamp = ListedItem.GetFriendlyDate(file.DateCreated);
            GetOtherProperties(file.Properties);

            // Get file MD5 hash
            var hashAlgTypeName = HashAlgorithmNames.Md5;

            ViewModel.ItemMD5HashProgressVisibility = Visibility.Visible;
            ViewModel.ItemMD5HashVisibility         = Visibility.Visible;
            try
            {
                ViewModel.ItemMD5Hash = await App.CurrentInstance.InteractionOperations
                                        .GetHashForFile(Item, hashAlgTypeName, TokenSource.Token, ProgressBar);
            }
            catch (Exception ex)
            {
                NLog.LogManager.GetCurrentClassLogger().Error(ex, ex.Message);
                ViewModel.ItemMD5HashCalcError = true;
            }
        }
Esempio n. 35
0
        private void MergeWithReference(ItemViewModel item, ReferenceViewModel reference)
        {
            item.Name         = reference.Name;
            item.NameWithType = reference.NameWithType;
            item.FullName     = reference.FullName;
            item.CommentId    = reference.CommentId;

            if (reference.NameInDevLangs.Count > 0)
            {
                foreach (var pair in reference.NameInDevLangs)
                {
                    item.Names[pair.Key] = pair.Value;
                }
            }
            if (reference.FullNameInDevLangs.Count > 0)
            {
                foreach (var pair in reference.FullNameInDevLangs)
                {
                    item.FullNames[pair.Key] = pair.Value;
                }
            }
            if (reference.NameWithTypeInDevLangs.Count > 0)
            {
                foreach (var pair in reference.NameWithTypeInDevLangs)
                {
                    item.NamesWithType[pair.Key] = pair.Value;
                }
            }

            // SHOULD sync with ItemViewModel & ReferenceViewModel
            // Make sure key inside Additional dictionary does not contain the same key value as ItemViewModel
            foreach (var pair in reference.Additional)
            {
                switch (pair.Key)
                {
                case "summary":
                {
                    if (pair.Value is string summary)
                    {
                        item.Summary = summary;
                    }
                    break;
                }

                case "remarks":
                {
                    if (pair.Value is string remarks)
                    {
                        item.Remarks = remarks;
                    }
                    break;
                }

                case "example":
                {
                    var examples = GetListFromObject(pair.Value);
                    if (examples != null)
                    {
                        item.Examples = examples;
                    }
                    break;
                }

                case Constants.PropertyName.Id:
                case Constants.PropertyName.Type:
                case Constants.PropertyName.Source:
                case Constants.PropertyName.Documentation:
                case "isEii":
                case "isExtensionMethod":
                case "children":
                case "assemblies":
                case "namespace":
                case "langs":
                case "syntax":
                case "overridden":
                case "overload":
                case "exceptions":
                case "seealso":
                case "see":
                    break;

                default:
                    item.Metadata[pair.Key] = pair.Value;
                    break;
                }
            }
        }
        public ActionResult ShopingCart(string quentity, string Id)
        {
            if (quentity == null || quentity == "")
            {
                quentity = "1";
            }
            RestaurantEntities db = new RestaurantEntities();

            try
            {
                int           itemId = Int32.Parse(Id);
                int           Qnty   = Int32.Parse(quentity);
                Item          item   = db.Items.SingleOrDefault(x => x.Id == itemId);
                ItemViewModel itemVM = new ItemViewModel();
                itemVM.Id          = item.Id;
                itemVM.Name        = item.Name;
                itemVM.Price       = item.Price;
                itemVM.CatId       = item.CatId;
                itemVM.Description = item.Description;

                if (Session["cart"] == null)
                {
                    List <CartCreateViewModel> list = new List <CartCreateViewModel>();

                    list.Add(new CartCreateViewModel {
                        ItemId = item.Id, ItemName = item.Name, Quentity = Qnty, Tot_price = item.Price * Qnty
                    });
                    Session["cart"] = list;
                }
                else
                {
                    List <CartCreateViewModel> list = (List <CartCreateViewModel>)Session["cart"];

                    int sz = list.Count;

                    int flag = 0;
                    int indx = 0;
                    for (int i = 0; i < sz; i++)
                    {
                        if (list[i].ItemId == item.Id)
                        {
                            flag = 1;
                            indx = i;
                            break;
                        }
                    }

                    if (flag == 1)
                    {
                        list[indx].Quentity += Qnty;
                        list[indx].Tot_price = item.Price * list[indx].Quentity;
                    }
                    else
                    {
                        list.Add(new CartCreateViewModel {
                            ItemId = item.Id, ItemName = item.Name, Quentity = Qnty, Tot_price = item.Price * Qnty
                        });
                    }


                    Session["cart"] = list;
                }
            }catch (Exception ex)
            {
            }



            return(View());
        }
Esempio n. 37
0
 public static void Validate(this ItemViewModel item, JSchema schema)
 {
     item.Value.Schema = schema;
     item.Validation.Validate(schema, item.Value.Token);
 }
Esempio n. 38
0
 public ItemSave(ItemViewModel from)
 {
     this.ModelBase    = from.Base;
     this.ModelVariant = from.Variant;
     this.DyeId        = from.Dye;
 }
 public SplitPage(ItemViewModel model)
 {
     InitializeComponent();
     BindingContext = Model = model;
 }
Esempio n. 40
0
        public async Task <ActionResult> Transfer(ItemViewModel item)
        {
            if (!ModelState.IsValid)
            {
                return(View(item));
            }
            //find transferred item in db
            var itemInOldOffice = await _db.Items.FindAsync(item.Id);

            if (itemInOldOffice == null)
            {
                return(HttpNotFound());
            }
            //if trip notebook
            if (item.ItemTypeId == 8)
            {
                item.Quantity = 1;
            }
            //check if we transfer more than we have
            if (itemInOldOffice.Quantity < item.Quantity)
            {
                // return view with error message
                ModelState.AddModelError(string.Empty, "Нельзя переместить больше, чем есть в наличии (" + itemInOldOffice.Quantity + " шт.)!");
                return(View(item));
            }

            //find item in target location
            Item itemInNewOffice;

            if (item.TargetOfficeId == 1)
            {
                //for the main office location may be null
                itemInNewOffice = await _db.Items.Where(i => i.Name == item.Name && (i.Location == null || i.Location.Id == 1)).FirstOrDefaultAsync();
            }
            else
            {
                itemInNewOffice = await _db.Items.Where(i => i.Name == item.Name && i.Location.Id == item.TargetOfficeId).FirstOrDefaultAsync();
            }

            //item doesn't exist in target location or it's a trip notebook - create new item
            if (item.ItemTypeId == 8 || itemInNewOffice == null)
            {
                itemInNewOffice = new Item
                {
                    Name        = item.Name,
                    Quantity    = item.Quantity,
                    MinQuantity = itemInOldOffice.MinQuantity,
                    ItemType    = await _db.ItemTypes.FindAsync(itemInOldOffice.ItemType.Id),
                    Location    = await _db.Offices.FindAsync(item.TargetOfficeId)
                };
                _db.Items.Add(itemInNewOffice);
                await _db.SaveChangesAsync();

                //copy attribute-value pairs from source item
                foreach (var attr in itemInOldOffice.AttributeValues)
                {
                    var newAttrValuePair = new ItemAttributeValue
                    {
                        Attribute  = await _db.ItemAttributes.FindAsync(attr.Attribute.Id),
                        ParentItem = itemInNewOffice,
                        Value      = attr.Value
                    };
                    _db.ItemAttributeValues.Add(newAttrValuePair);
                    itemInNewOffice.AttributeValues.Add(newAttrValuePair);
                }
                //cartridge
                if (item.ItemTypeId == 11)
                {
                    foreach (var printer in itemInOldOffice.Printers)
                    {
                        itemInNewOffice.Printers.Add(await _db.Printers.FindAsync(printer.Id));
                    }
                }
            }
            else
            {
                itemInNewOffice.Quantity += item.Quantity;
            }

            // decrease source item quantity
            //if trip notebook - delete
            if (item.ItemTypeId == 8)
            {
                foreach (var attr in _db.ItemAttributeValues.Where(a => a.ParentItem.Id == item.Id))
                {
                    _db.ItemAttributeValues.Remove(attr);
                }
                _db.Items.Remove(itemInOldOffice);
            }
            else
            {
                itemInOldOffice.Quantity        -= item.Quantity;
                _db.Entry(itemInOldOffice).State = EntityState.Modified;
            }

            _db.Entry(itemInNewOffice).State = EntityState.Modified;
            await _db.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
        protected void addButton_Click(object sender, EventArgs e)
        {
            if (ItemsDownList.SelectedValue != "---No Items Available---") // First Condition
            {
                if (ItemsDownList.SelectedValue != "0")                    // Second Condition for itemDropDownList
                {
                    // Text Field Check Condition
                    if (StockOutQTextBox.Text.Trim() != "" && Convert.ToInt32(StockAvailableQTextBox.Text) < Convert.ToInt32(StockOutQTextBox.Text))
                    {
                        outputlabel.InnerHtml = "Available Quantity is Less";
                    }
                    else if (StockOutQTextBox.Text.Trim() == "")
                    {
                        outputlabel.InnerHtml = "Please Input Stock Out Quantity";
                    }
                    else
                    {
                        ItemViewModel itemViewModel = new ItemViewModel();
                        itemViewModel.ItemId          = Convert.ToInt32(ItemsDownList.SelectedValue);
                        itemViewModel.ItemName        = ItemsDownList.SelectedItem.ToString();
                        itemViewModel.CompanyName     = companyDropDownList.SelectedItem.ToString();
                        itemViewModel.StockAQQuantity = Convert.ToInt32(StockAvailableQTextBox.Text);
                        itemViewModel.Quantity        = Convert.ToInt32(StockOutQTextBox.Text.Trim());

                        if (ViewState["itemVS"] == null)
                        {
                            ItemViewModels.Add(itemViewModel);
                            ViewState["itemVS"]   = ItemViewModels;
                            outputlabel.InnerHtml = "Item Added to Card Successfully";
                        }
                        else
                        {
                            ItemViewModels = (List <ItemViewModel>)ViewState["itemVS"];
                            foreach (ItemViewModel item in ItemViewModels.ToList())
                            {
                                try
                                {
                                    if (item.ItemId == itemViewModel.ItemId)
                                    {
                                        var existItem = ItemViewModels.Find(x => x.ItemId == itemViewModel.ItemId);
                                        if (existItem != null)
                                        {
                                            // Avobe code are corretly working
                                            int quantity = Convert.ToInt32(item.Quantity + itemViewModel.Quantity);
                                            if (quantity <= Convert.ToInt32(itemViewModel.StockAQQuantity))
                                            {
                                                item.Quantity        += itemViewModel.Quantity;
                                                outputlabel.InnerHtml = "Stock Out Qunatity Increased";
                                            }
                                            else
                                            {
                                                outputlabel.InnerHtml = "Available Quantity is Less";
                                            }
                                        }
                                    }

                                    else if (item.ItemId != itemViewModel.ItemId)
                                    {
                                        var existsItem = ItemViewModels.Find(x => x.ItemId == itemViewModel.ItemId);
                                        if (existsItem == null)
                                        {
                                            ItemViewModels.Add(itemViewModel);
                                            ViewState["itemVS"]   = ItemViewModels;
                                            outputlabel.InnerHtml = "Item Added to Card Successfully";
                                        }
                                    }
                                }
                                catch (Exception a)
                                {
                                    System.Diagnostics.Debug.WriteLine("Sorry! Your Operation Did not Complete" + a.Message);
                                }
                            }
                        } // Third Condition End here

                        stockOutGridView.DataSource = ItemViewModels;
                        stockOutGridView.DataBind();
                        ClearValue();
                    }
                }
            }
        }
Esempio n. 42
0
        protected override void OnInit(EventArgs e)
        {
            try
            {
                base.OnInit(e);

                JavaScript.RequestRegistration(CommonJs.DnnPlugins);

                var fileId = Convert.ToInt32(this.Request.Params["FileId"]);
                this.file     = FileManager.Instance.GetFile(fileId, true);
                this.fileItem = this.controller.GetFile(fileId);
                this.folder   = FolderManager.Instance.GetFolder(this.file.FolderId);

                this.SaveButton.Click   += this.OnSaveClick;
                this.CancelButton.Click += this.OnCancelClick;

                if (FolderPermissionController.CanViewFolder((FolderInfo)this.folder))
                {
                    var mef = new ExtensionPointManager();
                    var preViewPanelExtension = mef.GetUserControlExtensionPointFirstByPriority("DigitalAssets", "PreviewInfoPanelExtensionPoint");
                    this.previewPanelControl = this.Page.LoadControl(preViewPanelExtension.UserControlSrc);
                    this.PreviewPanelContainer.Controls.Add(this.previewPanelControl);

                    var fileFieldsExtension = mef.GetUserControlExtensionPointFirstByPriority("DigitalAssets", "FileFieldsControlExtensionPoint");
                    this.fileFieldsControl    = this.Page.LoadControl(fileFieldsExtension.UserControlSrc);
                    this.fileFieldsControl.ID = this.fileFieldsControl.GetType().BaseType.Name;
                    this.FileFieldsContainer.Controls.Add(this.fileFieldsControl);

                    this.PrepareFilePreviewInfoControl();
                    this.PrepareFileFieldsControl();

                    // Tab Extension Point
                    var tabContentControlsInstances = new List <PropertiesTabContentControl>();
                    foreach (var extension in mef.GetEditPageTabExtensionPoints("DigitalAssets", "FilePropertiesTab"))
                    {
                        if (FolderPermissionController.HasFolderPermission(this.folder.FolderPermissions, extension.Permission))
                        {
                            var liElement = new HtmlGenericControl("li")
                            {
                                InnerHtml = "<a href=\"#" + extension.EditPageTabId + "\">" + extension.Text + "</a>",
                            };
                            liElement.Attributes.Add("class", extension.CssClass);
                            liElement.Attributes.Add("id", extension.EditPageTabId + "_tab");
                            this.Tabs.Controls.Add(liElement);

                            var container = new PanelTabExtensionControl {
                                PanelId = extension.EditPageTabId
                            };
                            var control = (PortalModuleBase)this.Page.LoadControl(extension.UserControlSrc);
                            control.ID = Path.GetFileNameWithoutExtension(extension.UserControlSrc);
                            control.ModuleConfiguration = this.ModuleConfiguration;
                            var contentControl = control as PropertiesTabContentControl;
                            if (contentControl != null)
                            {
                                contentControl.OnItemUpdated += this.OnItemUpdated;
                                tabContentControlsInstances.Add(contentControl);
                            }

                            container.Controls.Add(control);
                            this.TabsPanel.Controls.Add(container);
                        }
                    }

                    this.tabContentControls = tabContentControlsInstances.ToList();
                }
            }
            catch (Exception ex)
            {
                Exceptions.ProcessModuleLoadException(this, ex);
            }
        }
Esempio n. 43
0
        private void AddToTree(ItemViewModel item, List <TreeItem> tree)
        {
            var treeItem = ConvertToTreeItem(item);

            tree.Add(treeItem);
        }
Esempio n. 44
0
 void ItemInfoFooter_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
 {
     Item = DataContext as ItemViewModel;
 }
Esempio n. 45
0
 public ModelWrapper(ItemViewModel item, FileModel fileModel)
 {
     PrimaryItem = item;
     FileModel   = fileModel;
 }
Esempio n. 46
0
        public static List <ContextMenuFlyoutItemViewModel> GetBaseContextCommands(NamedPipeAsAppServiceConnection connection, CurrentInstanceViewModel currentInstanceViewModel, ItemViewModel itemViewModel, BaseLayoutCommandsViewModel commandsViewModel, bool shiftPressed, bool showOpenMenu)
        {
            var menuItemsList = ShellContextmenuHelper.SetShellContextmenu(GetBaseLayoutMenuItems(currentInstanceViewModel, itemViewModel, commandsViewModel), shiftPressed, showOpenMenu, connection, itemViewModel.WorkingDirectory, new List <ListedItem>());

            menuItemsList = Filter(items: menuItemsList, shiftPressed: shiftPressed, currentInstanceViewModel: currentInstanceViewModel, selectedItems: new List <ListedItem>());
            return(menuItemsList);
        }
 private void ItemDetailGeneralView_OnAppearing(object sender, EventArgs e)
 {
     vm = BindingContext as ItemViewModel;
 }
Esempio n. 48
0
        private async void SetAddressBarSuggestions(AutoSuggestBox sender, int maxSuggestions = 7)
        {
            try
            {
                IList <ListedItem> suggestions = null;
                var expandedPath = StorageFileExtensions.GetPathWithoutEnvironmentVariable(sender.Text);
                var folderPath   = Path.GetDirectoryName(expandedPath) ?? expandedPath;
                var folder       = await ItemViewModel.GetFolderWithPathFromPathAsync(folderPath);

                var currPath = await folder.GetFoldersWithPathAsync(Path.GetFileName(expandedPath), (uint)maxSuggestions);

                if (currPath.Count() >= maxSuggestions)
                {
                    suggestions = currPath.Select(x => new ListedItem(null)
                    {
                        ItemPath = x.Path, ItemName = x.Folder.Name
                    }).ToList();
                }
                else if (currPath.Any())
                {
                    var subPath = await currPath.First().GetFoldersWithPathAsync((uint)(maxSuggestions - currPath.Count()));

                    suggestions = currPath.Select(x => new ListedItem(null)
                    {
                        ItemPath = x.Path, ItemName = x.Folder.Name
                    }).Concat(
                        subPath.Select(x => new ListedItem(null)
                    {
                        ItemPath = x.Path, ItemName = Path.Combine(currPath.First().Folder.Name, x.Folder.Name)
                    })).ToList();
                }
                else
                {
                    suggestions = new List <ListedItem>()
                    {
                        new ListedItem(null)
                        {
                            ItemPath = App.CurrentInstance.FilesystemViewModel.WorkingDirectory,
                            ItemName = ResourceController.GetTranslation("NavigationToolbarVisiblePathNoResults")
                        }
                    };
                }

                // NavigationBarSuggestions becoming empty causes flickering of the suggestion box
                // Here we check whether at least an element is in common between old and new list
                if (!NavigationBarSuggestions.IntersectBy(suggestions, x => x.ItemName).Any())
                {
                    // No elemets in common, update the list in-place
                    for (int si = 0; si < suggestions.Count; si++)
                    {
                        if (si < NavigationBarSuggestions.Count)
                        {
                            NavigationBarSuggestions[si].ItemName = suggestions[si].ItemName;
                            NavigationBarSuggestions[si].ItemPath = suggestions[si].ItemPath;
                        }
                        else
                        {
                            NavigationBarSuggestions.Add(suggestions[si]);
                        }
                    }
                    while (NavigationBarSuggestions.Count > suggestions.Count)
                    {
                        NavigationBarSuggestions.RemoveAt(NavigationBarSuggestions.Count - 1);
                    }
                }
                else
                {
                    // At least an element in common, show animation
                    foreach (var s in NavigationBarSuggestions.ExceptBy(suggestions, x => x.ItemName).ToList())
                    {
                        NavigationBarSuggestions.Remove(s);
                    }
                    foreach (var s in suggestions.ExceptBy(NavigationBarSuggestions, x => x.ItemName).ToList())
                    {
                        NavigationBarSuggestions.Insert(suggestions.IndexOf(s), s);
                    }
                }
            }
            catch
            {
                NavigationBarSuggestions.Clear();
                NavigationBarSuggestions.Add(new ListedItem(null)
                {
                    ItemPath = App.CurrentInstance.FilesystemViewModel.WorkingDirectory,
                    ItemName = ResourceController.GetTranslation("NavigationToolbarVisiblePathNoResults")
                });
            }
        }
Esempio n. 49
0
        public async void CheckPathInput(ItemViewModel instance, string CurrentInput)
        {
            if (CurrentInput != instance.WorkingDirectory || App.CurrentInstance.ContentFrame.CurrentSourcePageType == typeof(YourHome))
            {
                //(App.CurrentInstance.OperationsControl as RibbonArea).RibbonViewModel.HomeItems.isEnabled = false;
                //(App.CurrentInstance.OperationsControl as RibbonArea).RibbonViewModel.ShareItems.isEnabled = false;

                if (CurrentInput.Equals("Home", StringComparison.OrdinalIgnoreCase) || CurrentInput.Equals(ResourceController.GetTranslation("NewTab"), StringComparison.OrdinalIgnoreCase))
                {
                    await App.CurrentInstance.FilesystemViewModel.SetWorkingDirectory(ResourceController.GetTranslation("NewTab"));

                    App.CurrentInstance.ContentFrame.Navigate(typeof(YourHome), ResourceController.GetTranslation("NewTab"), new SuppressNavigationTransitionInfo());
                }
                else
                {
                    switch (CurrentInput.ToLower())
                    {
                    case "%temp%":
                        CurrentInput = AppSettings.TempPath;
                        break;

                    case "%appdata":
                        CurrentInput = AppSettings.AppDataPath;
                        break;

                    case "%homepath%":
                        CurrentInput = AppSettings.HomePath;
                        break;

                    case "%windir%":
                        CurrentInput = AppSettings.WinDirPath;
                        break;
                    }

                    try
                    {
                        var item = await DrivesManager.GetRootFromPath(CurrentInput);

                        await StorageFileExtensions.GetFolderFromPathAsync(CurrentInput, item);

                        App.CurrentInstance.ContentFrame.Navigate(AppSettings.GetLayoutType(), CurrentInput); // navigate to folder
                    }
                    catch (Exception)                                                                         // Not a folder or inaccessible
                    {
                        try
                        {
                            var item = await DrivesManager.GetRootFromPath(CurrentInput);

                            await StorageFileExtensions.GetFileFromPathAsync(CurrentInput, item);

                            await Interaction.InvokeWin32Component(CurrentInput);
                        }
                        catch (Exception ex) // Not a file or not accessible
                        {
                            // Launch terminal application if possible
                            foreach (var item in AppSettings.TerminalsModel.Terminals)
                            {
                                if (item.Path.Equals(CurrentInput, StringComparison.OrdinalIgnoreCase) || item.Path.Equals(CurrentInput + ".exe", StringComparison.OrdinalIgnoreCase))
                                {
                                    if (App.Connection != null)
                                    {
                                        var value = new ValueSet();
                                        value.Add("Application", item.Path);
                                        value.Add("Arguments", String.Format(item.Arguments, App.CurrentInstance.FilesystemViewModel.WorkingDirectory));
                                        await App.Connection.SendMessageAsync(value);
                                    }
                                    return;
                                }
                            }

                            var dialog = new ContentDialog()
                            {
                                Title           = "Invalid item",
                                Content         = "The item referenced is either invalid or inaccessible.\nMessage:\n\n" + ex.Message,
                                CloseButtonText = "OK"
                            };

                            await dialog.ShowAsync();
                        }
                    }
                }

                App.CurrentInstance.NavigationToolbar.PathControlDisplayText = App.CurrentInstance.FilesystemViewModel.WorkingDirectory;
            }
        }
Esempio n. 50
0
 public IActionResult Edit(ItemViewModel itemModel)
 {
     service.Edit(itemModel.Todo.Id, itemModel.Todo.Title, itemModel.Todo.IsUrgent, itemModel.Todo.IsDone);
     return(RedirectToAction("Index"));
 }
 public int GetDetail(long ID, out ItemViewModel model)
 {
     return(_itemDAO.GetDetail(ID, out model));
 }
Esempio n. 52
0
        private async Task SetPathBoxDropDownFlyout(MenuFlyout flyout, PathBoxItem pathItem)
        {
            var nextPathItemTitle = App.CurrentInstance.NavigationToolbar.PathComponents
                                    [App.CurrentInstance.NavigationToolbar.PathComponents.IndexOf(pathItem) + 1].Title;
            IList <StorageFolderWithPath> childFolders = new List <StorageFolderWithPath>();

            try
            {
                var folder = await ItemViewModel.GetFolderWithPathFromPathAsync(pathItem.Path);

                childFolders = await folder.GetFoldersWithPathAsync(string.Empty);
            }
            catch
            {
                // Do nothing.
            }
            finally
            {
                flyout.Items?.Clear();
            }

            if (childFolders.Count == 0)
            {
                var flyoutItem = new MenuFlyoutItem
                {
                    Icon = new FontIcon {
                        FontFamily = Application.Current.Resources["FluentUIGlyphs"] as FontFamily, Glyph = "\uEC17"
                    },
                    Text = ResourceController.GetTranslation("SubDirectoryAccessDenied"),
                    //Foreground = (SolidColorBrush)Application.Current.Resources["SystemControlErrorTextForegroundBrush"],
                    FontSize = 12
                };
                flyout.Items.Add(flyoutItem);
                return;
            }

            var boldFontWeight = new FontWeight {
                Weight = 800
            };
            var normalFontWeight = new FontWeight {
                Weight = 400
            };
            var customGlyphFamily = Application.Current.Resources["FluentUIGlyphs"] as FontFamily;

            var workingPath = App.CurrentInstance.NavigationToolbar.PathComponents
                              [App.CurrentInstance.NavigationToolbar.PathComponents.Count - 1].
                              Path.TrimEnd(Path.DirectorySeparatorChar);

            foreach (var childFolder in childFolders)
            {
                var isPathItemFocused = childFolder.Item.Name == nextPathItemTitle;

                var flyoutItem = new MenuFlyoutItem
                {
                    Icon = new FontIcon
                    {
                        FontFamily = customGlyphFamily,
                        Glyph      = "\uEA5A",
                        FontWeight = isPathItemFocused ? boldFontWeight : normalFontWeight
                    },
                    Text       = childFolder.Item.Name,
                    FontSize   = 12,
                    FontWeight = isPathItemFocused ? boldFontWeight : normalFontWeight
                };

                if (workingPath != childFolder.Path)
                {
                    flyoutItem.Click += (sender, args) => App.CurrentInstance.ContentFrame.Navigate(AppSettings.GetLayoutType(), childFolder.Path);
                }

                flyout.Items.Add(flyoutItem);
            }
        }
Esempio n. 53
0
 public GameItemRemoveFileCommand(ItemViewModel itemViewModel)
 {
     this.itemViewModel = itemViewModel;
 }
        private void Item_NewLoaded(object sender, RoutedEventArgs e)
        {
            ItemControlBase item = (ItemControlBase)sender;

            ItemViewModel.ItemAdded(item.Item);
        }
 public TableSource(ItemsViewController controller)
 {
     this.controller     = controller;
     assignmentViewModel = ServiceContainer.Resolve <AssignmentViewModel>();
     itemViewModel       = ServiceContainer.Resolve <ItemViewModel>();
 }
Esempio n. 56
0
        public async void CheckPathInput(ItemViewModel instance, string currentInput, string currentSelectedPath)
        {
            if (currentSelectedPath == currentInput)
            {
                return;
            }

            if (currentInput != instance.WorkingDirectory || App.CurrentInstance.ContentFrame.CurrentSourcePageType == typeof(YourHome))
            {
                //(App.CurrentInstance.OperationsControl as RibbonArea).RibbonViewModel.HomeItems.isEnabled = false;
                //(App.CurrentInstance.OperationsControl as RibbonArea).RibbonViewModel.ShareItems.isEnabled = false;

                if (currentInput.Equals("Home", StringComparison.OrdinalIgnoreCase) || currentInput.Equals(ResourceController.GetTranslation("NewTab"), StringComparison.OrdinalIgnoreCase))
                {
                    await App.CurrentInstance.FilesystemViewModel.SetWorkingDirectory(ResourceController.GetTranslation("NewTab"));

                    App.CurrentInstance.ContentFrame.Navigate(typeof(YourHome), ResourceController.GetTranslation("NewTab"), new SuppressNavigationTransitionInfo());
                }
                else
                {
                    var workingDir = string.IsNullOrEmpty(App.CurrentInstance.FilesystemViewModel.WorkingDirectory)
                        ? AppSettings.HomePath
                        : App.CurrentInstance.FilesystemViewModel.WorkingDirectory;

                    currentInput = StorageFileExtensions.GetPathWithoutEnvironmentVariable(currentInput);
                    if (currentSelectedPath == currentInput)
                    {
                        return;
                    }
                    var item = await DrivesManager.GetRootFromPath(currentInput);

                    try
                    {
                        var pathToNavigate = (await StorageFileExtensions.GetFolderWithPathFromPathAsync(currentInput, item)).Path;
                        App.CurrentInstance.ContentFrame.Navigate(AppSettings.GetLayoutType(), pathToNavigate); // navigate to folder
                    }
                    catch (Exception)                                                                           // Not a folder or inaccessible
                    {
                        try
                        {
                            var pathToInvoke = (await StorageFileExtensions.GetFileWithPathFromPathAsync(currentInput, item)).Path;
                            await Interaction.InvokeWin32Component(pathToInvoke);
                        }
                        catch (Exception ex) // Not a file or not accessible
                        {
                            // Launch terminal application if possible
                            foreach (var terminal in AppSettings.TerminalController.Model.Terminals)
                            {
                                if (terminal.Path.Equals(currentInput, StringComparison.OrdinalIgnoreCase) || terminal.Path.Equals(currentInput + ".exe", StringComparison.OrdinalIgnoreCase))
                                {
                                    if (App.Connection != null)
                                    {
                                        var value = new ValueSet
                                        {
                                            { "WorkingDirectory", workingDir },
                                            { "Application", terminal.Path },
                                            { "Arguments", string.Format(terminal.Arguments,
                                                                         Helpers.PathNormalization.NormalizePath(App.CurrentInstance.FilesystemViewModel.WorkingDirectory)) }
                                        };
                                        await App.Connection.SendMessageAsync(value);
                                    }
                                    return;
                                }
                            }

                            try
                            {
                                if (!await Launcher.LaunchUriAsync(new Uri(currentInput)))
                                {
                                    throw new Exception();
                                }
                            }
                            catch
                            {
                                await DialogDisplayHelper.ShowDialog(ResourceController.GetTranslation("InvalidItemDialogTitle"),
                                                                     string.Format(ResourceController.GetTranslation("InvalidItemDialogContent"), Environment.NewLine, ex.Message));
                            }
                        }
                    }
                }

                App.CurrentInstance.NavigationToolbar.PathControlDisplayText = App.CurrentInstance.FilesystemViewModel.WorkingDirectory;
            }
        }
Esempio n. 57
0
 public static ItemViewModel OnlyValid(ItemViewModel i)
 {
     return i != null && i.Value != null ? i : null;
 }
 public ItemsViewController(IntPtr handle) : base(handle)
 {
     assignmentViewModel = ServiceContainer.Resolve <AssignmentViewModel>();
     itemViewModel       = ServiceContainer.Resolve <ItemViewModel>();
 }
 public ActionResult Manage(int id = 0)
 {
     ItemViewModel<int> model = new ItemViewModel<int>();
     model.Item = id;
     return View(model);
 }
Esempio n. 60
0
        protected void OnItemTapped(object sender, EventArgs args)
        {
            ItemViewModel itemViewModel = (ItemViewModel)sender;

            NavigationService.NavigateToValidationSessionDetailAsync(itemViewModel.Id, itemViewModel.Name);
        }