Ejemplo n.º 1
0
        private void RemoveBranchToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (SelectedBranch != null)
            {
                int index = BranchView.SelectedRows.First();
                if (index == Movie.CurrentBranch)
                {
                    Movie.CurrentBranch = -1;
                }
                else if (index < Movie.CurrentBranch)
                {
                    Movie.CurrentBranch--;
                }

                Movie.RemoveBranch(SelectedBranch);
                BranchView.RowCount = Movie.BranchCount;

                if (index == Movie.BranchCount)
                {
                    BranchView.ClearSelectedRows();
                    BranchView.SelectRow(Movie.BranchCount - 1, true);
                }

                //BranchView.Refresh();
                Tastudio.RefreshDialog();
                GlobalWin.OSD.AddMessage("Removed branch " + index.ToString());
            }
        }
Ejemplo n.º 2
0
        private void RemoveBranchToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (SelectedBranch != null)
            {
                int index = BranchView.SelectedRows.First();
                if (index == Movie.CurrentBranch)
                {
                    Movie.CurrentBranch = -1;
                }
                else if (index < Movie.CurrentBranch)
                {
                    Movie.CurrentBranch--;
                }

                _backupBranch = SelectedBranch.Clone();
                UndoBranchToolStripMenuItem.Enabled = UndoBranchButton.Enabled = true;
                UndoBranchToolStripMenuItem.Text    = "Undo Branch Removal";
                toolTip1.SetToolTip(UndoBranchButton, "Undo Branch Removal");
                _branchUndo = BranchUndo.Remove;

                Movie.RemoveBranch(SelectedBranch);
                BranchView.RowCount = Movie.BranchCount;

                if (index == Movie.BranchCount)
                {
                    BranchView.ClearSelectedRows();
                    BranchView.SelectRow(Movie.BranchCount - 1, true);
                }

                CallRemovedCallback(index);
                Tastudio.RefreshDialog();
                GlobalWin.OSD.AddMessage("Removed branch " + index.ToString());
            }
        }
Ejemplo n.º 3
0
        private void UndoBranchToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (_branchUndo == BranchUndo.Load)
            {
                LoadBranch(_backupBranch);
                CallLoadedCallback(Tastudio.CurrentTasMovie.Branches.IndexOf(_backupBranch));
                GlobalWin.OSD.AddMessage("Branch Load canceled");
            }
            else if (_branchUndo == BranchUndo.Update)
            {
                Movie.UpdateBranch(Movie.GetBranch(_backupBranch.UniqueIdentifier), _backupBranch);
                CallSavedCallback(Tastudio.CurrentTasMovie.Branches.IndexOf(_backupBranch));
                GlobalWin.OSD.AddMessage("Branch Update canceled");
            }
            else if (_branchUndo == BranchUndo.Text)
            {
                Movie.GetBranch(_backupBranch.UniqueIdentifier).UserText = _backupBranch.UserText;
                GlobalWin.OSD.AddMessage("Branch Text Edit canceled");
            }
            else if (_branchUndo == BranchUndo.Remove)
            {
                Movie.AddBranch(_backupBranch);
                BranchView.RowCount = Movie.BranchCount;
                CallSavedCallback(Tastudio.CurrentTasMovie.Branches.IndexOf(_backupBranch));
                GlobalWin.OSD.AddMessage("Branch Removal canceled");
            }

            UndoBranchToolStripMenuItem.Enabled = UndoBranchButton.Enabled = false;
            BranchView.Refresh();
            Tastudio.RefreshDialog();
        }
Ejemplo n.º 4
0
 private void BranchView_MouseUp(object sender, MouseEventArgs e)
 {
     if (e.Button == MouseButtons.Left)
     {
         BranchView.ReleaseCurrentCell();
     }
 }
Ejemplo n.º 5
0
        public void SelectBranchExternal(bool next)
        {
            if (SelectedBranch == null)
            {
                BranchView.SelectRow(Movie.CurrentBranch, true);
                BranchView.Refresh();
                return;
            }
            int sel = BranchView.SelectedRows.First();

            if (next)
            {
                if (GetBranch(sel + 1) != null)
                {
                    BranchView.SelectRow(sel, false);
                    BranchView.SelectRow(sel + 1, true);
                }
            }
            else             // previous
            {
                if (GetBranch(sel - 1) != null)
                {
                    BranchView.SelectRow(sel, false);
                    BranchView.SelectRow(sel - 1, true);
                }
            }
            BranchView.Refresh();
        }
