Exemplo n.º 1
0
 public void SetImage(Image img, Color overTint, Color downTint)
 {
     NormalImage   = img;
     OverImage     = img.Tint(overTint);
     DownImage     = img.Tint(downTint);
     DisabledImage = ToolStripRenderer.CreateDisabledImage(img);
 }
        public void UpdateVolumeState()
        {
            if (Globals.AudioAvailable)
            {
                Utils.InvokeIfRequired(this, () =>
                {
                    if (updateVolumeQueue.Count == 0)
                    {
                        VolumeTrackBar.Value = Globals.AudioHandler.FriendlyVolume;
                    }
                    VolumeLabel.Text = $"{(Globals.AudioHandler.AudioController.DefaultPlaybackDevice.IsMuted ? ("Muted") : VolumeTrackBar.Value + "%")}";

                    Image iconImg = Utils.GetIconFromResource(Globals.AudioHandler.AudioController.DefaultPlaybackDevice.IconPath).ToBitmap();
                    if (Globals.AudioHandler.AudioController.DefaultPlaybackDevice.IsMuted)
                    {
                        iconImg = ToolStripRenderer.CreateDisabledImage(iconImg);
                    }
                    AudioDevicePictureBox.Image = iconImg;
                    if (!Globals.AudioHandler.AudioController.DefaultPlaybackDevice.IsMuted)
                    {
                        AudioDevicePictureBox.BackColor = Color.Transparent;
                    }
                    else
                    {
                        AudioDevicePictureBox.BackColor = Color.FromArgb(255, 225, 225, 225);
                    }
                    Invalidate();
                    Update();
                    if (Globals.AudioHandler.AudioController.DefaultPlaybackDevice.IsMuted)
                    {
                        UpdatePeakValue(0);
                    }
                });
            }
        }
Exemplo n.º 3
0
        public override bool Initialize(IPluginHost host)
        {
            Terminate();

            if (host == null)
            {
                return(false);
            }
            m_host = host;
            PluginTranslate.Init(this, KeePass.Program.Translation.Properties.Iso6391Code);
            PluginTranslate.TranslationChanged += (o, e) => { PEDCalcValue.SetTranslatedUnits(); };
            Tools.DefaultCaption = PluginTranslate.PluginName;
            Tools.PluginURL      = "https://github.com/rookiestyle/pedcalc/";

            m_iconActive   = GfxUtil.ScaleImage(Resources.pedcalc, DpiUtil.ScaleIntX(16), DpiUtil.ScaleIntY(16));
            m_iconInactive = ToolStripRenderer.CreateDisabledImage(m_iconActive);

            PwEntry.EntryTouched            += OnEntryTouched;
            GlobalWindowManager.WindowAdded += OnWindowAdded;

            Tools.OptionsFormShown += Tools_OptionsFormShown;

            PEDCValueDAO.StartLogging();

            m_host.ColumnProviderPool.Add(m_cp);

            AddMenu();

            return(true);
        }
Exemplo n.º 4
0
        internal Image GetImageForTreeNode(string key, bool disabled)
        {
            if (string.IsNullOrEmpty(key))
            {
                key = "Default";
            }

            if (!scaledImagesCacheForTree.TryGetValue(key, out var image))
            {
                return(null);
            }

            if (disabled)
            {
                if (!scaledImagesCacheForTreeDisabled.TryGetValue(key, out var imageDisabled))
                {
                    try
                    {
                        imageDisabled = ToolStripRenderer.CreateDisabledImage(image);
                    }
                    catch { }

                    if (imageDisabled != null)
                    {
                        scaledImagesCacheForTreeDisabled[key] = imageDisabled;
                    }
                }

                image = imageDisabled;
            }

            return(image);

            //return scaledImagesCacheForTree[ key ];
        }
