示例#1
0
        protected override void OnDrawItem(DrawItemEventArgs e)
        {
            Graphics  grfx      = e.Graphics;
            Rectangle rectColor = new Rectangle(e.Bounds.Left, e.Bounds.Top, 2 * e.Bounds.Height, e.Bounds.Height);

            rectColor.Inflate(-1, -1);

            Rectangle rectText = new Rectangle(e.Bounds.Left + 2 * e.Bounds.Height,
                                               e.Bounds.Top,
                                               e.Bounds.Width - 2 * e.Bounds.Height,
                                               e.Bounds.Height);

            if (this.Enabled)
            {
                e.DrawBackground();
            }

            NamedItem <FontFamily> item           = e.Index >= 0 ? (NamedItem <FontFamily>)Items[e.Index] : new NamedItem <FontFamily>(FontFamily.GenericSansSerif, FontFamily.GenericSansSerif.Name);
            SolidBrush             foreColorBrush = new SolidBrush(e.ForeColor);

            Font font = new Font(item.Item, Font.Size, FontStyle.Regular);


            grfx.DrawString("Abc", font, foreColorBrush, rectColor);

            grfx.DrawString(item.ToString(), Font, foreColorBrush, rectText);
        }
示例#2
0
        private static Type GetServiceType(NamedItem soapBinding, Assembly assembly)
        {
            return((from type in assembly.GetTypes()
                    let bindingAttribute = type.GetCustomAttributes(typeof(WebServiceBindingAttribute), false)
                                           .Cast <WebServiceBindingAttribute>()
                                           .SingleOrDefault()
                                           where bindingAttribute != null && bindingAttribute.Name == soapBinding.Name
                                           select type).FirstOrDefault());

            //var serviceTypes = new List<Type>();

            //// FIXME: Best way to match the service/binding to the implementing type
            ////

            //foreach (var type in assembly.GetTypes())
            //{
            //    var bindingAttributes = type.GetCustomAttributes(typeof (WebServiceBindingAttribute), false);
            //    if (bindingAttributes.Length != 0) serviceTypes.Add(type);
            //}

            //var name = soapBinding.Type.Name;
            //return string.IsNullOrEmpty(name)
            //    ? new Type[0]
            //    : serviceTypes.Where(t => t.Name == name || t.Name.EndsWith(name));
        }
        private FrmWizConfigurationCluster(Core core, Peak current)
            : this()
        {
            this._core = core;

            this._chart = new ChartHelperForPeaks(null, core, this.panel1);

            this._ecbFilter    = DataSet.ForObsFilter(core).CreateComboBox(this._lstFilters, this._btnEditFilters, EditableComboBox.EFlags.IncludeAll);
            this._ecbSource    = DataSet.ForMatrixProviders(core).CreateComboBox(this._lstSource, this._btnSource, EditableComboBox.EFlags.IncludeNone);
            this._ecbSeedPeak  = DataSet.ForPeaks(core).CreateComboBox(this._lstSeedPeak, this._btnSeedPeak, EditableComboBox.EFlags.None);
            this._ecbSeedGroup = DataSet.ForGroups(core).CreateComboBox(this._lstGroups, this._btnGroups, EditableComboBox.EFlags.None);
            this._lstGroups.Items.AddRange(NamedItem.GetRange(core.Groups, z => z.DisplayName).ToArray());
            this._lstGroups.SelectedIndex = 0;

            this._ecbPeakFilter = DataSet.ForPeakFilter(core).CreateComboBox(this._lstPeakFilter, this._btnPeakFilter, EditableComboBox.EFlags.IncludeAll);
            this._ecbDistance   = DataSet.ForMetricAlgorithms(core).CreateComboBox(this._lstDistanceMeasure, this._btnDistanceMeasure, EditableComboBox.EFlags.None);
            this._lstDistanceMeasure.SelectedIndexChanged += this._lstDistanceMeasure_SelectedIndexChanged;

            this._ecbSeedPeak.SelectedItem = current;

            this._wizard                = CtlWizard.BindNew(this, this.tabControl1, CtlWizardOptions.DEFAULT | CtlWizardOptions.DialogResultCancel | CtlWizardOptions.HandleBasicChanges);
            this._wizard.OkClicked     += this.wizard_OkClicked;
            this._wizard.TitleHelpText  = Resx.Manual.DKMeansPlusPlus;
            this._wizard.PermitAdvance += this.ValidatePage;
            this._wizard.Revalidate();
        }
