예제 #1
0
        public ErrorListViewModel(LoggerModule module, System.Windows.Media.ImageSource iconSource) : base(module, "ErrorList")
        {
            this.Module     = module;
            this.IconSource = iconSource;

            ClearMessagesCommand = new RelayCommand(ClearMessages);
        }
        private void SetPreviewImage()
        {
            Bitmap       previewBitmap = new Bitmap(50, 50);
            Graphics     previewCanvas = Graphics.FromImage(previewBitmap);
            MemoryStream previewStream = new MemoryStream();

            try
            {
                previewCanvas.FillRectangle(new System.Drawing.Drawing2D.LinearGradientBrush(new Rectangle(0, 0, 50, 50),
                                                                                             SelectedBrush.StartColor,
                                                                                             SelectedBrush.EndColor,
                                                                                             (float)SelectedBrush.Angle), new Rectangle(0, 0, 50, 50));

                previewBitmap.Save(previewStream, System.Drawing.Imaging.ImageFormat.Png);
                System.Windows.Media.Imaging.BitmapImage imageSource = new System.Windows.Media.Imaging.BitmapImage();
                imageSource.BeginInit();
                imageSource.StreamSource = previewStream;
                imageSource.EndInit();

                PreviewImage = imageSource;
            }
            catch (Exception ex)
            {
                GisEditor.LoggerManager.Log(LoggerLevel.Debug, ex.Message, new ExceptionInfo(ex));
            }
            finally
            {
                previewBitmap.Dispose();
            }

            if (!stopColorChangedEvent)
            {
                OnSelectedBrushChanged();
            }
        }
        /// <summary>
        /// 刷新预览图
        /// 适用于simpleMaker状态
        /// </summary>
        private async Task refreshPreviewAsync()
        {
            //if (simpleMarkerSymbol == null)
            //    return;
            if (simple_RB.Checked)
            {
                if (simpleMarkerSymbol == null)
                {
                    return;
                }
                Esri.ArcGISRuntime.UI.RuntimeImage image = await simpleMarkerSymbol.CreateSwatchAsync(Color.WhiteSmoke);

                System.Windows.Media.ImageSource imageSource = await Esri.ArcGISRuntime.UI.RuntimeImageExtensions.ToImageSourceAsync(image);

                Image result = imageWpfToGDI(imageSource);
                previewBox.Image    = result;
                previewBox.SizeMode = PictureBoxSizeMode.AutoSize | PictureBoxSizeMode.CenterImage;
            }
            else
            {
                if (pictureMarkerSymbol == null)
                {
                    return;
                }
                Esri.ArcGISRuntime.UI.RuntimeImage image = await pictureMarkerSymbol.CreateSwatchAsync(Color.WhiteSmoke);

                System.Windows.Media.ImageSource imageSource = await Esri.ArcGISRuntime.UI.RuntimeImageExtensions.ToImageSourceAsync(image);

                Image result = imageWpfToGDI(imageSource);
                previewBox.Image    = result;
                previewBox.SizeMode = PictureBoxSizeMode.AutoSize | PictureBoxSizeMode.CenterImage;
            }
        }
예제 #4
0
 public FileListView(int id, string name, System.Windows.Media.ImageSource icon, bool isChecked)
 {
     this.Id        = id;
     this.Name      = name;
     this.IsChecked = isChecked;
     this.fileIcon  = icon;
 }
        /// <summary>
        /// Convert a <see cref="IItem"/> into an image representation.
        /// </summary>
        /// <param name="value"></param>
        /// <param name="targetType"></param>
        /// <param name="parameter"></param>
        /// <param name="culture"></param>
        /// <returns></returns>
        public object Convert(object value, Type targetType,
                              object parameter, CultureInfo culture)
        {
            var item = value as IItem;

            if (item == null)
            {
                return(Binding.DoNothing);
            }

            System.Windows.Media.ImageSource displayIcon = null;

            try
            {
                // a folder can be represented with a seperate icon for its expanded state
                if (item.ItemType == FSItemType.Folder)
                {
                    displayIcon = IconExtractor.GetFolderIcon(item.ItemPath,
                                                              item.IsExpanded).ToImageSource();
                }
                else
                {
                    displayIcon = IconExtractor.GetFileIcon(item.ItemPath).ToImageSource();
                }
            }
            catch
            {
            }

            return(displayIcon);
        }
