Example #1
0
        static void Main(String[] args)
        {
            TestResources();
            ResourceManager.Instance.CallingAssembly = Assembly.GetExecutingAssembly();
            string appDir  = Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase);
            string confDir = appDir + @"\Configuration";
            string dataDir = appDir + @"\" + Mobile.Properties.Resources.FormDataSetFolder;

            DirectoryInfo confInfo = new DirectoryInfo(confDir);

            if (!confInfo.Exists)
            {
                confInfo.Create();
            }

            DirectoryInfo dataInfo = new DirectoryInfo(dataDir);

            if (!dataInfo.Exists)
            {
                dataInfo.Create();
            }

            ConfigurationHelper  configuration        = new ConfigurationHelper(confDir + @"\configuration.xml");
            CommunicationManager communicationManager = new CommunicationManager(configuration.Configuration.Host, configuration.Configuration.Port);

            int    pid         = -1;
            String requestInfo = "";

            if (args.Length > 0)
            {
                requestInfo = args[0];
                pid         = (Int32)Registry.LocalMachine.OpenSubKey(@"Floading\MobileListener\ListenerPid\").GetValue("Pid");

                NotificationScreen notificationScreen = new NotificationScreen(configuration, requestInfo, pid, communicationManager);

                //Parse notification request
                String data = XmlConvert.DecodeName(requestInfo);
                using (StringReader reader = new StringReader(data))
                {
                    FormRequestInfo request = new XmlSerializer(typeof(FormRequestInfo)).Deserialize(reader) as FormRequestInfo;
                    if (communicationManager.GetFormInfo(request.CompilationRequestId) == null)
                    {
                        communicationManager.StoreFormInfo(new FormInfo()
                        {
                            RequestInfo = request, NotificationTime = request.Time, Source = request.From
                        });
                        notificationScreen.ShowNotification(request);
                        Application.Run(notificationScreen);
                    }
                    else
                    {
                        Application.Exit();
                    }
                }
            }
            else
            {
                Application.Run(new MainScreen(configuration, requestInfo, pid, communicationManager));
            }
        }
Example #2
0
        /// <summary>
        /// The Main form of the application
        /// </summary>
        /// <param name="configuration"></param>
        /// <param name="requestInfo"></param>
        /// <param name="pid"></param>
        /// <param name="communicationManager"></param>
        public MainScreen(ConfigurationHelper configuration, string requestInfo, int pid, CommunicationManager communicationManager)
        {
            InitializeComponent();
            this.communicationManager = communicationManager;

            currentFormId = -1;
            daemonPid     = pid;

            this.configuration = configuration;

            recentScreen = new RecentScreen();
            recentScreen.FormSelected  += OnRecentFormSelected;
            recentScreen.CancelFilling += OnFillingCanceled;

            notificationScreen = new NotificationScreen(null, null, -1, communicationManager);
            notificationScreen.Show();
            notificationScreen.Visible = false;
            notificationScreen.NotificationApproved += this.OnNotificationApproved;

            notificationReceiver = new NotificationReceiver();
            notificationReceiver.NotificationReceived += OnNotificationReceived;
            notificationReceiver.Start();

            Configuration conf = configuration.Configuration;

            communicationManager.FormFetched   += OnDataSetFetched;
            communicationManager.DataSubmitted += OnDataSubmitted;

            backgroundPanel.BackgroundImage          = Mobile.Properties.Resources.MainBackground;
            privateFormButton.BackgroundImage        = Mobile.Properties.Resources.PrivateFormButton;
            privateFormButton.ClickedBackgroundImage = Mobile.Properties.Resources.PrivateFormButtonPressed;
            publicFormButton.BackgroundImage         = Mobile.Properties.Resources.PublicFormButton;
            publicFormButton.ClickedBackgroundImage  = Mobile.Properties.Resources.PublicFormButtonPressed;
            resultsButton.BackgroundImage            = Mobile.Properties.Resources.ResultsButton;
            resultsButton.ClickedBackgroundImage     = Mobile.Properties.Resources.ResultsButtonPressed;
            helpButton.BackgroundImage     = Mobile.Properties.Resources.HelpButton;
            settingsButton.BackgroundImage = Mobile.Properties.Resources.SettingsButton;
            warningButton.BackgroundImage  = Mobile.Properties.Resources.RecentButton;
            checkNewButton.BackgroundImage = Mobile.Properties.Resources.SynchButton;

            settingsButton.BackColor    = helpButton.BackColor = warningButton.BackColor = Color.Transparent;
            privateFormButton.BackColor = publicFormButton.BackColor = resultsButton.BackColor = Color.Transparent;

            orientationWatcher          = new SystemState(SystemProperty.DisplayRotation);
            orientationWatcher.Changed += OnOrientationWatcherChanged;

            UpdateRecentForms();

            if (pid != -1)
            {
                daemonStartup = true;
            }

            OnConfigurationChanged(this, new ConfigurationChangedEventArgs(configuration.Configuration));
            this.AddMenusToDictionary();
            this.UpdateResources();
        }