示例#4
0
        void SetDataSource(FontFamily selected)
        {
            this.BeginUpdate();

            Items.Clear();

            foreach (FontFamily ff in FontFamily.Families)
            {
                if (!ff.IsStyleAvailable(FontStyle.Regular))
                {
                    continue;
                }
                if (!ff.IsStyleAvailable(FontStyle.Bold))
                {
                    continue;
                }
                if (!ff.IsStyleAvailable(FontStyle.Italic))
                {
                    continue;
                }

                Items.Add(new NamedItem <FontFamily>(ff, ff.Name));
            }

            SelectedItem = new NamedItem <FontFamily>(selected, selected.Name);

            this.EndUpdate();
        }
示例#5
0
 public Task <bool> Edit(NamedItem request)
 {
     return(Orm.Set <Student>()
            .UpdateAsync(request.ID
                         , o => new Student()
     {
         Name = request.Name
     }));
 }
        private void _btnSelectDiffPeak_Click(object sender, EventArgs e)
        {
            var def = NamedItem <Peak> .Extract(this._lstDiffPeak.SelectedItem);

            var newPeak = DataSet.ForPeaks(this._core).ShowList(this, def);

            if (newPeak != null)
            {
                this._lstDiffPeak.SelectedItem = newPeak;
            }
        }
示例#7
0
        private void ComboBox_DrawItem(object sender, DrawItemEventArgs e)
        {
            e.DrawBackground();
            e.DrawFocusRectangle();

            if (e.Index == -1)
            {
                return;
            }

            NamedItem <object> n = (NamedItem <object>) this.ComboBox.Items[e.Index];

            Image image = UiControls.GetImage(n.Value, false);

            if (!Enabled)
            {
                image = UiControls.DisabledImage(image);
            }

            Color colour = Enabled ? e.ForeColor : Color.FromKnownColor(KnownColor.GrayText);

            if (Enabled && n.Value is SpecialEditItem)
            {
                if (e.State.Has(DrawItemState.ComboBoxEdit))
                {
                    return;
                }

                Rectangle rect;
                const int BUTTON_WIDTH = 64;

                if (e.Bounds.Width > BUTTON_WIDTH)
                {
                    rect = new Rectangle(e.Bounds.Right - BUTTON_WIDTH, e.Bounds.Top, BUTTON_WIDTH, e.Bounds.Height);
                }
                else
                {
                    rect = new Rectangle(e.Bounds.Left, e.Bounds.Top, e.Bounds.Width, e.Bounds.Height);
                }

                ButtonRenderer.DrawButton(e.Graphics, rect, n.Value.ToString(), e.Font, e.State.Has(DrawItemState.Focus), PushButtonState.Normal);
                return;
            }

            int       offset    = e.Bounds.Height / 2 - image.Height / 2;
            Rectangle imageDest = new Rectangle(e.Bounds.Left + offset, e.Bounds.Top + offset, image.Width, image.Height);
            Rectangle imageSrc  = new Rectangle(0, 0, image.Width, image.Height);

            e.Graphics.DrawImage(image, imageDest, imageSrc, GraphicsUnit.Pixel);
            SizeF stringSize = e.Graphics.MeasureString(n.DisplayName, e.Font);

            TextRenderer.DrawText(e.Graphics, n.DisplayName, e.Font, new Point(imageDest.Right + 4, (int)(e.Bounds.Top + e.Bounds.Height / 2 - stringSize.Height / 2)), colour);
        }
 private void AssertUpdate(bool isTP)
 {
     var item = new NamedItem
         ();
     Store(item);
     Commit();
     var firstTS = CommitTimestampFor(item);
     item.SetName("New Name");
     if (!isTP)
     {
         Store(item);
     }
     Commit();
     var secondTS = CommitTimestampFor(item);
     AssertChangesHaveBeenStored(Db());
     Assert.IsTrue(secondTS > firstTS);
 }
        private void AssertUpdate(bool isTP)
        {
            var item = new NamedItem
                           ();

            Store(item);
            Commit();
            var firstTS = CommitTimestampFor(item);

            item.SetName("New Name");
            if (!isTP)
            {
                Store(item);
            }
            Commit();
            var secondTS = CommitTimestampFor(item);

            AssertChangesHaveBeenStored(Db());
            Assert.IsTrue(secondTS > firstTS);
        }
