Exemplo n.º 1
0
    public static TaskbarElement Create(Window window)
    {
        TaskbarElement taskbar_element =
            GameObject.Instantiate(The.Prefabs.TaskbarElement);

        taskbar_element.Window = window;

        return(taskbar_element);
    }
Exemplo n.º 2
0
        private async Task SetupTaskbar()
        {
            taskbar = TaskBarFactory.GetTaskbar();
            process = await taskbar.AddToTaskbar();

            Size      = new Size(452, 30);
            var(X, Y) = ConfigUtils.StringToPosition(Config.Get(ConfigKeys.BarPosition));
            process.SetPosition(X, Y);
        }
Exemplo n.º 3
0
    void Update()
    {
        IEnumerable <Window> windows_with_taskbar_elements =
            TaskbarElements.Select(taskbar_element => taskbar_element.Window);

        foreach (Window window in The.WindowContainer.Windows)
        {
            if (window.IsOpen && !windows_with_taskbar_elements.Contains(window))
            {
                TaskbarElement.Create(window).transform.SetParent(TaskbarElementsContainer, false);
            }
        }

        Vector2Int offset = Vector2Int.zero;

        foreach (TaskbarElement taskbar_element in TaskbarElements)
        {
            taskbar_element.RectTransform.anchoredPosition = new Vector3(offset.x, offset.y, 0);

            offset += taskbar_element.RectTransform.rect.size.YChangedTo(0).ToVector2Int();
        }
    }
Exemplo n.º 4
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            try
            {
                // set up the tray icon
                System.Windows.Forms.NotifyIcon notifyIcon = _trayIcon = new System.Windows.Forms.NotifyIcon
                {
                    Icon    = new System.Drawing.Icon("Resources\\icon.ico"),
                    Text    = Title,
                    Visible = true
                };
                _trayIcon.DoubleClick +=
                    delegate(object sender2, EventArgs args)
                {
                    Show();
                    WindowState = WindowState.Normal;
                };

                // grab the handles of everything we'll be tweaking
                _taskbar     = new TaskbarElement("Shell_TrayWnd");
                _startButton = new TaskbarElement(_taskbar, "Start", 1);
                _startMenu   = new TaskbarElement("Windows.UI.Core.CoreWindow", "Start");

                // get the buttons on the taskbar that directly have the taskbar as a parent
                for (int i = 0; i < 3; i++)
                {
                    _taskbarButtons[i] = new TaskbarElement(_taskbar, "TrayButton", (i + 1));
                }

                _cortanaButton     = new TaskbarElement(_taskbar, "TrayButton", 1);
                _cortanaSearchMenu = new TaskbarElement("Windows.UI.Core.CoreWindow", "Cortana");
                _mainAppContainer  = new TaskbarElement(_taskbar, "ReBarWindow32", 1);
                _trayIconContainer = new TaskbarElement(_taskbar, "TrayNotifyWnd", 1);
                //_volumeContainer = new TaskbarElement(_taskbar, "")
                _showDesktopButton = new TaskbarElement(_trayIconContainer, "TrayShowDesktopButtonWClass", 1);

                // set up sliders
                SliderTaskWidth.Maximum = _taskbar.GetWidth();

                //if (CheckAutoStart.IsChecked == true) {
                // create an instance of a dummy taskbar with some settings
                _dummyTaskbar                    = new Window();
                _dummyTaskbar.WindowState        = WindowState.Normal;
                _dummyTaskbar.WindowStyle        = WindowStyle.None;
                _dummyTaskbar.ResizeMode         = ResizeMode.NoResize;
                _dummyTaskbar.Width              = _taskBarWidth;
                _dummyTaskbar.Height             = _taskbar.GetHeight();
                _dummyTaskbar.Top                = _taskbar.GetTop();
                _dummyTaskbar.Left               = (_taskbar.GetWidth() / 2) - _dummyTaskbar.Width / 2;
                _dummyTaskbar.AllowsTransparency = true;
                UpdateDummySliders();
                _dummyTaskbar.ShowInTaskbar = false;
                _dummyTaskbar.Hide();
                //}
            }
            catch (Exception ex)
            {
                using (StreamWriter sw = new StreamWriter("debug.txt"))
                {
                    sw.WriteLine(ex);
                }
            }

            if (!File.Exists("settings.json"))
            {
                CreateSettings();
                _settings.LoadSettings();
            }
            else
            {
                _settings.LoadSettings();

                //TODO (justin): add some error checking here
                SliderTaskWidth.Value            = Convert.ToInt16(_settings.FindSetting("width").SettingValue);
                SliderDummyTaskRed.Value         = Convert.ToByte(_settings.FindSetting("red").SettingValue);
                SliderDummyTaskGreen.Value       = Convert.ToByte(_settings.FindSetting("green").SettingValue);
                SliderDummyTaskBlue.Value        = Convert.ToByte(_settings.FindSetting("blue").SettingValue);
                SliderDummyTaskOpacity.Value     = Convert.ToByte(_settings.FindSetting("opacity").SettingValue);
                CheckTaskbarVisible.IsChecked    = Convert.ToBoolean(_settings.FindSetting("showtaskbar").SettingValue);
                CheckHideStart.IsChecked         = Convert.ToBoolean(_settings.FindSetting("hidestartbutton").SettingValue);
                CheckHideShowDesk.IsChecked      = Convert.ToBoolean(_settings.FindSetting("hideshowdesktopbutton").SettingValue);
                CheckAutoStart.IsChecked         = Convert.ToBoolean(_settings.FindSetting("autostart").SettingValue);
                CheckLaunchWithWindows.IsChecked = Convert.ToBoolean(_settings.FindSetting("launchwithwindows").SettingValue);
            }

            textBoxSettings.Text = File.ReadAllText("settings.json");

            _dummyTaskbar?.Show();

            Focus();

            // set up background worker
            _bgWorker = new BackgroundWorker
            {
                WorkerSupportsCancellation = true
            };
            _bgWorker.DoWork += _bgWorker_DoWork;

            // TODO: create method for the button click action
            //       because this is stupid
            if (CheckAutoStart.IsChecked == true)
            {
                ButtonStart_Click(null, null);
            }
        }