Пример #1
0
        private void ListViewFood_MouseUp(object sender, MouseButtonEventArgs e)
        {
            if (((ListView)sender).SelectedIndex == -1)
            {
                return;
            }

            if (((ListView)sender).ItemContainerGenerator.ContainerFromIndex(((ListView)sender).SelectedIndex) is ListViewItem lvi)
            {
                ListView ListViewSelected = (ListView)sender;
                var      bc = new BrushConverter();

                for (int j = 0; j < Food1.Count; j++)
                {
                    ListViewItem lvi1 = ListViewFood1.ItemContainerGenerator.ContainerFromIndex(j) as ListViewItem;
                    var          cp1  = VisualTreeHelperExtensions.FindVisualChild <ContentPresenter>(lvi1);

                    var dt1 = cp1.ContentTemplate as DataTemplate;
                    var rt1 = (Rectangle)dt1.FindName("BackGround", cp1);
                    var tb1 = (TextBlock)dt1.FindName("NameFood", cp1);
                    rt1.Fill = Brushes.White;
                }

                for (int j = 0; j < Food2.Count; j++)
                {
                    ListViewItem lvi2 = ListViewFood2.ItemContainerGenerator.ContainerFromIndex(j) as ListViewItem;
                    var          cp2  = VisualTreeHelperExtensions.FindVisualChild <ContentPresenter>(lvi2);

                    var dt2 = cp2.ContentTemplate as DataTemplate;
                    var rt2 = (Rectangle)dt2.FindName("BackGround", cp2);
                    var tb2 = (TextBlock)dt2.FindName("NameFood", cp2);
                    rt2.Fill = Brushes.White;
                }

                for (int j = 0; j < Food3.Count; j++)
                {
                    ListViewItem lvi3 = ListViewFood3.ItemContainerGenerator.ContainerFromIndex(j) as ListViewItem;
                    var          cp3  = VisualTreeHelperExtensions.FindVisualChild <ContentPresenter>(lvi3);

                    var dt3 = cp3.ContentTemplate as DataTemplate;
                    var rt3 = (Rectangle)dt3.FindName("BackGround", cp3);
                    var tb3 = (TextBlock)dt3.FindName("NameFood", cp3);
                    rt3.Fill = Brushes.White;
                }

                var cp = VisualTreeHelperExtensions.FindVisualChild <ContentPresenter>(lvi);

                var dt = cp.ContentTemplate as DataTemplate;
                var rt = (Rectangle)dt.FindName("BackGround", cp);
                var tb = (TextBlock)dt.FindName("NameFood", cp);
                rt.Fill = (Brush)bc.ConvertFrom("#FF0BD9EE");

                if (ListViewSelected.Name == "ListViewFood1")
                {
                    foreach (var item in Food1)
                    {
                        if (item.name == tb.Text)
                        {
                            foodSelected = item;
                            break;
                        }
                    }
                }
                else if (ListViewSelected.Name == "ListViewFood2")
                {
                    foreach (var item in Food2)
                    {
                        if (item.name == tb.Text)
                        {
                            foodSelected = item;
                            break;
                        }
                    }
                }
                else
                {
                    foreach (var item in Food3)
                    {
                        if (item.name == tb.Text)
                        {
                            foodSelected = item;
                            break;
                        }
                    }
                }

                string result = API.AddFoodInBill(tableSelected.number, foodSelected);
                if (result == "")
                {
                    return;
                }
                dynamic stuffAddFood = JsonConvert.DeserializeObject(result);

                if (stuffAddFood.message != "successfull")
                {
                    MessageBox.Show("Có lỗi sảy ra, vui lòng thử lại!!!");
                }
                else
                {
                    MessageBox.Show("Thêm món thành công!!!");
                    UpdateBillLayout();
                    rt.Fill = Brushes.White;
                }
            }
        }
Пример #2
0
        public void GotRecentGames(RecentGames result)
        {
            gameStats.Clear();
            result.GameStatistics.Sort((s1, s2) => s2.CreateDate.CompareTo(s1.CreateDate));
            foreach (var game in result.GameStatistics)
            {
                game.GameType =
                    Client.TitleCaseString(game.GameType.Replace("_GAME", string.Empty).Replace("MATCHED", "NORMAL"));
                var match = new MatchStats();
                foreach (var stat in game.Statistics)
                {
                    var type      = typeof(MatchStats);
                    var fieldName = Client.TitleCaseString(stat.StatType.Replace('_', ' ')).Replace(" ", string.Empty);
                    var f         = type.GetField(fieldName);
                    f.SetValue(match, stat.Value);
                }
                match.Game = game;
                gameStats.Add(match);
            }

            Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() =>
            {
                GamesListView.Items.Clear();
                foreach (var stats in gameStats)
                {
                    var item                       = new RecentGameOverview();
                    var gameChamp                  = champions.GetChampion((int)Math.Round(stats.Game.ChampionId));
                    item.ChampionImage.Source      = gameChamp.icon;
                    item.ChampionNameLabel.Content = gameChamp.displayName;
                    item.ScoreLabel.Content        =
                        string.Format("{0}/{1}/{2} ",
                                      stats.ChampionsKilled,
                                      stats.NumDeaths,
                                      stats.Assists);

                    switch (stats.Game.QueueType)
                    {
                    case "NORMAL":
                        item.ScoreLabel.Content += "(Normal)";
                        break;

                    case "NORMAL_3x3":
                        item.ScoreLabel.Content += "(Normal 3v3)";
                        break;

                    case "ARAM_UNRANKED_5x5":
                        item.ScoreLabel.Content += "(ARAM)";
                        break;

                    case "NONE":
                        item.ScoreLabel.Content += "(Custom)";
                        break;

                    case "RANKED_SOLO_5x5":
                        item.ScoreLabel.Content += "(Ranked 5v5)";
                        break;

                    case "RANKED_TEAM_5x5":
                        item.ScoreLabel.Content += "(Ranked Team 5v5)";
                        break;

                    case "RANKED_TEAM_3x3":
                        item.ScoreLabel.Content += "(Ranked Team 3v3)";
                        break;

                    case "CAP_5x5":
                        item.ScoreLabel.Content += "(Team Builder)";
                        break;

                    case "BOT":
                        item.ScoreLabel.Content += "(Bots)";
                        break;

                    case "KING_PORO":
                        item.ScoreLabel.Content += "(King Poro)";
                        break;

                    default:
                        Client.Log(stats.Game.QueueType);
                        item.ScoreLabel.Content += "Please upload this log to github.";
                        break;
                    }

                    item.CreepScoreLabel.Content = stats.MinionsKilled + " minions";
                    item.DateLabel.Content       = stats.Game.CreateDate;
                    item.IPEarnedLabel.Content   = "+" + stats.Game.IpEarned + " IP";
                    item.PingLabel.Content       = stats.Game.UserServerPing + "ms";

                    var bc    = new BrushConverter();
                    var brush = (Brush)bc.ConvertFrom("#FF609E74");

                    if (Math.Abs(stats.Lose - 1) < .00001)
                    {
                        brush = (Brush)bc.ConvertFrom("#FF9E6060");
                    }
                    else if (Math.Abs(stats.Game.IpEarned) < .00001)
                    {
                        brush = (Brush)bc.ConvertFrom("#FFE27100");
                    }

                    item.GridView.Background = brush;
                    item.GridView.Width      = 280;
                    GamesListView.Items.Add(item);
                }
                if (GamesListView.Items.Count > 0)
                {
                    GamesListView.SelectedIndex = 0;
                }
            }));
        }
Пример #3
0
        private void displayFoodItems()
        {
            string[] list1 = new string[4] {
                "pack://siteoforigin:,,,/Resources/Edamame.jpg", "Edamame", "Soft soybeans served in the pod, which are steamed and lightly tossed in sea salt.", "$5.10"
            };
            string[] list2 = new string[4] {
                "pack://siteoforigin:,,,/Resources/SearedTunaSushi.jpg", "Seared Tuna Sushi (2 pcs)", "Lightly seared tuna, sushi rice, and spicy mayo topped with green onions.", "$4.10"
            };
            string[] list3 = new string[4] {
                "pack://siteoforigin:,,,/Resources/BroccoliTempura.jpg", "Broccoli Tempura (4 pcs)", "Battered broccoli, deep friend to a crispy texture, and served with tempura sauce", "$4.20"
            };
            string[] list4 = new string[4] {
                "pack://siteoforigin:,,,/Resources/GreenTea.jpg", "Green Tea", "Hot green tea", "$4.00"
            };

            FoodItem.foodItems = new List <string[]>();
            // FoodItem.foodItems.Add(list1);
            // FoodItem.foodItems.Add(list2);
            //FoodItem.foodItems.Add(list3);
            //FoodItem.foodItems.Add(list4);

            foreach (string[] item in FoodItem.foodItems)
            {
                ListViewItem appetizerItem = new ListViewItem();
                appetizerItem.Background      = Brushes.White;
                appetizerItem.BorderThickness = new Thickness(1, 1, 1, 1);
                appetizerItem.BorderBrush     = Brushes.Gray;
                appetizerItem.Height          = 72;

                StackPanel appetizerStack = new StackPanel();
                appetizerStack.Orientation = Orientation.Horizontal;
                appetizerStack.Width       = 695;

                //Item image
                Image appetizerImage = new Image();
                appetizerImage.Height = 58;
                appetizerImage.Width  = 65;
                appetizerImage.SnapsToDevicePixels = true;
                appetizerImage.Stretch             = Stretch.Fill;
                BitmapImage imagePath = new BitmapImage(new Uri(item[0]));
                appetizerImage.Source = imagePath;

                StackPanel appetizerStack2 = new StackPanel();
                appetizerStack2.Orientation = Orientation.Vertical;
                appetizerStack2.Width       = 513;

                //Title and detail
                TextBlock title  = new TextBlock();
                TextBlock detail = new TextBlock();
                title.Height                = 22;
                title.FontFamily            = new FontFamily("Yu Gothic UI");
                title.FontSize              = 16;
                title.Margin                = new Thickness(5, 0, 10, 5);
                title.RenderTransformOrigin = new Point(0.497, 0.422);
                title.FontWeight            = FontWeights.Bold;
                title.Text = item[1];

                detail.Height              = 22;
                detail.FontFamily          = new FontFamily("Yu Gothic UI");
                detail.FontSize            = 14;
                detail.Margin              = new Thickness(5, 0, 0, 5);
                detail.HorizontalAlignment = HorizontalAlignment.Left;
                detail.Width      = 557;
                detail.Foreground = Brushes.Gray;
                detail.Text       = item[2];

                //Price
                TextBlock price = new TextBlock();
                price.Height     = 17;
                price.FontFamily = new FontFamily("Yu Gothic UI");
                price.FontSize   = 16;
                price.Width      = 40;
                price.Margin     = new Thickness(20, 0, 0, 10);
                price.FontWeight = FontWeights.Bold;
                price.Text       = item[3];

                //delete icon
                //Item image
                Image deleteIcon = new Image();
                deleteIcon.Height = 24;
                deleteIcon.Width  = 28;
                BitmapImage deleteIconPath = new BitmapImage(new Uri("pack://siteoforigin:,,,/Resources/Delete.png"));
                deleteIcon.Source = deleteIconPath;

                //Delete Button
                Button deleteBtn = new Button();
                deleteBtn.FontFamily = new FontFamily("Yu Gothic UI");
                deleteBtn.Height     = 34;
                deleteBtn.Width      = 38;
                deleteBtn.Margin     = new Thickness(10, 0, 0, 0);
                deleteBtn.Click     += DeleteBtn_Click;
                deleteBtn.Background = Brushes.White;
                var bc = new BrushConverter();
                deleteBtn.BorderBrush = (Brush)bc.ConvertFrom("#FFF39E08");
                deleteBtn.Content     = deleteIcon;


                appetizerStack2.Children.Add(title);
                appetizerStack2.Children.Add(detail);

                appetizerStack.Children.Add(appetizerImage);
                appetizerStack.Children.Add(appetizerStack2);
                appetizerStack.Children.Add(price);
                appetizerStack.Children.Add(deleteBtn);

                appetizerItem.Content = appetizerStack;
                listView.Items.Add(appetizerItem);
            }
        }
