/// <summary>
        /// Initializes a new instance of the <see cref="MainViewModel"/> class.
        /// Konstruktor Klasy, przypisuje nazwe uzytkownika, wywo³uje <see cref="TME_SAPEntities.Init"/>, <see cref="initSap"/> oraz pobiera numer u¿ytkownika z SAP.
        /// </summary>
        public MainViewModel()
        {
            CultureResources.ChangeCulture(new System.Globalization.CultureInfo(Properties.Settings.Default.Language));
            TME_SAPEntities.Init();
            initSap();
            GeneratePerNr();
            Pernr = _pernr;


            try
            {
                AutoUpdater.ReportErrors          = false;
                AutoUpdater.ShowSkipButton        = false;
                AutoUpdater.ShowRemindLaterButton = false;
                AutoUpdater.RunUpdateAsAdmin      = false;

                DispatcherTimer timer = new DispatcherTimer {
                    Interval = TimeSpan.FromSeconds(5)
                };
                timer.Tick += delegate
                {
                    AutoUpdater.Start(@"\\ma01\Firma\ApplicationUpdates\SmallStacker\AutoUpdaterTest.xml");
                    timer.Stop();
                };
                timer.Start();
            }
            catch (Exception ex)
            {
                Messenger.Default.Send(new LogMessage(ex.Message, LogType.ERROR), "Log");
            }
        }
Exemple #2
0
        public static List <SettingsCategory> LoadSettings()
        {
            List <SettingsCategory> categories = new List <SettingsCategory>();

            setup(ref categories);
            return(categories);

            void setup(ref List <SettingsCategory> list)
            {
                var interf = new SettingsCategory("Interface");

                interf.Options.Add(
                    new DropdownSettingsOption(
                        "ui_language",
                        "Language",
                        new Dictionary <string, string> {
                    { "Czech", "cs-CZ" },
                    { "English", "en" }
                },
                        (s) => { CultureResources.ChangeCulture(s); }
                        )
                    );

                list.Add(interf);
            }
        }
Exemple #3
0
        private static void SetLanguage()
        {
            if (string.IsNullOrWhiteSpace(Properties.Settings.Default.LanguageName))
            {
                var culture = CultureResources.SupportedCultures.Contains(CultureInfo.InstalledUICulture)
                    ? CultureInfo.InstalledUICulture
                    : new CultureInfo("en-US");

                CultureInfo.DefaultThreadCurrentCulture   = culture;
                CultureInfo.DefaultThreadCurrentUICulture = culture;

                Thread.CurrentThread.CurrentCulture   = culture;
                Thread.CurrentThread.CurrentUICulture = culture;

                Cultures.Resources.Culture = culture;

                CultureResources.ChangeCulture(culture);

                Properties.Settings.Default.LanguageName = CultureResources.SupportedCultures.Find(x => Equals(x, culture)).NativeName;
            }
            else
            {
                var culture = CultureResources.SupportedCultures.Find(x => x.NativeName == Properties.Settings.Default.LanguageName);

                CultureInfo.DefaultThreadCurrentCulture   = culture;
                CultureInfo.DefaultThreadCurrentUICulture = culture;

                Thread.CurrentThread.CurrentCulture   = culture;
                Thread.CurrentThread.CurrentUICulture = culture;

                Cultures.Resources.Culture = culture;

                CultureResources.ChangeCulture(culture);
            }
        }
Exemple #4
0
 private void _fileExplorer_PropertyChanged(object sender, PropertyChangedEventArgs e)
 {
     if (e.PropertyName == nameof(FileExplorer.Lang))
     {
         CultureResources.ChangeCulture(CultureInfo.CurrentUICulture);
     }
 }
Exemple #5
0
 public void ChangeLanguage(CultureInfo cultureInfo)
 {
     CultureResources.ChangeCulture(cultureInfo);
     CultureInfo.DefaultThreadCurrentCulture   = cultureInfo;
     CultureInfo.DefaultThreadCurrentUICulture = cultureInfo;
     CurrentDate = DateTime.Today.ToString(StaticDateTimeFormat.ShortDate, Properties.Resources.Culture);
     RaisePropertyChanged(nameof(CurrentDate));
 }
        /// <summary>
        /// Action when other language was chosen
        /// </summary>
        private void LanguageChanged()
        {
            Thread.CurrentThread.CurrentCulture   = new CultureInfo(SelectedLanguage.Value.Name);
            Thread.CurrentThread.CurrentUICulture = new CultureInfo(SelectedLanguage.Value.Name);

            CultureInfo cultureInfo = new CultureInfo(SelectedLanguage.Value.Name);

            CultureResources.ChangeCulture(cultureInfo);
        }
