Esempio n. 1
0
        private void CheckForUpdate()
        {
            if (_updateCount % 5 == 0)
            {
                System.Threading.ThreadPool.QueueUserWorkItem(delegate(object state)
                {
                    try
                    {
                        Obany.Communications.CommunicationsResult res = Obany.Communications.CommunicationsManager.Get(new Uri("http://support.shumbi.com/version/?product=" + _aboutData.ProductName + "&version=" + _aboutData.VersionStringFixed + "&updatecount=" + _updateCount), null);

                        if (res.Status == Obany.Core.OperationStatus.Success)
                        {
                            if (res.BinaryResponse != null)
                            {
                                _update = Obany.Language.Xml.XmlHelper.BinaryDeserialize <Update>(res.BinaryResponse);

                                if (_update != null)
                                {
                                    DateTime currentBuildDate;
                                    DateTime newBuildDate;

                                    if (CalculateBuildDate(_aboutData.VersionStringFixed, out currentBuildDate))
                                    {
                                        if (CalculateBuildDate(_update.Version, out newBuildDate))
                                        {
                                            if (newBuildDate > currentBuildDate)
                                            {
                                                Action a = delegate()
                                                {
                                                    textUpdateAvailable.Text            = CultureHelper.GetString(Properties.Resources.ResourceManager, "UPDATEAVAILABLE");
                                                    rowDefinitionUpdateAvailable.Height = new GridLength(40);
                                                    borderUpdateAvailable.Visibility    = Visibility.Visible;
                                                };

                                                Dispatcher.Invoke(a);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                    catch
                    {
                    }
                });
            }
        }
Esempio n. 2
0
        public override void AnnotationRenderWebPage(Guid renderTaskId, string renderUrl, AnnotationRenderWebPageComplete annotationRenderWebPageComplete)
        {
            ThreadPool.QueueUserWorkItem(delegate(object s)
            {
                string imageMimeType = "";
                int imageWidth       = 0;
                int imageHeight      = 0;
                _renderWebPage       = null;

                try
                {
                    if (renderUrl.ToLower().EndsWith(".jpg") || renderUrl.ToLower().EndsWith(".jpeg"))
                    {
                        Obany.Communications.CommunicationsResult communicationResult = Obany.Communications.CommunicationsManager.Get(new Uri(renderUrl), null);

                        if (communicationResult.Status == OperationStatus.Success)
                        {
                            using (System.IO.MemoryStream ms = new System.IO.MemoryStream(communicationResult.BinaryResponse))
                            {
                                using (System.Drawing.Image image = System.Drawing.Bitmap.FromStream(ms))
                                {
                                    imageMimeType  = "image/jpeg";
                                    imageWidth     = image.Width;
                                    imageHeight    = image.Height;
                                    _renderWebPage = communicationResult.BinaryResponse;
                                }
                            }
                        }
                    }
                }
                catch
                {
                }

                if (_renderWebPage == null)
                {
                    Obany.Render.Web.HtmlToImage h2i = new Obany.Render.Web.HtmlToImage();
                    _renderWebPage = h2i.RenderToBitmap(renderUrl, out imageWidth, out imageHeight, out imageMimeType);
                }

                if (annotationRenderWebPageComplete != null)
                {
                    annotationRenderWebPageComplete(_renderWebPage != null, renderTaskId, _renderWebPage, imageWidth, imageHeight, imageMimeType, null);
                }
            });
        }
Esempio n. 3
0
        private void LoadSettings()
        {
            Obany.Preferences.Registry.PreferencesProviderConfiguration preferencesConfiguration = new Obany.Preferences.Registry.PreferencesProviderConfiguration();
            preferencesConfiguration.RegistryKey = Microsoft.Win32.Registry.CurrentUser;
            preferencesConfiguration.Root        = @"Software\" + _aboutData.CompanyNamePlain + @"\" + _aboutData.ProductName + @"\";

            Obany.Preferences.Model.IPreferencesProvider preferencesProvider = new Obany.Preferences.Registry.PreferencesProvider(preferencesConfiguration);

            double defWidth  = (System.Windows.SystemParameters.PrimaryScreenWidth - 20);
            double defHeight = (System.Windows.SystemParameters.PrimaryScreenHeight - 50);
            double defLeft   = 10;
            double defTop    = 10;

            bool maxim = preferencesProvider.GetBool("IsMaximized", false);

            this.Left   = preferencesProvider.GetDouble("WindowLeft", defLeft);
            this.Top    = preferencesProvider.GetDouble("WindowTop", defTop);
            this.Width  = preferencesProvider.GetDouble("WindowWidth", defWidth);
            this.Height = preferencesProvider.GetDouble("WindowHeight", defHeight);

            this.WindowState = maxim ? WindowState.Maximized : WindowState.Normal;
            this.ResizeMode  = maxim ? ResizeMode.NoResize : ResizeMode.CanResizeWithGrip;

            buttonMaximize.Visibility = maxim ? Visibility.Collapsed : Visibility.Visible;
            buttonRestore.Visibility  = maxim ? Visibility.Visible : Visibility.Collapsed;

            coreInterface.LoadSettings(preferencesProvider);

            if (_sendLicensing)
            {
                bool isRegistered = preferencesProvider.GetBool("IsRegistered", false);

                if (!isRegistered)
                {
                    System.Threading.ThreadPool.QueueUserWorkItem(delegate(object state)
                    {
                        License license            = new License();
                        license.ApplicationName    = _aboutData.ProductName;
                        license.ApplicationVersion = _aboutData.VersionStringFixed;
                        license.OS          = Environment.OSVersion.Platform.ToString();
                        license.OSVersion   = Environment.OSVersion.Version.ToString();
                        license.ServicePack = Environment.OSVersion.ServicePack;
                        license.DateTimeUtc = DateTime.Now.ToUniversalTime();
                        license.ProcessorId = Obany.Core.Logging.GetManagementInfo("Win32_Processor", "ProcessorId");
                        license.BiosSerial  = Obany.Core.Logging.GetManagementInfo("Win32_BIOS", "SerialNumber");
                        if (!string.IsNullOrEmpty(_vendorId))
                        {
                            license.OemHardwareId = string.Join(",", MainWindow.GetVendorProductIds(_vendorId).ToArray());
                        }

                        Obany.Communications.CommunicationsResult res = Obany.Communications.CommunicationsManager.Put(new Uri("http://support.shumbi.com/license/?product=" + _aboutData.ProductName + "&version=" + _aboutData.VersionStringFixed), null, "text/xml", Obany.Language.Xml.XmlHelper.BinarySerialize(license));

                        if (res.Status == Obany.Core.OperationStatus.Success)
                        {
                            if (res.BinaryResponse != null)
                            {
                                string resString = System.Text.Encoding.UTF8.GetString(res.BinaryResponse);

                                if (!string.IsNullOrEmpty(resString))
                                {
                                    if (resString.Trim() == "OK")
                                    {
                                        preferencesProvider.SetBool("IsRegistered", true);
                                    }
                                }
                            }
                        }
                    });
                }
            }

            _updateCount = preferencesProvider.GetInt32("UpdateCount", 0);
        }