Exemplo n.º 5
0
        /// <summary>
        /// Initialization of the application and initial state of settings.
        /// </summary>
        public FrmMain()
        {
            // Timer elapses every second
            PomoTimer.Interval = 1000;

            // Set timer to event handler
            PomoTimer.Tick += TimeEventProcessor;

            // Initialize form
            InitializeComponent();

            // Force settings form to top
            _settings = new Settings();
            _settings.ShowDialog();

            // Set default PomoTimer
            _nextBreak = _settings.PomoTimer * 60;

            // Set timer label to 0:00
            lblTimer.Text = @"0:00";

            // Created DisabledPomo
            _disabledPomo = ToolStripRenderer.CreateDisabledImage(_pomoIcon);

            // Set PomoIcons to Disabled
            UpdatePomoIcon();
        }
Exemplo n.º 6
0
        private void GetGridBodyAndSaveToImage()
        {
            //get the rectangle of the DataGridView in the Screen (not in the form) or the actual position of the
            //DataGridView in the Screen monitor
            GetWindowRect(Handle, out GridRectangle);

            //calculate the dimension of the bitmap and create it
            int rowHeadsWidth     = RowHeadersVisible ? RowHeadersWidth : 0;
            int columnHeadsHeight = ColumnHeadersVisible ? ColumnHeadersHeight : 0;
            int width             = Width - rowHeadsWidth - 1;
            int height            = Height - columnHeadsHeight - 1;

            GridCellsImageCopy = new Bitmap(width, height);

            //copy the DataGrids content to the bitmap but don't include the rowheader and columnheader
            using (Graphics bitmapGraphics = Graphics.FromImage(GridCellsImageCopy))
            {
                bitmapGraphics.CopyFromScreen(GridRectangle.Left + rowHeadsWidth, GridRectangle.Top + columnHeadsHeight,
                                              0, 0, new Size(GridRectangle.Width, GridRectangle.Height), CopyPixelOperation.SourceCopy);
            }

            //make the image grayscale only if the grid cells are not empty
            if (Rows.Count > 0)
            {
                GridCellsImageCopy = (Bitmap)ToolStripRenderer.CreateDisabledImage(GridCellsImageCopy);
            }
        }
Exemplo n.º 7
0
 protected override void OnRenderItemImage(ToolStripItemImageRenderEventArgs e)
 {
     if (ThemeConfig.EffectiveTheme != PdnTheme.Aero)
     {
         base.OnRenderItemImage(e);
     }
     else
     {
         Rectangle     imageRectangle = e.ImageRectangle;
         Image         normalImage    = e.Image;
         ToolStripItem item           = e.Item;
         if (normalImage != null)
         {
             Image image2 = null;
             if (!item.Enabled)
             {
                 image2 = ToolStripRenderer.CreateDisabledImage(normalImage);
             }
             Image     image   = image2 ?? normalImage;
             Rectangle srcRect = new Rectangle(Point.Empty, image.Size);
             e.Graphics.DrawImage(image, imageRectangle, srcRect, GraphicsUnit.Pixel);
             if (image2 != null)
             {
                 image2.Dispose();
                 image2 = null;
             }
         }
     }
 }
Exemplo n.º 8
0
 private void setIconsDisabled()
 {
     IconStop.Image  = ToolStripRenderer.CreateDisabledImage(disabledImages[(int)IconOrder.Stop]);
     IconUp.Image    = ToolStripRenderer.CreateDisabledImage(disabledImages[(int)IconOrder.Up]);
     IconDown.Image  = ToolStripRenderer.CreateDisabledImage(disabledImages[(int)IconOrder.Down]);
     IconLeft.Image  = ToolStripRenderer.CreateDisabledImage(disabledImages[(int)IconOrder.Left]);
     IconRight.Image = ToolStripRenderer.CreateDisabledImage(disabledImages[(int)IconOrder.Right]);
 }
Exemplo n.º 9
0
        public void ToolStripRenderer_CreateDisabledImage_Invoke_Success()
        {
            using var image = new Bitmap(10, 11);
            Image result = Assert.IsType <Bitmap>(ToolStripRenderer.CreateDisabledImage(image));

            Assert.NotSame(result, image);
            Assert.Equal(new Size(10, 11), result.Size);
        }
