Exemplo n.º 1
0
        public SMM(SMMConsole output, MapsGraphicalInterface mgi, UserFilesManager userfiles)
        {
            this.consoleHandler = output;

            this.cmdProcessor = new CmdProcessor(this, this.sqlClient);
            this.mapProcessor = new MapProcessor(this, mgi, userfiles, this.sqlClient);
            this.userFiles = userfiles;
           
            isConnectionEstablished = false;
        }
Exemplo n.º 2
0
        public MapProcessor(SMM apphandler, MapsGraphicalInterface mgi, UserFilesManager userfiles, MySQLClient sqlclient)
        {
            this.appHandler = apphandler;
            this.MGI = mgi;
            this.sqlClient = sqlclient;
            this.userFiles = userfiles;
            Maps = new ObservableCollection<MAP>();
            Maps.CollectionChanged += mgi.maps_CollectionChanged;

            // bind the map graphical interface to the map processor
            this.MGI.setMapProcessor(this);
        }
Exemplo n.º 3
0
        public MainWindow()
        {
            InitializeComponent();

            App.LanguageChanged += LanguageChanged;
            CultureInfo currLang = App.Language;
            // fill in language changing menu:
            menuLanguage.Items.Clear();
            foreach (var lang in App.Languages)
            {
                MenuItem menuLang = new MenuItem();
                menuLang.Header = lang.DisplayName;
                menuLang.Tag = lang;
                menuLang.IsChecked = lang.Equals(currLang);
                menuLang.Click += ChangeLanguageClick;
                menuLanguage.Items.Add(menuLang);
            }

            string subPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\SSMM\\"; // root folder path
            UserFiles = new UserFilesManager(subPath);

            bool IsFirstLaunch = false;
            if(!UserFiles.IsSettingsFileExist())
            {
                // first launch
                App.Language = CultureInfo.InstalledUICulture;
                UserFiles.CreateAndFillSettingsFile(App.Language.ToString(), (bool)IsConnRemember.IsChecked, Input_STREAMER_OBJECT_DD.Text, Input_STREAMER_OBJECT_SD.Text, true);
                UserFiles.ConsoleLogging = true;
                IsFirstLaunch = true;
            }
            else
            {
                // load settings from file
                string lang = App.Language.ToString();
                bool saveConn = (bool)IsConnRemember.IsChecked;
                string S_OBJECT_DD = Input_STREAMER_OBJECT_DD.Text;
                string S_OBJECT_SD = Input_STREAMER_OBJECT_SD.Text;
                bool consoleLogging = (bool)IsConsoleLogKeeping.IsChecked;
                try
                {
                    UserFiles.ReadSettingsFile(out lang, out saveConn, out S_OBJECT_DD, out S_OBJECT_SD, out consoleLogging);
                }
                catch{ }
                App.Language = new CultureInfo(lang);
                IsConnRemember.IsChecked = saveConn;
                Input_STREAMER_OBJECT_DD.Text = S_OBJECT_DD;
                Input_STREAMER_OBJECT_SD.Text = S_OBJECT_SD;
                IsConsoleLogKeeping.IsChecked = consoleLogging;
                UserFiles.ConsoleLogging = consoleLogging;

                if(saveConn)
                {
                    ConnectionHost.Text = UserFiles.DecryptHostname();
                    ConnectionDbName.Text = UserFiles.DecryptDbName();
                    ConnectionUser.Text = UserFiles.DecryptUsername();
                    ConnectionPassword.Password = UserFiles.DecryptPassword();

                    if (ConnectionHost.Text.Trim().Length < 1) ConnectionHost.Text = "";
                    if (ConnectionDbName.Text.Trim().Length < 1) ConnectionDbName.Text = "";
                    if (ConnectionHost.Text.Trim().Length < 1) ConnectionUser.Text = "";
                    if (ConnectionPassword.Password.Trim().Length < 1) ConnectionPassword.Password = "";
                }
            }

            // Init console 
            AppConsole = new SMMConsole(SMM_Console, SMM_Console_Scroller, UserFiles);
            // Init maps graphical interface
            MGI = new MapsGraphicalInterface(
                this, 
                Map_List, 
                MapInfoName, 
                MapInfoState,
                MapInfoDateAdded, 
                "MapInfoCounter_"
            );

            // Init handler
            AppHandler = new SMM(AppConsole, MGI, UserFiles); // init after connect to click

            if (IsFirstLaunch) AppHandler.ChangeLanguage(FindResource("c_lang_code").ToString());
        }