Exemple #1
0
        public DiffControl()
        {
            InitializeComponent();

            revertButton.Content = PresentationResourceService.GetImage("Icons.16x16.UndoIcon");
            copyButton.Content   = PresentationResourceService.GetImage("Icons.16x16.CopyIcon");
        }
Exemple #2
0
        public ICollection BuildItems(Codon codon, object owner)
        {
            ArrayList list = new ArrayList();

            foreach (PadDescriptor padContent in WorkbenchSingleton.Workbench.PadContentCollection)
            {
                if (padContent.Category == Category)
                {
                    var item = new System.Windows.Controls.MenuItem();
                    item.Header = ICSharpCode.Core.Presentation.MenuService.ConvertLabel(StringParser.Parse(padContent.Title));
                    if (!string.IsNullOrEmpty(padContent.Icon))
                    {
                        item.Icon = PresentationResourceService.GetImage(padContent.Icon);
                    }
                    item.Command = new BringPadToFrontCommand(padContent);
                    if (!string.IsNullOrEmpty(padContent.Shortcut))
                    {
                        var kg = Core.Presentation.MenuService.ParseShortcut(padContent.Shortcut);
                        WorkbenchSingleton.MainWindow.InputBindings.Add(
                            new System.Windows.Input.InputBinding(item.Command, kg)
                            );
                        item.InputGestureText = kg.GetDisplayStringForCulture(Thread.CurrentThread.CurrentUICulture);
                    }

                    list.Add(item);
                }
            }
            return(list);
        }
Exemple #3
0
 static BitmapSource GetImage(string name)
 {
     try {
         return(PresentationResourceService.GetBitmapSource(name));
     } catch (Exception) {
         return(null);                // image isn't needed necessarily
     }
 }
        /// <summary>
        /// Converts a resource identifier string to a Wpf imagesource.
        /// </summary>
        /// <param name="value">The value produced by the binding source.</param>
        /// <param name="targetType">The type of the binding target property.</param>
        /// <param name="parameter">The converter parameter to use.</param>
        /// <param name="culture">The culture to use in the converter.</param>
        /// <returns>
        /// A converted value. If the method returns null, the valid null value is used.
        /// </returns>
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value is string resourceIdentifier)
            {
                return(PresentationResourceService.GetBitmapSource(resourceIdentifier));
            }

            return(Binding.DoNothing);
        }
Exemple #5
0
        internal static object CreateToolBarItemContent(Codon codon)
        {
            object result  = null;
            Image  image   = null;
            Label  label   = null;
            bool   isImage = false;
            bool   isLabel = false;

            if (codon.Properties.Contains("icon"))
            {
                image = new Image
                {
                    Source = PresentationResourceService.GetBitmapSource(StringParser.Parse(codon.Properties["icon"])),
                    Height = 16
                };
                image.SetResourceReference(FrameworkElement.StyleProperty, ToolBarService.ImageStyleKey);
                isImage = true;
            }
            if (codon.Properties.Contains("label"))
            {
                label = new Label
                {
                    Content = StringParser.Parse(codon.Properties["label"]),
                    Padding = new Thickness(0),
                    VerticalContentAlignment = VerticalAlignment.Center
                };
                isLabel = true;
            }

            if (isImage && isLabel)
            {
                var panel = new StackPanel
                {
                    Orientation = Orientation.Horizontal
                };
                image.Margin = new Thickness(0, 0, 5, 0);
                panel.Children.Add(image);
                panel.Children.Add(label);
                result = panel;
            }
            else
            if (isImage)
            {
                result = image;
            }
            else
            if (isLabel)
            {
                result = label;
            }
            else
            {
                result = codon.Id;
            }

            return(result);
        }
Exemple #6
0
        public PadToRibbon(PadDescriptor padDescriptor)
        {
            this.padDescriptor = padDescriptor;
            this.Header        = StringParser.Parse(padDescriptor.Title);

            if (padDescriptor.Icon != null)
            {
                this.Icon = PresentationResourceService.GetBitmapSource(padDescriptor.Icon);
            }
        }