Пример #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="command"></param>
        /// <returns>null: Delay add</returns>
        private RibbonGroupBox GetUiPosition(CompositeRemoteCommand command, out RibbonTabItem ribbonTab)
        {
            Argument.IsNotNull(() => command.DeserializedUIData);
            Argument.IsOfType(() => command.DeserializedUIData, typeof(RibbonUIData));
            var ribbonUiData  = (RibbonUIData)(command.DeserializedUIData);
            var ribbonTabData = ribbonUiData.UiPosition.RibbonTab;
            //find ribbon tab
            string tabName = null;

            if (ribbonTabData == null || string.IsNullOrEmpty(ribbonTabData.Name))
            {
                tabName = "RibbonTabHome";
            }
            else
            {
                tabName = ribbonTabData.Name;
            }
            ribbonTab = Ribbon.Tabs.FirstOrDefault(tab => tab.Name.Equals(tabName));
            if (ribbonTab == null)
            {
                if (ribbonTabData != null && ribbonTabData.CreatNewIfCanNotFound)
                {
                    //ToDo: creat new, consider contextual tab?
                    ribbonTab = new RibbonTabItem {
                        Name = ribbonTabData.Name
                    };
                    ribbonTab.BindToLoc(RibbonTabItem.HeaderProperty, ribbonTabData.LocalizedHeader);
                    //Consider ribbon tab group data
                    var ribbonGroupData = ribbonUiData.UiPosition.RibbonTabGroup;
                    if (!string.IsNullOrEmpty(ribbonGroupData.Name))
                    {
                        //find or create
                        var tabGroup = Ribbon.ContextualGroups.FirstOrDefault(ribbonGroup => ribbonGroup.Name.Equals(ribbonGroupData.Name));
                        if (tabGroup == null)
                        {
                            var conv = new BrushConverter();
                            tabGroup = new RibbonContextualTabGroup()
                            {
                                Visibility = Visibility.Visible, Name = ribbonGroupData.Name
                            };

                            if (!string.IsNullOrEmpty(ribbonGroupData.BorderBrush))
                            {
                                tabGroup.BorderBrush =
                                    conv.ConvertFromString(ribbonGroupData.BorderBrush) as SolidColorBrush;
                            }
                            if (!string.IsNullOrEmpty(ribbonGroupData.BackgroundBrush))
                            {
                                tabGroup.Background =
                                    conv.ConvertFromString(ribbonGroupData.BackgroundBrush) as SolidColorBrush;
                            }

                            if (string.IsNullOrEmpty(ribbonGroupData.LocalizedHeader))
                            {
                                tabGroup.Header = ribbonGroupData.Name;
                            }
                            else
                            {
                                tabGroup.BindToLoc(RibbonContextualTabGroup.HeaderProperty, ribbonGroupData.LocalizedHeader);
                            }
                            ShellService.Ribbon.AddRibbonContextualTabGroup(tabGroup);
                        }
                        if (ribbonTab.Group == null)
                        {
                            ribbonTab.Group = tabGroup;
                        }
                    }
                    ShellService.Ribbon.AddRibbonTab(ribbonTab);
                }
                else
                {
                    //delay the remote command add.
                    DelayGenerateUiList.Add(command);
                    return(null);
                }
            }

            //ribbon group box
            var groupBox = ribbonTab.Groups.FirstOrDefault(g => g.Name.Equals(ribbonUiData.UiPosition.GroupBox.Name));

            if (groupBox == null)
            {
                groupBox = new RibbonGroupBoxContextUI()
                {
                    Name = ribbonUiData.UiPosition.GroupBox.Name
                };
                if (string.IsNullOrEmpty(ribbonUiData.UiPosition.GroupBox.LocalizedHeader))
                {
                    groupBox.Header = ribbonUiData.UiPosition.GroupBox.Name;
                }
                else
                {
                    groupBox.BindToLoc(RibbonGroupBox.HeaderProperty, ribbonUiData.UiPosition.GroupBox.LocalizedHeader);
                }

                ribbonTab.Groups.Add(groupBox);
            }
            return(groupBox);
        }
Пример #5
0
        /// <summary>
        /// Loads the add-in menu and toolbar buttons
        /// </summary>
        /// <param name="window"></param>
        public void InitializeAddinsUi(MainWindow window, List <MarkdownMonsterAddin> addins = null)
        {
            if (addins == null)
            {
                addins = AddIns;
            }

            foreach (var addin in addins)
            {
                addin.Model = window.Model;

                foreach (var addinMenuItem in addin.MenuItems)
                {
                    try
                    {
                        var mitem = new MenuItem
                        {
                            Header = addinMenuItem.Caption,
                            Name   = StringUtils.ToCamelCase(addinMenuItem.Caption)
                        };

                        if (string.IsNullOrEmpty(addin.Name))
                        {
                            addin.Name = addinMenuItem.Caption;
                        }

                        Action <object, ICommand> xAction = (s, c) =>
                        {
                            try
                            {
                                addinMenuItem.Execute?.Invoke(mitem);
                            }
                            catch (Exception ex)
                            {
                                mmApp.Log($"Addin {addin.Name ?? addin.Id} Execute failed", ex);
                                string msg = $"The '{addin.Name ?? addin.Id}' addin failed:\r\n\r\n{ex.GetBaseException().Message}\r\n\r\n" +
                                             "You can check to see if there is an update for the Addin available in the Addin Manager. We also recommend you update to the latest version of Markdown Monster.";
                                MessageBox.Show(msg, "Addin Execution Failed",
                                                MessageBoxButton.OK, MessageBoxImage.Warning);
                            }
                        };
                        Func <object, ICommand, bool> cxAction = null;
                        if (addinMenuItem.CanExecute != null)
                        {
                            cxAction = (s, e) =>
                            {
                                try
                                {
                                    return(addinMenuItem.CanExecute.Invoke(s));
                                }
                                catch (Exception ex)
                                {
                                    mmApp.Log($"Addin {addin.Name} CanExecute failed", ex);
                                    return(true);
                                }
                            }
                        }
                        ;
                        addinMenuItem.Command = new CommandBase(xAction, cxAction);
                        mitem.Command         = addinMenuItem.Command;

                        addin.Model.Window.MenuAddins.Items.Add(mitem);

                        // if an icon is provided also add to toolbar
                        if (addinMenuItem.FontawesomeIcon != FontAwesomeIcon.None || addinMenuItem.IconImageSource != null)
                        {
                            var hasConfigMenu = addinMenuItem.ExecuteConfiguration != null;

                            Brush colorBrush;
                            if (string.IsNullOrEmpty(addinMenuItem.FontawesomeIconColor))
                            {
                                colorBrush = mmApp.Model.Window.Foreground;
                            }
                            else
                            {
                                colorBrush = new BrushConverter().ConvertFrom(addinMenuItem.FontawesomeIconColor) as Brush;
                            }

                            var titem = new Button();

                            var source = addinMenuItem.IconImageSource ??
                                         ImageAwesome.CreateImageSource(addinMenuItem.FontawesomeIcon, colorBrush);

                            titem.Content = new Image()
                            {
                                Source  = source,
                                ToolTip = addinMenuItem.Caption +
                                          (!string.IsNullOrEmpty(addinMenuItem.KeyboardShortcut) ?
                                           $" ({addinMenuItem.KeyboardShortcut})" :
                                           string.Empty),
                                Height = addinMenuItem.IconImageSource == null ? 18 : 19,
                                Width  = addinMenuItem.IconImageSource == null ? 18 : 19,
                            };
                            if (hasConfigMenu)
                            {
                                titem.Padding = new Thickness(5, 4, 4, 4);
                            }

                            addinMenuItem.MenuItemButton = titem;



                            if (addinMenuItem.Execute != null)
                            {
                                titem.Command = addinMenuItem.Command;
                                AddKeyboardShortcut(addinMenuItem, addin);
                            }

                            addin.Model.Window.ToolbarAddIns.Visibility = Visibility.Visible;
                            int toolIndex = addin.Model.Window.ToolbarAddIns.Items.Add(titem);

                            // Add configuration dropdown if configured
                            if (hasConfigMenu)
                            {
                                var tcitem = new Button
                                {
                                    FontSize = 10F,
                                    Content  = new Image()
                                    {
                                        Source =
                                            ImageAwesome.CreateImageSource(FontAwesomeIcon.CaretDown,
                                                                           addin.Model.Window.Foreground),
                                        Height = 16,
                                        Width  = 8,
                                        Margin = new Thickness(0, 0, 0, 0)
                                    },

                                    ToolTip = addinMenuItem.Caption + " Configuration",
                                };
                                tcitem.Padding = new Thickness(2, 4, 2, 4);
                                tcitem.Margin  = new Thickness(0, 0, 4, 0);

                                var ctxm = new ContextMenu();
                                tcitem.ContextMenu = ctxm;

                                // create context menu and add drop down behavior
                                var behaviors = Interaction.GetBehaviors(tcitem);
                                behaviors.Add(new DropDownButtonBehavior());

                                tcitem.Click += (sender, args) =>
                                {
                                    ctxm.Items.Clear();
                                    var configMenuItem = new MenuItem()
                                    {
                                        Header = addinMenuItem.Caption
                                    };
                                    configMenuItem.Command = addinMenuItem.Command;
                                    if (addinMenuItem.CanExecute != null)
                                    {
                                        configMenuItem.IsEnabled = addinMenuItem.CanExecute.Invoke(sender);
                                    }
                                    ctxm.Items.Add(configMenuItem);

                                    configMenuItem = new MenuItem()
                                    {
                                        Header = $"{addinMenuItem.Caption} Configuration",
                                    };
                                    if (addinMenuItem.ExecuteConfiguration != null)
                                    {
                                        configMenuItem.Click += (s, e) => addinMenuItem.ExecuteConfiguration?.Invoke(s);
                                    }

                                    addinMenuItem.ConfigurationMenuItem = configMenuItem;

                                    ctxm.Items.Add(configMenuItem);

                                    // Uninstall Addin
                                    if (!addin.Id.Equals("screencapture", StringComparison.InvariantCultureIgnoreCase) &&
                                        !addin.Id.Equals("weblog", StringComparison.InvariantCultureIgnoreCase) &&
                                        !addin.Id.Equals("snippets", StringComparison.InvariantCultureIgnoreCase))
                                    {
                                        configMenuItem = new MenuItem()
                                        {
                                            Header = $"Uninstall {addinMenuItem.Caption}",
                                        };
                                        if (addinMenuItem.ExecuteConfiguration != null)
                                        {
                                            configMenuItem.Click += (s, e) =>
                                            {
                                                if (AddinManager.Current.UninstallAddin(addin.Id))
                                                {
                                                    mmApp.Model.Window.ShowStatusSuccess(
                                                        $"{addin.Name} addin has been removed.");
                                                    addinMenuItem.MenuItemButton.Visibility = Visibility.Collapsed;
                                                    tcitem.Visibility = Visibility.Collapsed;
                                                }
                                                else
                                                {
                                                    mmApp.Model.Window.ShowStatusError(
                                                        $"Unable to uninstall {addin.Name} addin.");
                                                }
                                            }
                                        }
                                        ;

                                        addinMenuItem.ConfigurationMenuItem = configMenuItem;
                                        ctxm.Items.Add(configMenuItem);
                                    }
                                };

                                addin.Model.Window.ToolbarAddIns.Items.Add(tcitem);
                            }
                            ;
                        }
                    }
                    catch (Exception ex)
                    {
                        var msg = $"Unable to load add-in: {Path.GetFileNameWithoutExtension(addin.Name)}";
                        mmApp.Log(msg, ex);
                        AddinLoadErrors.AppendLine(msg + "\r\n");
                    }
                }
            }

            if (AddinLoadErrors.Length > 0)
            {
                MessageBox.Show(AddinLoadErrors.ToString() +
                                "\r\n\r\n" +
                                "Try updating each failing addin and Markdown Monster to the latest versions or uninstall each failing addins.",
                                "The following addins failed to load",
                                MessageBoxButton.OK, MessageBoxImage.Warning);
            }
            _addinLoadErrors = null;
        }
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            BrushConverter converter = new BrushConverter();

            return((Brush)converter.ConvertFromString(value.ToString()));
        }
