示例#1
0
        static void Main(string[] args)
        {
            Workspace w = new Workspace("workspaceTest");

            TodoTask t1 = new TodoTask("Task 1");

            t1.Description = "This is a description of the first Task.";

            TodoTask t2 = new TodoTask("Task 2");

            t2.Description = "Yet another task.";

            w[0].Label = "First Lane";
            w[0].Add(t1);
            w[0].Add(t2);

            w.Add(new Lane("Second Lane"));
            TodoTask t3 = new TodoTask("Task 3");

            t3.Description = "This task is in another Lane.";

            w[1].Add(t3);

            //w.MoveLane(w[1], HorizontalDirection.LEFT);
            w.MoveTask(w[0][0], VerticalDirection.DOWN);
            WorkspaceManager.SaveWorkspace(w, @"C:\tmp\testworkspace.json");
        }
        public void Initialize(ITestResources resources)
        {
            InitializeTests();

            sceneStack = resources.SceneStack;

            font = new Font(resources.Fonts.Default);
            var fontProvider = resources.Fonts;

            scene = new UserInterfaceScene(
                resources.GraphicsDevice,
                resources.UserInterfaceRenderer,
                resources.LocalizedContent,
                resources.StyleConfigurator);

            spriteBatch = new SpriteBatch(resources.GraphicsDevice);

            var menu = new Menu();

            foreach (var test in tests)
            {
                menu.Add(test.Name, () => StartTest?.Invoke(this, new TestEventArgs(test)));
            }

            var workspace = new Workspace("default");

            workspace.Add(menu);

            scene.Desktop.PushWorkspace(workspace);

            sceneStack.Add(scene);
        }
        private void OnAddPortion(string value)
        {
            var portion = MenuItem.AddDefaultMenuPortion(Model);

            Portions.Add(new PortionViewModel(portion));
            Workspace.Add(portion);
        }
        public ProgramSetting GetSetting(string valueName)
        {
            var setting = Workspace.Single <ProgramSettingValue>(x => x.Name == valueName);

            if (_settingCache.ContainsKey(valueName))
            {
                if (setting == null)
                {
                    setting = _settingCache[valueName];
                }
                else
                {
                    _settingCache.Remove(valueName);
                }
            }
            if (setting == null)
            {
                setting = new ProgramSettingValue {
                    Name = valueName
                };
                _settingCache.Add(valueName, setting);
                Workspace.Add(setting);
            }
            return(new ProgramSetting(setting));
        }
        public override bool Execute(DotSpatial.Data.ICancelProgressHandler cancelProgressHandler)
        {
            StreamReader sr   = new StreamReader(DataFileName);
            var          line = sr.ReadLine();

            line = sr.ReadLine();
            var buf       = TypeConverterEx.Split <string>(line);
            int ncell     = int.Parse(buf[1]);
            int nvar      = int.Parse(buf[3]);
            var variables = new string[nvar + 2];

            variables[0] = "x";
            variables[1] = "y";
            for (int i = 0; i < nvar; i++)
            {
                variables[i + 2] = buf[4 + i];
            }
            var mat_out = new DataCube <float>(nvar + 2, 1, ncell);

            mat_out.Name      = OutputDataCube;
            mat_out.Variables = variables;
            for (int i = 0; i < ncell; i++)
            {
                line = sr.ReadLine().Trim();
                var vec = TypeConverterEx.Split <float>(line);
                for (int j = 0; j < nvar + 2; j++)
                {
                    mat_out[j, 0, i] = vec[j];
                }
            }
            sr.Close();
            Workspace.Add(mat_out);
            cancelProgressHandler.Progress("Package_Tool", 100, "Finished");
            return(true);
        }
示例#6
0
        public void Collections_AddNonNullItem_Success()
        {
            Collection <ResourceCollectionInfo> collection = new Workspace().Collections;

            collection.Add(new ResourceCollectionInfo());
            Assert.Equal(1, collection.Count);
        }
示例#7
0
 public void CurrentLayerStillSetAfterDrawingToOtherLayerTest()
 {
     Workspace.AddLayer("Other");
     Workspace.SetCurrentLayer("Other");
     Workspace.Add(Workspace.GetLayer("0"), Line());
     Assert.Equal(1, Workspace.GetLayer("0").EntityCount);
     Assert.Equal(Workspace.GetLayer("Other"), Workspace.Drawing.CurrentLayer);
 }
示例#8
0
        private void InitializeMagicMenu(Workspace workspace)
        {
            magicList = new Menu("Magic");

            magicList.Exit += () => desktop.PopWorkspace();

            workspace.Add(magicList);
        }
示例#9
0
        public ProjectViewModel(FolderViewModel parent, DirectoryInfo dir)
            : base(parent, dir)
        {
            var tuple = Workspace.Add(this);

            _id      = tuple.Item1;
            _project = tuple.Item2;
        }
