示例#1
0
        /// <summary>
        /// Creates a new thumbnail of a certain window.
        /// </summary>
        /// <param name="handle">Handle of the window to clone.</param>
        /// <param name="region">Optional region.</param>
        public void SetThumbnailHandle(WindowHandle handle, ThumbnailRegion region)
        {
            Log.WriteDetails("Setting new thumbnail",
                             "HWND {0}, region {1}", handle, region
                             );

            if (_thumbnail != null && !_thumbnail.IsInvalid)
            {
                _thumbnail.Close();
                _thumbnail = null;
            }

            //Attempt to get top level Form from Control
            Form owner = this.TopLevelControl as Form;

            if (owner == null)
            {
                throw new Exception("Internal error: ThumbnailPanel.TopLevelControl is not a Form.");
            }

            _labelGlass.Visible = false;

            //Register new thumbnail, update regioning directly and refresh thumbnail
            _thumbnail     = DwmManager.Register(owner, handle.Handle);
            _currentRegion = region;
            _regionEnabled = (region != null);
            UpdateThubmnail();
        }
示例#2
0
 private void DoubleAnimation_Completed(object sender, EventArgs e)
 {
     loaded = true;
     if (Sidebar.SidebarWindow.sett.enableGlass)
     {
         DwmManager.EnableBlurBehindWindow(ref handle);
     }
 }
示例#3
0
        public override void PostHandleFormInit(MainForm form)
        {
            //Do not show in task bar, but display notify icon
            //NOTE: this effectively makes Windows ignore the Flip 3D policy set above (on Windows 7)
            //NOTE: this also makes HotKey registration critically fail on Windows 7
            form.ShowInTaskbar = false;

            DwmManager.SetWindowFlip3dPolicy(form, WindowsFormsAero.Flip3DPolicy.ExcludeAbove);

            _icon = new NotificationIcon(form);
        }
示例#4
0
 private void SetGlass()
 {
     if (!this._glassMargins.IsNull && this._glassEnabled)
     {
         DwmManager.EnableGlassFrame(this, this._glassMargins);
     }
     else
     {
         DwmManager.DisableGlassFrame(this);
     }
     base.Invalidate();
 }
示例#5
0
        /*public Padding GlassMargins {
         *  get {
         *      return _glassMargins;
         *  }
         *  set {
         *      _glassMargins = value;
         *
         *      _glassEnabled = (_glassMargins != Padding.Empty);
         *      _glassFull = _glassMargins.AllNegative();
         *
         *      UpdateGlass();
         *  }
         * }*/

        private void UpdateGlass()
        {
            if (DesignMode)
            {
                return;
            }

            if (_glassEnabled)
            {
                DwmManager.EnableGlassFrame(this, _glassMargins);
            }
            else
            {
                DwmManager.DisableGlassFrame(this);
            }

            Invalidate();
        }
示例#6
0
        private void SetGlass()
        {
            if (DesignMode)
            {
                return;
            }

            if (!_glassMargins.IsNull && _glassEnabled)
            {
                DwmManager.EnableGlassFrame(this, _glassMargins);
            }
            else
            {
                DwmManager.DisableGlassFrame(this);
            }

            this.Invalidate();
        }
示例#7
0
        private void LoadAnimation_Completed(object sender, EventArgs e)
        {
            if (DwmManager.IsBlurAvailable && sett.enableGlass)
            {
                DwmManager.EnableBlurBehindWindow(ref Handle);
            }

            shadow.Height = this.Height;
            shadow.Top    = this.Top;

            if (sett.enableShadow)
            {
                shadow.Show();
                shadow.Owner = this;
            }

            if (sett.enableUpdates)
            {
                foreach (string file in Directory.GetFiles(System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "*.old", SearchOption.TopDirectoryOnly))
                {
                    File.Delete(file);
                }

                foreach (string file in Directory.GetFiles(sett.path, "*.old", SearchOption.AllDirectories))
                {
                    File.Delete(file);
                }

                ThreadStart threadStarter = delegate
                {
                    UpdateInfo updateInfo = UpdateManager.CheckForUpdates();
                    if (updateInfo.Version != null && updateInfo.Description != null)
                    {
                        TaskDialogs.UpdateDialog.ShowDialog(updateInfo.Version, updateInfo.Description);
                    }
                };
                Thread thread = new Thread(threadStarter);
                thread.SetApartmentState(ApartmentState.STA);
                thread.Start();
            }
        }
