Example #1
0
        private void btnAddElementsSystray_Click(object sender, RoutedEventArgs e)
        {
            if (lbDisplayListSystray.SelectedItem != null)
            {
                DisplayInfoTypes element = StringToDisplayInfo((string)lbDisplayListSystray.SelectedItem);
                _settings.DisplaySystray.Add(element);

                int index = lbDisplayListSystray.SelectedIndex;
                DisplayInfoListSystray.Remove(element);

                lblDisplayElementSystray.GetBindingExpression(ListBox.ItemsSourceProperty).UpdateTarget();
                lbDisplayListSystray.GetBindingExpression(ListBox.ItemsSourceProperty).UpdateTarget();

                lblDisplayElementSystray.SelectedIndex = lblDisplayElementSystray.Items.Count - 1;

                if (lbDisplayListSystray.Items.Count > 0)
                {
                    if (index < lbDisplayListSystray.Items.Count)
                    {
                        lbDisplayListSystray.SelectedIndex = index;
                    }
                    else
                    {
                        lbDisplayListSystray.SelectedIndex = --index;
                    }
                }
            }
        }
Example #2
0
        private void btnDownElementSystray_Click(object sender, RoutedEventArgs e)
        {
            if (lblDisplayElementSystray.SelectedIndex < lblDisplayElementSystray.Items.Count - 1)
            {
                int index = lblDisplayElementSystray.SelectedIndex;

                DisplayInfoTypes element = _settings.DisplaySystray[index];
                _settings.DisplaySystray.RemoveAt(index);

                index++;

                _settings.DisplaySystray.Insert(index, element);
                lblDisplayElementSystray.GetBindingExpression(ListBox.ItemsSourceProperty).UpdateTarget();
            }
        }
Example #3
0
        private void btnUpElement_Click(object sender, RoutedEventArgs e)
        {
            if (lblDisplayElement.SelectedIndex > 0)
            {
                int index = lblDisplayElement.SelectedIndex;

                DisplayInfoTypes element = _settings.Display[index];
                _settings.Display.RemoveAt(index);

                index--;

                _settings.Display.Insert(index, element);
                lblDisplayElement.GetBindingExpression(ListBox.ItemsSourceProperty).UpdateTarget();
            }
        }
