ListBoxItem used by the languages listBox.
Inheritance: System.Windows.Controls.ListBoxItem
コード例 #1
0
        private void Localization_OnLoaded(object sender, RoutedEventArgs e)
        {
            foreach (var resourceDictionary in Application.Current.Resources.MergedDictionaries)
            {
                var imageItem = new ImageListBoxItem();
                imageItem.Tag = resourceDictionary.Source.OriginalString;
                imageItem.Content = resourceDictionary.Source.OriginalString;

                if (resourceDictionary.Source.OriginalString.Contains("StringResource"))
                {
                    imageItem.Image = FindResource("Vector.Translate") as Canvas;

                    #region Name

                    var subs = resourceDictionary.Source.OriginalString.Substring(resourceDictionary.Source.OriginalString.IndexOf("StringResource"));
                    var pieces = subs.Split(new[] {'.'}, StringSplitOptions.RemoveEmptyEntries);

                    if (pieces.Length == 2)
                    {
                        imageItem.Author = "Recognized as English";
                    }
                    else if (pieces.Length == 3)
                    {
                        imageItem.Author = "Recognized as " + pieces[1];
                    }

                    #endregion   
                }
                else
                {
                    imageItem.IsEnabled = false;
                    imageItem.Image = FindResource("Vector.No") as Canvas;
                    imageItem.Author = "This is a style dictionary.";
                }

                ResourceListBox.Items.Add(imageItem);
            }

            ResourceListBox.SelectedIndex = ResourceListBox.Items.Count - 1;
        }
コード例 #2
0
        private void Add_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            var ofd = new OpenFileDialog
            {
                AddExtension = true,
                CheckFileExists = true,
                Title = "Open a Resource Dictionay",
                Filter = "Resource Dictionay (*.xaml)|*.xaml;"
            };

            var result = ofd.ShowDialog();

            if (result.HasValue && result.Value)
            {
                #region Validation

                var subs = ofd.FileName.Substring(ofd.FileName.IndexOf("StringResource"));

                if (Application.Current.Resources.MergedDictionaries.Any(x => x.Source.OriginalString.Contains(subs)))
                {
                    Dialog.Ok("Action Denied", "You can't add a resource with the same name.",
                        "Try renaming like: StringResource.[Language Code].xaml");

                    return;
                }

                var pieces = subs.Split(new[] { '.' }, StringSplitOptions.RemoveEmptyEntries);

                if (pieces.Length != 3)
                {
                    Dialog.Ok("Action Denied", "Filename wrong format.",
                        "Try renaming like: StringResource.[Language Code].xaml");

                    return;
                }

                var culture = new CultureInfo(pieces[1]);

                if (culture.EnglishName.Contains("Unknown"))
                {
                    Dialog.Ok("Action Denied", "Unknown Language.", $"The {pieces[1]} was not recognized as a valid language code.");

                    return;
                }

                #endregion

                if (LocalizationHelper.ImportStringResource(ofd.FileName))
                {
                    var resourceDictionary = Application.Current.Resources.MergedDictionaries.LastOrDefault();

                    var imageItem = new ImageListBoxItem();
                    imageItem.Tag = resourceDictionary.Source.OriginalString;
                    imageItem.Content = resourceDictionary.Source.OriginalString;
                    imageItem.Image = FindResource("Vector.Translate") as Canvas;
                    imageItem.Author = "Recognized as " + pieces[1];
                    ResourceListBox.Items.Add(imageItem);
                }
            }
        }
コード例 #3
0
ファイル: Editor.xaml.cs プロジェクト: dbremner/ScreenToGif
        private void Copy_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            Pause();

            var selected = FrameListView.SelectedItems.OfType<FrameListBoxItem>().ToList();
            var list = selected.Select(item => ListFrames[item.FrameNumber]).ToList();

            if (!Util.Clipboard.Copy(list))
            {
                Dialog.Ok("Clipboard Exception", "Impossible to copy selected frames.",
                    "Something wrong happened, please report this issue (by sending the exception log).");
                return;
            }

            #region Item

            var imageItem = new ImageListBoxItem();
            imageItem.Tag = String.Format("Frames: {0}", String.Join(", ", selected.Select(x => x.FrameNumber)));
            imageItem.Author = DateTime.Now.ToString("hh:mm:ss");

            if (list.Count > 1)
            {
                imageItem.Image = FindResource("Vector.ImageStack") as Canvas;
                imageItem.Content = String.Format("{0} Images", list.Count);
            }
            else
            {
                imageItem.Image = FindResource("Vector.Image") as Canvas;
                imageItem.Content = String.Format("{0} Image", list.Count);
            }

            #endregion

            ClipboardListView.Items.Add(imageItem);
            ClipboardListView.SelectedIndex = ClipboardListView.Items.Count - 1;

            ShowPanel(PanelType.Clipboard, FindResource("Editor.Edit.Clipboard").ToString(), "Vector.Paste");
        }
