// FIXME: replace all invocations with direct call to ViewLayout
        protected int GetModelRowAt(int x, int y)
        {
            if (ViewLayout != null)
            {
                var child = ViewLayout.FindChildAtPoint(new Point(x, y));
                return(child == null ? -1 : ViewLayout.GetModelIndex(child));
            }
            else
            {
                if (y < 0 || ChildSize.Height <= 0)
                {
                    return(-1);
                }

                int v_page_offset = VadjustmentValue % ChildSize.Height;
                int first_row     = VadjustmentValue / ChildSize.Height;
                int row_offset    = (y + v_page_offset) / ChildSize.Height;
                return(first_row + row_offset);
            }
        }
Esempio n. 2
0
        private void PaintView(Cairo.Context cr, Rect clip)
        {
            clip.Intersect((Rect)list_rendering_alloc);
            cr.Rectangle((Cairo.Rectangle)clip);
            cr.Clip();

            cell_context.Clip             = (Gdk.Rectangle)clip;
            cell_context.TextAsForeground = false;

            selected_rows.Clear();

            for (int layout_index = 0; layout_index < ViewLayout.ChildCount; layout_index++)
            {
                var layout_child     = ViewLayout[layout_index];
                var child_allocation = layout_child.Allocation;

                if (!child_allocation.IntersectsWith(clip) || ViewLayout.GetModelIndex(layout_child) >= Model.Count)
                {
                    continue;
                }

                if (Selection != null && Selection.Contains(ViewLayout.GetModelIndex(layout_child)))
                {
                    selected_rows.Add(ViewLayout.GetModelIndex(layout_child));

                    PaintRowSelection(cr, (int)child_allocation.X, (int)child_allocation.Y,
                                      (int)child_allocation.Width, (int)child_allocation.Height);

                    cell_context.Selected = true;
                }
                else
                {
                    cell_context.Selected = false;
                }

                layout_child.Render(cell_context);
            }

            cr.ResetClip();
        }
Esempio n. 3
0
        public void RememberCurrentLayout()
        {
            if (ViewContext == null || BindingListSource == null)
            {
                return;
            }
            var viewSpec = BindingListSource.ViewSpec;

            if (viewSpec == null)
            {
                return;
            }
            var viewName = GetViewName();

            if (viewName.GroupId.Equals(ViewGroup.BUILT_IN.Id) || viewName.GroupId.Equals(default(ViewGroupId)))
            {
                return;
            }
            var viewLayouts = ViewContext.GetViewLayoutList(GetViewName());

            using (var dlg = new NameLayoutForm(ViewContext,
                                                new HashSet <string>(viewLayouts.Layouts.Select(layout => layout.Name))))
            {
                if (dlg.ShowDialog(FormUtil.FindTopLevelOwner(this)) == DialogResult.OK)
                {
                    var newLayout = new ViewLayout(dlg.LayoutName);
                    newLayout = PopulateLayout(newLayout);
                    var newLayouts = viewLayouts.Layouts.Where(layout => layout.Name != dlg.LayoutName).Concat(new[]
                    {
                        newLayout
                    });
                    viewLayouts = viewLayouts.ChangeLayouts(newLayouts);
                    if (dlg.MakeDefault)
                    {
                        viewLayouts = viewLayouts.ChangeDefaultLayoutName(dlg.LayoutName);
                    }
                    ViewContext.SetViewLayoutList(viewName.GroupId, viewLayouts);
                }
            }
        }
Esempio n. 4
0
        public void TestViewLayoutRowTransforms()
        {
            var dataSchema = new DataSchema();
            var viewLayout = new ViewLayout("TestName").ChangeRowTransforms(
                new IRowTransform[]
            {
                new PivotSpec()
                .ChangeRowHeaders(new[]
                                  { new PivotSpec.Column(new ColumnId("RowHeaderOne")).ChangeCaption("MyCaption") })
                .ChangeColumnHeaders(new[] { new PivotSpec.Column(new ColumnId("ColumnOne")), })
                .ChangeValues(new[]
                {
                    (PivotSpec.AggregateColumn) new PivotSpec.AggregateColumn(new ColumnId("ValueOne"),
                                                                              AggregateOperation.Cv).ChangeCaption("Aggregate column caption"),
                }),
                new RowFilter("filterText", true, new[]
                {
                    new RowFilter.ColumnFilter(new ColumnId("column1"), FilterPredicate.CreateFilterPredicate(dataSchema, typeof(string), FilterOperations.OP_CONTAINS, "contains1"))
                }).SetColumnSorts(new[]
                {
                    new RowFilter.ColumnSort(new ColumnId("columnSort1"), ListSortDirection.Ascending),
                    new RowFilter.ColumnSort(new ColumnId("columnSort2"), ListSortDirection.Descending)
                })
            }
                ).ChangeColumnFormats(new []
            {
                Tuple.Create(new ColumnId("ColumnId1"), ColumnFormat.EMPTY.ChangeFormat("R").ChangeWidth(20))
            }).ChangeClusterSpec(new ClusteringSpec(new []
            {
                new ClusteringSpec.ValueSpec(new ClusteringSpec.ColumnRef(new ColumnId("column_id_1")), "role1"),
                new ClusteringSpec.ValueSpec(new ClusteringSpec.ColumnRef(PropertyPath.Root.Property("property1")), "role2"),
            }).ChangeDistanceMetric("distance_metric"));

            var viewLayoutList = new ViewLayoutList("Test").ChangeLayouts(new [] { viewLayout })
                                 .ChangeDefaultLayoutName("TestName");
            var roundTrip = RoundTripToXml(viewLayoutList);

            Assert.AreEqual(viewLayoutList, roundTrip);
        }
