Exemplo n.º 1
0
        /// <summary>
        /// The LinkDataSources method.
        /// </summary>
        private void LinkDataSources()
        {
            var linkList   = new List <DataSource>();
            var unlinkList = new List <DataSource>();

            foreach (ListViewItem item in lvTagSources.Items)
            {
                var dataSource = (DataSource)item.Tag;

                if (item.Checked)
                {
                    if (!CurrentSourceList.Any(s => dataSource.Id.Contains(s)))
                    {
                        linkList.Add(dataSource);
                    }
                }
                else
                {
                    if (CurrentSourceList.Any(s => dataSource.Id.Contains(s)))
                    {
                        unlinkList.Add(dataSource);
                    }
                }
            }

            if (linkList.Count > 0)
            {
                SelectedTag.Link(linkList);
            }

            if (unlinkList.Count > 0)
            {
                SelectedTag.Unlink(unlinkList);
            }
        }
Exemplo n.º 2
0
        void miCopySpectr_Click(object sender, EventArgs e)
        {
            try
            {
                if (Selected == null)
                {
                    MessageBox.Show(MainForm.MForm,
                                    Common.MLS.Get(MLSConst, "Выберите спектр который нужно перемерить"),
                                    Common.MLS.Get(MLSConst, "Предупреждение"),
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Warning
                                    );
                    return;
                }

                LastPath = SelectedTag.GetPath();

                /*DialogResult dr = MessageBox.Show(MainForm.MForm,
                 *      Common.MLS.Get(MLSConst, "Вы действительно хотите перемерить спектр: ") + LastPath,
                 *      Common.MLS.Get(MLSConst, "Осторожно!!!"),
                 *      MessageBoxButtons.YesNo,
                 *      MessageBoxIcon.Warning);
                 *
                 * if (dr == DialogResult.No)
                 *  return;*/

                string name = util.StringDialog.GetString(MainForm.MForm,
                                                          Common.MLS.Get(MLSConst, "Копирование пробы"),
                                                          Common.MLS.Get(MLSConst, "Введите имя для копии пробы:") + LastPath,
                                                          "", true);

                if (name == null)
                {
                    return;
                }

                Spectr sp       = new Spectr(LastPath);
                int    path_ind = LastPath.LastIndexOf('\\');
                string path     = LastPath.Substring(0, path_ind + 1);
                sp.SaveAs(path + name);
                ReLoadList();
            }
            catch (Exception ex)
            {
                Common.Log(ex);
            }
        }
Exemplo n.º 3
0
        private void Init()
        {
            SegmentItems.Children.Clear();
            SegmentItems.RowDefinitions.Clear();
            SegmentItems.ColumnDefinitions.Clear();
            SegmentItems.ColumnSpacing = this.SectionSpacing;
            SegmentItems.RowSpacing    = this.SectionSpacing;

            if (ItemsSource?.Any() != true)
            {
                return;
            }

            for (int i = 0; i < ItemsSource.Count; i++)
            {
                var item = ItemsSource[i];

                // Check if selected
                item.IsSelected = item.IsSelected || (SelectedTag != null && SelectedTag?.ToString() == item.Tag?.ToString());

                var view = GetView(item, i);

                // If selected we display content
                if (item.IsSelected)
                {
                    this.MainContent = item.Content;
                }

                if (SectionOrientation == StackOrientation.Horizontal)
                {
                    SegmentItems.ColumnDefinitions.Add(new ColumnDefinition()
                    {
                        Width = SectionHorizontalayout.Alignment == LayoutAlignment.Fill ? GridLength.Star : GridLength.Auto
                    });
                }
                else
                {
                    SegmentItems.RowDefinitions.Add(new RowDefinition()
                    {
                        Height = GridLength.Auto
                    });
                }

                SegmentItems.Children.Add(view);
            }
        }
