Exemplo n.º 1
0
        private void ShowMarkPicturesButton_Click(object sender, RoutedEventArgs e)
        {
            if (GridViewer.ViewType == GalleryViewType.Marked)
            {
                return;
            }

            var galleries = (CurrentGallery != null ? new[] { CurrentGallery } : Container.Default.GetExportedValues <Gallery>()).Select(x => x.GalleryName).ToArray();

            var online_mark_feature = CurrentGallery?.Feature <IGalleryMark>();

            var source = new Func <IEnumerable <GalleryItem> >(() => (online_mark_feature?.GetMarkedGalleryItem()) ?? LocalDBContext.Instance.ItemMarks
                                                               .Select(x => new { gallery = galleries.FirstOrDefault(y => y == x.Item.GalleryName), gallery_item = x })
                                                               .Where(x => x.gallery != null)
                                                               .ToArray()//avoid SQL.
                                                               .Select(x => x.gallery_item.Item.ConvertToNormalModel()));


            GalleryTitle        = (CurrentGallery != null ? $"{CurrentGallery.GalleryName}的" : "") + (online_mark_feature != null?"在线":"本地") + "收藏列表";
            GridViewer.ViewType = GalleryViewType.Marked;
            GridViewer.ClearGallery();
            GridViewer.Gallery = null;
            GridViewer.LoadableSourceFactory = source;

            CloseLeftPanel();
        }
Exemplo n.º 2
0
        public void ApplyGallery(Gallery gallery, IEnumerable <string> keywords = null)
        {
            Func <IEnumerable <GalleryItem> > items_source_creator;

            if (keywords?.Any() ?? false)
            {
                GridViewer.ViewType  = GalleryViewType.SearchResult;
                items_source_creator = new Func <IEnumerable <GalleryItem> >(() => gallery.TryFilterIfNSFWEnable(gallery.Feature <IGallerySearchImage>().SearchImages(keywords).MakeMultiThreadable()));
                GalleryTitle         = $"{gallery.GalleryName} ({string.Join(" ", keywords)})";
                ShowReturnButton     = true;
            }
            else
            {
                GridViewer.ViewType  = GalleryViewType.Main;
                items_source_creator = new Func <IEnumerable <GalleryItem> >(() => gallery.TryFilterIfNSFWEnable(gallery.GetMainPostedImages().MakeMultiThreadable()));
                GalleryTitle         = gallery.GalleryName;
                ShowReturnButton     = false;
            }

            CurrentGallery = gallery;

            GridViewer.ClearGallery();
            GridViewer.Gallery = gallery;
            GridViewer.LoadableSourceFactory = items_source_creator;

            UpdateAccountButtonText();
        }
Exemplo n.º 3
0
        public async void ApplyGallery(Gallery gallery, IEnumerable <string> keywords = null)
        {
            Func <IEnumerable <GalleryItem> > items_source_creator;

            if (keywords?.Any() ?? false)
            {
                GridViewer.ViewType  = GalleryViewType.SearchResult;
                items_source_creator = new Func <IEnumerable <GalleryItem> >(() => gallery.TryFilterIfNSFWEnable(gallery.Feature <IGallerySearchImage>().SearchImages(keywords).MakeMultiThreadable()));
                GalleryTitle         = $"{gallery.GalleryName} ({string.Join(" ", keywords)})";
                ShowReturnButton     = true;
            }
            else
            {
                GridViewer.ViewType  = GalleryViewType.Main;
                items_source_creator = new Func <IEnumerable <GalleryItem> >(() => gallery.TryFilterIfNSFWEnable(gallery.GetMainPostedImages().MakeMultiThreadable()));
                GalleryTitle         = gallery.GalleryName;
                ShowReturnButton     = false;
            }

            CurrentGallery = gallery;
            SettingManager.LoadSetting <GlobalSetting>().RememberLastViewedGalleryName = gallery.GalleryName;

            GridViewer.ClearGallery();
            GridViewer.Gallery = gallery;
            GridViewer.LoadableSourceFactory = items_source_creator;

            if (gallery.SupportFeatures.HasFlag(GallerySupportFeature.Account))
            {
                await TryAutoLogin(gallery);
            }

            UpdateAccountButtonText();

            Log.Info($"Switch main page gallery:{gallery.GalleryName}");
        }
