private void OnBrowse(object sender, RoutedEventArgs e)
        {
            Microsoft.Win32.OpenFileDialog dialog = new Microsoft.Win32.OpenFileDialog();

            dialog.InitialDirectory = System.Environment.GetFolderPath(Environment.SpecialFolder.MyPictures);
            dialog.DefaultExt = "Image files (jpg, gif, png)";
            dialog.Filter = "Image files|*.jpg; *.jpeg; *.gif; *.png;";

            Nullable<bool> result = dialog.ShowDialog();

            if (result.Value == true)
            {
                string directory = System.IO.Path.GetDirectoryName(dialog.FileName);
                images = Directory.EnumerateFiles(directory).Where
                    (
                        filename => filename.EndsWith(".jpg")
                        || filename.EndsWith(".jpeg")
                        || filename.EndsWith(".gif")
                        || filename.EndsWith(".png")
                    )
                    .ToList<string>();

                OpenImage(images.IndexOf(dialog.FileName));
            }
        }
        public DetectionButtonsControl()
        {
            double imageWidth = 10;
            double imageHeight = 10;
            double buttonWidth;
            double smallDelimiter = 6 / 100 * imageWidth;
            double largeDelimiter = 8 / 100 * imageWidth;
            InitializeComponent();
            Button startButton = new Button();
            Button nextButton = new Button();
            Button backButton = new Button();
            Button stopButton = new Button();
            this.ButtonsStackPanel.Children.Add(startButton);
            this.ButtonsStackPanel.Children.Add(nextButton);
            this.ButtonsStackPanel.Children.Add(backButton);
            this.ButtonsStackPanel.Children.Add(stopButton);

            List<Button> buttons = new List<Button>();
            buttonWidth = (imageWidth - 2 * smallDelimiter - (buttons.Count - 1) * largeDelimiter) / buttons.Count;
            foreach (Button b in buttons)
            {

                if (buttons.IndexOf(b) == 1)
                {
                    //b.xPos = imageWidth + smallDelimiter;
                }
                else
                {
                    //b.xPos = imageWidth + largeDelimiter;
                }
            }
        }
Пример #3
0
        public IEnumerable<string> ConvertTagsToHtml(string[] lines)
        {
            var tables = new Dictionary<string, List<string>>();
            var lastLine = "";
            var tableCount = 0;

            var list = new List<string>();
            foreach (var line in lines)
            {

                if (line.StartsWith("<F>") && line.Length > 3)
                    list.Add(string.Format("<span>{0}</span>", line[3].ToString().PadLeft(lines.Max(x => x.Length), line[3])));
                if (line.StartsWith("<T>"))
                    list.Add(string.Format("<B>{0}</B>", RemoveTag(line)));
                if (line.StartsWith("<C") && line.Length > 3 && (line[2] == '>' || char.IsDigit(line[2])))
                    list.Add(string.Format("<span>{0}</span>", RemoveTag(line)));
                if (line.StartsWith("<L") && line.Length > 3 && (line[2] == '>' || char.IsDigit(line[2])))
                    list.Add(string.Format("<span>{0}</span>", RemoveTag(line)));
                if (line.StartsWith("<EB>"))
                    list.Add("<B>");
                if (line.StartsWith("<DB>"))
                    list.Add("</B>");

                if (line.StartsWith("<J") && line.Length > 3 && (line[2] == '>' || char.IsDigit(line[2])))
                {
                    if (!lastLine.StartsWith("<J"))
                    {
                        tableCount++;
                        list.Add("tbl" + tableCount);
                    }

                    var tableName = "tbl" + tableCount;
                    if (!tables.ContainsKey(tableName))
                        tables.Add(tableName, new List<string>());
                    tables[tableName].Add(RemoveTag(line));
                }

                if (!line.Contains("<") && !string.IsNullOrEmpty(line.Trim()))
                    list.Add(line);

                lastLine = line;
            }

            foreach (var table in tables)
            {
                list.InsertRange(list.IndexOf(table.Key), GetTableLines(table.Value, Printer.CharsPerLine));
                list.Remove(table.Key);
            }

            for (int i = 0; i < list.Count; i++)
            {
                list[i] = list[i].TrimEnd();
                if ((!list[i].ToLower().EndsWith("<BR>") && RemoveTag(list[i]).Trim().Length > 0) || list[i].Trim().Length == 0)
                    list[i] += "<BR>";
                list[i] = list[i].Replace(" ", "&nbsp;");
            }

            return list;
        }
        internal void SetComponentLinks(IEnumerable<AbstractEndpoint.IAbstractComponentLink> componentLinks)
        {
            var links = new List<ComponentsOrderingViewModel>();

            var setOrder = new Action(() =>
                {
                    var worker = new BackgroundWorker();
                    worker.DoWork += (e, s) =>
                    {
                        foreach (var cl in links.AsEnumerable().Reverse())
                        {
                            cl.Link.Order = links.IndexOf(cl) + 1;
                        }
                    };
                    worker.RunWorkerAsync();
                });
            foreach (var cl in componentLinks.OrderBy(x => x.Order))
            {
                var vm = new ComponentsOrderingViewModel { Link = cl };
                links.Add(vm);
                vm.UpCommand = new RelayCommand(
                    () =>
                    {
                        var prevIndex = links.IndexOf(vm);
                        links.Remove(vm);
                        links.Insert(prevIndex - 1, vm);
                        this.ComponentList.ItemsSource = null;
                        this.ComponentList.ItemsSource = links;
                        this.ComponentList.SelectedItem = vm;
                        setOrder();
                    }, () => links.IndexOf(vm) > 0);
                vm.DownCommand = new RelayCommand(
                    () =>
                    {
                        var prevIndex = links.IndexOf(vm);
                        links.Remove(vm);
                        links.Insert(prevIndex + 1, vm);
                        this.ComponentList.ItemsSource = null;
                        this.ComponentList.ItemsSource = links;
                        this.ComponentList.SelectedItem = vm;
                        setOrder();
                    }, () => links.IndexOf(vm) < links.Count - 1);
            }
            this.ComponentList.ItemsSource = links;
        }
Пример #5
0
 public int Save(Score score)
 {
     TheScores.Add(score);
     TheScores = TheScores.OrderBy(s => s.ElapsedTime).ToList();
     var position = TheScores.IndexOf(score) + 1;
     File.WriteAllText(scoresPath, JsonConvert.SerializeObject(TheScores), Encoding.UTF8);
     WriteLeaderBoard(position);
     return position;
 }
Пример #6
0
        protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            newItem = GlobalVars.item;
            GlobalVars.item = null;
            Item item = Database_Functions.GetItem(newItem.Item_ID);
            this.item_name.Text = item.Title;
            this.textBlock_description.Text = item.Description;
            textBlock_total.Text = Database_Functions.GetItemCost(item.ID).ToString("c");
            IList<Transaction> transactions = Database_Functions.GetItemTransactions(item.ID);
            IList<TextBlock> names = new List<TextBlock>();
            IList<TextBlock> amounts = new List<TextBlock>();
            IList<string> names_only = new List<string>();
            IList<Decimal> amounts_only = new List<Decimal>();
            int index = -1;

            foreach (Transaction t in transactions)
            {
                TextBlock name = new TextBlock();
                name.FontSize = 20;
                name.Margin = new Thickness(9, 64, 0, 0);
                name.Text = Database_Functions.GetMember((int)t.MemberID).Name;
                TextBlock amount = new TextBlock();
                amount.FontSize = 28;
                amount.Margin = new Thickness(9, 0, 0, 0);
                amounts_only.Add(t.Amount);
                if (t.Amount < 0)
                    amount.Text = "-" + (t.Amount * -1).ToString("c");
                else
                    amount.Text = t.Amount.ToString("c");
                if (!names_only.Contains(name.Text))
                {
                    names_only.Add(name.Text);
                    names.Add(name);
                    ContentPanel.Children.Add(name);
                    amounts.Add(amount);
                    ContentPanel.Children.Add(amount);
                }
                else
                {
                    index = names_only.IndexOf(name.Text);
                    Decimal temp = amounts_only[index] + t.Amount;
                    if (temp < 0)
                        amounts[index].Text = "-" + (temp * -1).ToString("c");
                    else
                        amounts[index].Text = temp.ToString("c");
                }
            }
        }