Exemple #7
0
 private void AddMixedMode()
 {
     if (!RuleState.Contains(mixedModeTuple))
     {
         var image = PresentationResourceService.GetBitmapSource("Icons.16x16.ClosedFolderBitmap");
         mixedModeTuple = Tuple.Create <ImageSource, string>(image,
                                                             StringParser.Parse("${res:ICSharpCode.CodeAnalysis.ProjectOptions.WarningErrorMixed}"));
         RuleState.Add(mixedModeTuple);
         Index = RuleState.Count - 1;
         base.RaisePropertyChanged("Index");
     }
 }
Exemple #8
0
 /// <summary>
 /// Gets an image source from a resource.
 /// </summary>
 /// <exception cref="ResourceNotFoundException">The resource with the specified name does not exist</exception>
 public static ImageSource GetImageSource(this IResourceService resourceService, string resourceName)
 {
     if (resourceService == null)
     {
         throw new ArgumentNullException("resourceService");
     }
     if (resourceName == null)
     {
         throw new ArgumentNullException("resourceName");
     }
     return(PresentationResourceService.GetBitmapSource(resourceName));
 }
 static BitmapSource GetReferenceImage()
 {
     try {
         if (ReferenceImage == null)
         {
             ReferenceImage = PresentationResourceService.GetBitmapSource("Icons.16x16.Reference");
         }
         return(ReferenceImage);
     } catch (Exception) {
         return(null);
     }
 }
        ParallelStackFrameModel CreateItemForFrame(StackFrame frame, ref bool lastItemIsExternalMethod)
        {
            ParallelStackFrameModel model = new ParallelStackFrameModel();
            string fullName;

            if (frame.HasSymbols)
            {
                // Show the method in the list
                fullName = frame.GetMethodName();
                lastItemIsExternalMethod = false;
                model.FontWeight         = FontWeights.Normal;
                model.Foreground         = Brushes.Black;
            }
            else
            {
                // Show [External methods] in the list
                if (lastItemIsExternalMethod)
                {
                    return(null);
                }
                fullName                 = ResourceService.GetString("MainWindow.Windows.Debug.CallStack.ExternalMethods").Trim();
                model.FontWeight         = FontWeights.Normal;
                model.Foreground         = Brushes.Gray;
                lastItemIsExternalMethod = true;
            }

            if (frame.Thread.SelectedStackFrame != null &&
                frame.Thread.ID == debuggedProcess.SelectedThread.ID &&
                frame.Thread.SelectedStackFrame.IP == frame.IP &&
                frame.Thread.SelectedStackFrame.GetMethodName() == frame.GetMethodName())
            {
                model.Image = PresentationResourceService.GetImage("Bookmarks.CurrentLine").Source;
                model.IsRunningStackFrame = true;
            }
            else
            {
                if (selectedFrame != null && frame.Thread.ID == selectedFrame.Thread.ID &&
                    frame.GetMethodName() == selectedFrame.GetMethodName())
                {
                    model.Image = PresentationResourceService.GetImage("Icons.48x48.CurrentFrame").Source;
                }
                else
                {
                    model.Image = null;
                }
                model.IsRunningStackFrame = false;
            }

            model.MethodName = fullName;

            return(model);
        }
Exemple #11
0
 private static void Initialize()
 {
     _imageList = new List <ImageSource>
     {
         PresentationResourceService.GetBitmapSource("Icons.16x16.Desktop"),
         PresentationResourceService.GetBitmapSource("Icons.16x16.ClosedFolderBitmap"),
         PresentationResourceService.GetBitmapSource("Icons.16x16.OpenFolderBitmap"),
         PresentationResourceService.GetBitmapSource("Icons.16x16.StandardWorksheet"),
         PresentationResourceService.GetBitmapSource("Icons.16x16.PlotLineScatter"),
         PresentationResourceService.GetBitmapSource("Icons.16x16.PropertyBag"),
         PresentationResourceService.GetBitmapSource("Icons.16x16.Editor")
     };
 }
		public override IList GetToolbarItems()
		{
			var items = base.GetToolbarItems();
			
			if (!finished) {
				stopButton = new Button { Content = new Image { Height = 16, Source = PresentationResourceService.GetBitmapSource("Icons.16x16.Debug.StopProcess") } };
				stopButton.Click += StopButtonClick;
				
				items.Add(stopButton);
			}
			
			return items;
		}