Exemplo n.º 4
0
        private void JumpConfirmButton_Click(object sender, RoutedEventArgs e)
        {
            PageJumpPopup.IsOpen = false;

            if (!int.TryParse(JumpPageInput.Text, out var page))
            {
                return;
            }

            GridViewer.ChangePage(page);
        }
 private void GridViewer_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
 {
     if (IsFileOpen && (Keyboard.Modifiers & ModifierKeys.Control) > 0)
     {
         var p     = Mouse.GetPosition(GridViewer);
         var scale = _bitmap.Width / GridViewer.ActualWidth;
         p.X *= scale;
         p.Y *= scale;
         GridViewer.SelectTileAt((int)p.X, (int)p.Y);
         GridViewer.UpdateGrid();
     }
 }
Exemplo n.º 6
0
        /// <summary>
        /// Spawn dataset viewer for the live outputs
        /// </summary>
        public void SpawnDatasetViewer()
        {
            Console.WriteLine("Spawning Dataset Viewer\n");

            // Intialise the SDS object for the live view
            DataSetToViewLive = SDSCreator.CreateSDSInMemory(true);

            DataSetToViewLive.Metadata["VisualHints"] =
                "\"Biomass density\"(Longitude,Latitude) Style:Colormap; Palette:#000040=0,Blue=0.1,Green=0.2661,#FA8000=0.76395,Red; Transparency:0.38";

            // Start viewing
            GridViewer.AsynchronousView(ref DataSetToViewLive, "");
        }
 private void DisplayBitmap()
 {
     try
     {
         _zoom = 1.0;
         UpdateZoom();
         BitmapViewer.DisplayBitmap(_bitmap);
         GridViewer.CreateGrid(_bitmap);
     }
     catch (Exception e)
     {
         ShowError(e);
     }
 }
Exemplo n.º 8
0
        /* Handle E-R Grid View */

        private void eRGridToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var gv = new GridViewer(bs);

            /* Keep track of changes */
            myChart.EntityChanged += EntityChangedByEditor;
            bs.PositionChanged    += Bs_PositionChanged;
            gv.FormClosed         += EntityChangedByEditor;
            gv.FormClosed         += HandleGridViewClose;

            gv.Show(this);

            eRGridToolStripMenuItem.Enabled = false;
        }
Exemplo n.º 9
0
        public async Task GridViewerExcludeTest(string expr)
        {
            await HostScript.InitializeAsync();

            var e      = Substitute.For <IDataObjectEvaluator>();
            var viewer = new GridViewer(Services.GetService <ICoreShell>(), e);

            viewer.CanView(null).Should().BeFalse();
            var session = HostScript.Session;

            await session.ExecuteAsync($"x <- {expr}");

            var value = await session.EvaluateAndDescribeAsync("x", AllFields, null);

            viewer.CanView(value).Should().BeFalse();
        }
