Exemplo n.º 1
0
 private void BlueprintsTargetUpdated(object sender, DataTransferEventArgs e)
 {
     BlueprintNameColumn.Width     = 0;
     BlueprintProgressColumn.Width = 0;
     Blueprints.UpdateLayout();
     BlueprintNameColumn.Width     = new DataGridLength(1, DataGridLengthUnitType.Auto);
     BlueprintProgressColumn.Width = new DataGridLength(1, DataGridLengthUnitType.Auto);
 }
Exemplo n.º 2
0
        private int ToolbarHeight => SystemInformation.CaptionHeight + 6; // couldn't find a proper property returning "29" which is the height I need

        private void MainWindowLoaded(object sender, RoutedEventArgs args)
        {
            var dimensions = SettingsManager.Dimensions;

            Width  = dimensions.Width;
            Left   = dimensions.Left;
            Top    = dimensions.Top;
            Height = dimensions.Height;

            if (dimensions.LeftSideWidth != 1 || dimensions.RightSideWidth != 1)
            {
                ContentGrid.ColumnDefinitions[0].Width = new GridLength(dimensions.LeftSideWidth, GridUnitType.Star);
                ContentGrid.ColumnDefinitions[2].Width = new GridLength(dimensions.RightSideWidth, GridUnitType.Star);
            }

            if (AllowsTransparency)
            {
                ToggleEditMode.Content = viewModel.Languages.Translate("Unlock Window");
                Splitter.Visibility    = Visibility.Hidden;
            }
            else
            {
                ToggleEditMode.Content = viewModel.Languages.Translate("Lock Window");
                ResetWindowPositionButton.Visibility = Visibility.Visible;
            }

            icon = TrayIconManager.Init((o, e) => ShowWindow(),
                                        (o, e) => Close(), ConfigureShortcut,
                                        (o, e) => ToggleEditModeChecked(o, null),
                                        (o, e) => ResetWindowPositionButtonClicked(o, null),
                                        (o, e) => Languages.PromptLanguage(viewModel.Languages));

            var shortcut = SettingsManager.Shortcut;

            HotkeyManager.RegisterHotKey(this, (Keys) new KeysConverter().ConvertFromString(shortcut));
            Blueprints.UpdateLayout();
        }
Exemplo n.º 3
0
        private void PostLoad(WindowDimensions dimensions)
        {
            if (dimensions.LeftSideWidth != 1 || dimensions.RightSideWidth != 1)
            {
                ContentGrid.ColumnDefinitions[0].Width = new GridLength(dimensions.LeftSideWidth, GridUnitType.Star);
                ContentGrid.ColumnDefinitions[2].Width = new GridLength(dimensions.RightSideWidth, GridUnitType.Star);
            }

            if (AllowsTransparency)
            {
                ToggleEditMode.Content  = viewModel.Languages.Translate("Unlock Window");
                MainSplitter.Visibility = Visibility.Hidden;
            }
            else
            {
                ToggleEditMode.Content = viewModel.Languages.Translate("Lock Window");
                ResetWindowPositionButton.Visibility = Visibility.Visible;
            }

            menu = TrayIconManager.BuildContextMenu((o, e) => ShowWindow(),
                                                    (o, e) => Close(),
                                                    ConfigureShortcut,
                                                    (o, e) => ToggleEditModeChecked(o, null),
                                                    (o, e) => ResetWindowPositionButtonClicked(o, null),
                                                    (o, e) => Languages.PromptLanguage(viewModel.Languages),
                                                    () => serverBridge.Toggle(),
                                                    serverBridge.Running,
                                                    (o, e) => { ReleaseNotesManager.ShowReleaseNotes(); },
                                                    Properties.Settings.Default.CurrentVersion,
                                                    (o, e) => { new NotificationSettingsWindow(viewModel.Languages).ShowDialog(); },
                                                    (o, e) => { new GraphicSettingsWindow(viewModel.GraphicSettings).ShowDialog(); },
                                                    (o, e) =>
            {
                System.Diagnostics.Process.Start($"http://localhost:{SettingsManager.ServerPort}/{viewModel.CurrentCommander.Key}/chart");
            },
                                                    (o, e) => ClearAggregationAndRestart(o, null),
                                                    (o, e) => { new SettingsExportWindow(Restart, RefreshShoppingList).ShowDialog(); });

            icon = TrayIconManager.Init(menu);

            try
            {
                var shortcut = SettingsManager.Shortcut;
                var hotKey   = (Keys) new KeysConverter().ConvertFromString(shortcut);

                HotkeyManager.RegisterHotKey(this, hotKey);
            }
            catch
            {
                SettingsManager.Shortcut = null;
                ConfigureShortcut(this, EventArgs.Empty);
                ShowWindow();
            }

            Blueprints.UpdateLayout();
            ShoppingList.UpdateLayout();

            if (!AllowsTransparency)
            {
                saveDimensionScheduler      = new PostponeScheduler(SaveDimensions, 500);
                SizeChanged                += (o, e) => saveDimensionScheduler.Schedule();
                LocationChanged            += (o, e) => saveDimensionScheduler.Schedule();
                MainSplitter.DragCompleted += (o, e) => saveDimensionScheduler.Schedule();
            }
        }