示例#10
0
    void SetDataSource(FontFamily selected)
    {
      this.BeginUpdate();

      Items.Clear();

      foreach (FontFamily ff in FontFamily.Families)
      {
        if (!ff.IsStyleAvailable(FontStyle.Regular))
          continue;
        if (!ff.IsStyleAvailable(FontStyle.Bold))
          continue;
        if (!ff.IsStyleAvailable(FontStyle.Italic))
          continue;

        Items.Add(new NamedItem<FontFamily>(ff,ff.Name));
      }

      SelectedItem = new NamedItem<FontFamily>(selected,selected.Name);

      this.EndUpdate();
    }
示例#11
0
        private void UpdateItemsNoPreserve()
        {
            this.ComboBox.Items.Clear();

            // Null ("all" or "none") item
            if (this._includeNull != ENullItemName.NoNullItem)
            {
                this._none = new NamedItem <object>(ReflectionHelper.GetDefault(this._config.DataType), this._includeNull.ToUiString());
                this.ComboBox.Items.Add(this._none);
            }

            // Regular items
            NamedItem <object>[] source = NamedItem.GetRange <object>(this._config.UntypedGetList(true).Cast <object>(), this._config.UntypedName).ToArray();
            Array.Sort <NamedItem <object> >(source); // For Julie
            this.ComboBox.Items.AddRange(source);

            // Edit button item
            if (_button != null)
            {
                this.ComboBox.Items.Add(new NamedItem <object>(new SpecialEditItem()));
            }
        }