예제 #6
0
        public override bool GetIcon(IQuickWindow quickWindow, out System.Windows.Media.ImageSource icon)
        {
            try
            {
                if (Directory.Exists(m_fullpath))
                {
                    icon = GetRoot().DefaultFolderIcon;
                }
                else
                {
                    string dest = m_fullpath;
                    if (!Path.IsPathRooted(m_fullpath))
                    {
                        dest = MatchCommonShortcutPath(m_fullpath);
                    }

                    var tmp = Icon.ExtractAssociatedIcon(dest);     //获得主线程图标
                    icon = tmp.ToBitmapSource();
                }
                return(true);
            }
            catch { }
            icon = null;
            return(false);
        }
예제 #7
0
        protected virtual IEnumerable <Completion> GetSnippetCompletions()
        {
            if (LanguageGuid == Guid.Empty)
            {
                return(EmptyCompletions);
            }

            List <Completion> snippetCompletions = new List <Completion>();
            Guid languageGuid = LanguageGuid;

            VsExpansion[]   expansions             = Provider.ExpansionManager.EnumerateExpansions(languageGuid, new string[] { "Expansion" }, false);
            ImageSource     defaultExpansionGlyph  = Provider.GlyphService.GetGlyph(StandardGlyphGroup.GlyphCSharpExpansion, StandardGlyphItem.GlyphItemPublic);
            IconDescription defaultIconDescription = new IconDescription(StandardGlyphGroup.GlyphCSharpExpansion, StandardGlyphItem.GlyphItemPublic);

            foreach (var expansion in expansions)
            {
                Completion completion = CreateSnippetCompletion(expansion, defaultExpansionGlyph, defaultIconDescription);
                if (completion == null)
                {
                    continue;
                }

                snippetCompletions.Add(completion);
            }

            return(snippetCompletions);
        }
예제 #8
0
        public static System.Drawing.Bitmap GetSysDrawingBitmapFromImageSource(System.Windows.Media.ImageSource src)
        {
            //https://stackoverflow.com/questions/32073767/convert-system-windows-media-imagesource-to-system-drawing-bitmap
            BitmapImage source = src as BitmapImage;
            int         width  = (int)src.Width;
            int         height = (int)src.Height;
            int         stride = width * ((source.Format.BitsPerPixel + 7) / 8);
            IntPtr      ptr    = IntPtr.Zero;

            try
            {
                ptr = System.Runtime.InteropServices.Marshal.AllocHGlobal(height * stride);
                source.CopyPixels(new Int32Rect(0, 0, width, height), ptr, height * stride, stride);
                using (var bmp = new System.Drawing.Bitmap(width, height, stride, System.Drawing.Imaging.PixelFormat.Format1bppIndexed, ptr))
                {
                    return(new System.Drawing.Bitmap(bmp));
                }
            }
            finally
            {
                if (ptr != IntPtr.Zero)
                {
                    System.Runtime.InteropServices.Marshal.FreeHGlobal(ptr);
                }
            }
        }