Пример #7
0
 public Classement(List<Joueur> classement)
 {
     InitializeComponent();
     int i = 0;
     int k = 1;
     foreach (Joueur j in classement)
     {
         classementPanel.Children.Add(new JoueurClassement(j,i+1));
         int index = classement.IndexOf(j);
         if (index+1 < classement.Count && classement[index + 1].Points < j.Points)
             i=k;
         k++;
     }
 }
Пример #8
0
        public Messages()
        {
            _messages = CMClient.Instance().LastDisplayContext.Messages;

            Message message = _messages.FirstOrDefault(item => item.Id == CMClient.Instance().LastDisplayContext.InitialMessageId);
            if(message != null)
            {
                _currentMessage = _messages.IndexOf(message);
            }

            DataContext = this;
            InitializeComponent();

            ShowMessage();
        }
 private List<Models.ResultListNode> AddListRessultNode(List<HtmlNode> listNode)
 {
     List<Models.ResultListNode> list = new List<Models.ResultListNode>();
     try
     {
         foreach (var item in listNode)
         {
             list.Add(new Models.ResultListNode { NameNode = "[" + listNode.IndexOf(item) + "] " + item.Name, InerText = item.InnerText, InerHtml = item.OuterHtml, Items = AddListRessultNode(item.ChildNodes.ToList()) });
             AddListRessultNode(item.ChildNodes.ToList());
         }
     }
     catch
     {
     
     }
    
     return list;
 }
Пример #10
0
 public void fill()
 {
     LocalList.ItemsSource = null;
     if ((Application.Current as App).estado == Estado.accepted && (Application.Current as App).state == WatcherState.active)
     {
         geolist = geolist.OrderBy(s => s.GetDistanceTo(watcher.Position.Location)).ToList();
         loc = loc.OrderBy(i => geolist.IndexOf(new GeoCoordinate() { Latitude = i.latLocal, Longitude = i.longLocal })).ToList();
         for (int i = 0; i < geolist.ToArray().Length; i++)
         {
             loc.ToArray()[i].distance = "~" + Math.Round((geolist.ToArray()[i].GetDistanceTo(watcher.Position.Location) / 1000), 1) + "km";
         }
         LocalList.ItemsSource = loc;
     }
     else
     {
         LocalList.ItemsSource = loc;
     }
 }
 private void UploadImages()
 {
     List<int> delImage = new List<int>();
     ListingManager listManager = new ListingManager();
     for(int i = 0; i<imageSource.Count; i++)
     {
         if (imageSource[i] == " " || imageSource[i] == "")
         {
             delImage.Add(i);
             listManager.EditListingImage(imageID[i],imageCaptions[i]);
         }
     }
     for (int i = delImage.Count - 1; i >= 0; i--)
     {
         if (delImage.IndexOf(i) != -1)
         {
             imageSource.RemoveAt(i);
             imageCaptions.RemoveAt(i);
         }
     }
         for (int i = 0; i < imageSource.Count; i++)
         {
             Console.WriteLine(i + " New " + imageID[i] + " - " + imageSource[i] + " with " + imageCaptions[i] + " of " + imageSource.Count);
         }
     Overlays.Listings.LoadingOverlay uploadImages = new Overlays.Listings.LoadingOverlay(propertyID, imageSource, imageCaptions);
     uploadImages.Owner = Framework.UI.Controls.Window.GetWindow(this);
     uploadImages.Show();
     (this.Tag as AgentWindow).HideEditListingView();
     (this.Tag as AgentWindow).ShowListingsView();
     ClearView();
 }
