Esempio n. 1
0
 private void OnMSG_CareOneConfig_SAVEDATA(NotificationMessageAction <DataOneRegistationInfo> action)
 {
     _dataInfo.Led_name  = Led_name;
     _dataInfo.Latitude  = Latitude;
     _dataInfo.Longitude = Longitude;
     action.Execute(_dataInfo);
 }
Esempio n. 2
0
 private void finishGame(NotificationMessageAction notificationMessageAction)
 {
     if (notificationMessageAction.Notification.Equals("win"))
     {
         dispatcherTime.Stop();
         if (Time < _bestTime || _bestTime == 0)
         {
             _bestTime = Time;
             ApplicationData.Current.LocalSettings.Values[Name] = Time;
         }
         _dialogService.ShowMessage(
             "Best time " + HelpConvert.intToStringTime(_bestTime) + "\nCurrent time " + HelpConvert.intToStringTime(Time),
             "Puzzle Completed",
             "Menu",
             "Retry",
             (menu) =>
         {
             if (menu)
             {
                 _navigationService.GoBack();
             }
             else
             {
                 initGame();
                 notificationMessageAction.Execute();     // execute the callback = restart
             }
         });
     }
 }
 private void ProcessCloudFoundryProviderMessage(NotificationMessageAction <ICloudFoundryProvider> message)
 {
     if (message.Notification.Equals(Messages.GetCloudFoundryProvider))
     {
         message.Execute(this);
     }
 }
 private void NotificationMessageBoxResultRecieved(NotificationMessageAction <MessageBoxResult> msg)
 {
     if (msg.Notification == "Reset Settings")
     {
         var result = ModernDialog.ShowMessage("Are you sure you want to reset your settings to default?", "Reset settings to default", MessageBoxButton.YesNo);
         msg.Execute(result);
     }
 }
 private void NotificationMessageBoxResultRecieved(NotificationMessageAction <MessageBoxResult> msg)
 {
     if (msg.Notification == "Delete Vn Confirm")
     {
         var result = ModernDialog.ShowMessage("Are you SURE you want to delete this visual novel and all associated data?", "Delete Visual Novel?", MessageBoxButton.YesNo);
         msg.Execute(result);
     }
 }
Esempio n. 6
0
 private void ExecuteSaveCommand()
 {
     if (string.IsNullOrWhiteSpace(Name) || string.IsNullOrWhiteSpace(Url))
     {
         return;
     }
     _addItem.Execute(new WebsiteItem(Name, UrlHelper.GetWeb(Url)));
     Name = Url = string.Empty;
 }
Esempio n. 7
0
        private void GetDirectory(NotificationMessageAction <DirectoryInfo> msg)
        {
            System.Windows.Forms.FolderBrowserDialog folderBrowser = new System.Windows.Forms.FolderBrowserDialog();
            if (folderBrowser.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                var result = new System.IO.DirectoryInfo(folderBrowser.SelectedPath);

                msg.Execute(result);
            }
        }
Esempio n. 8
0
 private void ExecuteSaveCommand()
 {
     if (string.IsNullOrWhiteSpace(Email))
     {
         return;
     }
     _callBack.Execute(new EmailItem(Email, Params));
     Email  = string.Empty;
     Params = string.Empty;
     _close.Execute();
 }
Esempio n. 9
0
 private void OnNotificationMessageActionReceived(NotificationMessageAction <MessageBoxResult> obj)
 {
     if (obj.Sender is ViewMassMove)
     {
         switch (obj.Notification.ToString())
         {
         case "AskForOverwrite":
             obj.Execute(MessageBox.Show("The preset position has been existed, overwrite ?", "Warning", MessageBoxButton.YesNo, MessageBoxImage.Question));
             break;
         }
     }
 }