Esempio n. 5
0
        protected override void OnSizeAllocated(Rectangle allocation)
        {
            base.OnSizeAllocated(allocation);

            if (IsRealized)
            {
                event_window.MoveResize(allocation);
            }

            MoveResize(allocation);
            RecalculateColumnSizes();
            RegenerateColumnCache();

            if (ViewLayout != null)
            {
                ViewLayout.Allocate((Hyena.Gui.Canvas.Rect)list_rendering_alloc);
            }

            if (vadjustment != null)
            {
                hadjustment.PageSize      = header_interaction_alloc.Width;
                hadjustment.PageIncrement = header_interaction_alloc.Width;
                vadjustment.PageSize      = list_rendering_alloc.Height;
                vadjustment.PageIncrement = list_rendering_alloc.Height;
                UpdateAdjustments();
            }

            ICareAboutView model = Model as ICareAboutView;

            if (model != null)
            {
                model.RowsInView = RowsInView;
            }

            OnInvalidateMeasure();
            InvalidateList();
        }
Esempio n. 6
0
        public void SetViewContext(IViewContext viewContext, ViewInfo viewInfo, ViewLayout viewLayout)
        {
            ViewContext = viewContext;
            if (null == viewInfo)
            {
                BindingListView.ViewInfo = null;
            }
            else
            {
                IRowSource rowSource   = null;
                bool       viewChanged = true;
                if (null != ViewInfo)
                {
                    if (ViewInfo.RowSourceName == viewInfo.RowSourceName)
                    {
                        rowSource = RowSource;
                        if (ViewInfo.Name == viewInfo.Name)
                        {
                            viewChanged = false;
                        }
                    }
                }
                rowSource = rowSource ?? viewContext.GetRowSource(viewInfo);
                BindingListView.SetViewAndRows(viewInfo, rowSource);
                if (viewChanged)
                {
                    BindingListView.ClearTransformStack();
                }

                if (viewLayout != null)
                {
                    ApplyLayout(viewLayout);
                }
            }
            OnListChanged(new ListChangedEventArgs(ListChangedType.Reset, -1));
        }
 CanvasItem GetLayoutChildAt(Point point)
 {
     point.Offset(-list_interaction_alloc.X, -list_interaction_alloc.Y);
     return(ViewLayout.FindChildAtPoint(point));
 }
        public ActionResult Create(ViewLayout ViewdevLayout)
        {
            if (ModelState.IsValid)
            {
                ViewdevLayout.Devlayout.dvLtVersion    = "1";
                ViewdevLayout.Devlayout.dvLtLastUpdate = DateTime.Now.ToString();

                string[] sett = ViewdevLayout.result.Split('#');
                db.DevLayout.Add(ViewdevLayout.Devlayout);
                db.SaveChanges();
                foreach (string s in sett)
                {
                    if (s != "")
                    {
                        LayoutSettings layouteset = new LayoutSettings();
                        string[]       data       = s.Split(';');
                        foreach (string v in data)
                        {
                            Guid     guid = Guid.NewGuid();
                            string[] val  = v.Split(':');
                            if (val[0] == "type")
                            {
                                layouteset.ltSType = val[1];
                            }
                            else if (val[0] == "left")
                            {
                                layouteset.ItSPosition += val[0] + ":" + val[1] + ";";
                            }
                            else if (val[0] == "top")
                            {
                                layouteset.ItSPosition += val[0] + ":" + val[1] + ";";
                            }
                            else if (val[0] == "width")
                            {
                                layouteset.ItSPosition += val[0] + ":" + val[1] + ";";
                            }
                            else if (val[0] == "height")
                            {
                                layouteset.ItSPosition += val[0] + ":" + val[1] + ";";
                            }
                            else if (val[0] == "dbid")
                            {
                                layouteset.ItSdbid = guid.ToString();
                            }
                        }
                        layouteset.ltSDevLayoutId = ViewdevLayout.Devlayout.dvLtAutoId;
                        db.LayoutSettings.Add(layouteset);
                        db.SaveChanges();
                    }
                }
                string subPath = ViewdevLayout.Devlayout.dvLtAutoId.ToString();
                System.IO.Directory.CreateDirectory(Server.MapPath("~/files/" + subPath));
                return(RedirectToAction("Settings", new { id = ViewdevLayout.Devlayout.dvLtAutoId }));

                //if (ViewdevLayout.Devlayout.dvLtType == 1)
                //{

                //    db.DevLayout.Add(ViewdevLayout.Devlayout);
                //    db.SaveChanges();
                //    if (ViewdevLayout.result != null)
                //    {
                //        string[] sett = ViewdevLayout.result.Split('#');
                //        foreach (string s in sett)
                //        {
                //            if (s != "")
                //            {
                //                LayoutSettings layouteset = new LayoutSettings();
                //                string[] data = s.Split(';');
                //                foreach (string v in data)
                //                {
                //                    Guid guid = Guid.NewGuid();
                //                    string[] val = v.Split(':');
                //                    if (val[0] == "type")
                //                        layouteset.ltSType = val[1];
                //                    else if (val[0] == "left")
                //                        layouteset.ItSPosition += val[0] + ":" + val[1] + ";";
                //                    else if (val[0] == "top")
                //                        layouteset.ItSPosition += val[0] + ":" + val[1] + ";";
                //                    else if (val[0] == "width")
                //                        layouteset.ItSPosition += val[0] + ":" + val[1] + ";";
                //                    else if (val[0] == "height")
                //                        layouteset.ItSPosition += val[0] + ":" + val[1] + ";";
                //                    else if (val[0] == "dbid")
                //                        layouteset.ItSdbid = guid.ToString();
                //                }
                //                layouteset.ltSDevLayoutId = ViewdevLayout.Devlayout.dvLtAutoId;
                //                db.LayoutSettings.Add(layouteset);
                //                db.SaveChanges();
                //            }
                //        }
                //        string subPath = ViewdevLayout.Devlayout.dvLtAutoId.ToString();
                //        System.IO.Directory.CreateDirectory(Server.MapPath("~/files/" + subPath));
                //    }

                //    DeviceIO addnew;
                //    for (int i = 0; i < ViewdevLayout.inputCount; i++)
                //    {
                //        addnew = new DeviceIO
                //        {
                //            ioType = "1",
                //            ioDeviceId = ViewdevLayout.Devlayout.dvLtAutoId,
                //            ioValType = "bit"
                //        };
                //        db.DeviceIO.Add(addnew);
                //    }
                //    for (int i = 0; i < ViewdevLayout.outputCount; i++)
                //    {
                //        addnew = new DeviceIO
                //        {
                //            ioType = "2",
                //            ioDeviceId = ViewdevLayout.Devlayout.dvLtAutoId,
                //            ioValType = "bit"
                //        };
                //        db.DeviceIO.Add(addnew);
                //    }
                //    for (int i = 0; i < ViewdevLayout.virtualCount; i++)
                //    {
                //        addnew = new DeviceIO
                //        {
                //            ioType = "3",
                //            ioDeviceId = ViewdevLayout.Devlayout.dvLtAutoId,
                //            ioValType = "string"
                //        };
                //        db.DeviceIO.Add(addnew);
                //    }
                //    db.SaveChanges();
                //    return RedirectToAction("Settings", new { id = ViewdevLayout.Devlayout.dvLtAutoId });
                //}
                //else if (ViewdevLayout.Devlayout.dvLtType == 2)
                //{
                //    string[] sett = ViewdevLayout.result.Split('#');
                //    db.DevLayout.Add(ViewdevLayout.Devlayout);
                //    db.SaveChanges();
                //    foreach (string s in sett)
                //    {
                //        if (s != "")
                //        {
                //            LayoutSettings layouteset = new LayoutSettings();
                //            string[] data = s.Split(';');
                //            foreach (string v in data)
                //            {
                //                Guid guid = Guid.NewGuid();
                //                string[] val = v.Split(':');
                //                if (val[0] == "type")
                //                    layouteset.ltSType = val[1];
                //                else if (val[0] == "left")
                //                    layouteset.ItSPosition += val[0] + ":" + val[1] + ";";
                //                else if (val[0] == "top")
                //                    layouteset.ItSPosition += val[0] + ":" + val[1] + ";";
                //                else if (val[0] == "width")
                //                    layouteset.ItSPosition += val[0] + ":" + val[1] + ";";
                //                else if (val[0] == "height")
                //                    layouteset.ItSPosition += val[0] + ":" + val[1] + ";";
                //                else if (val[0] == "dbid")
                //                    layouteset.ItSdbid = guid.ToString();
                //            }
                //            layouteset.ltSDevLayoutId = ViewdevLayout.Devlayout.dvLtAutoId;
                //            db.LayoutSettings.Add(layouteset);
                //            db.SaveChanges();
                //        }
                //    }
                //    string subPath = ViewdevLayout.Devlayout.dvLtAutoId.ToString();
                //    System.IO.Directory.CreateDirectory(Server.MapPath("~/files/" + subPath));
                //    return RedirectToAction("Settings", new { id = ViewdevLayout.Devlayout.dvLtAutoId });
                //}
                //else if (ViewdevLayout.Devlayout.dvLtType == 3)
                //{
                //    db.DevLayout.Add(ViewdevLayout.Devlayout);
                //    db.SaveChanges();
                //    DeviceIO addnew;
                //    for (int i = 0; i < ViewdevLayout.inputCount; i++)
                //    {
                //        addnew = new DeviceIO
                //        {
                //            ioType = "1",
                //            ioDeviceId = ViewdevLayout.Devlayout.dvLtAutoId,
                //            ioValType = "bit"
                //        };
                //        db.DeviceIO.Add(addnew);
                //    }
                //    for (int i = 0; i < ViewdevLayout.outputCount; i++)
                //    {
                //        addnew = new DeviceIO
                //        {
                //            ioType = "2",
                //            ioDeviceId = ViewdevLayout.Devlayout.dvLtAutoId,
                //            ioValType = "bit"
                //        };
                //        db.DeviceIO.Add(addnew);
                //    }
                //    for (int i = 0; i < ViewdevLayout.virtualCount; i++)
                //    {
                //        addnew = new DeviceIO
                //        {
                //            ioType = "3",
                //            ioDeviceId = ViewdevLayout.Devlayout.dvLtAutoId,
                //            ioValType = "string"
                //        };
                //        db.DeviceIO.Add(addnew);
                //    }
                //    db.SaveChanges();
                //    return RedirectToAction("Settings", new { id = ViewdevLayout.Devlayout.dvLtAutoId });
                //}
            }
            return(View(ViewdevLayout));
        }
        public ActionResult Edit(int?id, ViewLayout ViewdevLayout)
        {
            if (id != null)
            {
                List <LayoutSettings> getloutseting = db.LayoutSettings.Where(x => x.ltSDevLayoutId == id.Value).ToList();
                DevLayout             getDevlayout  = db.DevLayout.Find(id.Value);
                if (getDevlayout != null)
                {
                    /*foreach (var data in getloutseting)
                     * {
                     *  db.LayoutSettings.Attach(data);
                     *  db.LayoutSettings.Remove(data);
                     *  db.SaveChanges();
                     * }*/
                    getDevlayout.dvLtLastUpdate = DateTime.Now.ToString();
                    db.SaveChanges();

                    string[] sett = ViewdevLayout.result.Split('#');
                    foreach (string s in sett)
                    {
                        if (s != "")
                        {
                            string[]       data       = s.Split(';');
                            string[]       getguid    = data[6].Split(':');
                            string         guid       = getguid[1];
                            LayoutSettings layouteset = db.LayoutSettings.Where(x => x.ItSdbid == guid).SingleOrDefault();
                            if (layouteset == null)
                            {
                                layouteset = new LayoutSettings();
                            }
                            else
                            {
                                layouteset.ItSPosition = "";
                            }
                            if (layouteset == null)
                            {
                                layouteset = new LayoutSettings();
                            }
                            foreach (string v in data)
                            {
                                string[] val = v.Split(':');
                                if (val[0] == "type")
                                {
                                    layouteset.ltSType = val[1];
                                }
                                else if (val[0] == "left")
                                {
                                    layouteset.ItSPosition += val[0] + ":" + val[1] + ";";
                                }
                                else if (val[0] == "top")
                                {
                                    layouteset.ItSPosition += val[0] + ":" + val[1] + ";";
                                }
                                else if (val[0] == "width")
                                {
                                    layouteset.ItSPosition += val[0] + ":" + val[1] + ";";
                                }
                                else if (val[0] == "height")
                                {
                                    layouteset.ItSPosition += val[0] + ":" + val[1] + ";";
                                }
                            }
                            layouteset.ltSDevLayoutId = getDevlayout.dvLtAutoId;
                            if (layouteset.ItSdbid == null)
                            {
                                layouteset.ItSdbid = Guid.NewGuid().ToString();
                                db.LayoutSettings.Add(layouteset);
                            }

                            var getset = getloutseting.Where(x => x.ItSdbid == layouteset.ItSdbid).SingleOrDefault();
                            if (getset != null)
                            {
                                getloutseting.Remove(getset);
                            }
                            db.SaveChanges();
                        }
                    }
                    foreach (var data in getloutseting)
                    {
                        db.LayoutSettings.Attach(data);
                        db.LayoutSettings.Remove(data);
                        db.SaveChanges();
                    }
                    string subPath = getDevlayout.dvLtAutoId.ToString();
                    Directory.CreateDirectory(Server.MapPath("~/files/" + subPath));
                    return(RedirectToAction("Settings", new { id = getDevlayout.dvLtAutoId }));

                    //if (getDevlayout.dvLtType == 1)
                    //{
                    //    if (ViewdevLayout.result != null)
                    //    {
                    //        string[] sett = ViewdevLayout.result.Split('#');
                    //        foreach (string s in sett)
                    //        {
                    //            if (s != "")
                    //            {
                    //                //LayoutSettings layouteset = new LayoutSettings();
                    //                string[] data = s.Split(';');
                    //                string[] getguid = data[6].Split(':');
                    //                string guid = getguid[1];
                    //                LayoutSettings layouteset = db.LayoutSettings.Where(x => x.ItSdbid == guid).SingleOrDefault();
                    //                if (layouteset ==  null)
                    //                {
                    //                    layouteset = new LayoutSettings();
                    //                }
                    //                else
                    //                {
                    //                    layouteset.ItSPosition = "";
                    //                }
                    //                foreach (string v in data)
                    //                {
                    //                    string[] val = v.Split(':');
                    //                    if (val[0] == "type")
                    //                        layouteset.ltSType = val[1];
                    //                    else if (val[0] == "left")
                    //                        layouteset.ItSPosition += val[0] + ":" + val[1] + ";";
                    //                    else if (val[0] == "top")
                    //                        layouteset.ItSPosition += val[0] + ":" + val[1] + ";";
                    //                    else if (val[0] == "width")
                    //                        layouteset.ItSPosition += val[0] + ":" + val[1] + ";";
                    //                    else if (val[0] == "height")
                    //                        layouteset.ItSPosition += val[0] + ":" + val[1] + ";";
                    //                }
                    //                layouteset.ltSDevLayoutId = getDevlayout.dvLtAutoId;
                    //                if (layouteset.ItSdbid == null)
                    //                {
                    //                    layouteset.ItSdbid = Guid.NewGuid().ToString();
                    //                    db.LayoutSettings.Add(layouteset);
                    //                }

                    //                var getset = getloutseting.Where(x => x.ItSdbid == layouteset.ItSdbid).SingleOrDefault();
                    //                if (getset != null)
                    //                {
                    //                    getloutseting.Remove(getset);
                    //                }

                    //                db.SaveChanges();
                    //            }
                    //        }


                    //        string subPath = getDevlayout.dvLtAutoId.ToString();
                    //        Directory.CreateDirectory(Server.MapPath("~/files/" + subPath));
                    //    }

                    //    DeviceIO addnew;
                    //    for (int i = 0; i < ViewdevLayout.inputCount; i++)
                    //    {
                    //        addnew = new DeviceIO
                    //        {
                    //            ioType = "1",
                    //            ioDeviceId = ViewdevLayout.Devlayout.dvLtAutoId,
                    //            ioValType = "bit"
                    //        };
                    //        db.DeviceIO.Add(addnew);
                    //    }
                    //    for (int i = 0; i < ViewdevLayout.outputCount; i++)
                    //    {
                    //        addnew = new DeviceIO
                    //        {
                    //            ioType = "2",
                    //            ioDeviceId = ViewdevLayout.Devlayout.dvLtAutoId,
                    //            ioValType = "bit"
                    //        };
                    //        db.DeviceIO.Add(addnew);
                    //    }
                    //    for (int i = 0; i < ViewdevLayout.virtualCount; i++)
                    //    {
                    //        addnew = new DeviceIO
                    //        {
                    //            ioType = "3",
                    //            ioDeviceId = ViewdevLayout.Devlayout.dvLtAutoId,
                    //            ioValType = "string"
                    //        };
                    //        db.DeviceIO.Add(addnew);
                    //    }
                    //    db.SaveChanges();
                    //    foreach (var data in getloutseting)
                    //    {
                    //        db.LayoutSettings.Attach(data);
                    //        db.LayoutSettings.Remove(data);
                    //        db.SaveChanges();
                    //    }
                    //    return RedirectToAction("Settings", new { id = getDevlayout.dvLtAutoId });
                    //}
                    //else if (getDevlayout.dvLtType == 2)
                    //{
                    //    string[] sett = ViewdevLayout.result.Split('#');
                    //    foreach (string s in sett)
                    //    {
                    //        if (s != "")
                    //        {
                    //            string[] data = s.Split(';');
                    //            string[] getguid = data[6].Split(':');
                    //            string guid = getguid[1];
                    //            LayoutSettings layouteset = db.LayoutSettings.Where(x => x.ItSdbid == guid).SingleOrDefault();
                    //            if (layouteset == null)
                    //            {
                    //                layouteset = new LayoutSettings();
                    //            }
                    //            else
                    //            {
                    //                layouteset.ItSPosition = "";
                    //            }
                    //            if (layouteset == null)
                    //            {
                    //                layouteset = new LayoutSettings();
                    //            }
                    //            foreach (string v in data)
                    //            {
                    //                string[] val = v.Split(':');
                    //                if (val[0] == "type")
                    //                    layouteset.ltSType = val[1];
                    //                else if (val[0] == "left")
                    //                    layouteset.ItSPosition += val[0] + ":" + val[1] + ";";
                    //                else if (val[0] == "top")
                    //                    layouteset.ItSPosition += val[0] + ":" + val[1] + ";";
                    //                else if (val[0] == "width")
                    //                    layouteset.ItSPosition += val[0] + ":" + val[1] + ";";
                    //                else if (val[0] == "height")
                    //                    layouteset.ItSPosition += val[0] + ":" + val[1] + ";";
                    //            }
                    //            layouteset.ltSDevLayoutId = getDevlayout.dvLtAutoId;
                    //            if (layouteset.ItSdbid == null)
                    //            {
                    //                layouteset.ItSdbid = Guid.NewGuid().ToString();
                    //                db.LayoutSettings.Add(layouteset);
                    //            }

                    //            var getset = getloutseting.Where(x => x.ItSdbid == layouteset.ItSdbid).SingleOrDefault();
                    //            if (getset != null)
                    //            {
                    //                getloutseting.Remove(getset);
                    //            }
                    //            db.SaveChanges();
                    //        }
                    //    }
                    //    foreach (var data in getloutseting)
                    //    {
                    //        db.LayoutSettings.Attach(data);
                    //        db.LayoutSettings.Remove(data);
                    //        db.SaveChanges();
                    //    }
                    //    string subPath = getDevlayout.dvLtAutoId.ToString();
                    //    System.IO.Directory.CreateDirectory(Server.MapPath("~/files/" + subPath));
                    //    return RedirectToAction("Settings", new { id = getDevlayout.dvLtAutoId });
                    //}
                    //else if (getDevlayout.dvLtType == 3)
                    //{
                    //    //db.DevLayout.Add(ViewdevLayout.Devlayout);
                    //    //db.SaveChanges();
                    //    DeviceIO addnew;
                    //    for (int i = 0; i < ViewdevLayout.inputCount; i++)
                    //    {
                    //        addnew = new DeviceIO
                    //        {
                    //            ioType = "1",
                    //            ioDeviceId = ViewdevLayout.Devlayout.dvLtAutoId,
                    //            ioValType = "bit"
                    //        };
                    //        db.DeviceIO.Add(addnew);
                    //    }
                    //    for (int i = 0; i < ViewdevLayout.outputCount; i++)
                    //    {
                    //        addnew = new DeviceIO
                    //        {
                    //            ioType = "2",
                    //            ioDeviceId = ViewdevLayout.Devlayout.dvLtAutoId,
                    //            ioValType = "bit"
                    //        };
                    //        db.DeviceIO.Add(addnew);
                    //    }
                    //    for (int i = 0; i < ViewdevLayout.virtualCount; i++)
                    //    {
                    //        addnew = new DeviceIO
                    //        {
                    //            ioType = "3",
                    //            ioDeviceId = getDevlayout.dvLtAutoId,
                    //            ioValType = "string"
                    //        };
                    //        db.DeviceIO.Add(addnew);
                    //    }
                    //    db.SaveChanges();
                    //    foreach (var data in getloutseting)
                    //    {
                    //        db.LayoutSettings.Attach(data);
                    //        db.LayoutSettings.Remove(data);
                    //        db.SaveChanges();
                    //    }
                    //    return RedirectToAction("Settings", new { id = getDevlayout.dvLtAutoId });
                    //}
                }
            }
            return(View());

            /*if (ModelState.IsValid)
            *  {
            *   devLayout.Devlayout.dvLtLastUpdate = DateTime.Now.ToString();
            *   devLayout.Devlayout.dvLtVersion = (Convert.ToInt32(devLayout.Devlayout.dvLtVersion) + 1).ToString();
            *
            *   db.Entry(devLayout).State = EntityState.Modified;
            *   db.SaveChanges();
            *   return RedirectToAction("Index");
            *  }
            *  return View(devLayout);*/
        }
        public void LoadPreferences()
        {
            Directory.SetCurrentDirectory(m_filepath_root);

            m_grid_display = (GridDisplay)UserPrefs.GetInt("grid_display", (int)m_grid_display);
            m_grid_spacing = UserPrefs.GetInt("grid_spacing", m_grid_spacing);
            m_grid_snap    = UserPrefs.GetFloat("grid_snap", m_grid_snap);

            m_coplanar_tol   = UserPrefs.GetInt("coplanar_tol", m_coplanar_tol);
            m_rotate_angle   = UserPrefs.GetInt("rotate_angle", m_rotate_angle);
            m_side_select    = (SideSelect)UserPrefs.GetInt("side_select", (int)m_side_select);
            m_insert_advance = UserPrefs.GetBool("insert_advance", m_insert_advance);
            m_drag_mode      = (DragMode)UserPrefs.GetInt("drag_mode", (int)m_drag_mode);

            m_view_mode_ortho   = (ViewMode)UserPrefs.GetInt("view_mode_ortho", (int)m_view_mode_ortho);
            m_view_mode_persp   = (ViewMode)UserPrefs.GetInt("view_mode_persp", (int)m_view_mode_persp);
            m_view_persp_fov    = UserPrefs.GetInt("view_persp_fov", m_view_persp_fov);
            m_view_layout       = (ViewLayout)UserPrefs.GetInt("view_layout", (int)m_view_layout);
            m_bg_color          = (BGColor)UserPrefs.GetInt("bg_color", (int)m_bg_color);
            m_gimbal_display    = (GimbalDisplay)UserPrefs.GetInt("gimbal_display", (int)m_gimbal_display);
            m_lighting_type     = (LightingType)UserPrefs.GetInt("lighting_type", (int)m_lighting_type);
            m_cp_display        = (ClipPlaneDisplay)UserPrefs.GetInt("clip_decal", (int)m_cp_display);
            m_insert_decal      = (InsertDecal)UserPrefs.GetInt("insert_decal", (int)m_insert_decal);
            m_show_3d_text_type = (ShowTextType)UserPrefs.GetInt("show_segment_numbers", (int)m_show_3d_text_type);
            m_auto_center       = UserPrefs.GetBool("auto_center", m_auto_center);

            m_decal_list_loc       = UserPrefs.GetPoint("decal_list_loc", decal_list.Location);
            m_decal_list_sz        = UserPrefs.GetPoint("decal_list_sz", (Point)decal_list.Size);
            m_tex_list_loc         = UserPrefs.GetPoint("tex_list_loc", texture_list.Location);
            m_tex_list_sz          = UserPrefs.GetPoint("tex_list_sz", (Point)texture_list.Size);
            m_texture_set_list_loc = UserPrefs.GetPoint("texture_set_list_loc", texture_list.Location);
            m_texture_set_list_sz  = UserPrefs.GetPoint("texture_set_list_sz", (Point)texture_list.Size);
            m_uv_editor_loc        = UserPrefs.GetPoint("uv_editor_loc", uv_editor.Location);
            m_uv_editor_sz         = UserPrefs.GetPoint("uv_editor_sz", (Point)uv_editor.Size);

            decal_list.Size   = (Size)m_decal_list_sz;
            texture_list.Size = (Size)m_tex_list_sz;
            uv_editor.Size    = (Size)m_uv_editor_sz;

            for (int i = 0; i < NumRecentFiles; i++)
            {
                string recent_file = GetRecentFile(i);
                SetRecentFile(i, UserPrefs.GetString("recent" + i.ToString(), recent_file));
            }
            Shell.UpdateRecentFileMenu();

            m_pivot_mode = (PivotMode)UserPrefs.GetInt("entity_pivot", (int)m_pivot_mode);

            m_editor_layout = UserPrefs.GetString("layout", string.Empty);

            //Save whether pop-up windows are open at startup
            m_decal_list_visible       = UserPrefs.GetBool("decal_list_vis", false);
            m_texture_list_visible     = UserPrefs.GetBool("tex_list_vis", false);
            m_texture_set_list_visible = UserPrefs.GetBool("texture_set_list_vis", false);
            m_uv_editor_visible        = UserPrefs.GetBool("uv_editor_vis", false);

#if !PUBLIC_RELEASE
            Overload.Perforce.m_cached_username   = UserPrefs.GetString("m_cached_username", string.Empty);
            Overload.Perforce.m_cached_clientname = UserPrefs.GetString("m_cached_clientname", string.Empty);
#endif // !PUBLIC_RELEASE

            m_mm_edit_type = (EditMode)UserPrefs.GetInt("mm_edit_type", (int)m_mm_edit_type);
            m_mm_op_mode   = (OperationMode)UserPrefs.GetInt("mm_op_mode", (int)m_mm_op_mode);

            //Read texture collections
            int num_texture_collections = UserPrefs.GetInt("num_texture_collections", 0);
            for (int c = 0; c < num_texture_collections; c++)
            {
                TextureCollections.Add(new TextureCollection(UserPrefs.GetString("texture_collection_" + c), true));
            }
        }