示例#12
0
 public object this[String Name]
 {
     get
     {
         foreach (T Obj in this)
         {
             if (Obj.Name.Equals(Name, StringComparison.OrdinalIgnoreCase))
             {
                 if (Obj is Instance)
                 {
                     NamedItem N = Obj;
                     Instance  I = (Instance)N;
                     return(I.Model);
                 }
                 else
                 {
                     return(Obj);
                 }
             }
         }
         throw new Exception("Cannot find object: " + ParentName + Name);
     }
 }
 private long CommitTimestampFor(NamedItem item)
 {
     return(Db().Ext().GetObjectInfo(item).GetCommitTimestamp());
 }
 private long CommitTimestampFor(NamedItem item)
 {
     return Db().Ext().GetObjectInfo(item).GetCommitTimestamp();
 }
        void wizard_OkClicked(object sender, EventArgs e)
        {
            // Check
            if (!this._wizard.RevalidateAll())
            {
                FrmMsgBox.ShowError(this, "Not all options have been selected.");
                return;
            }

            int    param1_numClusters   = this._radStopN.Checked ? int.Parse(this._txtStopN.Text) : int.MinValue;
            double param2_distanceLimit = this._radStopD.Checked ? double.Parse(this._txtStopD.Text) : double.MinValue;

            Debug.Assert(this._ecbSeedPeak.HasSelection, "Expected a seed peak to be selected");
            WeakReference <Peak> param3_seedPeak  = new WeakReference <Peak>(this._ecbSeedPeak.SelectedItem);
            GroupInfo            param4_seedGroup = NamedItem <GroupInfo> .Extract(this._lstGroups.SelectedItem);

            int             param5_doKMeans = this._radFinishK.Checked ? 1 : 0;
            IMatrixProvider source          = this._ecbSource.SelectedItem;

            object[] parameters = { param1_numClusters, param2_distanceLimit, param3_seedPeak, param4_seedGroup, param5_doKMeans };
            string   name       = "DK";

            // Create a constraint that only allows overlapping timepoints
            HashSet <int>       overlappingPoints = new HashSet <int>();
            var                 fil           = this._ecbFilter.SelectedItem ?? ObsFilter.Empty;
            var                 passed        = fil.Test(source.Provide.Columns.Select(z => z.Observation)).Passed;
            HashSet <GroupInfo> groups        = new HashSet <GroupInfo>(passed.Select(z => z.Group));
            bool                needsExFilter = false;

            foreach (int ctp in this._core.Times)
            {
                bool trueInAny  = false;
                bool falseInAny = false;

                foreach (GroupInfo g in groups)
                {
                    if (passed.Any(z => z.Group == g && z.Time == ctp))
                    {
                        trueInAny = true;
                    }
                    else
                    {
                        falseInAny = true;
                    }
                }

                if (trueInAny && !falseInAny) // i.e. true in all          TT
                {
                    overlappingPoints.Add(ctp);
                }
                else if (trueInAny) // i.e. true in one but not all        TF
                {
                    needsExFilter = true;
                }
                //else if (falseInAny) //  False in all (accptable)        FT
                // else       //     No groups                             FF
            }

            ObsFilter trueFilter;

            if (needsExFilter)
            {
                List <ObsFilter.Condition> conditions = new List <ObsFilter.Condition>
                {
                    new ObsFilter.ConditionFilter(Filter.ELogicOperator.And, false,
                                                  this._ecbFilter.SelectedItem, true),
                    new ObsFilter.ConditionTime(Filter.ELogicOperator.And, false,
                                                Filter.EElementOperator.Is,
                                                overlappingPoints)
                };


                trueFilter = new ObsFilter(null, null, conditions);
                this._core.AddObsFilter(trueFilter);
            }
            else
            {
                trueFilter = this._ecbFilter.SelectedItem;
            }

            ArgsClusterer args = new ArgsClusterer(
                Algo.ID_DKMEANSPPWIZ,
                this._ecbSource.SelectedItem,
                this._ecbPeakFilter.SelectedItem,
                new ConfigurationMetric()
            {
                Args = new ArgsMetric(this._ecbDistance.SelectedItem.Id, this._ecbSource.SelectedItem, this._ecbDistance.SelectedItem.Parameters.StringToParams(this._core, this._txtDistanceParams.Text))
            },
                trueFilter,
                this._chkClusterIndividually.Checked,
                EClustererStatistics.None,
                parameters,
                "DK")
            {
                OverrideDisplayName = name,
                Comment             = "Generated using wizard"
            };

            ConfigurationClusterer config = new ConfigurationClusterer()
            {
                Args = args
            };

            FrmWait.Show(this, "Clustering", null, z => this._core.AddClusterer(config, z));
            this.DialogResult = DialogResult.OK;
        }
示例#16
0
 public Task <bool> Edit(NamedItem request)
 {
     return(StudentService.Edit(request));
 }