Exemplo n.º 10
0
        /// <summary>
        /// Ignore the fancy name for this function. If the path is null or invalid then grayscale the image.
        /// </summary>
        /// <param name="path"></param>
        /// <returns></returns>
        private void ApplyGameIconRendererGrayscaleByPathValidation(string path, PictureBox pb)
        {
            bool isValid = IsPathValid(path);

            if (isValid == false)
            {
                pb.BackgroundImage = ToolStripRenderer.CreateDisabledImage(pb.BackgroundImage);
            }
        }
Exemplo n.º 11
0
 private void ChangeQuestionHint_Click(object sender, EventArgs e)
 {
     ResetAnswersState();
     changeQuestionHint.Enabled = false;
     FillQuestionData(answersPanel, questionController.GetCurrentReplacerQuestion());
     ShuffleAnswers();
     changeQuestionHint.BackgroundImage = ToolStripRenderer.CreateDisabledImage(changeQuestionHint.BackgroundImage);
     questionController.SetQuestionController(QuestionType.ReplacerQuestion);
 }
Exemplo n.º 12
0
        private Image GetImage(string coin)
        {
            ResourceManager rm  = Properties.Resources.ResourceManager;
            Bitmap          img = (Bitmap)rm.GetObject(coin);

            if (img != null && !active)
            {
                return(ToolStripRenderer.CreateDisabledImage(img));
            }
            return(img);
        }
Exemplo n.º 13
0
 public void LoadFile(string filePath)
 {
     renderer              = new WaveFormRenderer();
     Image                 = renderer.Render(filePath, averagePeakProvider, soundCloudOrangeTransparentBlocks);
     ImageG                = ToolStripRenderer.CreateDisabledImage(Image);
     reader                = new WaveFileReader(filePath);
     handleLeft.Left       = 0;
     handleRight.Left      = imgWaveform.Width - handleRight.Width;
     originalDuration.Text = endTime.Text = FormatTime(reader.TotalTime.TotalMilliseconds);
     UpdateImage();
 }