예제 #9
0
            public override void EnterClassOrInterfaceDefinition(PhpParser.ClassOrInterfaceDefinitionContext context)
            {
                string name = GetQualifiedName(context);

                IEditorNavigationType navigationType = _provider.EditorNavigationTypeRegistryService.GetEditorNavigationType(PredefinedEditorNavigationTypes.Types);
                var          startToken = _antlrParseResultArgs.Tokens[context.SourceInterval.a];
                var          stopToken  = _antlrParseResultArgs.Tokens[context.SourceInterval.b];
                SnapshotSpan span       = new SnapshotSpan(_snapshot, new Span(startToken.StartIndex, stopToken.StopIndex - startToken.StartIndex + 1));
                SnapshotSpan seek       = span;

                if (context.PHP_IDENTIFIER() != null)
                {
                    seek = new SnapshotSpan(_snapshot, new Span(context.PHP_IDENTIFIER().Symbol.StartIndex, 0));
                }

                StandardGlyphGroup glyphGroup;

                if (context.KW_INTERFACE() != null)
                {
                    glyphGroup = StandardGlyphGroup.GlyphGroupInterface;
                }
                else
                {
                    glyphGroup = StandardGlyphGroup.GlyphGroupClass;
                }

                //StandardGlyphItem glyphItem = GetGlyphItemFromChildModifier(child);
                StandardGlyphItem     glyphItem = StandardGlyphItem.GlyphItemPublic;
                ImageSource           glyph     = _provider.GlyphService.GetGlyph(glyphGroup, glyphItem);
                NavigationTargetStyle style     = NavigationTargetStyle.None;

                _navigationTargets.Add(new EditorNavigationTarget(name, navigationType, span, seek, glyph, style));
            }
 /// <summary>
 /// Initializes a new instance of the ProgramFeatureImageViewModel class.
 /// </summary>
 /// <param name="name">Display name of the feature.</param>
 /// <param name="image">Icon representing the feature. May be <c>null</c>.</param>
 /// <param name="toolTip">Tool tip for the feature, displayed when hovering over icon.</param>
 /// <param name="category">The category of features to which the specific feature belongs.</param>
 /// <param name="flags">The flag describing the specific feature.</param>
 public ProgramFeatureImageViewModel(string name, OSImage image, string toolTip, FeatureCategory category, uint flags)
 {
     Name     = name;
     Image    = image;
     ToolTip  = toolTip;
     Category = category;
     Flags    = flags;
 }
예제 #11
0
 public MyCampaigns(System.Windows.Media.ImageSource campaignStatusImageSource, string campaignName, string deliveryMode, string date, string description)
 {
     CampaignStatusImageSource = campaignStatusImageSource;
     CampaignName = campaignName;
     DeliveryMode = deliveryMode;
     Date         = date;
     Description  = description;
 }
예제 #12
0
        private void CreateImageFromSic(string sic, int size)
        {
            System.Windows.Media.ImageSource imageSource = symbolDictionary.GetSymbolImage(sic, 256, 256);

            System.Windows.Media.Imaging.WriteableBitmap bi = imageSource as System.Windows.Media.Imaging.WriteableBitmap;

            SaveAsPng(sic + ".png", bi);
        }
예제 #13
0
 private void ReadPng(TImage aImage)
 {
     using (MemoryStream Ms = new MemoryStream())
     {
         aImage.Save(Ms, System.Drawing.Imaging.ImageFormat.Png);
         Ms.Position = 0;
         ReadPng(Ms);
     }
 }
예제 #14
0
        public void Add(string key, ImageInformation imageInformation, ImageSource bitmap)
        {
            if (string.IsNullOrWhiteSpace(key) || bitmap == null)
            {
                return;
            }

            _reusableBitmaps.TryAdd(key, new Tuple <ImageSource, ImageInformation>(bitmap, imageInformation));
        }
 public async void BitmapSourceEnableAsync()
 {
     if (BitmapSource is null)
     {
         ImageNeeded(this, new EventArgs());
         BitmapSource = await GetBitmapSource;
         OnPropertyChanged("BitmapSource");
     }
 }
        private Bitmap ImageWpfToGDI(System.Windows.Media.ImageSource image)
        {
            MemoryStream ms      = new MemoryStream();
            var          encoder = new System.Windows.Media.Imaging.BmpBitmapEncoder();

            encoder.Frames.Add(System.Windows.Media.Imaging.BitmapFrame.Create(image as System.Windows.Media.Imaging.BitmapSource));
            encoder.Save(ms);
            ms.Flush();
            return(System.Drawing.Image.FromStream(ms) as Bitmap);
        }
예제 #17
0
        private Completion CreateRuleReferenceCompletion(string ruleName)
        {
            string      displayText        = ruleName;
            string      insertionText      = ruleName;
            string      description        = string.Empty;
            string      iconAutomationText = string.Empty;
            ImageSource iconSource         = char.IsLower(ruleName[0]) ? Provider.ParserRuleGlyph : Provider.LexerRuleGlyph;

            return(new Completion(displayText, insertionText, description, iconSource, iconAutomationText));
        }
