public StartingContext(IContainer container, ProfileManager profileManager, ISplash splash)
        {
            _container      = container;
            _splash         = splash;
            _profileManager = profileManager;

            if (_profileManager.ProfileLoaded)
            {
                Pandora.Log.WriteEntry("Import startup initiated");
                LoadProfile(_profileManager.Profile.Name);
            }
            else
            {
                Pandora.Log.WriteEntry("Normal startup initiated");

                // Move on with normal startup
                Process proc = Pandora.ExistingInstance;
                if (proc != null) // Single instance check
                {
                    Pandora.Log.WriteError(null, "Double instance detected");
                    MessageBox.Show("You can't run two instances of Pandora's Box at the same time");
                    //  Issue 33:    Bring to front if already started - Tarion
                    ProcessExtension.BringToFront(proc);
                }
                else
                {
                    Pandora.Log.WriteEntry("Double instances check passed");
                    DoProfile();
                }
            }
        }
Example #2
0
        public StartingContext(IContainer container, ProfileManager profileManager, ISplash splash)
        {
            _container = container;
            _splash = splash;
            _profileManager = profileManager;
            
            if (_profileManager.ProfileLoaded)
            {
                Pandora.Log.WriteEntry("Import startup initiated");
                LoadProfile(_profileManager.Profile.Name);
            }
            else
            {
                Pandora.Log.WriteEntry("Normal startup initiated");

                // Move on with normal startup
                Process proc = Pandora.ExistingInstance;
                if (proc != null) // Single instance check
                {
                    Pandora.Log.WriteError(null, "Double instance detected");
                    MessageBox.Show("You can't run two instances of Pandora's Box at the same time");
                    //  Issue 33:  	 Bring to front if already started - Tarion
                    ProcessExtension.BringToFront(proc);
                }
                else
                {
                    Pandora.Log.WriteEntry("Double instances check passed");
                    DoProfile();
                }
            }
        }
 public SplashService(IOptions <ApplicationNameAndVersion> options, ISplash splash)
 {
     Options = options;
     Splash  = splash;
 }
Example #4
0
        static void Main(string[] args)
        {
            try
            {
                Log.WriteEntry("Starting");

                var builder = new LightCoreBuilder();
                Container = builder.BuildContainer();
                _splash   = Container.Resolve <ISplash>();

                _splash.Show();
                AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;

                // Delete any temp files created during compilation of profile IO
                var temp = Path.Combine(Folder, "temp.dll");

                if (File.Exists(temp))
                {
                    _splash.SetStatusText("Deleting temporary files");
                    File.Delete(temp);
                }

                _profileManager = Container.Resolve <ProfileManager>();
                // Issue 28:     Refactoring Pandora.cs - Tarion
                // Move any profiles resulting from previous versions
                _profileManager.MoveOldProfiles();
                //ProfileManager.Instance.MoveOldProfiles();
                // End Issue 28:

                if (args.Length == 1 && File.Exists(args[0]) && Path.GetExtension(args[0]).ToLower() == ".pbp")
                {
                    _profileManager.ImportProfile(args[0]);
                }

                var context = Container.Resolve <StartingContext>();
                Application.Run(context);

                // the following code is replaced, logic moved into StartingContext

                /*
                 * if (profileManager.ProfileLoaded)
                 * {
                 *      Pandora.Log.WriteEntry("Import startup initiated");
                 *      m_Context = new StartingContext(profileManager.Profile.Name);
                 *      Application.Run(m_Context);
                 * }
                 * else
                 * {
                 *      Pandora.Log.WriteEntry("Normal startup initiated");
                 *
                 *      // Move on with normal startup
                 *      Process proc = Pandora.ExistingInstance;
                 *      if (proc != null) // Single instance check
                 *      {
                 *              Pandora.Log.WriteError(null, "Double instance detected");
                 *              System.Windows.Forms.MessageBox.Show("You can't run two instances of Pandora's Box at the same time");
                 *              //  Issue 33:    Bring to front if already started - Tarion
                 *              ProcessExtension.BringToFront(proc);
                 *      }
                 *      else
                 *      {
                 *              Pandora.Log.WriteEntry("Double instances check passed");
                 *
                 *              m_Context = new StartingContext();
                 *              Application.Run(m_Context);
                 *      }
                 * }
                 */
            }
            catch (Exception err)
            {
                Clipboard.SetDataObject(err.ToString(), true);
                MessageBox.Show(
                    "An error occurred. The error text has been placed on your clipboard, use CTRL+V to paste it in a text file.");
                // Issue 6:      Improve error management - Tarion
                Environment.Exit(1);
                // End Issue 6:
            }
        }