Пример #7
0
        private void LogMessage(string message)
        {
            var bc = new BrushConverter();

            LogMessage(message, (Brush)bc.ConvertFrom("#FF99AAB5"));
        }
        private bool CheckInputs()
        {
            var bc = new BrushConverter();

            ConfirmationDate.BorderBrush = (Brush)bc.ConvertFrom("#FFCCCCCC");

            FullName.BorderBrush = (Brush)bc.ConvertFrom("#FFCCCCCC");

            PlaceOfBaptism.BorderBrush = (Brush)bc.ConvertFrom("#FFCCCCCC");

            Sponsor1.BorderBrush = (Brush)bc.ConvertFrom("#FFCCCCCC");

            Parent1.BorderBrush = (Brush)bc.ConvertFrom("#FFCCCCCC");

            Minister.BorderBrush = (Brush)bc.ConvertFrom("#FFCCCCCC");

            Sponsor1.BorderBrush = (Brush)bc.ConvertFrom("#FFCCCCCC");

            Parish.BorderBrush = (Brush)bc.ConvertFrom("#FFCCCCCC");

            Province.BorderBrush = (Brush)bc.ConvertFrom("#FFCCCCCC");

            bool ret = true;

            if (string.IsNullOrWhiteSpace(ConfirmationDate.Text))
            {
                ConfirmationDate.ToolTip     = "This field is required.";
                ConfirmationDate.BorderBrush = Brushes.Red;
                Icon3.BorderBrush            = Brushes.Red;

                ret = false;
            }
            if (EntryNum.Value < 0)
            {
                EntryNum.ToolTip     = "Must be greater than zero.";
                EntryNum.BorderBrush = Brushes.Red;
                Icon2.BorderBrush    = Brushes.Red;

                ret = false;
            }
            if (PageNum.Value < 0)
            {
                PageNum.ToolTip     = "Must be greater than zero.";
                PageNum.BorderBrush = Brushes.Red;
                Icon1.BorderBrush   = Brushes.Red;

                ret = false;
            }
            if (string.IsNullOrWhiteSpace(FullName.Text))
            {
                FullName.ToolTip     = "This field is required.";
                FullName.BorderBrush = Brushes.Red;
                Icon5.BorderBrush    = Brushes.Red;

                ret = false;
            }
            if (Stipend.Value == 0)
            {
                Stipend.ToolTip     = "Notice: Stipend is set to zero.";
                Stipend.BorderBrush = Brushes.Orange;
                Icon9.BorderBrush   = Brushes.Red;

                MsgStipend();
                ret = true;
            }
            if (string.IsNullOrWhiteSpace(PlaceOfBaptism.Text))
            {
                PlaceOfBaptism.ToolTip     = "This field is required.";
                PlaceOfBaptism.BorderBrush = Brushes.Red;
                Icon8.BorderBrush          = Brushes.Red;

                ret = false;
            }
            if (string.IsNullOrWhiteSpace(Sponsor1.Text))
            {
                Sponsor1.ToolTip     = "This field is required.";
                Sponsor1.BorderBrush = Brushes.Red;
                Icon11.BorderBrush   = Brushes.Red;

                ret = false;
            }
            if (string.IsNullOrWhiteSpace(Parent1.Text))
            {
                Parent1.ToolTip     = "This field is required.";
                Parent1.BorderBrush = Brushes.Red;
                Icon10.BorderBrush  = Brushes.Red;

                ret = false;
            }
            if (string.IsNullOrWhiteSpace(Minister.Text))
            {
                Minister.ToolTip     = "This field is required.";
                Minister.BorderBrush = Brushes.Red;
                Icon14.BorderBrush   = Brushes.Red;

                ret = false;
            }
            if (string.IsNullOrWhiteSpace(Parish.Text))
            {
                Parish.ToolTip     = "This field is required.";
                Parish.BorderBrush = Brushes.Red;
                Icon6.BorderBrush  = Brushes.Red;

                ret = false;
            }
            if (string.IsNullOrWhiteSpace(Province.Text))
            {
                Province.ToolTip     = "This field is required.";
                Province.BorderBrush = Brushes.Red;
                Icon7.BorderBrush    = Brushes.Red;

                ret = false;
            }
            return(ret);
        }
        private void Tc0SkipButton_MouseEnter(object sender, MouseEventArgs e)
        {
            var bc = new BrushConverter();

            Tc0SkipButton.Background = (Brush)bc.ConvertFrom("#8c2d2d");
        }
Пример #10
0
        // handles when a heat-map option is selected
        public void heatMapOptions(object sender, MouseButtonEventArgs e)
        {
            // only register event if MAP_STATE is "heat"
            if (MAP_STATE == "interactive")
            {
                return;
            }
            else
            {
                // color depending on state's percentile
                string[] colors = new string[] { "#ffb3b3", "#ff6666", "#ff0000", "#b30000", "#4d0000" };

                // option selected
                string optionSelected = (string)((TextBlock)sender).Tag;

                switch (optionSelected)
                {
                case "testedOption":
                    heatMapOption = "tested";
                    testedHeatMapOption.Opacity = 1;
                    deathsHeatMapOption.Opacity = .5;
                    currentStateClicked.Opacity = .5;
                    break;

                case "positiveOption":
                    heatMapOption = "positive";
                    testedHeatMapOption.Opacity = .5;
                    deathsHeatMapOption.Opacity = .5;
                    currentStateClicked.Opacity = 1;
                    break;

                case "deathsOption":
                    heatMapOption = "deaths";
                    testedHeatMapOption.Opacity = .5;
                    deathsHeatMapOption.Opacity = 1;
                    currentStateClicked.Opacity = .5;
                    break;
                }

                // assign percentiles
                Dictionary <string, int> percentiles;
                switch (heatMapOption)
                {
                case "tested":
                    percentiles = testedPercentiles;
                    break;

                case "positive":
                    percentiles = positivePercentiles;
                    break;

                case "deaths":
                    percentiles = deathsPercentiles;
                    break;

                default:
                    percentiles = testedPercentiles;
                    break;
                }

                // change map colors
                var bc = new BrushConverter();
                foreach (KeyValuePair <string, string> states in statePairs)
                {
                    var name = (Path)this.FindName(states.Key);
                    name.Fill = (Brush)bc.ConvertFrom(colors[percentiles[states.Key] - 1]);
                }
            }
        }
Пример #11
0
        private void dgTagResults_LoadingRow(object sender, DataGridRowEventArgs e)
        {
            try {
                if (chkEnableTagAging)
                {
                    var            data = (TagReadRecord)e.Row.DataContext;
                    TimeSpan       difftimeInSeconds = (DateTime.UtcNow - data.TimeStamp.ToUniversalTime());
                    BrushConverter brush             = new BrushConverter();
                    if (enableTagAgingOnRead)
                    {
                        if (difftimeInSeconds.TotalSeconds < 12)
                        {
                            switch (Math.Round(difftimeInSeconds.TotalSeconds).ToString())
                            {
                            case "5":
                                e.Row.Background = (Brush)brush.ConvertFrom("#FFEEEEEE");
                                break;

                            case "6":
                                e.Row.Background = (Brush)brush.ConvertFrom("#FFD3D3D3");
                                break;

                            case "7":
                                e.Row.Background = (Brush)brush.ConvertFrom("#FFCCCCCC");
                                break;

                            case "8":
                                e.Row.Background = (Brush)brush.ConvertFrom("#FFC3C3C3");
                                break;

                            case "9":
                                e.Row.Background = (Brush)brush.ConvertFrom("#FFBBBBBB");
                                break;

                            case "10":
                                e.Row.Background = (Brush)brush.ConvertFrom("#FFA1A1A1");
                                break;

                            case "11":
                                e.Row.Background = new SolidColorBrush(Colors.Gray);
                                break;
                            }
                            Dispatcher.BeginInvoke(new System.Threading.ThreadStart(delegate() { RetainAgingOnStopRead(data.SerialNumber.ToString(), e.Row.Background); }));
                        }
                        else
                        {
                            e.Row.Background = (Brush)brush.ConvertFrom("#FF888888");
                            Dispatcher.BeginInvoke(new System.Threading.ThreadStart(delegate() { RetainAgingOnStopRead(data.SerialNumber.ToString(), e.Row.Background); }));
                        }
                    }
                    else
                    {
                        if (tagagingColourCache.ContainsKey(data.SerialNumber.ToString()))
                        {
                            e.Row.Background = tagagingColourCache[data.SerialNumber.ToString()];
                        }
                        else
                        {
                            e.Row.Background = Brushes.White;
                        }
                    }
                }
            }
            catch {}
        }
Пример #12
0
        // changes between heat and interactive map UI state
        public void changeMapState(object sender, MouseButtonEventArgs e)
        {
            // set UI MAP_STATE
            string map_state = ((string)((TextBlock)sender).Tag).ToLower();

            // to avoid re-loading current UI State
            if (map_state == MAP_STATE)
            {
                return;
            }
            else
            {
                MAP_STATE = map_state;
            }


            // color depending on state's percentile!
            string[] colors = new string[] { "#ffb3b3", "#ff6666", "#ff0000", "#b30000", "#4d0000" };

            // revert STATE to null
            STATE = null;

            // clear stats on left-sidebar
            numTested.Text   = "--";
            numPositive.Text = "--";
            numDeaths.Text   = "--";

            // reset percentage increases
            percentTestedIncrease.Text   = "";
            percentPositiveIncrease.Text = "";
            percentDeathsIncrease.Text   = "";

            // clear bar-graph
            var bc = new BrushConverter();

            month6.Background = (Brush)bc.ConvertFrom("#292929");
            month5.Background = (Brush)bc.ConvertFrom("#292929");
            month4.Background = (Brush)bc.ConvertFrom("#292929");
            month3.Background = (Brush)bc.ConvertFrom("#292929");
            month2.Background = (Brush)bc.ConvertFrom("#292929");
            month1.Background = (Brush)bc.ConvertFrom("#292929");

            // reset bar-graph text
            month6Name.Text = "";
            month5Name.Text = "";
            month4Name.Text = "";
            month3Name.Text = "";
            month2Name.Text = "";
            month1Name.Text = "";

            // reset bar-graph data selection
            testedBar.Foreground   = Brushes.Gray;
            positiveBar.Foreground = Brushes.Gray;
            deathsBar.Foreground   = Brushes.Gray;

            // reset current map clicked text
            currentStateClicked.Text = "--";

            // rearrange UI according to MAP_STATE
            switch (MAP_STATE)
            {
            case "heat":

                // change heat/interactive button opacity, for clarity
                heatButton.Opacity        = 1;
                interactiveButton.Opacity = .5;

                // enable color blocks
                colorBlocks.Opacity = 1;

                // enable heat-map options
                testedHeatMapOption.Opacity = 1;
                deathsHeatMapOption.Opacity = .5;

                // enables heat-map options (positive option)
                // kinda confusing cause currentStateClicked is now the "positive" button
                // So, what I do is rearrange currentStateClicked to match the size of other heat-map options
                currentStateClicked.Width      = 80;
                currentStateClicked.Margin     = new Thickness(5, 15, 0, 5);
                currentStateClicked.Text       = "Positive";
                currentStateClicked.Background = (Brush)bc.ConvertFrom("#121212");
                currentStateClicked.Opacity    = .5;
                currentStateClicked.FontSize   = 12;

                // change map interactions
                MAP.IsEnabled = false;

                // assign percentiles
                Dictionary <string, int> percentiles;
                switch (heatMapOption)
                {
                case "tested":
                    percentiles = testedPercentiles;
                    break;

                case "positive":
                    percentiles = positivePercentiles;
                    break;

                case "deaths":
                    percentiles = deathsPercentiles;
                    break;

                default:
                    percentiles = testedPercentiles;
                    break;
                }

                // change map colors
                foreach (KeyValuePair <string, string> states in statePairs)
                {
                    var name = (Path)this.FindName(states.Key);
                    name.Fill = (Brush)bc.ConvertFrom(colors[percentiles[states.Key] - 1]);
                }

                break;

            case "interactive":

                // change button opacity, for clarity
                interactiveButton.Opacity = 1;
                heatButton.Opacity        = .5;

                // disable color blocks
                colorBlocks.Opacity = 0;

                // enable heat-map options
                testedHeatMapOption.Opacity = 0;
                deathsHeatMapOption.Opacity = 0;

                // enables heat-map options (positive option)
                // kinda confusing cause currentStateClicked is now the "positive" button
                currentStateClicked.Width      = 250;
                currentStateClicked.Margin     = new Thickness(-80, -2, 0, 4);
                currentStateClicked.Text       = "--";
                currentStateClicked.Background = (Brush)bc.ConvertFrom("#292929");
                currentStateClicked.Opacity    = 1;
                currentStateClicked.FontSize   = 25;

                // change map interactions
                MAP.IsEnabled = true;

                // reset map colors
                foreach (KeyValuePair <string, string> states in statePairs)
                {
                    var name = (Path)this.FindName(states.Key);
                    name.Fill = (Brush)bc.ConvertFrom("#ffd2d2d2");
                }

                break;
            }
        }