Esempio n. 10
0
 private void ExecuteSaveCommand()
 {
     DatabaseHelper.Open();
     SystemHelper.Set("Background", Background);
     SystemHelper.Set("FontFamily", FontFamily.Name);
     SystemHelper.Set("FontSize", FontSize);
     SystemHelper.Set("FontWeight", FontWeight);
     SystemHelper.Set("Foreground", Foreground);
     SystemHelper.Save();
     DatabaseHelper.Close();
     _system.Execute();
 }
        private async void RenderImage(NotificationMessageAction <SoftwareBitmap> notificationMessageAction)
        {
            if (BaumCollection != null && BaumCollection.Count > 0)
            {
                if (BaumCollection.Where(x => x.IsMarked == true).Count() > 0)
                {
                    SelectTree(BaumCollection.Where(x => x.IsMarked == true).First());
                }

                //_selectedBaum = _BaumCollection.Where(x => x.IsMarked = true).First();
                //RaisePropertyChanged(() => SelectedBaum);
            }

            RenderTargetBitmap renderTargetBitmap = new RenderTargetBitmap();

            await renderTargetBitmap.RenderAsync(mapGrid);

            if (renderTargetBitmap.PixelHeight != 0 && renderTargetBitmap.PixelWidth != 0)
            {
                SoftwareBitmap softwareBitmap = new SoftwareBitmap(BitmapPixelFormat.Bgra8, renderTargetBitmap.PixelWidth, renderTargetBitmap.PixelHeight);
                softwareBitmap.DpiX = 600;
                softwareBitmap.DpiY = 600;
                softwareBitmap.CopyFromBuffer(await renderTargetBitmap.GetPixelsAsync());

                notificationMessageAction.Execute(softwareBitmap);
            }



            //BitmapDecoder imagedecoder;
            //using (var imagestream = await Map.OpenAsync(FileAccessMode.Read))
            //{
            //    imagedecoder = await BitmapDecoder.CreateAsync(imagestream);

            //    CanvasDevice device = CanvasDevice.GetSharedDevice();
            //    CanvasRenderTarget renderTarget = new CanvasRenderTarget(device, imagedecoder.PixelWidth, imagedecoder.PixelHeight, 96);
            //    using (var ds = renderTarget.CreateDrawingSession())
            //    {
            //        ds.Clear(Colors.White);
            //        CanvasBitmap image = await CanvasBitmap.LoadAsync(device, imagestream);
            //        ds.DrawImage(image);
            //        //ds.DrawText(lblName.Text, new System.Numerics.Vector2(150, 150), Colors.Black);
            //    }

            //    await renderTarget.SaveAsync(imagestream, CanvasBitmapFileFormat.Jpeg);

            //    BitmapImage bitmap = new BitmapImage();
            //    bitmap.SetSource(imagestream);

            //    MapR = bitmap;
            //}
        }
        private void HandleNotificationMessage(NotificationMessageAction <CollectionLibrary> message)
        {
            //check if it has a same id from sender
            var x = (ItemModel)message.Sender;
            CollectionLibrary checkitem;

            try {
                checkitem = ItemItemSource.Where(i => i.Itemproperty.Item_Id == x.Item_Id).First();
                message.Execute(checkitem);
            }
            catch (Exception) {
                checkitem = null;
            }
        }
Esempio n. 13
0
        private void GetInputDate(NotificationMessageAction <DateTime> msg)
        {
            object[] vals = new object[] { msg.Notification, null };
            var      win  = new InputDateWindow(vals);

            win.Owner = this;
            win.WindowStartupLocation = WindowStartupLocation.CenterOwner;
            win.ShowDialog();

            if (vals[1] != null)
            {
                msg.Execute(vals[1]);
            }
        }
Esempio n. 14
0
        private void GetInput(NotificationMessageAction <string> msg)
        {
            string[] vals = new string[] { msg.Notification, null };
            var      win  = new InputWindow(vals);

            win.Owner = this;
            win.WindowStartupLocation = WindowStartupLocation.CenterOwner;
            win.ShowDialog();

            if (vals[1] != null)
            {
                msg.Execute(vals[1]);
            }

            //   msg.Execute(MessageBox.Show("选择", "问题", MessageBoxButton.YesNo, MessageBoxImage.Question).ToString());
        }