예제 #18
0
        private Completion CreateLabelCompletion(LabelInfo label)
        {
            string      displayText        = "$" + label.Name;
            string      insertionText      = "$" + label.Name;
            string      description        = label.Description;
            string      iconAutomationText = string.Empty;
            ImageSource iconSource         = Provider.GlyphService.GetGlyph(label.Glyph, StandardGlyphItem.GlyphItemPublic);

            return(new Completion(displayText, insertionText, description, iconSource, iconAutomationText));
        }
예제 #19
0
        /// <inheritdoc />
        protected override void OnColorChanged(INTV.Core.Model.Stic.Color color)
        {
            OSImage icon = GetIconForColor(color);

            Icon = icon;
            if (Icon == null)
            {
                ErrorReporting.ReportError <InvalidOperationException>(ReportMechanism.Default, "OnColorChanged", "ProgramViewModel");
            }
        }
예제 #20
0
 private void ShowWinCopy(System.Windows.Media.ImageSource ISource, Window win)
 {
     try {
         WindowCopy winCopy = new WindowCopy(ISource, win, null);
         winCopy.winMain = win;
         winCopy.Closed += WinCopy_Closed;
         winCopy.Show();
     }
     catch (Exception ex)
     { }
 }
예제 #21
0
        private static ProgramFeatureImageViewModel FetchProgramFeatureViewModelForFlag <TFlag>(this TFlag flag, IProgramFeatureSet <TFlag> featureSet, bool allowNullImage) where TFlag : struct
        {
            ProgramFeatureImageViewModel featureViewModel = null;
            OSImage image = featureSet.GetImageForFeature(flag);

            if (allowNullImage || (image != null))
            {
                featureViewModel = new ProgramFeatureImageViewModel(featureSet.GetFeatureName(flag), image, featureSet.GetFeatureDescription(flag), featureSet.Category, (uint)((object)flag));
            }
            return(featureViewModel);
        }
예제 #22
0
        private CImage CreateActionImage(System.Windows.Media.ImageSource source, MouseButtonEventHandler handler)
        {
            CImage ci = new CImage();

            ci.Source   = source;
            ci.MouseUp += handler;
            ci.Height   = 30;
            ci.Margin   = new Thickness(0, 0, 5, 0);
            DockPanel.SetDock(ci, Dock.Right);
            return(ci);
        }
예제 #23
0
        /// <summary>
        ///  Bitmap -> ImageSource
        /// </summary>
        /// <param name="bitmap"></param>
        /// <returns></returns>
        public static System.Windows.Media.ImageSource ConverBitmapToImageSource(Bitmap bitmap)
        {
            IntPtr hBitmap = bitmap.GetHbitmap();

            System.Windows.Media.ImageSource wpfBitmap = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(
                hBitmap,
                IntPtr.Zero,
                Int32Rect.Empty,
                BitmapSizeOptions.FromEmptyOptions());
            return(wpfBitmap);
        }
        /// <summary>
        /// 由传进来的layer初始化simpleMaker的样式
        /// </summary>
        private async void initLegend()
        {
            //初始化点样式
            FeatureLayer   feature        = layer as FeatureLayer;
            SimpleRenderer simpleRenderer = feature.Renderer as SimpleRenderer;

            if (simpleRenderer != null)
            {
                //需要注意的是 这里不应该直接引用传递 否则在未确认的情况下也会影响到点的样式
                simpleMarkerSymbol = simpleRenderer.Symbol.Clone() as SimpleMarkerSymbol;
                //如果为空则说明Symbol不为简单点样式
                if (simpleMarkerSymbol == null)
                {
                    //因为后面需要订阅事件 所以不能为null
                    simpleMarkerSymbol  = new SimpleMarkerSymbol();
                    pictureMarkerSymbol = simpleRenderer.Symbol.Clone() as PictureMarkerSymbol;
                    if (pictureMarkerSymbol != null)
                    {
                        Esri.ArcGISRuntime.UI.RuntimeImage image = await pictureMarkerSymbol.CreateSwatchAsync(Color.WhiteSmoke);

                        System.Windows.Media.ImageSource imageSource = await Esri.ArcGISRuntime.UI.RuntimeImageExtensions.ToImageSourceAsync(image);

                        Image result = imageWpfToGDI(imageSource);
                        previewBox.Image          = result;
                        previewBox.SizeMode       = PictureBoxSizeMode.Zoom;
                        simple_RB.Checked         = false;
                        customPic_RB.Checked      = true;
                        StyleCombox.Enabled       = false;
                        colorBtn.Enabled          = false;
                        sizeUpDown.Value          = (decimal)pictureMarkerSymbol.Width + 1;
                        transparencyControl.Value = MainWindow.getAlpha(pictureMarkerSymbol.Opacity);
                    }
                }
                else
                {
                    int index = findSelectIndex(x =>
                    {
                        return(simpleMarkerSymbol.Style.ToString().Equals(x.ToString()));
                    });
                    int count = ((List <SimpleMarkerSymbolStyle>)StyleCombox.DataSource).Count;
                    //设置传入的layer的样式
                    simple_RB.Checked         = true;
                    StyleCombox.SelectedIndex = index;
                    colorBtn.BackColor        = simpleMarkerSymbol.Color;
                    sizeUpDown.Value          = (decimal)simpleMarkerSymbol.Size;
                    transparencyControl.Value = simpleMarkerSymbol.Color.A;
                    await refreshPreviewAsync();
                }
            }
            //如果Layer是别的数据类型
            else
            {
            }
        }
