Example #1
0
 void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) {
     switch (connectionId)
     {
     case 1:
     this.myimage = ((System.Windows.Controls.Image)(target));
     
     #line 9 "..\..\..\UserControls\MyCheckUC.xaml"
     this.myimage.MouseLeftButtonDown += new System.Windows.Input.MouseButtonEventHandler(this.myimage_MouseLeftButtonDown);
     
     #line default
     #line hidden
     
     #line 9 "..\..\..\UserControls\MyCheckUC.xaml"
     this.myimage.MouseEnter += new System.Windows.Input.MouseEventHandler(this.myimage_MouseEnter);
     
     #line default
     #line hidden
     
     #line 9 "..\..\..\UserControls\MyCheckUC.xaml"
     this.myimage.MouseLeave += new System.Windows.Input.MouseEventHandler(this.myimage_MouseLeave);
     
     #line default
     #line hidden
     return;
     }
     this._contentLoaded = true;
 }
        public DirectoryListItem(int width, int height, songInfo info)
        {
            itemInfo = info;

            _isPressed = false;
            _background = new System.Windows.Controls.Image();
            _background.Stretch = Stretch.Fill;
            _background.Width = width;
            _background.Height = height;
            this.Children.Add(_background);

            _artist = new System.Windows.Controls.Label();
            _artist.Content = info.artist;
            _artist.Margin = new Thickness(0, 0, 0, 0);
            _artist.FontFamily = new System.Windows.Media.FontFamily("Calibri");
            _artist.FontSize = 20.0;
            _artist.Foreground = System.Windows.Media.Brushes.White;
            this.Children.Add(_artist);

            _title = new System.Windows.Controls.Label();
            _title.Content = info.title;
            _title.FontFamily = new System.Windows.Media.FontFamily("Calibri");
            _title.FontSize = 16.0;
            _title.Foreground = System.Windows.Media.Brushes.White;
            _title.Margin = new Thickness(0, 30, 0, 0);
            this.Children.Add(_title);

            itemInfo = info;
        }