Пример #13
0
        // builds bar-graph based on state selected and dataType ("tested", "positive", or "deaths")
        public void buildBarGraph(string state, string dataType)
        {
            // pull rleevant state data
            StateData st = new StateData(state);

            // returns max value of all keys in dictionary (helpful for creating bargraph bounds)
            int maxValue = st.barGraphData(dataType).Values.Max();

            // these are the 14 different value stops our data could "attach" to
            // the bar graph is from 0 - maxValue, and theres 14 valid "heights" for each bar
            double barGraphIncrement = maxValue / 14;

            // List of the literal number at each "stop"
            List <double> barStops = new List <double>();

            // fill barStops with those 14 numbers
            double stopNum = barGraphIncrement; // lowest value for graph would be the first stop (wont be zero)

            for (int i = 0; i < 14; i++)
            {
                barStops.Add(stopNum);
                stopNum += barGraphIncrement;
            }

            // I choose to dump my dictionary into 2 Lists, associated by their index
            List <int> months  = new List <int>();
            List <int> dataNum = new List <int>();

            foreach (KeyValuePair <int, int> kvp in st.barGraphData(dataType))
            {
                months.Add(kvp.Key);
                dataNum.Add(kvp.Value);
            }

            // assigned month names in bar graph
            month6Name.Text = monthStrings[months[0] - 1];
            month5Name.Text = monthStrings[months[1] - 1];
            month4Name.Text = monthStrings[months[2] - 1];
            month3Name.Text = monthStrings[months[3] - 1];
            month2Name.Text = monthStrings[months[4] - 1];
            month1Name.Text = monthStrings[months[5] - 1];

            // adjust margin-tops for each bar
            int indexBarStop = 0;
            int currentMonth = 6;

            foreach (int d in dataNum)
            {
                double lowestDifference = Double.PositiveInfinity;

                for (int i = 0; i < barStops.Count; i++)
                {
                    double difference = Math.Abs(d - barStops[i]);

                    if (difference < lowestDifference)
                    {
                        lowestDifference = difference;
                        indexBarStop     = i;
                    }
                }


                // marginTop for each bar in barGraph
                int marginTop = (((barStops.Count - indexBarStop + 1) * 5) + 5 >= 75) ? 70 : ((barStops.Count - indexBarStop + 1) * 5) + 5;

                // change color of each bar
                var bc = new BrushConverter();

                // adjust margin-tops for each bar
                if (currentMonth == 6)
                {
                    currentMonth     -= 1;
                    month6.Margin     = new Thickness(185, marginTop, 0, 0);
                    month6.Background = (Brush)bc.ConvertFrom("#bb86fc");
                    month6Name.Margin = new Thickness(10, 55 - marginTop, 10, 0);
                }
                else if (currentMonth == 5)
                {
                    currentMonth     -= 1;
                    month5.Margin     = new Thickness(111, marginTop, 0, 0);
                    month5.Background = (Brush)bc.ConvertFrom("#bb86fc");
                    month5Name.Margin = new Thickness(10, 55 - marginTop, 10, 0);
                }
                else if (currentMonth == 4)
                {
                    currentMonth     -= 1;
                    month4.Margin     = new Thickness(37, marginTop, 0, 0);
                    month4.Background = (Brush)bc.ConvertFrom("#bb86fc");
                    month4Name.Margin = new Thickness(10, 55 - marginTop, 10, 0);
                }
                else if (currentMonth == 3)
                {
                    currentMonth     -= 1;
                    month3.Margin     = new Thickness(-37, marginTop, 0, 0);
                    month3.Background = (Brush)bc.ConvertFrom("#bb86fc");
                    month3Name.Margin = new Thickness(10, 55 - marginTop, 10, 0);
                }
                else if (currentMonth == 2)
                {
                    currentMonth     -= 1;
                    month2.Margin     = new Thickness(-111, marginTop, 0, 0);
                    month2.Background = (Brush)bc.ConvertFrom("#bb86fc");
                    month2Name.Margin = new Thickness(10, 55 - marginTop, 10, 0);
                }
                else
                {
                    currentMonth     -= 1;
                    month1.Margin     = new Thickness(-185, marginTop, 0, 0);
                    month1.Background = (Brush)bc.ConvertFrom("#bb86fc");
                    month1Name.Margin = new Thickness(10, 55 - marginTop, 10, 0);
                }
            }
        }
Пример #14
0
        private void ListViewUsingVIPRoom_MouseUp(object sender, MouseButtonEventArgs e)
        {
            if (((ListView)sender).SelectedIndex == -1)
            {
                return;
            }

            if (((ListView)sender).ItemContainerGenerator.ContainerFromIndex(((ListView)sender).SelectedIndex) is ListViewItem lvi)
            {
                lvHienTai  = (ListView)sender;
                lviHienTai = lvi;

                var bc = new BrushConverter();

                for (int j = 0; j < UsingVIPSingleRooms.Count; j++)
                {
                    ListViewItem lvi1 = ListViewUsingVIPSingleRoom.ItemContainerGenerator.ContainerFromIndex(j) as ListViewItem;
                    var          cp1  = VisualTreeHelperExtensions.FindVisualChild <ContentPresenter>(lvi1);

                    var dt1 = cp1.ContentTemplate as DataTemplate;
                    var rt1 = (Rectangle)dt1.FindName("BackGround", cp1);
                    var tb1 = (TextBlock)dt1.FindName("NumberRoom", cp1);

                    rt1.Fill = Brushes.White;
                }

                for (int j = 0; j < UsingVIPCoupleRooms.Count; j++)
                {
                    ListViewItem lvi2 = ListViewUsingVIPCoupleRoom.ItemContainerGenerator.ContainerFromIndex(j) as ListViewItem;
                    var          cp2  = VisualTreeHelperExtensions.FindVisualChild <ContentPresenter>(lvi2);

                    var dt2 = cp2.ContentTemplate as DataTemplate;
                    var rt2 = (Rectangle)dt2.FindName("BackGround", cp2);
                    var tb2 = (TextBlock)dt2.FindName("NumberRoom", cp2);

                    rt2.Fill = Brushes.White;
                }

                for (int j = 0; j < UsingVIPGroupRooms.Count; j++)
                {
                    ListViewItem lvi3 = ListViewUsingVIPGroupRoom.ItemContainerGenerator.ContainerFromIndex(j) as ListViewItem;
                    var          cp3  = VisualTreeHelperExtensions.FindVisualChild <ContentPresenter>(lvi3);

                    var dt3 = cp3.ContentTemplate as DataTemplate;
                    var rt3 = (Rectangle)dt3.FindName("BackGround", cp3);
                    var tb3 = (TextBlock)dt3.FindName("NumberRoom", cp3);

                    rt3.Fill = Brushes.White;
                }

                var cp = VisualTreeHelperExtensions.FindVisualChild <ContentPresenter>(lvi);

                var dt = cp.ContentTemplate as DataTemplate;
                var rt = (Rectangle)dt.FindName("BackGround", cp);
                var tb = (TextBlock)dt.FindName("NumberRoom", cp);

                foreach (var room in DataProvider.Ins.DB.Phongs.ToList())
                {
                    if (tb.Text == room.soPhong)
                    {
                        phongHienTai = room;

                        NumberRoom.Text    = room.soPhong;
                        TypeRoom.Text      = room.loaiPhong;
                        Customername.Text  = room.KhachHang.hoTen;
                        CustomerID.Text    = room.KhachHang.cmnd;
                        NoteTextBlock.Text = room.ghiChu;
                        Time.Text          = ((DateTime.Now - room.thoiGianBatDau).Value.Days).ToString() + " ngày " + ((DateTime.Now - room.thoiGianBatDau).Value).ToString(@"hh\:mm\:ss");
                        Total.Text         = Math.Round((((DateTime.Now - room.thoiGianBatDau).Value.Hours + ((DateTime.Now - room.thoiGianBatDau).Value.Days) * 24) * phongHienTai.DanhSachBangGia.cacGioSau + phongHienTai.DanhSachBangGia.gioDau), 0).ToString();

                        break;
                    }
                }

                rt.Fill = (Brush)bc.ConvertFrom("#FF0BD9EE");
            }
        }