Exemple #13
0
 public StringListEditorXaml()
 {
     InitializeComponent();
     moveUpButton.Content = new Image {
         Height = 16, Source = PresentationResourceService.GetBitmapSource("Icons.16x16.ArrowUp")
     };
     moveDownButton.Content = new Image {
         Height = 16, Source = PresentationResourceService.GetBitmapSource("Icons.16x16.ArrowDown")
     };
     deleteButton.Content = new Image {
         Height = 16, Source = PresentationResourceService.GetBitmapSource("Icons.16x16.DeleteIcon")
     };
     DataContext = this;
 }
        private void SelectFrame(uint threadId, ExpandoObject selectedItem)
        {
            if (selectedItem == null)
            {
                return;
            }

            var thread = Process.Threads.Find(t => t.ID == threadId);

            if (thread == null)
            {
                return;
            }

            if (StackSelected != null)
            {
                StackSelected(this, EventArgs.Empty);
            }

            this.IsSelected = true;

            dynamic obj = selectedItem;

            foreach (var frame in thread.Callstack)
            {
                if (frame.GetMethodName() == obj.MethodName)
                {
                    if (!obj.IsRunningStackFrame)
                    {
                        obj.Image = PresentationResourceService.GetImage("Icons.48x48.CurrentFrame").Source;
                    }

                    SourcecodeSegment nextStatement = frame.NextStatement;
                    if (nextStatement != null)
                    {
                        var location = new Location(nextStatement.StartColumn, nextStatement.StartLine);
                        FileService.JumpToFilePosition(
                            nextStatement.Filename, location.Line, location.Column);

                        if (FrameSelected != null)
                        {
                            FrameSelected(this, new FrameSelectedEventArgs(frame, location));
                        }
                    }

                    break;
                }
            }
        }
Exemple #15
0
 public void InitializeText()
 {
     Title = StringParser.Parse("${res:Altaxo.Gui.ExceptionBox.Title}");
     closeButton.Content       = StringParser.Parse("${res:Altaxo.Gui.ExceptionBox.ExitAltaxo}");
     label3.Text               = StringParser.Parse("${res:Altaxo.Gui.ExceptionBox.ThankYouMsg}");
     label2.Text               = StringParser.Parse("${res:Altaxo.Gui.ExceptionBox.HelpText2}");
     label.Text                = StringParser.Parse("${res:Altaxo.Gui.ExceptionBox.HelpText1}");
     continueButton.Content    = StringParser.Parse("${res:Altaxo.Gui.ExceptionBox.Continue}");
     reportButton.Content      = StringParser.Parse("${res:Altaxo.Gui.ExceptionBox.ReportError}");
     copyErrorCheckBox.Content = StringParser.Parse("${res:Altaxo.Gui.ExceptionBox.CopyToClipboard}");
     if (PresentationResourceService.InstanceAvailable)
     {
         _guiImage.Source = PresentationResourceService.GetBitmapSource("Altaxo.Gui.ExceptionBox.Image");
     }
 }
