Ejemplo n.º 1
0
        private void autorunBox_Click(object sender, RoutedEventArgs e)
        {
            if (wnd == null)
            {
                return;
            }
            bool result = false;

            if (autorunBox.IsChecked == true)
            {
                result = DWAS2Interop.SetAutorunState(true);
                if (!result)
                {
                    autorunBox.IsChecked = false;
                }
            }
            else
            {
                result = DWAS2Interop.SetAutorunState(false);
                if (!result)
                {
                    autorunBox.IsChecked = true;
                }
            }
            if (result)
            {
                MessageBox.Show("Operation succeeded.".t(wnd.lang), "DWAS2", MessageBoxButton.OK, MessageBoxImage.Information);
            }
            else
            {
                MessageBox.Show("Operation failed.".t(wnd.lang), "DWAS2", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Ejemplo n.º 2
0
        /*** Event Handlers ***/

        private void HomePage_Loaded(object sender, RoutedEventArgs e)
        {
            DWAS2Helper.SetUserControlLanguage(this);
            wnd = DWAS2Helper.GetUserControlMainWindow(this);
            InitializeLanguageSelectComboBox();
            wnd.OrientationChanged += MainWindow_Orientation_Changed;
            // set autorun state
            autorunBox.IsChecked = DWAS2Interop.GetAutorunState();
        }
Ejemplo n.º 3
0
        public void UpdateDetection()
        {
            var newOrientation = DWAS2Interop.GetDesktopOrientation(config.reverse);

            if (newOrientation != lastOrientation)
            {
                lastOrientation = newOrientation;

                UpdateNotifyIcon();
                UpdateWallpaper();
                UpdateLockscreen();

                OrientationChangedEvent(new OrientationChangedEventArgs(newOrientation));
            }
        }
Ejemplo n.º 4
0
        public MainWindow()
        {
            InitializeComponent();

            // init logger
            string logpath = System.AppDomain.CurrentDomain.BaseDirectory + @"\DWAS2.log";

            GeneralLogger.Initialize(logpath);

            // read and process configuration
            config.ReadConfig();
            ProcessConfig();

            // check hiding
            if (File.Exists(config.wpLandscape) && File.Exists(config.wpPortrait) && File.Exists(config.lcLandscape) && File.Exists(config.lcPortrait))
            {
                this.shouldHideAtStartup = true;
            }

            // read language
            languages = DWAS2LanguageManager.LoadLanguages();
            lang      = DWAS2LanguageManager.SelectLanguage(languages, config.language);
            if (lang.Language.CompareTo(config.language) != 0)
            {
                config.language = lang.Language;
                config.SaveConfig();
            }
            // LANGUAGE IS PROCESSED IN WINDOW_LOADED EVENT HANDLER

            // read orientation
            lastOrientation = DWAS2Interop.GetDesktopOrientation(config.reverse);

            // notify icon
            InitNotifyIcon();

            // initial set
            UpdateDetection();

            // start timer
            InitTimer();
        }
Ejemplo n.º 5
0
        public void UpdateWallpaper()
        {
            string path   = lastOrientation == Orientation.Landscape ? config.wpLandscape : config.wpPortrait;
            PicPos picpos = lastOrientation == Orientation.Landscape ? config.wpPosLandscape : config.wpPosPortrait;

            if (File.Exists(path))
            {
                if (!DWAS2Interop.SetDesktopPicPos(picpos))
                {
                    notifyIcon.ShowBalloonTip(1000, "DWAS2", "DWAS2 failed to set your picture position.".t(lang), WinForms.ToolTipIcon.Error);
                }
                if (!DWAS2Interop.SetWallpaper(path))
                {
                    notifyIcon.ShowBalloonTip(1000, "DWAS2", "DWAS2 failed to set your wallpaper.".t(lang), WinForms.ToolTipIcon.Error);
                    return;
                }
            }
            else
            {
                notifyIcon.ShowBalloonTip(1000, "DWAS2", "DWAS2 wallpaper for current orientation does not exist.".t(lang), WinForms.ToolTipIcon.Error);
            }
        }