Exemplo n.º 14
0
        private void FMain_Load(object sender, EventArgs eventArgs)
        {
            MaximumSize = Screen.PrimaryScreen.WorkingArea.Size;
            using (var smallIcon = new Icon(Icon, new Size(16, 16))) {
                picIcon.InitialImage = picIcon.Image = smallIcon.ToBitmap();
                picIcon.ErrorImage   = ToolStripRenderer.CreateDisabledImage(picIcon.InitialImage);
            }

            ApplyColorScheme(ColorScheme.Default);
            CursorFixup(this);

            mnuEditSelectClearAll.ShortcutKeyDisplayString        = "Esc";
            mnuScoreNoteStartPositionAt0.ShortcutKeyDisplayString = "0";
            mnuScoreNoteStartPositionAt1.ShortcutKeyDisplayString = "1";
            mnuScoreNoteStartPositionAt2.ShortcutKeyDisplayString = "2";
            mnuScoreNoteStartPositionAt3.ShortcutKeyDisplayString = "3";
            mnuScoreNoteStartPositionAt4.ShortcutKeyDisplayString = "4";
            mnuScoreNoteStartPositionAt5.ShortcutKeyDisplayString = "5";
            mnuScoreNoteStartPositionTo0.ShortcutKeyDisplayString = "P";
            mnuScoreNoteStartPositionTo1.ShortcutKeyDisplayString = "Q";
            mnuScoreNoteStartPositionTo2.ShortcutKeyDisplayString = "W";
            mnuScoreNoteStartPositionTo3.ShortcutKeyDisplayString = "E";
            mnuScoreNoteStartPositionTo4.ShortcutKeyDisplayString = "R";
            mnuScoreNoteStartPositionTo5.ShortcutKeyDisplayString = "T";

            mnuEditModeSelect.ShortcutKeyDisplayString    = "F";
            mnuEditModeTap.ShortcutKeyDisplayString       = "A";
            mnuEditModeHoldFlick.ShortcutKeyDisplayString = "S";
            mnuEditModeSlide.ShortcutKeyDisplayString     = "D";

            DirectorSettingsManager.LoadSettings();
            ApplySettings(DirectorSettingsManager.CurrentSettings);

            _liveControl = new LiveControl();
            _liveControl.PreloadWave(TapAudioFilePath);
            _liveControl.PreloadWave(FlickAudioFilePath);
            _liveControl.PreloadWave(SlideAudioFilePath);

            // Localize before setting command shortcut display strings.
            Localize(LanguageManager.Current);
            this.MonitorLocalizationChange();

            RegisterCommands();

            CmdProjectNew.Command.Execute(null);
            CmdScoreNoteStartPositionSetAt.Command.Execute(NotePosition.Default);

            if (Program.StartupOptions.BvspCommunicationEnabled)
            {
                _communication = new SDCommunication(this);
                _communication.Server.Start(0);
            }
        }
        /// <summary>
        /// Initializes the supported tools launch commands.
        /// </summary>
        public override void SetupCommands()
        {
            Trace.TraceInformation("Launch Commands:");
            Trace.Indent();
            Image imgIcon = null;

            ClearLaunchCommands();

            string strCommand = GetBOSSLaunchCommand();

            Trace.TraceInformation("BOSS Command: {0} (IsNull={1})", strCommand, (strCommand == null));
            if (strCommand != null)
            {
                imgIcon = File.Exists(strCommand) ? Icon.ExtractAssociatedIcon(strCommand).ToBitmap() : null;
                AddLaunchCommand(new Command("BOSS", "Launch BOSS", "Launches BOSS.", imgIcon, LaunchBOSS, true));
            }
            else
            {
                imgIcon = ToolStripRenderer.CreateDisabledImage((Properties.Resources.oblivion_logo.ToBitmap()));
                AddLaunchCommand(new Command("Config#BOSS", "Config BOSS", "Configures BOSS.", imgIcon, ConfigBOSS, true));
            }

            strCommand = GetWryeBashLaunchCommand();
            Trace.TraceInformation("Wrye Bash Command: {0} (IsNull={1})", strCommand, (strCommand == null));
            if (File.Exists(strCommand))
            {
                imgIcon = File.Exists(strCommand) ? Icon.ExtractAssociatedIcon(strCommand).ToBitmap() : null;
                AddLaunchCommand(new Command("WryeBash", "Launch Wrye Bash", "Launches Wrye Bash.", imgIcon, LaunchWryeBash, true));
            }
            else
            {
                imgIcon = ToolStripRenderer.CreateDisabledImage((Properties.Resources.oblivion_logo.ToBitmap()));
                AddLaunchCommand(new Command("Config#Wrye Bash", "Config Wrye Bash", "Configures Wrye Bash.", imgIcon, ConfigWryeBash, true));
            }

            strCommand = GetLOOTLaunchCommand();
            Trace.TraceInformation("LOOT Command: {0} (IsNull={1})", strCommand, (strCommand == null));
            if ((strCommand != null) && (File.Exists(strCommand)))
            {
                imgIcon = File.Exists(strCommand) ? Icon.ExtractAssociatedIcon(strCommand).ToBitmap() : null;
                AddLaunchCommand(new Command("LOOT", "Launch LOOT", "Launches LOOT.", imgIcon, LaunchLOOT, true));
            }
            else
            {
                imgIcon = ToolStripRenderer.CreateDisabledImage((Properties.Resources.oblivion_logo.ToBitmap()));
                AddLaunchCommand(new Command("Config#LOOT", "Config LOOT", "Configures LOOT.", imgIcon, ConfigLOOT, true));
            }

            Trace.Unindent();
        }