Exemple #16
0
 private static void Initialize()
 {
     _imageList = new List <ImageSource>
     {
         PresentationResourceService.GetBitmapSource("Icons.16x16.ClosedFolderBitmap"),
         PresentationResourceService.GetBitmapSource("Icons.16x16.OpenFolderBitmap"),
         PresentationResourceService.GetBitmapSource("Icons.16x16.FLOPPY"),
         PresentationResourceService.GetBitmapSource("Icons.16x16.DRIVE"),
         PresentationResourceService.GetBitmapSource("Icons.16x16.CDROM"),
         PresentationResourceService.GetBitmapSource("Icons.16x16.NETWORK"),
         PresentationResourceService.GetBitmapSource("Icons.16x16.Desktop"),
         PresentationResourceService.GetBitmapSource("Icons.16x16.PersonalFiles"),
         PresentationResourceService.GetBitmapSource("Icons.16x16.MyComputer")
     };
 }
        public AvalonPadContent(AvalonDockLayout layout, PadDescriptor descriptor)
        {
            this.descriptor = descriptor;
            this.layout     = layout;

            CustomFocusManager.SetRememberFocusedChild(this, true);
            this.Name = descriptor.Class.Replace('.', '_');
            this.SetValueToExtension(TitleProperty, new StringParseExtension(descriptor.Title));
            placeholder = new TextBlock {
                Text = this.Title
            };
            this.Content = placeholder;
            this.Icon    = PresentationResourceService.GetBitmapSource(descriptor.Icon);

            placeholder.IsVisibleChanged += AvalonPadContent_IsVisibleChanged;
        }
        private void UpdateBreakpoint()
        {
            Breakpoint.Condition      = CommandText;
            Model.Condition           = CommandText;
            Breakpoint.ScriptLanguage = language;
            Model.Language            = language;

            if (!string.IsNullOrEmpty(console.CommandText))
            {
                Breakpoint.Action = BreakpointAction.Condition;
                Model.Image       = PresentationResourceService.GetImage("Bookmarks.BreakpointConditional").Source;
            }
            else
            {
                Breakpoint.Action = BreakpointAction.Break;
                Model.Image       = PresentationResourceService.GetImage("Bookmarks.Breakpoint").Source;
            }
        }
        public IList GetToolbarItems()
        {
            WorkbenchSingleton.AssertMainThread();
            if (toolbarItems == null)
            {
                toolbarItems = new List <object>();
                DropDownButton perFileDropDown = new DropDownButton();
                perFileDropDown.Content = new Image {
                    Height = 16, Source = PresentationResourceService.GetBitmapSource("Icons.16x16.FindIcon")
                };
                perFileDropDown.SetValueToExtension(DropDownButton.ToolTipProperty, new LocalizeExtension("MainWindow.Windows.SearchResultPanel.SelectViewMode.ToolTip"));

                flatItem = new MenuItem();
                flatItem.SetValueToExtension(MenuItem.HeaderProperty, new LocalizeExtension("MainWindow.Windows.SearchResultPanel.Flat"));
                flatItem.Click += delegate { SetPerFile(false); };

                perFileItem = new MenuItem();
                perFileItem.SetValueToExtension(MenuItem.HeaderProperty, new LocalizeExtension("MainWindow.Windows.SearchResultPanel.PerFile"));
                perFileItem.Click += delegate { SetPerFile(true); };

                perFileDropDown.DropDownMenu = new ContextMenu();
                perFileDropDown.DropDownMenu.Items.Add(flatItem);
                perFileDropDown.DropDownMenu.Items.Add(perFileItem);
                toolbarItems.Add(perFileDropDown);
                toolbarItems.Add(new Separator());

                Button expandAll = new Button();
                expandAll.SetValueToExtension(Button.ToolTipProperty, new LocalizeExtension("MainWindow.Windows.SearchResultPanel.ExpandAll.ToolTip"));
                expandAll.Content = new Image {
                    Height = 16, Source = PresentationResourceService.GetBitmapSource("Icons.16x16.OpenAssembly")
                };
                expandAll.Click += delegate { ExpandCollapseAll(true); };
                toolbarItems.Add(expandAll);

                Button collapseAll = new Button();
                collapseAll.SetValueToExtension(Button.ToolTipProperty, new LocalizeExtension("MainWindow.Windows.SearchResultPanel.CollapseAll.ToolTip"));
                collapseAll.Content = new Image {
                    Height = 16, Source = PresentationResourceService.GetBitmapSource("Icons.16x16.Assembly")
                };
                collapseAll.Click += delegate { ExpandCollapseAll(false); };
                toolbarItems.Add(collapseAll);
            }
            return(toolbarItems);
        }
Exemple #20
0
        public ProfilerView(ProfilingDataProvider provider)
        {
            InitializeComponent();
            this.provider = provider;

            this.timeLine.IsEnabled = true;
            this.timeLine.ValuesList.Clear();
            this.timeLine.ValuesList.AddRange(this.provider.DataSets.Select(i => new TimeLineInfo()
            {
                value = i.CpuUsage / 100, displayMarker = i.IsFirst
            }));
            this.timeLine.SelectedStartIndex = 0;
            this.timeLine.SelectedEndIndex   = this.timeLine.ValuesList.Count;

            var translation = new SharpDevelopTranslation();

            foreach (TabItem item in this.tabView.Items)
            {
                if (item.Content != null)
                {
                    QueryView view = item.Content as QueryView;
                    view.Reporter    = new ErrorReporter(UpdateErrorList);
                    view.Provider    = provider;
                    view.Translation = translation;
                    view.SetRange(this.timeLine.SelectedStartIndex, this.timeLine.SelectedEndIndex);
                    view.ContextMenuOpening += delegate(object sender, ContextMenuEventArgs e) {
                        object source = (e.OriginalSource is Shape) ? e.OriginalSource : view;
                        MenuService.CreateContextMenu(source, "/AddIns/Profiler/QueryView/ContextMenu").IsOpen = true;
                    };
                }
            }

            this.dummyTab.Header = new Image {
                Source = PresentationResourceService.GetImage("Icons.16x16.NewDocumentIcon").Source, Height = 16, Width = 16
            };

            this.CommandBindings.Add(new CommandBinding(ApplicationCommands.SelectAll, ExecuteSelectAll, CanExecuteSelectAll));

            InitializeLastItems();
            InitializeOldTabs();
        }