Ejemplo n.º 6
0
        public BranchView GetBranchInfo(long branchId)
        {
            using (var ctx = new ConXContext())
            {
                Branch branch = ctx.Branchs
                                .Include("branchGroup")
                                .Where(x => x.branchId == branchId)
                                .SingleOrDefault();

                BranchView view = new BranchView
                {
                    branchId         = branch.branchId,
                    branchCode       = branch.branchCode,
                    branchNameThai   = branch.branchNameThai,
                    branchNameEng    = branch.branchNameEng,
                    branchGroupId    = branch.branchGroupId,
                    branchGroupCode  = branch.branchGroup.branchGroupCode,
                    branchGroupName  = branch.branchGroup.branchGroupName,
                    status           = branch.status,
                    statusTxt        = branch.statusTxt,
                    entityCode       = branch.entityCode,
                    email            = branch.email,
                    docRunningPrefix = branch.docRunningPrefix
                };

                return(view);
            }
        }
Ejemplo n.º 7
0
        private static void MoveElementInsideTree(DataTreeView target, BranchView branchItem)
        {
            if (target.Tree.Children.Count == 0)
            {
                return;
            }

            if (branchItem.Element.DataStructure == null)
            {
                Debug.Write("Can not remove datapoints, only datastructures");
                return;
            }

            var ix = target.Tree.Children.IndexOf(branchItem.Element.DataStructure);

            if (ix != -1)
            {
                if (ix == target.Tree.Children.Count - 1)
                {
                    return;
                }

                target.Tree.Children.Move(ix, target.Tree.Children.Count - 1);
                return;
            }

            var branchParent = XamarinHelpers.GetTypedElementFromParents <BranchView>(branchItem.Parent);

            branchParent.Element.DataStructure.Children.Remove(branchItem.Element.DataStructure);
            target.Tree.Children.Add(branchItem.Element.DataStructure);
        }
Ejemplo n.º 8
0
        public async Task <IActionResult> UpdateBranch(BranchView branchView)
        {
            var branchUpdate = await _context.branches.FindAsync(branchView.Id);

            if (branchUpdate == null)
            {
                return(NotFound());
            }
            branchUpdate.ID             = branchView.Id;
            branchUpdate.BranchName     = branchView.BranchName;
            branchUpdate.BranchLocation = branchView.BranchLocation;
            branchUpdate.BranchPhone    = branchView.BranchPhone;
            branchUpdate.NoofEmployees  = branchView.NoofEmployees;

            try
            {
                _context.branches.Update(branchUpdate);
                _context.SaveChangesAsync();
            }
            catch (Exception e)
            {
                throw e;
            }

            return(NoContent());
        }
Ejemplo n.º 9
0
 private void LoadSelectedBranch()
 {
     if (SelectedBranch != null)
     {
         CurrentBranch = BranchView.SelectedRows.First();
         BranchView.Refresh();
         LoadBranch(SelectedBranch);
     }
 }
Ejemplo n.º 10
0
        public void Branch()
        {
            TasBranch branch = CreateBranch();

            Movie.AddBranch(branch);
            BranchView.RowCount = Movie.BranchCount;
            CurrentBranch       = Movie.BranchCount - 1;
            BranchView.Refresh();
            Tastudio.RefreshDialog();
        }
Ejemplo n.º 11
0
 private void BranchView_MouseMove(object sender, MouseEventArgs e)
 {
     if (BranchView.CurrentCell?.RowIndex == null || BranchView.CurrentCell.Column == null)
     {
         Screenshot.FadeOut();
     }
     else if (BranchView.CurrentCell.Column.Name == BranchNumberColumnName)
     {
         BranchView.Refresh();
     }
 }
Ejemplo n.º 12
0
 private void LoadSelectedBranch()
 {
     if (SelectedBranch != null)
     {
         int index = BranchView.SelectedRows.First();
         Movie.CurrentBranch = index;
         LoadBranch(SelectedBranch);
         BranchView.Refresh();
         GlobalWin.OSD.AddMessage("Loaded branch " + Movie.CurrentBranch.ToString());
     }
 }
Ejemplo n.º 13
0
 private void BranchView_CellDropped(object sender, InputRoll.CellEventArgs e)
 {
     if (e.NewCell != null && e.NewCell.IsDataCell && e.OldCell.RowIndex.Value < Movie.BranchCount)
     {
         int currenthash = Movie.BranchHashByIndex(Movie.CurrentBranch);
         Movie.SwapBranches(e.OldCell.RowIndex.Value, e.NewCell.RowIndex.Value);
         int newindex = Movie.BranchIndexByHash(currenthash);
         Movie.CurrentBranch = newindex;
         BranchView.SelectRow(newindex, true);
     }
 }