Пример #12
0
        /// <summary>
        /// This method is called by a splitter when it is dragged
        /// </summary>
        /// <param name="splitter">Dragged splitter</param>
        /// <param name="delta"></param>
        void splitter_DragDelta(object sender, DragDeltaEventArgs e)
        {
            ResizingPanelSplitter splitter = e.Source as ResizingPanelSplitter;
            int i = 0;

            //Compute the list of visible children
            List<FrameworkElement> visibleChildren = new List<FrameworkElement>();
            for (i = 0; i < VisualChildrenCount; i++)
            {
                FrameworkElement child = GetVisualChild(i) as FrameworkElement;

                IDockableControl dockableControl = child as IDockableControl;
                if (dockableControl != null &&
                    !dockableControl.IsDocked)
                {
                    if (i == VisualChildrenCount - 1 &&
                        i > 0)
                    {
                        //remove the last splitter added
                        if (visibleChildren.Count > 0 &&
                            visibleChildren.Last<FrameworkElement>() is ResizingPanelSplitter)
                            visibleChildren.RemoveAt(visibleChildren.Count - 1);
                    }
                    else if (i < VisualChildrenCount - 1)
                    {
                        //discard the next splitter
                        i++;
                    }

                    continue;
                }

                visibleChildren.Add(child);
            }

            if (visibleChildren.Count == 0)
                return;

            if (visibleChildren.Last<FrameworkElement>() is ResizingPanelSplitter)
                visibleChildren.RemoveAt(visibleChildren.Count - 1);

            Size[] currentSizes = new Size[visibleChildren.Count];
            double delta = Orientation == Orientation.Horizontal ? e.HorizontalChange : e.VerticalChange;

            if (_childrenFinalSizes == null)
                return;

            _childrenFinalSizes.CopyTo(currentSizes, 0);

            int iSplitter = visibleChildren.IndexOf(splitter);

            Debug.Assert(iSplitter > -1);

            List<FrameworkElement> prevChildren = new List<FrameworkElement>();
            for (i = iSplitter - 1; i >= 0; i--)
            {
                FrameworkElement child = visibleChildren[i] as FrameworkElement;
                if (child is ResizingPanelSplitter)
                    continue;
                if (child.IsAbsolute() || child.IsAuto())
                {
                    if (prevChildren.Count == 0)
                    {
                        prevChildren.Add(child);
                    }
                    break;
                }
                if (child.IsStar())
                {
                    prevChildren.Add(child);
                }
            }

            List<FrameworkElement> nextChildren = new List<FrameworkElement>();

            for (i = iSplitter + 1; i < visibleChildren.Count; i++)
            {
                FrameworkElement child = visibleChildren[i] as FrameworkElement;
                if (child is ResizingPanelSplitter)
                    continue;
                if (child.IsAbsolute() || child.IsAuto())
                {
                    if (nextChildren.Count == 0)
                        nextChildren.Add(child);
                    break;
                }
                if (child.IsStar())
                {
                    nextChildren.Add(child);
                }
            }


            double prevMinSize = prevChildren.Sum<FrameworkElement>(c => Orientation == Orientation.Horizontal ? c.MinWidth : c.MinHeight);
            double nextMinSize = nextChildren.Sum<FrameworkElement>(c => Orientation == Orientation.Horizontal ? c.MinWidth : c.MinHeight);
            double prevMaxSize = prevChildren.Sum<FrameworkElement>(c => Orientation == Orientation.Horizontal ? c.MaxWidth : c.MaxHeight);
            double nextMaxSize = nextChildren.Sum<FrameworkElement>(c => Orientation == Orientation.Horizontal ? c.MaxWidth : c.MaxHeight);

            double prevSize = prevChildren.Sum<FrameworkElement>(c => Orientation == Orientation.Horizontal ? currentSizes[visibleChildren.IndexOf(c)].Width : currentSizes[visibleChildren.IndexOf(c)].Height);
            double nextSize = nextChildren.Sum<FrameworkElement>(c => Orientation == Orientation.Horizontal ? currentSizes[visibleChildren.IndexOf(c)].Width : currentSizes[visibleChildren.IndexOf(c)].Height);

            if (prevSize + delta < prevMinSize)
                delta = prevMinSize - prevSize;
            if (nextSize - delta < nextMinSize)
                delta = -(nextMinSize - nextSize);

            double remDelta = delta * 2;

            while (!HelperFunc.AreClose(delta, 0.0))
            {
                int prevChildrenCountWithNoMinLen =
                    prevChildren.Count<FrameworkElement>(c => delta > 0 ? true : (Orientation == Orientation.Horizontal ? currentSizes[visibleChildren.IndexOf(c)].Width > c.MinWidth : currentSizes[visibleChildren.IndexOf(c)].Height > c.MinHeight));
                int nextChildrenCountWithNoMinLen =
                    nextChildren.Count<FrameworkElement>(c => delta < 0 ? true : (Orientation == Orientation.Horizontal ? currentSizes[visibleChildren.IndexOf(c)].Width > c.MinWidth : currentSizes[visibleChildren.IndexOf(c)].Height > c.MinHeight));
                
                delta = remDelta / 2.0;

                for (i = 0; i < currentSizes.Length; i++)
                {
                    FrameworkElement child = visibleChildren[i] as FrameworkElement;
                    if (child is ResizingPanelSplitter)
                        continue;

                    if (Orientation == Orientation.Horizontal)
                    {
                        if (prevChildren.Contains(child) && prevChildrenCountWithNoMinLen > 0)
                        {
                            double s = delta / prevChildrenCountWithNoMinLen;
                            if (currentSizes[i].Width + s < child.MinWidth)
                                s = child.MinWidth - currentSizes[i].Width;
                            
                            currentSizes[i].Width += s;
                            remDelta -= s;
                        }
                        if (nextChildren.Contains(child) && nextChildrenCountWithNoMinLen > 0)
                        {
                            double s = delta / nextChildrenCountWithNoMinLen;
                            if (currentSizes[i].Width - s < child.MinWidth)
                                s = currentSizes[i].Width - child.MinWidth;

                            currentSizes[i].Width -= s;
                            remDelta -= s;
                        }
                    }
                    else
                    {
                        if (prevChildren.Contains(child) && prevChildrenCountWithNoMinLen > 0)
                        {
                            double s = delta / prevChildrenCountWithNoMinLen;
                            if (currentSizes[i].Height + s < child.MinHeight)
                                s = child.MinHeight - currentSizes[i].Height;

                            currentSizes[i].Height += s;
                            remDelta -= s;
                        }
                        if (nextChildren.Contains(child) && nextChildrenCountWithNoMinLen > 0)
                        {
                            double s = delta / nextChildrenCountWithNoMinLen;
                            if (currentSizes[i].Height - s < child.MinHeight)
                                s = currentSizes[i].Height - child.MinHeight;

                            currentSizes[i].Height -= s;
                            remDelta -= s;
                        }
                    }
                }
            }

            Debug.Assert(HelperFunc.AreClose(delta, 0.0));

            double totalStartsSum = 0.0;
            double totalSizeForStarts = 0.0;

            for (i = 0; i < visibleChildren.Count; i++)
            { 
                FrameworkElement child = visibleChildren[i] as FrameworkElement;
                if (child is ResizingPanelSplitter)
                    continue;
                if (child.IsStar())
                {
                    totalStartsSum += child.GetStarValue();
                    totalSizeForStarts += Orientation == Orientation.Horizontal ? currentSizes[i].Width : currentSizes[i].Height;
                }
            }
                

            double starsScaleFactor = totalStartsSum / totalSizeForStarts;

            for (i = 0; i < currentSizes.Length; i++)
            {
                FrameworkElement child = visibleChildren[i] as FrameworkElement;

                if (child is ResizingPanelSplitter)
                    continue;

                if (child.IsStar())
                {
                    if (Orientation == Orientation.Horizontal)
                    {
                        SetResizeWidth(child,
                            new GridLength(HelperFunc.MultiplyCheckNaN(currentSizes[i].Width, starsScaleFactor), GridUnitType.Star));
                    }
                    else
                    {
                        SetResizeHeight(child,
                            new GridLength(HelperFunc.MultiplyCheckNaN(currentSizes[i].Height, starsScaleFactor), GridUnitType.Star));
                    }
                }
                else if (child.IsAbsolute())
                {
                    if (Orientation == Orientation.Horizontal)
                    {
                        SetResizeWidth(child,
                            new GridLength(currentSizes[i].Width, GridUnitType.Pixel));
                    }
                    else
                    {
                        SetResizeHeight(child,
                            new GridLength(currentSizes[i].Height, GridUnitType.Pixel)); 
                    }
                }
            }

            InvalidateMeasure();
            
            //ResizingPanelSplitter splitter = e.Source as ResizingPanelSplitter;
            //int iSplitter = Children.IndexOf(splitter);

            //UIElement childPrev = null;
            //UIElement childNext = null;

            ////int posInc = ResizingDirection == ResizingDirection.Direct ? 2 : -2;
            //int posInc = 2;// FlowDirection == FlowDirection.LeftToRight ? 2 : -2;
            //int negInc = -posInc;
            //int i = iSplitter;

            //while (i >= 0 ||
            //    i < Children.Count - 1)
            //{
            //    if (NextChildIsVisible(i))
            //    {
            //        //childNext = Children[ResizingDirection == ResizingDirection.Direct ? i + 1 : i - 1];
            //        childNext = Children[i + 1];//FlowDirection == FlowDirection.LeftToRight ? i + 1 : i - 1];
            //        break;
            //    }

            //    i += posInc;
            //}

            //i = iSplitter;

            //while (i >= 0 ||
            //        i < Children.Count - 1)
            //{
            //    if (PrevChildIsVisible(i))
            //    {
            //        //childPrev = Children[ResizingDirection == ResizingDirection.Direct ? i - 1 : i + 1];
            //        childPrev = Children[i - 1];//FlowDirection == FlowDirection.LeftToRight ? i - 1 : i + 1]; 
            //        break;
            //    }

            //    i -= posInc;
            //}

            //Size resExtPrev = new Size((double)childPrev.GetValue(ResizeWidthProperty), (double)childPrev.GetValue(ResizeHeightProperty));
            //Size resExtNext = new Size((double)childNext.GetValue(ResizeWidthProperty), (double)childNext.GetValue(ResizeHeightProperty));


            //#region Orientation == Horizontal
            //if (Orientation == Orientation.Horizontal)
            //{
            //    double delta = e.HorizontalChange;

            //    if (!double.IsPositiveInfinity(resExtPrev.Width) &&
            //        (resExtPrev.Width + delta < 0))
            //        delta = -resExtPrev.Width;

            //    if (!double.IsPositiveInfinity(resExtNext.Width) &&
            //        resExtNext.Width - delta < 0)
            //        delta = resExtNext.Width;


            //    if (!double.IsPositiveInfinity(resExtPrev.Width))
            //        childPrev.SetValue(ResizeWidthProperty, resExtPrev.Width + delta);
            //    if (!double.IsPositiveInfinity(resExtNext.Width))
            //        childNext.SetValue(ResizeWidthProperty, resExtNext.Width - delta);
            //}
            //#endregion
            //#region Orientation == Vertical
            //else //if (Orientation == Orientation.Vertical)
            //{
            //    double delta = e.VerticalChange;

            //    if (!double.IsPositiveInfinity(resExtPrev.Height) &&
            //        (resExtPrev.Height + delta < 0))
            //        delta = -resExtPrev.Height;

            //    if (!double.IsPositiveInfinity(resExtNext.Height) &&
            //        resExtNext.Height - delta < 0)
            //        delta = resExtNext.Height;


            //    if (!double.IsPositiveInfinity(resExtPrev.Height))
            //        childPrev.SetValue(ResizeHeightProperty, resExtPrev.Height + delta);

            //    if (!double.IsPositiveInfinity(resExtNext.Height))
            //        childNext.SetValue(ResizeHeightProperty, resExtNext.Height - delta);
            //}
            //#endregion

        }