Пример #15
0
        private void button_Click(object sender, RoutedEventArgs e)
        {
            // on vérifie si l'élève appuie sur terminer avant de terminer complètement
            if ((checkBox.IsChecked == false && checkBox1.IsChecked == false && checkBox2.IsChecked == false) ||
                (checkBoxb.IsChecked == false && checkBox1b.IsChecked == false && checkBox2b.IsChecked == false) ||
                (checkBoxc.IsChecked == false && checkBox1c.IsChecked == false && checkBox2c.IsChecked == false) ||
                (checkBoxd.IsChecked == false && checkBox1d.IsChecked == false) ||
                (checkBoxe.IsChecked == false && checkBox1e.IsChecked == false) ||
                (checkBoxf.IsChecked == false && checkBox1f.IsChecked == false) ||
                (textBlock9.Text == "-------" || textBlock11.Text == "-------" || textBlock13.Text == "-------") ||
                (textBlock9b.Text == "-------" || textBlock11b.Text == "-------" || textBlock13b.Text == "-------" || textBlock15b.Text == "-------") ||
                (textBlock9c.Text == "-------" || textBlock11c.Text == "-------" || textBlock13c.Text == "-------")
                )
            {
                textBlock22.Visibility = Visibility.Visible;
                textBlock22.Text       = "لم تجب على كل الاسئلة";
            }
            else
            {
                textBlock22.Visibility = Visibility.Hidden;
                button.Click          -= button_Click;
                timer.Stop();
                textBlock19.Text = "0:0";
                note             = 0;
                int nbCorrect = 0;
                var bc        = new BrushConverter();
                if (checkBox2.IsChecked == true)
                {
                    note++;
                    nbCorrect++;
                }
                else
                {
                    checkBox2.IsChecked  = true;
                    checkBox.Visibility  = Visibility.Collapsed;
                    checkBox1.Visibility = Visibility.Collapsed;
                }
                if (checkBox1b.IsChecked == true)
                {
                    note++; nbCorrect++;
                }
                else
                {
                    checkBox1b.IsChecked  = true;
                    checkBoxb.Visibility  = Visibility.Collapsed;
                    checkBox2b.Visibility = Visibility.Collapsed;
                }
                if (checkBox2c.IsChecked == true)
                {
                    note++; nbCorrect++;
                }
                else
                {
                    checkBox2c.IsChecked  = true;
                    checkBoxc.Visibility  = Visibility.Collapsed;
                    checkBox1c.Visibility = Visibility.Collapsed;
                }
                ///
                if (checkBoxd.IsChecked == true)
                {
                    note++; nbCorrect++;
                }
                else
                {
                    checkBoxd.IsChecked   = true;
                    checkBox1d.Visibility = Visibility.Collapsed;
                }
                if (checkBoxe.IsChecked == true)
                {
                    note++; nbCorrect++;
                }
                else
                {
                    checkBoxe.IsChecked   = true;
                    checkBox1e.Visibility = Visibility.Collapsed;
                }
                if (checkBox1f.IsChecked == true)
                {
                    note++; nbCorrect++;
                }
                else
                {
                    checkBox1f.IsChecked = true;
                    checkBoxf.Visibility = Visibility.Collapsed;
                }
                ///
                if (textBlock9.Text.Equals("جبال الونشريس") || textBlock9.Text.Equals("جبال تسالا"))
                {
                    note += 0.5; nbCorrect++;
                }
                else
                {
                    textBlock9.Text       = "جبال الونشريس";
                    textBlock9.Background = (Brush)bc.ConvertFrom("#FFD62E2E");
                }
                if (textBlock11.Text.Equals("جبال تسالا") || textBlock11.Text.Equals("جبال الونشريس"))
                {
                    note += 0.5; nbCorrect++;
                }
                else
                {
                    textBlock11.Text       = "جبال تسالا";
                    textBlock11.Background = (Brush)bc.ConvertFrom("#FFD62E2E");
                }
                if (textBlock13.Text.Equals("جبال القصور"))
                {
                    note += 0.5; nbCorrect++;
                }
                else
                {
                    textBlock13.Text       = "جبال القصور";
                    textBlock13.Background = (Brush)bc.ConvertFrom("#FFD62E2E");
                }
                if (textBlock9b.Text.Equals("اعتدال"))
                {
                    note += 0.25; nbCorrect++;
                }
                else
                {
                    textBlock9b.Text       = "اعتدال";
                    textBlock9b.Background = (Brush)bc.ConvertFrom("#FFD62E2E");
                }
                if (textBlock11b.Text.Equals("غزارة الأمطار"))
                {
                    note += 0.25; nbCorrect++;
                }
                else
                {
                    textBlock11b.Text       = "غزارة الأمطار";
                    textBlock11b.Background = (Brush)bc.ConvertFrom("#FFD62E2E");
                }
                if (textBlock13b.Text.Equals("ارتفاع"))
                {
                    note += 0.25; nbCorrect++;
                }
                else
                {
                    textBlock13b.Text       = "ارتفاع";
                    textBlock13b.Background = (Brush)bc.ConvertFrom("#FFD62E2E");
                }
                if (textBlock15b.Text.Equals("قلة الأمطار"))
                {
                    note += 0.25; nbCorrect++;
                }
                else
                {
                    textBlock15b.Text       = "قلة الأمطار";
                    textBlock15b.Background = (Brush)bc.ConvertFrom("#FFD62E2E");
                }
                if (textBlock9c.Text.Equals("مصادر للمياه"))
                {
                    note += 0.5; nbCorrect++;
                }
                else
                {
                    textBlock9c.Text       = "مصادر للمياه";
                    textBlock9c.Background = (Brush)bc.ConvertFrom("#FFD62E2E");
                }
                if (textBlock11c.Text.Equals("المجاري المائية"))
                {
                    note += 0.5; nbCorrect++;
                }
                else
                {
                    textBlock11c.Text       = "المجاري المائية";
                    textBlock11c.Background = (Brush)bc.ConvertFrom("#FFD62E2E");
                }
                if (textBlock13c.Text.Equals("المياه الجوفية"))
                {
                    note += 0.5; nbCorrect++;
                }
                else
                {
                    textBlock13c.Text       = "المياه الجوفية";
                    textBlock13c.Background = (Brush)bc.ConvertFrom("#FFD62E2E");
                }

                textBlock9.AllowDrop   = false;
                textBlock11.AllowDrop  = false;
                textBlock13.AllowDrop  = false;
                textBlock9b.AllowDrop  = false;
                textBlock11b.AllowDrop = false;
                textBlock13b.AllowDrop = false;
                textBlock15b.AllowDrop = false;
                textBlock9c.AllowDrop  = false;
                textBlock11c.AllowDrop = false;
                textBlock13c.AllowDrop = false;
                EleveUserControl.Environnement.note = note;
                EleveUserControl.Environnement.note = note;
                if (EleveUserControl.Environnement.eleveConnecte.Statistiques.noteExam1 < note)
                {
                    EleveUserControl.Environnement.eleveConnecte.Statistiques.noteExam1 = note;
                }
                EleveUserControl.Environnement.eleveConnecte.Statistiques.Exam1DejaFait = true;
                Model.Utilities.MettreAJourListeDesEleves(EleveUserControl.Environnement.eleveConnecte);
                button2.Visibility = Visibility.Visible;
                button.Visibility  = Visibility.Hidden;
            }
        }
        private void Tc0SkipButton_MouseLeave(object sender, MouseEventArgs e)
        {
            var bc = new BrushConverter();

            Tc0SkipButton.Background = (Brush)bc.ConvertFrom("#FFBB3D3D");
        }
Пример #17
0
        private void Timer_Tick(object o, EventArgs a)
        {
            textBlock19.Text = _time.Minutes.ToString() + ":" + _time.Seconds.ToString();
            _time            = _time.Add(TimeSpan.FromSeconds(-1));
            if (_time.TotalSeconds.CompareTo(0) == 0)
            {
                button.Click -= button_Click;
                timer.Stop();
                textBlock19.Text = "0:0";
                note             = 0;
                int nbCorrect = 0;
                var bc        = new BrushConverter();
                if (checkBox2.IsChecked == true)
                {
                    note++;
                    nbCorrect++;
                }
                else
                {
                    checkBox2.IsChecked  = true;
                    checkBox.Visibility  = Visibility.Collapsed;
                    checkBox1.Visibility = Visibility.Collapsed;
                }
                if (checkBox1b.IsChecked == true)
                {
                    note++; nbCorrect++;
                }
                else
                {
                    checkBox1b.IsChecked  = true;
                    checkBoxb.Visibility  = Visibility.Collapsed;
                    checkBox2b.Visibility = Visibility.Collapsed;
                }
                if (checkBox2c.IsChecked == true)
                {
                    note++; nbCorrect++;
                }
                else
                {
                    checkBox2c.IsChecked  = true;
                    checkBoxc.Visibility  = Visibility.Collapsed;
                    checkBox1c.Visibility = Visibility.Collapsed;
                }

                ///

                if (checkBoxd.IsChecked == true)
                {
                    note++; nbCorrect++;
                }
                else
                {
                    checkBoxd.IsChecked   = true;
                    checkBox1d.Visibility = Visibility.Collapsed;
                }
                if (checkBoxe.IsChecked == true)
                {
                    note++; nbCorrect++;
                }
                else
                {
                    checkBoxe.IsChecked   = true;
                    checkBox1e.Visibility = Visibility.Collapsed;
                }
                if (checkBox1f.IsChecked == true)
                {
                    note++; nbCorrect++;
                }
                else
                {
                    checkBox1f.IsChecked = true;
                    checkBoxf.Visibility = Visibility.Collapsed;
                }



                ///
                if (textBlock9.Text.Equals("جبال الونشريس") || textBlock9.Text.Equals("جبال تسالا"))
                {
                    note += 0.5; nbCorrect++;
                }
                else
                {
                    textBlock9.Text       = "جبال الونشريس";
                    textBlock9.Background = (Brush)bc.ConvertFrom("#FFD62E2E");
                }
                if (textBlock11.Text.Equals("جبال تسالا") || textBlock11.Text.Equals("جبال الونشريس"))
                {
                    note += 0.5; nbCorrect++;
                }
                else
                {
                    textBlock11.Text       = "جبال تسالا";
                    textBlock11.Background = (Brush)bc.ConvertFrom("#FFD62E2E");
                }
                if (textBlock13.Text.Equals("جبال القصور"))
                {
                    note += 0.5; nbCorrect++;
                }
                else
                {
                    textBlock13.Text       = "جبال القصور";
                    textBlock13.Background = (Brush)bc.ConvertFrom("#FFD62E2E");
                }
                if (textBlock9b.Text.Equals("اعتدال"))
                {
                    note += 0.25; nbCorrect++;
                }
                else
                {
                    textBlock9b.Text       = "اعتدال";
                    textBlock9b.Background = (Brush)bc.ConvertFrom("#FFD62E2E");
                }
                if (textBlock11b.Text.Equals("غزارة الأمطار"))
                {
                    note += 0.25; nbCorrect++;
                }
                else
                {
                    textBlock11b.Text       = "غزارة الأمطار";
                    textBlock11b.Background = (Brush)bc.ConvertFrom("#FFD62E2E");
                }
                if (textBlock13b.Text.Equals("ارتفاع"))
                {
                    note += 0.25; nbCorrect++;
                }
                else
                {
                    textBlock13b.Text       = "ارتفاع";
                    textBlock13b.Background = (Brush)bc.ConvertFrom("#FFD62E2E");
                }
                if (textBlock15b.Text.Equals("قلة الأمطار"))
                {
                    note += 0.25; nbCorrect++;
                }
                else
                {
                    textBlock15b.Text       = "قلة الأمطار";
                    textBlock15b.Background = (Brush)bc.ConvertFrom("#FFD62E2E");
                }
                if (textBlock9c.Text.Equals("مصادر للمياه"))
                {
                    note += 0.5; nbCorrect++;
                }
                else
                {
                    textBlock9c.Text       = "مصادر للمياه";
                    textBlock9c.Background = (Brush)bc.ConvertFrom("#FFD62E2E");
                }
                if (textBlock11c.Text.Equals("المجاري المائية"))
                {
                    note += 0.5; nbCorrect++;
                }
                else
                {
                    textBlock11c.Text       = "المجاري المائية";
                    textBlock11c.Background = (Brush)bc.ConvertFrom("#FFD62E2E");
                }
                if (textBlock13c.Text.Equals("المياه الجوفية"))
                {
                    note += 0.5; nbCorrect++;
                }
                else
                {
                    textBlock13c.Text       = "المياه الجوفية";
                    textBlock13c.Background = (Brush)bc.ConvertFrom("#FFD62E2E");
                }


                textBlock9.AllowDrop   = false;
                textBlock11.AllowDrop  = false;
                textBlock13.AllowDrop  = false;
                textBlock9b.AllowDrop  = false;
                textBlock11b.AllowDrop = false;
                textBlock13b.AllowDrop = false;
                textBlock15b.AllowDrop = false;
                textBlock9c.AllowDrop  = false;
                textBlock11c.AllowDrop = false;
                textBlock13c.AllowDrop = false;
                EleveUserControl.Environnement.note = note;
                if (EleveUserControl.Environnement.eleveConnecte.Statistiques.noteExam1 < note)
                {
                    EleveUserControl.Environnement.eleveConnecte.Statistiques.noteExam1 = note;
                }
                EleveUserControl.Environnement.eleveConnecte.Statistiques.Exam1DejaFait = true;
                Model.Utilities.MettreAJourListeDesEleves(EleveUserControl.Environnement.eleveConnecte);
                button2.Visibility = Visibility.Visible;
                button.Visibility  = Visibility.Hidden;
            }
        }
        private void Step4NextButton_MouseEnter(object sender, MouseEventArgs e)
        {
            var bc = new BrushConverter();

            Step4NextButton.Background = (Brush)bc.ConvertFrom("#818182");
        }