Exemple #7
0
        public MainWindow()
        {
            CultureResources.ChangeCulture(Properties.Settings.Default.DefaultCulture);

            InitializeComponent();

            SimpleIoc.Default.Register <IDialogService>(() => this);

            _messenger = Messenger.Default;

            _messenger.Register <AsyncOperationIndicatorMessage>(this, ResponseForAsyncOperationIndicatorRequest);
        }
Exemple #8
0
        /// <summary>
        /// Handles the event of selection changed
        /// </summary>
        /// <param name="sender">Sender of the event.</param>
        /// <param name="e">Event arguments</param>
        private void cbLanguages_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            CultureInfo selected_culture = cbLanguages.SelectedItem as CultureInfo;

            //if not current language
            //could check here whether the culture we want to change to is available in order to provide feedback / action
            if (initialized && selected_culture != null && !selected_culture.Equals(L3.Cargo.Common.Resources.Culture))
            {
                Debug.WriteLine(string.Format("Change Current Culture to [{0}]", selected_culture));

                //change resources to new culture
                CultureResources.ChangeCulture(selected_culture);
            }
        }
Exemple #9
0
        protected override bool OnStartup(StartupEventArgs e)
        {
            CultureInfo currentCulture = new CultureInfo(Settings.Default.Language);

            CultureResources.ChangeCulture(currentCulture);

            Thread.CurrentThread.CurrentCulture   = currentCulture;
            Thread.CurrentThread.CurrentUICulture = currentCulture;

            App app = new App();

            app.InitializeComponent();
            app.Run();

            return(false);
        }
Exemple #10
0
        ////Code written by: Andrew Wood
        //Retrieved from: http://www.codeproject.com/Articles/22967/WPF-Runtime-Localization
        //Used under  Code Project Open License (CPOL) license.
        private void ComboBox_Languages_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            String selected_NativeName = ComboBox_Languages.SelectedItem as String;

            //if not current language
            //could check here whether the culture we want to change to is available in order to provide feedback / action
            if (Properties.Resources.Culture != null && !Properties.Resources.Culture.NativeName.Equals(selected_NativeName))
            {
                Debug.WriteLine(string.Format("Change Current Culture to [{0}]", selected_NativeName));

                //change resources to new culture
                CultureResources.ChangeCulture(selected_NativeName);

                //could apply a theme tied to this culture if desired
            }

            //Redrawing map so that context menu items change language as well
            mapSection.Update();
        }
Exemple #11
0
        private static void ComboBoxLanguage_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            Properties.Settings.Default.Save();

            if (((ComboBox)sender).SelectedItem == null)
            {
                var culture = CultureResources.SupportedCultures.Contains(CultureInfo.InstalledUICulture)
                    ? CultureInfo.InstalledUICulture
                    : new CultureInfo("en-US");

                CultureInfo.DefaultThreadCurrentCulture   = culture;
                CultureInfo.DefaultThreadCurrentUICulture = culture;

                Thread.CurrentThread.CurrentCulture   = culture;
                Thread.CurrentThread.CurrentUICulture = culture;

                Cultures.Resources.Culture = culture;

                CultureResources.ChangeCulture(culture);

                Properties.Settings.Default.LanguageName =
                    CultureResources.SupportedCultures.Find(x => Equals(x, culture)).NativeName;
            }
            else
            {
                var culture =
                    CultureResources.SupportedCultures.Find(x =>
                                                            x.NativeName == (string)((ComboBox)sender).SelectedItem);

                CultureInfo.DefaultThreadCurrentCulture   = culture;
                CultureInfo.DefaultThreadCurrentUICulture = culture;

                Thread.CurrentThread.CurrentCulture   = culture;
                Thread.CurrentThread.CurrentUICulture = culture;

                Cultures.Resources.Culture = culture;

                Process.Start(Application.ResourceAssembly.Location, "-lang");

                Application.Current.Shutdown();
            }
        }
        private void cbLanguages_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            CultureInfo selected_culture = (sender as ComboBox).SelectedItem as CultureInfo;

            //if not current language
            //could check here whether the culture we want to change to is available in order to provide feedback / action
            if (initialized && selected_culture != null && !selected_culture.Equals(L3.Cargo.Common.Dashboard.Resources.Culture))
            {
                Debug.WriteLine(string.Format("Change Current Culture to [{0}]", selected_culture));

                //save language in settings
                //Properties.Settings.Default.CultureDefault = selected_culture;
                //Properties.Settings.Default.Save();

                //change resources to new culture
                CultureResources.ChangeCulture(selected_culture);

                //could apply a theme tied to this culture if desired
            }
        }
