Esempio n. 1
0
        private bool OptionDifficultySettingChanged(OptionDifficultySetting value)
        {
            //save the change in the config file
            using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication())
            {
                using (IsolatedStorageFileStream isfs = new IsolatedStorageFileStream(c_configFile, FileMode.Create, isf))
                {
                    using (StreamWriter sr = new StreamWriter(isfs))
                    {
                        sr.WriteLine(value.ToString());
                    }
                }
            }

            // Show or hide UI elements appropriately
            if (m_workspace.Difficulty == OptionDifficultySetting.MaterialBalance)
            {
                Compounds_DF_TabControl.SelectedItem = DFAnalysisTab;
                CompoundTableTab.Visibility          = Visibility.Collapsed;
            }
            else
            {
                CompoundTableTab.Visibility = Visibility.Visible;
            }

            // Tell the control palette that the difficulty changed
            PrimaryPalette.RefreshPalette(value);

            return(true);
        }
Esempio n. 2
0
        public MainPage()
        {
            // Required to initialize variables
            InitializeComponent();

            // Set the workspace for the equation editor and other controls
            m_workspace.Equations.Add(new ChemProV.Logic.Equations.EquationModel());
            WorkSpace.EquationEditor.SetWorkspace(m_workspace);
            WorkSpace.CommentsPane.SetWorkspace(m_workspace);
            m_workspace.DegreesOfFreedomAnalysis.PropertyChanged +=
                new PropertyChangedEventHandler(DegreesOfFreedomAnalysis_PropertyChanged);
            m_workspace.DegreesOfFreedomAnalysis.Comments.CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(DFCommentsCollectionChanged);
            WorkSpace.SetWorkspace(m_workspace);
            CompoundTable.SetWorkspace(m_workspace);

            // Tell the palette control to update
            PrimaryPalette.RefreshPalette(m_workspace.Difficulty);

            // Monitor when the difficulty changes so we can update the config file
            m_workspace.PropertyChanged += delegate(object o, PropertyChangedEventArgs e)
            {
                if (e.PropertyName.Equals("Difficulty"))
                {
                    OptionDifficultySettingChanged(m_workspace.Difficulty);
                }
            };

            // Monitor when the comments pane visibility changes so we can update tooltips
            WorkSpace.PropertyChanged += delegate(object o, PropertyChangedEventArgs e)
            {
                if (e.PropertyName.Equals("CommentsPaneVisible"))
                {
                    ToolTipService.SetToolTip(CommentPaneButton, WorkSpace.CommentsPaneVisible ?
                                              "Hide comments pane" : "Show comments pane");
                }
            };

            if (Application.Current.IsRunningOutOfBrowser)
            {
                Install_Button.Click -= new RoutedEventHandler(InstallButton_Click);
                ButtonToolbar.Children.Remove(Install_Button);
            }

            this.Loaded += new RoutedEventHandler(LoadConfigFile);

            this.MouseLeftButtonDown  += new MouseButtonEventHandler(MainPage_MouseButton);
            this.MouseLeftButtonUp    += new MouseButtonEventHandler(MainPage_MouseButton);
            this.MouseRightButtonDown += new MouseButtonEventHandler(MainPage_MouseButton);
            this.MouseRightButtonUp   += new MouseButtonEventHandler(MainPage_MouseButton);

            if (App.Current.IsRunningOutOfBrowser)
            {
                App.Current.MainWindow.Closing += new EventHandler <ClosingEventArgs>(MainWindow_Closing);
            }

            //listen for selection changes in our children
            WorkSpace.ValidationChecked += new EventHandler(WorkSpace_ValidationChecked);

            CompoundTable.ConstantClicked += new EventHandler(CompoundTable_ConstantClicked);

            //setup timer
            saveTimer.Interval = autoSaveTimeSpan;
            saveTimer.Tick    += new EventHandler(autoSave);
            saveTimer.Start();

            //find our version number
            Assembly asm = Assembly.GetExecutingAssembly();

            if (asm.FullName != null)
            {
                AssemblyName assemblyName = new AssemblyName(asm.FullName);
                versionNumber = assemblyName.Version.ToString();
            }

            // Intialize the static App class
            Core.App.Init(this, PrimaryPalette);

            // Make sure that when the equation editor or compounds control gets focus that the
            // control palette switches back to select mode
            WorkSpace.EquationEditor.GotFocus += delegate(object sender, RoutedEventArgs e)
            {
                Core.App.ControlPalette.SwitchToSelect(false);
            };
            CompoundTable.GotFocus += delegate(object sender, RoutedEventArgs e)
            {
                Core.App.ControlPalette.SwitchToSelect(false);
            };

            // Show the debug tab if this is a debug build
#if DEBUG
            DebugTab.Visibility = System.Windows.Visibility.Visible;

            m_workspace.StreamsCollectionChanged      += new EventHandler(WorkspaceStreamsCollectionChanged);
            m_workspace.ProcessUnitsCollectionChanged += new EventHandler(WorkspaceProcessUnitsCollectionChanged);
#endif
        }