示例#10
0
        public void Collections_SetNullItem_ThrowsArgumentNullException()
        {
            Collection <ResourceCollectionInfo> collection = new Workspace().Collections;

            collection.Add(new ResourceCollectionInfo());

            AssertExtensions.Throws <ArgumentNullException>("item", () => collection[0] = null);
        }
        public void Add_GivenAction_AddsActionToActions()
        {
            var test = new Workspace();

            var stubAction = new Mock <IAction>();

            test.Add(stubAction.Object);

            Assert.Contains(stubAction.Object, test.Actions);
        }
示例#12
0
        public void Collections_SetNonNullItem_GetReturnsExpected()
        {
            Collection <ResourceCollectionInfo> collection = new Workspace().Collections;

            collection.Add(new ResourceCollectionInfo());

            var newValue = new ResourceCollectionInfo();

            collection[0] = newValue;
            Assert.Same(newValue, collection[0]);
        }
示例#13
0
        private void UpdateWorkspace(WorkspaceDefinition definition, bool resetSettings, SortDirection sortDirection, OrderBy orderBy, Serializer serializer)
        {
            Settings settings;
            var      workspaceFilePath = Path.Combine(_options.WorkspacePath, definition.FileName);

            if (resetSettings)
            {
                settings = new Settings();
            }
            else
            {
                var currentWorkspace = serializer.DeserializeFromJson <Workspace>(workspaceFilePath);
                settings = currentWorkspace.Settings;
            }

            IEnumerable <Snippet> filtered = _snippets.ToList();

            if (definition.Languages.Any())
            {
                filtered = filtered.Where(x => x.Files.Any(f => definition.Languages.Contains(_fileAssociations.Lookup(f))));
            }

            if (definition.Tags.Any())
            {
                filtered = filtered.Where(x => x.Meta.Tags.Any(t => definition.Tags.Contains(t)));
            }

            if (!filtered.Any())
            {
                File.Delete(workspaceFilePath);
                return;
            }

            var ascending = sortDirection == SortDirection.Ascending;
            var ordered   = orderBy switch
            {
                OrderBy.Alphabetical => ascending?filtered.OrderBy(x => x.Meta.Title) : filtered.OrderByDescending(x => x.Meta.Title),
                    OrderBy.Created => ascending?filtered.OrderBy(x => x.Meta.CreatedUtc) : filtered.OrderByDescending(x => x.Meta.CreatedUtc),
                        _ => throw new NotSupportedException($"Unable to sort by {nameof(orderBy)}")
            };

            var workspace = new Workspace {
                Settings = settings
            };

            foreach (var snippet in ordered)
            {
                var folder = new Folder(snippet.Meta.Title, Path.GetRelativePath(_options.WorkspacePath, snippet.DirectoryPath));
                workspace.Add(folder);
            }

            serializer.SerializeToJson(workspace, workspaceFilePath);
        }
示例#14
0
        public override bool Execute(DotSpatial.Data.ICancelProgressHandler cancelProgressHandler)
        {
            StreamReader sr   = new StreamReader(DataFileName);
            string       line = sr.ReadLine();

            line = sr.ReadLine();
            var buf      = TypeConverterEx.Split <string>(line.Trim());
            int ncell    = int.Parse(buf[1]);
            var var_name = buf[0];

            line = sr.ReadLine();
            int nstep    = 0;
            int progress = 0;
            int count    = 1;

            while (!sr.EndOfStream)
            {
                line = sr.ReadLine();
                if (!TypeConverterEx.IsNull(line))
                {
                    nstep++;
                }
            }
            sr.Close();

            var mat_out = new DataCube <float>(1, nstep, ncell);

            mat_out.Name      = OutputMatrix;
            mat_out.Variables = new string[] { var_name };
            sr = new StreamReader(DataFileName);
            mat_out.DateTimes = new DateTime[nstep];
            for (int i = 0; i < 3; i++)
            {
                sr.ReadLine();
            }

            for (int t = 0; t < nstep; t++)
            {
                line = sr.ReadLine();
                var vec = TypeConverterEx.SkipSplit <float>(line, 6);
                mat_out[0, t.ToString(), ":"] = vec;
                var dd = TypeConverterEx.Split <int>(line, 3);
                mat_out.DateTimes [t] = new DateTime(dd[0], dd[1], dd[2]);
                progress = t * 100 / nstep;
                if (progress > count)
                {
                    cancelProgressHandler.Progress("Package_Tool", progress, "Processing step:" + (t + 1));
                    count++;
                }
            }
            Workspace.Add(mat_out);
            return(true);
        }
        public void CanCreateCashAccount()
        {
            var accountType = AccountTypeBuilder.Create("Payment Accounts").Build();

            Workspace.Add(accountType);
            var account = AccountBuilder.Create("Cash").WithAccountType(accountType).Build();

            Workspace.Add(account);
            Workspace.CommitChanges();
            var balance = AccountService.GetAccountBalance(account.Id);

            Assert.AreEqual(0, balance);
        }