Exemple #21
0
        public CoreMenuItem(Codon codon, object caller, IReadOnlyCollection <ICondition> conditions)
        {
            _codon      = codon;
            _caller     = caller;
            _conditions = conditions;

            if (codon.Properties.Contains("icon"))
            {
                try
                {
                    var image = new Image
                    {
                        Source = PresentationResourceService.GetBitmapSource(codon.Properties["icon"]),
                        Height = 16
                    };
                    Icon = image;
                }
                catch (ResourceNotFoundException) { }
            }
            UpdateText();
        }
Exemple #22
0
        public RibMenuItem(Codon codon, object caller, bool createCommand, IEnumerable <ICondition> conditions)
        {
            this.caller     = caller;
            this.codon      = codon;
            this.conditions = conditions;

            if (createCommand)
            {
                ribbonCommand = (ICommand)codon.AddIn.CreateObject(codon.Properties["class"]);
            }
            if (codon.Properties.Contains("label"))
            {
                this.Header = StringParser.Parse(codon.Properties["label"]);
            }
            if (this.Icon == null && codon.Properties.Contains("icon"))
            {
                this.Icon = PresentationResourceService.GetBitmapSource(codon.Properties["icon"]);
            }

            UpdateStatus();
            UpdateText();
        }
        protected IList GetDefaultToolbarItems()
        {
            if (toolbarItems == null)
            {
                toolbarItems = new List <object>();
                DropDownButton perFileDropDown = new DropDownButton();
                perFileDropDown.Content = new Image {
                    Height = 16, Source = PresentationResourceService.GetBitmapSource("Icons.16x16.FindIcon")
                };
                perFileDropDown.SetValueToExtension(DropDownButton.ToolTipProperty, new LocalizeExtension("MainWindow.Windows.SearchResultPanel.SelectViewMode.ToolTip"));

                MenuItem flatItem = new MenuItem();
                flatItem.IsCheckable = true;
                flatItem.SetValueToExtension(MenuItem.HeaderProperty, new LocalizeExtension("MainWindow.Windows.SearchResultPanel.Flat"));
                flatItem.Click += delegate {
                    SetResultGrouping();
                    SetCheckedItem(flatItem, perFileDropDown.DropDownMenu);
                };

                MenuItem perFileItem = new MenuItem();
                perFileItem.IsCheckable = true;
                perFileItem.SetValueToExtension(MenuItem.HeaderProperty, new LocalizeExtension("MainWindow.Windows.SearchResultPanel.PerFile"));
                perFileItem.Click += delegate {
                    SetResultGrouping(SearchResultGroupingKind.PerFile);
                    SetCheckedItem(perFileItem, perFileDropDown.DropDownMenu);
                };

                MenuItem perProjectItem = new MenuItem();
                perProjectItem.IsCheckable = true;
                perProjectItem.SetValueToExtension(MenuItem.HeaderProperty, new LocalizeExtension("MainWindow.Windows.SearchResultPanel.PerProject"));
                perProjectItem.Click += delegate {
                    SetResultGrouping(SearchResultGroupingKind.PerProject);
                    SetCheckedItem(perProjectItem, perFileDropDown.DropDownMenu);
                };

                MenuItem perProjectAndFileItem = new MenuItem();
                perProjectAndFileItem.IsCheckable = true;
                perProjectAndFileItem.SetValueToExtension(MenuItem.HeaderProperty, new LocalizeExtension("MainWindow.Windows.SearchResultPanel.PerProjectAndFile"));
                perProjectAndFileItem.Click += delegate {
                    SetResultGrouping(SearchResultGroupingKind.PerProjectAndFile);
                    SetCheckedItem(perProjectAndFileItem, perFileDropDown.DropDownMenu);
                };

                perFileDropDown.DropDownMenu = new ContextMenu();
                perFileDropDown.DropDownMenu.Items.Add(flatItem);
                perFileDropDown.DropDownMenu.Items.Add(perFileItem);
                perFileDropDown.DropDownMenu.Items.Add(perProjectItem);
                perFileDropDown.DropDownMenu.Items.Add(perProjectAndFileItem);
                toolbarItems.Add(perFileDropDown);
                toolbarItems.Add(new Separator());

                Button expandAll = new Button();
                expandAll.SetValueToExtension(Button.ToolTipProperty, new LocalizeExtension("MainWindow.Windows.SearchResultPanel.ExpandAll.ToolTip"));
                expandAll.Content = new Image {
                    Height = 16, Source = PresentationResourceService.GetBitmapSource("Icons.16x16.OpenCollection")
                };
                expandAll.Click += delegate { ExpandCollapseAll(true); };
                toolbarItems.Add(expandAll);

                Button collapseAll = new Button();
                collapseAll.SetValueToExtension(Button.ToolTipProperty, new LocalizeExtension("MainWindow.Windows.SearchResultPanel.CollapseAll.ToolTip"));
                collapseAll.Content = new Image {
                    Height = 16, Source = PresentationResourceService.GetBitmapSource("Icons.16x16.Collection")
                };
                collapseAll.Click += delegate { ExpandCollapseAll(false); };
                toolbarItems.Add(collapseAll);
            }
            // Copy the list to avoid modifications to the static list
            return(new List <object>(toolbarItems));
        }