Пример #13
0
        public void populatePreBoxFields()
        {
            type = Treatment.GetTreatmentTypes();
            List<Employee> allEmployees = Employee.GetEmployees();
            wards = Ward.GetWards();
            doctors = new List<string>();
            employeeIDs = new List<int>();

            foreach (Employee employee in allEmployees)
            {
                if (employee.Employee_type == "Doctor")
                {
                    doctors.Add(employee.Lname + ", " + employee.Fname);
                    employeeIDs.Add(employee.Eid);
                }
            }

            boxDoctors.DataContext = doctors;
            boxDoctors.SelectedIndex = employeeIDs.IndexOf(treatment.Doctor);
            boxTreatmentType.DataContext = type;
            boxWard.DataContext = wards;
            boxWard.DisplayMemberPath = "WardName";
            boxWard.SelectedValuePath = "SlugName";
            boxDoctors.Items.Refresh();
            boxTreatmentType.Items.Refresh();
            patient.Select();
            lblName.Content = patient.LastName + ", " + patient.FirstName;
        }
Пример #14
0
        void cardView_OnDragging(object sender, EventArgs e)
        {
            lock (cardArrangeLock)
            {
                // First, find the two stacks that the card is hovering above.
                var relevantStacks = new List<CardStack>();
                var yOverlap = new List<double>();
                CardStack resultDeckStack = null;
                double maxOverlap = 0;
                double resultOverlap = 0;

                foreach (var stack in _allCardStacks)
                {
                    Rect rect = stack.BoundingBox;
                    rect.Intersect(new Rect(InteractingCard.Position, new Size(InteractingCard.Width, InteractingCard.Height)));
                    if (rect.Size.Height > 0)
                    {
                        if (stack.Parent != _resultPanel)
                        {
                            relevantStacks.Add(stack);
                            yOverlap.Add(rect.Size.Height);
                        }
                        else if (rect.Size.Width > maxOverlap)
                        {
                            resultDeckStack = stack;
                            maxOverlap = rect.Size.Width;
                            resultOverlap = rect.Size.Height;
                        }
                    }
                }

                if (resultDeckStack != null)
                {
                    relevantStacks.Add(resultDeckStack);
                    yOverlap.Add(resultOverlap);
                }
                Trace.Assert(relevantStacks.Count <= 2 && yOverlap.Count == relevantStacks.Count);

                // Second, set the interacting card of all card stacks accordingly
                foreach (var stack in _allCardStacks)
                {
                    CardInteraction status;
                    if (relevantStacks.Contains(stack) || stack == _sourceDeck)
                    {
                        stack.InteractingCard = InteractingCard;
                        status = CardInteraction.Drag;
                    }
                    else
                    {
                        stack.InteractingCard = null;
                        status = CardInteraction.None;
                    }
                    if (status != stack.CardStatus || status == CardInteraction.Drag)
                    {
                        stack.CardStatus = status;
                        stack.RearrangeCards();
                    }
                }

                // Finally, in the stack with greatest overlapping y-distance, highlight the slot.
                _ResetHighlightSlot();

                if (relevantStacks.Count == 0)
                {
                    _highlightedStack = null;
                }
                else
                {
                    _highlightedStack = relevantStacks[yOverlap.IndexOf(yOverlap.Max())];
                    var highlightedSlot = _stackToSlot[_highlightedStack];
                    if (highlightedSlot.Cards.Count > 0)
                    {
                        int index = Math.Min(_highlightedStack.InteractingCardIndex, highlightedSlot.Cards.Count - 1);
                        _highlightedCardSlot = highlightedSlot.Cards[index];
                        _highlightedCardSlot.CardModel.IsFaded = true;
                    }
                }
            }
        }
Пример #15
0
 void watcher_PositionChanged(object sender, GeoPositionChangedEventArgs<GeoCoordinate> e)
 {
     geolist = geolist.OrderBy(s => s.GetDistanceTo(watcher.Position.Location)).ToList();
     loc = loc.OrderBy(i => geolist.IndexOf(new GeoCoordinate() { Latitude = i.latLocal, Longitude = i.longLocal })).ToList();
     for (int i = 0; i < geolist.ToArray().Length; i++)
     {
         loc.ToArray()[i].distance = "~" + Math.Round((geolist.ToArray()[i].GetDistanceTo(watcher.Position.Location) / 1000), 1) + "km";
     }
     LocalList.ItemsSource = loc;
 }
Пример #16
0
 protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
 {
     base.OnNavigatedTo(e);
     fillEM();
     if ((Application.Current as App).estado == Estado.accepted && (Application.Current as App).state == WatcherState.active)
     {
         for (int i = 0; i < rutas.ToArray().Length; i++)
         {
             for (int j = 0; j < rutas.ToArray()[i].estaciones.ToArray().Length; i++)
             {
                 geolist.Add(new GeoCoordinate() { Latitude = rutas.ToArray()[i].estaciones.ToArray()[j].latEst, Longitude = rutas.ToArray()[i].estaciones.ToArray()[j].longEst });
             }
             geolist = geolist.OrderBy(s => s.GetDistanceTo(watcher.Position.Location)).ToList();
             rutas.ToArray()[i].estaciones = rutas.ToArray()[i].estaciones.OrderBy(p => geolist.IndexOf(new GeoCoordinate() { Latitude = p.latEst, Longitude = p.longEst })).ToList();
             for (int k = 0; k < geolist.ToArray().Length; k++)
             {
                 rutas.ToArray()[i].estaciones.ToArray()[k].distancia = "~" + Math.Round((geolist.ToArray()[k].GetDistanceTo(watcher.Position.Location) / 1000), 1) + "km";
             }
         }
         estacList.ItemsSource = rutas;
     }
     else
     {
         estacList.ItemsSource = rutas;
     }
 }