Esempio n. 11
0
        private void OnQueryTooltip(object o, Gtk.QueryTooltipArgs args)
        {
            if (!args.KeyboardTooltip)
            {
                if (ViewLayout != null)
                {
                    var pt    = new Point(args.X - list_interaction_alloc.X, args.Y - list_interaction_alloc.Y);
                    var child = ViewLayout.FindChildAtPoint(pt);
                    if (child != null)
                    {
                        string markup;
                        Rect   area;
                        pt.Offset(ViewLayout.ActualAllocation.Point);
                        if (child.GetTooltipMarkupAt(pt, out markup, out area))
                        {
                            area.Offset(-ViewLayout.ActualAllocation.X, -ViewLayout.ActualAllocation.Y);
                            area.Offset(list_interaction_alloc.X, list_interaction_alloc.Y);
                            args.Tooltip.Markup  = markup;
                            args.Tooltip.TipArea = (Gdk.Rectangle)area;

                            /*if (!area.Contains (args.X, args.Y)) {
                             *  Log.WarningFormat ("Tooltip rect {0} does not contain tooltip point {1},{2} -- this will cause excessive requerying", area, args.X, args.Y);
                             * }*/
                            args.RetVal = true;
                        }
                    }
                }
                else if (cell_context != null && cell_context.Layout != null)
                {
                    ITooltipCell cell;
                    Column       column;
                    int          row_index;

                    if (GetEventCell <ITooltipCell> (args.X, args.Y, out cell, out column, out row_index))
                    {
                        CachedColumn cached_column = GetCachedColumnForColumn(column);

                        string markup = cell.GetTooltipMarkup(cell_context, cached_column.Width);
                        if (!String.IsNullOrEmpty(markup))
                        {
                            Gdk.Rectangle rect = new Gdk.Rectangle();
                            rect.X = list_interaction_alloc.X + cached_column.X1;

                            // get the y of the event in list coords
                            rect.Y = args.Y - list_interaction_alloc.Y;

                            // get the top of the cell pointed to by list_y
                            rect.Y -= VadjustmentValue % ChildSize.Height;
                            rect.Y -= rect.Y % ChildSize.Height;

                            // convert back to widget coords
                            rect.Y += list_interaction_alloc.Y;

                            // TODO is this right even if the list is wide enough to scroll horizontally?
                            rect.Width = cached_column.Width;

                            // TODO not right - could be smaller if at the top/bottom and only partially showing
                            rect.Height = ChildSize.Height;

                            /*if (!rect.Contains (args.X, args.Y)) {
                             *  Log.WarningFormat ("ListView tooltip rect {0} does not contain tooltip point {1},{2} -- this will cause excessive requerying", rect, args.X, args.Y);
                             * }*/

                            args.Tooltip.Markup  = markup;
                            args.Tooltip.TipArea = rect;
                            args.RetVal          = true;
                        }
                    }
                }
            }

            // Work around ref counting SIGSEGV, see http://bugzilla.gnome.org/show_bug.cgi?id=478519#c9
            if (args.Tooltip != null)
            {
                args.Tooltip.Dispose();
            }
        }