Example #4
0
        public static UIElement Create(DisplayInfoTypes displayInfoTypes, params object[] param)
        {
            StackPanel panel;
            TextBlock label;
            TextBlock data;
            Binding binding;

            switch (displayInfoTypes)
            {
                case DisplayInfoTypes.UsagePeriod:
                    panel = new StackPanel();
                    panel.Orientation = Orientation.Horizontal;

                    label = createLabel("Text.ClientDashboard_lblUsagePeriod");
                    panel.Children.Add(label);

                    data = createDataLabel("Account.PeriodStart", new DateConverter(), "d MMMM");
                    panel.Children.Add(data);

                    data = createDataLabel(null, null, null);

                    binding = new Binding("Text.ClientDashboard_At");
                    binding.Mode = BindingMode.OneTime;
                    binding.Source = ressource;
                    data.SetBinding(TextBlock.TextProperty, binding);
                    data.Margin = new Thickness(4, 0, 4, 0);

                    panel.Children.Add(data);

                    data = createDataLabel("Account.PeriodEnd", new DateConverter(), "d MMMM yyyy");
                    panel.Children.Add(data);

                    return panel;

                case DisplayInfoTypes.Overcharge:
                    panel = new StackPanel();
                    panel.Orientation = Orientation.Horizontal;

                    label = createLabel("Text.ClientDashboard_Overcharge");
                    panel.Children.Add(label);

                    data = createDataLabel("Account.Overcharge", new DoubleConverter(), "C");
                    panel.Children.Add(data);

                    return panel;

                case DisplayInfoTypes.DayRemaining:
                    panel = new StackPanel();
                    panel.Orientation = Orientation.Horizontal;

                    label = createLabel("Text.ClientDashboard_lblDayRemaining");
                    panel.Children.Add(label);

                    data = createDataLabel("Account.DayRemaining", new TimeSpanConverter(), null);
                    panel.Children.Add(data);

                    return panel;

                case DisplayInfoTypes.Upload:
                    panel = new StackPanel();
                    panel.Orientation = Orientation.Horizontal;

                    label = createLabel("Text.ClientDashboard_Upload");
                    panel.Children.Add(label);

                    data = createDataLabel("Account.Upload", new SIUnitStringConverter(), null);
                    panel.Children.Add(data);
                    return panel;

                case DisplayInfoTypes.UploadPercent:
                    panel = new StackPanel();
                    panel.Orientation = Orientation.Horizontal;

                    label = createLabel("Text.ClientDashboard_UploadPercent");
                    panel.Children.Add(label);

                    data = createDataLabel("Account.UploadPercent", new DoubleConverter(), "P");
                    panel.Children.Add(data);
                    return panel;

                case DisplayInfoTypes.Download:
                    panel = new StackPanel();
                    panel.Orientation = Orientation.Horizontal;

                    label = createLabel("Text.ClientDashboard_Download");
                    panel.Children.Add(label);

                    data = createDataLabel("Account.Download", new SIUnitStringConverter(), null);
                    panel.Children.Add(data);
                    return panel;

                case DisplayInfoTypes.DownloadPercent:
                    panel = new StackPanel();
                    panel.Orientation = Orientation.Horizontal;

                    label = createLabel("Text.ClientDashboard_DownloadPercent");
                    panel.Children.Add(label);

                    data = createDataLabel("Account.DownloadPercent", new DoubleConverter(), "P");
                    panel.Children.Add(data);
                    return panel;

                case DisplayInfoTypes.Combined:
                    panel = new StackPanel();
                    panel.Orientation = Orientation.Horizontal;

                    label = createLabel("Text.ClientDashboard_Combined");
                    panel.Children.Add(label);

                    data = createDataLabel("Account.Combined", new SIUnitStringConverter(), null);
                    panel.Children.Add(data);
                    return panel;

                case DisplayInfoTypes.CombinedPercent:
                    panel = new StackPanel();
                    panel.Orientation = Orientation.Horizontal;

                    label = createLabel("Text.ClientDashboard_CombinedPercent");
                    panel.Children.Add(label);

                    data = createDataLabel("Account.CombinedPercent", new DoubleConverter(), "P");
                    panel.Children.Add(data);
                    return panel;

                case DisplayInfoTypes.CombinedOnTotal:
                    panel = new StackPanel();
                    panel.Orientation = Orientation.Horizontal;

                    label = createLabel("Text.ClientDashboard_CombinedOnTotal");
                    panel.Children.Add(label);

                    data = createDataLabel("Account.Combined", new SIUnitStringConverter(), null);
                    panel.Children.Add(data);

                    label = createLabel("Text.On");
                    label.SetResourceReference(TextBlock.StyleProperty, "DynamicData");
                    panel.Children.Add(label);

                    data = createDataLabel("Account.CombinedMaximum", new SIUnitStringConverter(), null);
                    panel.Children.Add(data);

                    return panel;

                case DisplayInfoTypes.AverageCombined:
                   panel = new StackPanel();
                    panel.Orientation = Orientation.Horizontal;

                    label = createLabel("Text.ClientDashboard_AverageCombined");
                    panel.Children.Add(label);

                    data = createDataLabel("Account.AverageCombined", new SIUnitStringConverter(), null);
                    panel.Children.Add(data);
                    return panel;

                case DisplayInfoTypes.SuggestCombined:
                    panel = new StackPanel();
                    panel.Orientation = Orientation.Horizontal;

                    label = createLabel("Text.ClientDashboard_lblSuggestCombined");
                    panel.Children.Add(label);

                    data = createDataLabel("Account.SuggestCombined", new SIUnitStringConverter(), null);
                    panel.Children.Add(data);
                    return panel;
                case DisplayInfoTypes.SuggestCombinedPercent:
                    panel = new StackPanel();
                    panel.Orientation = Orientation.Horizontal;

                    label = createLabel("Text.ClientDashboard_SuggestCombinedPercent");
                    panel.Children.Add(label);

                    data = createDataLabel("Account.SuggestCombinedPercent", new DoubleConverter(), "P");
                    panel.Children.Add(data);

                    return panel;

                case DisplayInfoTypes.EstimateCombined:
                   panel = new StackPanel();
                    panel.Orientation = Orientation.Horizontal;

                    label = createLabel("Text.ClientDashboard_EstimateCombined");
                    panel.Children.Add(label);

                    data = createDataLabel("Account.EstimateCombined", new SIUnitStringConverter(), null);
                    panel.Children.Add(data);
                    return panel;

                case DisplayInfoTypes.EstimateTotalCombined:
                    panel = new StackPanel();
                    panel.Orientation = Orientation.Horizontal;

                    label = createLabel("Text.ClientDashboard_AtThisRate");
                    panel.Children.Add(label);

                    data = createDataLabel("Account.EstimateTotalCombined", new UpDownConverter(), null);
                    panel.Children.Add(data);

                    label = createLabel("Text.ClientDashboard_OfYourLimit");
                    panel.Children.Add(label);

                    return panel;

                case DisplayInfoTypes.TheoryDailyCombined:
                    panel = new StackPanel();
                    panel.Orientation = Orientation.Horizontal;

                    label = createLabel("Text.ClientDashboard_TheoryDailyCombined");
                    panel.Children.Add(label);

                    data = createDataLabel("Account.TheoryDailyCombined", new SIUnitStringConverter(), null);
                    panel.Children.Add(data);
                    return panel;

                case DisplayInfoTypes.TheoryDailyCombinedPercent:
                    panel = new StackPanel();
                    panel.Orientation = Orientation.Horizontal;

                    label = createLabel("Text.ClientDashboard_TheoryDailyCombinedPercent");
                    panel.Children.Add(label);

                    data = createDataLabel("Account.TheoryDailyCombinedPercent", new DoubleConverter(), "P");
                    panel.Children.Add(data);
                    return panel;

                case DisplayInfoTypes.TheoryCombinedDifference:
                    panel = new StackPanel();
                    panel.Orientation = Orientation.Horizontal;

                    label = createLabel("Text.ClientDashboard_TheoryCombinedDifference");
                    panel.Children.Add(label);

                    data = createDataLabel("Account.TheoryCombinedVersusCombined", new SIUnitStringConverter(), null);
                    panel.Children.Add(data);
                    return panel;

                case DisplayInfoTypes.UploadDownloadGraph:
                    return new UploadDownload();

                case DisplayInfoTypes.CombinedGraph:
                    return new Combined();

                case DisplayInfoTypes.HistoryGraph:
                    WindowsFormsHost host = new WindowsFormsHost();
                    host.Name = "zedHost";
                    host.Margin = new Thickness(0, 5, 0, 0);
                    host.Padding = new Thickness(6, 0, 6, 0);
                    host.Height = 230;

                    CIVAccount account = param[0] as CIVAccount;

                    host.Child = new GraphFactory().Generate(account.Account.Username,
                                                            new Period()
                                                            {
                                                                Start = account.Account.PeriodStart,
                                                                End = account.Account.PeriodEnd
                                                            },0,0);

                    return host;
            }
            return new StackPanel();
        }