Exemplo n.º 4
0
        private void ShowTags()
        {
            // We create a temp list for selection and mark the selected if exist already
            list = new ObservableList <SelectedTag>();
            foreach (RepositoryItemTag t in  WorkSpace.Instance.Solution.Tags)
            {
                SelectedTag st = new SelectedTag();
                st.Name        = t.Name;
                st.Description = t.Description;
                st.GUID        = t.Guid;

                if (mTags.Contains(t.Guid))
                {
                    st.Selected = true;
                }

                list.Add(st);
            }

            TagsGrid.DataSourceList = list;
        }
Exemplo n.º 5
0
        public async Task <IActionResult> ToggleSelectedTag([FromBody] TagIDModel t)
        {
            var user = await _userManager.GetUserAsync(HttpContext.User);

            var tag = _context.Tags.Find(t.TagID);

            if (tag != null)
            {
                var selectedTagRows = Util.GetSelectedTagMatches(user, tag, _context, Request);

                if (!selectedTagRows.Any())
                {
                    var selectedTag = new SelectedTag
                    {
                        Tag  = tag,
                        User = user,
                        IP   = user == null
                            ? Util.GetCurrentIPString(Request)
                            : null
                    };

                    await _context.AddAsync(selectedTag);
                }
                else
                {
                    foreach (SelectedTag row in selectedTagRows)
                    {
                        _context.Remove(row);
                    }
                }
                await _context.SaveChangesAsync();

                return(new OkObjectResult(t.TagID));
            }
            else
            {
                return(new BadRequestObjectResult(tag));
            }
        }
Exemplo n.º 6
0
        private View GetView(SegmentControlItem item)
        {
            // Check if item should be selected
            var isSelected =
                item.IsSelected ||
                (SelectedTag != null && SelectedTag?.ToString() == item.Tag?.ToString());

            Grid view = new Grid()
            {
                Padding = new Thickness(1)
            };

            if (UserBorder)
            {
                view.Children.Add(new BoxView
                {
                    BackgroundColor = isSelected ? SelectedBackgroundColor : SegmentBackgroundColor
                });
            }

            var label = new Label
            {
                Text              = item.Text,
                VerticalOptions   = LayoutOptions.Center,
                HorizontalOptions = TextAlignment,
                FontSize          = Device.GetNamedSize(FontSize, typeof(Label)),
                TextColor         = isSelected ? SelectedTextColor : SegmentTextColor,
                Margin            = TextMargin,
                InputTransparent  = true
            };

            if (!UserBorder)
            {
                view.RowDefinitions.Add(new RowDefinition()
                {
                    Height = GridLength.Auto
                });
                view.RowDefinitions.Add(new RowDefinition()
                {
                    Height = GridLength.Auto
                });

                BoxView boxView = new BoxView
                {
                    HeightRequest     = 4,
                    BackgroundColor   = Color.Transparent,
                    HorizontalOptions = LayoutOptions.Fill,
                    Color             = isSelected ? SelectedBackgroundColor : Color.Transparent
                };

                Grid.SetRow(boxView, 1);
                Grid.SetRow(label, 0);

                view.Children.Add(boxView);
            }

            view.Children.Add(label);

            item.IsSelected = isSelected;

            if (item.IsSelected)
            {
                this.MainContent = item.Content;
            }

            view.GestureRecognizers.Add(new TapGestureRecognizer()
            {
                Command          = TapGestureCommand,
                CommandParameter = item
            });

            return(view);
        }
Exemplo n.º 7
0
        void miRemoveFolder_Click(object sender, EventArgs e)
        {
            try
            {
                if (SelectedTag == null || SelectedTag.SpName != null)
                {
                    return;
                }
                if (Selected.Nodes.Count != 0)
                {
                    return;
                }
                DialogResult dr = MessageBox.Show(MainForm.MForm,
                                                  Common.MLS.Get(MLSConst, "Вы действительно хотите удалить папку: ") + SelectedTag.GetPath(),
                                                  Common.MLS.Get(MLSConst, "Осторожно!!!"),
                                                  MessageBoxButtons.YesNo,
                                                  MessageBoxIcon.Warning);

                if (dr == DialogResult.No)
                {
                    return;
                }

                SelectedTag.Folder.DeleteFolder();

                ReLoadList();
            }
            catch (Exception ex)
            {
                Common.Log(ex);
            }
        }