Esempio n. 1
0
            public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
            {
                if (value == null || parameter == null)
                {
                    return("-");
                }

                ProjectNode  node    = value as ProjectNode;
                ValuePreview preview = parameter as ValuePreview;

                //long offset = preview.Offset;
                //IReadOnlyList<byte> data = node[0, node.Length];

                //if (offset < 0 || offset >= data.Count)
                //	return "-";

                try
                {
                    return(Datatypes.Helpers.ToString(typeof(_Type), node.Data, (int)preview.Offset));
                }
                catch
                {
                    return("-");
                }
            }
Esempio n. 2
0
        private void View_ValuePreview(object sender, RoutedEventArgs e)
        {
            if (_IsCheckedToggling)
            {
                return;
            }

            bool active;

            if (sender is MenuItem)
            {
                _IsCheckedToggling             = true;
                View_ValuePreview_TB.IsChecked = active = (sender as MenuItem).IsChecked;
                _IsCheckedToggling             = false;
            }
            else if (sender is ToggleButton)
            {
                _IsCheckedToggling = true;
                View_ValuePreview_Menu.IsChecked = active = (sender as ToggleButton).IsChecked.GetValueOrDefault(false);
                _IsCheckedToggling = false;
            }
            else
            {
                return;
            }

            if (!active)             // <- Logic flipped as we're triggered after check was updated!
            {
                // Remove value preview panel
                if (_ValuePreview == null)
                {
                    throw new Exception("Invalid internal state! (value preview == null)");
                }
                Tools.Remove(_ValuePreview);
                _ValuePreview = null;
            }
            else
            {
                // Add value preview panel
                if (_ValuePreview != null)
                {
                    throw new Exception("Invalid internal state! (value preview != null)");
                }
                _ValuePreview         = new Tools.ValuePreview(PrjView);
                _ValuePreview.Project = CurrentProject;
                Tools.Add(_ValuePreview);
            }
        }