Esempio n. 15
0
 private void ExecuteConnectCommand()
 {
     try
     {
         var connectionString =
             $"Database = '{Database}'; Data Source = '{Host}'; Port = {Port}; User Id = '{UserName}'; Password = '******'; charset = '{CharSet}'; pooling = true; Allow Zero Datetime = True";
         MySqlConnection conn = new MySqlConnection(connectionString);
         conn.Open();
         _showMessage("连接成功!");
         conn.Close();
         DatabaseHelper.ConnectionString = connectionString;
         _closeView.Execute();
         //Task.Factory.StartNew(() =>
         //{
         //    Thread.Sleep(1000);
         //    _closeView.Execute();
         //});
     }
     catch (Exception e)
     {
         _showMessage("连接失败!" + e.Message);
     }
 }
Esempio n. 16
0
        private void ExecuteSaveCommand()
        {
            if (string.IsNullOrWhiteSpace(Url))
            {
                return;
            }
            var item = new WebRuleItem();

            item.Name             = Name;
            item.Url              = UrlHelper.GetWeb(Url);
            item.CatalogBegin     = CatalogBegin;
            item.CatalogEnd       = CatalogEnd;
            item.ChapterBegin     = ChapterBegin;
            item.ChapterEnd       = ChapterEnd;
            item.Replace          = Replace;
            item.AuthorBegin      = AuthorBegin;
            item.AuthorEnd        = AuthorEnd;
            item.DescriptionBegin = DescriptionBegin;
            item.DescriptionEnd   = DescriptionEnd;
            item.CoverBegin       = CoverBegin;
            item.CoverEnd         = CoverEnd;
            _addItem.Execute(item);
        }
Esempio n. 17
0
        private void ShowAutoGenerateWindow(NotificationMessageAction <ClassBreakViewModel> message)
        {
            ClassBreakStyleAutoGenerateWindow window = new ClassBreakStyleAutoGenerateWindow();

            window.Title = message.Notification;
            double maxValue = double.MinValue;
            double minValue = double.MaxValue;

            if (requiredValues.FeatureLayer != null)
            {
                ShapeFileFeatureLayer shapeFileFeatureLayer = requiredValues.FeatureLayer as ShapeFileFeatureLayer;
                //if (shapeFileFeatureLayer != null)
                //{
                //    double tmpMinValue = double.MaxValue;
                //    double tmpMaxValue = double.MinValue;
                //    shapeFileFeatureLayer.SafeProcess(() =>
                //    {
                //        string dbfFileName = Path.ChangeExtension(shapeFileFeatureLayer.ShapePathFileName, ".dbf");

                //        if (File.Exists(dbfFileName))
                //        {
                //            using (GeoDbf geoDbf = new GeoDbf(dbfFileName, DbfReadWriteMode.ReadOnly))
                //            {
                //                geoDbf.Open();
                //                for (int i = 1; i <= geoDbf.RecordCount; i++)
                //                {
                //                    string fieldValue = geoDbf.ReadFieldAsString(i, ColumnName);
                //                    double number = double.NaN;
                //                    Double.TryParse(fieldValue, out number);
                //                    if (!Double.IsNaN(number))
                //                    {
                //                        tmpMinValue = number < tmpMinValue ? number : tmpMinValue;
                //                        tmpMaxValue = number > tmpMaxValue ? number : tmpMaxValue;
                //                    }
                //                }
                //            }
                //        }
                //    });

                //    maxValue = tmpMaxValue;
                //    minValue = tmpMinValue;
                //}
                //else
                {
                    Collection <Feature> features = new Collection <Feature>();
                    bool needReturn = false;
                    requiredValues.FeatureLayer.SafeProcess(() =>
                    {
                        if (requiredValues.FeatureLayer.FeatureSource.CanGetCountQuickly())
                        {
                            int count = requiredValues.FeatureLayer.FeatureSource.GetCount();
                            if (count > 50000)
                            {
                                //MessageBoxResult result = MessageBox.Show(string.Format("{0} contains a large amount of records, it might spend too much time to process. Do you want to continue?", requiredValues.FeatureLayer.Name), "Info", MessageBoxButton.YesNo, MessageBoxImage.Information);
                                //if (result == MessageBoxResult.No)
                                //{
                                //    needReturn = true;
                                //}
                            }
                        }

                        if (!needReturn)
                        {
                            features = requiredValues.FeatureLayer.QueryTools.GetAllFeatures(requiredValues.FeatureLayer.GetDistinctColumnNames());
                        }
                    });

                    if (needReturn)
                    {
                        return;
                    }

                    foreach (Feature feature in features)
                    {
                        double columnValue = 0;
                        try
                        {
                            if (feature.ColumnValues.ContainsKey(ColumnName))
                            {
                                columnValue = Convert.ToDouble(feature.ColumnValues[ColumnName]);
                            }
                            //else if (feature.LinkColumnValues.ContainsKey(ColumnName))
                            //{
                            //    //TODO: we need to figure out how to choose the columnValue when there are multiple link column values.
                            //    Collection<LinkColumnValue> values = feature.LinkColumnValues[ColumnName];
                            //    LinkColumnValue firstValue = values.FirstOrDefault();
                            //    if (firstValue != null)
                            //    {
                            //        columnValue = Convert.ToDouble(firstValue.Value);
                            //    }
                            //}
                        }
                        catch
                        { }

                        minValue = columnValue < minValue ? columnValue : minValue;
                        maxValue = columnValue > maxValue ? columnValue : maxValue;
                    }
                }

                window.LowValue  = minValue;
                window.HighValue = maxValue;
            }

            if (minValue == maxValue)
            {
                System.Windows.Forms.MessageBox.Show(GisEditor.LanguageManager.GetStringResource("ClassBreakStyleViewModelCanntbrokeMessage"), "Alert", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information);
            }
            else if (window.ShowDialog().GetValueOrDefault())
            {
                message.Execute(window.ViewModel);
                RaisePropertyChanged("ClassBreakItems");
            }
        }