Exemplo n.º 16
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="m"></param>
        protected override void WndProc(ref Message m)
        {
            base.WndProc(ref m);

            if (m.Msg == WM_PAINT)
            {
                Graphics g = Graphics.FromHwnd(Handle);

                if (this.Enabled)
                {
                    Rectangle rect = new Rectangle(this.Width - 17, 1, 16, this.Height - 2);
                    //arrow background Color Redraw
                    g.FillRectangle(bshArrowBackgroundDefaultColor, rect);
                    //arrow Draw
                    g.DrawImage(_image, rect.X + 3, rect.Y + 6, 8, 8);
                }
                else
                {
                    Rectangle rect = new Rectangle(2, 1, this.Width - 2, this.Height - 2);
                    Rectangle arrowRect = new Rectangle(this.Width - 17, 1, 16, this.Height - 2);
                    //arrow background Color Redraw
                    g.FillRectangle(bshArrowBackgroundDisabledColor, rect);
                    //arrow Draw
                    g.DrawImage(ToolStripRenderer.CreateDisabledImage(_image), arrowRect.X + 3, arrowRect.Y + 6, 8, 8);

                    IntPtr brush;
                    brush = CreateSolidBrush(ColorTranslator.ToWin32(MenConstants.Thin));
                    m.Result = brush;
                }
                Rectangle bounds = new Rectangle(0, 0, Width, Height);
                if (this.Focused)
                {
                    ControlPaint.DrawBorder(g, bounds,
                    _focusBorderColor, 2, ButtonBorderStyle.Solid,
                    _focusBorderColor, 2, ButtonBorderStyle.Solid,
                    _focusBorderColor, 2, ButtonBorderStyle.Solid,
                    _focusBorderColor, 2, ButtonBorderStyle.Solid);
                }
                else
                {
                    ControlPaint.DrawBorder(g, bounds,
                     _defaultBorderColor, 1, ButtonBorderStyle.Solid,
                     _defaultBorderColor, 1, ButtonBorderStyle.Solid,
                     _defaultBorderColor, 1, ButtonBorderStyle.Solid,
                     _defaultBorderColor, 1, ButtonBorderStyle.Solid);
                }

            }
            
        }
Exemplo n.º 17
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="e"></param>
        private void HoverPaint(PaintEventArgs e)
        {
            Point     pt;
            Rectangle rect;

            pt   = new Point(2, 2);
            rect = new Rectangle(pt, new Size(16, 16));
            e.Graphics.FillRectangle(Enabled ? _bshDefaultBackGround : _bshDisabledBackGround, rect);
            if (Checked)
            {
                e.Graphics.DrawImage(Enabled ? _imgCheckMark : ToolStripRenderer.CreateDisabledImage(_imgCheckMark), rect);
            }
            e.Graphics.DrawRectangle(Enabled ? _penHoverBorder : _penDisabledBorder, rect);
        }
Exemplo n.º 18
0
        private void InitializeIcons()
        {
            enabledImages[(int)IconOrder.Stop]  = Image.FromFile(@"icons\if_6_-_Cross_1815573.png");
            enabledImages[(int)IconOrder.Up]    = Image.FromFile(@"icons\if_1_-_Up_1815558.png");
            enabledImages[(int)IconOrder.Down]  = Image.FromFile(@"icons\if_2_-_Down_1815568.png");
            enabledImages[(int)IconOrder.Left]  = Image.FromFile(@"icons\if_4_-_Left_1815571.png");
            enabledImages[(int)IconOrder.Right] = Image.FromFile(@"icons\if_3_-_Right_1815570.png");

            for (int i = 0; i < 5; i++)
            {
                disabledImages[i] = ToolStripRenderer.CreateDisabledImage(enabledImages[i]);
            }

            setIconsDisabled();
        }