Example #5
0
 public ProfileManager(ISplash splash)
 {
     _splash = splash;
 }
Example #6
0
		static void Main(string[] args)
		{
			try
			{
				Log.WriteEntry("Starting");

                LightCoreBuilder builder = new LightCoreBuilder();
                _container = builder.BuildContainer();
                _splash = _container.Resolve<ISplash>();

                _splash.Show();
				AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);

				// Delete any temp files created during compilation of profile IO
				string temp = Path.Combine(Pandora.Folder, "temp.dll");

				if (File.Exists(temp))
				{
                    _splash.SetStatusText("Deleting temporary files");
					File.Delete(temp);
				}


                _profileManager = _container.Resolve<ProfileManager>();
				// Issue 28:  	 Refactoring Pandora.cs - Tarion
				// Move any profiles resulting from previous versions
                _profileManager.MoveOldProfiles();
				//ProfileManager.Instance.MoveOldProfiles();
				// End Issue 28:

				if (args.Length == 1 && File.Exists(args[0]) && Path.GetExtension(args[0]).ToLower() == ".pbp")
				{
                    _profileManager.ImportProfile(args[0]);
				}

                StartingContext context = _container.Resolve<StartingContext>();
                Application.Run(context);

                // the following code is replaced, logic moved into StartingContext
                /*
                if (profileManager.ProfileLoaded)
				{
					Pandora.Log.WriteEntry("Import startup initiated");
                    m_Context = new StartingContext(profileManager.Profile.Name);
					Application.Run(m_Context);
				}
				else
				{
					Pandora.Log.WriteEntry("Normal startup initiated");

					// Move on with normal startup
					Process proc = Pandora.ExistingInstance;
					if (proc != null) // Single instance check
					{
						Pandora.Log.WriteError(null, "Double instance detected");
						System.Windows.Forms.MessageBox.Show("You can't run two instances of Pandora's Box at the same time");
						//  Issue 33:  	 Bring to front if already started - Tarion
						ProcessExtension.BringToFront(proc);
					}
					else
					{
						Pandora.Log.WriteEntry("Double instances check passed");

						m_Context = new StartingContext();
						Application.Run(m_Context);
					}
				}
                */
			}
			catch (Exception err)
			{
				Clipboard.SetDataObject(err.ToString(), true);
				MessageBox.Show("An error occurred. The error text has been placed on your clipboard, use CTRL+V to paste it in a text file.");
				// Issue 6:  	 Improve error management - Tarion
				Environment.Exit(1);
				// End Issue 6:
			}
		}