Пример #19
0
        //Нет в 13.2
        //protected override FrameworkElement CreateContent(Type valueType, DataType? dataType)
        protected override FrameworkElement CreateContentAndInitializeUI()
        {
            FrameworkElement result = null;

            if (!string.IsNullOrEmpty(LookUpCode) && LookupType == RclLookupType.None)
            {
                LookupType = RclLookupType.Default;
            }

            switch (LookupType)
            {
            case RclLookupType.Default:
            case RclLookupType.DefaultGrid:
                var customComboBoxEditRcl = new CustomComboBoxEditRcl
                {
                    Name                      = string.Format("{0}_{1}", Name, LookupType),
                    IsWfDesignMode            = IsWfDesignMode,
                    LookupType                = LookupType,
                    LookUpCodeEditorFilterExt =
                        IsWfDesignMode ? WfDesignModeLookUpCodeEditorFilterExt : LookUpFilterExt,
                    LookUpCodeEditor    = LookUpCode,
                    UseFunctionKeys     = UseFunctionKeys,
                    ParentKeyPreview    = ParentKeyPreview,
                    HotKey              = HotKey,
                    CustomDisplayMember = CustomDisplayMember,
                    LookupTitle         = DisplayName
                };
                if (MaxRowsOnPage.HasValue)
                {
                    customComboBoxEditRcl.MaxRowsOnPage = MaxRowsOnPage.Value;
                }
                result = customComboBoxEditRcl;
                break;

            case RclLookupType.SelectControl:
                VerticalAlignment = VerticalAlignment.Stretch;
                var select = new CustomSelectControl
                {
                    LookUpCodeEditorFilterExt =
                        IsWfDesignMode ? WfDesignModeLookUpCodeEditorFilterExt : LookUpFilterExt,
                    LookUpCodeEditor    = LookUpCode,
                    UseFunctionKeys     = UseFunctionKeys,
                    ParentKeyPreview    = ParentKeyPreview,
                    CustomDisplayMember = CustomDisplayMember,
                    ExternalItemsSource = ItemsSource,
                    DisplayMember       = DisplayMember,
                    ValueMember         = ValueMember
                };
                if (MaxRowsOnPage.HasValue)
                {
                    select.MaxRowsOnPage = MaxRowsOnPage.Value;
                }
                if ((CloseDialogOnSelectedItemChanged || CloseDialog) && CloseDialogCommand != null)
                {
                    select.CommandParameter = ValueDataFieldConstants.CreateDefaultParameter(ValueDataFieldConstants.Value);
                    select.Command          = CloseDialogCommand;
                }
                result = select;
                break;

            case RclLookupType.SelectGridControl:
            case RclLookupType.List:
                VerticalAlignment = VerticalAlignment.Stretch;

                //debug
                //if (IsWfDesignMode)
                //    Fields = GetGridFields();
                //

                var customSelectView = new CustomSelectView
                {
                    ItemsSourceType = FieldType,
                    IsWfDesignMode  = IsWfDesignMode,
                    AutoShowAutoFilterRowWhenRowsCountMoreThan = -1,
                    LookUpCodeEditorFilterExt =
                        IsWfDesignMode ? WfDesignModeLookUpCodeEditorFilterExt : LookUpFilterExt,
                    LookUpCodeEditor           = LookUpCode,
                    Source                     = ItemsSource,
                    DisplaySetting             = DisplaySetting.HasValue ? DisplaySetting.Value : SettingDisplay.List,
                    VerifyColumnsSourceChanged = true,
                    ShowSelectMenuItem         = LookupType == RclLookupType.SelectGridControl,
                    MaxRows                    = MaxRows,
                    Fields                     = Fields != null && Fields.Any() ? new ObservableCollection <DataField>(Fields) : null,
                    AllowAutoShowAutoFilterRow = AllowAutoShowAutoFilterRow,
                    DoNotAllowUpdateShowAutoFilterRowFromXml = DoNotAllowUpdateShowAutoFilterRowFromXml,
                    ShowAutoFilterRow     = ShowAutoFilterRow,
                    ShowTotalRow          = ShowTotalRow,
                    DoNotActionOnEnterKey = DoNotActionOnEnterKey,
                    BestFitColumnNames    = BestFitColumnNames,
                    FormatConditions      = FormatConditions
                };

                if (ShowControlMenu.HasValue)
                {
                    customSelectView.ShowMenu = ShowControlMenu.Value;
                }

                if (IsWfDesignMode && string.IsNullOrEmpty(customSelectView.LookUpCodeEditor) &&
                    customSelectView.Source == null && FieldType != null)
                {
                    customSelectView.Source = new[] { Activator.CreateInstance(FieldType) };
                }

                if (FooterMenu != null && FooterMenu.Length > 0)
                {
                    customSelectView.AddFooterMenuItems(FooterMenu, FontSize, IsWfDesignMode);
                }

                if ((CloseDialogOnSelectedItemChanged || CloseDialog) && CloseDialogCommand != null)
                {
                    customSelectView.Command = CloseDialogCommand;
                }

                result = customSelectView;
                break;
            }

            if (IsMemoView)
            {
                result = new MemoEdit
                {
                    ShowIcon = false,
                    //PopupWidth = 250,
                    MemoTextWrapping = TextWrapping.Wrap,
                    MemoVerticalScrollBarVisibility   = ScrollBarVisibility.Hidden,
                    MemoHorizontalScrollBarVisibility = ScrollBarVisibility.Hidden
                };
            }

            if (typeof(IList).IsAssignableFrom(FieldType))
            {
                result = CreateContentSubListView(FieldType);
            }

            if (result == null)
            {
                result = CreateContentInternal();
            }

            if (result == null)
            {
                result = base.CreateContentAndInitializeUI();
                var textEdit = result as TextEdit;
                if (textEdit != null)
                {
                    textEdit.TextWrapping = TextWrapping.Wrap;
                    if (textEdit.TextWrapping == TextWrapping.Wrap)
                    {
                        textEdit.HorizontalContentAlignment = HorizontalAlignment.Left;
                        textEdit.VerticalContentAlignment   = VerticalAlignment.Top;
                    }
                    if (!String.IsNullOrEmpty(BackGroundColor))
                    {
                        var brushconverter = new BrushConverter();
                        ((TextEdit)result).Background = brushconverter.ConvertFromString(BackGroundColor) as Brush;
                    }
                }
            }

            var termilalUi = result as IRclUi;

            if (termilalUi == null)
            {
                //Гридам не навязывать стандартную обработку клавиш.
                if (LookupType != RclLookupType.SelectGridControl && LookupType != RclLookupType.List)
                {
                    if (CloseDialog)
                    {
                        KeyHelper.SetCloseDialogElement(result);
                    }
                    if (IsDoNotMovedFocusOnNextControl)
                    {
                        KeyHelper.SetDoNotMovedFocusOnNextControl(result);
                    }
                    result.PreviewKeyDown += (s, e) => KeyHelper.PreviewKeyDown(result, e);
                }
            }
            else
            {
                termilalUi.IsMovedFocusOnNextControl = !CloseDialog;
            }

            if (IsFocused || SetFocus)
            {
                result.BackgroundFocus();
            }

            if (IsWfDesignMode)
            {
                var themeName = ThemeManager.GetThemeName(this);
                if (string.IsNullOrEmpty(themeName))
                {
                    themeName = StyleKeys.RclDefaultThemeName;
                }
                ThemeManager.SetThemeName(result, themeName);
            }

            return(result);
        }
        private void Step5NextButton_MouseLeave(object sender, MouseEventArgs e)
        {
            var bc = new BrushConverter();

            Step5NextButton.Background = (Brush)bc.ConvertFrom("#FFA9A9AA");
        }
Пример #21
0
        private void updateBits(StringWithNotify sel, string s)
        {
            if (sel == null)
            {
                return;
            }

            string bits    = "";
            string rawbits = "";
            int    temp;

            for (int i = 2; i < s.Length - 2; i += 2)
            {
                if (int.TryParse(s.Substring(i, 3), System.Globalization.NumberStyles.HexNumber, null, out temp))
                {
                    bits    += Convert.ToString(temp, 2).PadLeft(8, '0') /* + " " + Convert.ToString(temp, 16).PadLeft(2, '0').ToUpper() + " " + (char)temp /*+ " " + temp*/ + "\n";
                    rawbits += Convert.ToString(temp, 2).PadLeft(8, '0');
                }
            }

            /*for (int i = 0; i < bits.Length; i += 2)
             * bits = bits.Insert(i, " ");*/

            for (int j = 0; j <= rawbits.Length - 16; j += 8)
            {
                var inside  = double.Parse(rawbits.Substring(j, 8)) * .25;
                var outside = double.Parse(rawbits.Substring(j + 8, 8)) * 0.5 - 40.0;
                if ((inside < 30) && (inside > 10) && (outside > -5) && (outside < 20))
                {
                    bits += "\n" + inside;
                    bits += "\n" + outside;
                }
            }

            BitBox.Inlines.Clear();

            var bc    = new BrushConverter();
            int index = 0;

            for (int i = 0; i < 64; i++)
            {
                if (index >= bits.Length)
                {
                    break;
                }

                if ((bits[index] == '0') || (bits[index] == '1'))
                {
                    BitBox.Inlines.Add(
                        new Run(
                            bits[index].ToString())
                    {
                        Background = sel.colors[i] != 0 ?
                                     (Brush)bc.ConvertFrom
                                         ("#" + Convert.ToString((sel.colors[i] * 8), 16).PadRight(6, 'C')) :
                                     Brushes.White
                    });
                    index++;
                }

                while ((index < bits.Length) && (bits[index] != '0') && (bits[index] != '1'))
                {
                    BitBox.Inlines.Add(
                        new Run(
                            bits[index].ToString()));
                    index++;
                }
            }
            //else
            //  BitBox.Text = bits;

            /*Dispatcher.Invoke(() => {
             * for (int i = 0; i < 8; i++)
             *  MyBindableTwoDArray[i, 0] = rawbits[i];
             * });*/
        }
Пример #22
0
        private void ButtonEdit_Click(object sender, RoutedEventArgs e)
        {
            if ((string)ButtonEdit.Content == "Edit")
            {
                switch (tableName)
                {
                case "Tasks":
                    TextBoxDescription.IsReadOnly = false;
                    TextBoxCategoryID.IsReadOnly  = false;
                    TextBoxUserID.IsReadOnly      = false;
                    TextBoxDescription.Background = Brushes.White;
                    TextBoxCategoryID.Background  = Brushes.White;
                    TextBoxUserID.Background      = Brushes.White;
                    break;

                case "Categories":
                    TextBoxDescription.IsReadOnly = false;
                    TextBoxDescription.Background = Brushes.White;
                    break;

                case "Users":
                    TextBoxDescription.IsReadOnly = false;
                    TextBoxDescription.Background = Brushes.White;
                    break;

                default:
                    break;
                }

                ButtonEdit.Content = "Save";
            }
            else
            {
                BrushConverter brush = new BrushConverter();
                switch (tableName)
                {
                case "Tasks":
                    using (var db = new TasksDBEntities())
                    {
                        var taskToEdit = db.Tasks.Find(task.TaskID);
                        taskToEdit.Description = TextBoxDescription.Text;
                        taskToEdit.CategoryID  = Convert.ToInt32(TextBoxCategoryID.Text);
                        taskToEdit.UserID      = Convert.ToInt32(TextBoxUserID.Text);
                        db.SaveChanges();
                        ListBox.ItemsSource = null;
                        tasks = db.Tasks.ToList();
                        ListBox.ItemsSource = tasks;
                    }
                    TextBoxDescription.IsReadOnly = true;
                    TextBoxCategoryID.IsReadOnly  = true;
                    TextBoxUserID.IsReadOnly      = true;
                    TextBoxDescription.Background = (Brush)brush.ConvertFrom("#E8D79B");
                    TextBoxCategoryID.Background  = (Brush)brush.ConvertFrom("#E8D79B");
                    TextBoxUserID.Background      = (Brush)brush.ConvertFrom("#E8D79B");
                    break;

                case "Categories":
                    using (var db = new TasksDBEntities())
                    {
                        var categoryToEdit = db.Categories.Find(category.CategoryID);
                        categoryToEdit.CategoryName = TextBoxDescription.Text;
                        db.SaveChanges();
                        ListBox.ItemsSource = null;
                        categories          = db.Categories.ToList();
                        ListBox.ItemsSource = categories;
                    }
                    TextBoxDescription.IsReadOnly = true;
                    TextBoxDescription.Background = (Brush)brush.ConvertFrom("#E8D79B");
                    break;

                case "Users":
                    using (var db = new TasksDBEntities())
                    {
                        var userToEdit = db.Users.Find(user.UserID);
                        userToEdit.UserName = TextBoxDescription.Text;
                        db.SaveChanges();
                        ListBox.ItemsSource = null;
                        users = db.Users.ToList();
                        ListBox.ItemsSource = users;
                    }
                    TextBoxDescription.IsReadOnly = true;
                    TextBoxDescription.Background = (Brush)brush.ConvertFrom("#E8D79B");
                    break;

                default:
                    break;
                }
                ButtonEdit.Content = "Edit";
            }
        }