Exemplo n.º 19
0
            /// <summary>
            /// Render the button images based on the size of the button
            /// </summary>
            /// <param name="e"></param>
            protected override void OnRenderItemImage(ToolStripItemImageRenderEventArgs e)
            {
                if (e.Item is ToolStripButton && e.Image != null && !(e.Item is ToolStripDropDownButton))
                {
                    // Calculate the correct location to draw
                    Rectangle r = e.Item.ContentRectangle;
                    if (e.Item.Pressed || ((ToolStripButton)e.Item).Checked)
                    {
                        r.Y += 1;
                        r.X += 1;
                    }
                    // Calculate the correct image to draw
                    Image i = e.Image;
                    if (!e.Item.Enabled)
                    {
                        i = ToolStripRenderer.CreateDisabledImage(e.Image);
                    }

                    // Maintain the image aspect ratio and center in button
                    int   imageWidth       = i.Width;
                    int   imageHeight      = i.Height;
                    float imageAspect      = (float)imageWidth / (float)imageHeight;
                    int   origButtonWidth  = r.Width;
                    int   origButtonHeight = r.Height;
                    float origButtonAspect = (float)origButtonWidth / (float)origButtonHeight;

                    // Adjust the Button aspect ratio
                    if (imageAspect < origButtonAspect)
                    {
                        r.Width = (int)Math.Round(imageAspect * origButtonHeight);
                    }
                    else if (imageAspect > origButtonAspect)
                    {
                        r.Height = (int)Math.Round(origButtonWidth / imageAspect);
                    }

                    // Center Image in Button
                    r.X += (origButtonWidth - r.Width) / 2;
                    r.Y += (origButtonHeight - r.Height) / 2;

                    // Draw the image
                    e.Graphics.DrawImage(i, r);
                }
                else
                {
                    base.OnRenderItemImage(e);
                }
            }
Exemplo n.º 20
0
        private void FiftyFiftyHint_Click(object sender, EventArgs e)
        {
            fiftyFiftyHint.Enabled         = false;
            fiftyFiftyHint.BackgroundImage = ToolStripRenderer.CreateDisabledImage(fiftyFiftyHint.BackgroundImage);

            var answers = answersPanel.Controls.OfType <Button>().ToList();

            for (int i = rand.Next(-1, 1) * 3, hiddenQuestionsNumber = 0; hiddenQuestionsNumber < 2; i++)
            {
                if (!questionController.IsRightAnswer(answers[Math.Abs(i)].Text))
                {
                    answers[Math.Abs(i)].Visible = false;
                    hiddenQuestionsNumber++;
                }
            }
        }
Exemplo n.º 21
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="e"></param>
        protected override void OnRenderArrow(ToolStripArrowRenderEventArgs e)
        {
            Rectangle rect = e.ArrowRectangle;

            rect.Y     += 6;
            rect.Height = 8;
            rect.Width  = 8;
            if (e.Item.Enabled)
            {
                e.Graphics.DrawImage(_arrowImage, rect);
            }
            else
            {
                e.Graphics.DrawImage(ToolStripRenderer.CreateDisabledImage(_arrowImage), rect);
            }
        }
Exemplo n.º 22
0
 Random rand = new Random();        //???
 public GameForm(IDataProvider dataProvider, IGameRules gameRules)
 {
     questionController = new QuestionController(dataProvider, gameRules);
     questionController.RefreshPackNameList();
     InitializeComponent();
     CreateRadio();
     questionController.timer.Tick += new EventHandler(Timer_Tick);
     if (!gameRules.HintsAvailable)
     {
         foreach (Button item in hintsPanel.Controls)
         {
             item.Enabled         = false;
             item.BackgroundImage = ToolStripRenderer.CreateDisabledImage(item.BackgroundImage);
         }
     }
 }