Example #7
0
        /// <summary>
        /// 创建当前的插件信息
        /// </summary>
        /// <param name="plugins"></param>
        private static void CreateUI(UIControlledApplication revitapp, List <IFangCommand> plugins, ISplash splash)
        {
            if (plugins.Count > 0)
            {
                //通过tab分组
                var tabs = plugins.GroupBy(x => x.TabName);

                //获取当前所有的tabs信息
                foreach (var t in tabs)
                {
                    if (t.Count() > 0)
                    {
                        //创建指定的面板
                        CreateTab(revitapp, t.Key);
                        //获取当前所有的面板组
                        var panels = t.GroupBy(x => x.PanelName);

                        //获取当前的面板的数量
                        if (panels.Count() > 0)
                        {
                            //对当前的面板进行排序
                            var orderPanels = panels.OrderBy(x => x.ElementAtOrDefault(0).PanelIndex);

                            foreach (var p in orderPanels)
                            {
                                //创建当前的面板
                                var panel = CreatePanel(revitapp, t.Key, p.Key);

                                if (panel != null)
                                {
                                    //获取当前的stack分类
                                    Dictionary <string, List <IFangCommand> > splitValues = new Dictionary <string, List <IFangCommand> >();

                                    //遍历所有的插件
                                    foreach (var b in p)
                                    {
                                        //进行分组显示
                                        if (!string.IsNullOrEmpty(b.SplitName))
                                        {
                                            if (splitValues.Keys.Contains(b.SplitName))
                                            {
                                                splitValues[b.SplitName].Add(b);
                                            }
                                            else
                                            {
                                                splitValues[b.SplitName] = new List <IFangCommand>();
                                                splitValues[b.SplitName].Add(b);
                                            }
                                        }
                                        else
                                        {
                                            if (splitValues.Keys.Contains(b.ModelName))
                                            {
                                                splitValues[b.ModelName].Add(b);
                                            }
                                            else
                                            {
                                                splitValues[b.ModelName] = new List <IFangCommand>();
                                                splitValues[b.ModelName].Add(b);
                                            }
                                        }
                                    }
                                    CreateStack(panel, splitValues);
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                splash.ProcessData = "当前无任何插件可以加载";
            }
        }
Example #8
0
        /// <summary>
        /// 加载所有的插件信息
        /// </summary>
        /// <param name="revitapp"></param>
        /// <param name="splash"></param>
        public static void LoadAllPlugins(UIControlledApplication revitapp, ISplash splash)
        {
            /// <summary>
            /// 所有的插件列表
            /// </summary>
            List <IFangCommand> plugins = new List <IFangCommand>();
            //获取当前的应用程序路径
            string appPath = Unity.GetAssemblyPath();

            if (appPath != null)
            {
                //获取当前所有的文件信息
                string[] files = Directory.GetFiles(appPath);
                //获取下面所有的dll
                foreach (string file in files)
                {
                    if (file.Contains("Fang.LGK.Plugin.") == false)
                    {
                        continue;
                    }
                    //获取扩展名
                    string ext = Path.GetExtension(file);
                    //判断是否是扩展名
                    if (ext.ToLower() != ".dll")
                    {
                        continue;
                    }

                    try
                    {
                        //加载当前的程序集
                        Assembly tmp = Assembly.LoadFrom(file);
                        //获取当前所有类型信息
                        Type[] types = tmp.GetTypes();
                        //显示加载进度
                        splash.ProcessData = Path.GetFileName(file);
                        //获取当前的成员类型信息
                        foreach (Type t in types)
                        {
                            if (IsValidPlugin(t))
                            {
                                try
                                {
                                    //创建当前的插件信息
                                    IFangCommand plugin = (IFangCommand)tmp.CreateInstance(t.FullName);
                                    plugins.Add(plugin);
                                }
                                catch (Exception ex) {
                                    splash.ProcessData = "当前应用程序加载失败" + ex.Message;
                                    continue;
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        splash.ProcessData = "当前应用程序加载失败" + ex.Message;
                    }
                    //创建当前界面
                }

                CreateUI(revitapp, plugins, splash);
            }
            else
            {
            }
        }
Example #9
0
 public ProfileManager(ISplash splash)
 {
     _splash = splash;
 }
Example #10
0
		public Box(ProfileManager profileManager, ISplash splash)
		{
            _profileManager = profileManager;
            _splash = splash;

            _splash.SetStatusText("Loading appearance");
			InitializeComponent();

            _splash.SetStatusText("Initializing maps and artwork");
			Map.MulManager = _profileManager.Profile.MulManager;
			Art.MulFileManager = _profileManager.Profile.MulManager;
			
			Pandora.Map = Map;
			Pandora.Art = Art;
			Pandora.Prop = ucPropManager;

			if ( Pandora.Hues != null )
			{
                _splash.SetStatusText("Reading hues");
				m_HuePicker = new HuePicker();
			}

            _splash.SetStatusText("Restoring options");
			ApplyOptions();

            _splash.SetStatusText("Building travel destinations");
			InitPages();

            // Update Title when online change!
            Pandora.BoxConnection.OnlineChanged += new EventHandler(delegate(Object sender, EventArgs e)
                {
                    this.Text = string.Format(Pandora.Localization.TextProvider["Misc.BoxTitle"], _profileManager.Profile.Name, Pandora.BoxConnection.Connected ? Pandora.Localization.TextProvider["Misc.Online"] : Pandora.Localization.TextProvider["Misc.Offline"]);
                });
		}