Exemplo n.º 10
0
        public async Task GridViewerExcludeTest(string expr)
        {
            var e      = Substitute.For <IDataObjectEvaluator>();
            var viewer = new GridViewer(_aggregator, e);

            viewer.CanView(null).Should().BeFalse();

            using (var hostScript = new RHostScript(_sessionProvider)) {
                var session = hostScript.Session;

                await session.ExecuteAsync($"x <- {expr}");

                var value = await session.EvaluateAndDescribeAsync("x", AllFields, null);

                viewer.CanView(value).Should().BeFalse();
            }
        }
        public void ShowExecutionPlan(DataTable tablePlan)
        {
            var control = new GridViewer();

            control.AttachDataSource(tablePlan);

            var colRows = control.Columns["rows"];

            if (colRows != null)
            {
                var ruleRows = control.FormatRules.AddDataBar(colRows);
                (ruleRows.Rule as FormatConditionRuleDataBar).PredefinedName = "Blue Gradient";
            }

            var colFiltered = control.Columns["filtered"];

            if (colFiltered != null)
            {
                var ruleFiltered = control.FormatRules.AddDataBar(colFiltered);
                (ruleFiltered.Rule as FormatConditionRuleDataBar).PredefinedName = "Blue Gradient";
            }

            var colExtra = control.Columns["Extra"];

            if (colExtra != null)
            {
                control.Columns.Remove(colExtra);
            }

            control.ColumnAutoWidth  = true;
            control.PreviewFieldName = "Extra";

            control.Load += (s, e) =>
            {
                var ctrl = s as Control;
                if (ctrl.Parent is XtraDialogForm frm)
                {
                    frm.MakeXtraDialogFormResizeableWithDelay();
                }
            };

            XtraDialog.Show(_Owner, control, "Execution plan", MessageBoxButtons.OK);
        }
        private void MoveGrid_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            var moveGridCommand = e.Command as MoveGridCommand;

            if (moveGridCommand != null)
            {
                GridViewer.OffsetX += moveGridCommand.X;
                GridViewer.OffsetY += moveGridCommand.Y;
            }
            var resetGridCommand = e.Command as ResetGridCommand;

            if (resetGridCommand != null)
            {
                GridViewer.OffsetX = 0;
                GridViewer.OffsetY = 0;
                GridViewer.ClearSelection();
            }
            GridViewer.UpdateGrid();
        }
Exemplo n.º 13
0
        public MainForm()
        {
            InitializeComponent();
            // Load global settings
            this.mGlobalSettings = new GlobalSettings();
            this.mLocalSettings  = LocalSettings.GetInstance();

            // Restore the size
            Size = mLocalSettings.m_size;
            if ((Size.Height < 100) || (Size.Width < 200))
            {
                Size lsize = new Size();
                lsize.Height = 500;
                lsize.Width  = 800;

                this.Size = lsize;
            }

            //register the viewer manager classes
            //qq there must be a better way of doing this, it seems a bit
            //   odd. Could use reflection. Might be a little slow or have
            //   unexpected side-effects. It's nice to be able to control
            //   the order the tabs appear in, too.
            ViewTabActions.Tag  = ActionsViewer.InitialiseViewer(this);
            ViewTabXML.Tag      = XMLViewer.InitialiseViewer(this);
            ViewTabFlat.Tag     = FlatViewer.InitialiseViewer(this);
            ViewTabImg.Tag      = ImageViewer.InitialiseViewer(this);
            ViewTabBump.Tag     = BumpViewer.InitialiseViewer(this);
            ViewTabSteering.Tag = SteeringViewer.InitialiseViewer(this);
            ViewTabCamera.Tag   = CameraViewer.InitialiseViewer(this);
            ViewTabGrid.Tag     = GridViewer.InitialiseViewer(this);
            ViewTab3D.Tag       = ThreeDeeViewer.InitialiseViewer(this);
            ViewTabVRAM.Tag     = VRAMViewer.InitialiseViewer(this);
            ViewTab3dEditor.Tag = ThreeDeeEditor.InitialiseViewer(this);
            ViewTabHistory.Tag  = HistoryViewer.InitialiseViewer(this);

            //auto-load last level
            if (mLocalSettings.LastOpenedFile != null)
            {
                LoadInternal(mLocalSettings.LastOpenedType, mLocalSettings.LastOpenedFile);
            }
        }
        public void bind(params string[] dependants)
        {
            var data = GetGridDataToBind();

            GridViewer.DataSource = data;
            GridViewer.DataBind();
            foreach (ResDetailsHeadingEntity item in _postBackRepository.GetList())
            {
                for (int i = 0; i < GridViewer.Rows.Count; i++)
                {
                    GridViewer.Rows[i].Cells[item.index].HorizontalAlign = item.Alignment;
                }

                if (GridViewer.HeaderRow != null)
                {
                    GridViewer.HeaderRow.Cells[item.index].Text = S1 + item.SortExpression + S2 + item.Text + S3;
                }
            }
            DataItemsCount = data.Count;
        }