Пример #17
0
        void splitter_DragCompleted(object sender, DragCompletedEventArgs e)
        {
            HideResizerOverlayWindow();

            Resizer splitter = e.Source as Resizer;
            int i = 0;

            //Compute the list of visible children
            List<FrameworkElement> visibleChildren = new List<FrameworkElement>();
            for (i = 0; i < VisualChildrenCount; i++)
            {
                FrameworkElement child = GetVisualChild(i) as FrameworkElement;

                IDockableControl dockableControl = child as IDockableControl;
                if (dockableControl != null &&
                    !dockableControl.IsDocked)
                {
                    if (i == VisualChildrenCount - 1 &&
                        i > 0)
                    {
                        //remove the last splitter added
                        if (visibleChildren.Count > 0 &&
                            visibleChildren.Last<FrameworkElement>() is Resizer)
                            visibleChildren.RemoveAt(visibleChildren.Count - 1);
                    }
                    else if (i < VisualChildrenCount - 1)
                    {
                        //discard the next splitter
                        i++;
                    }

                    continue;
                }

                visibleChildren.Add(child);
            }

            if (visibleChildren.Count == 0)
                return;

            if (visibleChildren.Last<FrameworkElement>() is Resizer)
                visibleChildren.RemoveAt(visibleChildren.Count - 1);

            Size[] currentSizes = new Size[visibleChildren.Count];
            Window wnd = Window.GetWindow(this);
            if (wnd == null)
            {
                InvalidateMeasure();
                return;
            }
            var trToWnd = TransformToAncestor(wnd).Inverse;
            Vector transformedDelta = trToWnd.Transform(new Point(e.HorizontalChange, e.VerticalChange)) -
                trToWnd.Transform(new Point());
            double delta = Orientation == Orientation.Horizontal ? transformedDelta.X : transformedDelta.Y;

            if (_childrenFinalSizes == null)
                return;

            _childrenFinalSizes.CopyTo(currentSizes, 0);

            int iSplitter = visibleChildren.IndexOf(splitter);

            Debug.Assert(iSplitter > -1);

            List<FrameworkElement> prevChildren = new List<FrameworkElement>();
            for (i = iSplitter - 1; i >= 0; i--)
            {
                FrameworkElement child = visibleChildren[i] as FrameworkElement;
                if (child is Resizer)
                    continue;
                if (child.IsAbsolute() || child.IsAuto())
                {
                    if (prevChildren.Count == 0)
                    {
                        prevChildren.Add(child);
                    }
                    break;
                }
                if (child.IsStar())
                {
                    prevChildren.Add(child);
                }
            }

            List<FrameworkElement> nextChildren = new List<FrameworkElement>();

            for (i = iSplitter + 1; i < visibleChildren.Count; i++)
            {
                FrameworkElement child = visibleChildren[i] as FrameworkElement;
                if (child is Resizer)
                    continue;
                if (child.IsAbsolute() || child.IsAuto())
                {
                    if (nextChildren.Count == 0)
                        nextChildren.Add(child);
                    break;
                }
                if (child.IsStar())
                {
                    nextChildren.Add(child);
                }
            }

            double prevMinSize = prevChildren.Sum<FrameworkElement>(c => Orientation == Orientation.Horizontal ? c.MinWidth : c.MinHeight);
            double nextMinSize = nextChildren.Sum<FrameworkElement>(c => Orientation == Orientation.Horizontal ? c.MinWidth : c.MinHeight);
            double prevMaxSize = prevChildren.Sum<FrameworkElement>(c => Orientation == Orientation.Horizontal ? c.MaxWidth : c.MaxHeight);
            double nextMaxSize = nextChildren.Sum<FrameworkElement>(c => Orientation == Orientation.Horizontal ? c.MaxWidth : c.MaxHeight);

            double prevSize = prevChildren.Sum<FrameworkElement>(c => Orientation == Orientation.Horizontal ? currentSizes[visibleChildren.IndexOf(c)].Width : currentSizes[visibleChildren.IndexOf(c)].Height);
            double nextSize = nextChildren.Sum<FrameworkElement>(c => Orientation == Orientation.Horizontal ? currentSizes[visibleChildren.IndexOf(c)].Width : currentSizes[visibleChildren.IndexOf(c)].Height);

            if (prevSize + delta < prevMinSize)
                delta = prevMinSize - prevSize;
            if (nextSize - delta < nextMinSize)
                delta = -(nextMinSize - nextSize);

            double remDelta = delta * 2;

            while (!HelperFunc.AreClose(delta, 0.0))
            {
                int prevChildrenCountWithNoMinLen =
                    prevChildren.Count<FrameworkElement>(c => delta > 0 ? true : (Orientation == Orientation.Horizontal ? currentSizes[visibleChildren.IndexOf(c)].Width > c.MinWidth : currentSizes[visibleChildren.IndexOf(c)].Height > c.MinHeight));
                int nextChildrenCountWithNoMinLen =
                    nextChildren.Count<FrameworkElement>(c => delta < 0 ? true : (Orientation == Orientation.Horizontal ? currentSizes[visibleChildren.IndexOf(c)].Width > c.MinWidth : currentSizes[visibleChildren.IndexOf(c)].Height > c.MinHeight));

                delta = remDelta / 2.0;

                for (i = 0; i < currentSizes.Length; i++)
                {
                    FrameworkElement child = visibleChildren[i] as FrameworkElement;
                    if (child is Resizer)
                        continue;

                    if (Orientation == Orientation.Horizontal)
                    {
                        if (prevChildren.Contains(child) && prevChildrenCountWithNoMinLen > 0)
                        {
                            double s = delta / prevChildrenCountWithNoMinLen;
                            if (currentSizes[i].Width + s < child.MinWidth)
                                s = child.MinWidth - currentSizes[i].Width;

                            currentSizes[i].Width += s;
                            remDelta -= s;
                        }
                        if (nextChildren.Contains(child) && nextChildrenCountWithNoMinLen > 0)
                        {
                            double s = delta / nextChildrenCountWithNoMinLen;
                            if (currentSizes[i].Width - s < child.MinWidth)
                                s = currentSizes[i].Width - child.MinWidth;

                            currentSizes[i].Width -= s;
                            remDelta -= s;
                        }
                    }
                    else
                    {
                        if (prevChildren.Contains(child) && prevChildrenCountWithNoMinLen > 0)
                        {
                            double s = delta / prevChildrenCountWithNoMinLen;
                            if (currentSizes[i].Height + s < child.MinHeight)
                                s = child.MinHeight - currentSizes[i].Height;

                            currentSizes[i].Height += s;
                            remDelta -= s;
                        }
                        if (nextChildren.Contains(child) && nextChildrenCountWithNoMinLen > 0)
                        {
                            double s = delta / nextChildrenCountWithNoMinLen;
                            if (currentSizes[i].Height - s < child.MinHeight)
                                s = currentSizes[i].Height - child.MinHeight;

                            currentSizes[i].Height -= s;
                            remDelta -= s;
                        }
                    }
                }
            }

            Debug.Assert(HelperFunc.AreClose(delta, 0.0));

            double totalStartsSum = 0.0;
            double totalSizeForStarts = 0.0;

            for (i = 0; i < visibleChildren.Count; i++)
            {
                FrameworkElement child = visibleChildren[i] as FrameworkElement;
                if (child is Resizer)
                    continue;
                if (child.IsStar())
                {
                    totalStartsSum += child.GetStarValue();
                    totalSizeForStarts += Orientation == Orientation.Horizontal ? currentSizes[i].Width : currentSizes[i].Height;
                }
            }

            double starsScaleFactor = totalStartsSum / totalSizeForStarts;

            for (i = 0; i < currentSizes.Length; i++)
            {
                FrameworkElement child = visibleChildren[i] as FrameworkElement;

                if (child is Resizer)
                    continue;

                if (child.IsStar())
                {
                    if (Orientation == Orientation.Horizontal)
                    {
                        SetResizeWidth(child,
                            new GridLength(HelperFunc.MultiplyCheckNaN(currentSizes[i].Width, starsScaleFactor), GridUnitType.Star));
                    }
                    else
                    {
                        SetResizeHeight(child,
                            new GridLength(HelperFunc.MultiplyCheckNaN(currentSizes[i].Height, starsScaleFactor), GridUnitType.Star));
                    }
                }
                else if (child.IsAbsolute())
                {
                    if (Orientation == Orientation.Horizontal)
                    {
                        SetResizeWidth(child,
                            new GridLength(currentSizes[i].Width, GridUnitType.Pixel));
                    }
                    else
                    {
                        SetResizeHeight(child,
                            new GridLength(currentSizes[i].Height, GridUnitType.Pixel));
                    }
                }
            }

            InvalidateMeasure();
        }
Пример #18
0
        private static void CheckForOtherDispatchers(Dispatcher mainDispatcher)
        {
            // check and see if any of the root visuals have a different mainDispatcher
            // if so, ask the user if they wish to enter multiple mainDispatcher mode.
            // if they do, launch a snoop ui for every additional mainDispatcher.
            // see http://snoopwpf.codeplex.com/workitem/6334 for more info.

            List<Visual> rootVisuals = new List<Visual>();
            List<Dispatcher> dispatchers = new List<Dispatcher>();
            dispatchers.Add(mainDispatcher);
            foreach (PresentationSource presentationSource in PresentationSource.CurrentSources)
            {
                Visual presentationSourceRootVisual = presentationSource.RootVisual;

                if (!(presentationSourceRootVisual is Window))
                    continue;

                Dispatcher presentationSourceRootVisualDispatcher = presentationSourceRootVisual.Dispatcher;

                if (dispatchers.IndexOf(presentationSourceRootVisualDispatcher) == -1)
                {
                    rootVisuals.Add(presentationSourceRootVisual);
                    dispatchers.Add(presentationSourceRootVisualDispatcher);
                }
            }

            if (rootVisuals.Count > 0)
            {
                var result =
                    MessageBox.Show
                    (
                        "Snoop has noticed windows running in multiple dispatchers!\n\n" +
                        "Would you like to enter multiple dispatcher mode, and have a separate Snoop window for each dispatcher?\n\n" +
                        "Without having a separate Snoop window for each dispatcher, you will not be able to Snoop the windows in the dispatcher threads outside of the main dispatcher. " +
                        "Also, note, that if you bring up additional windows in additional dispatchers (after Snooping), you will need to Snoop again in order to launch Snoop windows for those additional dispatchers.",
                        "Enter Multiple Dispatcher Mode",
                        MessageBoxButton.YesNo,
                        MessageBoxImage.Question
                    );

                if (result == MessageBoxResult.Yes)
                {
                    SnoopModes.MultipleDispatcherMode = true;
                    Thread thread = new Thread(new ParameterizedThreadStart(DispatchOut));
                    thread.Start(rootVisuals);
                }
            }
        }