Exemple #24
0
        public override Inline GetInlineItem(string url, out bool inlineItemIsErrorMessage)
        {
            // There are two peculiarities when it comes to creating images from a stream (especially: from a MemoryStream)
            // First peculiarity:
            // The sequence
            //
            // var imageSource = BitmapFrame.Create(stream, BitmapCreateOptions.None, BitmapCacheOption.OnLoad);
            //
            // to create an image can only be used if IsUndoEnabled is set to false in the FlowDocument.
            // This is because the BitmapFrame is not serializable, but the Undo function needs that.
            // Second peculiarity:
            // even then, there is a bug in Wpf when converting the FlowDocument into a FixedDocument:
            // when you use the above sequence to create images from MemoryStreams (tested only for them),
            // all images in the FixedDocument are equal to the first image in the FlowDocument
            // Summary1: we have to use a BitmapImage instead and use the stream to fill it
            // Summary2: It is a good idea anyway to set IsUndoEnabled to false in the FlowDocument, as it speeds up changes of the FlowDocument considerably

            if (url.StartsWith(ImagePretext.GraphRelativePathPretext))
            {
                string graphName = url.Substring(ImagePretext.GraphRelativePathPretext.Length);

                var grp = FindGraphWithUrl(graphName);

                if (grp is Altaxo.Graph.Gdi.GraphDocument graph)
                {
                    var options = new Altaxo.Graph.Gdi.GraphExportOptions()
                    {
                        SourceDpiResolution      = _targetResolution,
                        DestinationDpiResolution = _targetResolution,
                    };

                    using (var stream = new System.IO.MemoryStream())
                    {
                        Altaxo.Graph.Gdi.GraphDocumentExportActions.RenderToStream(graph, stream, options);
                        stream.Seek(0, System.IO.SeekOrigin.Begin);
                        var image = GetImageFromStream(stream);
                        inlineItemIsErrorMessage = false;
                        return(new InlineUIContainer(image));
                    }
                }
                else if (grp is Altaxo.Graph.Graph3D.GraphDocument graph3D)
                {
                    var options = new Altaxo.Graph.Gdi.GraphExportOptions()
                    {
                        SourceDpiResolution      = _targetResolution,
                        DestinationDpiResolution = _targetResolution,
                    };

                    using (var stream = new System.IO.MemoryStream())
                    {
                        if ((0, 0) == Altaxo.Graph.Graph3D.GraphDocumentExportActions.RenderToStream(graph3D, stream, options))
                        {
                            inlineItemIsErrorMessage = true;
                            return(new Run(string.Format("ERROR: NO RENDERER FOR 3D GRAPHS FOUND!")));
                        }

                        stream.Seek(0, System.IO.SeekOrigin.Begin);
                        var image = GetImageFromStream(stream);

                        inlineItemIsErrorMessage = false;
                        return(new InlineUIContainer(image));
                    }
                }
                else
                {
                    inlineItemIsErrorMessage = true;
                    return(new Run(string.Format("ERROR: GRAPH '{0}' NOT FOUND!", graphName)));
                }
            }
            else if (url.StartsWith(ImagePretext.ResourceImagePretext))
            {
                string      name         = url.Substring(ImagePretext.ResourceImagePretext.Length);
                ImageSource bitmapSource = null;
                try
                {
                    bitmapSource = PresentationResourceService.GetBitmapSource(name);
                }
                catch (Exception)
                {
                }

                if (null != bitmapSource)
                {
                    var image = new Image()
                    {
                        Source = bitmapSource
                    };

                    inlineItemIsErrorMessage = false;
                    return(new InlineUIContainer(image));
                }
                else
                {
                    inlineItemIsErrorMessage = true;
                    return(new Run(string.Format("ERROR: RESOURCE '{0}' NOT FOUND!", name)));
                }
            }
            else if (url.StartsWith(ImagePretext.LocalImagePretext))
            {
                string name = url.Substring(ImagePretext.LocalImagePretext.Length);

                if (null != LocalImages && LocalImages.TryGetValue(name, out var img))
                {
                    var   stream = img.GetContentStream();
                    Image image  = GetImageFromStream(stream);

                    inlineItemIsErrorMessage = false;
                    return(new InlineUIContainer(image));
                }
                else
                {
                    inlineItemIsErrorMessage = true;
                    return(new Run(string.Format("ERROR: LOCAL IMAGE '{0}' NOT FOUND!", name)));
                }
            }
            else
            {
                if (string.IsNullOrEmpty(url) || !Uri.IsWellFormedUriString(url, UriKind.RelativeOrAbsolute))
                {
                    inlineItemIsErrorMessage = false;
                    return(null);
                }
                try
                {
                    var bitmapSource = new BitmapImage(new Uri(url, UriKind.RelativeOrAbsolute));

                    // This is not nice, but we have to validate that our bitmapSource is valid already now, since we may need to resize it immediately,
                    // and we want to provoke the exception if our url was not valid
                    int pixelHeight = bitmapSource.PixelHeight;

                    var image = new Image {
                        Source = bitmapSource
                    };
                    inlineItemIsErrorMessage = false;
                    return(new InlineUIContainer(image));
                }
                catch (Exception ex)
                {
                    inlineItemIsErrorMessage = true;
                    return(new Run(string.Format("ERROR RENDERING '{0}' ({1})", url, ex.Message)));
                }
            }
        }