Example #5
0
        public static UIElement Create(DisplayInfoTypes displayInfoTypes, params object[] param)
        {
            StackPanel panel;
            TextBlock  label;
            TextBlock  data;
            Binding    binding;

            switch (displayInfoTypes)
            {
            case DisplayInfoTypes.UsagePeriod:
                panel             = new StackPanel();
                panel.Orientation = Orientation.Horizontal;

                label = createLabel("Text.ClientDashboard_lblUsagePeriod");
                panel.Children.Add(label);

                data = createDataLabel("Account.PeriodStart", new DateConverter(), "d MMMM");
                panel.Children.Add(data);

                data = createDataLabel(null, null, null);

                binding        = new Binding("Text.ClientDashboard_At");
                binding.Mode   = BindingMode.OneTime;
                binding.Source = ressource;
                data.SetBinding(TextBlock.TextProperty, binding);
                data.Margin = new Thickness(4, 0, 4, 0);

                panel.Children.Add(data);

                data = createDataLabel("Account.PeriodEnd", new DateConverter(), "d MMMM yyyy");
                panel.Children.Add(data);

                return(panel);

            case DisplayInfoTypes.Overcharge:
                panel             = new StackPanel();
                panel.Orientation = Orientation.Horizontal;

                label = createLabel("Text.ClientDashboard_Overcharge");
                panel.Children.Add(label);

                data = createDataLabel("Account.Overcharge", new DoubleConverter(), "C");
                panel.Children.Add(data);

                return(panel);

            case DisplayInfoTypes.DayRemaining:
                panel             = new StackPanel();
                panel.Orientation = Orientation.Horizontal;

                label = createLabel("Text.ClientDashboard_lblDayRemaining");
                panel.Children.Add(label);

                data = createDataLabel("Account.DayRemaining", new TimeSpanConverter(), null);
                panel.Children.Add(data);

                return(panel);

            case DisplayInfoTypes.Upload:
                panel             = new StackPanel();
                panel.Orientation = Orientation.Horizontal;

                label = createLabel("Text.ClientDashboard_Upload");
                panel.Children.Add(label);

                data = createDataLabel("Account.Upload", new SIUnitStringConverter(), null);
                panel.Children.Add(data);
                return(panel);

            case DisplayInfoTypes.UploadPercent:
                panel             = new StackPanel();
                panel.Orientation = Orientation.Horizontal;

                label = createLabel("Text.ClientDashboard_UploadPercent");
                panel.Children.Add(label);

                data = createDataLabel("Account.UploadPercent", new DoubleConverter(), "P");
                panel.Children.Add(data);
                return(panel);

            case DisplayInfoTypes.Download:
                panel             = new StackPanel();
                panel.Orientation = Orientation.Horizontal;

                label = createLabel("Text.ClientDashboard_Download");
                panel.Children.Add(label);

                data = createDataLabel("Account.Download", new SIUnitStringConverter(), null);
                panel.Children.Add(data);
                return(panel);

            case DisplayInfoTypes.DownloadPercent:
                panel             = new StackPanel();
                panel.Orientation = Orientation.Horizontal;

                label = createLabel("Text.ClientDashboard_DownloadPercent");
                panel.Children.Add(label);

                data = createDataLabel("Account.DownloadPercent", new DoubleConverter(), "P");
                panel.Children.Add(data);
                return(panel);

            case DisplayInfoTypes.Combined:
                panel             = new StackPanel();
                panel.Orientation = Orientation.Horizontal;

                label = createLabel("Text.ClientDashboard_Combined");
                panel.Children.Add(label);

                data = createDataLabel("Account.Combined", new SIUnitStringConverter(), null);
                panel.Children.Add(data);
                return(panel);

            case DisplayInfoTypes.CombinedPercent:
                panel             = new StackPanel();
                panel.Orientation = Orientation.Horizontal;

                label = createLabel("Text.ClientDashboard_CombinedPercent");
                panel.Children.Add(label);

                data = createDataLabel("Account.CombinedPercent", new DoubleConverter(), "P");
                panel.Children.Add(data);
                return(panel);

            case DisplayInfoTypes.CombinedOnTotal:
                panel             = new StackPanel();
                panel.Orientation = Orientation.Horizontal;

                label = createLabel("Text.ClientDashboard_CombinedOnTotal");
                panel.Children.Add(label);

                data = createDataLabel("Account.Combined", new SIUnitStringConverter(), null);
                panel.Children.Add(data);

                label = createLabel("Text.On");
                label.SetResourceReference(TextBlock.StyleProperty, "DynamicData");
                panel.Children.Add(label);

                data = createDataLabel("Account.CombinedMaximum", new SIUnitStringConverter(), null);
                panel.Children.Add(data);

                return(panel);

            case DisplayInfoTypes.AverageCombined:
                panel             = new StackPanel();
                panel.Orientation = Orientation.Horizontal;

                label = createLabel("Text.ClientDashboard_AverageCombined");
                panel.Children.Add(label);

                data = createDataLabel("Account.AverageCombined", new SIUnitStringConverter(), null);
                panel.Children.Add(data);
                return(panel);

            case DisplayInfoTypes.SuggestCombined:
                panel             = new StackPanel();
                panel.Orientation = Orientation.Horizontal;

                label = createLabel("Text.ClientDashboard_lblSuggestCombined");
                panel.Children.Add(label);

                data = createDataLabel("Account.SuggestCombined", new SIUnitStringConverter(), null);
                panel.Children.Add(data);
                return(panel);

            case DisplayInfoTypes.SuggestCombinedPercent:
                panel             = new StackPanel();
                panel.Orientation = Orientation.Horizontal;

                label = createLabel("Text.ClientDashboard_SuggestCombinedPercent");
                panel.Children.Add(label);

                data = createDataLabel("Account.SuggestCombinedPercent", new DoubleConverter(), "P");
                panel.Children.Add(data);

                return(panel);

            case DisplayInfoTypes.EstimateCombined:
                panel             = new StackPanel();
                panel.Orientation = Orientation.Horizontal;

                label = createLabel("Text.ClientDashboard_EstimateCombined");
                panel.Children.Add(label);

                data = createDataLabel("Account.EstimateCombined", new SIUnitStringConverter(), null);
                panel.Children.Add(data);
                return(panel);

            case DisplayInfoTypes.EstimateTotalCombined:
                panel             = new StackPanel();
                panel.Orientation = Orientation.Horizontal;

                label = createLabel("Text.ClientDashboard_AtThisRate");
                panel.Children.Add(label);

                data = createDataLabel("Account.EstimateTotalCombined", new UpDownConverter(), null);
                panel.Children.Add(data);

                label = createLabel("Text.ClientDashboard_OfYourLimit");
                panel.Children.Add(label);

                return(panel);

            case DisplayInfoTypes.TheoryDailyCombined:
                panel             = new StackPanel();
                panel.Orientation = Orientation.Horizontal;

                label = createLabel("Text.ClientDashboard_TheoryDailyCombined");
                panel.Children.Add(label);

                data = createDataLabel("Account.TheoryDailyCombined", new SIUnitStringConverter(), null);
                panel.Children.Add(data);
                return(panel);

            case DisplayInfoTypes.TheoryDailyCombinedPercent:
                panel             = new StackPanel();
                panel.Orientation = Orientation.Horizontal;

                label = createLabel("Text.ClientDashboard_TheoryDailyCombinedPercent");
                panel.Children.Add(label);

                data = createDataLabel("Account.TheoryDailyCombinedPercent", new DoubleConverter(), "P");
                panel.Children.Add(data);
                return(panel);

            case DisplayInfoTypes.TheoryCombinedDifference:
                panel             = new StackPanel();
                panel.Orientation = Orientation.Horizontal;

                label = createLabel("Text.ClientDashboard_TheoryCombinedDifference");
                panel.Children.Add(label);

                data = createDataLabel("Account.TheoryCombinedVersusCombined", new SIUnitStringConverter(), null);
                panel.Children.Add(data);
                return(panel);

            case DisplayInfoTypes.UploadDownloadGraph:
                return(new UploadDownload());

            case DisplayInfoTypes.CombinedGraph:
                return(new Combined());

            case DisplayInfoTypes.HistoryGraph:
                WindowsFormsHost host = new WindowsFormsHost();
                host.Name    = "zedHost";
                host.Margin  = new Thickness(0, 5, 0, 0);
                host.Padding = new Thickness(6, 0, 6, 0);
                host.Height  = 230;

                CIVAccount account = param[0] as CIVAccount;

                host.Child = new GraphFactory().Generate(account.Account.Username,
                                                         new Period()
                {
                    Start = account.Account.PeriodStart,
                    End   = account.Account.PeriodEnd
                }, 0, 0);

                return(host);
            }
            return(new StackPanel());
        }