Exemplo n.º 15
0
        private void ShowHistoryButton_Click(object sender, RoutedEventArgs e)
        {
            if (GridViewer.ViewType == GalleryViewType.History)
            {
                return;
            }

            var galleries = (CurrentGallery != null ? new[] { CurrentGallery } : Container.Default.GetExportedValues <Gallery>()).Select(x => x.GalleryName).ToArray();

            var source = new Func <IEnumerable <GalleryItem> >(() => LocalDBContext.Instance.VisitRecords.OrderByDescending(x => x.LastVisitTime).Select(x => x.GalleryItem)
                                                               .Select(x => new { gallery = galleries.FirstOrDefault(y => y == x.GalleryName), gallery_item = x })
                                                               .Where(x => x.gallery != null)
                                                               .ToArray()//avoid SQL.
                                                               .Select(x => x.gallery_item.ConvertToNormalModel()));


            GalleryTitle        = "历史浏览记录";
            GridViewer.ViewType = GalleryViewType.History;
            GridViewer.ClearGallery();
            GridViewer.Gallery = null;
            GridViewer.LoadableSourceFactory = source;

            CloseLeftPanel();
        }
Exemplo n.º 16
0
 private void RefreshButton_Click(object sender, RoutedEventArgs e)
 {
     GridViewer.RefreshItem();
 }
Exemplo n.º 17
0
        public virtual void EndInit()
        {
            //==============================================
            //              创建过滤条件
            //==============================================
            AllFilters = new List <FilterControlBase>();

            foreach (FilterDefinition fd in FilterDefinitions)
            {
                FilterControlBase fc = (FilterControlBase)Activator.CreateInstance(fd.FilterControlType, true);
                fc.DataPropertyName = fd.DataPropertyName;
                fc.Title            = fd.Title;
                if (!fd.FilterOperator.IsNullOrWhiteSpace())
                {
                    fc.FilterOperator = fd.FilterOperator;
                }
                fc.Parent = pFilters;
                AllFilters.Add(fc);
            }
            //==============================================
            //                  创建表格
            //==============================================

            //空白组默认设置为页面标题
            ColumnDefinitions.ForEach(c => { if (c.GroupName.IsNullOrWhiteSpace())
                                             {
                                                 c.GroupName = Text;
                                             }
                                      });

            //创建Tab页
            tabContainer.TabPages.Clear();
            var queryGroups = ColumnDefinitions.Select(c => c.GroupName).Distinct().ToArray();

            foreach (string g in queryGroups)
            {
                tabContainer.TabPages.Add(g);
                //创建表格
                GridViewer dgv = new GridViewer();

                //添加列
                foreach (var col in ColumnDefinitions.Where(c => c.GroupName == g))
                {
                    dgv.CreateColumn(col.ColumnType, col.Title, col.DataPropertyName, col.Name, col.Width, col.SortMode, col.SortOrder, col.Visible, col.Index, col.Frozen);
                }
                dgv.Dock   = DockStyle.Fill;
                dgv.Parent = tabContainer.TabPages[tabContainer.TabCount - 1];

                //TODO: 暂不支持排序
            }

            //只有一个表格则不显示TabControl
            if (tabContainer.TabPages.Count == 1)
            {
                Control dgv = tabContainer.TabPages[0].Controls[0];
                dgv.Parent = this;
                Controls.Remove(tabContainer);
                tabContainer = null; //dispose
                dgv.BringToFront();
            }

            //所有表格
            AllGridView = this.FindChildControl(c => c is DataGridView).OfType <DataGridView>().ToList();

            //==============================================
            //               生成Select语句
            //==============================================
            var query = from dgv in AllGridView
                        from col in dgv.Columns.OfType <DataGridViewColumn>()
                        where !col.DataPropertyName.IsNullOrWhiteSpace()
                        select col.DataPropertyName;

            List <string> fields = new List <string>();

            foreach (string col in query.Distinct())
            {
                fields.Add("[{0}] AS '{1}'".FormatWith(col.Replace(".", "].["), col));
            }

            Sentence_Select = string.Join(", ", fields.ToArray());

            //==============================================
            //          关联表格的选择及滚动
            //==============================================
            if (AllGridView.Count > 1)
            {
                DataGridView dgv = AllGridView[0];

                for (int i = 1; i < AllGridView.Count; i++)
                {
                    DataGridView tmp = AllGridView[i];
                    dgv.SyncSelectedRowIndex(tmp);
                    dgv.SyncRowHeight(tmp);
                    dgv.SyncVerticalScroll(tmp);
                }
            }

            //==============================================
            //                  注册表格事件
            //==============================================
            //注册事件
            AllGridView.ForEach(d =>
            {
                d.ColumnHeaderMouseClick += ColumnHeaderMouseClick;
                d.SelectionChanged       += SelectionChanged;
                d.CellDoubleClick        += CellDoubleClick;
            });
        }