示例#17
0
        protected override object MapResult(JObject jsonResult)
        {
            object result;

            switch (ResultType?.Name)
            {
            case "SessionInfo":
                result = SessionInfo.MapFromJson(jsonResult);
                LogResult(result);
                SessionInfo.LastId = ((SessionInfo)result).Id;
                return(result);

            case "Range":
                result = Range.MapFromJson(jsonResult);
                LogResult(result);
                return(result);

            case "Worksheet":
                result = Worksheet.MapFromJson(jsonResult);
                LogResult(result);
                return(result);

            case "Worksheet[]":
                var worksheets = new List <Worksheet>();
                foreach (var jsonWorksheet in jsonResult.GetValue("value"))
                {
                    worksheets.Add(Worksheet.MapFromJson(jsonWorksheet.ToObject <JObject>()));
                }
                LogResult(worksheets);
                return(worksheets.ToArray());

            case "Table":
                result = Table.MapFromJson(jsonResult);
                LogResult(result);
                return(result);

            case "Table[]":
                var tables = new List <Table>();
                foreach (var jsonTable in jsonResult.GetValue("value"))
                {
                    tables.Add(Table.MapFromJson(jsonTable.ToObject <JObject>()));
                }
                LogResult(tables);
                return(tables.ToArray());

            case "TableRow":
                result = TableRow.MapFromJson(jsonResult);
                LogResult(result);
                return(result);

            case "Chart":
                result = Chart.MapFromJson(jsonResult);
                LogResult(result);
                return(result);

            case "Chart[]":
                var charts = new List <Chart>();
                foreach (var jsonChart in jsonResult.GetValue("value"))
                {
                    charts.Add(Chart.MapFromJson(jsonChart.ToObject <JObject>()));
                }
                LogResult(charts);
                return(charts.ToArray());

            case "ChartTitle":
                result = ChartTitle.MapFromJson(jsonResult);
                LogResult(result);
                return(result);

            case "NamedItem":
                result = NamedItem.MapFromJson(jsonResult);
                LogResult(result);
                return(result);

            case "NamedItem[]":
                var namedItems = new List <NamedItem>();
                foreach (var jsonNamedItem in jsonResult.GetValue("value"))
                {
                    namedItems.Add(NamedItem.MapFromJson(jsonNamedItem.ToObject <JObject>()));
                }
                LogResult(namedItems);
                return(namedItems.ToArray());

            default:
                return(base.MapResult(jsonResult));
            }
        }
		public void Read_NamedItems ()
		{
			// foo
			// - bar
			// -- foo
			// - baz
			var obj = new NamedItem ("foo");
			var obj2 = new NamedItem ("bar");
			obj.References.Add (obj2);
			obj.References.Add (new NamedItem ("baz"));
			obj2.References.Add (obj);

			var xr = new XamlObjectReader (obj);
			Read_NamedItems (xr, true);
		}
        public static async Task ReplyWithValue(IDialogContext context, string workbookId, NamedItem namedItem)
        {
            try
            {
                switch (namedItem.Type)
                {
                case "Range":
                    var range = await ServicesHelper.ExcelService.NamedItemRangeAsync(
                        workbookId, namedItem.Name,
                        ExcelHelper.GetSessionIdForRead(context));

                    await ServicesHelper.LogExcelServiceResponse(context);

                    if ((range.RowCount == 1) && (range.ColumnCount == 1))
                    {
                        // Named item points to a single cell
                        if ((string)(range.ValueTypes[0][0]) != "Empty")
                        {
                            await context.PostAsync($"**{namedItem.Name}** is **{range.Text[0][0]}**");
                        }
                        else
                        {
                            await context.PostAsync($"**{namedItem.Name}** is empty");
                        }
                    }
                    else
                    {
                        // Named item points to a range with multiple cells
                        var reply = $"**{namedItem.Name}** has these values:\n\n{GetRangeReply(range)}";
                        await context.PostAsync(reply);
                    }
                    break;

                case "String":
                case "Boolean":
                case "Integer":
                case "Double":
                    await context.PostAsync($"**{namedItem.Name}** is **{namedItem.Value}**");

                    break;

                default:
                    await context.PostAsync($"Sorry, I am not able to determine the value of **{namedItem.Name}** ({namedItem.Type}, {namedItem.Value})");

                    break;
                }
            }
            catch (Exception ex)
            {
                await context.PostAsync($"Sorry, something went wrong getting the value of **{namedItem.Name}** ({ex.Message})");
            }
        }