예제 #25
0
        private void RB_Cut_Click(object sender, RoutedEventArgs e)
        {
            Window win = Window.GetWindow(this);

            win.Hide();
            Thread.Sleep(200);
            System.Drawing.Bitmap            newBitmap = CopyHelper.CopyFromScreen();
            System.Windows.Media.ImageSource ISource   = CopyHelper.BitMapToImageSource(newBitmap);

            ShowWinCopy(ISource, win);
        }
예제 #26
0
        public override Completion CreateCompletion(AlloyIntellisenseController controller, ICompletionSession session)
        {
            string             displayText        = Name;
            string             insertionText      = Name;
            string             description        = string.Empty;
            StandardGlyphGroup glyphGroup         = IsEnum ? StandardGlyphGroup.GlyphGroupEnum : StandardGlyphGroup.GlyphGroupStruct;
            ImageSource        iconSource         = controller.Provider.GlyphService.GetGlyph(glyphGroup, StandardGlyphItem.GlyphItemPublic);
            string             iconAutomationText = string.Empty;

            return(new Completion(displayText, insertionText, description, iconSource, iconAutomationText));
        }
예제 #27
0
        protected virtual Completion CreateKeywordCompletion([NotNull] string keyword)
        {
            Requires.NotNullOrEmpty(keyword, nameof(keyword));

            string      displayText        = keyword;
            string      insertionText      = keyword;
            string      description        = null;
            ImageSource iconSource         = Provider.GlyphService.GetGlyph(StandardGlyphGroup.GlyphKeyword, StandardGlyphItem.GlyphItemPublic);
            string      iconAutomationText = new IconDescription(StandardGlyphGroup.GlyphKeyword, StandardGlyphItem.GlyphItemPublic).ToString();

            return(new Completion(displayText, insertionText, description, iconSource, iconAutomationText));
        }
예제 #28
0
 public override bool GetIcon(IQuickWindow quickWindow, out System.Windows.Media.ImageSource icon)
 {
     try
     {
         var tmp = Icon.ExtractAssociatedIcon(m_fullpath);     //获得主线程图标
         icon = tmp.ToBitmapSource();
         return(true);
     }
     catch { }
     icon = null;
     return(false);
 }
예제 #29
0
        async public Task <System.Windows.Media.ImageSource> LoadImageAsync(ImageSource imageSource, CancellationToken cancelationToken)
        {
            System.Windows.Media.ImageSource image = await _imageLoaderSourceHandler.LoadImageAsync(imageSource, cancelationToken);

            EventHandler <bool> statusChangedHandler = (EventHandler <bool>)ImageSourceExtensions.GetStatusChangedHandler(imageSource);

            if (statusChangedHandler != null)
            {
                statusChangedHandler(imageSource, image != null);
            }
            return(image);
        }