Пример #19
0
 static void AppendList(ref List<string> l1, List<string> l2)
 {
     if (l2 == null)
         return;
     foreach (string s in l2)
     {
         if (l1.IndexOf(s) == -1)
             l1.Add(s);
     }
 }
        private static List<Skeleton> InterpolateFrames(List<Skeleton> skels, int nFrames)
        {
            int diff = nFrames - skels.Count;
            List<Skeleton> result = skels;

            List<double> dists = new List<double>();
            for (int i = 0; i < skels.Count - 1; i++)
            {
                dists.Add(GetDistBetweenFrames(skels.ElementAt(i), skels.ElementAt(i + 1)));
            }

            for (int i = 0; i < diff; i++)
            {
                if (dists.Count == 0)
                {
                    break;
                }
                double max = dists.Min();
                int index = dists.IndexOf(max);

                Skeleton insert = GetMidFrame(skels.ElementAt(index), skels.ElementAt(index + 1));
                result.Insert(index, insert);
                dists.RemoveAt(index);
            }

            return AlignFrames(result, nFrames);
        }
Пример #21
0
        public string CreateAnimatedString(string wrong, string right, List<Change> changes)
        {
            var word = wrong;
            foreach (var change in changes)
            {
                switch (change.ChangeType)
                {
                    case ChangeType.Insert:
                    {
                        word = word.Insert(change.Index, change.Character + "");
                        //when you insert a charahter the indexes will be effected so you need to push them
                        changes.Skip(changes.IndexOf(change) + 1).ToList().ForEach(f =>
                        {
                            f.Index++;
                            if (f.Index2.HasValue)
                                f.Index2++;
                        });
                    }
                    break;
                    case ChangeType.Remove:
                    //leav the char in there cuz the animation will take it out
                    break;
                    case ChangeType.Swap:
                    //leav them unswaped cuz the animation will do it 
                    break;
                    case ChangeType.Replace:
                    {
                        //put the new char next to the old one 
                        word = word.Insert(change.Index, change.Character2 + "");
                        //when you insert a charahter the indexes will be effected so you need to push them
                        changes.Skip(changes.IndexOf(change) + 1).ToList().ForEach(f =>
                        {
                            f.Index++;
                            if (f.Index2.HasValue)
                                f.Index2++;
                        });

                    }
                    break;
                }
            }
            return word;
        }
Пример #22
0
        private void browse_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog dlg = new OpenFileDialog();

            dlg.Filter = "All images|*.jpeg;*.png;*.jpg;*.bmp|JPEG Files (*.jpeg)|*.jpeg|PNG Files (*.png)|*.png|JPG Files (*.jpg)|*.jpg|Bitmap Files (*.bmp)|*.bmp";
            Nullable<bool> result = dlg.ShowDialog();
            if (result == true)
            {
                string filename = dlg.FileName;
                Uri uri = new Uri(filename);
                BitmapImage imgSource = new BitmapImage(uri);

                FileNameTextBox.Text = filename;
                picture.Source = imgSource;

                /* KNN */
                List<double []> letters = new List<double[]>();
                List<int> outputList = new List<int>();
                List<string> indexes = new List<string>();

                foreach (string letterPath in dictionary) {
                    FileInfo file = new FileInfo(letterPath);
                    string nameClean = file.Name.Substring(0, file.Name.Length - 4);

                    while (Char.IsDigit(nameClean[nameClean.Length - 1])) {
                        nameClean = nameClean.Substring(0, nameClean.Length - 1);
                    }
                    int i = indexes.IndexOf(nameClean);

                    if (i <= -1) {
                        indexes.Add(nameClean);
                        outputList.Add(indexes.Count - 1);
                    } else {
                        outputList.Add(i);
                    }
                    letters.Add(getVectors(cropImage(getImageBitmap(file.FullName))));
                }

                DateTime start = DateTime.Now;

                KNearestNeighbors knn = new KNearestNeighbors(k: 3, classes: indexes.Count, inputs: letters.ToArray(), outputs: outputList.ToArray());
                int answer = knn.Compute(getVectors(cropImage(MakeGrayscale(getImageBitmap(filename)))));
                string res = indexes[answer];
                lettre.Content = res;
                timeSpent.Content = "Execution time: " + (DateTime.Now - start);
            }
        }
Пример #23
0
        private void submitCFButton_Click(object sender, RoutedEventArgs e)
        {
            TextBox firstNameTB = (TextBox) this.FindName("nameCFTextBox");
            TextBox lastNameTB = (TextBox) this.FindName("lastNameCFTextBox");
            TextBox descriptionTB = (TextBox) this.FindName("descriptionCFTextBox");

            string resultString = resultTextBox.Text;
            
            Grid parent = (Grid)this.FindName("summaryCFGrid");
            Grid oddGrid = (Grid)parent.Children.OfType<Grid>().ElementAt(0);
            Grid evenGrid = (Grid)parent.Children.OfType<Grid>().ElementAt(1);
            RadioButton even = (RadioButton)evenGrid.Children.OfType<RadioButton>().FirstOrDefault(r => r.IsChecked.Value);
            RadioButton odd = (RadioButton)oddGrid.Children.OfType<RadioButton>().FirstOrDefault(r => r.IsChecked.Value);
            int evenSummand = Int32.Parse(even.Content.ToString());
            int oddSummand = Int32.Parse(odd.Content.ToString());
            int sum = evenSummand + oddSummand;

            string goodNameString = firstNameTB.Text;
            string goodLastNameString = lastNameTB.Text;
            string goodDescriptionString = descriptionTB.Text;
            string goodSumString = "Summary: " + sum;

            List<string> listFromBox = new List<string>(resultString.Split(new string[] {Environment.NewLine}, StringSplitOptions.RemoveEmptyEntries));


            string badSumString = listFromBox.FirstOrDefault(r => r.IndexOf("Summary") == 0);
            if (badSumString != null)
            {
                listFromBox[listFromBox.IndexOf(badSumString)] = goodSumString;
            }
            else
            {
                listFromBox.Add(goodSumString);
            }

            if (goodNameString != "")
            {
                string badNameString = listFromBox.FirstOrDefault(r => r.IndexOf("Name") == 0);
                if (badNameString != null)
                {
                    listFromBox[listFromBox.IndexOf(badNameString)] = "Name: " + goodNameString;
                }
                else
                {
                    listFromBox.Add("Name: "+ goodNameString);
                }
            }

            if (goodLastNameString != "")
            {
                string badLastNameString = listFromBox.FirstOrDefault(r => r.IndexOf("Last Name") == 0);
                if (badLastNameString != null)
                {
                    listFromBox[listFromBox.IndexOf(badLastNameString)] = "Last Name: " + goodLastNameString;
                }
                else
                {
                    listFromBox.Add("Last Name: " + goodLastNameString);
                }
            }

            if (goodDescriptionString!= "")
            {
                string badDescriptionString = listFromBox.FirstOrDefault(r => r.IndexOf("Description") == 0);
                if (badDescriptionString!= null)
                {
                    listFromBox[listFromBox.IndexOf(badDescriptionString)] = "Description: " + goodDescriptionString;
                }
                else
                {
                    listFromBox.Add("Description: " + goodDescriptionString);
                }
            }

            resultTextBox.Text = String.Join(Environment.NewLine, listFromBox);
            
        }
