public PartListForm(MainForm parentForm)
 {
     InitializeComponent();
     // set the size of the image (do not change)
     this.listView.SmallImageList = new ImageList();
     this.listView.SmallImageList.ImageSize = new Size(16, 16);
     // save the parent form
     mMainFormReference = parentForm;
 }
Exemple #2
0
        static void Main(string[] args)
        {
            try
            {
                // this two method must be called before the first creation of window
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);

                // create the splash screen and show it (in the main thread)
                SplashScreen splashScreen = new SplashScreen();
                splashScreen.Show();
                Application.DoEvents(); // call the DoEvent for paint event to be done

                // try to load the language saved in the setting,
                // if the setting is set to default, the window culture info is used
                // we should do that before creating the MainForm to have the menu in
                // the right language
                string language = BlueBrick.Properties.Settings.Default.Language;
                if (!language.Equals("default"))
                {
                    // create a new culture info based on the property
                    System.Globalization.CultureInfo cultureInfo = new System.Globalization.CultureInfo(language);
                    // change the culture of the resources and the UI
                    BlueBrick.Properties.Resources.Culture = cultureInfo;
                    System.Threading.Thread.CurrentThread.CurrentUICulture = cultureInfo;
                }

                // the application can be launched with one argument, which should be a name of a file
                // that we should open. If you double-click on a BlueBrick document (or choose the "open with..."
                // in the right click context menu) the Windows will launch the program and give the filename
                // (full path in parameter)
                string fileToOpen = null;
                if (args.Length > 0)
                    fileToOpen = args[0];

                // Create the mainWindow (which is the task that take time)
                MainForm mainWindow = new MainForm(fileToOpen);

                // when the mainwindow constructor is finished, we can hide the splashscreen and destroy it
                splashScreen.Hide();
                splashScreen.Dispose();

                // Finally call the main loop
                Application.Run(mainWindow);
            }
            catch (Exception e)
            {
                // final catch for exeption
                string message = Properties.Resources.ErrorMsgCrash;
                message += e.ToString();
                MessageBox.Show(null, message,
                    Properties.Resources.ErrorMsgTitleError, MessageBoxButtons.OK,
                    MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
            }
        }
 public MainForm(string fileToOpen)
 {
     InitializeComponent();
     sInstance = this;
     // create and hide the part list form
     mPartListForm = new PartListForm(this);
     // load the custom cursors and icons
     LoadEmbededCustomCursors();
     // reset the shortcut keys
     initShortcutKeyArrayFromSettings();
     // PATCH FIX BECAUSE DOT NET FRAMEWORK IS BUGGED
     PreferencesForm.sSaveDefaultKeyInSettings();
     // load the part info
     loadPartLibraryFromDisk();
     // PATCH FIX BECAUSE DOT NET FRAMEWORK IS BUGGED for mapping UI properties in settings
     // and do it after loading the library cause some UI settings concern the library
     loadUISettingFromDefaultSettings();
     // disbale all the buttons of the toolbar and menu items by default
     // the open of the file or the creation of new map will enable the correct buttons
     enableGroupingButton(false, false);
     enablePasteButton(false);
     enableToolbarButtonOnItemSelection(false);
     enableToolbarButtonOnLayerSelection(false, false, false);
     // check if we need to open a file or create a new map
     if ((fileToOpen != null) && canOpenThisFile(fileToOpen))
     {
         openMap(fileToOpen);
     }
     else
     {
         createNewMap();
         // we update the list in the else because it is already updated in the openMap()
         UpdateRecentFileMenuFromConfigFile();
     }
     // check if we need to open a budget at startup
     if (Properties.Settings.Default.BudgetFilenameToLoadAtStartup != string.Empty)
     {
         if (!openBudget(Properties.Settings.Default.BudgetFilenameToLoadAtStartup, null))
         {
             // clear the settings if the budget is not valid, to avoid throwing the error message every time
             Properties.Settings.Default.BudgetFilenameToLoadAtStartup = string.Empty;
         }
     }
     else
     {
         updateEnableStatusForBudgetMenuItem();
     }
 }