Exemple #25
0
 public override object ProvideValue(IServiceProvider serviceProvider)
 {
     return(PresentationResourceService.GetBitmapSource(key));
 }
 public ImageAndDescription(string resourceName, string description)
     : this(PresentationResourceService.GetBitmapSource(resourceName), description)
 {
 }
        void CreateMethodViewStacks()
        {
            var list = new List <Tuple <ObservableCollection <ParallelStackFrameModel>, ObservableCollection <ParallelStackFrameModel>, List <uint> > >();

            // find all threadstacks that contains the selected frame
            for (int i = currentThreadStacks.Count - 1; i >= 0; --i)
            {
                var tuple = currentThreadStacks[i].ItemCollection.SplitStack(selectedFrame, currentThreadStacks[i].ThreadIds);
                if (tuple != null)
                {
                    list.Add(tuple);
                }
            }

            currentThreadStacks.Clear();

            // common
            ThreadStack             common = new ThreadStack();
            var                     observ = new ObservableCollection <ParallelStackFrameModel>();
            bool                    dummy  = false;
            ParallelStackFrameModel obj    = CreateItemForFrame(selectedFrame, ref dummy);

            obj.Image = PresentationResourceService.GetImage("Icons.48x48.CurrentFrame").Source;
            observ.Add(obj);
            common.ItemCollection = observ;
            common.StackSelected += OnThreadStackSelected;
            common.FrameSelected += OnFrameSelected;
            common.UpdateThreadIds(parallelStacksView == ParallelStacksView.Tasks, selectedFrame.Thread.ID);
            common.Process             = debuggedProcess;
            common.ThreadStackChildren = new List <ThreadStack>();
            common.ThreadStackParents  = new List <ThreadStack>();

            // for all thread stacks, split them in 2 :
            // one that invokes the method frame, second that get's invoked by current method frame
            foreach (var tuple in list)
            {
                // add top
                if (tuple.Item1.Count > 0)
                {
                    ThreadStack topStack = new ThreadStack();
                    topStack.ItemCollection = tuple.Item1;
                    topStack.StackSelected += OnThreadStackSelected;
                    topStack.FrameSelected += OnFrameSelected;
                    topStack.UpdateThreadIds(parallelStacksView == ParallelStacksView.Tasks, tuple.Item3.ToArray());
                    topStack.Process            = debuggedProcess;
                    topStack.ThreadStackParents = new List <ThreadStack>();
                    topStack.ThreadStackParents.Add(common);

                    currentThreadStacks.Add(topStack);
                    common.ThreadStackChildren.Add(topStack);
                }

                // add bottom
                if (tuple.Item2.Count > 0)
                {
                    ThreadStack bottomStack = new ThreadStack();
                    bottomStack.ItemCollection = tuple.Item2;
                    bottomStack.StackSelected += OnThreadStackSelected;
                    bottomStack.FrameSelected += OnFrameSelected;
                    bottomStack.UpdateThreadIds(parallelStacksView == ParallelStacksView.Tasks, tuple.Item3.ToArray());
                    bottomStack.Process             = debuggedProcess;
                    bottomStack.ThreadStackChildren = new List <ThreadStack>();
                    bottomStack.ThreadStackChildren.Add(common);
                    common.UpdateThreadIds(parallelStacksView == ParallelStacksView.Tasks, tuple.Item3.ToArray());
                    common.ThreadStackParents.Add(bottomStack);
                    currentThreadStacks.Add(bottomStack);
                }
            }

            currentThreadStacks.Add(common);
            common.IsSelected = true;
        }