Exemplo n.º 4
0
        private void MainWindowLoaded(object sender, RoutedEventArgs args)
        {
            var dimensions = SettingsManager.Dimensions;

            Width  = dimensions.Width;
            Left   = dimensions.Left;
            Top    = dimensions.Top;
            Height = dimensions.Height;

            if (dimensions.LeftSideWidth != 1 || dimensions.RightSideWidth != 1)
            {
                ContentGrid.ColumnDefinitions[0].Width = new GridLength(dimensions.LeftSideWidth, GridUnitType.Star);
                ContentGrid.ColumnDefinitions[2].Width = new GridLength(dimensions.RightSideWidth, GridUnitType.Star);
            }

            if (AllowsTransparency)
            {
                ToggleEditMode.Content  = viewModel.Languages.Translate("Unlock Window");
                MainSplitter.Visibility = Visibility.Hidden;
            }
            else
            {
                ToggleEditMode.Content = viewModel.Languages.Translate("Lock Window");
                ResetWindowPositionButton.Visibility = Visibility.Visible;
            }

            menu = TrayIconManager.BuildContextMenu((o, e) => ShowWindow(),
                                                    (o, e) => Close(),
                                                    ConfigureShortcut,
                                                    (o, e) => ToggleEditModeChecked(o, null),
                                                    (o, e) => ResetWindowPositionButtonClicked(o, null),
                                                    (o, e) => Languages.PromptLanguage(viewModel.Languages),
                                                    () => serverBridge.Toggle(),
                                                    serverBridge.Running,
                                                    (o, e) =>
            {
                ReleaseNotesManager.ShowReleaseNotes();
            },
                                                    Properties.Settings.Default.CurrentVersion,
                                                    (o, e) =>
            {
                ThresholdsManagerWindow.ShowThresholds(viewModel.Languages, viewModel.CurrentCommander.Value.State.Cargo, viewModel.CurrentCommander.Key);
            },
                                                    (o, e) =>
            {
                new NotificationSettingsWindow(viewModel.Languages).ShowDialog();
            },
                                                    (o, e) =>
            {
                new GraphicSettingsWindow(viewModel.GraphicSettings).ShowDialog();
            });

            icon = TrayIconManager.Init(menu);

            try
            {
                var shortcut = SettingsManager.Shortcut;
                var hotKey   = (Keys) new KeysConverter().ConvertFromString(shortcut);

                HotkeyManager.RegisterHotKey(this, hotKey);
            }
            catch
            {
                SettingsManager.Shortcut = null;
                ConfigureShortcut(this, EventArgs.Empty);
                ShowWindow();
            }

            Blueprints.UpdateLayout();
            ShoppingList.UpdateLayout();

            if (!AllowsTransparency)
            {
                saveDimensionScheduler      = new PostponeScheduler(SaveDimensions, 500);
                SizeChanged                += (o, e) => saveDimensionScheduler.Schedule();
                LocationChanged            += (o, e) => saveDimensionScheduler.Schedule();
                MainSplitter.DragCompleted += (o, e) => saveDimensionScheduler.Schedule();
            }
        }