示例#16
0
        public override bool Execute(DotSpatial.Data.ICancelProgressHandler cancelProgressHandler)
        {
            var mat  = Get3DMat(InputDataCube);
            var dims = GetDims(InputDataCube);

            if (mat != null)
            {
                int nvar  = mat.Size[0];
                int ntime = mat.Size[1];
                DataCube <float> mean_mat = null;
                if (dims[0] == ":")
                {
                    mean_mat = new DataCube <float>(nvar, ntime, 1);
                    for (int i = 0; i < nvar; i++)
                    {
                        if (mat.ILArrays[i] != null)
                        {
                            for (int j = 0; j < ntime; j++)
                            {
                                var vec = mat.GetVector(i, j.ToString(), ":");
                                var av  = vec.Average();
                                mean_mat[i, j, 0] = av * Multiplier;
                            }
                        }
                    }
                }
                else
                {
                    mean_mat = new DataCube <float>(1, ntime, 1);
                    int var_index = int.Parse(dims[0]);
                    if (mat.ILArrays[var_index] != null)
                    {
                        for (int j = 0; j < ntime; j++)
                        {
                            var vec = mat.GetVector(var_index, j.ToString(), ":");
                            var av  = vec.Average();
                            mean_mat[0, j, 0] = av * Multiplier;
                        }
                    }
                }

                mean_mat.Name          = OutputDataCube;
                mean_mat.TimeBrowsable = true;
                Workspace.Add(mean_mat);
                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#17
0
        public override bool Execute(DotSpatial.Data.ICancelProgressHandler cancelProgressHandler)
        {
            IFeatureSet fs = null;

            if (!TypeConverterEx.IsNull(PointFeatureFileName) && File.Exists(PointFeatureFileName))
            {
                fs = FeatureSet.Open(PointFeatureFileName);
            }
            if (fs != null)
            {
                var          npt      = fs.NumRows();
                Coordinate[] coors    = new Coordinate[npt];
                int          progress = 0;
                for (int i = 0; i < npt; i++)
                {
                    var geo_pt = fs.GetFeature(i).Geometry;
                    coors[i] = geo_pt.Coordinate;
                }
                var time     = _TimeVariable.GetData() as float[];
                var xx       = _XVariable.GetData() as float[];
                var yy       = _YVariable.GetData() as float[];
                var nc_array = _SelectedVariable.GetData() as float[, , ];
                int nstep    = time.Count();
                var mat_out  = new DataCube <float>(1, time.Length, npt);
                mat_out.Name      = OutputMatrix;
                mat_out.Variables = new string[] { _SelectedVariableName };
                mat_out.DateTimes = new DateTime[nstep];

                var pt_index = GetIndex(xx, yy, coors);
                for (int t = 0; t < nstep; t++)
                {
                    for (int i = 0; i < npt; i++)
                    {
                        mat_out[0, t, i] = nc_array[t, pt_index[i][1], pt_index[i][0]];
                    }
                    progress = t * 100 / nstep;
                    cancelProgressHandler.Progress("Package_Tool", progress, "Processing time step:" + t);

                    mat_out.DateTimes[t] = DateTime.FromOADate(time[t]);
                }

                Workspace.Add(mat_out);
                return(true);
            }
            else
            {
                cancelProgressHandler.Progress("Package_Tool", 50, "Failed to run. The input parameters are incorrect.");
                return(false);
            }
        }
示例#18
0
        public void Test_addElement_ThrowsAnException_WhenTheSpecifiedElementDoesNotExistInTheModel()
        {
            try
            {
                Workspace      workspace      = new Workspace("1", "");
                SoftwareSystem softwareSystem = workspace.Model.AddSoftwareSystem("Software System");

                SystemLandscapeView view = new Workspace("", "").Views.CreateSystemLandscapeView("key", "Description");
                view.Add(softwareSystem);
                throw new TestFailedException();
            }
            catch (ArgumentException ae)
            {
                Assert.Equal("The element named Software System does not exist in the model associated with this view.", ae.Message);
            }
        }
        private void btn_open_dcx_Click(object sender, EventArgs e)
        {
            OpenFileDialog dlg = new OpenFileDialog();

            dlg.Filter = "data cube file|*.dcx";
            if (dlg.ShowDialog() == DialogResult.OK)
            {
                System.Windows.Forms.Cursor.Current = Cursors.WaitCursor;
                DataCubeStreamReader asx = new DataCubeStreamReader(dlg.FileName);
                asx.LoadDataCube();
                var mat = asx.DataCube;
                mat.Name = Path.GetFileNameWithoutExtension(dlg.FileName);
                Workspace.Add(mat);
                System.Windows.Forms.Cursor.Current = Cursors.Default;
            }
        }
示例#20
0
        public override bool Execute(DotSpatial.Data.ICancelProgressHandler cancelProgressHandler)
        {
            cancelProgressHandler.Progress("Package_Tool", 10, "Begin to calculate");
            PenmanMonteithET pet = new PenmanMonteithET();
            StreamReader     sr  = new StreamReader(InputDataFile);
            List <float>     et0 = new List <float>();
            int nrow             = 0;

            sr = new StreamReader(InputDataFile);
            List <DateTime> dates = new List <DateTime>();
            List <float[]>  meto  = new List <float[]>();
            List <float>    tav   = new List <float>();

            while (!sr.EndOfStream)
            {
                var line = sr.ReadLine();
                if (!TypeConverterEx.IsNull(line))
                {
                    var strs = TypeConverterEx.Split <string>(line);
                    var date = DateTime.Parse(strs[0]);
                    var vv   = TypeConverterEx.SkipSplit <float>(line, 1);
                    dates.Add(date);
                    meto.Add(vv);
                    tav.Add(vv[0]);
                    nrow++;
                }
            }
            sr.Close();

            var ts      = new DataCube <float>(tav.ToArray(), dates.ToArray());
            var tav_mon = TimeSeriesAnalyzer.GetMonthlyMean(ts, NumericalDataType.Average);

            pet.MonthTemperature = Array.ConvertAll(tav_mon, x => (double)x);
            for (int i = 0; i < nrow; i++)
            {
                var vv = meto[i];
                et0.Add((float)pet.ET0(Latitude, Longitude, vv[0], vv[1], vv[2], vv[3], vv[4], vv[5], dates[i], CloudCover));
            }
            DataCube <float> mat_out = new DataCube <float>(1, 1, et0.Count);

            mat_out[0, "0", ":"] = et0.ToArray();
            mat_out.Name         = PET;
            cancelProgressHandler.Progress("Package_Tool", 100, "Calculated");
            Workspace.Add(mat_out);
            return(true);
        }
示例#21
0
        private void OnBatchCreateItems(TModel obj)
        {
            var title       = string.Format(Resources.BatchCreate_f, PluralModelTitle);
            var description = string.Format(Resources.BatchCreateInfo_f, PluralModelTitle);
            var data        = InteractionService.UserIntraction.GetStringFromUser(title, description);

            if (data.Length > 0)
            {
                var items = ((IEntityCreator <TModel>)InternalCreateNewViewModel(new TModel())).CreateItems(data);
                foreach (var item in items)
                {
                    Workspace.Add(item);
                }
                Workspace.CommitChanges();
                _items = null;
                RaisePropertyChanged(() => Items);
            }
        }
示例#22
0
        public override bool Execute(DotSpatial.Data.ICancelProgressHandler cancelProgressHandler)
        {
            int    var_indexA = 0;
            int    var_indexB = 0;
            var    matA       = Get3DMat(MatrixA, ref var_indexA);
            var    matB       = Get3DMat(MatrixB, ref var_indexB);
            double prg        = 0;

            if (matA != null && matB != null)
            {
                int nstep   = System.Math.Min(matA.Size[1], matB.Size[1]);
                int ncell   = matA.Size[2];
                var mat_out = new DataCube <float>(1, 1, ncell);
                mat_out.Name      = OutputMatrix;
                mat_out.Variables = new string[] { "CorrelationCoefficients" };
                for (int c = 0; c < ncell; c++)
                {
                    var vecA     = matA.GetVector(var_indexA, ":", c.ToString());
                    var dou_vecA = MatrixOperation.ToDouble(vecA);
                    var vecB     = matB.GetVector(var_indexB, ":", c.ToString());;
                    var dou_vecB = MatrixOperation.ToDouble(vecB);
                    var len      = System.Math.Min(vecA.Length, vecB.Length);
                    //   var cor = MyStatisticsMath.Correlation(dou_vecA, dou_vecB);
                    var cor = Heiflow.Core.Alglib.alglib.basestat.pearsoncorrelation(dou_vecA, dou_vecB, len);
                    if (double.IsNaN(cor) || double.IsInfinity(cor))
                    {
                        cor = 0;
                    }
                    mat_out[0, 0, c] = (float)cor;
                    prg = (c + 1) * 100.0 / ncell;
                    if (prg % 10 == 0)
                    {
                        cancelProgressHandler.Progress("Package_Tool", (int)prg, "Caculating Cell: " + (c + 1));
                    }
                }
                Workspace.Add(mat_out);
                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#23
0
        public override bool Execute(DotSpatial.Data.ICancelProgressHandler cancelProgressHandler)
        {
            int    var_indexA = 0;
            var    matA       = Get3DMat(InputDataCube, ref var_indexA);
            double prg        = 0;
            int    count      = 1;

            if (matA != null)
            {
                int nstep = matA.Size[1];
                int ncell = matA.Size[2];

                var mat_out = new DataCube <float>(1, 1, ncell);
                mat_out.Name      = OutputDataCube;
                mat_out.Variables = new string[] { "Slope" };

                for (int c = 0; c < ncell; c++)
                {
                    var    vec = matA.GetVector(var_indexA, ":", c.ToString());
                    var    dou_vec = MatrixOperation.ToDouble(vec);
                    var    steps = new double[nstep];
                    double rs, slope, yint;
                    for (int t = 1; t < nstep; t++)
                    {
                        steps[t] = t + 1;
                    }
                    MyStatisticsMath.LinearRegression(steps, dou_vec, 0, nstep, out rs, out yint, out slope);
                    mat_out[0, 0, c] = (float)slope;
                    prg = (c + 1) * 100.0 / ncell;
                    if (prg > count)
                    {
                        cancelProgressHandler.Progress("Package_Tool", (int)prg, "Caculating Cell: " + (c + 1));
                        count++;
                    }
                }
                Workspace.Add(mat_out);
                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#24
0
        public override bool Execute(DotSpatial.Data.ICancelProgressHandler cancelProgressHandler)
        {
            var da = GetVector(DataCubeA);
            var db = GetVector(DataCubeB);

            if (da != null && db != null && da.Length == db.Length)
            {
                var vec = new DataCube <float>(1, 1, da.Length);
                for (int i = 0; i < da.Length; i++)
                {
                    vec[0, 0, i] = da[i] + db[i];
                }
                vec.Name = OutputDataCube;
                Workspace.Add(vec);
                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#25
0
        public override bool Execute(DotSpatial.Data.ICancelProgressHandler cancelProgressHandler)
        {
            var vec_minu = GetVector(MinuendDataCube);
            var vec_subt = GetVector(SubtrahendDataCube);

            if (vec_minu != null && vec_subt != null && vec_minu.Length == vec_subt.Length)
            {
                var vec = new DataCube <float>(1, 1, vec_minu.Length);
                for (int i = 0; i < vec_minu.Length; i++)
                {
                    vec[0, 0, i] = vec_minu[i] - vec_subt[i];
                }
                vec.Name = OutputDataCube;
                Workspace.Add(vec);
                return(true);
            }
            else
            {
                return(false);
            }
        }
        public void CanSearchEntities()
        {
            var customer1 = new Entity {
                Name = "Emre Eren", EntityTypeId = CustomerEntityType.Id
            };

            customer1.SetCustomData("Phone", "1111111");
            Assert.AreEqual("1111111", customer1.GetCustomData("Phone"));
            Workspace.Add(customer1);

            var customer2 = new Entity {
                Name = "Hasan Bulut", EntityTypeId = CustomerEntityType.Id
            };

            customer2.SetCustomData("Phone", "2222222");
            Assert.AreEqual("2222222", customer2.GetCustomData("Phone"));
            Workspace.Add(customer2);

            Workspace.CommitChanges();

            var customers = Workspace.All <Entity>(x => x.EntityTypeId == CustomerEntityType.Id).ToList();

            Assert.AreEqual(2, customers.Count());

            customer2 = customers.Single(x => x.Name == "Hasan Bulut");
            customer2.SetCustomData("Phone", "3333333");
            Workspace.CommitChanges();

            customer2 = Workspace.Single <Entity>(x => x.Name == "Hasan Bulut");
            Assert.AreEqual("3333333", customer2.GetCustomData("Phone"));

            var foundItems = EntityService.SearchEntities(CustomerEntityType, "111", "");

            Assert.AreEqual(1, foundItems.Count);

            var phoneSearch2 = EntityService.SearchEntities(CustomerEntityType, "Phone:111", "");

            Assert.AreEqual(1, phoneSearch2.Count);
            Assert.AreEqual("Emre Eren", phoneSearch2[0].Name);
        }
示例#27
0
        public override bool Execute(DotSpatial.Data.ICancelProgressHandler cancelProgressHandler)
        {
            int var_index = 0;
            var mat       = Get3DMat(InputDataCube, ref var_index);
            int prg       = 0;
            int count     = 1;

            if (mat != null)
            {
                int nstep   = mat.Size[1];
                int ncell   = mat.Size[2];
                var mat_out = new DataCube <float>(4, 1, ncell);
                mat_out.Name      = OutputDataCube;
                mat_out.Variables = new string[] { "Mean", "Variance", "Skewness", "kurtosis" };
                for (int c = 0; c < ncell; c++)
                {
                    double mean = 0, variance = 0, skewness = 0, kurtosis = 0;
                    var    vec     = mat.GetVector(var_index, ":", c.ToString());
                    var    dou_vec = MatrixOperation.ToDouble(vec);
                    Heiflow.Core.Alglib.alglib.basestat.samplemoments(dou_vec, vec.Length, ref mean, ref variance, ref skewness, ref kurtosis);
                    mat_out[0, 0, c] = (float)mean;
                    mat_out[1, 0, c] = (float)variance;
                    mat_out[2, 0, c] = (float)skewness;
                    mat_out[3, 0, c] = (float)kurtosis;
                    prg = (c + 1) * 100 / ncell;
                    if (prg > count)
                    {
                        cancelProgressHandler.Progress("Package_Tool", prg, "Caculating Cell: " + (c + 1));
                        count++;
                    }
                }
                Workspace.Add(mat_out);
                return(true);
            }
            else
            {
                return(false);
            }
        }
        public override bool Execute(DotSpatial.Data.ICancelProgressHandler cancelProgressHandler)
        {
            DataCubeStreamReader ds = new DataCubeStreamReader(CloudCoverFileName);

            ds.LoadDataCube();
            var           cloudcover  = ds.DataCube;
            CSVFileStream locationcsv = new CSVFileStream(LocationFileName);
            var           locations   = locationcsv.Load <double>();
            StreamReader  sr_dates    = new StreamReader(DateTimeFileName);
            int           ndays       = cloudcover.Size[1];
            int           nlocation   = cloudcover.Size[2];
            var           dates       = new DateTime[ndays];
            int           progress    = 0;
            int           np          = 1;
            var           swmat       = new DataCube <float>(cloudcover.Size[0], cloudcover.Size[1], cloudcover.Size[2]);

            swmat.Name = OutputName;
            for (int i = 0; i < ndays; i++)
            {
                var line = sr_dates.ReadLine();
                dates[i] = DateTime.Parse(line);
            }
            sr_dates.Close();
            for (int i = 0; i < ndays; i++)
            {
                for (int j = 0; j < nlocation; j++)
                {
                    swmat[0, i, j] = (float)_ShortWaveRadiation.DailyIncomingRadiationIntensity(locations.GetValue(j, 1), locations.GetValue(j, 0), dates[i], cloudcover[0, i, j]);
                }
                progress = i * 100 / ndays;
                if (progress == 5 * np)
                {
                    cancelProgressHandler.Progress("Package_Tool", progress, "Processing step: " + progress + "%");
                    np++;
                }
            }
            Workspace.Add(swmat);
            return(true);
        }
示例#29
0
        private WorkspacePackage CreatePackage(OrderBy orderBy, SortDirection sortDirection, IEnumerable <Snippet> snippets, string name, bool hideMetaFiles, ICollection <string> tags, ICollection <string> languages)
        {
            var ascending       = sortDirection == SortDirection.Ascending;
            var orderedSnippets = orderBy switch
            {
                OrderBy.Alphabetical => ascending?snippets.OrderBy(x => x.Meta.Title) : snippets.OrderByDescending(x => x.Meta.Title),
                    OrderBy.Created => ascending?snippets.OrderBy(x => x.Meta.CreatedUtc) : snippets.OrderByDescending(x => x.Meta.CreatedUtc),
                        _ => throw new NotSupportedException($"Unable to sort by {nameof(orderBy)}")
            };

            var workspace = new Workspace();

            workspace.Settings.FilesExclude.MetaJson = hideMetaFiles;

            foreach (var snippet in orderedSnippets)
            {
                var folder = new Folder(snippet.Meta.Title, Path.GetRelativePath(_options.WorkspacePath, snippet.DirectoryPath));
                workspace.Add(folder);
            }

            return(new WorkspacePackage($"{name}{Constants.WorkspaceFileExtension}", workspace, tags, languages));
        }
示例#30
0
        public override bool Execute(DotSpatial.Data.ICancelProgressHandler cancelProgressHandler)
        {
            var var_index = 0;
            var mat       = Get3DMat(Source, ref var_index);
            var dims      = GetDims(Source);

            if (mat != null)
            {
                var buf             = mat.ILArrays[var_index];
                var array           = buf[dims[1], dims[2]];
                var size            = array.Size.ToIntArray();
                DataCube <float> dc = new DataCube <float>(1, 1, 1, true);
                dc[0] = array;
                dc.SetSize(new int[] { 1, size[0], size[1] });
                dc.Name = Output;
                Workspace.Add(dc);
                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#31
0
		static DefaultNotions()
		{
			workspace = (Workspace)AppDomain.CurrentDomain.CreateInstance("ASDE.SemanticsEngine", "JBSnorro.Reas.SemanticsEngine.Workspace2").Unwrap();

			//defines the only two sets with null parent set. The
			Unknown = Set.CreateOverarchingOrUnknownSet(workspace, "?", appendable: false, setSelfAsDomain: false);
			OverarchingSet = Set.CreateOverarchingOrUnknownSet(workspace, "set", appendable: true, setSelfAsDomain: OverarchingSetContainsItself);
			EmptySet = new Set(workspace, "∅");

			var variableSet = new VariableSet(OverarchingSet, "var<set>");
			SetDefinition = new GenericSet(variableSet, EmptyCollection<ISet>.ReadOnlyList, variableSet.ToSingletonReadOnlyList(), Variance.Covariant.ToSingletonReadOnlyList(), "set<>");

			//AllAppendables is defined by     appendable : set<var appendable>, just like set : set<set> (well, actually, set : appendable<set>)
			//in what set would the variable appendables then be? Could be OverarchingSet: then we have the consistent appendable ⊆ set<var<appendable>> ⊆ var<appendable> ⊆ OverarchingSet
			//alternatively, I can create it just as appendable : set<set>. I'll do that for now, as it's simpler. 
			//Anyway, this does not impose the constraint that any set appended to appendables is in fact appendable (just like any other constraint isn't implemented at the moment).
			//Anyway, we can choose the above consistent more convoluted definition of appendables by uncommenting:
			//var variableAppendableSet = Set.CreateGenericSetParameter(workspace, "var<appendable>", OverarchingSet, appendable: true); //hmmm?
			//AllAppendables = new GenericSet(SetDefinition, variableAppendableSet.ToSingletonReadOnlyList(), "AllAppendables", appendable: true);

			//Another alternative, yet less elegant, is to have AllAppendables as singleton (per workspace) type deriving from generic set, such that it can have a variable itself as generic set parameter
			AllAppendables = new GenericSet(SetDefinition, OverarchingSet.ToSingletonReadOnlyList<ISet>(), "AllAppendables", appendable: true);

			workspace.Add(SetRelationType.Subset, SetDefinition, OverarchingSet);
			workspace.Add(SetRelationType.Subset, OverarchingSet, SetDefinition);

			//defines the sets that will contain ∈, × and →
			InDefiningSet = Signature.From(Unknown, OverarchingSet, OverarchingSet);//?×set→set
			CartesianAndSignatureProductType = Signature.From(OverarchingSet, OverarchingSet, OverarchingSet);//set×set→set

			//defines the notions of ∈, × and → (not their implementations)
			InDefining = new Notion(InDefiningSet, "∈");
			CartesianProduct = new Notion(CartesianAndSignatureProductType, "×");
			SignatureProduct = new Notion(CartesianAndSignatureProductType, "→");

			NaturalNumbers = new Set(workspace, "Gets the notion representing the natural numbers");

			GenericTypeOpeningDelimiterSet = new Set(workspace, "⟨");//Contains the single name that represents the opening delimiter of the special construct in which you can specify type arguments");
			GenericTypeClosingDelimiterSet = new Set(workspace, "⟩");//Contains the single name that represents the closing delimiter of the special construct in which you can specify type arguments");
																	 //GenericTypeOpeningDelimiter = new Notion(GenericTypeOpeningDelimiterSet, true, "The type argument/parameter list opening delimiter");
																	 //GenericTypeClosingDelimiter = new Notion(GenericTypeClosingDelimiterSet, true, "The type argument/parameter list closing delimiter");

			Booleans = Set.Create(workspace, "Booleans",
								  _ => new Notion(_, "true"),
								  _ => new Notion(_, "false"));

			BinarySetRelations = Signature.From(OverarchingSet, OverarchingSet, Booleans);//set×set→bool
			ProperSubset = new Notion(BinarySetRelations, "⊂");
			Subset = new Notion(BinarySetRelations, "⊆");
			ProperSuperset = new Notion(BinarySetRelations, "⊃");
			Superset = new Notion(BinarySetRelations, "⊇");



			Intersect = new Notion(CartesianAndSignatureProductType, "∩");

			//I believe these two are so far only used in sets (not say integer), hence are in set×set→bool
			EqualityOperator = new Notion(BinarySetRelations, "=");
			InequalityOperator = new Notion(BinarySetRelations, "≠");

			SetBuilderOpeningBraces = new Set(workspace, "Opening set builder braces. ");
			SetBuilderClosingBraces = new Set(workspace, "Closing set builder braces. ");
			SetBuilderEnumerationDelimiters = new Set(workspace, "Enumeration delimiters");

			//the set that contains the information on the precedence of linear notations
			//it is an appendable set of appendable sets of sets: Appendable<Appendable<Set>>

			//is this the actual set or just its signature?

			//the operator sets accept all functions of their respective signatures. The LinearAPSet makes sure these functions are transformed into operators
			//binary operators : set<LHS×RHS→TResult>
			BinaryOperators = LinearAPSet.Create(Signature.From(new VariableSet(workspace, "LHS"), new VariableSet(workspace, "RHS"), new VariableSet(workspace, "TResult")), DomainKind.Binary);
			UnaryOperators = LinearAPSet.Create(Signature.From(new VariableSet(workspace, "TOperand"), new VariableSet(workspace, "TResult")), LinearSet.Unary);
			UnaryPreOperators = LinearAPSet.Create((Signature)UnaryOperators.GenericSetArguments[0], DomainKind.UnaryPrefix);
			UnaryPostOperators = LinearAPSet.Create((Signature)UnaryOperators.GenericSetArguments[0], DomainKind.UnaryPostfix);
			//generic operators : ?   nothing?
			NullaryOperators = new LinearAPSet(workspace, "nullary");

			workspace.Add(SetRelationType.Subset, UnaryOperators, UnaryPostOperators);
			workspace.Add(SetRelationType.Subset, UnaryOperators, UnaryPreOperators);

			Operators = new Set(workspace, "Binary, unary and nullary operators");//Operators is not appendable, even though elements can be appended to it (indirectly). TODO: think about that: hence even a set that is not appendable may not be static
			workspace.Add(SetRelationType.Subset, BinaryOperators, Operators);
			workspace.Add(SetRelationType.Subset, UnaryOperators, Operators);//contains unary pre and unary post operators
			workspace.Add(SetRelationType.Subset, NullaryOperators, Operators);

			//It is the actual set, but the generic type argument should also be constant. The fact that the generic type argument is specified, is unrelated to appending the generic type argument "as element" (which we don't want to do)
			//the associativity sets accept all functions of their respective signatures. The LinearAPSet makes sure these functions are transformed into operators
			AssociativeOperators = new LinearAPSet(workspace, Associativity.Associative);
			LeftAssociativeOperators = new LinearAPSet(workspace, Associativity.Left);
			RightAssociativeOperators = new LinearAPSet(workspace, Associativity.Right);
			UnassociativeOperators = new LinearAPSet(workspace, Associativity.Undefined);

			//the equal precedence sets accept all functions of operator signature. The LinearAPSet makes sure these functions are transformed into operators.
			//The function appending to Precedences should do that
			//Precedences = Operators.CreateSubset("appendable set of operators", isConstant: false).CreateSubset("appendable set of appendable sets of operators", appendable: true, isConstant: true);
			Precedences = new GenericSet(SetDefinition, Operators.CreateSubset(appendable: true, isConstant: true).ToSingletonReadOnlyList(), "Precedences", appendable: true);
			PrecedenceElements = new FacadeMapCollection<Notion, Set>((IReadOnlyList<Notion>)workspace.TryGetElements(Precedences), equalPrecOperators => (Set)equalPrecOperators);


			//THE INNER CONSTRUCT DOESN'T CONSTRUCT AN ACTUAL SET, BUT JUST THE 'TYPE' OF ONE. Does that mean it constructs the canonical one? Well, it refers to the canonical one

			//AllAppendables it an example of a generic appendable set 
			//the equal precedence operator sets (the elements of Precedences) exemplify a constructed appendable set (which also implies there is a generic appendable set right?)
			//Precedences is an example of a set containing a reference to a set but not necessarily needing that type (namely Appendable<operators>)
			//
			//I could constructing a type always yield the canonical one (i.e. a constant inappendable one), and then you could clone it and set make the clone variable or appendable
			//only generic sets (i.e. those that have generic parameters) are constructible in this way
			//then what I now call cloning could in that case also be named constructing: you could then construct some set from the canonical one
			//however, construct conveys that a new one ie created: by specifying generic argument sets we don't necessarily create a new set since the Set.From method is called
			//we could adopt "substitute" for constructing generic sets?
			//we would adopt "adopt" for constructing generic sets? that's better, it doesn't convey necessarily creating a new one
			//Then cloning it while changing some properties (isConstant, appendable) could then very well be called construct, since it always creates a new one

			//but suppose that a generic set argument is appendable, then only appendable subsets can be used there (may depend on variance: if it's contravariant, could then also non-appendable sets be used in case an appendable is required? dunno)
			//but then it seems like adopting a set shouldn't change its appendibility
		}
示例#32
0
		/// <summary> Allows to create the generic signature definition. </summary>
		private Signature(Workspace workspace)
			: base(new[] { new VariableSet(DefaultNotions.OverarchingSet, "TParameter"), new VariableSet(DefaultNotions.OverarchingSet, "TResult") }.ToReadOnlyList(), signatureVariances, "signature definition")
		{
			workspace.Add(SetRelationType.Subset, this, DefaultNotions.SetDefinition);
		}