예제 #1
0
        private void CopyButton_Click(object sender, EventArgs e)
        {
            InputBoxResult result;

            switch (_options[List.SelectedIndex].Type)
            {
            case "Bar":
                result = InputBox.Show("Copy To:", "Copy Bar Graph", "", BarGraphOptions.ValidateNameHandler);
                if (result.Ok)
                {
                    var o = BarGraphOptions.Load(_options[List.SelectedIndex].Name);
                    o.Save(result.Text);
                }
                break;

            case "Pie":
                result = InputBox.Show("Copy To:", "Copy Pie Graph", "", BarGraphOptions.ValidateNameHandler);
                if (result.Ok)
                {
                    var o = PieGraphOptions.Load(_options[List.SelectedIndex].Name);
                    o.Save(result.Text);
                }
                break;

            default:
                throw new Exception("Unknown Type: " + _options[List.SelectedIndex].Type);
            }
            PopulateList();
        }
예제 #2
0
        private void Populate()
        {
            _options = PieGraphOptions.Load(_optionsName);

            NameLabel.Text = _optionsName;

            HeightInput.Value = _options.Height;
            WidthInput.Value  = _options.Width;

            MarginTop.Value    = _options.MarginTop;
            MarginBottom.Value = _options.MarginBottom;
            MarginLeft.Value   = _options.MarginLeft;
            MarginRight.Value  = _options.MarginRight;

            ChromaKey.BackColor = _options.ChromaKey;
            TransparentBackground.CheckState = _options.TransparentBackground
                ? CheckState.Checked
                : CheckState.Unchecked;
            Option1Color.BackColor = _options.Option1Color;
            Option2Color.BackColor = _options.Option2Color;
            Option3Color.BackColor = _options.Option3Color;
            Option4Color.BackColor = _options.Option4Color;

            _optionLabelFont          = _options.OptionFont;
            OptionFontColor.BackColor = _options.OptionFontColor;

            _countFont = _options.CountFont;
            CountFontColor.BackColor = _options.CountFontColor;

            _totalFont = _options.TitleFont;
            TotalFontColor.BackColor = _options.TitleFontColor;

            TotalPosition.SelectedItem = _options.TotalPosition;
        }
예제 #3
0
        private void ImportButton_Click(object sender, EventArgs e)
        {
            var dialog = new OpenFileDialog
            {
                InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments),
                Filter           = "XBar Files (*.xbar)|*.xbar|XPie Files (*.xpie)|*.xpie",
                Title            = "Import Pie Graph"
            };

            if (dialog.ShowDialog() == DialogResult.OK)
            {
                if (dialog.FileName.EndsWith(".xbar"))
                {
                    BarGraphOptions.Import(dialog.FileName);
                    PopulateList();
                }
                else if (dialog.FileName.EndsWith(".xpie"))
                {
                    PieGraphOptions.Import(dialog.FileName);
                    PopulateList();
                }
                else
                {
                    MessageBox.Show(this, "Invalid File Type", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
예제 #4
0
        private void RenameButton_Click(object sender, EventArgs e)
        {
            InputBoxResult result;

            switch (_options[List.SelectedIndex].Type)
            {
            case "Bar":
                result = InputBox.Show("New Name:", "Rename Bar Graph", "", BarGraphOptions.ValidateNameHandler);
                if (result.Ok)
                {
                    BarGraphOptions.Rename(_options[List.SelectedIndex].Name, result.Text);
                }
                break;

            case "Pie":
                result = InputBox.Show("New Name:", "Rename Pie Graph", "", PieGraphOptions.ValidateNameHandler);
                if (result.Ok)
                {
                    PieGraphOptions.Rename(_options[List.SelectedIndex].Name, result.Text);
                }
                break;

            default:
                throw new Exception("Unknown Type: " + _options[List.SelectedIndex].Type);
            }
            PopulateList();
        }
예제 #5
0
        private void NewPieButton_Click(object sender, EventArgs e)
        {
            var result = InputBox.Show("Name:", "New Pie Graph", "", PieGraphOptions.ValidateNameHandler);

            if (result.Ok)
            {
                //TODO: Add Exception Control
                PieGraphOptions.CreateNew(result.Text);
            }
            PopulateList();
            EditPieGraph(result.Text);
        }
예제 #6
0
        private void ExportButton_Click(object sender, EventArgs e)
        {
            switch (_options[List.SelectedIndex].Type)
            {
            case "Bar":
                BarGraphOptions.Export(_options[List.SelectedIndex].Name);
                break;

            case "Pie":
                PieGraphOptions.Export(_options[List.SelectedIndex].Name);
                break;

            default:
                throw new Exception("Unknown Type: " + _options[List.SelectedIndex].Type);
            }
        }
예제 #7
0
        private void PopulateList()
        {
            var originalIndex = List.SelectedIndex;

            List.Items.Clear();

            //Get Bar Graphs
            var barGraphs = BarGraphOptions.GetAvaliable();

            //Get Pie Graphs - TODO
            var pieGraphs = PieGraphOptions.GetAvaliable();

            _options = new List <SelectListObject>();

            foreach (var n in barGraphs)
            {
                _options.Add(new SelectListObject(n, "Bar"));
                List.Items.Add("Bar - " + n);
            }
            foreach (var n in pieGraphs)
            {
                _options.Add(new SelectListObject(n, "Pie"));
                List.Items.Add("Pie - " + n);
            }


            if (List.Items.Count > 0)
            {
                List.SelectedIndex   = originalIndex < List.Items.Count ? originalIndex : 0;
                StartButton.Enabled  = true;
                EditButton.Enabled   = true;
                DeleteButton.Enabled = true;
                CopyButton.Enabled   = true;
                RenameButton.Enabled = true;
                ExportButton.Enabled = true;
            }
            else
            {
                StartButton.Enabled  = false;
                EditButton.Enabled   = false;
                DeleteButton.Enabled = false;
                CopyButton.Enabled   = false;
                RenameButton.Enabled = false;
                ExportButton.Enabled = false;
            }
        }
예제 #8
0
        private static void CreateDefaultTypes()
        {
            if (BarGraphOptions.GetAvaliable().Count == 0)
            {
                BarGraphOptions.CreateNew("Default");
            }

            if (PieGraphOptions.GetAvaliable().Count == 0)
            {
                PieGraphOptions.CreateNew("Default");
            }

            if (GiveawayOptions.GetAvaliable().Count == 0)
            {
                GiveawayOptions.CreateNew("Default");
            }
        }
예제 #9
0
 private void ReadOptions()
 {
     _options = PieGraphOptions.Load(_optionsName);
 }