Exemplo n.º 18
0
        public async Task GridViewerDimLengthTest(string cast)
        {
            var e      = Substitute.For <IDataObjectEvaluator>();
            var viewer = new GridViewer(Services.GetService <ICoreShell>(), e);

            viewer.CanView(null).Should().BeFalse();

            await HostScript.InitializeAsync();

            var session = HostScript.Session;

            await session.ExecuteAsync($"x <- {cast}(c())");

            var value = await session.EvaluateAndDescribeAsync("x", AllFields, null);

            viewer.CanView(value).Should().BeFalse();

            await session.ExecuteAsync($"x <- {cast}(1)");

            value = await session.EvaluateAndDescribeAsync("x", AllFields, null);

            viewer.CanView(value).Should().BeFalse();

            value = await session.EvaluateAndDescribeAsync("dim(x) <- 1", AllFields, null);

            value = await session.EvaluateAndDescribeAsync("x", AllFields, null);

            viewer.CanView(value).Should().BeFalse();

            value = await session.EvaluateAndDescribeAsync("dim(x) <- c(1, 1)", AllFields, null);

            value = await session.EvaluateAndDescribeAsync("x", AllFields, null);

            viewer.CanView(value).Should().BeTrue();

            value = await session.EvaluateAndDescribeAsync("dim(x) <- c(1, 1, 1)", AllFields, null);

            value = await session.EvaluateAndDescribeAsync("x", AllFields, null);

            viewer.CanView(value).Should().BeFalse();

            await session.ExecuteAsync($"x <- {cast}(1:100)");

            value = await session.EvaluateAndDescribeAsync("x", AllFields, null);

            viewer.CanView(value).Should().BeTrue();

            await session.ExecuteAsync($"dim(x) <- 100");

            value = await session.EvaluateAndDescribeAsync("x", AllFields, null);

            viewer.CanView(value).Should().BeTrue();

            await session.ExecuteAsync($"dim(x) <- c(10, 10)");

            value = await session.EvaluateAndDescribeAsync("x", AllFields, null);

            viewer.CanView(value).Should().BeTrue();

            await session.ExecuteAsync($"dim(x) <- c(10, 5, 2)");

            value = await session.EvaluateAndDescribeAsync("x", AllFields, null);

            viewer.CanView(value).Should().BeFalse();
        }