Пример #23
0
        public void AjouterRecette(string imagePlat, int nbEtoiles, string headerText, string descriptionText, int prix, string createur)
        {
            StackPanel main = new StackPanel();

            main.Orientation = Orientation.Horizontal;
            main.Width       = 800;
            main.Height      = 100;
            main.Margin      = new Thickness(0, 10, 0, 10);

            Image plat = new Image();

            plat.Source = new BitmapImage(new Uri(imagePlat));
            plat.Margin = new Thickness(5);

            StackPanel textContainer = new StackPanel();

            textContainer.Orientation = Orientation.Vertical;
            textContainer.Margin      = new Thickness(10);

            TextBlock header = new TextBlock();

            header.Text     = headerText;
            header.FontSize = 30;
            header.Width    = 380;


            TextBlock description = new TextBlock();

            description.Text         = descriptionText + " Recette postée par: " + createur;
            description.FontSize     = 15;
            description.Width        = 380;
            description.TextWrapping = TextWrapping.Wrap;

            Button prixCook = new Button();

            prixCook.Content           = prix + " cook";
            prixCook.VerticalAlignment = VerticalAlignment.Center;
            prixCook.FontSize          = 15;
            prixCook.Margin            = new Thickness(30, 0, 0, 0);
            prixCook.Tag = headerText;
            var converter = new BrushConverter();

            prixCook.Background = (Brush)converter.ConvertFromString("#4AD7D1");
            prixCook.Foreground = (Brush)converter.ConvertFromString("#000000");
            prixCook.Click     += new RoutedEventHandler(AjouterAuPanier_Click);

            StackPanel etoilesContainer = new StackPanel();

            etoilesContainer.Orientation = Orientation.Horizontal;
            etoilesContainer.Margin      = new Thickness(5, 0, 0, 0);


            textContainer.Children.Add(header);


            for (int i = 0; i < nbEtoiles; i++)
            {
                Image etoiles = new Image();
                etoiles.Source = new BitmapImage(new Uri("/Resources/etoile.jpg", UriKind.Relative));
                etoiles.Height = 20;
                etoiles.Width  = 20;
                etoiles.HorizontalAlignment = HorizontalAlignment.Left;
                etoilesContainer.Children.Add(etoiles);
            }
            textContainer.Children.Add(etoilesContainer);
            textContainer.Children.Add(description);

            main.Children.Add(plat);
            main.Children.Add(textContainer);
            main.Children.Add(prixCook);

            RecipiesContainer.Children.Add(main);
        }
Пример #24
0
        private void ButtonAdd_Click(object sender, RoutedEventArgs e)
        {
            if ((string)ButtonAdd.Content == "Add")
            {
                switch (tableName)
                {
                case "Tasks":
                    TextBoxDescription.IsReadOnly = false;
                    TextBoxCategoryID.IsReadOnly  = false;
                    TextBoxUserID.IsReadOnly      = false;
                    TextBoxDescription.Background = Brushes.White;
                    TextBoxCategoryID.Background  = Brushes.White;
                    TextBoxUserID.Background      = Brushes.White;
                    break;

                case "Categories":
                    TextBoxDescription.IsReadOnly = false;
                    TextBoxDescription.Background = Brushes.White;
                    break;

                case "Users":
                    TextBoxDescription.IsReadOnly = false;
                    TextBoxDescription.Background = Brushes.White;
                    break;

                default:
                    break;
                }
                ButtonAdd.Content = "Confirm";
            }
            else
            {
                BrushConverter brush = new BrushConverter();
                switch (tableName)
                {
                case "Tasks":
                    using (var db = new TasksDBEntities())
                    {
                        Task newTask = new Task
                        {
                            Description = TextBoxDescription.Text,
                            CategoryID  = Convert.ToInt32(TextBoxCategoryID.Text)
                        };
                        db.Tasks.Add(newTask);
                        db.SaveChanges();
                        ListBox.ItemsSource = null;
                        tasks = db.Tasks.ToList();
                        ListBox.ItemsSource = tasks;
                    }
                    TextBoxDescription.IsReadOnly = true;
                    TextBoxCategoryID.IsReadOnly  = true;
                    TextBoxUserID.IsReadOnly      = true;
                    TextBoxDescription.Background = (Brush)brush.ConvertFrom("#E8D79B");
                    TextBoxCategoryID.Background  = (Brush)brush.ConvertFrom("#E8D79B");
                    TextBoxUserID.Background      = (Brush)brush.ConvertFrom("#E8D79B");
                    break;

                case "Categories":
                    using (var db = new TasksDBEntities())
                    {
                        Category newCategory = new Category
                        {
                            CategoryName = TextBoxDescription.Text,
                        };
                        db.Categories.Add(newCategory);
                        db.SaveChanges();
                        ListBox.ItemsSource = null;
                        categories          = db.Categories.ToList();
                        ListBox.ItemsSource = categories;
                    }
                    TextBoxDescription.IsReadOnly = true;
                    TextBoxDescription.Background = (Brush)brush.ConvertFrom("#E8D79B");
                    break;

                case "Users":
                    using (var db = new TasksDBEntities())
                    {
                        User newUser = new User
                        {
                            UserName = TextBoxDescription.Text,
                        };
                        db.Users.Add(newUser);
                        db.SaveChanges();
                        ListBox.ItemsSource = null;
                        users = db.Users.ToList();
                        ListBox.ItemsSource = users;
                    }
                    TextBoxDescription.IsReadOnly = true;
                    TextBoxDescription.Background = (Brush)brush.ConvertFrom("#E8D79B");
                    break;

                default:
                    break;
                }
                ButtonAdd.Content = "Add";
            }
        }
Пример #25
0
        internal static Brush String2Brush(string StrColor)
        {
            BrushConverter BrcInstance = new BrushConverter();

            return((Brush)BrcInstance.ConvertFromString(StrColor));
        }
Пример #26
0
        /// <summary>
        /// Notifiers the theme.
        /// </summary>
        public void NotifierTheme(string theme, string titleBG, string titleFG, string contentBG)
        {
            try
            {
                logger.Debug("ThresholdNotiferViewModel : NotifierTheme : Entry");
                logger.Info("ThresholdNotiferViewModel : NotifierTheme : Theme : " + theme);
                logger.Info("ThresholdNotiferViewModel : NotifierTheme : Theme Title Background : " + titleBG);
                logger.Info("ThresholdNotiferViewModel : NotifierTheme : Theme Title Foreground: " + titleFG);
                logger.Info("ThresholdNotiferViewModel : NotifierTheme : Theme Content Background: " + contentBG);

                switch (theme)
                {
                case "Outlook8":
                    TitleBackground   = new SolidColorBrush();
                    TitleBackground   = new BrushConverter().ConvertFromString("#007edf") as SolidColorBrush;
                    BorderBrush       = new SolidColorBrush();
                    BorderBrush       = new BrushConverter().ConvertFromString("#007edf") as SolidColorBrush;
                    TitleColor        = new SolidColorBrush();
                    TitleColor        = new BrushConverter().ConvertFromString("#000000") as SolidColorBrush;
                    ContentBackground = new SolidColorBrush();
                    ContentBackground = new BrushConverter().ConvertFromString("#FFFFFF") as SolidColorBrush;
                    break;

                case "Yahoo":
                    TitleBackground   = new SolidColorBrush();
                    TitleBackground   = new BrushConverter().ConvertFromString("#340481") as SolidColorBrush;
                    BorderBrush       = new SolidColorBrush();
                    BorderBrush       = new BrushConverter().ConvertFromString("#340481") as SolidColorBrush;
                    TitleColor        = new SolidColorBrush();
                    TitleColor        = new BrushConverter().ConvertFromString("#000000") as SolidColorBrush;
                    ContentBackground = new SolidColorBrush();
                    ContentBackground = new BrushConverter().ConvertFromString("#FFFFFF") as SolidColorBrush;
                    break;

                case "Grey":
                    TitleBackground   = new SolidColorBrush();
                    TitleBackground   = new BrushConverter().ConvertFromString("#c6c7c6") as SolidColorBrush;
                    BorderBrush       = new SolidColorBrush();
                    BorderBrush       = new BrushConverter().ConvertFromString("#c6c7c6") as SolidColorBrush;
                    TitleColor        = new SolidColorBrush();
                    TitleColor        = new BrushConverter().ConvertFromString("#000000") as SolidColorBrush;
                    ContentBackground = new SolidColorBrush();
                    ContentBackground = new BrushConverter().ConvertFromString("#FFFFFF") as SolidColorBrush;
                    break;

                case "BB_Theme1":
                    TitleBackground   = new SolidColorBrush();
                    TitleBackground   = new BrushConverter().ConvertFromString("#5C6C7A") as SolidColorBrush;
                    BorderBrush       = new SolidColorBrush();
                    BorderBrush       = new BrushConverter().ConvertFromString("#5C6C7A") as SolidColorBrush;
                    TitleColor        = new SolidColorBrush();
                    TitleColor        = new BrushConverter().ConvertFromString("#FFFFFF") as SolidColorBrush;
                    ContentBackground = new SolidColorBrush();
                    ContentBackground = new BrushConverter().ConvertFromString("#6082B6") as SolidColorBrush;
                    break;

                case "Custom":
                    TitleBackground   = new SolidColorBrush();
                    TitleBackground   = new BrushConverter().ConvertFromString(titleBG) as SolidColorBrush;
                    BorderBrush       = new SolidColorBrush();
                    BorderBrush       = new BrushConverter().ConvertFromString(titleBG) as SolidColorBrush;
                    TitleColor        = new SolidColorBrush();
                    TitleColor        = new BrushConverter().ConvertFromString(titleFG) as SolidColorBrush;
                    ContentBackground = new SolidColorBrush();
                    ContentBackground = new BrushConverter().ConvertFromString(contentBG) as SolidColorBrush;
                    break;

                default:
                    TitleBackground   = new SolidColorBrush();
                    TitleBackground   = new BrushConverter().ConvertFromString("#007edf") as SolidColorBrush;
                    BorderBrush       = new SolidColorBrush();
                    BorderBrush       = new BrushConverter().ConvertFromString("#007edf") as SolidColorBrush;
                    TitleColor        = new SolidColorBrush();
                    TitleColor        = new BrushConverter().ConvertFromString("#000000") as SolidColorBrush;
                    ContentBackground = new SolidColorBrush();
                    ContentBackground = new BrushConverter().ConvertFromString("#FFFFFF") as SolidColorBrush;
                    break;
                }
            }
            catch (Exception ex)
            {
                logger.Error("ThresholdNotiferViewModel : NotifierTheme : " + ex.Message);
            }
            finally
            {
                GC.Collect();
            }

            logger.Debug("ThresholdNotiferViewModel : NotifierTheme : Exit");
        }
Пример #27
0
    public async void web_client_download_completed(object sender, System.ComponentModel.AsyncCompletedEventArgs e)
    {
        if (e.Error == null && check())
        {
            //MessageBox.Show("Success!");
            label_glob.Content     += "  -  DONE";
            form1.uc.statusBox.Text = "waiting for commands";
            int fine_files = Convert.ToInt32(form1.uc.cpbLabel.Content.ToString().Substring(0, form1.uc.cpbLabel.Content.ToString().IndexOf("/")));
            int all_files  = Convert.ToInt32(form1.uc.cpbLabel.Content.ToString().Substring(form1.uc.cpbLabel.Content.ToString().IndexOf("/") + 1));
            fine_files += 1;

            form1.uc.cpbLabel.Content = fine_files + "/" + all_files;
            form1.uc.cpb.Value        = (fine_files * 100) / all_files;

            var brc = new BrushConverter();
            form1.uc.statusEllipse.Fill   = (Brush)brc.ConvertFrom("#FFADFF2F");
            form1.uc.statusEllipse.Stroke = (Brush)brc.ConvertFrom("#FFABADB3");


            PackIcon stopIcon = new PackIcon();
            stopIcon.Kind            = PackIconKind.CheckboxMarkedCircle;
            stopIcon.Width           = 18;
            stopIcon.Height          = 18;
            pgBar_pause_glob.Content = stopIcon;

            pgBar_pause_glob.IsEnabled = false;
            webClient_global.Dispose();
        }
        else if (e.Error == null)
        {
            download_file_async(url_global, path_global, webClient_global, form1);
        }
        else if (e.Cancelled)
        {
            webClient_global.Dispose();

            var brc = new BrushConverter();
            label_glob.Content           += "  -  STOPPED";
            progressBar_glob.Foreground   = (Brush)brc.ConvertFrom("#FF1C0A3C");
            form1.uc.statusBox.Text       = "waiting for commands";
            form1.uc.statusEllipse.Fill   = (Brush)brc.ConvertFrom("#FFADFF2F");
            form1.uc.statusEllipse.Stroke = (Brush)brc.ConvertFrom("#FFABADB3");

            PackIcon stopIcon = new PackIcon();
            stopIcon.Kind              = PackIconKind.Stop;
            stopIcon.Width             = 18;
            stopIcon.Height            = 18;
            pgBar_pause_glob.Content   = stopIcon;
            pgBar_pause_glob.IsEnabled = false;
        }
        else
        {
            webClient_global.Dispose();

            var brc = new BrushConverter();
            label_glob.Content           += "  -  ERROR";
            progressBar_glob.Foreground   = (Brush)brc.ConvertFrom("#FF1C0A3C");
            form1.uc.statusBox.Text       = "waiting for commands";
            form1.uc.statusEllipse.Fill   = (Brush)brc.ConvertFrom("#FFADFF2F");
            form1.uc.statusEllipse.Stroke = (Brush)brc.ConvertFrom("#FFABADB3");

            PackIcon stopIcon = new PackIcon();
            stopIcon.Kind              = PackIconKind.CloseCircleOutline;
            stopIcon.Width             = 18;
            stopIcon.Height            = 18;
            pgBar_pause_glob.Content   = stopIcon;
            pgBar_pause_glob.IsEnabled = false;
            webClient_global.Dispose();

            form1.DockColors("Error");
            form1.uc.showErr = true;
            if (!form1.dialog_atom)
            {
                form1.uc.dialog_atom = true;
                var x = await form1.uc.ShowDialogHost(e.Error.Message);

                form1.uc.dialog_atom = false;
            }
        }
        //((WebClient)sender).Dispose();
    }