Exemple #13
0
        private void Application_Startup(object sender, StartupEventArgs e)
        {
            CultureResources.ChangeCulture(BridgeManager.Properties.Settings.Default.ui_language);

            var container = ContainerConfig.Configure();

            var scope = container.BeginLifetimeScope();

            ConfigureNestedViewModels(scope);

            this.mainWindowViewModel = scope.Resolve <MainWindowViewModel>();

            ConfigureMainWindow();

            //----------------------------------------------------------

            Console.WriteLine("Welcome to BridgeManager v. 0.1");

            defaultTest(scope);
        }
        private void SetAndStoreAppLanguage(string cultureCode)
        {
            var ci = new CultureInfo(cultureCode);

            CultureResources.ChangeCulture(ci);
            WindowsSettings.Default.AppLanguage = cultureCode;
            WindowsSettings.Default.Save();

            foreach (var item in LanguageMenuItem.Items)
            {
                var menuItem = item as MenuItem;

                if (menuItem == null)
                {
                    continue;
                }

                var tag = menuItem.Tag.ToString();
                menuItem.IsChecked = tag == cultureCode;
            }
        }
Exemple #15
0
        private void LoadProgramState()
        {
            try
            {
                var isoStore = IsolatedStorageFile.GetUserStoreForAssembly();

                if (isoStore.FileExists(SavedStateFileName))
                {
                    XmlSerializer serializer = new XmlSerializer(typeof(ProgramState));

                    using var isoStream = new IsolatedStorageFileStream(SavedStateFileName, FileMode.Open, isoStore);
                    using var reader    = new StreamReader(isoStream);

                    var state           = (ProgramState)serializer.Deserialize(reader);
                    var savedFontFamily = new FontFamily(state.FontFamilySource);

                    // Check if the saved font exists in the collection
                    // in case the user has deleted the font that was saved
                    if (FontList.Contains(savedFontFamily))
                    {
                        SelectedFont = savedFontFamily;
                    }
                    else
                    {
                        SelectedFont = DefaultFontFamily;
                    }

                    SelectedFontWeight    = LocalizedFontWeight.FromEnglishName(state.FontWeight);
                    SelectedFontSize      = state.FontSize;
                    SelectedKanjiFontSize = state.KanjiFontSize;
                    SpacingAdjustment     = state.SpacingAdjustment;
                    GlyphHorizontalMargin = state.HorizontalMargin;

                    DropShadowSettings.BlurRadius = state.BlurRadius;
                    DropShadowSettings.Direction  = state.Direction;
                    DropShadowSettings.Depth      = state.ShadowDepth;
                    DropShadowSettings.Opacity    = state.Opacity;

                    AdvancedExpanded = state.AdvancedExpanded;
                    DisplayBoundingRectanglesChecked = state.DisplayBoundingRectangles;
                    UseDarkTheme = state.UseDarkTheme;

                    if (!string.IsNullOrEmpty(state.SelectedLanguage))
                    {
                        CultureResources.ChangeCulture(new CultureInfo(state.SelectedLanguage));
                        var lang = Languages.Find(l => l.Culture.Name == state.SelectedLanguage);
                        if (lang != null)
                        {
                            SelectedLanguage = lang;
                        }
                    }
                }
                else
                {
                    SelectedFont = DefaultFontFamily;
                }
            }
            catch (IsolatedStorageException ex)
            {
                Console.WriteLine("Loading state failed: " + ex.Message);
            }
            catch (FileNotFoundException)
            {
                // Default settings will be used
            }
        }