예제 #30
0
        public static System.Windows.Media.ImageSource BytesToImage(byte[] bytes)
        {
            System.Windows.Media.Imaging.BitmapImage biImg = new System.Windows.Media.Imaging.BitmapImage();
            System.IO.MemoryStream ms = new System.IO.MemoryStream(bytes);
            biImg.BeginInit();
            biImg.StreamSource = ms;
            biImg.EndInit();

            System.Windows.Media.ImageSource imgSrc = biImg as System.Windows.Media.ImageSource;

            return(imgSrc);
        }
예제 #31
0
        public EditorNavigationTarget(string name, IEditorNavigationType editorNavigationType, SnapshotSpan span, SnapshotSpan seek, ImageSource glyph = null, NavigationTargetStyle style = NavigationTargetStyle.None)
        {
            Contract.Requires<ArgumentNullException>(name != null, "name");
            Contract.Requires<ArgumentNullException>(editorNavigationType != null, "editorNavigationType");

            this._name = name;
            this._editorNavigationType = editorNavigationType;
            this.Span = span;
            this.Seek = seek;
            this._style = style;
            this.Glyph = glyph;
        }
예제 #32
0
 public EditorNavigationTarget(string name, IEditorNavigationType editorNavigationType, SnapshotSpan span, ImageSource glyph = null, NavigationTargetStyle style = NavigationTargetStyle.None)
     : this(name, editorNavigationType, span, new SnapshotSpan(span.Start, span.End), glyph, style)
 {
     Contract.Requires(name != null);
     Contract.Requires(editorNavigationType != null);
 }
        private void HandleFunctionOrPredicate(CommonTree tree, CommonTree name, IList<CommonTree> parameters, CommonTree returnSpec, ImageSource glyph)
        {
            if (tree == null || name == null)
                return;

            var navigationType = EditorNavigationTypeRegistryService.GetEditorNavigationType(PredefinedEditorNavigationTypes.Members);
            var startToken = _tokens[tree.TokenStartIndex];
            var stopToken = _tokens[tree.TokenStopIndex];
            Span span = new Span(startToken.StartIndex, stopToken.StopIndex - startToken.StartIndex + 1);
            SnapshotSpan ruleSpan = new SnapshotSpan(Snapshot, span);
            SnapshotSpan ruleSeek = new SnapshotSpan(Snapshot, new Span(name.Token.StartIndex, 0));

            string functionDisplayName = (name.Type == DOT) ? GetNameText((CommonTree)name.Children[1]) : GetNameText(name);
            string thisType = (name.Type == DOT) ? GetNameText((CommonTree)name.Children[0]) : null;
            IEnumerable<string> thisParam = !string.IsNullOrEmpty(thisType) ? Enumerable.Repeat(string.Format("this : {0}", thisType), 1) : Enumerable.Empty<string>();
            IList<string> parameterText = thisParam.Concat(parameters != null ? parameters.SelectMany(GetParameterText) : new string[0]).ToArray();
            string returnText = returnSpec != null ? string.Format(" : {0}", GetNameText(returnSpec)) : string.Empty;
            string displayName = string.Format("{0} {1}[{2}]{3}", tree.Text, functionDisplayName, string.Join(", ", parameterText), returnText);
            _targets.Add(new EditorNavigationTarget(displayName, navigationType, ruleSpan, ruleSeek, glyph));
        }
        protected virtual Completion CreateSnippetCompletion(VsExpansion expansion, ImageSource defaultExpansionGlyph, IconDescription defaultIconDescription)
        {
            if (string.IsNullOrEmpty(expansion.shortcut))
                return null;

            string displayText = expansion.shortcut;
            string insertionText = expansion.shortcut;
            string description = expansion.description;
            return new Completion(displayText, insertionText, description, defaultExpansionGlyph, defaultIconDescription.ToString());
        }