Exemplo n.º 23
0
 protected override void OnRenderItemCheck(ToolStripItemImageRenderEventArgs e)
 {
     if (ThemeConfig.EffectiveTheme != PdnTheme.Aero)
     {
         base.OnRenderItemCheck(e);
     }
     else
     {
         Rectangle         imageRectangle = e.ImageRectangle;
         ToolStripItem     item           = e.Item;
         Image             image          = item.Image;
         ToolStripMenuItem item2          = item as ToolStripMenuItem;
         if (item2 != null)
         {
             Rectangle rect = imageRectangle;
             rect.Inflate(2, 2);
             HighlightState state = item.Enabled ? HighlightState.Hover : HighlightState.Disabled;
             SelectionHighlight.DrawBackground(e.Graphics, this.penBrushCache, rect, state);
             bool flag = false;
             if ((image == null) && item2.Checked)
             {
                 Image reference = PdnResources.GetImageResource("Icons.ToolStrip.Checked.png").Reference;
                 if (item.Enabled)
                 {
                     image = reference;
                     flag  = false;
                 }
                 else
                 {
                     image = ToolStripRenderer.CreateDisabledImage(reference);
                     flag  = true;
                 }
             }
             if (image != null)
             {
                 Rectangle srcRect = new Rectangle(Point.Empty, image.Size);
                 e.Graphics.DrawImage(image, imageRectangle, srcRect, GraphicsUnit.Pixel);
             }
             if (flag)
             {
                 image.Dispose();
                 image = null;
             }
         }
     }
 }
Exemplo n.º 24
0
        /// <summary>
        /// Adds image watermark into source file, saves resulted file to out file.
        /// </summary>
        /// <param name="sourceFile">Source slides file to proceed.</param>
        /// <param name="outFile">Output slides file.</param>
        /// <param name="options">Watermark options.</param>
        public void AddImageWatermark(
            string sourceFile,
            string outFile,
            ImageWatermarkOptionsModel options
            )
        {
            using (var presentation = new Presentation(sourceFile))
            {
                var size = presentation.SlideSize.Size;
                var img  = ResizeImage(
                    new Bitmap(options.ImageFile),
                    options.ZoomPercent / 100.0
                    ) as Image;

                if (options.IsGrayScaled)
                {
                    img = ToolStripRenderer.CreateDisabledImage(img);
                }

                var imgx = presentation.Images.AddImage(img);

                var height = imgx.Height;
                var width  = imgx.Width;

                var centerW = (size.Width - width) / 2;
                var centerH = (size.Height - height) / 2;

                foreach (var slide in presentation.Slides)
                {
                    IPictureFrame pf = slide.Shapes.AddPictureFrame(
                        ShapeType.Rectangle,
                        centerW, centerH,
                        imgx.Width, imgx.Height,
                        imgx
                        );

                    pf.Name = "WaterMark";

                    pf.LineFormat.FillFormat.FillType = FillType.NoFill;

                    pf.Rotation = options.RotationAngleDegrees;
                }

                presentation.Save(outFile, GetFormatFromSource(sourceFile));
            }
        }
 public void UpdateDeviceState()
 {
     if (Globals.AudioAvailable)
     {
         Utils.InvokeIfRequired(this, () =>
         {
             AudioDeviceNameLabel.Text = $"{Globals.AudioHandler.AudioController.DefaultPlaybackDevice.Name}{(Globals.AudioHandler.AudioController.DefaultPlaybackDevice.IsBluetooth ? " (Bluetooth)" : "")}";
             VolumeLabel.Text          = $"{(Globals.AudioHandler.AudioController.DefaultPlaybackDevice.IsMuted ? ("Muted") : VolumeTrackBar.Value + "%")}";
             VolumeSliderTooltip.SetToolTip(AudioDeviceNameLabel, Globals.AudioHandler.AudioController.DefaultPlaybackDevice.Name);
             Image iconImg = Utils.GetIconFromResource(Globals.AudioHandler.AudioController.DefaultPlaybackDevice.IconPath).ToBitmap();
             if (Globals.AudioHandler.AudioController.DefaultPlaybackDevice.IsMuted)
             {
                 iconImg = ToolStripRenderer.CreateDisabledImage(iconImg);
             }
             AudioDevicePictureBox.Image = iconImg;
             UpdateVolumeState();
         });
     }
 }