Example #3
0
 public override void OnApplyTemplate()
 {
     base.OnApplyTemplate();
     _currentImageReference = (Image)GetTemplateChild("ImagePresenter");
     _currentImageReference.ImageOpened += GetImageSourceImageOpened;
     _currentImageReference.ImageFailed += GetImageSourceImageFailed;
 }
        /// <summary>
        /// Within the given line add the scarlet box behind the a
        /// </summary>
        private void CreateVisuals(ITextViewLine line)
        {
            //grab a reference to the lines in the current TextView 
            IWpfTextViewLineCollection textViewLines = _view.TextViewLines;
            int start = line.Start;
            int end = line.End;

            //Loop through each character, and place a box around any a 
            for (int i = start; (i < end); ++i)
            {
                if (_view.TextSnapshot[i] == 'a')
                {
                    SnapshotSpan span = new SnapshotSpan(_view.TextSnapshot, Span.FromBounds(i, i + 1));
                    Geometry g = textViewLines.GetMarkerGeometry(span);
                    if (g != null)
                    {
                        GeometryDrawing drawing = new GeometryDrawing(_brush, _pen, g);
                        drawing.Freeze();

                        DrawingImage drawingImage = new DrawingImage(drawing);
                        drawingImage.Freeze();

                        Image image = new Image();
                        image.Source = drawingImage;

                        //Align the image with the top of the bounds of the text geometry
                        Canvas.SetLeft(image, g.Bounds.Left);
                        Canvas.SetTop(image, g.Bounds.Top);

                        _layer.AddAdornment(AdornmentPositioningBehavior.TextRelative, span, null, image, null);
                    }
                }
            }
        }
        private void wdw1_Loaded(object sender, RoutedEventArgs e)
        {
            try
            {
                ImageBrush myBrush = new ImageBrush();
                System.Windows.Controls.Image image = new System.Windows.Controls.Image();
                image.Source = new BitmapImage(
                    new Uri(AppDomain.CurrentDomain.BaseDirectory + "\\Icons\\bg5.png"));
                myBrush.ImageSource = image.Source;
                wdw1.Background = myBrush;

                if (status == "View")
                {
                    using (var ctx = new finalContext())
                    {
                        Domain.Position pos = ctx.Positions.Find(pID);
                        txtPosition.Text = pos.PositionName;
                        txtDesc.Text = pos.Description;
                        btnSave.Content = "Save";
                    }
                }
            }
            catch (Exception ex)
            {
                System.Windows.MessageBox.Show("Runtime Error: " + ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
        }
        public static Image AsImage(BitmapImage bitmapImage)
        {
            Image image = new Image();
            image.Source = bitmapImage;

            return image;
        }
Example #7
0
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            icon = GetTemplateChild("PART_Icon") as Image;

            if (icon != null)
            {
                icon.MouseLeftButtonDown += icon_MouseLeftButtonDown;
                icon.MouseUp += icon_MouseUp;
            }

            minButton = GetTemplateChild("PART_MinButton") as Button;
            maxButton = GetTemplateChild("PART_MaxButton") as Button;
            closeButton = GetTemplateChild("PART_CloseButton") as Button;

            if (minButton != null)
                minButton.Click += button_Click;

            if (maxButton != null)
                maxButton.Click += button_Click;

            if (closeButton != null)
                closeButton.Click += button_Click;
        }
Example #8
0
 public TcpViewModelDataType(TcpRow data)
 {
     Data = data;
     ProccessIcon = new Image();
     ImageName = "Skipped";
     FullPath = "Skipped";
 }
Example #9
0
 public TcpViewModelDataType(TcpRow data, Image icon, string name, string path)
 {
     Data = data;
     ProccessIcon = icon;
     ImageName = name;
     FullPath = path;
 }
        private void btnRun_Click(object sender, RoutedEventArgs e)
        {
            Workbook workbook = new Workbook();
            workbook.LoadFromFile(@"..\..\..\..\..\Data\ImageSample.xls");
            Worksheet sheet = workbook.Worksheets[0];
            //get picture
            ExcelPicture pic = sheet.Pictures[0];

            //save memoryStream
            System.Windows.Controls.Image img = new System.Windows.Controls.Image();
            System.IO.MemoryStream mem = new System.IO.MemoryStream();
            pic.Picture.Save(mem, System.Drawing.Imaging.ImageFormat.Png);
            img.Source = GetBitmapSourceFromStream(mem);
            //create window
            Window imgWindow = new Window();
            imgWindow.Title = "ImageSample";
            imgWindow.WindowStartupLocation = WindowStartupLocation.CenterScreen;
            imgWindow.Width = pic.Picture.Width;
            imgWindow.Height = pic.Picture.Height;
            imgWindow.ResizeMode = ResizeMode.NoResize;
            //set margin
            Thickness thick = new Thickness(0,0,0,0);
            img.Margin = thick;
            imgWindow.Content = img;
            imgWindow.ShowDialog();
        }
Example #11
0
        public CardPack()
        {
            _pack = new List<Card>();
            Uri uri = new Uri("./Images/cards.png", UriKind.Relative);
            source = new BitmapImage(uri);
            _cardFronts = new List<CroppedBitmap>();
            CardBack = new Image();

            int w = source.PixelWidth / 13;
            int h = source.PixelHeight/5;

            for (int s = 0; s < 4; s++)
            {
                for (int v = 0; v < 13; v++)
                {
                    int imageIndex = (s*13) + v;

                    int fx = imageIndex % 13;
                    int fy = imageIndex / 13;

                    Int32Rect sourceRect = new Int32Rect(fx * w, fy * h, w, h);
                    CroppedBitmap front = new CroppedBitmap(source, sourceRect);

                    sourceRect = new Int32Rect(2 * w, 4 * h, w, h);
                    CroppedBitmap back = new CroppedBitmap(source, sourceRect);

                    Image frontImage = new Image {Source = front};
                    Image backImage = new Image { Source = back };

                    Card card = new Card((CardSuit)s, (CardValue)v, frontImage, backImage);
                    _pack.Add(card);
                }
            }
        }
Example #12
0
        void CheckImage(BitmapImage img)
        {
            if(img.IsDownloading)
            {
                Dispatcher.InvokeAsync(() => CheckImage(img), DispatcherPriority.Background);
            }
            else
            {
                var el = new System.Windows.Controls.Image()
                {
                    Source = img,
                    SnapsToDevicePixels = true,
                    UseLayoutRounding = true,
                    MinWidth = LedBadgeLib.BadgeCaps.Width,
                    MinHeight = LedBadgeLib.BadgeCaps.Height,
                    Width = img.Width * ((BitmapSource)img).DpiX / 96,
                    Stretch = Stretch.UniformToFill,
                };
                RenderOptions.SetBitmapScalingMode(img, BitmapScalingMode.NearestNeighbor);
                el.Measure(new Size(LedBadgeLib.BadgeCaps.Width, LedBadgeLib.BadgeCaps.Height));
                el.Arrange(new Rect(0, 0, LedBadgeLib.BadgeCaps.Width, LedBadgeLib.BadgeCaps.Height));

                m_messageQueue.Enqueue(new LedBadgeLib.MessageQueueItem(new LedBadgeLib.WpfVisual(el, dither : Dither)));
            };
        }
Example #13
0
 public void SetCurrentRoom(Image image)
 {
     CurrentRoom.Selected = false;
     var room = _rooms.FirstOrDefault(a => a.Image == image);
     if (room != null) CurrentRoom = room;
     CurrentRoom.Selected = true;
 }
Example #14
0
 public void AddFriend(Image userIcon, string userName, string userStatus, int userID, bool isOnline)
 {
     Friend friend = new Friend(userIcon, userName, userStatus, userID, isOnline);
     friend.RequestShare += friend_RequestShare;
     _friends.Add(friend);
     Update();
 }
        public ImageTransitionControl()
        {
            InitializeComponent();

            _currentImage = Image1;
            _newImage = Image2;
        }
Example #16
0
        private void Window_Loaded_1(object sender, RoutedEventArgs e)
        {
            try
            {
                ImageBrush myBrush = new ImageBrush();
                System.Windows.Controls.Image image = new System.Windows.Controls.Image();
                image.Source = new BitmapImage(
                    new Uri(AppDomain.CurrentDomain.BaseDirectory + "\\Icons\\bg5.png"));
                myBrush.ImageSource = image.Source;
                wdw1.Background = myBrush;
                resetGrid();

                if (status == false)//maintenance
                {
                    btnView.Visibility = Visibility.Hidden;
                    btnAdd.Visibility = Visibility.Hidden;
                    btnRet.Visibility = Visibility.Visible;
                    myLbL.Content = "Bank Retrieval";
                }
            }
            catch (Exception ex)
            {
                System.Windows.MessageBox.Show("Runtime Error: " + ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
        }
        private void wdw1_Loaded(object sender, RoutedEventArgs e)
        {
            try
            {
                ImageBrush myBrush = new ImageBrush();
                System.Windows.Controls.Image image = new System.Windows.Controls.Image();
                image.Source = new BitmapImage(
                    new Uri(AppDomain.CurrentDomain.BaseDirectory + "\\Icons\\bg5.png"));
                myBrush.ImageSource = image.Source;
                //Grid grid = new Grid();
                wdw1.Background = myBrush;

                using (var ctx = new finalContext())
                {
                    FPaymentInfo fp = ctx.FPaymentInfo.Find(fId);
                    double n = 0;
                    n = fp.Amount * (fp.Loan.Service.DaifPenalty / 100);
                    lblDaif.Content = "(Fee: " + n.ToString("N2") + ")";
                    DaifFee = Double.Parse(n.ToString("N2"));
                    n = fp.Amount * (fp.Loan.Service.ClosedAccountPenalty / 100);
                    lblClosed.Content = "(Fee: " + n.ToString("N2") + ")";
                    ClosedFee = Double.Parse(n.ToString("N2"));
                }
            }
            catch (Exception ex)
            {
                System.Windows.MessageBox.Show("Runtime Error: " + ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
        }
Example #18
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ImageButton"/> class.
        /// </summary>
        public ImageButton()
        {
            SetResourceReference(HeightProperty, "DefaultControlHeight");

            var panel = new StackPanel {Orientation = Orientation.Horizontal};

            _icon = new Image {Margin = new Thickness(0, 0, 6, 0)};
            var imageBinding = new Binding("Icon")
                               	{
                               		Source = this,
                               		UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
                               	};
            _icon.SetBinding(Image.SourceProperty, imageBinding);

            panel.Children.Add(_icon);

            _textBlock = new TextBlock();
            var textBinding = new Binding("Content")
                              	{
                              		Source = this,
                              		UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
                              	};
            _textBlock.SetBinding(TextBlock.TextProperty, textBinding);
            panel.Children.Add(_textBlock);

            base.Content = panel;

            SetResourceReference(StyleProperty, typeof (Button));
        }
Example #19
0
        public ImageTarget(String name, String filename)
        {
            image = new System.Windows.Controls.Image();
            grid = new Grid();
            this.name = name;
            LoadImage(filename);
            image.Height = 100;
            image.Width = 100;
            grid.Children.Add(image);

            highlight = new System.Windows.Shapes.Rectangle();
            highlight.Width = 100;
            highlight.Height = 100;
            highlight.Fill = new SolidColorBrush(System.Windows.Media.Color.FromRgb(70, 130, 80));
            highlight.Opacity = 0.4;
            highlight.Visibility = System.Windows.Visibility.Hidden;
            grid.Children.Add(highlight);

            
            select = new System.Windows.Shapes.Rectangle();
            select.Width = 120;
            select.Height = 120;
            select.Fill = new SolidColorBrush(System.Windows.Media.Color.FromRgb(0, 255, 0));
            Grid.SetZIndex(select, -1);
            select.Visibility = System.Windows.Visibility.Hidden;
            grid.Children.Add(select);
            
             
        }
Example #20
0
 public static void SavePicture(Image img)
 {
     //PhotoSet set = this.CurrentPhoto();
     //if (null == set)
     //{
     //    CustomControls.PopToast("图片不存在,无法保存!", "", 0x3e8);
     //}
     //else
     //{
     //    ImageCacherEngine.imgSuffixString = string.Format("480x{0}", 720);
     //    string filename = ImageCacherEngine.FileCacheName(set.ImageUri);
     //    if (IsoStore.FileExists(filename))
     //    {
     //        Stream source = IsoStore.StreamFileFromIsoStore(filename);
     //        if (source.Length > 0L)
     //        {
     //            Picture picture = new MediaLibrary().SavePicture(filename.Substring(7, filename.Length - 7), source);
     //            CustomControls.PopToast("保存成功!", "", 0x3e8);
     //        }
     //    }
     //    else
     //    {
     //        CustomControls.PopToast("图片不存在,无法保存!", "", 0x3e8);
     //    }
     //}
 }
Example #21
0
        public void FillItem(string path,string _name)
        {
            _filepath = path;
            StackPanel ImageStack = new StackPanel();
            ImageStack.Background = System.Windows.Media.Brushes.Transparent;
            ImageStack.Orientation = Orientation.Vertical;
            System.Windows.Controls.Image FileImage = new System.Windows.Controls.Image();

            //set the source!!!
            FileImage.Source = SmartThumnailProvider.GetThumbInt(path, 128, 128,ThumbOptions.BiggerOk);

            TextBlock FileText = new TextBlock();
            FileText.FontSize = 18;
            FileText.TextTrimming = TextTrimming.CharacterEllipsis;
            FileText.Text = _name;
            FileText.TextAlignment = TextAlignment.Center;
            FileText.VerticalAlignment = VerticalAlignment.Bottom;
            FileText.Height = 30;
            FileImage.Height = 100;
            FileImage.Width = 100;
            ImageStack.Children.Add(FileImage);
            ImageStack.Children.Add(FileText);

            this.Content = ImageStack;
        }
 /// <summary>
 /// Defaults to the off state and the image from displayedImage
 /// </summary>
 public ImageToggle(ImageSource otherImage, ref Image displayedImage)
 {
     _img1 = otherImage;
     _img2 = displayedImage.Source;
     _displayedImage = displayedImage;
     Toggled = false;
 }
 /// <summary>
 /// 
 /// </summary>
 /// <param name="target"></param>
 public void SetTargetImage(Image target)
 {
     if (null != target)
     {
         target.Source = this.colorBitmap;
     }
 }
Example #24
0
        private static MemoryStream SaveDrawingImage(ImageSource drawingImage)
        {
            var image = new Image
            {
                Source = drawingImage
            };

            image.Arrange(new Rect(0, 0, drawingImage.Width, drawingImage.Height));

            var settings = Settings.Default;

            var renderTargetBitmap = new RenderTargetBitmap((int)drawingImage.Width, (int)drawingImage.Height, settings.ImageDPI, settings.ImageDPI, PixelFormats.Default);
            renderTargetBitmap.Render(image);

            Settings.Default.Save();

            var encoder = new JpegBitmapEncoder
            {
                QualityLevel = settings.JpgQuality
            };

            encoder.Frames.Add(BitmapFrame.Create(renderTargetBitmap));

            var memoryStream = new MemoryStream();

            encoder.Save(memoryStream);

            return memoryStream;
        }
        public JumpToSlideWindow()
        {
            InitializeComponent();
            var mainWin = DesignerMainWindow.GetInstance();
            for (int i = 0; i < mainWin.lbThumbs.Items.Count; i++)
            {
                var vb = mainWin.lbThumbs.Items[i] as Viewbox;
                var slideImg = (vb.Child as Border).Child as Image;
                if (slideImg == null) continue;

                var thumb = new Image {Source = slideImg.Source};
                if (i == mainWin.GetCurrentSlideNr())
                    thumb.Opacity = 0.7;

                thumb.Width = 110;
                thumb.Height = thumb.Width/1.6666667;

                var brdr = new Border
                    {
                        BorderBrush = Brushes.Black,
                        BorderThickness = new Thickness(2),
                        Margin = new Thickness(1, 3, 2, 3),
                        Child = thumb,
                        Tag = vb.Tag
                    };

                lbSlides.Items.Add(brdr);
            }
        }
        private void CreateDragVisual()
        {
            ClearDragVisual();

            var bitmap = new System.Windows.Media.Imaging.WriteableBitmap(this, null);
            bitmap.Render(this, null);
            bitmap.Invalidate();

            _dragVisual = new System.Windows.Controls.Image();
            _dragVisual.Source = bitmap;

            // find topmost canvas.. (so we can add the drag visual as a child
            // and ensure that it is on top of everything)
            //
            var canvas = this.GetTopmostParentOfType<Canvas>();

            canvas.Children.Add(_dragVisual);

            var point = this.GetRelativePosition(canvas);

            _dragVisual.SetValue(Canvas.TopProperty, point.Y);
            _dragVisual.SetValue(Canvas.LeftProperty, point.X);

            // Really make sure the drag visual is on top
            //
            Canvas.SetZIndex(_dragVisual, Int16.MaxValue);
        }
 private void MetroWindow_Loaded_1(object sender, RoutedEventArgs e)
 {
     try
     {
         ImageBrush myBrush = new ImageBrush();
         System.Windows.Controls.Image image = new System.Windows.Controls.Image();
         image.Source = new BitmapImage(
             new Uri(AppDomain.CurrentDomain.BaseDirectory + "\\Icons\\bg5.png"));
         myBrush.ImageSource = image.Source;
         //Grid grid = new Grid();
         wdw1.Background = myBrush;
         if (status == "Approval")
         {
             lbl1.Content = "View all Applied Loans";
             lbl2.Content = "Update Loans";
         }
         else if (status == "Releasing")
         {
             lbl1.Content = "View all Approved Loans";
             lbl2.Content = "Update Released Loans";
         }
     }
     catch (Exception ex)
     {
         System.Windows.MessageBox.Show("Runtime Error: " + ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
         return;
     }
 }
        public RecordController(int width, int height)
        {
            _isPressed = false;
            _button = new System.Windows.Controls.Image();
            _button.Stretch = Stretch.Fill;
            _button.Width = width;
            _button.Height = height;
            this.Children.Add(_button);

            _artistLabel = new System.Windows.Controls.Label();
            _artistLabel.Content = "Artist";
            _artistLabel.Margin = new Thickness(0, 170, 0, 0);
            _artistLabel.Width = 462;
            _artistLabel.HorizontalContentAlignment = HorizontalAlignment.Center;
            _artistLabel.FontFamily = new System.Windows.Media.FontFamily("Calibri");
            _artistLabel.FontSize = 20.0;
            this.Children.Add(_artistLabel);

            _titleLabel = new System.Windows.Controls.Label();
            _titleLabel.Content = "Title";
            _titleLabel.Margin = new Thickness(100, 260, 0, 0);
            _titleLabel.Width = 262;
            _titleLabel.HorizontalContentAlignment = HorizontalAlignment.Center;
            this.Children.Add(_titleLabel);

        }
		private void OnDragInitialize(object sender, DragInitializeEventArgs args)
		{
			args.AllowedEffects = DragDropEffects.All;
			if (args.OriginalSource.GetType() == typeof(Telerik.Windows.Controls.RadListBoxItem))
			{
				var draggedShape = (args.OriginalSource as Telerik.Windows.Controls.RadListBoxItem).ChildrenOfType<RadDiagramShapeBase>().FirstOrDefault();
				if (draggedShape != null)
				{
					var shapeSize = new Size(draggedShape.ActualWidth, draggedShape.ActualHeight);
					if (shapeSize.Width > 0 && shapeSize.Height > 0)
					{
						var dropInfo = new DiagramDropInfo(shapeSize, SerializationService.Default.SerializeItems(new List<IDiagramItem> {draggedShape}));
						args.Data = dropInfo;
						args.DragVisualOffset = new Point(args.RelativeStartPoint.X - (shapeSize.Width / 2), args.RelativeStartPoint.Y - (shapeSize.Height / 2));

						var draggingImage = new System.Windows.Controls.Image
						{
							Source = new Telerik.Windows.Media.Imaging.RadBitmap(draggedShape).Bitmap,
							Width = shapeSize.Width,
							Height = shapeSize.Height
						};
						args.DragVisual = draggingImage;
					}
				}
			}
		}
Example #30
0
 void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) {
     switch (connectionId)
     {
     case 1:
     this.CheckImage = ((System.Windows.Controls.Image)(target));
     return;
     case 2:
     
     #line 7 "..\..\MainWindow.xaml"
     ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.Green_Click);
     
     #line default
     #line hidden
     return;
     case 3:
     
     #line 8 "..\..\MainWindow.xaml"
     ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.Red_Click);
     
     #line default
     #line hidden
     return;
     case 4:
     
     #line 9 "..\..\MainWindow.xaml"
     ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.Purple_Click);
     
     #line default
     #line hidden
     return;
     }
     this._contentLoaded = true;
 }