示例#8
0
        private void LongBar_SourceInitialized(object sender, EventArgs e)
        {
            Handle = new WindowInteropHelper(this).Handle;
            ReadSettings();
            ThemesManager.LoadTheme(Sidebar.SidebarWindow.sett.path, sett.theme);
            object enableGlass = ThemesManager.GetThemeParameter(Sidebar.SidebarWindow.sett.path, sett.theme, "boolean", "EnableGlass");

            if (enableGlass != null && !Convert.ToBoolean(enableGlass))
            {
                sett.enableGlass = false;
            }
            object useSystemColor = ThemesManager.GetThemeParameter(Sidebar.SidebarWindow.sett.path, sett.theme, "boolean", "UseSystemGlassColor");

            if (useSystemColor != null && Convert.ToBoolean(useSystemColor))
            {
                Bg.Fill = new SolidColorBrush(DwmManager.ColorizationColor);
                DwmManager.ColorizationColorChanged += new EventHandler(SideBar_DwmColorChanged);
            }

            LocaleManager.LoadLocale(Sidebar.SidebarWindow.sett.path, sett.locale);

            this.Width = sett.width;
            SystemTray.AddIcon(this);
            // Force set sidebar window style to tool window, bypassing the restriction placed on AllowTransparency
            NativeMethods.SetWindowLong(Handle, GetWindowLongMessage.GWL_EXSTYLE, 128);
            SetSide(sett.side);
            this.MaxWidth = SystemParameters.PrimaryScreenWidth / 2;
            this.MinWidth = 31;

            DwmManager.ExcludeFromFlip3D(Handle);
            DwmManager.ExcludeFromPeek(Handle);

            SystemTray.SidebarVisibilityChanged += new SystemTray.SidebarVisibilityChangedEventHandler(SystemTray_SidebarvisibleChanged);

            GetTiles();
        }
示例#9
0
 public override void PostHandleFormInit(MainForm form)
 {
     DwmManager.SetWindowFlip3dPolicy(form, WindowsFormsAero.Flip3DPolicy.ExcludeAbove);
     DwmManager.SetExcludeFromPeek(form, true);
     DwmManager.SetDisallowPeek(form, true);
 }
示例#10
0
        private void ApplySettings()
        {
            if (SidebarWindow.sett.overlapTaskbar && !(bool)OverlapCheckBox.IsChecked)
            {
                AppBar.RestoreTaskbar();
            }

            SidebarWindow.sett.startup        = (bool)AutostartCheckBox.IsChecked;
            SidebarWindow.sett.topMost        = (bool)TopMostCheckBox.IsChecked;
            SidebarWindow.sett.locked         = (bool)LockedCheckBox.IsChecked;
            SidebarWindow.sett.overlapTaskbar = (bool)OverlapCheckBox.IsChecked;
            SidebarWindow.sett.enableGlass    = (bool)AeroGlassCheckBox.IsChecked;
            SidebarWindow.sett.enableShadow   = (bool)ShadowCheckBox.IsChecked;
            SidebarWindow.sett.locale         = LangComboBox.Text;
            SidebarWindow.sett.theme          = ThemesComboBox.Text;
            SidebarWindow.sett.enableUpdates  = (bool)UpdatesCheckBox.IsChecked;

            if (ScreenComboBox.SelectedIndex == 0)
            {
                SidebarWindow.sett.screen = "Primary";
            }
            else
            {
                SidebarWindow.sett.screen = Utils.GetScreenFromFriendlyName(ScreenComboBox.Text).DeviceName;
            }

            if ((bool)AutostartCheckBox.IsChecked)
            {
                try
                {
                    using (RegistryKey key = Registry.CurrentUser.OpenSubKey("Software", RegistryKeyPermissionCheck.ReadWriteSubTree).OpenSubKey("Microsoft").OpenSubKey("Windows").OpenSubKey("CurrentVersion").OpenSubKey("Run", true))
                    {
                        key.SetValue("LongBar", "" + Assembly.GetExecutingAssembly().Location + "", RegistryValueKind.String);
                        key.Close();
                    }
                }
                catch { }
            }
            else
            {
                try
                {
                    using (RegistryKey key = Registry.CurrentUser.OpenSubKey("Software", RegistryKeyPermissionCheck.ReadWriteSubTree).OpenSubKey("Microsoft").OpenSubKey("Windows").OpenSubKey("CurrentVersion").OpenSubKey("Run", true))
                    {
                        key.DeleteValue("LongBar", false);
                        key.Close();
                    }
                }
                catch { }
            }

            if (LocationComboBox.SelectedIndex == 0)
            {
                SidebarWindow.sett.side = AppBarSide.Left;
            }
            else
            {
                SidebarWindow.sett.side = AppBarSide.Right;
            }

            if (DwmManager.IsBlurAvailable && SidebarWindow.sett.enableGlass)
            {
                DwmManager.EnableBlurBehindWindow(ref SidebarHandle);
            }
            else
            {
                DwmManager.DisableBlurBehindWindow(ref SidebarHandle);
            }

            if (ShadowCheckBox.IsChecked == true)
            {
                SidebarWindow.shadow.Show();
            }
            else
            {
                SidebarWindow.shadow.Hide();
            }

            AppBar.AppbarRemove();
            SidebarWindow.SetSide(SidebarWindow.sett.side);

            SidebarWindow.SetTheme(ThemesComboBox.Text);
            SidebarWindow.SetLocale(LangComboBox.Text);
        }