Ejemplo n.º 14
0
        /// <summary>
        /// 根据拓扑数据显示布线图
        /// </summary>
        private void ShowGraph(BranchView obj)
        {
            this.Dispatcher.Invoke((Action)(() =>
            {
                LayoutDocument doc = new LayoutDocument();
                WireGraph graph = null;
                bool left = true, right = true;
                doc.Title = obj.GraphName;
                switch (obj.GraphType)
                {
                case GraphType.VccToGndGraph:
                    {
                        left = true; right = true;
                        break;
                    }

                case GraphType.VccToCFGraph:
                    {
                        left = true; right = false;
                        break;
                    }

                case GraphType.CFToGndGraph:
                    {
                        left = true; right = false;
                        break;
                    }

                case GraphType.CompleteGraph:
                    {
                        left = true; right = false;
                        break;
                    }
                }
                LayoutContent other = ShowPanel.Children.FirstOrDefault(p => p.Title.Equals(doc.Title));
                if (other != null)
                {
                    other.IsActive = true;
                    return;
                }
                ShowPanel.Children.Add(doc);
                doc.IsActive = true;
                if (obj.page == null)
                {
                    graph = new WireGraph(obj, left, right);
                    obj.page = graph;
                }
                else
                {
                    graph = (WireGraph)obj.page;
                }
                doc.Content = graph;
            }));
        }
Ejemplo n.º 15
0
 public WireGraph(BranchView view, bool left, bool right)
 {
     InitializeComponent();
     this.observer = view.Observer;
     this.view     = view;
     drawGraph(view.Nodes, left, right);
     setSearchSource(view.Nodes);
     Messenger.Default.Register <string>(this, "LabelClicked", updateLabel);
     Messenger.Default.Register <string>(this, "PowClicked", updatePowMark);
     Messenger.Default.Register <ISet <INotifyComponentChanged> >(this, "ShowConductRoute", showConductRoute);
 }
Ejemplo n.º 16
0
 private void BranchView_MouseMove(object sender, MouseEventArgs e)
 {
     if (BranchView.CurrentCell == null || !BranchView.CurrentCell.RowIndex.HasValue || BranchView.CurrentCell.Column == null)
     {
         //not sure if we need to explicitly hide the screenshot here as well
     }
     else if (BranchView.CurrentCell.Column.Name == BranchNumberColumnName)
     {
         BranchView.Refresh();
     }
 }
Ejemplo n.º 17
0
 private void BranchView_MouseMove(object sender, MouseEventArgs e)
 {
     if (BranchView.CurrentCell == null || !BranchView.CurrentCell.RowIndex.HasValue || BranchView.CurrentCell.Column == null)
     {
         CloseScreenShotPopUp();
     }
     else if (BranchView.CurrentCell.Column.Name == BranchNumberColumnName)
     {
         BranchView.Refresh();
     }
 }
Ejemplo n.º 18
0
        public void Branch()
        {
            TasBranch branch = CreateBranch();

            Movie.NewBranchText = "";             // reset every time it's used
            Movie.AddBranch(branch);
            BranchView.RowCount = Movie.BranchCount;
            Movie.CurrentBranch = Movie.BranchCount - 1;
            BranchView.Refresh();
            Tastudio.RefreshDialog();
        }
Ejemplo n.º 19
0
 private void BranchView_MouseDown(object sender, MouseEventArgs e)
 {
     if (e.Button == MouseButtons.Left)
     {
         if (BranchView.CurrentCell != null && BranchView.CurrentCell.IsDataCell &&
             BranchView.CurrentCell.Column.Name == BranchNumberColumnName)
         {
             BranchView.DragCurrentCell();
         }
     }
 }
 public void SelectBranchExternal(int slot)
 {
     if (GetBranch(slot) != null)
     {
         BranchView.SelectRow(slot, true);
         BranchView.Refresh();
     }
     else
     {
         NonExistentBranchMessage(slot);
     }
 }
Ejemplo n.º 21
0
 private void LoadSelectedBranch()
 {
     if (SelectedBranch != null)
     {
         int index = BranchView.SelectedRows.First();
         //if (Movie.CurrentBranch == index) // if the current branch was edited, we should allow loading it. some day there might be a proper check
         //	return;
         Movie.CurrentBranch = index;
         LoadBranch(SelectedBranch);
         BranchView.Refresh();
         GlobalWin.OSD.AddMessage("Loaded branch " + Movie.CurrentBranch.ToString());
     }
 }