Esempio n. 12
0
        /// <summary>
        /// Render views for stacked, side by side or tabbed
        /// </summary>

        void CreateCommonLayoutAndRenderViews(ViewLayout layout)
        {
            DockPanel        pdp    = null;  // parent dock panel which is a vertical or horizontal split panel or a tab panel
            DockPanel        dp     = null;  // current docking panel that contains the view panel & is stored in the ResultsDisplayPanel
            DockPanel        lastDp = null;
            XtraPanel        viewPanel;      // panel that contains current view control and is contained in a docking panel or directly in the views panel if single view on page
            ResultsViewProps view;
            DockingStyle     dockingStyle = DockingStyle.Top;

            if (layout == ViewLayout.SideBySide)
            {
                dockingStyle           = DockingStyle.Top;
                ResultsPage.LastLayout = layout;
            }

            else if (layout == ViewLayout.Stacked)
            {
                dockingStyle           = DockingStyle.Left;
                ResultsPage.LastLayout = layout;
            }

            else if (layout == ViewLayout.Tabbed)
            {
                dockingStyle             = DockingStyle.Left;
                ResultsPage.TabbedLayout = true;                 // set flag indicating tabbed layout
            }

            ResultsPage             page  = ResultsPage;
            List <ResultsViewProps> views = page.Views;

            DockManager dm = DockManager;

            dm.Clear();

            DockPanel activePanel = null;

            for (int vi = 0; vi < views.Count; vi++)
            {
                view           = views[vi];
                viewPanel      = new XtraPanel();     // the panel that will contain the view control, goes into a DockPanel or directly into the viewsPanel if only one view
                viewPanel.Dock = DockStyle.Fill;      // it will fill its containing panel

                if (views.Count == 1)                 // if just one view then let it use the full panel (no DockPanel with view header)
                {
                    Controls.Add(viewPanel);
                }

                else                 // create a new DockPanel, add the viewPanel to it and
                {
                    if (vi == 0)     // first panel, add to DockManager
                    {
                        dp = dm.AddPanel(dockingStyle);
                    }

                    else if (vi == 1)                     // 2nd panel, add to first which creates splitter
                    {
                        dp = lastDp.AddPanel();
                    }

                    else                     // additional panels are just added to splitter
                    {
                        dp = dm.RootPanels[0].AddPanel();
                    }

                    lastDp = dp;

                    SetupDockPanel(dp, view, viewPanel);

                    if (page.ActiveViewIndex == vi)
                    {
                        activePanel = dp;
                    }
                }
            }                        // view loop

            if (activePanel != null) // set the active panel
            {
                dm.ActivePanel = activePanel;
            }

            if (dm.RootPanels.Count > 0)
            {
                dm.RootPanels[0].Size = Size;
            }

            if (layout == ViewLayout.SideBySide)
            {
                foreach (DockPanel dp0 in dm.Panels)
                {
                    if (dp0.Count == 0)
                    {
                        dp0.Height = Height;
                    }
                }
                //dp0.Width = (int)(Width / (double)views.Count + .5);
            }

            else if (layout == ViewLayout.Stacked)
            {
                foreach (DockPanel dp0 in dm.Panels)
                {
                    if (dp0.Count == 0)
                    {
                        dp0.Width = Width;
                    }
                }
                //dp0.Height = (int)(Height / (double)views.Count + .5);
            }

            else if (layout == ViewLayout.Tabbed && dm.RootPanels.Count > 0)
            {
                SetupTabbedPanel(dm.RootPanels[0]);                 // make it tabbed
            }
            return;
        }
        // HEADER GUI
        void HeaderOnGui()
        {
            GUIStyle labelstyle = GUI.skin.GetStyle("Label");

            labelstyle.alignment  = TextAnchor.UpperLeft;
            labelstyle.fixedWidth = 300;

            // WINDOW TITLE
            string libtype = (showClass == 3 ? "3D":"2D");



            EditorGUILayout.BeginHorizontal();

            labelstyle.fontSize = 24;
            GUILayout.Label("Archimatix " + libtype + " Library");
            labelstyle.fontSize = 12;


            EditorGUILayout.Space();

            if (GUILayout.Button("Refresh"))
            {
                ArchimatixEngine.createLibraryFromJSONFiles();
            }
            EditorGUILayout.Space();

            if (showClass == 3)
            {
                if (GUILayout.Button("Switch to 2D"))
                {
                    showClass = 2;
                }
            }
            else
            {
                if (GUILayout.Button("Switch to 3D"))
                {
                    showClass = 3;
                }
            }

            EditorGUILayout.EndHorizontal();



            EditorGUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();



            // SEARCH FIELD

            GUILayout.Label("Search", richRightLabelStyle);

            if (string.IsNullOrEmpty(searchString))
            {
                searchString = "";
            }

            EditorGUI.BeginChangeCheck();
            GUI.SetNextControlName("TF_SEARCH");
            searchString = GUILayout.TextField(searchString, GUILayout.Width(130));
            if (EditorGUI.EndChangeCheck())
            {
                string[] words = searchString.Split(' ');
                ArchimatixEngine.library.filterResultsUsingSearch(new List <string>(words));

                lastTextField = "TF_SEARCH";
            }


            if (GUILayout.Button("x", GUILayout.Width(20)))
            {
                GUI.FocusControl("dummy");
                searchString = "";
                ArchimatixEngine.library.filteredResults = null;
            }


            GUILayout.FlexibleSpace();

            if (viewLayout == ViewLayout.EditList)
            {
                if (GUILayout.Button("Grid", GUILayout.Width(100)))
                {
                    viewLayout = ViewLayout.Grid;
                }
            }
            else
            {
                if (GUILayout.Button("Edit", GUILayout.Width(100)))
                {
                    viewLayout = ViewLayout.EditList;
                }
            }



            EditorGUILayout.EndHorizontal();
        }
Esempio n. 14
0
 private bool IsDefault(ViewLayout viewLayout)
 {
     return(viewLayout.Name == ViewLayoutList.DefaultLayoutName);
 }
Esempio n. 15
0
        public bool Export(CancellationToken cancellationToken, IProgressMonitor progressMonitor, ref IProgressStatus status, ViewInfo viewInfo, ViewLayout viewLayout, TextWriter writer, DsvWriter dsvWriter)
        {
            progressMonitor = progressMonitor ?? new SilentProgressMonitor();
            using (var bindingListSource = new BindingListSource(cancellationToken))
            {
                bindingListSource.SetViewContext(this, viewInfo);
                progressMonitor.UpdateProgress(status = status.ChangePercentComplete(5)
                                                        .ChangeMessage(Resources.ExportReportDlg_ExportReport_Writing_report));

                WriteDataWithStatus(progressMonitor, ref status, writer, bindingListSource, dsvWriter);
                if (progressMonitor.IsCanceled)
                {
                    return(false);
                }

                writer.Flush();
                progressMonitor.UpdateProgress(status = status.Complete());
            }
            return(true);
        }