Exemple #16
0
        public MainWindowViewModel(Canvas fontCanvas, Canvas rectCanvas, FontFamily defaultFontFamily)
        {
            CultureResources.EnumerateAvailableCultures();
            Languages = CultureResources.AvailableCultures.Select(culture => new Language(culture)).ToList();

            var currentLanguage = Languages.Find(l => l.Culture.TwoLetterISOLanguageName == Thread.CurrentThread.CurrentUICulture.TwoLetterISOLanguageName);

            if (currentLanguage == null)
            {
                currentLanguage = Languages.Find(l => l.Culture == CultureResources.AvailableCultures[0]);
            }

            SelectedLanguage = currentLanguage;
            FontWeightList   = LocalizedFontWeights.All;

            this.ObservableForProperty(x => x.SelectedLanguage)
            .Subscribe(lang => CultureResources.ChangeCulture(lang.Value.Culture));

            FontGenerator     = new RS2014FontGenerator(fontCanvas, rectCanvas);
            FontCanvas        = fontCanvas;
            DefaultFontFamily = defaultFontFamily;

            FontList = Fonts.SystemFontFamilies.OrderBy(x => x.Source).ToList();

            LoadProgramState();

            WindowTitle = ProgramName;

            var thisAsm = Assembly.GetExecutingAssembly();

            ProgramVersion = thisAsm.GetName().Version.ToString();

            CreateReactiveCommands();

            this.WhenAnyValue(x => x.UseDarkTheme)
            .Subscribe(dt =>
            {
                string theme = dt ? "Dark" : "Light";

                ThemeManager.Current.ChangeTheme(Application.Current, theme + ".Steel");
            });

            // Generate font after a delay when font size, glyph margin or spacing is changed
            this.WhenAnyValue(
                x => x.SelectedFontSize,
                x => x.SelectedKanjiFontSize,
                x => x.GlyphHorizontalMargin,
                x => x.SpacingAdjustment)
            .Where(_ => CanGenerate)       // Don't do anything if generation is currently disabled
            .Throttle(TimeSpan.FromMilliseconds(650), RxApp.MainThreadScheduler)
            .DistinctUntilChanged()
            .Select(_ => Unit.Default)
            .InvokeCommand(GenerateFont);

            // Generate font immediately when font family or weight or "accurate inner rects" is changed
            this.WhenAnyValue(
                x => x.UseAccurateInnerRects,
                x => x.SelectedFont,
                x => x.SelectedFontWeight)
            .DistinctUntilChanged()
            .Select(_ => Unit.Default)
            .InvokeCommand(GenerateFont);
        }
Exemple #17
0
        static FileModel()
        {
            Messenger.Default.Register(Application.Current, (NotificationMessage message) =>
            {
                if (message.NotificationType == NotificationType.Add)
                {
                    string parentPath = FileSystemHelper.GetParentFolderPath(message.Path);
                    if (FileModelCache.TryGetValue(parentPath, out FileModel parentFileModel))
                    {
                        string parsingName = FileSystemHelper.GetFileParsingName(message.Path);
                        if (String.IsNullOrEmpty(parsingName))
                        {
                            return;
                        }

                        FileModel fileModel = FromPath(parsingName);
                        if (fileModel.IsDirectory)
                        {
                            parentFileModel.Folders?.Add(fileModel);
                        }
                        else
                        {
                            parentFileModel.Files?.Add(fileModel);
                        }
                    }
                }
                else if (message.NotificationType == NotificationType.Remove)
                {
                    string parentPath = FileSystemHelper.GetParentFolderPath(message.Path);
                    if (FileModelCache.TryGetValue(parentPath, out FileModel parentFileModel) && FileModelCache.ContainsKey(message.Path))
                    {
                        FileModelCache.TryRemove(message.Path, out FileModel fileModel);
                        if (fileModel.IsDirectory)
                        {
                            parentFileModel.Folders?.Remove(fileModel);
                        }
                        else
                        {
                            parentFileModel.Files?.Remove(fileModel);
                        }
                    }
                }
                else if (message.NotificationType == NotificationType.Rename)
                {
                    if (FileModelCache.ContainsKey(message.Path))
                    {
                        FileModelCache.TryRemove(message.Path, out FileModel fileModel);

                        string parsingName = FileSystemHelper.GetFileParsingName(message.NewPath);
                        if (String.IsNullOrEmpty(parsingName))
                        {
                            return;
                        }

                        FileModelCache.TryAdd(parsingName, fileModel);
                        FromPath(parsingName);

                        if (fileModel.Folders != null)
                        {
                            foreach (FileModel folder in fileModel.Folders)
                            {
                                folder.ParentName = fileModel.Name;
                                folder.Rename(message.Path, message.NewPath);
                            }
                        }

                        if (fileModel.Files != null)
                        {
                            foreach (FileModel file in fileModel.Files)
                            {
                                file.ParentName = fileModel.Name;
                                file.Rename(message.Path, message.NewPath);
                            }
                        }
                    }
                }
                else if (message.NotificationType == NotificationType.Update)
                {
                    if (FileModelCache.ContainsKey(message.Path))
                    {
                        string parsingName = FileSystemHelper.GetFileParsingName(message.Path);
                        if (String.IsNullOrEmpty(parsingName))
                        {
                            return;
                        }

                        FromPath(parsingName);
                    }
                }
            });

            Settings.Default.SettingsSaving += (s, e) =>
            {
                if (Properties.Resources.Culture.Name != Settings.Default.Language)
                {
                    CultureResources.ChangeCulture(Settings.Default.Language);

                    FileSystemHelper.Computer.Name     = Properties.Resources.Computer;
                    FileSystemHelper.Computer.FullName = Properties.Resources.Computer;

                    FileSystemHelper.QuickAccess.Name     = Properties.Resources.QuickAccess;
                    FileSystemHelper.QuickAccess.FullName = Properties.Resources.QuickAccess;
                }
            };
        }
