private void Options_Click(object sender, RoutedEventArgs e)
        {
            Window setup = new SetupDialog();

            setup.Owner = this;
            if (setup.ShowDialog() ?? false)
            {
                using (new WaitCursor())
                {
                    // stop modules and dispatcher timer
                    FormManager.Default.ObjectRefreshStop();
                    ModuleManager.Default.ModulesStop();

                    // save settings if dialog result was success
                    FrameworkSettingsFile.Default.CopySettingsFrom(SetupDialog.CurrentSettings);
                    FrameworkSettingsFile.Default.Save();

                    // reload modules
                    ModuleManager.Default.ModulesLoad();
                    ModuleManager.Default.ModulesInitializeAndStart();

                    // reload startup form
                    SetupFormSettings   form_settings = FrameworkSettingsFile.Default.GetSettings <SetupFormSettings>();
                    MainGeneralSettings main_settings = FrameworkSettingsFile.Default.GetSettings <MainGeneralSettings>();

                    FormManager.Default.LoadForm(form_settings.StartupForm, main_settings.ModulesPath, main_settings.FormsPath);

                    // restart modules and dispatcher timer
                    FormManager.Default.ObjectRefreshStart();
                }
            }
        }
Пример #2
0
        /// <summary>
        /// Refreshes form info collection
        /// </summary>
        public void RefreshFormInfo()
        {
            string[]            form_files;
            FormInfo            form_info;
            String              path;
            MainGeneralSettings settings = FrameworkSettingsFile.Default.GetSettings <MainGeneralSettings>();

            // init
            m_available_forms.Clear();
            path = settings.FormsPath;

            try
            {
                form_files = Directory.GetFiles(path, "*.xaml");

                for (int i = 0; i < form_files.Length; i++)
                {
                    form_info = new FormInfo();

                    form_info.FormName = Path.GetFileNameWithoutExtension(form_files[i]);
                    form_info.FormPath = form_files[i];

                    m_available_forms.Add(form_info);
                }
            }
            catch
            {
            }
        }
        public void Load()
        {
            MainGeneralSettings settings = FrameworkSettingsFile.Default.GetSettings <MainGeneralSettings>();

            FormManager.Default.AvailableFormRefresh(settings.FormsPath);
            m_available_forms = FormManager.Default.AvailableForms;

            m_settings = SetupDialog.CurrentSettings.GetSettings <SetupFormSettings>();
        }
        private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            ModuleManager.Default.ModulesStop();
            CommunicationManager.Default.Stop();
            CommunicationManager.Default.PacketLogClose();
            FormManager.Default.ObjectRefreshStop();
            FormManager.Default.CloseCurrentForm();

            MainGeneralSettings settings = FrameworkSettingsFile.Default.GetSettings <MainGeneralSettings>();

            settings.MainWindowPos.SaveWindowPositionAndSize(this);

            FrameworkSettingsFile.Default.SetSettings(settings);
            FrameworkSettingsFile.Default.Save();
        }
Пример #5
0
        /// <summary>
        /// Loads given form
        /// </summary>
        /// <param name="in_form_path">Form (XAML) file name to load</param>
        public void LoadForm(string in_form_path)
        {
            MainGeneralSettings main_settings = FrameworkSettingsFile.Default.GetSettings <MainGeneralSettings>();

            // create parser context for XAML load
            var pc = new ParserContext();

            pc.BaseUri = new Uri(main_settings.ModulesPath, UriKind.Absolute);
            string form_full_path = in_form_path;

            // try to rebuild form full path using current settings
            if (!File.Exists(form_full_path))
            {
                string form_filename = Path.GetFileName(form_full_path);

                form_full_path = Path.Combine(main_settings.FormsPath, form_filename);
            }

            // load form
            try
            {
                Stream sr = File.OpenRead(form_full_path);
                m_current_form = (FrameworkElement)XamlReader.Load(sr, pc);
            }
            catch
            {
                m_current_form = null;
            }

            // remove forms
            m_parent.Children.Clear();

            // add new form
            if (m_current_form != null)
            {
                m_parent.Children.Add(m_current_form);
            }
        }
        public MainWindow()
        {
            // load config file and get settings
            FrameworkSettingsFile.Default.Load();

            // load modules
            ModuleManager.Default.AddMainModule(new ModuleInterface());
            ModuleManager.Default.ModulesLoad();

            // init controls
            InitializeComponent();

            FormManager.Default.SetFormParent(FormContainer);

            // create communicators
            CreateUDPCommunicator();
            CreateUARTCommunicator();
            CreateUSBCommunicator();

            CommunicationManager.Default.PacketLogCreate("packet_log.txt");

            // create realtime objects
            CreateRealtimeObjects();

            // load startup form
            SetupFormSettings   form_settings = FrameworkSettingsFile.Default.GetSettings <SetupFormSettings>();
            MainGeneralSettings main_settings = FrameworkSettingsFile.Default.GetSettings <MainGeneralSettings>();

            FormManager.Default.LoadForm(form_settings.StartupForm, main_settings.ModulesPath, main_settings.FormsPath);

            // start modules
            ModuleManager.Default.ModulesInitializeAndStart();

            // start communication manager
            CommunicationManager.Default.Start();
        }
        private void Window_Initialized(object sender, EventArgs e)
        {
            MainGeneralSettings settings = FrameworkSettingsFile.Default.GetSettings <MainGeneralSettings>();

            settings.MainWindowPos.LoadWindowPositionAndSize(this);
        }