Exemple #28
0
        public AvalonPadContent(AvalonDockLayout layout, PadDescriptor descriptor)
        {
            this.descriptor = descriptor;
            this.layout     = layout;

            CustomFocusManager.SetRememberFocusedChild(this, true);
            this.Name = descriptor.Class.Replace('.', '_');
            this.SetValueToExtension(TitleProperty, new StringParseExtension(descriptor.Title));
            placeholder = new TextBlock {
                Text = this.Title
            };
            this.Content = placeholder;

            if (String.IsNullOrEmpty(descriptor.PackIconKey))
            {
                if (!String.IsNullOrEmpty(descriptor.Icon))
                {
                    this.Icon = PresentationResourceService.GetBitmapSource(descriptor.Icon);
                    HasIcon   = true;
                }
            }
            else
            {
                if (descriptor.PackIconKey.Contains(";"))
                {
                    string[] packIconValues = descriptor.PackIconKey.Split(';');
                    string   packIconType   = packIconValues[0];
                    string   packIconKind   = packIconValues[1];

                    switch (packIconType)
                    {
                    case "PackIconMaterial":
                        PackIconKind = (Enum)Enum.Parse(typeof(PackIconMaterialKind),
                                                        packIconKind);
                        break;

                    case "PackIconMaterialLight":
                        PackIconKind = (Enum)Enum.Parse(typeof(PackIconMaterialLightKind),
                                                        packIconKind);
                        break;

                    case "PackIconModern":
                        PackIconKind = (Enum)Enum.Parse(typeof(PackIconModernKind),
                                                        packIconKind);
                        break;

                    case "PackIconOcticons":
                        PackIconKind = (Enum)Enum.Parse(typeof(PackIconOcticonsKind),
                                                        packIconKind);
                        break;

                    case "PackIconSimpleIcons":
                        PackIconKind = (Enum)Enum.Parse(typeof(PackIconSimpleIconsKind),
                                                        packIconKind);
                        break;

                    case "PackIconEntypo":
                        PackIconKind = (Enum)Enum.Parse(typeof(PackIconEntypoKind),
                                                        packIconKind);
                        break;

                    case "PackIconFontAwesome":
                        PackIconKind = (Enum)Enum.Parse(typeof(PackIconFontAwesomeKind),
                                                        packIconKind);
                        break;
                    }
                    HasPackIcon = true;
                }
            }

            placeholder.IsVisibleChanged += AvalonPadContent_IsVisibleChanged;
        }