Esempio n. 18
0
 private void HandleNotificationMessage(NotificationMessageAction <string> message)
 {
     message.Execute("Success (from ActivationService)!");
 }
Esempio n. 19
0
 /// <summary>
 /// Callback message from VM_Tiles to get the preselected project name.
 /// </summary>
 /// <param name="msg">The callback message.</param>
 private void GetPreselectedProject(NotificationMessageAction <string> msg)
 {
     msg.Execute(PreselectedProject);
 }
Esempio n. 20
0
 private void HandleNotificationMessage(NotificationMessageAction <string> message)
 {
     message.Execute("Success (from App.xaml.cs)!");
 }
Esempio n. 21
0
 private void HandleNotificationMessage(NotificationMessageAction <string> message)
 {
     // Execute a callback to send a reply to the sender.
     message.Execute("Success! (from MainActivity.cs)");
 }
        private void ExecuteDropCommand(DragEventArgs parameter)
        {
            var item = (CodeItem)parameter.Data.GetData(typeof(CodeItem));

            _addText.Execute(item.Content);
        }
Esempio n. 23
0
        private void _begin()
        {
            var item  = new BookItem(Name, Source, Kind, Url);
            var conn  = DatabaseHelper.Open();
            var count = DatabaseHelper.Find <BookItem>("count(Name)", "Name = @name", new SQLiteParameter("@name", item.Name));

            if (Convert.ToInt32(count) > 0)
            {
                DatabaseHelper.Close();
                _showMessage("书名存在,请更改!");
                RingVisibility = Visibility.Collapsed;
                return;
            }
            var chapters = new List <ChapterItem>();

            var watch = new Stopwatch();

            watch.Start();
            LocalHelper.CreateTempDir();
            var rule = new WebRuleItem();

            if (item.Source == BookSources.网络)
            {
                rule = DatabaseHelper.GetRule(item.Url);
                if (rule == null)
                {
                    DatabaseHelper.Close();
                    _showMessage("网站规则不存在,请添加!");
                    RingVisibility = Visibility.Collapsed;
                    watch.Stop();
                    return;
                }
                chapters.AddRange(Helper.HttpHelper.GetBook(ref item, rule));
            }
            else
            {
                chapters.AddRange(LocalHelper.GetChapters(item.Url));
            }
            var id = DatabaseHelper.InsertId <BookItem>(
                "Name, Image, Description, Author, Source, Kind, Url, `Index`, Count, Time",
                "@name,@image,@description,@author,@source,@kind, @url, @index, @count, @time",
                new SQLiteParameter("@name", item.Name),
                new SQLiteParameter("@image", item.Image),
                new SQLiteParameter("@description", item.Description),
                new SQLiteParameter("@author", item.Author),
                new SQLiteParameter("@source", item.Source),
                new SQLiteParameter("@kind", item.Kind),
                new SQLiteParameter("@url", item.Url),
                new SQLiteParameter("@index", item.Index),
                new SQLiteParameter("@count", item.Count),
                new SQLiteParameter("@time", item.Time));

            if (item.Source == BookSources.网络)
            {
                _showMessage("章节下载中", 0);
                var chapterLength = chapters.Count;
                var result        = Parallel.ForEach <ChapterItem>(chapters, chapter =>
                {
                    var i = 0;
                    if (File.Exists(LocalHelper.TempDir + chapter.Content))
                    {
                        return;
                    }
                    OneBegin:
                    var html = new HtmlExpand();
                    try
                    {
                        html.SetUrl(chapter.Url);  // 超时
                        html.Narrow(rule.ChapterBegin, rule.ChapterEnd);
                        LocalHelper.WriteTemp(
                            html.GetText(rule.Replace), chapter.Content);
                    }
                    catch (Exception ex)
                    {
                        if (i < 5)
                        {
                            Thread.Sleep(20000);
                            goto OneBegin;
                        }
                        LocalHelper.WriteLog(
                            $"{ex.Message} 网址 {chapter.Url}");
                    }
                });
                while (!result.IsCompleted)
                {
                    Thread.Sleep(1000);
                }
                _showMessage("章节下载成功,导入中");
            }

            var writer = new StreamWriter($"{LocalHelper.TempDir}{Name}.txt", false, Encoding.UTF8);

            foreach (var chapter in chapters)
            {
                writer.WriteLine(chapter.Name);
                writer.WriteLine();
                writer.WriteLine(LocalHelper.ReadTemp(chapter.Content));
                writer.WriteLine();
                writer.WriteLine();
            }
            writer.Close();


            try
            {
                DbTransaction trans = conn.BeginTransaction();
                try
                {
                    foreach (var chapter in chapters)
                    {
                        DatabaseHelper.Insert <ChapterItem>(
                            "Name, Content, BookId, Url",
                            "@Name, @Content, @BookId, @Url",
                            new SQLiteParameter("@Name", chapter.Name),
                            new SQLiteParameter("@Content", LocalHelper.ReadTemp(chapter.Content)),
                            new SQLiteParameter("@BookId", id),
                            new SQLiteParameter("@Url", chapter.Url));
                    }
                    trans.Commit();
                }
                catch (Exception ex)
                {
                    trans.Rollback();
                    LocalHelper.WriteLog(ex.Message);
                    _showMessage("章节插入失败,已进行回滚!");
                }
            }
            catch (Exception ex)
            {
                LocalHelper.WriteLog(ex.Message);
            }


            DatabaseHelper.Close();
            _addItem.Execute(item);
            RingVisibility = Visibility.Collapsed;
            Name           = Url = string.Empty;
            watch.Stop();
            _showMessage("执行完成!耗时:" + watch.Elapsed);
        }
Esempio n. 24
0
 private void ExecuteCloseCommand()
 {
     _readItem.Execute(_book);
 }
Esempio n. 25
0
 private static void HandleNotificationMessage(NotificationMessageAction <string> message)
 {
     message.Execute("Reçu et Traité par App.xaml.cs!");
 }