Exemple #18
0
 public AppverseShellView()
 {
     InitializeComponent();
     CultureResources.ChangeCulture(Properties.Settings.Default.DefaultCulture);
     ShowTitleBar = true;
 }
Exemple #19
0
        public InitialSetup()
        {
            InitializeComponent();
            CultureResources.ChangeCulture(Properties.Settings.Default.DefaultCulture.NativeName);

            //Check and Attempt to recover
            Serializer serializer = Serializer.Instance;

            if (serializer.Recoverable())
            {
                if (MessageBox.Show(Properties.Resources.MessageBox_Recovery_RecoveryFound, Properties.Resources.MessageBox_Recovery_RecoveryFound_Title, MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
                {
                    MainWindow mw = new MainWindow();
                    mw.Show();
                    switch (serializer.PerformRecovery())
                    {
                    case RecoveryResults.Partial: MessageBox.Show(Properties.Resources.MessageBox_Recovery_PartialRecovery);
                        goto case RecoveryResults.Success;

                    case RecoveryResults.Success: serializer.StartBackUp();
                        this.Close();
                        break;

                    case RecoveryResults.Failure: MessageBox.Show(Properties.Resources.MessageBox_Recovery_FailedRecovery);
                        mw.ForceClose();
                        serializer.CleanUp();
                        break;
                    }
                }
                else
                {
                    serializer.CleanUp();
                }
            }

            ComboBoxItem createUserItem = new ComboBoxItem();

            createUserItem.Content    = "NEW USER";
            createUserItem.FontStyle  = FontStyles.Italic;
            createUserItem.FontWeight = FontWeights.Bold;

            ComboBoxItem createUserItemSupervisor = new ComboBoxItem();

            createUserItemSupervisor.Content    = "NEW USER";
            createUserItemSupervisor.FontStyle  = FontStyles.Italic;
            createUserItemSupervisor.FontWeight = FontWeights.Bold;

            /*ComboBoxItem createUserItemOpManager = new ComboBoxItem();
             * createUserItemOpManager.Content = "NEW USER";
             * createUserItemOpManager.FontStyle = FontStyles.Italic;
             * createUserItemOpManager.FontWeight = FontWeights.Bold;*/

            dispatcherName.Items.Add(createUserItem);
            supervisorName.Items.Add(createUserItemSupervisor);
            //opManagerName.Items.Add(createUserItemOpManager);

            ComboBoxItem supervisorItem = new ComboBoxItem();

            supervisorItem.Content = "Supervisor";

            ComboBoxItem opManagerItem = new ComboBoxItem();

            opManagerItem.Content = "Operation Manager";

            Combobox_SupervisorOperationManager.Items.Add(supervisorItem);
            Combobox_SupervisorOperationManager.Items.Add(opManagerItem);

            lastGridRow = InitialSetupGrid.RowDefinitions.Count;


            using (SQLiteDataReader reader = StaticDBConnection.QueryDatabase("SELECT Name FROM Volunteers"))
            {
                while (reader.Read())
                {
                    ComboBoxItem cbItem = new ComboBoxItem();
                    cbItem.Content = reader["Name"].ToString();
                    ComboBoxItem cbItemSupervisor = new ComboBoxItem();
                    cbItemSupervisor.Content = reader["Name"].ToString();
                    ComboBoxItem cbItemOpManager = new ComboBoxItem();
                    cbItemOpManager.Content = reader["Name"].ToString();
                    dispatcherName.Items.Add(cbItem);
                    supervisorName.Items.Add(cbItemSupervisor);
                    //opManagerName.Items.Add(cbItemOpManager);
                }
            }
            StaticDBConnection.CloseConnection();
        }
 /// <summary>
 /// Metoda odpowiadająca za zmiane języka na Angielski
 /// </summary>
 /// <param name="param">Nie uzywany</param>
 private void ukButton(object param)
 {
     Properties.Settings.Default.Language = "en-US";
     CultureResources.ChangeCulture(new System.Globalization.CultureInfo(Properties.Settings.Default.Language));
     Properties.Settings.Default.Save();
 }