コード例 #4
0
ファイル: Editor.xaml.cs プロジェクト: dbremner/ScreenToGif
        private void Cut_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            e.Handled = true;
            Pause();

            #region Validation

            if (FrameListView.SelectedItems.Count == FrameListView.Items.Count)
            {
                Dialog.Ok(FindResource("Editor.Clipboard.InvalidCut.Title").ToString(), 
                    FindResource("Editor.Clipboard.InvalidCut.Instruction").ToString(), 
                    FindResource("Editor.Clipboard.InvalidCut.Message").ToString(), Dialog.Icons.Info);
                CutButton.IsEnabled = true;
                return;
            }

            #endregion

            ActionStack.Did(ListFrames);

            var selected = FrameListView.SelectedItems.OfType<FrameListBoxItem>().ToList();
            var list = selected.Select(item => ListFrames[item.FrameNumber]).ToList();

            FrameListView.SelectedIndex = -1;

            if (!Util.Clipboard.Cut(list))
            {
                Dialog.Ok("Clipboard Exception", "Impossible to cut selected frames.",
                    "Something wrong happened, please report this issue (by sending the exception log).");

                Undo_Executed(null, null);

                return;
            }

            selected.OrderByDescending(x => x.FrameNumber).ToList().ForEach(x => ListFrames.RemoveAt(x.FrameNumber));
            selected.OrderByDescending(x => x.FrameNumber).ToList().ForEach(x => FrameListView.Items.Remove(x));

            AdjustFrameNumbers(selected[0].FrameNumber);
            SelectNear(selected[0].FrameNumber);

            #region Item

            var imageItem = new ImageListBoxItem();
            imageItem.Author = DateTime.Now.ToString("hh:mm:ss");

            if (selected.Count > 1)
            {
                imageItem.Tag = String.Format("Frames: {0}", String.Join(", ", selected.Select(x => x.FrameNumber)));
                imageItem.Image = FindResource("Vector.ImageStack") as Canvas;
                imageItem.Content = String.Format("{0} Images", list.Count);
            }
            else
            {
                imageItem.Tag = String.Format("Frame: {0}", selected[0].FrameNumber);
                imageItem.Image = FindResource("Vector.Image") as Canvas;
                imageItem.Content = String.Format("{0} Image", list.Count);
            }

            #endregion

            ClipboardListView.Items.Add(imageItem);
            ClipboardListView.SelectedIndex = ClipboardListView.Items.Count - 1;

            ShowPanel(PanelType.Clipboard, FindResource("Editor.Edit.Clipboard").ToString(), "Vector.Paste");
        }
コード例 #5
0
ファイル: Editor.xaml.cs プロジェクト: akappel/screentogif
        private void Cut_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            e.Handled = true;
            Pause();

            #region Validation

            if (FrameListView.SelectedItems.Count == FrameListView.Items.Count)
            {
                Dialog.Ok("Cut Operation", "You can't cut all frames.", "The recording needs at least one frame.", Dialog.Icons.Info);
                CutButton.IsEnabled = true;
                return;
            }

            #endregion

            ActionStack.Did(ListFrames);

            var selected = FrameListView.SelectedItems.OfType<FrameListBoxItem>().ToList();
            var list = selected.Select(item => ListFrames[item.FrameNumber]).ToList();

            FrameListView.SelectedItem = null;

            selected.OrderByDescending(x => x.FrameNumber).ToList().ForEach(x => ListFrames.RemoveAt(x.FrameNumber));
            selected.OrderByDescending(x => x.FrameNumber).ToList().ForEach(x => FrameListView.Items.Remove(x));

            list = list.CopyToClipboard(true); //Maybe add to a Clipboard class helper that handles all requests?
            ClipboardListView.DataContext = list;

            AdjustFrameNumbers(selected[0].FrameNumber);
            SelectNear(selected[0].FrameNumber);

            #region Item

            var imageItem = new ImageListBoxItem();
            imageItem.Author = DateTime.Now.ToString("hh:mm:ss");

            if (selected.Count > 1)
            {
                imageItem.Tag = String.Format("Frames: {0}", String.Join(", ", selected.Select(x => x.FrameNumber)));
                imageItem.Image = FindResource("Vector.ImageStack") as Canvas;
                imageItem.Content = String.Format("{0} Images", list.Count);
            }
            else
            {
                imageItem.Tag = String.Format("Frame: {0}", selected[0].FrameNumber);
                imageItem.Image = FindResource("Vector.Image") as Canvas;
                imageItem.Content = String.Format("{0} Image", list.Count);
            }

            #endregion

            //var imageList = new List<ImageListBoxItem>() { imageItem };
            ClipboardListView.Items.Clear();
            ClipboardListView.Items.Add(imageItem);

            ShowPanel(PanelType.Clipboard, "Clipboard", "Vector.Paste");
        }
コード例 #6
0
ファイル: Editor.xaml.cs プロジェクト: akappel/screentogif
        private void Copy_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            Pause();

            var selected = FrameListView.SelectedItems.OfType<FrameListBoxItem>().ToList();

            #region Validation

            if (!selected.Any())
            {
                Dialog.Ok("Copy Operation", "No frames selected.", "You need to select at least one frame.", Dialog.Icons.Info);
                return;
            }

            #endregion

            var list = selected.Select(item => ListFrames[item.FrameNumber]).ToList();

            list = list.CopyToClipboard(); //Maybe add to a Clipboard class helper that handles all requests?

            ClipboardListView.DataContext = list;

            #region Item

            var imageItem = new ImageListBoxItem();
            imageItem.Tag = String.Format("Frames: {0}", String.Join(", ", selected.Select(x => x.FrameNumber)));
            imageItem.Author = DateTime.Now.ToString("hh:mm:ss");

            if (list.Count > 1)
            {
                imageItem.Image = FindResource("Vector.ImageStack") as Canvas;
                imageItem.Content = String.Format("{0} Images", list.Count);
            }
            else
            {
                imageItem.Image = FindResource("Vector.Image") as Canvas;
                imageItem.Content = String.Format("{0} Image", list.Count);
            }

            #endregion

            //var imageList = new List<ImageListBoxItem>() { imageItem };
            ClipboardListView.Items.Clear();
            ClipboardListView.Items.Add(imageItem);

            ShowPanel(PanelType.Clipboard, "Clipboard", "Vector.Paste");
        }