Ejemplo n.º 22
0
        private static bool IsOwnParent(BranchView target, BranchView item)
        {
            var parent = XamarinHelpers.GetTypedElementFromParents <BranchView>(target.Parent);

            while (parent != null)
            {
                if (parent == item)
                {
                    return(true);
                }
                parent = XamarinHelpers.GetTypedElementFromParents <BranchView>(parent.Parent);
            }

            return(false);
        }
 public void UpdateBranchExternal(int slot = -1)
 {
     if (slot != -1)
     {
         if (GetBranch(slot) != null)
         {
             BranchView.SelectRow(slot, true);
         }
         else
         {
             NonExistentBranchMessage(slot);
             return;
         }
     }
     UpdateBranchToolStripMenuItem_Click(null, null);
 }
Ejemplo n.º 24
0
        public void SelectBranchExternal(int slot)
        {
            if (Tastudio.FloatEditingMode)
            {
                return;
            }

            if (GetBranch(slot) != null)
            {
                BranchView.SelectRow(slot, true);
                BranchView.Refresh();
            }
            else
            {
                NonExistentBranchMessage(slot);
            }
        }
Ejemplo n.º 25
0
        private void BranchView_MouseDown(object sender, MouseEventArgs e)
        {
            UpdateBranchButton.Enabled         =
                LoadBranchButton.Enabled       =
                    JumpToBranchButton.Enabled =
                        SelectedBranch != null;

            BranchesContextMenu.Close();

            if (e.Button == MouseButtons.Left)
            {
                if (BranchView.CurrentCell != null && BranchView.CurrentCell.IsDataCell &&
                    BranchView.CurrentCell.Column.Name == BranchNumberColumnName)
                {
                    BranchView.DragCurrentCell();
                }
            }
        }
Ejemplo n.º 26
0
        private static void MoveElementInsideTree(BranchView target, BranchView item)
        {
            if (target.Element.DataPoint != null || item.Element.DataPoint != null)
            {
                Debug.WriteLine("Reordering of data points not implemented yet");
                return;
            }

            if (IsOwnParent(target, item))
            {
                Debug.WriteLine("You shouldn't become your own grandmother.");
                return;
            }

            // If immediate element of parent, move to top
            if (target.Element.DataStructure.Children.Contains(item.Element.DataStructure))
            {
                var ix = target.Element.DataStructure.Children.IndexOf(item.Element.DataStructure);
                if (ix == 0)
                {
                    return;
                }
                target.Element.DataStructure.Children.Move(ix, 0);
                return;
            }

            var parent = XamarinHelpers.GetTypedElementFromParents <BranchView>(item.Parent);

            if (parent != null)
            {
                parent.Element.DataStructure.Children.Remove(item.Element.DataStructure);
            }
            else
            {
                var treeParent = XamarinHelpers.GetTypedElementFromParents <DataTreeView>(item.Parent);
                if (treeParent == null)
                {
                    Debug.WriteLine("Unknown parent");
                    return;
                }
                treeParent.Tree.Children.Remove(item.Element.DataStructure);
            }
            target.Element.DataStructure.Children.Add(item.Element.DataStructure);
        }
Ejemplo n.º 27
0
        public void LoadBranchExternal(int slot = -1)
        {
            if (Tastudio.FloatEditingMode)
            {
                return;
            }

            if (slot != -1)
            {
                if (GetBranch(slot) != null)
                {
                    BranchView.SelectRow(slot, true);
                }
                else
                {
                    NonExistentBranchMessage(slot);
                    return;
                }
            }
            LoadBranchToolStripMenuItem_Click(null, null);
        }
Ejemplo n.º 28
0
        private void RemoveBranchContextMenuItem_Click(object sender, EventArgs e)
        {
            if (SelectedBranch != null)
            {
                int index = BranchView.SelectedRows.First();
                if (index == CurrentBranch)
                {
                    CurrentBranch = -1;
                }

                Movie.RemoveBranch(SelectedBranch);
                BranchView.RowCount = Movie.BranchCount;

                if (index == BranchView.SelectedRows.FirstOrDefault())
                {
                    BranchView.ClearSelectedRows();
                }

                BranchView.Refresh();
            }
        }
Ejemplo n.º 29
0
 public void Restart()
 {
     BranchView.DeselectAll();
     BranchView.RowCount = Movie.BranchCount;
     BranchView.Refresh();
 }
Ejemplo n.º 30
0
 public void UpdateValues()
 {
     BranchView.RowCount = Movie.BranchCount;
     BranchView.Refresh();
 }