Exemplo n.º 26
0
        private void CreateRuleIcon()
        {
            if (Rule.Icon != null)
            {
                (icon, iconGrayScale) = (Rule.Icon, (Bitmap)ToolStripRenderer.CreateDisabledImage(Rule.Icon));
            }
            else if (File.Exists(firewallRuleDto.ProgramPath))
            {
                icon          = GetExeIcon(firewallRuleDto.ProgramPath);
                iconGrayScale = (Bitmap)ToolStripRenderer.CreateDisabledImage(icon);
            }
            else
            {
                icon          = CreateDefaultRuleIcon(true);
                iconGrayScale = CreateDefaultRuleIcon(false);
            }

            DrawDirection(firewallRuleDto.Direction, icon);
            DrawDirection(firewallRuleDto.Direction, iconGrayScale);
        }
        private Image GetDeviceImage(string iconPath)
        {
            using (Icon icon = GetIconFromDeviceIconPath(iconPath))
            {
                if (icon == null)
                {
                    return(null);
                }

                Image image = icon.ToBitmap();
                if (State == AudioDeviceState.Active)
                {
                    return(image);
                }

                using (image)
                {
                    return(ToolStripRenderer.CreateDisabledImage(image));
                }
            }
        }
Exemplo n.º 28
0
 public void DrawItemPluginIndicator(Graphics g, ToolStripItem item)
 {
     if (pluginIndicator.Reference != null)
     {
         int       height   = UIUtil.ScaleHeight(0x10);
         int       width    = UIUtil.ScaleWidth(10);
         Rectangle destRect = new Rectangle((item.Bounds.Width - width) - 9, (item.Bounds.Height - height) / 2, width, height);
         Image     image    = null;
         if (!item.Enabled)
         {
             image = ToolStripRenderer.CreateDisabledImage(pluginIndicator.Reference);
         }
         Image     image2  = image ?? pluginIndicator.Reference;
         Rectangle srcRect = new Rectangle(Point.Empty, image2.Size);
         g.DrawImage(image2, destRect, srcRect, GraphicsUnit.Pixel);
         if (image != null)
         {
             image.Dispose();
             image = null;
         }
     }
 }
Exemplo n.º 29
0
        private void RenderImage(Graphics g)
        {
            Contract.Requires(g != null);

            var image = Image;

            if (image == null)
            {
                return;
            }

            var imageRect = ImageRectangle;

            if (!Enabled)
            {
                var disposeImage = false;
                if (Pressed)
                {
                    imageRect.X += 1;
                }
                if (!Enabled)
                {
                    image        = ToolStripRenderer.CreateDisabledImage(image);
                    disposeImage = true;
                }

                g.DrawImage(image, imageRect);

                if (disposeImage)
                {
                    image.Dispose();
                }
                return;
            }

            g.DrawImage(image, imageRect);
        }
Exemplo n.º 30
0
        async private void AnswerButtonClick(object sender, EventArgs e)
        {
            if (questionController.IsRightAnswer(((Button)sender).Text))
            {
                answersPanel.Enabled = false;
                questionController.timer.Stop();
                ((Button)sender).BackColor = Color.ForestGreen;
                await Task.Delay(3000);

                ((Button)sender).BackColor = Color.LightGray;
                answersPanel.Enabled       = true;
                NewQuestion();
            }
            else
            {
                if (IsExtraLifeAvailable)
                {
                    ((Button)sender).BackColor    = Color.Tomato;
                    ((Button)sender).Enabled      = false;
                    extraLifeHint.FlatStyle       = FlatStyle.Standard;
                    extraLifeHint.Enabled         = false;
                    extraLifeHint.BackgroundImage = ToolStripRenderer.CreateDisabledImage(extraLifeHint.BackgroundImage);
                }
                else
                {
                    answersPanel.Enabled = false;
                    questionController.timer.Stop();
                    ((Button)sender).BackColor = Color.Red;
                    answersPanel.Controls.OfType <Button>().Where(x => questionController.IsRightAnswer(x.Text)).FirstOrDefault().BackColor = Color.ForestGreen;
                    await Task.Delay(3000);

                    GameOver();
                }
                IsExtraLifeAvailable = false;
            }
        }