Пример #24
0
        // parameters:
        //      strLibraryCodeList  当前用户管辖的馆代码。也就是说馆代码列表中,至少要出现这些事项
        void FillLibraryCodeList(string strLibraryCodeList)
        {
            Debug.Assert(_comboBox_libraryCode != null, "");

            List<string> librarycodes = new List<string>();
            XmlNodeList nodes = this._dom.DocumentElement.SelectNodes("library");
            foreach (XmlNode node in nodes)
            {
                string strCode = DomUtil.GetAttr(node, "code");
                librarycodes.Add(strCode);
            }

            // 看看是否还有不属于任何<library>元素的
            nodes = this._dom.DocumentElement.SelectNodes("//param[count(ancestor::library) = 0]");
            if (nodes.Count > 0)
            {
                if (librarycodes.IndexOf("") == -1)
                    librarycodes.Insert(0, "");
            }

            // 增补
            string[] list = strLibraryCodeList.Split(new char[] { ',' }); // , StringSplitOptions.RemoveEmptyEntries
            foreach (string s in list)
            {
                if (librarycodes.IndexOf(s) == -1)
                {
                    // 如果要增补空字符串,需要放在第一个元素
                    if (string.IsNullOrEmpty(s) == true)
                        librarycodes.Insert(0, s);
                    else
                        librarycodes.Add(s);
                }
            }

            string strCurrent = _comboBox_libraryCode.Text;
            _comboBox_libraryCode.Items.Clear();
            foreach (string s in librarycodes)
            {
                _comboBox_libraryCode.Items.Add(s);
            }

            if (_comboBox_libraryCode.Items.IndexOf(strCurrent) != -1)
                _comboBox_libraryCode.Text = strCurrent;
            else
            {
                if (_comboBox_libraryCode.Items.Count > 0)
                    _comboBox_libraryCode.SelectedIndex = 0;
                // _comboBox_libraryCode.Text = _comboBox_libraryCode.Items[0].ToString();
            }

        }
Пример #25
0
        //房间参数赋值,返回房间类对象
        private object value_Room(List<string> _lsEqu, List<string> _lsState, string _name_Room, double[] _light_zm_power, double[] _light_zs_power, double[] _acreage, double _tv_power, double _audio_power)
        {
            //string[] zstr = { "drawing", "master", "children", "study", "kitchen", "dining", "bathroom", "balcony" };
            List<string> ls_Name_Room = zstr.ToList<string>();

            //温度
            int index_tem = _lsEqu.IndexOf(_name_Room + "_" + "tem");
            double tem = Convert.ToDouble(_lsState[index_tem]);
            //灯光照明
            int index_light_zm = _lsEqu.IndexOf(_name_Room + "_" + "light_zm");
            bool light_zm;
            if (_lsState[index_light_zm].Equals("on"))
            {
                light_zm = true;
            }
            else
            {
                light_zm = false;
            }
            //灯光装饰
            int index_light_zs = _lsEqu.IndexOf(_name_Room + "_" + "light_zs");
            bool light_zs;
            if (_lsState[index_light_zs].Equals("on"))
            {
                light_zs = true;
            }
            else
            {
                light_zs = false;
            }

            int index_Name_Room = ls_Name_Room.IndexOf(_name_Room);
            //照明功率
            double light_zm_power = _light_zm_power[index_Name_Room];
            //装饰功率
            double light_zs_power = _light_zs_power[index_Name_Room];
            //房间面积
            double acreage = _acreage[index_Name_Room];

            if (_name_Room.Equals("drawing"))
            {
                //电视
                int index_tv = _lsEqu.IndexOf(_name_Room + "_" + "tv");
                bool tv;
                if (_lsState[index_tv].Equals("on"))
                {
                    tv = true;
                }
                else
                {
                    tv = false;
                }
                //音响
                int index_audio = _lsEqu.IndexOf(_name_Room + "_" + "audio");
                bool audio;
                if (_lsState[index_audio].Equals("on"))
                {
                    audio = true;
                }
                else
                {
                    audio = false;
                }

                double tv_power = _tv_power;
                double audio_power = _audio_power;

                Room_Drawing room_Drawing = new Room_Drawing(tem, light_zm, light_zs, light_zm_power, light_zs_power, acreage, tv, audio, tv_power, audio_power);
                return room_Drawing;
            }
            else
            {
                Room room = new Room(tem, light_zm, light_zs, light_zm_power, light_zs_power, acreage);
                return room;
            }
        }
Пример #26
0
        public void populatePreBoxFields()
        {
            doctors = new List<string>();
            employeeIDs = new List<int>();
            List<Employee> allEmployees = Employee.GetEmployees();

            foreach (Employee employee in allEmployees)
            {
                if (employee.Employee_type == "Doctor")
                {
                    doctors.Add(employee.Lname + ", " + employee.Fname);
                    employeeIDs.Add(employee.Eid);
                }
            }

            boxDoctors.DataContext = doctors;
            boxDoctors.SelectedIndex = employeeIDs.IndexOf(prescription.Doctor);
            boxDoctors.Items.Refresh();
            lblGenerateName.Content = patient.LastName + ", " + patient.FirstName;
        }
        private static List<Skeleton> RemoveFrames(List<Skeleton> skels, int nFrames)
        {
            int diff = skels.Count - nFrames;
            List<Skeleton> result = new List<Skeleton>();

            List<double> dists = new List<double>();
            for (int i = 0; i < skels.Count - 1; i++)
            {
                dists.Add(GetDistBetweenFrames(skels.ElementAt(i), skels.ElementAt(i + 1)));
            }

            List<int> ignore = new List<int>();
            int j = 0;
            while (j < diff)
            {
                double min = dists.Min();
                int index = dists.IndexOf(min);
                if (index < skels.Count - 3)
                {
                    ignore.Add(index);
                    j++;
                }
                dists.RemoveAt(index);
            }

            for (int i = 0; i < skels.Count; i++)
            {
                if (ignore.Contains(i))
                {
                    continue;
                }

                result.Add(skels.ElementAt(i));
            }

            return AlignFrames(result, nFrames);
        }
        private void RedeemTickets()
        {
            try
            {
                LogManager.WriteLog("Inside RedeemTickets() Method", LogManager.enumLogLevel.Info);
                List<ReedemTicketInfo> _lstToProcess = new List<ReedemTicketInfo>();
                _lstToProcess.AddRange(_objTickets.Where(Tck => (Tck.TicketStatus == 0) && (Tck.IsVoucherRedeemed == false) || (Tck.TicketStatus == 1) && (Tck.IsVoucherRedeemed == false) || (Tck.TicketStatus == -14 && Settings.RedeemExpiredTicket && Tck.IsVoucherRedeemed == false && Security.SecurityHelper.HasAccess("CashdeskOperator.Authorize.cs.MultipleRedeemExpiredTicket")) || (Tck.TicketStatus == -15 && Settings.RedeemExpiredTicket && Tck.IsVoucherRedeemed == false && Security.SecurityHelper.HasAccess("CashdeskOperator.Authorize.cs.MultipleRedeemExpiredTicket"))).ToList());
                LogManager.WriteLog("The number of unprocessed tickets:" + _lstToProcess.Count, LogManager.enumLogLevel.Info);

                if (_lstToProcess.Count == 0)
                {
                    Dispatcher.Invoke
                           (new Action(() =>
                           {
                               txtErrorStatus.Text = Application.Current.Resources["CRedeemMultipleTicketsNoValidTickets"].ToString();
                               btnStopRedeem.Visibility = System.Windows.Visibility.Hidden;
                               btnClearRedeem.Visibility = System.Windows.Visibility.Visible;
                               btnRedeemTickets.Visibility = System.Windows.Visibility.Visible;                              
                               DisableRemoveVoucher(true);

                           }));
                    return;
                }
                foreach (ReedemTicketInfo ticket in _lstToProcess)
                {

                    if (_AutoReset.WaitOne(300))
                    {

                        Dispatcher.Invoke
                            (new Action(() =>
                            {

                                txtErrorStatus.Text = Application.Current.Resources["CRedeemMultipleTicketStopRedeeming"].ToString();
                                //btnExit.IsEnabled = true;
                                btnRedeemTickets.Visibility = System.Windows.Visibility.Visible;
                                btnClearRedeem.Visibility = System.Windows.Visibility.Visible;
                                DisableRemoveVoucher(true);
                            }));

                        return;
                    }
                    Dispatcher.BeginInvoke((Action)(() =>
                                     {

                                         lvTickets.ScrollIntoView(ticket);
                                         lvTickets.SelectedItem = ticket;
                                         txtErrorStatus.Text = string.Format(Application.Current.Resources["RedeemMultipleTicketProcessingMessage"].ToString() + "({0}/{1})...{2}", (_lstToProcess.IndexOf(ticket) + 1).ToString(), _lstToProcess.Count.ToString(), ticket.Barcode);

                                     }), null);

                    if (!ticket.IsVoucherRedeemed)
                    {
                        string RedeemStatus = string.Empty;

                        //Db hit to redeem the ticket
                        RedeemStatus = RedeemTicket(ticket);                   

                            Dispatcher.Invoke(new Action(() =>
                            {                              
                                ticket.Status = RedeemStatus;
                            }));                       

                    }

                }
                Dispatcher.BeginInvoke((Action)(() =>
                {
                    txtErrorStatus.Foreground = new SolidColorBrush(Colors.Green);
                    txtErrorStatus.Text = Application.Current.Resources["CRedeemMultipleTicketRedemptionCompletion"].ToString();                                         
                    btnClearRedeem.Visibility = System.Windows.Visibility.Visible;
                    LogManager.WriteLog("All the tickets are redeemed successfully", LogManager.enumLogLevel.Info);
                    btnRedeemTickets.Visibility = System.Windows.Visibility.Visible;
                    DisableRemoveVoucher(true);
                    btnStopRedeem.Visibility = System.Windows.Visibility.Hidden;                   
                    dispTimer.Start();
                }
                      ), null);

            }
            catch (Exception ex)
            {
                ExceptionManager.Publish(ex);

            }
          
        }
