コード例 #1
0
ファイル: Class2.cs プロジェクト: mlatjac/synched
        private SynchedUser currentUser;      // User for whom we're editing and managing documents

        // Get an instance of the model. Pass it the RichTextBox's Flow Document and a synched user key
        public static SynchedModel GetInstance(FlowDocument fdDoc, String strSynchedUser)
        {
            if (ModelUniqueInstance == null)
            {
                ModelUniqueInstance = new SynchedModel(fdDoc, strSynchedUser);
            }

            return(ModelUniqueInstance);
        }
コード例 #2
0
        private void btnPrint_Click(object sender, RoutedEventArgs e)
        {
            // Need to clone document otherwise Rich Text Box text dissapears after printing
            FlowDocument fdPrintClone = SynchedModel.Clone(rtbDocumentEditor.Document);


            if (dlgPrint.ShowDialog() == true)
            {
                // We need to set a column width, otherwise printing defaults to 2 columns (half of page size)
                fdPrintClone.IsColumnWidthFlexible = false;
                fdPrintClone.PageWidth             = dlgPrint.PrintableAreaWidth;
                fdPrintClone.ColumnWidth           = dlgPrint.PrintableAreaWidth;

                IDocumentPaginatorSource idpSource = fdPrintClone;

                dlgPrint.PrintDocument(idpSource.DocumentPaginator, "SynchEdPrinting");
            }
        }
コード例 #3
0
        public MainWindow()
        {
            // Initialize GUI
            try
            {
                // Main Window Components
                InitializeComponent();
                // Font menus
                cmbFontFamily.ItemsSource = Fonts.SystemFontFamilies.OrderBy(f => f.Source);
                cmbFontSize.ItemsSource   = new List <double>()
                {
                    8, 9, 10, 11, 12, 14, 16, 18, 20, 22, 24, 26, 28, 36, 48, 72
                };


                // Dialogs
                dlgCollabs   = new CollaboratorsDialog();
                dlgSelectDoc = new SelectDocumentDialog();
                dlgSaveAs    = new SaveAsDialog();
                dlgPrint     = new PrintDialog();

                // Language Selector
                SetupSpellCheckLanguageSelector();
            }
            catch (Exception exEx)
            {
                MessageBox.Show("There was a problem intializing the user interface " + exEx.Message);
                AbortStartupAndExit();
            }

            try
            {
                // Initialize Model
                // Fetch information from installation
                SetupUserKeyFromInstallURL();

                // Fetch user information
                String strSynchedUser = Properties.Settings.Default.SynchedUserKey; // Get User key from application settings

                if (String.IsNullOrEmpty(strSynchedUser) == true)
                {
                    // Use message below in production
                    //MessageBox.Show("This application requires a user account on the SynchEd website. Create an account and install the application directly from your profile page.");
                    //AbortStartupAndExit();

                    // For demo purposes, allow a default user
                    MessageBox.Show("This demo is best when using a configured installation of SynchEd. You may be seing this message because you installed from Chrome. Try installing from Windows Explorer instead.");
                    strSynchedUser = "******";
                }
                // Complete model initialization
                Model = SynchedModel.GetInstance(rtbDocumentEditor.Document, strSynchedUser);

                // Set some info in status bar
                lblUser.Text = "Connected as: " + Model.UserName;
            }
            catch (Exception exEx)
            {
                MessageBox.Show("There was a problem connecting to database " + exEx.Message);
                AbortStartupAndExit();
            }

            // FIXME Remove test data and dialog loop
            SetupTestData();
            //LoopThroughDialogs();
        }