Пример #28
0
        private void DrawChromatogram(ChromatographicPeak peak, Canvas canvas)
        {
            if (chargeToColor == null)
            {
                var converter = new BrushConverter();
                chargeToColor = new Dictionary <int, SolidColorBrush>();
                chargeToColor.Add(0, Brushes.Maroon);

                chargeToColor.Add(1, Brushes.DeepPink);
                chargeToColor.Add(2, Brushes.Purple);
                chargeToColor.Add(3, Brushes.Blue);
                chargeToColor.Add(4, Brushes.Green);
                chargeToColor.Add(5, Brushes.Gold);
                chargeToColor.Add(6, Brushes.Orange);
                //chargeToColor.Add(7, Brushes.DarkCyan);
                //chargeToColor.Add(8, Brushes.DimGray);
                //chargeToColor.Add(9, Brushes.Firebrick);
                //chargeToColor.Add(10, Brushes.LimeGreen);

                chargeToColor.Add(int.MinValue, Brushes.Black);
            }

            List <Tuple <double, double> >[] dataPointsForEachCharge = new List <Tuple <double, double> > [peak.isotopicEnvelopes.Max(p => p.charge)];

            double xAxisLowerbound = double.MaxValue;
            double xAxisUpperbound = 0;
            double yAxisLowerbound = 0;
            double yAxisUpperbound = 0;

            for (int zIndex = 0; zIndex < dataPointsForEachCharge.Length; zIndex++)
            {
                int z = zIndex + 1;

                dataPointsForEachCharge[zIndex] = new List <Tuple <double, double> >();
                var g = peak.isotopicEnvelopes.Where(p => p.charge == z).OrderBy(p => p.retentionTime).ToList();

                if (g.Any())
                {
                    double rt = g.Min(p => p.retentionTime);
                    if (rt < xAxisLowerbound)
                    {
                        xAxisLowerbound = rt;
                    }
                    rt = g.Max(p => p.retentionTime);
                    if (rt > xAxisUpperbound)
                    {
                        xAxisUpperbound = rt;
                    }

                    double inten = g.Max(p => p.intensity);
                    if (inten > yAxisUpperbound)
                    {
                        yAxisUpperbound = inten;
                    }
                }

                foreach (var env in g)
                {
                    dataPointsForEachCharge[zIndex].Add(new Tuple <double, double>(env.retentionTime, env.intensity));
                }
            }

            canvas.Children.Clear();

            if (xAxisUpperbound - xAxisLowerbound == 0)
            {
                return;
            }

            double xAxisStep = (xAxisUpperbound - xAxisLowerbound) / 5;
            double yAxisStep = (yAxisUpperbound - yAxisLowerbound) / 5;

            DrawGraphAxes(canvas, xAxisLowerbound, xAxisUpperbound, xAxisStep, yAxisLowerbound, yAxisUpperbound, yAxisStep, 20, "{0:0.00}", "0.0E0");

            int offset = 0;
            // Make some data sets.
            bool observedSomethingYet = false;

            for (int j = 0; j < dataPointsForEachCharge.Length; j++)
            {
                PointCollection points = new PointCollection();

                var dataPoints = dataPointsForEachCharge[j];
                if (dataPoints.Any())
                {
                    observedSomethingYet = true;
                }

                if (observedSomethingYet)
                {
                    for (int i = 0; i < dataPoints.Count; i++)
                    {
                        Point p = new Point(dataPoints[i].Item1, dataPoints[i].Item2);
                        var   transformedPoint = WtoD(p);
                        points.Add(transformedPoint);
                    }

                    Polyline polyline = new Polyline();
                    polyline.StrokeThickness = lineStroke;
                    SolidColorBrush brushColor;
                    if (chargeToColor.TryGetValue(j + 1, out brushColor))
                    {
                    }
                    else
                    {
                        brushColor = chargeToColor[int.MinValue];
                    }

                    polyline.Stroke = brushColor;
                    polyline.Points = points;

                    canvas.Children.Add(polyline);

                    var rectangle = new Rectangle();
                    rectangle.Stroke = brushColor;
                    rectangle.Fill   = brushColor;
                    rectangle.Height = 4;
                    rectangle.Width  = 4;
                    Canvas.SetTop(rectangle, offset + 5);
                    Canvas.SetLeft(rectangle, canvas.ActualWidth - 45);

                    TextBlock textBlock = new TextBlock();
                    textBlock.FontSize = fontSize;
                    textBlock.Text     = "z=" + (j + 1) + "; " + dataPoints.Count;
                    Canvas.SetTop(textBlock, offset + 1);
                    Canvas.SetLeft(textBlock, canvas.ActualWidth - 39);

                    offset += 12;

                    canvas.Children.Add(rectangle);
                    canvas.Children.Add(textBlock);
                }
            }

            TextBlock sbr = new TextBlock();

            sbr.Text = peak.GetSignalToBaseline().ToString("F1");
            Canvas.SetTop(sbr, 0);
            Canvas.SetLeft(sbr, 0);
            canvas.Children.Add(sbr);

            TextBlock peakcount = new TextBlock();

            peakcount.Text = DeconvolutedFeatures.Count.ToString();
            Canvas.SetTop(peakcount, 20);
            Canvas.SetLeft(peakcount, 0);
            canvas.Children.Add(peakcount);
        }
Пример #29
0
        public void CustomizeView(Watch3D model, NodeView nodeView)
        {
            model.ViewModel   = nodeView.ViewModel.DynamoViewModel;
            this.watch3dModel = model;

            var renderingTier = (RenderCapability.Tier >> 16);

            if (renderingTier < 2)
            {
                return;
            }

            View = new Watch3DView(model.GUID, watch3dModel)
            {
                Width  = model.WatchWidth,
                Height = model.WatchHeight
            };

            var pos     = model.CameraPosition;
            var viewDir = model.LookDirection;

            View.View.Camera.Position      = new Point3D(pos.X, pos.Z, -pos.Y);
            View.View.Camera.LookDirection = new Vector3D(viewDir.X, viewDir.Z, -viewDir.Y);

            // When user sizes a watch node, only view gets resized. The actual
            // NodeModel does not get updated. This is where the view updates the
            // model whenever its size is updated.
            //Updated from (Watch3d)View.SizeChanged to nodeView.SizeChanged - height
            // and width should correspond to node model and not watch3Dview
            nodeView.SizeChanged += (sender, args) =>
                                    model.SetSize(args.NewSize.Width, args.NewSize.Height);

            model.RequestUpdateLatestCameraPosition += this.UpdateLatestCameraPosition;

            var mi = new MenuItem {
                Header = "Zoom to Fit"
            };

            mi.Click += mi_Click;

            nodeView.MainContextMenu.Items.Add(mi);

            var backgroundRect = new Rectangle
            {
                HorizontalAlignment = HorizontalAlignment.Stretch,
                VerticalAlignment   = VerticalAlignment.Stretch,
                IsHitTestVisible    = false
            };
            var bc          = new BrushConverter();
            var strokeBrush = (Brush)bc.ConvertFrom("#313131");

            backgroundRect.Stroke          = strokeBrush;
            backgroundRect.StrokeThickness = 1;
            var backgroundBrush = new SolidColorBrush(Color.FromRgb(240, 240, 240));

            backgroundRect.Fill = backgroundBrush;

            nodeView.PresentationGrid.Children.Add(backgroundRect);
            nodeView.PresentationGrid.Children.Add(View);
            nodeView.PresentationGrid.Visibility = Visibility.Visible;

            DataBridge.Instance.RegisterCallback(
                model.GUID.ToString(),
                obj =>
                nodeView.Dispatcher.Invoke(
                    new Action <object>(RenderData),
                    DispatcherPriority.Render,
                    obj));
        }
Пример #30
0
        private void ListViewUsingVIPTable_MouseUp(object sender, MouseButtonEventArgs e)
        {
            if (((ListView)sender).SelectedIndex == -1)
            {
                return;
            }

            if (((ListView)sender).ItemContainerGenerator.ContainerFromIndex(((ListView)sender).SelectedIndex) is ListViewItem lvi)
            {
                ListView ListViewSelected = (ListView)sender;

                var bc = new BrushConverter();

                for (int j = 0; j < UsingVIP4PersonTables.Count; j++)
                {
                    ListViewItem lvi1 = ListViewUsingVIP4PersonTable.ItemContainerGenerator.ContainerFromIndex(j) as ListViewItem;
                    var          cp1  = VisualTreeHelperExtensions.FindVisualChild <ContentPresenter>(lvi1);

                    var dt1         = cp1.ContentTemplate as DataTemplate;
                    var rt1         = (Rectangle)dt1.FindName("BackGround", cp1);
                    var tb1         = (TextBlock)dt1.FindName("NumberTable", cp1);
                    var tbtype1     = (TextBlock)dt1.FindName("TypeTable", cp1);
                    var tbcustomer1 = (TextBlock)dt1.FindName("CustomerName", cp1);

                    rt1.Fill = Brushes.White;
                }

                for (int j = 0; j < UsingVIP8PersonTables.Count; j++)
                {
                    ListViewItem lvi2 = ListViewUsingVIP8PersonTable.ItemContainerGenerator.ContainerFromIndex(j) as ListViewItem;
                    var          cp2  = VisualTreeHelperExtensions.FindVisualChild <ContentPresenter>(lvi2);

                    var dt2 = cp2.ContentTemplate as DataTemplate;
                    var rt2 = (Rectangle)dt2.FindName("BackGround", cp2);
                    var tb2 = (TextBlock)dt2.FindName("NumberTable", cp2);

                    rt2.Fill = Brushes.White;
                }

                for (int j = 0; j < UsingVIP12PersonTables.Count; j++)
                {
                    ListViewItem lvi3 = ListViewUsingVIP12PersonTable.ItemContainerGenerator.ContainerFromIndex(j) as ListViewItem;
                    var          cp3  = VisualTreeHelperExtensions.FindVisualChild <ContentPresenter>(lvi3);

                    var dt3 = cp3.ContentTemplate as DataTemplate;
                    var rt3 = (Rectangle)dt3.FindName("BackGround", cp3);
                    var tb3 = (TextBlock)dt3.FindName("NumberTable", cp3);

                    rt3.Fill = Brushes.White;
                }

                var cp = VisualTreeHelperExtensions.FindVisualChild <ContentPresenter>(lvi);

                var dt = cp.ContentTemplate as DataTemplate;
                var rt = (Rectangle)dt.FindName("BackGround", cp);
                var tb = (TextBlock)dt.FindName("NumberTable", cp);

                if (ListViewSelected.Name == "ListViewUsingVIP4PersonTable")
                {
                    foreach (var item in UsingVIP4PersonTables)
                    {
                        if (item.number == tb.Text)
                        {
                            tableSelected = item;
                            break;
                        }
                    }
                }
                else if (ListViewSelected.Name == "ListViewUsingVIP8PersonTable")
                {
                    foreach (var item in UsingVIP8PersonTables)
                    {
                        if (item.number == tb.Text)
                        {
                            tableSelected = item;
                            break;
                        }
                    }
                }
                else
                {
                    foreach (var item in UsingVIP12PersonTables)
                    {
                        if (item.number == tb.Text)
                        {
                            tableSelected = item;
                            break;
                        }
                    }
                }

                UpdateBillLayout();

                AddFood.IsEnabled             = true;
                BtnPay.IsEnabled              = true;
                DiscountCodeTextBox.IsEnabled = true;

                rt.Fill = (Brush)bc.ConvertFrom("#FF0BD9EE");
            }
        }