コード例 #1
0
ファイル: LoadSave.cs プロジェクト: iEduard/Connecty
        /// <summary>
        /// The Actual Save Settings funktion where all the magic happens
        /// </summary>
        /// <param name="fileNameAndPath"></param>
        /// <param name="settings"></param>
        private static void save(string fileNameAndPath, ConnectySetings settings)
        {
            try
            {
                //save the car list to a file
                ObjectToSerialize objectToSerialize = new ObjectToSerialize();
                objectToSerialize.ConnectionSettings = settings.connectionSettings;

                objectToSerialize.ApplicationSettings = settings.applicationSettings;
                objectToSerialize.ViewSettings        = settings.viewSettings;

                Serializer serializer = new Serializer();
                serializer.SerializeObject(fileNameAndPath, objectToSerialize);
            }
            catch (Exception)
            {
                // Configure the message box to be displayed
                string           messageBoxText = "Die Einstellungen konnten nicht gespeichert werden. Bitte prüfen ob die notwendigen rechte für das speichern vorhanden sind.";
                string           caption        = "Datei speichern nicht erfolgreich";
                MessageBoxButton button         = MessageBoxButton.OK;
                MessageBoxImage  icon           = MessageBoxImage.Warning;

                // Display message box
                MessageBox.Show(messageBoxText, caption, button, icon);
            }
        }
コード例 #2
0
ファイル: LoadSave.cs プロジェクト: iEduard/Connecty
        /// <summary>
        /// The actual Load Settings function that does all the magic
        /// </summary>
        /// <param name="fileNameAndPath"></param>
        /// <returns></returns>
        private static ConnectySetings load(string fileNameAndPath)
        {
            ConnectySetings loadedSettings = new ConnectySetings();

            try
            {
                ObjectToSerialize objectToSerialize = new ObjectToSerialize();
                Serializer        serializer        = new Serializer();
                objectToSerialize = serializer.DeSerializeObject(fileNameAndPath);

                loadedSettings.connectionSettings  = objectToSerialize.ConnectionSettings;
                loadedSettings.applicationSettings = objectToSerialize.ApplicationSettings;
                loadedSettings.viewSettings        = objectToSerialize.ViewSettings;
            }
            catch (Exception)
            {
                // Configure the message box to be displayed
                string           messageBoxText = "Die Einstellungen konnten nicht geladen werden.";
                string           caption        = "Ungültige Settings Datei";
                MessageBoxButton button         = MessageBoxButton.OK;
                MessageBoxImage  icon           = MessageBoxImage.Warning;

                // Display message box
                MessageBox.Show(messageBoxText, caption, button, icon);
            }

            // Return the loaded Settings
            return(loadedSettings);
        }
コード例 #3
0
        /// <summary>
        /// Open Settings was triggerd
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OpenExecuted(object sender, ExecutedRoutedEventArgs e)
        {
            ConnectySetings loadedSettings = LoadSave.openSettings();

            if (loadedSettings != null)
            {
                settings = loadedSettings;
                updateMainWindowTitle();
                UpdateViewStateDependence(settings.viewSettings);

                // In case we got a different Connection Settings we will disconnect the Current Connection
                ConnectionInterface_Disconnect();
            }
        }
コード例 #4
0
ファイル: LoadSave.cs プロジェクト: iEduard/Connecty
        private static string settingsExtension   = ".cs";// Experimental


        #region Save

        /// <summary>
        /// Function where the user chooses the Name and the Path of the Settings File
        /// </summary>
        /// <param name="settings"></param>
        public static void saveSettings(ConnectySetings settings)
        {
            SaveFileDialog saveFileDialog = new SaveFileDialog();

            saveFileDialog.Title        = "Connecty Einstellungen speichern";
            saveFileDialog.DefaultExt   = settingsExtension;
            saveFileDialog.AddExtension = true;
            saveFileDialog.Filter       = "Connecty Settings (*.cs)|*.cs|Alle Dateien (*.*)|*.*";;

            if (saveFileDialog.ShowDialog() == true)
            {
                save(saveFileDialog.FileName, settings);
            }
        }
コード例 #5
0
        /// <summary>
        /// Main Window Constructor
        /// </summary>
        public MainWindow()
        {
            // Load the Default Settings
            settings = LoadSave.loadSettings(System.AppDomain.CurrentDomain.BaseDirectory);

            // Create a new Connection Interface Object
            connection = new FunctionInterface();
            connection.StatusbarUpdate += new ConnectionStateUpdateEventHandler(UpdateConnectionState_Event);
            connection.SendRecived     += new MsgSendRecivedEventHandler(MsgSendRecived_Event);


            msgLog.viewSettings = settings.viewSettings;


            // Init the UI
            InitializeComponent();

            // Add some Hot Keys and bind the Eventhandlers to the UI
            AddHotKeys();

            // Init the UI
            tbSendData.Text = "";    // Erase the Textbox Send Data
            updateMainWindowTitle(); // Update the Main Window Title


            // Try to set the Position , the Height and the Width
            this.Left   = settings.applicationSettings.position.X;
            this.Top    = settings.applicationSettings.position.Y;
            this.Width  = settings.applicationSettings.width;
            this.Height = settings.applicationSettings.height;

            // Update the UI with the Current View Settings
            UpdateViewStateDependence(msgLog.viewSettings);

            // Update the Statusbar
            update_StatusBarSendTo(connectionSelectionSendData);

            // Debug Stuff
            debugStuff();
        }
コード例 #6
0
ファイル: LoadSave.cs プロジェクト: iEduard/Connecty
 /// <summary>
 /// Save the given Data to a path withe a given Name
 /// </summary>
 /// <param name="filePath"></param>
 /// <param name="fileName"></param>
 /// <param name="settings"></param>
 private static void save(string filePath, string fileName, ConnectySetings settings)
 {
     save(filePath + fileName, settings);
 }
コード例 #7
0
ファイル: LoadSave.cs プロジェクト: iEduard/Connecty
 /// <summary>
 /// Save the Settings with the Default Name
 /// </summary>
 /// <param name="filePath"></param>
 /// <param name="settings"></param>
 public static void saveSettings(string filePath, ConnectySetings settings)
 {
     save(filePath, defaultSettingsName, settings);
 }
コード例 #8
0
ファイル: LoadSave.cs プロジェクト: iEduard/Connecty
 /// <summary>
 /// Save the Settings with a specified Name
 /// </summary>
 /// <param name="filePath"></param>
 /// <param name="fileName"></param>
 /// <param name="settings"></param>
 public static void saveSettings(string filePath, string fileName, ConnectySetings settings)
 {
     save(filePath, fileName, settings);
 }