Пример #29
0
        /// <summary>
        /// Prepare, with path, file(s) and call LoadFile for async downloading
        /// </summary>
        /// <param name="Reason">What files to prepade</param>
        /// <param name="File">If a specific file within a group of alike files. Default: ""</param>
        /// <param name="document">Character stat XML, to get correct power files from. Default: null</param>
        public void PrepareFilePaths(string Reason, string File = "", XDocument document = null)
        {
            switch (Reason)
             {
            // Startup loading of informations
            case "Get list of games":
               FileProcessTask = (int)FileProcessEnum.getListOfGames;
               LoadFile("./index.xml");
               break;
            case "Get list of characters":
               FileProcessTask = (int)FileProcessEnum.getListOfCharacters;
               LoadFile("./" + Globals.GameInformation.SelectedGame + "/characters/index_characters.xml");
               break;
            case "Get list of equipment":
               FileProcessTask = (int)FileProcessEnum.getListOfEquipment;
               LoadFile("./" + Globals.GameInformation.SelectedGame + "/equipment/index_equipment.xml");
               break;
            case "Get list of powers":
               FileProcessTask = (int)FileProcessEnum.getListOfPowers;
               LoadFile("./" + Globals.GameInformation.SelectedGame + "/powers/index_powers.xml");
               break;
            case "Get types of equipment":
               FileProcessTask = (int)FileProcessEnum.getTypesOfEquipment;
               LoadFile("./" + Globals.GameInformation.SelectedGame + "/equipment/" + File + "/index_" + File + ".xml");
               break;
            case "Get types of power":
               FileProcessTask = (int)FileProcessEnum.getTypesOfPower;
               LoadFile("./" + Globals.GameInformation.SelectedGame + "/powers/" + File + "/index_" + File + ".xml");
               break;
            // Character sheet informations
            case "Get character stats":
               FileProcessTask = (int)FileProcessEnum.getCharacterStats;
               LoadFile("./" + Globals.GameInformation.SelectedGame + "/characters/" + File + ".xml");
               break;
            case "Get character powers":
               FileProcessTask = (int)FileProcessEnum.getCharacterPowerFiles;
               Globals.TemporaryData.FilesStillToLoad = 0;

               foreach (XElement ePowerName in document.Descendants("powers"))
               {
                  string powerType = ePowerName.Attribute("type").Value;

                  // find single power types
                  List<string> PowerIndex = (from vTypes in ePowerName.Descendants(powerType)
                                             select vTypes.Element("type").Value).Distinct().ToList();
                  PowerIndex.AddRange(Globals.GameInformation.PowerIndexForAll.ElementAt(Globals.GameInformation.PowerIndex.IndexOf(powerType)));  // find general powers
                  PowerIndex.Remove("");                                                          // Cleanup of list

                  // number of files to load
                  Globals.TemporaryData.FilesStillToLoad += PowerIndex.Count;

                  PowerIndex.ForEach(delegate(string str)
                  {
                     LoadFile("./" + Globals.GameInformation.SelectedGame + "/powers/" + powerType + "/" + str + ".xml");
                  });
               }
               break;
            case "Get character power crossRefs":
               FileProcessTask = (int)FileProcessEnum.getCharacterPowerCrossRefs;
               Globals.TemporaryData.FilesStillToLoad = 0;

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

               foreach (XElement eCrossRef in document.Descendants("crossRef"))
               {
                  string parentName = eCrossRef.Parent.Name.ToString();
                  string typeName = eCrossRef.Element("type").Value;

                  if (UserFiles.IndexOf(parentName + ": " + typeName) == -1)                                                     // file hasn't been called to load yet
                  {
                     UserFiles.Add(parentName + ": " + typeName);                                                                // add file to has been called to load list
                     Globals.TemporaryData.FilesStillToLoad++;                                                                   // NB. because FilesStillToLoad isn't set the exact number from the start it can potentially be counter down to 0 (and new new functions called) before all files are send to loading
                     LoadFile("./" + Globals.GameInformation.SelectedGame + "/powers/" + parentName + "/" + typeName + ".xml");
                  }
               }
               break;
            case "Get character power keywords":
               FileProcessTask = (int)FileProcessEnum.getCharacterPowerKeywords;
               Globals.TemporaryData.FilesStillToLoad = 0;

               //string powerType = "";
               foreach (string ePowerType in Globals.TemporaryData.SelectedCharacterStats.Descendants("powers").Attributes("type"))
               {
                  if ((from vKeywords in Globals.TemporaryData.SelectedCharacterPowers.Descendants(ePowerType).Elements("keyword")
                       select vKeywords.Value).ToList().Count > 0)
                  {
                     Globals.TemporaryData.FilesStillToLoad++;
                     LoadFile("./" + Globals.GameInformation.SelectedGame + "/mechanic/" + ePowerType + "_keywords.xml");
                  }
               }
               break;
            case "Get empty character sheet":
               FileProcessTask = (int)FileProcessEnum.getEmptyCharacterSheet;
               LoadFile("./" + Globals.GameInformation.SelectedGame + "/sheets/" + File + ".xml");
               break;
            default:
               throw new UnknownFileProcessException(Reason);
             }
        }
Пример #30
0
 public void watcher_PositionChanged(object sender, GeoPositionChangedEventArgs<GeoCoordinate> e)
 {
     for (int i = 0; i < rutas.ToArray().Length; i++ )
     {
         for (int j = 0; j < rutas.ToArray()[i].estaciones.ToArray().Length; i++ )
         {
             geolist.Add(new GeoCoordinate() { Latitude = rutas.ToArray()[i].estaciones.ToArray()[j].latEst, Longitude = rutas.ToArray()[i].estaciones.ToArray()[j].longEst });
         }
         geolist = geolist.OrderBy(s => s.GetDistanceTo(watcher.Position.Location)).ToList();
         rutas.ToArray()[i].estaciones = rutas.ToArray()[i].estaciones.OrderBy(p => geolist.IndexOf(new GeoCoordinate() { Latitude = p.latEst, Longitude = p.longEst })).ToList();
         for (int k = 0; k < geolist.ToArray().Length; k++)
         {
             rutas.ToArray()[i].estaciones.ToArray()[k].distancia = "~" + Math.Round((geolist.ToArray()[k].GetDistanceTo(watcher.Position.Location) / 1000), 1) + "km";
         }
     }
     estacList.ItemsSource = rutas;
 }