Exemplo n.º 19
0
        private void Form1_Load(object sender, EventArgs e)
        {
            dbFileName        = "racion.sqlite";
            lbStatusText.Text = "Disconnected";

            #region Connect
            if (!File.Exists(dbFileName))
            {
                MessageBox.Show("Please, create DB and blank table (Push \"Create\" button)");
            }

            try
            {
                m_dbConn = new SQLiteConnection("Data Source=" + dbFileName + ";Version=3;");
                m_dbConn.Open();
                m_sqlCmd.Connection = m_dbConn;

                lbStatusText.Text = "Connected";
            }
            catch (SQLiteException ex)
            {
                lbStatusText.Text = "Disconnected";
                MessageBox.Show("Error: " + ex.Message);
            }
            #endregion Connect

            string sql = "SELECT * FROM ingr_tbl";
            // Создаем объект DataAdapter
            adapter = new SQLiteDataAdapter(sql, m_dbConn);
            // Создаем объект Dataset

            // Заполняем Dataset
            adapter.Fill(ds);
            //Очистка грида
            GridViewer.Rows.Clear();
            GridViewer.Columns.Clear();
            GridViewer.Refresh();
            // Отображаем данные
            GridViewer.DataSource = ds.Tables[0];

            int i = 0;
            GridViewer.AllowUserToOrderColumns = false;

            #region Стиль ячейки
            var cell = new DataGridViewCheckBoxCell()
            {
                TrueValue  = "true",
                FalseValue = "false",
            };
            cell.Style.NullValue = false;
            //this.dataGridView1.Rows[2].Cells[0] = cell;
            #endregion Стиль ячейки

            foreach (DataGridViewColumn col in GridViewer.Columns)
            {
                if (i > 3)
                {
                    //addCheckBoxCell(GridViewer.Rows[0], GridViewer.Rows[0].Cells[i].Value.ToString(),i);
                    //(GridViewer.Rows[0].Cells[i] as DataGridViewCheckBoxCell).Value = true;
                    //(GridViewer[i, 1]. DataGridViewCheckBoxCell).Visible = true;
                }
                col.HeaderCell.Value = ds.Tables[0].Rows[1][i];                       //заголовки
                col.SortMode         = DataGridViewColumnSortMode.NotSortable;        //Сортировка
                col.AutoSizeMode     = DataGridViewAutoSizeColumnMode.DisplayedCells; //Поджать ширину
                if (i == 0)
                {
                    col.Visible = false;
                }
                i++;
            }
        }
Exemplo n.º 20
0
        public async Task GridViewerDimLengthTest(string cast)
        {
            var e      = Substitute.For <IDataObjectEvaluator>();
            var viewer = new GridViewer(_aggregator, e);

            viewer.CanView(null).Should().BeFalse();

            using (var hostScript = new RHostScript(_sessionProvider)) {
                var session = hostScript.Session;

                await session.ExecuteAsync($"x <- {cast}(c())");

                var value = await session.EvaluateAndDescribeAsync("x", AllFields, null);

                viewer.CanView(value).Should().BeFalse();

                await session.ExecuteAsync($"x <- {cast}(1)");

                value = await session.EvaluateAndDescribeAsync("x", AllFields, null);

                viewer.CanView(value).Should().BeFalse();

                value = await session.EvaluateAndDescribeAsync("dim(x) <- 1", AllFields, null);

                value = await session.EvaluateAndDescribeAsync("x", AllFields, null);

                viewer.CanView(value).Should().BeFalse();

                value = await session.EvaluateAndDescribeAsync("dim(x) <- c(1, 1)", AllFields, null);

                value = await session.EvaluateAndDescribeAsync("x", AllFields, null);

                viewer.CanView(value).Should().BeTrue();

                value = await session.EvaluateAndDescribeAsync("dim(x) <- c(1, 1, 1)", AllFields, null);

                value = await session.EvaluateAndDescribeAsync("x", AllFields, null);

                viewer.CanView(value).Should().BeFalse();

                await session.ExecuteAsync($"x <- {cast}(1:100)");

                value = await session.EvaluateAndDescribeAsync("x", AllFields, null);

                viewer.CanView(value).Should().BeTrue();

                await session.ExecuteAsync($"dim(x) <- 100");

                value = await session.EvaluateAndDescribeAsync("x", AllFields, null);

                viewer.CanView(value).Should().BeTrue();

                await session.ExecuteAsync($"dim(x) <- c(10, 10)");

                value = await session.EvaluateAndDescribeAsync("x", AllFields, null);

                viewer.CanView(value).Should().BeTrue();

                await session.ExecuteAsync($"dim(x) <- c(10, 5, 2)");

                value = await session.EvaluateAndDescribeAsync("x", AllFields, null);

                viewer.CanView(value).Should().BeFalse();
            }
        }